Stair-climbing puzzle: Difference between revisions

(Added AHK)
Line 55:
Climbed up to 0
Climbed up to 1
</pre>
=={{header|ALGOL 68}}==
{{trans|Ada}}
 
{{works with|ALGOL 68|Standard - no extensions to language used}}
 
{{works with|ALGOL 68G|Any - tested with release [http://sourceforge.net/projects/algol68/files/algol68g/algol68g-1.18.0/algol68g-1.18.0-9h.tiny.el5.centos.fc11.i386.rpm/download 1.18.0-9h.tiny]}}
 
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8.8d.fc9.i386]}}
<lang Algol68> PROC step up = VOID:
BEGIN
WHILE NOT step DO
step up
OD
END # step up #;</lang>The following is a test program simulating step: <lang Algol68>
PROC scaffolding = VOID:
BEGIN
INT level := 0;
 
PROC step = BOOL:
BEGIN
IF random > 0.5 THEN
level +:= 1;
print(("Climbed up to",level, new line));
TRUE
ELSE
level -:= 1;
print(("Fell down to",level, new line));
FALSE
FI
END # step #;
 
PROC step up = VOID:
BEGIN
WHILE NOT step DO
step up
OD
END # step up #;
 
step up
END # scaffolding #;
 
scaffolding</lang>
Sample output:
<pre>
Fell down to -1
Fell down to -2
Climbed up to -1
Climbed up to +0
Climbed up to +1
</pre>