Water collected between towers: Difference between revisions

→‎{{header|Factor}}: Wasn't aware of cumulative max word from math.statistics vocab; use that instead of rolling my own.
(added Factor)
(→‎{{header|Factor}}: Wasn't aware of cumulative max word from math.statistics vocab; use that instead of rolling my own.)
Line 703:
 
=={{header|Factor}}==
<lang factor>USING: formatting kernel math math.order sequences ;math.statistics
sequences ;
IN: rosetta-code.water-towers
 
Line 715 ⟶ 716:
{ 6 7 10 7 6 }
}
 
: max-sweep ( seq -- seq' ) 0 [ max ] accumulate* ;
 
: area ( seq -- n )
[ ]dup [ cum-max-sweep ] [ <reversed> maxcum-sweepmax reverse ] tribi
[ min ] 2map swap [ - ] 2map sum ;
1,827

edits