Score a dice pair
Roll two dice and sum them. If the two dice match, the pair doubles in value.
- The base score is the sum of both dice.
- When both dice show the same face, the total is doubled.
dice_pair(first_roll: int, second_roll: int) → int
Where you start
def dice_pair(first_roll: int, second_roll: int) -> int:
Worked examples
| Call | Result |
|---|---|
dice_pair(6, 6) | 24 |
dice_pair(3, 4) | 7 |
dice_pair(1, 1) | 4 |
dice_pair(2, 5) | 7 |
Hint
Sum first, then check for a double.
Reference solution in Python
def dice_pair(first_roll: int, second_roll: int) -> int:
total = first_roll + second_roll
if first_roll == second_roll:
total *= 2
return total