Problem 129489 · easy · Phase 01 Prerequisites & Setup

Pig Dice Turns

nested loops · conditionals · lists

In the dice game Pig a player rolls a die several times per turn. turns is a list of turns, each a list of die rolls (1-6). A turn scores the sum of its rolls, unless any roll in it is a 1, in which case the whole turn scores 0. Return the player's total over all turns.

Examples

Input:  turns = [[3, 4], [6, 1], [2, 2, 2]]
Output: 13
Explanation: 7 + 0 + 6

Input:  turns = [[1]]
Output: 0

Constraints

  • 0 <= len(turns) <= 500, each turn has 0 to 20 rolls.

Goals

  • Process a list of lists with a nested loop
  • Detect a spoiling condition inside a turn and score it zero
Starting Python…