# https://www.youtube.com/watch?v=hk9c7sJ08Bg

from collections import defaultdict

distribution = {0:1}


def print_sorted_by_key(counter):
    print('{')
    for key in sorted(counter.keys()):
        print(f'    {key}: {counter[key]},')
    print('}')

def convolve(distribution, equally_weighted_dice):
    d2 = defaultdict(float)
    for k,v in distribution.items():
        for red in equally_weighted_dice:
            d2[k+red] += v/len(equally_weighted_dice)
    return d2


for _ in range(20):
    distribution = convolve(distribution, [2,7,7,12,12, 17])
    distribution = convolve(distribution, [3,8,8,13,13, 18])


# print_sorted_by_key(distribution)

cumulative = defaultdict(float)
acc = 0
for k in sorted(distribution):
    acc += distribution[k]
    cumulative[k] = acc

# print_sorted_by_key(distribution)
# print(sum(distribution.values()))
print_sorted_by_key(cumulative)
