summaryrefslogtreecommitdiff
path: root/07/test.scm
diff options
context:
space:
mode:
authorPrefetch2024-03-26 21:41:32 +0100
committerPrefetch2024-03-26 21:41:32 +0100
commit757b98fb30e75d7698a0986184d0303224db156c (patch)
treeb0f01bf59bb6fc7d26b55f6edd611393f8f8bf62 /07/test.scm
parent1fbb07c54523c7a576bfff1cb689e155dd55f15a (diff)
Publish days 6-10
Diffstat (limited to '07/test.scm')
-rw-r--r--07/test.scm43
1 files changed, 43 insertions, 0 deletions
diff --git a/07/test.scm b/07/test.scm
new file mode 100644
index 0000000..ed299f8
--- /dev/null
+++ b/07/test.scm
@@ -0,0 +1,43 @@
+(import (chezscheme))
+
+; Where the magic happens
+(import (lib))
+
+; My quick-and-dirty unit testing framework (copied for each day)
+(define (run-test name proc input expected)
+ (let ((result (proc input)))
+ (if (equal? result expected)
+ (printf "\x1b;[32;1mPASS\x1b;[0m: ~a\n"
+ name)
+ (printf "\x1b;[31;1mFAIL\x1b;[0m: ~a: got ~a, expected ~a\n"
+ name result expected))))
+
+(define input '("pbga (66)"
+ "xhth (57)"
+ "ebii (61)"
+ "havc (66)"
+ "ktlj (57)"
+ "fwft (72) -> ktlj, cntj, xhth"
+ "qoyq (66)"
+ "padx (45) -> pbga, havc, qoyq"
+ "tknk (41) -> ugml, padx, fwft"
+ "jptl (61)"
+ "ugml (68) -> gyxo, ebii, jptl"
+ "gyxo (61)"
+ "cntj (57)"))
+
+(printf "Part 1 tests:\n")
+
+(define (test-part1 name input expected)
+ (run-test name solve-part1 input expected))
+
+(test-part1 "part 1 example 1"
+ input "tknk")
+
+(printf "Part 2 tests:\n")
+
+(define (test-part2 name input expected)
+ (run-test name solve-part2 input expected))
+
+(test-part2 "part 2 example 1"
+ input 60)