Advertisement
Guest User

Untitled

a guest
Dec 10th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. L := FileOpen("day10_input.txt","R").Read()
  2. Sort, L, N
  3.  
  4. List := StrSplit(L,"`r`n")
  5. List.insertAt(1,0)
  6.  
  7. total := Pointer := 1
  8.  
  9. Loop {
  10.   if (Pointer >= List.Length())
  11.     break
  12.   count := CountConsecutive(List,Pointer)
  13.   total *= GetMultiplier(count-1)
  14.   Pointer += count + 1
  15. }
  16.  
  17. Msgbox % total
  18.  
  19. CountConsecutive(List,index) {
  20.   Loop {
  21.     if (List[index + A_Index] != List[index + A_Index - 1] + 1)
  22.       Return % A_Index - 1
  23.   }
  24.   Return 1
  25. }
  26.  
  27. GetMultiplier(n) {
  28.   return n<1?1:n+GetMultiplier(n-1)
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement