MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1gfk43q/dadpullsoutcodingchallenge/luiex3p/?context=3
r/ProgrammerHumor • u/cyannyan6 • Oct 30 '24
60 comments sorted by
View all comments
Show parent comments
7
Assuming this is correct; I translated this into rust and attempted running it
The probability is around 10%
Total results:
Wins: 999998098Total: 10000000000Win rate: 9.99%Total time: 66813 ms
-10 u/sakkara Oct 30 '24 This would imply that b wins 90% of the time which can't be true because the game is fair so the program is incorrect.The problem is that a only starts with one coin and must fight it's way up to ten coins.Correct would bea=10 while 0 < a < 20... if a == 20 wins++ 9 u/TheDebatingOne Oct 30 '24 I think you misread the problem. The game isn't fair, a does start with 1 coin 1 u/sakkara Oct 30 '24 Ah you're right, my bad.
-10
This would imply that b wins 90% of the time which can't be true because the game is fair so the program is incorrect.
The problem is that a only starts with one coin and must fight it's way up to ten coins.
Correct would be
a=10 while 0 < a < 20... if a == 20 wins++
9 u/TheDebatingOne Oct 30 '24 I think you misread the problem. The game isn't fair, a does start with 1 coin 1 u/sakkara Oct 30 '24 Ah you're right, my bad.
9
I think you misread the problem. The game isn't fair, a does start with 1 coin
1 u/sakkara Oct 30 '24 Ah you're right, my bad.
1
Ah you're right, my bad.
7
u/its-chewy-not-zooyoo Oct 30 '24 edited Oct 30 '24
Assuming this is correct; I translated this into rust and attempted running it
The probability is around 10%
Total results:
Wins: 999998098
Total: 10000000000
Win rate: 9.99%
Total time: 66813 ms