Stair-climbing puzzle: Difference between revisions
Content added Content deleted
(→{{header|AutoHotkey}}: small obvious correction, plus whitespace fix) |
(Added TI-83 BASIC) |
||
Line 499: | Line 499: | ||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
The setup (note that <code>level</code> and <code>steps</code> are not used elsewhere, but are great for |
The setup (note that <code>level</code> and <code>steps</code> are not used elsewhere, but are great for testing�) |
||
<lang tcl>set level 41 |
<lang tcl>set level 41 |
||
set prob 0.5001 |
set prob 0.5001 |
||
Line 525: | Line 525: | ||
while {![step]} step-up-rec |
while {![step]} step-up-rec |
||
}</lang> |
}</lang> |
||
=={{header|TI-83 BASIC}}== |
|||
TI-83 BASIC doesn't have functions (only subroutines), so a variable must be used as the return value for <code>prgmSTEP</code>. Set <code>A</code> to <code>1</code> before calling to display the offset from the stair it was called from (store in D). Set <code>B</code> to <code>1</code> to pause after each attempt. <code>C</code> is the return variable for <code>prgmSTEP</code>. <code>D</code> is the stair it is on (only used for display, and not used if <code>A</code> isn't <code>1</code>). |
|||
<code>prgmSTEP</code>: |
|||
<lang ti83b>If rand>.5:Then |
|||
0→C |
|||
Disp "FALL" |
|||
If A=1:Then |
|||
D-1→D |
|||
Disp D |
|||
End |
|||
Else |
|||
1→C |
|||
Disp "CLIMB" |
|||
If A=1:Then |
|||
D+1→D |
|||
Disp D |
|||
End |
|||
End |
|||
If B=1 |
|||
Pause</lang> |
|||
<code>prgmSTEPUP</code>: |
|||
<lang ti83b>prgmSTEP |
|||
While C=0 |
|||
prgmSTEPUP |
|||
prgmSTEP |
|||
End</lang> |