I tested this with code and ended up with right around what Jonathan Allan suggests in his answer. I simulated a million games a few times, and the results are:
You won 19.07%, 19.15%, 19.14% of the games.
That's assuming my (python2.7
) code is correct, of course.
import random
def roll():
return random.choice([2,3,3,4,4,4,5,5,5,5,6,6,6,6,6,7,7,7,7,7,7,8,8,8,8,8,9,9,9,9,10,10,10,11,11,12])
def game():
count = 0
rolls = []
while True:
rolls.append(roll())
if count >= 1:
if (rolls[count] == 7) and (rolls[count-1] == 7):
winner = "A"
break
if count >= 2:
if (rolls[count] > rolls[count-1]) and (rolls[count-1] > rolls[count-2]):
winner = "B"
break
count += 1
# print "Winner: %s" % winner
# print rolls
return winner
def games(n):
game_number = 1
count_a = 0
count_b = 0
while game_number <= n:
result = game()
if result == "A":
count_a += 1
if result == "B":
count_b += 1
game_number += 1
print "A won %i and B won %i of %i total." % (count_a,count_b,game_number-1)
print "A won %s percent of the games." %(str(100*float(count_a)/(game_number-1)))
This isn't intended to be the answer, just posting this for those who want to give it a try.