Created
December 3, 2018 14:00
-
-
Save wojkos/d6e607817dcf43535276d6289e38a785 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
@cache = [] | |
def cache_recursion_solution(n, k) | |
end |
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
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 |
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
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