You are viewing a single comment's thread. Return to all comments →
I'm having a hard time trying to figure out why is my CL code failing on HackerRank but not when I run locally:
(defun functions-or-not () (let ((x (read))) (labels ((f-or-not (n) (when (> n 0) (if (f-or-n) (format t "YES~%") (format t "NO~%")) (f-or-not (1- n))))) (f-or-not x)))) (defun split (s) (loop for i = 0 then (1+ j) as j = (position #\Space s :start i) collect (subseq s i j) while j)) (defun read-args (n) (if (= n 0) nil (let ((pair (split (read-line)))) (cons (list (parse-integer (first pair)) (parse-integer (second pair))) (read-args (1- n)))))) (defun f-or-n () (let* ((n (read)) (args (read-args n)) (domain (mapcar #'car args)) (lenDomain (length domain))) (= lenDomain (length (remove-duplicates domain))))) (functions-or-not)
I'm getting a huge stack trace as a Runtime Error, but the two lines that are bugging me are these:
4: (PARSE-INTEGER "" :START 0 :END NIL :RADIX 10 :JUNK-ALLOWED NIL) 5: (READ-ARGS 3)
I honestly don't understand how is this possible. Locally I'm using GNU CLISP 2.49.
Seems like cookies are disabled on this browser, please enable them to open this website
Functions or Not?
You are viewing a single comment's thread. Return to all comments →
I'm having a hard time trying to figure out why is my CL code failing on HackerRank but not when I run locally:
I'm getting a huge stack trace as a Runtime Error, but the two lines that are bugging me are these:
I honestly don't understand how is this possible. Locally I'm using GNU CLISP 2.49.