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.
Since the winning score is 1, Player 2 gains no advantage to flipping multiple times and therefore each turn, his/her probability of winning is simply 0.5.
The probability of Player 2 winning on his/her first turn is 0.5 * 0.5 since Player 1 has to miss with probability 0.5 AND Player 2 has to hit with probability 0.5
The probability of Player 2 winning on his/her second turn is 0.5 * 0.5 * 0.5 * 0.5 since Player 1 has to miss, then Player 2 has to miss, then Player 1 has to miss, then Player 2 has to hit. The pattern continues for an arbitrary number of turns.
The probability of Player 2 winning on any of his/her turns is therefore the sum of the infinite sequence 1 / (2 ^ (2n + 2)) which is equal to 1/3.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #232: The Race
You are viewing a single comment's thread. Return to all comments →
The way I thought about it was this:
Since the winning score is 1, Player 2 gains no advantage to flipping multiple times and therefore each turn, his/her probability of winning is simply 0.5.
The probability of Player 2 winning on his/her first turn is 0.5 * 0.5 since Player 1 has to miss with probability 0.5 AND Player 2 has to hit with probability 0.5
The probability of Player 2 winning on his/her second turn is 0.5 * 0.5 * 0.5 * 0.5 since Player 1 has to miss, then Player 2 has to miss, then Player 1 has to miss, then Player 2 has to hit. The pattern continues for an arbitrary number of turns.
The probability of Player 2 winning on any of his/her turns is therefore the sum of the infinite sequence 1 / (2 ^ (2n + 2)) which is equal to 1/3.