This commit is contained in:
David Daily 2020-12-02 16:46:23 -06:00
parent 374dfcbc1d
commit d48ccb2d2e
2 changed files with 22 additions and 1 deletions

19
2020/day2.ahk Normal file
View File

@ -0,0 +1,19 @@
#SingleInstance, Force
loc := A_ScriptDir "\data2.txt"
file := FileOpen(loc, "r")
Loop {
If (file.AtEOF)
Break
data := StrSplit(file.ReadLine(), [A_Tab, A_Space, "-"], " `t:-")
; 1:first number 2:second number 3:letter 4:password
reg := "^[^" data[3] "]*(" data[3] "[^" data[3] "]*){" data[1] "," data[2] "}$"
StrReplace(data[4],data[3],,test) ; String Replace to get # of LETTER
If (test>=data[1] AND test<=data[2]) ; Check if # of LETTER is within the bounds
p1++
If ((subStr(data[4], data[1], 1) == data[3])^(subStr(data[4], data[2], 1) == data[3])) ; Please don't make me explain this one
p2++
}
file.Close()
MsgBox % "Part 1: " p1 "`nPart 2: " p2

View File

@ -2,4 +2,6 @@
Advent of Code repo for stuff and things
[Advent of code website](https://adventofcode.com)
[Advent of code website](https://adventofcode.com)
Made with the help of the wonderful members of the AHK discord, cause I'm not that smaht and its only day 2.