Water collected between towers: Difference between revisions
Content added Content deleted
m (→{{header|Quackery}}: fast graphics) |
Drkameleon (talk | contribs) (added Arturo) |
||
Line 676: | Line 676: | ||
{{Out}} |
{{Out}} |
||
<syntaxhighlight lang="applescript">{2, 14, 35, 0, 0, 0, 0}</syntaxhighlight> |
<syntaxhighlight lang="applescript">{2, 14, 35, 0, 0, 0, 0}</syntaxhighlight> |
||
=={{header|Arturo}}== |
|||
<syntaxhighlight lang="arturo">cmax: function => [ |
|||
m: neg ∞ |
|||
map & 'x -> m:<=max @[m x] |
|||
] |
|||
vmin: $ => [map couple & & => min] |
|||
vsub: $ => [map couple & & 'p -> p\0 - p\1] |
|||
water: function [a][ |
|||
sum vsub vmin reverse cmax reverse a cmax a a |
|||
] |
|||
loop [ |
|||
[1, 5, 3, 7, 2], |
|||
[5, 3, 7, 2, 6, 4, 5, 9, 1, 2], |
|||
[2, 6, 3, 5, 2, 8, 1, 4, 2, 2, 5, 3, 5, 7, 4, 1], |
|||
[5, 5, 5, 5], |
|||
[5, 6, 7, 8], |
|||
[8, 7, 7, 6], |
|||
[6, 7, 10, 7, 6] |
|||
] 'a -> print [a "->" water a]</syntaxhighlight> |
|||
{{out}} |
|||
<pre>[1 5 3 7 2] -> 2 |
|||
[5 3 7 2 6 4 5 9 1 2] -> 14 |
|||
[2 6 3 5 2 8 1 4 2 2 5 3 5 7 4 1] -> 35 |
|||
[5 5 5 5] -> 0 |
|||
[5 6 7 8] -> 0 |
|||
[8 7 7 6] -> 0 |
|||
[6 7 10 7 6] -> 0</pre> |
|||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |