Advertisement
Guest User

Untitled

a guest
Dec 9th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. List := StrSplit(FileOpen("day9_input.txt","R").Read(),"`r`n")
  2.  
  3. preamble := 25
  4.  
  5. Loop % List.Length() {
  6.   if (A_Index <= preamble)
  7.     continue
  8.   if !GetValidSum(List,A_Index,preamble)
  9.     MsgBox % "Line: " A_Index "`nNumber: " List[A_Index]
  10. }
  11.  
  12. GetValidSum(array,line,preamble) {
  13.   Loop % preamble {
  14.     Loop1_Index := A_Index
  15.     Loop % preamble {
  16.       if (Loop1_Index == A_Index)
  17.         continue
  18.       if (array[line - preamble - 1 + A_Index] + array[line - preamble - 1 + Loop1_Index] == array[line])
  19.         return true
  20.     }
  21.   }
  22.   return false
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement