""" Use this file to develop and test your Assignment 3 functions S0, 2020.""" def main(): print_header(8, "get_dice_score()") test_get_dice_score() #-------------------------------------------------- # 8888888888888888888888888888888888888888888888888 # Score a hand of random dice throws #-------------------------------------------------- """ In a dice rolling game a player's hand is made up of any number of random dice rolls and is valued in the following way: • In this game a run is a sequence of dice values starting from 1, e.g., 123, 12345, 1234, 1. • Each dice which is part of a run of dice starting from a 1 has a value which is equivalent to the dice number. The value of any dice which is part of a run is added to the score for the hand. • If there is no 1 in a hand of dice, the score for the whole hand is 0. • A hand of dice can contain more than one run. Study the following five example hands of dice and their corresponding valuation. Make sure you understand how the hands are valued: [5, 3, 2, 5, 4, 5, 6, 4, 3] has value 0 [3, 4, 1, 5, 3, 1, 4, 6] has value 2 (contains one run with just the dice [1] and a second run with just [1]) [5, 3, 2, 2, 6, 4, 5, 1, 4] has value 21 (contains one run with the dice [1, 2, 3, 4, 5, 6]) [2, 1, 1, 1, 2, 3, 3, 1, 3, 2] has value 19 (contains three separate runs with the dice [1, 2, 3] and a second run with the dice [1] [3, 4, 1, 5, 2, 1, 5, 1, 2, 3, 4, 6] has value 37 (contains one run with the dice [1, 2, 3, 4, 5, 6], a second run with [1, 2, 3, 4, 5] and a third run with the dice [1]) Complete the get_dice_score() function which is passed a list of dice rolls and returns the value of the hand according to the rules described above. """ def get_dice_score(list_of_dice): return 0 def test_get_dice_score(): print("1. score: ", get_dice_score([5, 3, 2, 5, 4, 5, 6, 4, 3])) print("2. score: ", get_dice_score([3, 4, 1, 5, 3, 1, 4, 6])) print("3. score: ", get_dice_score([5, 3, 2, 2, 6, 4, 5, 1, 4])) print("4. score: ", get_dice_score([2, 1, 1, 1, 2, 3, 3, 1, 3, 2])) print("5. score: ", get_dice_score([3, 4, 1, 5, 2, 1, 5, 1, 2, 3, 4, 6])) print("6. score: ", get_dice_score([])) list1 = [5, 3, 2, 5, 5, 6, 4, 3, 2, 1, 1, 5, 2, 5, 1] list1_copy = list1[::] list1_copy.sort() print("7. list: ", list1) score1 = get_dice_score(list1) print(" list_sorted: ", list1_copy) print(" score:", score1) print() list1 = [5, 3, 2, 6, 4, 5, 1, 4, 1, 2, 6, 4] list1_copy = list1[::] list1_copy.sort() print("8. list: ", list1) score1 = get_dice_score(list1) print(" list_sorted: ", list1_copy) print(" score:", score1) print() list1 = [2, 1, 1, 1, 2, 3, 3, 2, 3] list1_copy = list1[::] list1_copy.sort() print("9. list: ", list1) score1 = get_dice_score(list1) print(" list_sorted: ", list1_copy) print(" score:", score1) print() #-------------------------------------------------- # Print header lines #-------------------------------------------------- def print_header(number, text): text = str(number) + ". " + text print("-" * 30) print(str(number) * 30) print(text) print("-" * 30) main()