Day 2
This commit is contained in:
parent
374dfcbc1d
commit
d48ccb2d2e
19
2020/day2.ahk
Normal file
19
2020/day2.ahk
Normal 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
|
@ -2,4 +2,6 @@
|
|||||||
|
|
||||||
Advent of Code repo for stuff and things
|
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.
|
||||||
|
Loading…
Reference in New Issue
Block a user