Last active
December 3, 2018 13:33
-
-
Save wojkos/72e2b1d142029dfec004eef0302d757c to your computer and use it in GitHub Desktop.
cassino_game created by wojkos - https://repl.it/@wojkos/cassinogame
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# wined coins | |
n1 = 10 | |
n2 = 18 | |
# used all-in | |
k1 = 10 | |
k2 = 2 | |
def solution(n, k) | |
steps = 0 | |
while n > 1 | |
if n.even? and k > 0 | |
n /= 2 | |
else | |
n -= 1 | |
end | |
steps += 1 | |
end | |
steps | |
end | |
p solution(n1, k1) == 4 | |
p solution(n2, k2) == 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment