projects
/
adventofcode2020.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add cl-interpol
[adventofcode2020.git]
/
src
/
utilities.lisp
diff --git
a/src/utilities.lisp
b/src/utilities.lisp
index 91e74d11b1aeb5a8a6316c11562e7934f9eb0aa1..ce9aa6d39ce67b27c0608dda35c3adf23e5e18b9 100644
(file)
--- a/
src/utilities.lisp
+++ b/
src/utilities.lisp
@@
-8,6
+8,9
@@
(defun int-list-from (str)
(mapcar #'parse-integer (list-from str)))
(defun int-list-from (str)
(mapcar #'parse-integer (list-from str)))
+(defun list-list-from (str)
+ (split-sequence "" (list-from str) :test #'string=))
+
(defun cartesian-product (A B &rest C)
(let ((helper (lambda (X Y)
(if Y (loop for x in X
(defun cartesian-product (A B &rest C)
(let ((helper (lambda (X Y)
(if Y (loop for x in X
@@
-17,6
+20,11
@@
(wrap-A (mapcar #'list A)))
(reduce helper C :initial-value (funcall helper wrap-A B))))
(wrap-A (mapcar #'list A)))
(reduce helper C :initial-value (funcall helper wrap-A B))))
+(defun manhattan-distance (a b)
+ (destructuring-bind ((ax ay) (bx by)) (list a b)
+ (+ (abs (- ax bx))
+ (abs (- ay by)))))
+
(def-suite util)
(in-suite util)
(def-suite util)
(in-suite util)