Skip to content

Instantly share code, notes, and snippets.

@barreyro
Created May 23, 2015 23:25
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barreyro/a0c0f67729e54b2fac05 to your computer and use it in GitHub Desktop.
Save barreyro/a0c0f67729e54b2fac05 to your computer and use it in GitHub Desktop.
Have the function CoinDeterminer(num) take the input, which will be an integer ranging from 1 to 250, and return an integer output that will specify the least number of coins, that when added, equal the input integer. Coins are based on a system as follows: there are coins representing the integers 1, 5, 7, 9, and 11. So for example: if num is 1…
def CoinDeterminer(num)
return num if num < 5
count = num / 11
if (num%11).even?
return count + 2
else
return count + 1
end
end
@hasnain-eng
Copy link

2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment