diff --git a/Slightly less terrible b/Slightly less terrible new file mode 100644 index 0000000..b07a20c --- /dev/null +++ b/Slightly less terrible @@ -0,0 +1,8 @@ +from random import randint +from statistics import mean + +number_of_sides = int(input("How many sides on your dice? ")) + +avg = mean([max(randint(1,number_of_sides), randint(1,number_of_sides)) for _ in range(10**6)]) + +print(f"Average result of rolling two and taking the highest is about {avg}") diff --git a/higher-of-two-rolls.py b/higher-of-two-rolls.py deleted file mode 100644 index e75264b..0000000 --- a/higher-of-two-rolls.py +++ /dev/null @@ -1,15 +0,0 @@ -import random - -number_of_sides = int(input("How many sides on your dice? ")) - -sum_of_results = 0.0 - -trials = 0 -while trials < 10**6: - sum_of_results += max([int(random.random()*number_of_sides)+1,int(random.random()*number_of_sides)+1]) - trials += 1 - -print("Average result of rolling two and taking the highest is about {0}".format(sum_of_results/trials)) - - -