We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Successively approximation is superb for this problem. I got this idea from thinking about Newton Raphson and chemical equilibrium. Start with an initial arbitrary (in my case, all 0.025) list of probabilities (probability of the player standing on this corresponding square at the end of the last round).
Use another list to accumulate the probabilities of the player ending up standing in each square which are generated in this round, by iterating each of the squares. Divide them by a common divisor to make sure their sum is . After certain approximating iterations we would end up with a fairly stable list of probabilities.
I picked approximating iterations for any input, and it passes all test cases within 0.08s. That's Python.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #84: Monopoly odds
You are viewing a single comment's thread. Return to all comments →
Successively approximation is superb for this problem. I got this idea from thinking about Newton Raphson and chemical equilibrium. Start with an initial arbitrary (in my case, all
0.025
) list of probabilities (probability of the player standing on this corresponding square at the end of the last round).Use another list to accumulate the probabilities of the player ending up standing in each square which are generated in this round, by iterating each of the squares. Divide them by a common divisor to make sure their sum is . After certain approximating iterations we would end up with a fairly stable list of probabilities.
I picked approximating iterations for any input, and it passes all test cases within 0.08s. That's Python.