(defconstant +good+ "good") (defconstant +problem+ "problem") (defun main (&rest argv) (declare (ignorable argv)) (let* ((query (read))) (dotimes (_ query) (let* ((s (read-line)) (n (length s)) (good-count (make-array 101 :element-type 'integer :initial-element 0)) (problem-count (make-array 101 :element-type 'integer :initial-element 0)) (res 0)) (dotimes (i (- n 10)) (dotimes (j 4) (when (char= (char s (+ i j)) (char +good+ j)) (incf (aref good-count i))))) (loop for i from 4 below (- n 6) do (dotimes (j 7) (when (char= (char s (+ i j)) (char +problem+ j)) (incf (aref problem-count i))))) (loop for i below (- n 10) do (loop for j from (+ i 4) below (- n 6) when (< res (+ (aref good-count i) (aref problem-count j))) do (setq res (+ (aref good-count i) (aref problem-count j))))) (format t "~d~%" (- 11 res)))))) (main)