You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
268B

  1. import sys
  2. from itertools import combinations
  3. ns = [int(n) for n in sys.stdin.read().splitlines()]
  4. for a, b in combinations(ns, 2):
  5. if a + b == 2020:
  6. print(a * b)
  7. for a, b, c in combinations(ns, 3):
  8. if a + b + c == 2020:
  9. print(a * b * c)