On 04/10, Carlitos wrote:
Hi there, fellow Lisp programmer,I didn't participate last year and I'm not sure how good the support of "exotic" languages is now that the code has to run on their servers. The solution below to the second problem seems fine to me, and it works for the test sets one and two. However, it results in a Runtime Error for test set three and I have no idea why that may be. I would be interested in knowing if other people has also experienced issues with SBCL. Cheers, Carlos (defun solve (n path) (declare (ignore n)) (coerce (loop for m across path collect (ecase m (#\S #\E) (#\E #\S))) 'string)) (defun run (&optional (input-stream t) (output-stream t)) (let ((cases (parse-integer (read-line input-stream)))) (loop for case from 1 to cases for n = (read input-stream) for path = (read-line input-stream) do (format output-stream "Case #~A: ~A~&" case (solve n path))))) (run)
This is what I came up with, and the only different is that you accumulate results into a list before coercing it back into a string -- I used MAP instead
(defun solve (lydia) (map 'string (lambda (m) (if (char= m #\S) #\E #\S)) lydia)) (defun solution () (loop :for i :from 1 :to (parse-integer (read-line)) :for ignored = (read-line) :for lydia = (read-line) :for mine = (solve lydia) :do (format t "Case #~d: ~a~%" i mine))) Ciao, Matteo -- Matteo Landi https://matteolandi.net -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/20190412193216.GC2837%40hairstyle.local. For more options, visit https://groups.google.com/d/optout.
