White RoomNEW White Room DSA

Two Cakes, Six Customers

A bakery has 2 cakes left and 6 people in line. Each person independently wants a cake with probability 0.2 and otherwise buys bread. Nobody leaves disappointed when at most 2 of the 6 want cake.

This program answers the question by summing over every wanting pattern:

from itertools import product

p = 0.0
for pattern in product([0, 1], repeat=6):   # 1 = this customer wants cake
    prob = 1.0
    for wants in pattern:
        prob *= 0.2 if wants else 0.8
    if sum(pattern) <= 2:
        p += prob

print(round(p, 3))

What does it print? Answer format: round to 3 decimal places.