This commit is contained in:
David Daily 2020-12-03 17:50:12 -06:00
parent d48ccb2d2e
commit 8625ee388e
1 changed files with 86 additions and 0 deletions

86
2020/day3.ahk Normal file
View File

@ -0,0 +1,86 @@
#SingleInstance, Force
loc := A_ScriptDir "\data3.txt"
file := FileOpen(loc, "r")
down := 1
right := 1
while !(file.AtEOF) {
data := StrSplit(file.ReadLine())
If (right > 31)
right -= 31
If (data[right] ~= "#")
p1++
down++
right += 3
}
file.Pos := 0
down := 1
right := 1
while !(file.AtEOF) {
data := StrSplit(file.ReadLine())
If (right > 31)
right -= 31
If (data[right] ~= "#")
p2a++
down++
right += 1
}
file.Pos := 0
down := 1
right := 1
while !(file.AtEOF) {
data := StrSplit(file.ReadLine())
If (right > 31)
right -= 31
If (data[right] ~= "#")
p2b++
down++
right += 3
}
file.Pos := 0
down := 1
right := 1
while !(file.AtEOF) {
data := StrSplit(file.ReadLine())
If (right > 31)
right -= 31
If (data[right] ~= "#")
p2c++
down++
right += 5
}
file.Pos := 0
down := 1
right := 1
while !(file.AtEOF) {
data := StrSplit(file.ReadLine())
If (right > 31)
right -= 31
If (data[right] ~= "#")
p2d++
down++
right += 7
}
file.Pos := 0
down := 1
right := 1
while !(file.AtEOF) {
skip := (down-1)*32
If !(file.Pos = skip){
file.ReadLine()
Continue
} Else
data := StrSplit(file.ReadLine())
If (right > 31)
right -= 31
If (data[right] ~= "#")
p2e++
down += 2
right++
}
file.Close()
MsgBox % "Part 1: " p1 "`nPart 2: " p2a "*" p2b "*" p2c "*" p2d "*" p2e " = " p2a*p2b*p2c*p2d*p2e