User:Thebigh/mysandbox: Difference between revisions

more
(more)
(more)
Line 6:
 
If you escaped, run 10,000 tests and print the average time taken and the average final length of the staircase.
 
==header|Fermat==
<lang fermat>
time_tot:=0; {we'll keep track of the total time and steps across all the trials}
steps_tot:=0;
!!('Seconds ','Steps behind ','Steps ahead');
for trial = 1 to 10 do
s_behind:=0; {initialise staircase and runner for this trial}
stair_len:=100;
time:=0;
while s_behind < stair_len do
s_behind:=s_behind + 1;
for wiz = 1 to 5 do
stair_len:=stair_len + 1; {evil wizard creates a step} {(mwaahahaha)}
if (Rand|stair_len) < s_behind then
s_behind:=s_behind + 1;
fi
od;
time:=time+1; {another second has passed}
if trial = 1 and 599<time and time<610 then
!!(time, ' ', s_behind, ' ',stair_len-s_behind)
fi;
od;
time_tot:=time_tot+time;
steps_tot:=steps_tot+stair_len;
od;
 
!!(time_tot/10000);
!!(steps_tot/10000);</lang>
{{out}}<pre>
Seconds Steps behind Steps ahead
600 2102 998
601 2105 1000
602 2110 1000
603 2116 999
604 2121 999
605 2126 999
606 2131 999
607 2137 998
608 2142 998
609 2145 1000
29037 / 10000
29237 / 2000
</pre>
Seconds Steps behind Steps ahead
600 2125 975
601 2129 976
602 2132 978
603 2136 979
604 2142 978
605 2146 979
606 2151 979
607 2156 979
608 2162 978
609 2166 979
3697083 / 1250
3722083 / 250
</pre>
 
==header|FreeBASIC==
781

edits