24 lines
555 B
Common Lisp
24 lines
555 B
Common Lisp
|
(defpackage #:aoc-2023/1.1
|
||
|
(:use #:cl)
|
||
|
(:export #:main))
|
||
|
|
||
|
(in-package #:aoc-2023/1.1)
|
||
|
|
||
|
(defun digits-to-integer (a b)
|
||
|
(values (parse-integer (format NIL "~A~A" a b))))
|
||
|
|
||
|
(defun line-value (line)
|
||
|
(digits-to-integer (find-if #'digit-char-p line)
|
||
|
(find-if #'digit-char-p line :from-end T)))
|
||
|
|
||
|
(defun main ()
|
||
|
(format T
|
||
|
"~A~%"
|
||
|
(loop :for line := (read-line T NIL)
|
||
|
:while line
|
||
|
:unless (string= line "")
|
||
|
:sum (line-value line))))
|
||
|
|
||
|
(eval-when (:execute)
|
||
|
(main))
|