Jump to content

Water collected between towers: Difference between revisions

m
→‎version 3: changed/added whitespace and comments, used a different glyph [≈] for the rainwater collected.
(Added Sidef)
m (→‎version 3: changed/added whitespace and comments, used a different glyph [≈] for the rainwater collected.)
Line 916:
This REXX version shows a scale and a representation of the towers and water collected.
<lang rexx>/*REXX program calculates and displays the amount of rainwater collected between towers.*/
call tower 1 5 3 7 2
call tower 5 3 7 2 6 4 5 9 1 2
call tower 2 6 3 5 2 8 1 4 2 2 5 3 5 7 4 1
call tower 5 5 5 5
call tower 5 6 7 8
call tower 8 7 7 6
call tower 6 7 10 7 6
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
Line 940:
do c=0 to # /*construct the plot+scale for display.*/
do h=1 for t.c+w.c; glyph='█' /*maybe show a floor of some tower(s). */
if h>t.c then glyph='~' if h>t.c then glyph='≈' /* " " rainwater between towers. */
if c==0 then p.h=overlay(right(h, 9), p.h, 1 ) /*place the tower scale*/
else p.h=overlay(glyph , p.h, 10+c) /*build the tower. */
end /*h*/
end /*c*/
p.1=overlay(w.00 'units of rainwater collected', p.1, 15+#) /*append the text.*/
do z=t.0 by -1 to 0; say p.z /*display the various tower floors of& towerswater.*/
end /*z*/
return</lang>
Line 953:
7 █
6 █
5 █~██≈█
4 █~██≈█
3 ███
2 ████
Line 961:
9 █
8 █
7 █~~~~██≈≈≈≈█
6 █~█~~██≈█≈≈█
5 █~█~█~███≈█≈█≈██
4 █~█~█████≈█≈████
3 ███~███████≈████
2 ████████~█████████≈█
1 ██████████ 14 units of rainwater collected
 
8 █
7 █~~~~~~~██≈≈≈≈≈≈≈█
6 █~~~█~~~~~~~██≈≈≈█≈≈≈≈≈≈≈█
5 █~█~█~~~~█~███≈█≈█≈≈≈≈█≈██
4 █~█~█~█~~█~████≈█≈█≈█≈≈█≈███
3 ███~█~█~~████████≈█≈█≈≈█████
2 ██████≈████████
2 ██████~████████
1 ████████████████ 35 units of rainwater collected
 
Cookies help us deliver our services. By using our services, you agree to our use of cookies.