DEV Community

Discussion on: Daily Challenge #240 - ATM

Collapse
 
mxb profile image
mxb

Implementation in Frink

// https://dev.to/thepracticaldev/daily-challenge-240-atm-109c
solve[amount] :=
{
  bills = [500, 200, 100, 50, 20, 10]
  count = 0

  if amount < 1 or amount > 1500
    return -1

  for b = bills
  {
    nbills = floor[amount / b]
    amount = amount - (nbills b)
    count = count + nbills
  }

  return count
}