diff --git a/day13-input.txt b/day13-input.txt index 2561256..2ae81ef 100644 --- a/day13-input.txt +++ b/day13-input.txt @@ -1,4 +1,8 @@ ( + +((2)) +((6)) + ((0 (() () (10 6) 0) (5) 5 9) ((5) 7)) ((((7 10 2 0)) ((5) (10 1 7) () () 9) ((0 6 2))) ()) diff --git a/day13-scratch.lisp b/day13-scratch.lisp index f47a622..6e530de 100644 --- a/day13-scratch.lisp +++ b/day13-scratch.lisp @@ -161,3 +161,19 @@ (nest-2-< '(2) '((2) 7)) ; here it is... + +;;; PART 2 +;; now working with the whole list - i need to sort it with that function + + +(let ((sorted (sort (copy-list *day13-all-list*) (lambda (left right) + (< (nest-2-< left right) 0))))) + (* (1+ (position '((2)) sorted :test #'equal)) + (1+ (position '((6)) sorted :test #'equal)))) + +(sort '(5 1 432 2 14) #'>) +(sort '(5 1 432 2 14) #'<) +(< 1 2) +(find '(1 2) '(1 (1 3) (1 2)) :test #'equal) +(position '(1 2) '(1 (1 3) (1 2)) :test #'equal) + diff --git a/day13-test.txt b/day13-test.txt index 0423898..2b95ff1 100644 --- a/day13-test.txt +++ b/day13-test.txt @@ -1,4 +1,7 @@ ( +((2)) +((6)) + (1 1 3 1 1) (1 1 5 1 1) diff --git a/day13.lisp b/day13.lisp index 50f134a..3103fe6 100644 --- a/day13.lisp +++ b/day13.lisp @@ -45,3 +45,10 @@ when (< (nest-2-< (nth i *day13-lefts*) (nth i *day13-rights*)) 0) collect (1+ i))) (apply #'+ *day13-indices*)) + +;;; PART 2 +(let ((sorted (sort (copy-list *day13-all-list*) (lambda (left right) + (< (nest-2-< left right) 0))))) + (* (1+ (position '((2)) sorted :test #'equal)) + (1+ (position '((6)) sorted :test #'equal)))) +;; 24477 yay