Anonymous user
Maximum triangle path sum: Difference between revisions
→{{header|Perl 6}}: some explanation of zip semantics
(→{{header|Perl 6}}: add entry) |
(→{{header|Perl 6}}: some explanation of zip semantics) |
||
Line 58:
=={{header|Perl 6}}==
Yes, the <tt>Zmax</tt> produces an extra wraparound value, but the <tt>Z+</tt> throws it away, since a zip operator will trim to the shorter list. We ought to be able to use <tt>[Z+]=</tt> as an assignment operator here, but rakudo has a bug. Note also we can use the <tt>Zmax</tt> metaoperator form because <tt>max</tt> is define as an infix in Perl 6.
<lang perl6>my @rows = slurp("triangle.txt").lines.map: { [.words] }
Line 68 ⟶ 69:
{{out}}
<pre>1320</pre>
=={{header|Python}}==
A simple mostly imperative solution:
|