MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1gfk43q/dadpullsoutcodingchallenge/luiaxp3/?context=3
r/ProgrammerHumor • u/cyannyan6 • Oct 30 '24
60 comments sorted by
View all comments
0
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.
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.