Water collected between towers: Difference between revisions

Added Quackery.
m (syntax highlighting fixup automation)
(Added Quackery.)
Line 3,048:
 
[6,7,10,7,6] -> 0</pre>
 
=={{header|Quackery}}==
 
<syntaxhighlight lang="Quackery"> [ $ "turtleduck.qky" loadfile ] now!
 
[ dup 0 = iff drop done
dup 2 times
[ 25 * 1 walk
1 4 turn
25 1 walk
1 4 turn ] ] is bar ( [ --> )
 
[ tuck size unrot
-1 4 turn
witheach
[ dup
' [ 158 151 147 ]
dup colour
fill bar
dup 25 * 1 fly
dip
[ behead
' [ 162 197 208 ]
dup colour
fill bar ]
-25 * 1 fly
1 4 turn
25 1 fly
-1 4 turn ]
drop
1 4 turn
-25 * 1 fly ] is chart ( [ [ --> )
 
[ [] 0 rot witheach
[ max dup dip join ]
drop ] is rightmax ( [ --> [ )
 
[ reverse
rightmax
reverse ] is leftmax ( [ --> [ )
 
[ [] unrot
witheach
[ over i^ peek
min swap dip join ]
drop ] is mins ( [ --> [ )
 
[ [] unrot
witheach
[ over i^ peek
- swap dip join ]
drop ] is diffs ( [ --> [ )
 
[ 0 swap witheach + ] is sum ( [ --> n )
 
[ dup 2dup rightmax
swap leftmax
mins diffs chart ] is task1 ( [ --> )
 
[ dup dup rightmax
swap leftmax
mins diffs sum ] is task2 ( [ --> )
 
turtle
 
' [ 5 3 7 2 6 4 5 9 1 2 ] task1
 
' [ [ 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 ] ]
 
witheach [ task2 echo sp ]</syntaxhighlight>
 
{{out}}
 
[[File:Quackery Water collected between towers.png|frame|center]]
 
<pre>2 14 35 0 0 0 0</pre>
 
 
=={{header|Racket}}==
1,462

edits