final solution

This commit is contained in:
David Daily 2020-12-09 13:08:21 -06:00
parent 63a04a7af5
commit bd144cb3f8
1 changed files with 22 additions and 11 deletions

View File

@ -4,6 +4,28 @@ file := FileOpen(loc, "r")
binID := []
decID := []
while !(file.AtEOF){
line := file.ReadLine()
RegExMatch(line, "\S*", line)
line := RegExReplace(line, "F|L", "0")
line := RegExReplace(line, "B|R", "1")
binID.Push(line)
decID.Push(Dec(line))
}
SortArray(binID)
SortArray(decID)
dialog("Part 1: " binID[binID.MaxIndex()] " | " decID[decID.MaxIndex()])
next := decID[decID.MinIndex()]
for k, v in decID
If (v = next){
next := v + 1
} Else {
dialog("Part 2: " v - 1)
ExitApp
}
dialog(str){
MsgBox, 1,, %str%
@ -11,17 +33,6 @@ dialog(str){
Run, day5.ahk
}
while !(file.AtEOF){
line := file.ReadLine()
line := RegExReplace(line, "F|L", "0")
line := RegExReplace(line, "B|R", "1")
binID.Push(line)
decID.Push(Dec(line))
}
SortArray(binID, "D")
SortArray(decID, "D")
dialog("Part 1: " binID[binID.MinIndex()] "`n" decID[decID.MinIndex()])
Dec(x){
b:=StrLen(x),r:=0
loop,parse,x