Advertisement
Armandur

Untitled

Dec 9th, 2020
562
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. linesFormatted = []
  2. with open("9 - input", 'r') as file:
  3.     lines = file.readlines()
  4.     for line in lines:
  5.         linesFormatted.append(int(line.strip("\n")))
  6.  
  7. start = 0
  8. while start+24 <= len(linesFormatted):
  9.     stop = start + 25
  10.     target = linesFormatted[stop]
  11.  
  12.     valid = False
  13.     for num1 in linesFormatted[start:stop]:
  14.         for num2 in linesFormatted[start:stop]:
  15.             if num1+num2 == target and num1 != num2:
  16.                 print(f"Sum exists for {target}")
  17.                 valid = True
  18.                 break
  19.         if valid:
  20.             break
  21.     if not valid:
  22.         print(f"Sum does not exist for {target}!")
  23.         break
  24.     start += 1
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement