Day 1
This commit is contained in:
parent
635e02a515
commit
374dfcbc1d
26
2020/day1.ahk
Normal file
26
2020/day1.ahk
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#SingleInstance, Force
|
||||||
|
|
||||||
|
answer := 2020
|
||||||
|
vals := [puzzle input in comma delimited form here]
|
||||||
|
p1 := False
|
||||||
|
p2 := False
|
||||||
|
Loop {
|
||||||
|
Random, a, vals.MinIndex(), vals.MaxIndex()
|
||||||
|
Random, b, vals.MinIndex(), vals.MaxIndex()
|
||||||
|
Random, c, vals.MinIndex(), vals.MaxIndex()
|
||||||
|
; Part 1:
|
||||||
|
x := vals[a]+vals[b]
|
||||||
|
; Part 2:
|
||||||
|
y := vals[a]+vals[b]+vals[c]
|
||||||
|
If (InStr(x, answer) and p1 = False){
|
||||||
|
MsgBox,, Part 1, % vals[a] "+" vals[b] "=" x "`n" vals[a] "x" vals[b] "=" vals[a]*vals[b]
|
||||||
|
p1 := True
|
||||||
|
}
|
||||||
|
If (InStr(y, answer) and p2 = False){
|
||||||
|
MsgBox,, Part 2, % vals[a] "+" vals[b] "+" vals[c] "=" y "`n" vals[a] "x" vals[b] "x" vals[c] "=" vals[a]*vals[b]*vals[c]
|
||||||
|
p2 := True
|
||||||
|
}
|
||||||
|
If (p1 and p2){
|
||||||
|
Break
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user