skaldjciareio

Advent of Code Day 5 Part 2

Dec 5th, 2020
153
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoEnv
  2. SetBatchLines, -1
  3. SetWorkingDir, %A_ScriptDir%
  4.  
  5. FileRead, read_file, Input.txt
  6.  
  7. seats := StrSplit(read_file, "`r`n")
  8.  
  9. SeatIds := []
  10.  
  11. For each, seat in seats
  12. {
  13.     row := 0
  14.     For i, char in StrSplit(SubStr(seat, 1, 7))
  15.     {
  16.         row += (2**(7-i)) * (char == "F" ? 0 : 1)
  17.     }
  18.     column := 0
  19.     For i, char in StrSplit(SubStr(seat, 8))
  20.     {
  21.         column += (2**(3-i)) * (char == "L" ? 0 : 1)
  22.     }
  23.     SeatIds[row * 8 + column] := 1
  24. }
  25.  
  26. result := 0
  27. Loop, % SeatIds.MaxIndex()
  28. {
  29.     If (A_Index > SeatIds.MinIndex())
  30.     {
  31.         If (SeatIds[A_Index] != 1)
  32.         {
  33.             result := A_Index
  34.             Break
  35.         }
  36.     }
  37.  
  38. }
  39.  
  40. Clipboard := result
  41. MsgBox, % result
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×