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

Home > Probability
Fateful Fickle Fifteen (Posted on 2005-03-24) Difficulty: 3 of 5
There is a bag with balls numbered 1 to 9. Two players take turns at randomly taking a ball from the bag. If a player gets three balls that sum fifteen, he wins. Getting fifteen with more or less balls doesn't count.

What are the odds of the first player winning? Of a draw?

See The Solution Submitted by Old Original Oskar!    
Rating: 4.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Confirmation of Charlie's results. Comment 9 of 9 |
(In reply to another approach -- solution by Charlie)

Here are my results, identical to what Charlie found.
Player One could win when drawing ball 5, 7, or 9
Player Two could win when drawing ball 6 or 8

5 34560 7 95904 9 81792 overall 212256
6 31968 8 72576 overall 104544
tie 46080
212256 104544
0.584920634920635 0.28809523809523807 0.12698412698412698
sum of all fractions 1.0

---------------------
from itertools import permutations

def winner(aList):
    """ boolean: determine from a list or tuple of integers if 3 of them sum to 15 """
    wins = [[1, 5, 9],
     [1, 6, 8],
     [2, 4, 9],
     [2, 5, 8],
     [2, 6, 7],
     [3, 4, 8],
     [3, 5, 7],
     [4, 5, 6]]
    if len(aList) < 3:
        return False
    for w in wins:
        if w[0] in aList and w[1] in aList and w[2] in aList:
            return True
    return False

bs = [i for i in range(1,10)]
ways15 = []
waysNot = []
for perm in permutations(bs,3):
    temp = sorted(list(perm))
    if sum(perm) == 15:
        if temp not in ways15:
            ways15.append(temp)
    else:
        if temp not in waysNot:
            waysNot.append(temp)

winOne = 0
winTwo = 0
winSeven = 0
winEight = 0
winNine = 0
draw = 0

for perm in permutations(bs,9):
    first = perm[:3]
    if winner(first):
        winOne += 1
        continue
    second = perm[3:6]
    if winner(second):
        winTwo += 1
        continue
    seven = first + (perm[6],)
    if winner(seven):
        winSeven += 1
        continue
    eight = second + (perm[7],)
    if winner(eight):
        winEight += 1
        continue
    nine = seven + (perm[8],)
    if winner(nine):
        winNine += 1
        continue
    draw += 1
            

total = winOne + winTwo + winSeven + winEight + winNine + draw
OneWins = winOne +  winSeven +  winNine
TwoWins = winTwo +  winEight

print('5',winOne, '7', winSeven, '9', winNine, 'overall', winOne+winSeven+winNine)
print('6',winTwo, '8', winEight, 'overall', winTwo+winEight)
print('tie',draw)
print(OneWins, TwoWins)
print(OneWins/total, TwoWins/total, draw/total)
print('sum of all fractions', OneWins/total+TwoWins/total+draw/total)

  Posted by Larry on 2022-07-20 13:51:28
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 (10)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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