diff options
author | Oscar Najera <hi@oscarnajera.com> | 2023-01-24 22:19:32 +0100 |
---|---|---|
committer | Oscar Najera <hi@oscarnajera.com> | 2023-01-24 22:19:32 +0100 |
commit | 31aa0839953395f5998c7ec4350760cfebae6506 (patch) | |
tree | 055e6189d864543d827ca23415b4ee56dabb46ab | |
parent | f23650fbae588817c22505f0efe91fed9bd4bc11 (diff) | |
download | scratch-31aa0839953395f5998c7ec4350760cfebae6506.tar.gz scratch-31aa0839953395f5998c7ec4350760cfebae6506.tar.bz2 scratch-31aa0839953395f5998c7ec4350760cfebae6506.zip |
drop some repetition
-rw-r--r-- | AoC2022/25/solver.lisp | 21 |
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) |