diff options
author | Yigit Sever | 2021-12-13 10:40:39 +0300 |
---|---|---|
committer | Yigit Sever | 2021-12-13 10:40:39 +0300 |
commit | bf16b19b1f6deffd1983efca059db576f3b60ee5 (patch) | |
tree | 1262f68d8eb2c326684d395aebcd5a1cc0b0f748 /2019/day4/password.lp | |
parent | 74b27ccca31bb757c737dd7fdc02f513f57561b2 (diff) | |
download | aoc-bf16b19b1f6deffd1983efca059db576f3b60ee5.tar.gz aoc-bf16b19b1f6deffd1983efca059db576f3b60ee5.tar.bz2 aoc-bf16b19b1f6deffd1983efca059db576f3b60ee5.zip |
2019, tracking
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. | ||