Frequencies from recorded rolls

A simulation produces a record of results. Turn a record of die rolls into frequencies and an estimate.

What to build

A program that summarises die rolls.

Requirements

  • Print six lines face F: C for F from 1 to 6, with C the number of rolls showing F.
  • Then print estimate E: the share of rolls that are 5 or 6, to 3 decimal places (the true probability is 1/3).

Input

One line: the rolls, whole numbers from 1 to 6 separated by spaces.

Output

Seven lines.

Constraints

1 to 10000 rolls.

Example

Input:

1 2 3 4 5 6

Output:

face 1: 1
face 2: 1
face 3: 1
face 4: 1
face 5: 1
face 6: 1
estimate 0.333

Why it works

The relative frequency of an event in recorded trials is the simulation's estimate of its probability, and the table of counts shows how evenly the faces came up.

Examples

Example 1 · Input
1 2 3 4 5 6
Expected output
face 1: 1
face 2: 1
face 3: 1
face 4: 1
face 5: 1
face 6: 1
estimate 0.333
Example 2 · Input
6 6 6 1
Expected output
face 1: 1
face 2: 0
face 3: 0
face 4: 0
face 5: 0
face 6: 3
estimate 0.750

Prompts inside input() are ignored when checking, so input("n: ") is fine.

Hints

Hint 1

Count each face with a list of six counters or collections.Counter.

Hint 2

The estimate is the share of rolls that are 5 or 6.

Solution

Show one correct solution (try it yourself first)
rolls = list(map(int, input().split()))
for face in range(1, 7):
    print(f"face {face}: {rolls.count(face)}")
high = sum(1 for r in rolls if r >= 5)
print(f"estimate {high / len(rolls):.3f}")

Lesson: Simulation: estimating probabilities by experiment →