Long stairs: Difference between revisions

J draft
(Added AutoHotkey)
(J draft)
Line 403:
</pre>
 
=={{header|J}}==
<lang J>stairsim=:{{
t=. 0 NB. fifths of a second
echo ;_8 _16 _20{.each 'seconds';'steps to top';'steps from bottom'
for_trial.i.1e4 do.
loc=. {.'min max'=. 0 100
while. loc < max do.
if. 0=5|t=.t+1 do.
loc=. loc+1
if.0=trial do.
if. 1=2999 3046 I.t do.
echo 8 16 20":(t%5),(max-loc),(loc-min)
end.
end.
end.
ins=. min+?max-min
if. ins < loc do. min=. min-1 else. max=. max+1 end.
end.
end.
echo 'Average steps taken: ',":t%5e4
echo 'Average length of staircase: ',":100+t%1e4
}}</lang>
 
Example run:<lang J> stairsim''
seconds steps to top steps from bottom
600 1142 1957
601 1142 1962
602 1141 1968
603 1141 1973
604 1142 1977
605 1143 1981
606 1143 1986
607 1143 1991
608 1144 1995
609 1144 2000
Average steps taken: 3026.43
Average length of staircase: 15232.2</lang>
=={{header|jq}}==
{{works with|jq}}
Line 475 ⟶ 512:
Average final length of staircase: 16159.81
</pre>
 
 
=={{header|Julia}}==
6,962

edits