Water collected between towers: Difference between revisions
Content added Content deleted
(Added Sidef) |
m (→version 3: changed/added whitespace and comments, used a different glyph [≈] for the rainwater collected.) |
||
Line 916: | Line 916: | ||
This REXX version shows a scale and a representation of the towers and water collected. |
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.*/ |
<lang rexx>/*REXX program calculates and displays the amount of rainwater collected between towers.*/ |
||
call tower 1 5 3 7 2 |
call tower 1 5 3 7 2 |
||
call tower 5 3 7 2 6 4 5 9 1 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 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 5 5 5 |
||
call tower 5 6 7 8 |
call tower 5 6 7 8 |
||
call tower 8 7 7 6 |
call tower 8 7 7 6 |
||
call tower 6 7 10 7 6 |
call tower 6 7 10 7 6 |
||
exit /*stick a fork in it, we're all done. */ |
exit /*stick a fork in it, we're all done. */ |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
Line 940: | Line 940: | ||
do c=0 to # /*construct the plot+scale for display.*/ |
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). */ |
do h=1 for t.c+w.c; glyph='█' /*maybe show a floor of some tower(s). */ |
||
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*/ |
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. */ |
else p.h=overlay(glyph , p.h, 10+c) /*build the tower. */ |
||
end /*h*/ |
end /*h*/ |
||
end /*c*/ |
end /*c*/ |
||
p.1=overlay(w.00 'units of rainwater collected', p.1, 15+#) |
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 |
do z=t.0 by -1 to 0; say p.z /*display various tower floors & water.*/ |
||
end /*z*/ |
end /*z*/ |
||
return</lang> |
return</lang> |
||
Line 953: | Line 953: | ||
7 █ |
7 █ |
||
6 █ |
6 █ |
||
5 |
5 █≈█ |
||
4 |
4 █≈█ |
||
3 ███ |
3 ███ |
||
2 ████ |
2 ████ |
||
Line 961: | Line 961: | ||
9 █ |
9 █ |
||
8 █ |
8 █ |
||
7 |
7 █≈≈≈≈█ |
||
6 |
6 █≈█≈≈█ |
||
5 |
5 █≈█≈█≈██ |
||
4 |
4 █≈█≈████ |
||
3 |
3 ███≈████ |
||
2 |
2 ████████≈█ |
||
1 ██████████ 14 units of rainwater collected |
1 ██████████ 14 units of rainwater collected |
||
8 █ |
8 █ |
||
7 |
7 █≈≈≈≈≈≈≈█ |
||
6 |
6 █≈≈≈█≈≈≈≈≈≈≈█ |
||
5 |
5 █≈█≈█≈≈≈≈█≈██ |
||
4 |
4 █≈█≈█≈█≈≈█≈███ |
||
3 |
3 ███≈█≈█≈≈█████ |
||
2 ██████≈████████ |
|||
2 ██████~████████ |
|||
1 ████████████████ 35 units of rainwater collected |
1 ████████████████ 35 units of rainwater collected |
||