(asdf:load-system "cl-strings") (require :cl-strings) (defvar *input* (mapcar (lambda (line) (mapcar (lambda (column) (parse-integer column)) (cl-strings:split line " "))) (uiop:with-safe-io-syntax () (uiop:read-file-lines "input.txt")))) (defun gradual-diff-p (record) (cond ((null (cdr record)) t) ((not (< 0 (abs (- (car record) (cadr record))) 4)) nil) (t (gradual-diff-p (cdr record))))) (defun safep (record) (and (or (apply #'< record) (apply #'> record)) (gradual-diff-p record))) (length (delete nil (mapcar #'safep *input*)))