せかいのなべあつ

3の倍数のときにあほになって5の倍数のときに犬になります。
3がつくときにあほになるというバリエーションもあるな。

(defun ahowow ( cur end_1 &optional ln )
  (if (>= cur end_1) (nreverse ln)
    (let ((mf3 (= (mod cur 3) 0))
          (mf5 (= (mod cur 5) 0)))
      (setf ln
            (cond ((and mf3 mf5) (cons "AhoWow" ln))
                  (mf5 (cons "Wow" ln))
                  (mf3 (cons "Aho" ln))
                  (t (cons cur ln))))
      (ahowow (+ cur 1) end_1 ln ))))

(defun num-rep (cur n end_1 ln)
  (if (or (= n 0) (= cur end_1)) ln
    (num-rep (+ cur 1) (- n 1) end_1 (cons cur ln))))


(defun ahowow-duty ( cur end_1 &optional ln )
  (if (>= cur end_1) (nreverse ln)
    (let ((m3 (mod cur 3))
          (m5 (mod cur 5)))
      (let ((mf3 (= m3 0))
            (mf5 (= m5 0))
            next-n)
        (setf ln
              (cond ((and mf3 mf5) (cons "AhoWow" ln))
                    (mf5 (cons "Wow" ln))
                    (mf3 (cons "Aho" ln))
                    (t (cons cur ln))))
        (setf next-n (min (- 3 m3) (- 5 m5)))
        (setf ln (num-rep (+ cur 1) (- next-n 1) end_1 ln))
        (ahowow-duty (+ cur next-n) end_1 ln )))))


(defun test (n)
  (mapcar (lambda (x) (format t "~a " x))
          (ahowow 1 (+ n 1)))
  (format t "~%"))