4 ms·
Small nitpick with your code, you define a step to be both a forward/backward movement and going into the corner and coming back (which I would define as 2 step
by hervature 6y ago
Small nitpick with your code, you define a step to be both a forward/backward movement and going into the corner and coming back (which I would define as 2 steps because the person has to spend twice as long completing that). Also, you didn't use floats for the expected times. I have made both changes and added them here:
https://play.golang.org/p/dnCuu05Dupc https://play.golang.org/p/dnCuu05Dupc
- Taek 6y agoThanks for the changes! Interestingly enough, it seems to have had very little / no effect on the growth rate. Nice to have the precision in the outputs. Run with 5 million iterations per size: 15 size: 2514.4287536 steps (1.413 growth) 16 size: 3543.3930332 steps (1.409 growth) 17 size: 4986.7099864 steps (1.407 growth) 18 size: 7008.892906 steps (1.406 growth) 19 size: 9834.1058896 steps (1.403 growth) 20 size: 13806.3093036 steps (1.404 growth) Also seems like it converges to a value below sqrt2, which doesn't surprise me. The function that drives the behavior just doesn't feel like it would end up on an irrational number for a growth rate.