Solve hanging lantern problem: Difference between revisions
Added Uiua solution
(→{{header|Ruby}}: Add Ruby) |
(Added Uiua solution) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1,393:
===Directly computing the count===
<syntaxhighlight lang="ruby" line>Factorial = Hash.new{|h, k| h[k] = k * h[k-1] } # a memoized factorial
Factorial[0] = 1
Line 1,418:
There are 73566121315513295589120000 ways to take these 8 columns down.
</pre>
=={{header|Uiua}}==
{{works with|Uiua|0.10.0}}
<syntaxhighlight lang="Uiua">
Fac ← /×+1⇡
Lant ← ÷⊃(/(×⊙Fac)|Fac/+)
Lant [1 2 3]
Lant [1 3 3]
Lant [1 3 3 5 7]
</syntaxhighlight>
{{out}}
<pre>
60
140
5587021440
</pre>
Line 1,424 ⟶ 1,441:
{{trans|Python}}
The result for n == 5 is slow to emerge.
<syntaxhighlight lang="
lantern = Fn.new { |n, a|
var count = 0
Line 1,459 ⟶ 1,476:
{{libheader|Wren-big}}
Alternatively, using library methods.
<syntaxhighlight lang="
import "./big" for BigInt
|