day 13 - part 2, now SORT with that ORDER
This commit is contained in:
parent
1457992342
commit
16cb2be49b
|
@ -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))) ())
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
(
|
||||
((2))
|
||||
((6))
|
||||
|
||||
(1 1 3 1 1)
|
||||
(1 1 5 1 1)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue