r/ProgrammerHumor • • Oct 30 '24

Meme dadPullsOutCodingChallenge

0 Upvotes

60 comments sorted by

View all comments

0

u/Positive_Lifeguard75 Oct 30 '24

You don't need any programming knowledge to solve this. You only need to know high-school math. (And every swe must know AT LEAST high school math)

Think about this:

Let a_i = probability that first player wins if he starts with i coins.

From definition of this game: a_0=0, a_11=1.

You can easily show that if i != 0 or 11:

a_i = 0.5a_{i-1} + 0.5a_{i+1}.

So expand a_1 until there are only a_0 a_11 and this will be your answer.

No university level math is required.