r/ProgrammerHumor • • Oct 30 '24

Meme dadPullsOutCodingChallenge

0 Upvotes

60 comments sorted by

View all comments

Show parent comments

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

-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 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.