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 not Marco, of course, so feel free to ignore me. :)
Anyway, the quiz:
Write a function, 'center', whose argument is a list of strings, which will be lines of text. 'center' should insert spaces at the beginning of the lines of text so that if they were printed, the text would be centered, and return the modified lines.
For example,
(center "This" "is" "a test of the" "center function")
should return the list:
(" This" " is" " a test of the" "center function")
because if these lines were printed, they would look like:
This is a test of the center function
-- Larry
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
On Wed, Jul 11, 2007 at 07:47:01PM -0700, Peter Seibel wrote:
Larry Clapp wrote:
In particular: no solutions for 48 hours; if you post one after that, include "[SPOILER]" in the subject.
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.
Yeah, I can live with that. After I posted the puzzle, I hacked up a solution, and gnashed my teeth that by my own rules I couldn't send it back. :)
So here's my version of CENTER.
[snip]
Broken. (Hey, if you can change the rules about posting solutions, I can change the rules about judging! ;)
Hint: re-read the problem specification.
Broken in a common way, though (based on MJD's comments[1] on the solutions to the first Perl quiz), and in the same way as my last almost-correct solution.
Your solution highlights some of the possible axes of judging, aka design trade-offs, kind of like Kent is always harping^W reminding us about in c.l.l. Specifically, your solution conses a little more than mine, but since you use reduce and mapcan and I use loop (twice), yours seems "Lispier".
-- L
[1] http://perl.plover.com/~alias/list.cgi?mss:8:200210:gjgjlgandhobgejokhic
On Thu, Jul 12, 2007 at 06:58:04AM -0400, Larry Clapp wrote:
Your solution highlights some of the possible axes of judging, aka design trade-offs, kind of like Kent is always harping^W reminding us about in c.l.l. Specifically, your solution conses a little more than mine, but since you use reduce and mapcan and I use loop (twice), yours seems "Lispier".
My solution:
(defun center (&rest list) (let* ((max-length (loop for item in list maximize (length item))) (center (floor max-length 2))) (loop for item in list for length = (length item) collect (format nil "~v,0T~A" (- center (floor length 2)) item))))
Outputs:
QUIZ 15 > (center "this" "is" "a test of the" "center function") (" this" " is" " a test of the" "center function")
I realize now that I should simplify my math:
(defun center2 (&rest list) (let ((max-length (loop for item in list maximize (length item)))) (loop for item in list collect (format nil "~v,0T~A" (floor (- max-length (length item)) 2) item))))
So far, I like Sean's solution the best. For reference, Sean wrote:
(defun center (&rest list) (let ((max (reduce #'max vals :key #'length))) (mapcar #'(lambda (x) (format nil "~,,v@A" (floor (- max (length x)) 2) x)) list)))
-- L
A solution using the minpad argument to ~A
(defun center (&rest list) (let ((max (reduce #'max vals :key #'length))) (mapcar #'(lambda (x) (format nil "~,,v@A" (floor (- max (length x)) 2) x)) list)))
Sean.
On Wed, 2007-07-11 at 18:36 -0400, 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 not Marco, of course, so feel free to ignore me. :)
Anyway, the quiz:
Write a function, 'center', whose argument is a list of strings, which will be lines of text. 'center' should insert spaces at the beginning of the lines of text so that if they were printed, the text would be centered, and return the modified lines.
For example,
(center "This" "is" "a test of the" "center function")
should return the list:
(" This" " is" " a test of the" "center function")
because if these lines were printed, they would look like:
This is
a test of the center function
-- Larry
[1] http://common-lisp.net/project/quiz/
quiz mailing list quiz@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/quiz