Missing Digit by hebiyan

(defun find-shortage (line)
  (loop for n from 0 upto 9
     if (null (position (digit-char n) line))
       return n))

(defun read-lines ()
  (labels ((inner (rv)
             (handler-case
                 (inner (cons (read-line) rv))
               (end-of-file ()
                 (reverse rv)))))
    (inner '())))

(defun main ()
  (format t "~{~a~%~}"
          (mapcar #'(lambda (l) (find-shortage l))
                  (read-lines))))
(main)

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page