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.

day1b.py 552B

123456789101112131415161718192021222324
  1. def comp(nums):
  2. for i in range(len(nums)):
  3. a = nums[i]
  4. r = nums[i+1:]
  5. for j in range(len(r)):
  6. b = r[j]
  7. s = r[j+1:]
  8. for k in range(len(s)):
  9. c = s[k]
  10. if a+b+c == 2020:
  11. return (a,b,c)
  12. return False
  13. def main():
  14. with open("input1a.txt") as file:
  15. lines = file.readlines()
  16. lines = [int(line.strip()) for line in lines]
  17. a,b,c = comp(lines)
  18. print(f"{a} * {b} * {c} = {a*b*c}")
  19. if __name__ == "__main__":
  20. main()