ADRM5TAEARR3W3PXDI5T57LLD2NWGBMVXWAGQTZBQY74VJ54QALAC
(defun count-crossing-points (lines)
(let ((count-hash (build-count-hash lines)))
(loop for k being the hash-keys in count-hash using (hash-value v)
count (>= v 2))))
(defun reverse-partition (pred col)
(loop with yays = '()
with nays = '()
for e in col
do (if (funcall pred e)
(setf yays (cons e yays))
(setf nays (cons e nays)))
finally (return (list yays nays))))
(defun part1 (input)
(count-crossing-points (remove-if #'angled-line-p input)))
(defun part2 (input)
(count-crossing-points input))
(format t "===== Part 1 =====")
(format t "Result: ~A~%~%" (time (part1 *data*)))
(defun count-crossing-points (lines count-hash)
(mark-lines lines count-hash)
(loop for k being the hash-keys in count-hash using (hash-value v)
count (>= v 2)))
(format t "===== Part 2 =====")
(format t "Result: ~A~%" (time (part2 *data*)))
(time
(let ((hash (make-hash-table :test 'equal))
(lines (reverse-partition #'angled-line-p *data*)))
(format t "Part 1: ~A~%" (count-crossing-points (cadr lines) hash))
(format t "Part 2: ~A~%" (count-crossing-points (car lines) hash))))