You are viewing a single comment's thread. Return to all comments →
Common Lisp (SBCL):
(defun lst-equal (l c) (if l (if (eq (car l) c) (lst-equal (cdr l) c) ()) t)) (defun get-all-second (fir l) (if l (if (eq (car (car l)) fir) (cons (cdr (car l)) (get-all-second fir (cdr l))) (get-all-second fir (cdr l))) ())) (defun f (l) (if l (if (lst-equal (get-all-second (car (car l)) l) (cdr (car l))) (f (cdr l)) "NO") "YES")) (defun read-pairs (n) (if (eq n 0) () (cons (list (read *standard-input*) (read *standard-input*)) (read-pairs (- n 1 ))))) (defun solve-case () (f (read-pairs (read)))) (dotimes (i (read)) (format t "~a~%" (solve-case)))
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 →
Common Lisp (SBCL):