kozima #4839(2007/12/16 03:49 GMT) [ Common Lisp ] Rating0/0=0.00
行数減らす工夫は何もしてないのに表示の方が長い……
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
(defun make-amida (list) (unless (equal list '(0)) (let ((n (1- (length list)))) (nconc (make-amida (remove n list)) (loop for x from (1- n) downto (position n list) collect x))))) (defun print-amida (x result) (let ((n (1- (length result)))) (format t "~{~D~^ ~}~&" (loop for x from 0 to n collect x)) (dolist (i x) (let ((str (format nil "~V@{| ~}|" n t))) (setf (aref str (+ i i 1)) #\-) (write-line str))) (format t "~{~D~^ ~}~&" result))) (let ((list '(3 5 2 4 0 1))) (print-amida (make-amida list) list))
Rating0/0=0.00-0+
[ reply ]
kozima
#4839()
[
Common Lisp
]
Rating0/0=0.00
行数減らす工夫は何もしてないのに表示の方が長い……
(defun make-amida (list) (unless (equal list '(0)) (let ((n (1- (length list)))) (nconc (make-amida (remove n list)) (loop for x from (1- n) downto (position n list) collect x))))) (defun print-amida (x result) (let ((n (1- (length result)))) (format t "~{~D~^ ~}~&" (loop for x from 0 to n collect x)) (dolist (i x) (let ((str (format nil "~V@{| ~}|" n t))) (setf (aref str (+ i i 1)) #\-) (write-line str))) (format t "~{~D~^ ~}~&" result))) (let ((list '(3 5 2 4 0 1))) (print-amida (make-amida list) list))Rating0/0=0.00-0+
[ reply ]