Predicting the next Math.random() in Java
- Added on 2023-08-13
- Page: http://franklinta.com/2014/08/31/predicting-the-next-math-random-in-java/
- See on Internet Archive
- #rand
A while back a friend of mine hosted a programming competition where you were given 9 random numbers one at a time and you had to guess the rank (the sorted position amongst the 9) of each as they are coming in. The goal was to submit a strategy in Java that will maximize the number of these games won. The best solution can guess right about 3.3% of the time but I figured if he was going to let me execute arbitrary code I might as well cheat and guess correctly 100% of the time. So I set out to