SPOILER: Re: [quiz] call for quizzes, and [QUIZ 4] centering

Peter Seibel peter at gigamonkeys.com
Thu Jul 12 02:47:01 UTC 2007


Larry Clapp wrote:
> I think there's interest in this list, I just think the guy that
> started it (Marco Baringer) ran out of or overestimated his free time.
> 
> If you have a puzzle or quiz, feel free to post it to the list.  Heck,
> if you have some (short) Lisp code that's just not working and you
> don't know why, post it to the list.
> 
> [ /me Googles ... ]
> 
> This list started as an imitation of the Perl quiz of the week, so
> I'll shamelessly copy their first quiz (see below).
> 
> I'd also like to ask everyone to take a moment and re-read the rules
> of the game as posted here[1].  In particular: no solutions for 48
> hours; if you post one after that, include "[SPOILER]" in the subject.
> I'll add to that: If you reply to a SPOILER thread and cut out the
> solution, you can remove SPOILER from the subject (or maybe change it
> to UNSPOILED just for fun :).  Also, the Perl quiz site has the
> following Q&A (paraphrased): Q: Where to I send my answer?  A: Don't
> feel obligated to send it anywhere.  The point of solving the puzzle
> is to have solved it.

I'm going to unilaterally change the rules (at least as they apply to me 
;-)) and say that it's okay to send a solution whenever you want as long 
as it's got SPOILER in the subject. If I hack up a solution I don't want 
to have to remember to come back in two days and send it to the list. So 
here's my version of CENTER.

   (defun center (&rest list)
     (let ((max (reduce #'max list :key #'length)))
       (format t "~{~v,0t~a~%~}"
	      (mapcan
	       #'(lambda (x) (list (floor (- max (length x)) 2) x))
	       list))))

REPL> (center "This" "is" "a test of the" "center function")
      This
       is
  a test of the
center function
NIL

-Peter


-- 
Peter Seibel                     : peter at gigamonkeys.com
A Billion Monkeys Can't be Wrong : http://www.gigamonkeys.com/blog/
Practical Common Lisp            : http://www.gigamonkeys.com/book/
Coders at Work                   : http://www.codersatwork.com/



More information about the Quiz mailing list