Solve hanging lantern problem: Difference between revisions
Content added Content deleted
(→{{header|Ruby}}: Add Ruby) |
|||
Line 1,393: | Line 1,393: | ||
===Directly computing the count=== |
===Directly computing the count=== |
||
Compute the count directly: |
|||
<syntaxhighlight lang="ruby" line>Factorial = Hash.new{|h, k| h[k] = k * h[k-1] } # a memoized factorial |
<syntaxhighlight lang="ruby" line>Factorial = Hash.new{|h, k| h[k] = k * h[k-1] } # a memoized factorial |
||
Factorial[0] = 1 |
Factorial[0] = 1 |