Problem 9 (200pts)

Implement max_scoring_num_rolls, which runs an experiment to determine the number of rolls (from 1 to 10) that gives the maximum average score for a turn. Your implementation should use make_averaged and roll_dice.

If two numbers of rolls are tied for the maximum average score, return the lower number. For example, if both 3 and 6 achieve a maximum average score, return 3.

You might find it useful to read the doctest and the example shown in the doctest for this problem before doing the unlocking test.

Important: In order to pass all of our tests, please make sure that you are testing dice rolls starting from 1 going up to 10, rather than from 10 to 1.

Before writing any code, unlock the tests to verify your understanding of the question:

$ python ok -q 09 -u

Once you are done unlocking, begin implementing your solution. You can check your correctness with:

$ python ok -q 09

The provided run_experiments function calls max_scoring_num_rolls(six_sided) and prints the result. You will likely find that rolling 6 dice maximizes the result of roll_dice using six-sided dice.

To call this function and see the result, run hog.py with the -r flag:

$ python hog.py -r

In addition, run_experiments compares various strategies to always_roll(6). You are welcome to change the implementation of run_experiments as you wish. Note that running experiments with picky_strategy and swine_strategy will not have accurate results until you implement them in the next two problems.

Some of the experiments may take up to a minute to run. You can always reduce the number of trials in your call to make_averaged to speed up experiments.

Running experiments won't affect your score on the project.