Last active
July 2, 2016 08:52
-
-
Save shakemurasan/70f89235d2694a3bcbcec83eb6dfc27f to your computer and use it in GitHub Desktop.
プログラマ脳を鍛える数学パズル:Q15
This file contains 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 './process_measure.rb' | |
# ------------------------------ | |
def step_count(a, b, n) | |
if a + b >= n | |
@count += 1 if a + b == n | |
return | |
end | |
4.times do | |
a += 1 | |
tb = b | |
4.times do | |
tb += 1 | |
step_count(a, tb, n) | |
end | |
end | |
end | |
def step_step(n) | |
@count = 0 | |
step_count(0,0,n) | |
puts @count | |
end | |
measure_do { step_step(10) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment