2009-01-22から1日間の記事一覧

Rubyで最短ルート数を探す 〜Rubyでオイラープロジェクトを解こう!Problem15

Problem 15 - Project Eulerより Starting in the top left corner of a 2×2 grid, there are 6 routes (without backtracking) to the bottom right corner. How many routes are there through a 20×20 grid? 2×2グリッドの左上の角からスタートした場合、…

Rubyで桁の合計を求める 〜Rubyでオイラープロジェクトを解こう!Problem16

Problem 16 - Project Eulerより and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number ? の各桁の合計は 3 + 2 + 7 + 6 + 8 = 26である。 の各桁の合計はいくつか。 算数的でないけど def sum_of_digits(n) …