Long stairs: Difference between revisions

Added XPL0 example.
(Added Quackery.)
(Added XPL0 example.)
Line 1,225:
</pre>
</small>
 
=={{header|Wren}}==
{{trans|C}}
Line 1,275 ⟶ 1,276:
Average secs taken: 2914.465
Average final length of staircase: 14672.325
</pre>
 
=={{header|XPL0}}==
{{trans|C}}
<syntaxhighlight lang "XPL0">include xpllib; \for Print
 
int Trial, SecsTotal, StepsTotal; \keep track of time and steps over all trials
int SBehind, SLen, Wiz, Secs; \all variables related to individual trial
[SecsTotal:= 0; StepsTotal:= 0;
Print("Seconds steps behind steps ahead\n");
for Trial:= 1 to 10000 do \10000 attempts for the runner
[SBehind:= 0; SLen:= 100; Secs:= 0; \initialise this Trial
while SBehind < SLen do \as long as runner is still on stairs
[SBehind:= SBehind+1; \runner climbs a step
for Wiz:= 1 to 6 do \evil Wizard conjures five new steps
[if Ran(SLen) < SBehind then
SBehind:= SBehind+1; \maybe a new step is behind us
SLen:= SLen+1; \either way, the staircase is longer
];
Secs:= Secs+1; \one second has passed
if Trial=1 & 599<Secs & Secs<610 then
Print("%d %d %d\n", Secs, SBehind, SLen-SBehind);
];
SecsTotal:= SecsTotal + Secs;
StepsTotal:= StepsTotal + SLen;
];
Print("Average seconds taken: %f\n", float(SecsTotal)/10000.0);
Print("Average final length of staircase: %f\n", float(StepsTotal)/10000.0);
]</syntaxhighlight>
{{out}}
<pre>
Seconds steps behind steps ahead
600 2275 1425
601 2278 1428
602 2283 1429
603 2289 1429
604 2294 1430
605 2299 1431
606 2304 1432
607 2306 1436
608 2311 1437
609 2316 1438
Average seconds taken: 6625.81730
Average final length of staircase: 39854.90380
</pre>
291

edits