Let's make a few observations:
- You should never be clicking next and then clicking random. If you are going to click random, you need to do it before you click next.
- This implies that the general strategy should be to click random until you get "close enough" to click next until you get to 42.
Let's investigate how close is close enough where you can start clicking next.
By using probability.py, we use a recursive function to accurately describe the probability that you will fare better by clicking Random, instead of clicking next every time. This formula was reasoned out by the following intuition (loosely based on my memory of an inductive proof):
- If your starting number is 42, you obviously are finished, and never should click random
- If your starting number is 41, you obviously should click next, and never click random. Clicking random will, at best match the number of moves it takes to click next and get to 42
- If your starting number is 40, then you can start to think about clicking random.
- It's possible that you click random and get 42. This is the only scenario in which you will get to 42 more efficiently than by clicking next twice.
- We know that, by the binomial distribution where p = 0.01, k = 1, n = 1, that this probability is 1%.
- That's not very likely to happen, so it's in our long term, average, best interest to click next twice, rather than risk it.
- If your starting number is 39, then you again can think about clicking random.
- Using the same logic, there are 2 outcomes of clicking random (41, 42) that will guarantee that you use less moves than clicking next
- If you random into 40, then you will use the same number of moves, so you should have just clicked next.
- We can model the probability that clicking random is better by adding this probability of your next roll guaranteeing a better result (2%) to the probability of not rolling a better result (98%) multiplied by the probability of getting a better result when you would have been at 40 (1%)
- this results in a probability of performing better than next being 2.98%.
- Hey that's a better chance! But still not good enough to warrant clicking random.
- By continuing this pattern, we can calc the probability for every number between 0 and 42.
- This is shown above (probability_output.txt).
The main point of the above file is to find the "tolerance" on which it stops becoming worth it to click "Random". By reading the probabilities, we can see that it is better on average to click random until you roll a 30, at which point it becomes slightly better to click next until you get to 42.