aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AoC2022/25/solver.lisp21
1 files changed, 9 insertions, 12 deletions
diff --git a/AoC2022/25/solver.lisp b/AoC2022/25/solver.lisp
index 630cd03..9b94956 100644
--- a/AoC2022/25/solver.lisp
+++ b/AoC2022/25/solver.lisp
@@ -1,20 +1,17 @@
(ql:quickload '(fiveam uiop))
+(defconstant +num-encoding+
+ '((2 . #\2)
+ (1 . #\1)
+ (0 . #\0)
+ (-1 . #\-)
+ (-2 . #\=)))
+
(defun encode-char (c)
- (ecase c
- (2 #\2)
- (1 #\1)
- (0 #\0)
- (-1 #\-)
- (-2 #\=)))
+ (cdr (assoc c +num-encoding+)))
(defun decode-char (c)
- (ecase c
- (#\2 2)
- (#\1 1)
- (#\0 0)
- (#\- -1)
- (#\= -2)))
+ (car (rassoc c +num-encoding+)))
(defun parse-snafu (num)
(loop for a across (reverse num)