27 lines
687 B
AutoHotkey
27 lines
687 B
AutoHotkey
|
#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
|
||
|
}
|
||
|
}
|