diff --git a/app/main.py b/app/main.py index fa56336e..edba64bc 100644 --- a/app/main.py +++ b/app/main.py @@ -1 +1,19 @@ -# write your code here +import random +from collections import Counter + + +def flip_coin() -> dict: + cases = 10000 + amount = 10 + + result = [] + + for _ in range(cases): + heads = sum(random.choice([0, 1]) for _ in range(amount)) + result.append(heads) + + counts = Counter(result) + + percentage = {key: (value / cases) * 100 for key, value in counts.items()} + + return dict(sorted(percentage.items()))