All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Probability
Flipping Even-Odd (Posted on 2011-01-28) Difficulty: 3 of 5
A game is played starting with 6 fair coins laid out with heads face up.

Each round consists of flipping all of the coins showing heads.

If an even number of coins is flipped and an even number of heads comes up the player loses.

If an odd number of coins is flipped and an odd number of heads comes up the player loses.

Rounds continue until the player either loses or reaches zero heads.

The player wins by getting to zero heads without losing.

What is the probability of winning this game?

Examples:
6→3→1 would be a loss.
6→3→0 would be a win.
6→0 would be a loss (even→even rule is applied first.)

No Solution Yet Submitted by Jer    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 2 of 3 |

    5   point 10
    9   for Nbr=6 to 1 step -1
   10    print Nbr,1-fnPLose(Nbr),(1-fnPLose(Nbr))/1
   11   next Nbr
   20    end
   30
   40    fnPLose(N)
   50       local Pl,H,Ph,Totph
   60     Pl=0:if N=0 then goto 150
   70     for H=0 to N
   80       Ph=combi(N,H)//2^N
   90       if H @ 2<>N @ 2 then
  100        :Pl=Pl+Ph*fnPLose(H)
  110       :else
  120        :Pl=Pl+Ph
  130       :endif
  140     next H
  150    return(Pl)

The above program, working recursively, again fills in Steve Herman's list of probabilites when starting with different numbers of tossed coins. In descending order, they are:

6       16793/131072   0.12812042236328125
5       563/4096       0.137451171875
4       23/128         0.1796875
3       7/32   0.21875
2       1/4    0.25
1       1/2    0.5

and, since the puzzle starts with 6 coins, the solution is 16793/131072 = 0.12812042236328125. All the decimal fractions are exact and terminating as all the denominators are powers of 2.

Simulation verification:

A million trials, via


FOR tr = 1 TO 1000000
  n = 6
  loss = 0: win = 0
  DO
    hds = 0
    FOR c = 1 TO n
      h = INT(RND(1) * 2)
      hds = hds + h
    NEXT
    IF hds MOD 2 = n MOD 2 THEN loss = 1 ELSE IF hds = 0 THEN win = 1
    n = hds
  LOOP UNTIL loss = 1 OR win = 1
  losses = losses + loss
  wins = wins + win
  PRINT wins, losses, tr
NEXT tr

result in 127731 wins.


  Posted by Charlie on 2011-01-28 18:15:08
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (6)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information