Finished
11# Score categories.
22# Change the values as you see fit.
3YACHT = None
4ONES = None
5TWOS = None
6THREES = None
7FOURS = None
8FIVES = None
9SIXES = None
10FULL_HOUSE = None
11FOUR_OF_A_KIND = None
12LITTLE_STRAIGHT = None
13BIG_STRAIGHT = None
14CHOICE = None
3YACHT = lambda dice: 50 if len(set(dice)) == 1 else 0
4ONES = lambda dice: dice.count(1) * 1
5TWOS = lambda dice: dice.count(2) * 2
6THREES = lambda dice: dice.count(3) * 3
7FOURS = lambda dice: dice.count(4) * 4
8FIVES = lambda dice: dice.count(5) * 5
9SIXES = lambda dice: dice.count(6) * 6
10FULL_HOUSE = lambda dice: sum(dice) if sorted(dice.count(d) for d in set(dice)) == [2, 3] else 0
11FOUR_OF_A_KIND = lambda dice: sum(d * 4 for d in set(dice) if dice.count(d) >= 4)
12LITTLE_STRAIGHT = lambda dice: 30 if sorted(dice) == [1, 2, 3, 4, 5] else 0
13BIG_STRAIGHT = lambda dice: 30 if sorted(dice) == [2, 3, 4, 5, 6] else 0
14CHOICE = lambda dice: sum(dice)
1515
1616
1717def score(dice, category):
18 pass
18 # Edge Case: Invalid number of dice
19 if len(dice) != 5:
20 raise ValueError("Exactly five dice are required")
21
22 # Edge Case: Invalid dice values (not between 1 and 6)
23 if any(d < 1 or d > 6 for d in dice):
24 raise ValueError("Dice values must be between 1 and 6 inclusively")
25
26 # Edge Case: Invalid category
27 if category is None:
28 raise ValueError("Category cannot be None")
29
30 return category(dice)
31
32# Handled Edge Cases: Invalid number of dice, Invalid dice values (not between 1 and 6), Invalid category
Test NameStatus
test_big_straight
Pass
test_big_straight_as_little_straight
Pass
test_choice
Pass
test_fives
Pass
test_four_in_order_but_not_a_little_straight
Pass
test_four_of_a_kind
Pass
test_four_of_a_kind_is_not_a_full_house
Pass
test_fours
Pass
test_full_house_is_not_four_of_a_kind
Pass
test_full_house_three_small_two_big
Pass
test_full_house_two_small_three_big
Pass
test_little_straight
Pass
test_little_straight_as_big_straight
Pass
test_minimum_is_1_maximum_is_5_but_not_a_little_straight
Pass
test_no_ones
Pass
test_no_pairs_but_not_a_big_straight
Pass
test_no_pairs_but_not_a_little_straight
Pass
test_not_yacht
Pass
test_ones
Pass
test_ones_out_of_order
Pass
test_sixes
Pass
test_two_pair_is_not_a_full_house
Pass
test_twos
Pass
test_yacht
Pass
test_yacht_as_choice
Pass
test_yacht_can_be_scored_as_four_of_a_kind
Pass
test_yacht_counted_as_threes
Pass
test_yacht_is_not_a_full_house
Pass
test_yacht_of_3s_counted_as_fives
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.