10の問題回答
ここの問題
ちまちま続けている。
整理してみた。
(asdf:operate 'asdf:load-op :drakma :verbose nil) (asdf:operate 'asdf:load-op :cl-smtp :verbose nil) (eval-when (:compile-toplevel :load-toplevel :execute) (require :drakma) (require :cl-json) (require :ltk) (require :cl-smtp) ) (defpackage :10problem-user (:use :common-lisp :ltk :drakma :cl-smtp )) (in-package :10problem-user) ;; problem1 (loop for i from 1 to 100 by 1 if (or (= 0 (mod i 3)) (cl-ppcre:scan "3" (write-to-string i))) do (format t "~aみゃ〜んえ〜ん~%" i) else do (format t "~a万円~%" i) ) ;; problem2 (defvar *day-words* '("おはよう" "こんにちわ" "こんばんわ")) (defconstant *day-names* '("Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday")) (multiple-value-bind (second minute hour date month year day-of-week dst-p tz) (get-decoded-time) (format t "現在時刻は ~2,'0d:~2,'0d:~2,'0d of ~a, ~d/~2,'0d/~d (GMT~@d)" hour minute second (nth day-of-week *day-names*) month date year (- tz))) (multiple-value-bind (second minute hour) (get-decoded-time) (cond ((and (<= 5 hour) (< hour 10)) (print (nth 0 *day-words*))) ((and (<= 10 hour) (< hour 18)) (print (nth 1 *day-words*))) ((or (and (<= 18 hour) (< hour 24)) (and (<= 0 hour) (< hour 5))) (print (nth 2 *day-words*))) )) ;; problem3 (sort (mapcar #'parse-integer (loop for line = (read-line nil nil nil) while line if (string= "" line) return y else collect line into y) ) #'<)