Skip to content

Instantly share code, notes, and snippets.

@wojkos
Created December 3, 2018 14:00
Show Gist options
  • Save wojkos/d6e607817dcf43535276d6289e38a785 to your computer and use it in GitHub Desktop.
Save wojkos/d6e607817dcf43535276d6289e38a785 to your computer and use it in GitHub Desktop.
cassino_game created by wojkos - https://repl.it/@wojkos/cassinogame
@cache = []
def cache_recursion_solution(n, k)
end
require 'date'
load 'while_loop.rb'
load 'cache_recursion.rb'
# wined coins
n1 = 10
n2 = 183313133133233009123
# used all-in
k1 = 10
k2 = 23
p while_solution(n1, k1) == 4
a = Time.now
p while_solution(n2, k2) == 5
def while_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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment