aboutsummaryrefslogtreecommitdiffstats
path: root/AoC2022/25
diff options
context:
space:
mode:
authorOscar Najera <hi@oscarnajera.com>2023-01-24 22:19:32 +0100
committerOscar Najera <hi@oscarnajera.com>2023-01-24 22:19:32 +0100
commit31aa0839953395f5998c7ec4350760cfebae6506 (patch)
tree055e6189d864543d827ca23415b4ee56dabb46ab /AoC2022/25
parentf23650fbae588817c22505f0efe91fed9bd4bc11 (diff)
downloadscratch-31aa0839953395f5998c7ec4350760cfebae6506.tar.gz
scratch-31aa0839953395f5998c7ec4350760cfebae6506.tar.bz2
scratch-31aa0839953395f5998c7ec4350760cfebae6506.zip
drop some repetition
Diffstat (limited to 'AoC2022/25')
-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)