diff options
Diffstat (limited to '2019/day4/password.lp')
-rw-r--r-- | 2019/day4/password.lp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/2019/day4/password.lp b/2019/day4/password.lp new file mode 100644 index 0000000..b9a1f1a --- /dev/null +++ b/2019/day4/password.lp | |||
@@ -0,0 +1,17 @@ | |||
1 | %353096-843212 | ||
2 | digit(X) :- X = 0..9. | ||
3 | place(N) :- N = 1..6. | ||
4 | |||
5 | 1 {pass(Q,X) : digit(X)} 1 :- place(Q). | ||
6 | value(N) :- N = A + B * 10 + C * 100 + D * 1000 + E * 10000 + F * 100000, pass(6,A), pass(5,B), pass(4,C), pass(3,D), pass(2,E), pass(1,F). | ||
7 | |||
8 | :- value(N), N < 353096. | ||
9 | :- value(N), N > 843212. | ||
10 | |||
11 | :- pass(Q,X), pass(Q', Y), Q' = Q + 1, X > Y. | ||
12 | %:- pass(Q,X), pass(Q', Y), pass(QQ, Z), Q' = Q + 1, QQ = Q' + 1, X = Y, Y = Z. % I couldn't figure out this so I did 581 - 2 | ||
13 | |||
14 | %1 {target(X,Y,XX,YY) : dir(DX,DY), XX-X = DX*S, YY-Y = DY*S, size(S), area(XX,YY,_)} 1 :- number(X,Y,_). | ||
15 | |||
16 | #show pass/2. | ||
17 | #show value/1. | ||