Loading...

The Yahtzee Scorer

A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
medium
Seniority
junior, mid

Problem

Our game analytics engine scores Yahtzee hands. Write a function called yahtzee_score that takes a list of 5 dice values (1-6) and a category string, and returns the score. Categories: 'ones' through 'sixes' (sum of matching dice), 'three_of_a_kind' (sum of all dice if 3+ match, else 0), 'four_of_a_kind' (sum of all dice if 4+ match, else 0), 'full_house' (25 if three of one and two of another, else 0), 'chance' (sum of all dice).

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a sandboxed Docker environment and grades it instantly.