X-Git-Url: http://git.jkinsey.net/?p=adventofcode2019.git;a=blobdiff_plain;f=test%2Fadventofcode2019%2Fday18_test.clj;fp=test%2Fadventofcode2019%2Fday18_test.clj;h=e962b491e5cd1d23a78ef8fa2aea9eff8fa0e2e3;hp=0000000000000000000000000000000000000000;hb=7a710645a2234dcb568c2e971b5b0367217d0ea8;hpb=21ab31d9418c308ae58d73141184be8b42a11ab8 diff --git a/test/adventofcode2019/day18_test.clj b/test/adventofcode2019/day18_test.clj new file mode 100644 index 0000000..e962b49 --- /dev/null +++ b/test/adventofcode2019/day18_test.clj @@ -0,0 +1,54 @@ +(ns adventofcode2019.day18-test + (:require [clojure.test :refer :all] + [adventofcode2019.day18 :refer :all])) + +(deftest test-build-world + (is (= {:p [5 1] + :t #{[1 1] [2 1] [4 1] [5 1] [6 1] [7 1]} + :k {\a [7 1], \b [1 1]} + :d {\A [3 1]}} + (build-world ["#########" + "#b.A.@.a#" + "#########"])))) + +(deftest test-pathing + (is (= 2 (path-between ((build-world ["#########" + "#b.A.@.a#" + "#########"]) :t) + [5 1] [7 1])))) + +(deftest test-accessible + (is (= {\a 2} + (accessible (build-world ["#########" + "#b.A.@.a#" + "#########"]))))) + +(deftest examples + (is (= 8 (acquire-all-keys (build-world ["#########" + "#b.A.@.a#" + "#########"])))) + (is (= 86 (acquire-all-keys (build-world ["########################" + "#f.D.E.e.C.b.A.@.a.B.c.#" + "######################.#" + "#d.....................#" + "########################"])))) + (is (= 132 (acquire-all-keys (build-world ["########################" + "#...............b.C.D.f#" + "#.######################" + "#.....@.a.B.c.d.A.e.F.g#" + "########################"])))) + #_(is (= 136 (acquire-all-keys (build-world ["#################" + "#i.G..c...e..H.p#" + "########.########" + "#j.A..b...f..D.o#" + "########@########" + "#k.E..a...g..B.n#" + "########.########" + "#l.F..d...h..C.m#" + "#################"])))) + (is (= 81 (acquire-all-keys (build-world ["########################" + "#@..............ac.GI.b#" + "###d#e#f################" + "###A#B#C################" + "###g#h#i################" + "########################"])))))