"no winner"

There is always a winner in this game. The coin is flipped until there is a winner. That could take 13 trillion flips, but the game is defined as continuing until there is a winner.

AssertNull 1,094 Practically a Posting Shark

"no winner"

There is always a winner in this game. The coin is flipped until there is a winner. That could take 13 trillion flips, but the game is defined as continuing until there is a winner.

xrjf 213 Posting Whiz Premium Member

Well, I'm just trying to clarify my ideas of the problem and I think I have progressed: just that, nothing else. So a last thought:

If first toss is H-c2-c3 let's see a bit of what happens depending on c2, c3, c4 and c5.

```
T=c2 | H=c3 | H=c4, THH A wins | H=c5 HHH, no winner
| T=c5 HHT, no winner
| T=c4 THT no winner | H=c5 HTH, no winner
| T=c5 HTT, no winner
| T=c3 | H=c4, TTH B wins | H=c5 THH, A should win but does
not because of res() re-initialization
.....
```

Minimalist 96 Posting Pro

O.K. if came across of being rude I do apologize as this was not the intention.

JamesCherrill commented: Well said +14

xrjf 213 Posting Whiz Premium Member

Your welcome.

AssertNull 1,094 Practically a Posting Shark

O.K. if came across of being rude I do apologize as this was not the intention.

Thank you. I appreciate that. Water under the bridge. No worries, no grudges. Moving on...

To the topic, I took trj's bets of THH vs. TTH and made a state machine graph, which I attach here. I come up with 2 to 1 odds that player 2 wins, or a 1/3 probability of player 1 winning. The current "state" is the relevant history of flips. Hopefully. Start state means no flips yet. From Start, if you flip heads, you stay at Start since both bet patterns start with Tails. Once you flip tails, you go to state T. From state T, you go to state TH if you flip Heads, TT if you flip tails. If you are in State TT, player 2 wins no matter what. Every flip of Tails just prolongs it. The first flip of Heads once you are in state TT makes player 2 win. Thus if you find yourself in TT, you are done.

For TH, if heads is flipped, player 1 wins. If TAILS is flipped, you end up with THT. THT is not in either bet, so knock off the leading T and you get HT. HT is in neigher bet, so knock off the leading H. You get state T. The state machine hopefully makes sense. Each state has two bracnches till you get a winner and the game stops.

From any state S, then state SH is defined as the next state if Heads is flipped. ST is the next state if Tails is flipped. Yougo from S to SH with 0.5 probability and S to ST with 0.5 probability given a fair coin.

Define p(S) as the probability player 1 wins given we are in State S.

Thus p(S) = 0.5p(SH) + 0.5p(ST).

See attached graph with some algebra. Note that if I remember my math right, 1/3 is (1/4 + 1/16 + 1/64 + 1/256 + ...).

xrjf 213 Posting Whiz Premium Member

xrjf 213 Posting Whiz Premium Member

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.