Maximum triangle path sum: Difference between revisions

m
→‎{{header|Factor}}: Use v+ instead of [ + ] 2map
m (→‎{{header|Factor}}: Use unclip-slice for better efficiency)
m (→‎{{header|Factor}}: Use v+ instead of [ + ] 2map)
Line 865:
 
=={{header|Factor}}==
<lang factor>USING: grouping.extras io.encodings.utf8 io.files kernel math
math.order math.parser math.vectors prettyprint sequences splitting ;
splitting ;
IN: rosetta-code.maximum-triangle-path-sum
 
Line 874 ⟶ 875:
 
: max-triangle-path-sum ( seq -- n )
<reversed> unclip-slice [ swap [ max ] 2clump-map v+ ]
[ swap [ max ] 2clump-map [ + ] 2map ] reduce first ;
 
"triangle.txt" parse-triangle max-triangle-path-sum .</lang>
1,808

edits