Drill

ProblemsPython › games

Score a dice pair

easygamesPython

Roll two dice and sum them. If the two dice match, the pair doubles in value.

dice_pair(first_roll: int, second_roll: int) → int

Solve it in the editor →

Where you start

def dice_pair(first_roll: int, second_roll: int) -> int:
    

Worked examples

CallResult
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

The same problem in another language

More games problems in Python