We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
from math import gcd
total_outcomes = 6 * 6
favorable = 0
for i in range(1, 7):
for j in range(1, 7):
if i + j <= 9:
favorable += 1
print(f"{favorable // gcd(favorable,total_outcomes)} / {total_outcomes//gcd(favorable,total_outcomes)}")
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 2: Basic Probability Puzzles #1
You are viewing a single comment's thread. Return to all comments →
from math import gcd total_outcomes = 6 * 6 favorable = 0 for i in range(1, 7): for j in range(1, 7): if i + j <= 9: favorable += 1 print(f"{favorable // gcd(favorable,total_outcomes)} / {total_outcomes//gcd(favorable,total_outcomes)}")