]> localhost Git - adventofcode2019.git/blame - test/adventofcode2019/day14_test.clj
Add untested day14pt1 (but it has tests!)
[adventofcode2019.git] / test / adventofcode2019 / day14_test.clj
CommitLineData
e26daef4
JK
1(ns adventofcode2019.day14-test
2 (:require [clojure.test :refer :all]
3 [adventofcode2019.day14 :refer :all]))
4
5(deftest check-make-graph
6 (is (= (make-graph ["3 ORE => 2 ABC"
7 "3 ABC => 1 FUEL"])
8 {"ABC" {{"ORE" 3/2} 1}
9 "FUEL" {{"ABC" 3} 1}})))
10
11(deftest simple-exchange
12 (is (= 3 (find-lowest-exchange-rate {"FUEL" {{"ORE" 1, "ABC" 2, "DEF" 3} 1
13 {"ORE" 3} 1
14 {"GHI" 5/2} 1}}
15 "FUEL" "ORE"))))
16
17(deftest trading-up
18 (is (= 6 (find-lowest-exchange-rate (make-graph ["3 ORE => 2 ABC"
19 "3 ABC => 1 FUEL"])
20 "FUEL" "ORE"))))
21
22(deftest complicated-exchange
23 (is (= 2 (find-lowest-exchange-rate (make-graph ["3 ORE => 2 ABC"
24 "3 ABC => 1 FUEL"
25 "2 ORE => 1 CDE"
26 "1 CDE => 1 FUEL"])
27 "FUEL" "ORE"))))
28
29(deftest very-tricky-exchange
30 (is (= 3 (find-lowest-exchange-rate (make-graph ["3 ORE => 2 ABC"
31 "3 ABC => 1 FUEL"
32 "4 ORE => 1 CDE"
33 "1 CDE => 1 FUEL"
34 "3 ORE => 2 FGH"
35 "1 FGH => 1 IJK"
36 "1 IJK => 1 FUEL"])
37 "FUEL" "ORE"))))