Long stairs: Difference between revisions
Content added Content deleted
(Created Nim solution.) |
(Added Quackery.) |
||
Line 997: | Line 997: | ||
Ten thousand trials to top: |
Ten thousand trials to top: |
||
Mean time: 2780.502 secs. Mean height: 14002.51 |
Mean time: 2780.502 secs. Mean height: 14002.51 |
||
</pre> |
|||
=={{header|Quackery}}== |
|||
<syntaxhighlight lang="Quackery"> [ 0 100 0 |
|||
[ 5 times |
|||
[ 2dup swap |
|||
random > + |
|||
dip 1+ ] |
|||
1+ |
|||
rot 1+ unrot |
|||
2dup < until ] |
|||
drop ] is test ( --> n n ) |
|||
( and again, with progress report ) |
|||
[ 0 100 0 |
|||
[ rot dup dip unrot |
|||
dup 600 610 within iff |
|||
[ say "After " echo |
|||
say " seconds, " |
|||
2dup dup |
|||
say "Behind: " |
|||
echo |
|||
say " Ahead: " |
|||
- echo cr ] |
|||
else drop |
|||
5 times |
|||
[ 2dup swap |
|||
random > + |
|||
dip 1+ ] |
|||
1+ |
|||
rot 1+ unrot |
|||
2dup < until ] |
|||
drop 2drop ] is progress ( --> ) |
|||
progress |
|||
cr |
|||
0 0 10000 times |
|||
[ test rot + |
|||
unrot + swap ] |
|||
swap |
|||
say "Mean time: " |
|||
number$ char . swap -4 stuff echo$ cr |
|||
say "Mean stairs: " |
|||
number$ char . swap -4 stuff echo$ cr</syntaxhighlight> |
|||
{{out}} |
|||
<pre>After 600 seconds, Behind: 2187 Ahead: 913 |
|||
After 601 seconds, Behind: 2191 Ahead: 914 |
|||
After 602 seconds, Behind: 2197 Ahead: 913 |
|||
After 603 seconds, Behind: 2200 Ahead: 915 |
|||
After 604 seconds, Behind: 2204 Ahead: 916 |
|||
After 605 seconds, Behind: 2208 Ahead: 917 |
|||
After 606 seconds, Behind: 2211 Ahead: 919 |
|||
After 607 seconds, Behind: 2214 Ahead: 921 |
|||
After 608 seconds, Behind: 2218 Ahead: 922 |
|||
After 609 seconds, Behind: 2224 Ahead: 921 |
|||
Mean time: 3063.7808 |
|||
Mean stairs: 15418.9040 |
|||
</pre> |
</pre> |
||