Skip to content

Instantly share code, notes, and snippets.

@wojkos
Last active December 3, 2018 13:33
Show Gist options
  • Save wojkos/72e2b1d142029dfec004eef0302d757c to your computer and use it in GitHub Desktop.
Save wojkos/72e2b1d142029dfec004eef0302d757c to your computer and use it in GitHub Desktop.
cassino_game created by wojkos - https://repl.it/@wojkos/cassinogame
# 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