fork download
  1. # your code goes here
  2.  
  3. from itertools import product
  4. from fractions import Fraction
  5.  
  6. x = sum(a ^ b ^ c == 0 for a, b, c in product(range(1, 7), repeat=3))
  7.  
  8. print(x, 216 - x)
  9. print(Fraction(216 - x, x))
  10.  
  11. x = sum(a ^ b ^ c == 1 for a, b, c in product(range(1, 7), repeat=3))
  12.  
  13. print(x, 216 - x)
  14. print(Fraction(216 - x, x))
  15.  
  16. def f(x):
  17. return 6 - abs(x - 7)
  18.  
  19. x = sum(f(a) * f(b) * f(c) for a, b, c in product(range(1, 13), repeat=3) if a ^ b ^ c == 0)
  20. print(x, 6 ** 6 - x)
  21. print(Fraction(6 ** 6 - x, x))
  22.  
Success #stdin #stdout 0.04s 32608KB
stdin
Standard input is empty
stdout
24 192
8
28 188
47/7
1440 45216
157/5