day 13 - part 2, now SORT with that ORDER

This commit is contained in:
efim 2022-12-14 20:41:44 +00:00
parent 1457992342
commit 16cb2be49b
4 changed files with 30 additions and 0 deletions

View File

@ -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))) ())

View File

@ -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)

View File

@ -1,4 +1,7 @@
(
((2))
((6))
(1 1 3 1 1)
(1 1 5 1 1)

View File

@ -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