project-euler/205_dice_game.py

18 lines
338 B
Python

#!/usr/bin/env python3
from itertools import product
peter = [0]*(4*9 + 1)
colin = [0]*(6*6 + 1)
for p in product([1,2,3,4], repeat=9):
peter[sum(p)] += 1
for p in product([1,2,3,4,5,6], repeat=6):
colin[sum(p)] += 1
c = 0.0
for i, p in enumerate(peter):
c += p * sum(colin[:i])
print("{0:.7f}".format(c/(6**6 * 4**9)))