LMKWOZVDWEBUHOH7TPO2AQKL4CTUVLA36Q74MBPE3U3QAF53E6FQC
{ pkgs ? import <nixpkgs> {} }: pkgs.mkShell {
nativeBuildInputs = with pkgs; [
sbcl
];
}
(defun process (instream)
(loop for line = (read-line instream nil) while line sum
(calibration line)
)
)
(defun calibration (line)
(let ((a NIL) (b NIL))
(loop for c across line do (let ((x (digit-char-p c)))
(when x (setq b x) (unless a (setq a x)))
))
(when (and a b) (+ (* 10 a) b))
)
)
(loop for arg in (cdr *posix-argv*) do
(with-open-file (s arg :direction :input) (format T "~d~&" (process s)))
)