Skip to content

Instantly share code, notes, and snippets.

@shakemurasan
Last active July 2, 2016 08:52
Show Gist options
  • Save shakemurasan/70f89235d2694a3bcbcec83eb6dfc27f to your computer and use it in GitHub Desktop.
Save shakemurasan/70f89235d2694a3bcbcec83eb6dfc27f to your computer and use it in GitHub Desktop.
プログラマ脳を鍛える数学パズル:Q15
# -- 処理時間計測の自作ライブラリ --
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