Menu
CoddyTech

Recap: Dice Simulation

Part of the Data and Plots section of Coddy's Machine Learning journey. Lesson 19 of 60.

challenge icon

Challenge

Easy

A board game has 5 rounds of 3 dice. A round is strong when none of its dice is under 4. Simulate one game from the seed the program reads:

  1. Draw all 15 rolls (1 to 6) at once and fold them into rounds, one row per round, in draw order.
  2. Build a scoreboard: round number (1 to 5), highest die, lowest die.
  3. Print it as below, then count the strong rounds.

Here is the game for the seed 13:

Five rounds of three dice for seed 13 as a grid. Dice under 4 are shaded; rounds 1 and 5 have none shaded, so they are strong

Its output:

Round, highest, lowest:
[[1 6 5]
 [2 6 1]
 [3 6 2]
 [4 6 1]
 [5 5 4]]
Rounds with no die under 4: 2

Try it yourself

import numpy as np

seed = int(input())

# Write your code below

All lessons in Data and Plots

Practice on your own: Online Python compiler