Untitled

 avatar
unknown
lisp
2 years ago
454 B
3
Indexable
(ql:quickload :str)

(defun num-char-p (c)
  (<= 48 (char-code c) 57))
     
(defun first-last-nums (str)
  (let ((s (str:words
            (substitute-if-not #\SPACE #'num-char-p str))))
    (parse-integer (concatenate 'string (first s) (car (last s))))))

(defun cord-sums (lines)
  (loop :for l :in lines
        :sum (first-last-nums l)))

;; Test
(cord-sums '("1abc2"
             "pqr3stu8vwx"
             "a1b2c3d4e5f"
             "treb7uchet"))
Editor is loading...
Leave a Comment