Remix.run Logo
Simulating the Ladybug Clock Puzzle(austinhenley.com)
21 points by azhenley 2 days ago | 4 comments
archargelod an hour ago | parent | next [-]

> After 5000 runs, they were all 8.4-9.7%

This sample size is really small. I ran 100 million simulations in Nim[0] (takes around a minute). And distribution converges toward 9.09% on all positions equally:

    Average turns: 65.99609065001634
    Final position distribution:
     4: 9.095%
    11: 9.093%
     7: 9.091%
     3: 9.091%
    10: 9.090%
     9: 9.090%
     1: 9.090%
     8: 9.090%
     2: 9.090%
     6: 9.090%
     5: 9.089%
     0: 0.000%

[0] - https://play.nim-lang.org/#pasty=hwdfbsfh (reduced amount of runs to not abuse playground server resources)
ludwik 2 hours ago | parent | prev [-]

Shouldn't the code say:

    position = (position + direction + 1) % 12;
Or have I misunderstood something?
nulptr 36 minutes ago | parent | next [-]

The +12 there is so that % works correctly (ie the number never becomes negative)

LiamPowell an hour ago | parent | prev [-]

The +12 is to keep the number positive. The direction contains the movement so a +1 wouldn't make sense.