summaryrefslogtreecommitdiffstats
path: root/2019/day4/password.lp
diff options
context:
space:
mode:
authorYigit Sever2021-12-13 10:40:39 +0300
committerYigit Sever2021-12-13 10:40:39 +0300
commitbf16b19b1f6deffd1983efca059db576f3b60ee5 (patch)
tree1262f68d8eb2c326684d395aebcd5a1cc0b0f748 /2019/day4/password.lp
parent74b27ccca31bb757c737dd7fdc02f513f57561b2 (diff)
downloadaoc-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.lp17
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
2digit(X) :- X = 0..9.
3place(N) :- N = 1..6.
4
51 {pass(Q,X) : digit(X)} 1 :- place(Q).
6value(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.