]>
Commit | Line | Data |
---|---|---|
7a710645 JK |
1 | (ns adventofcode2019.day18-test |
2 | (:require [clojure.test :refer :all] | |
3 | [adventofcode2019.day18 :refer :all])) | |
4 | ||
5 | (deftest test-build-world | |
6 | (is (= {:p [5 1] | |
7 | :t #{[1 1] [2 1] [4 1] [5 1] [6 1] [7 1]} | |
8 | :k {\a [7 1], \b [1 1]} | |
9 | :d {\A [3 1]}} | |
10 | (build-world ["#########" | |
11 | "#b.A.@.a#" | |
12 | "#########"])))) | |
13 | ||
14 | (deftest test-pathing | |
15 | (is (= 2 (path-between ((build-world ["#########" | |
16 | "#b.A.@.a#" | |
17 | "#########"]) :t) | |
fa02619e JK |
18 | [5 1] [7 1]))) |
19 | (is (= 28 (path-between ((build-world ["########################" | |
20 | "#...............@.C.D.f#" | |
21 | "#.######################" | |
22 | "#.......a...c.d.A.e.F.g#" | |
23 | "########################"]) :t) | |
24 | [16 1] [12 3])))) | |
7a710645 JK |
25 | |
26 | (deftest test-accessible | |
27 | (is (= {\a 2} | |
28 | (accessible (build-world ["#########" | |
29 | "#b.A.@.a#" | |
30 | "#########"]))))) | |
31 | ||
32 | (deftest examples | |
33 | (is (= 8 (acquire-all-keys (build-world ["#########" | |
34 | "#b.A.@.a#" | |
35 | "#########"])))) | |
36 | (is (= 86 (acquire-all-keys (build-world ["########################" | |
37 | "#f.D.E.e.C.b.A.@.a.B.c.#" | |
38 | "######################.#" | |
39 | "#d.....................#" | |
40 | "########################"])))) | |
41 | (is (= 132 (acquire-all-keys (build-world ["########################" | |
42 | "#...............b.C.D.f#" | |
43 | "#.######################" | |
44 | "#.....@.a.B.c.d.A.e.F.g#" | |
45 | "########################"])))) | |
fa02619e JK |
46 | (is (= 136 (acquire-all-keys (build-world ["#################" |
47 | "#i.G..c...e..H.p#" | |
48 | "########.########" | |
49 | "#j.A..b...f..D.o#" | |
50 | "########@########" | |
51 | "#k.E..a...g..B.n#" | |
52 | "########.########" | |
53 | "#l.F..d...h..C.m#" | |
54 | "#################"])))) | |
7a710645 JK |
55 | (is (= 81 (acquire-all-keys (build-world ["########################" |
56 | "#@..............ac.GI.b#" | |
57 | "###d#e#f################" | |
58 | "###A#B#C################" | |
59 | "###g#h#i################" | |
60 | "########################"]))))) |