Paste: aoc16
Author: | jon |
Mode: | factor |
Date: | Fri, 8 Jan 2021 15:12:11 |
Plain Text |
"/home/harperjon/Téléchargements/input16" ascii file-lines
{ "" } split [
first [
":" split first2 " or " split harvest
[ "-" split [ string>number ] map ] map
] H{ } map>assoc
] [ second second "," split [ string>number ] map ]
[ third rest [ "," split [ string>number ] map ] map ] tri [
nip concat swap values concat
[ [ first2 between? ] with any? ] curry reject sum .
] [
rot [
values concat
[ [ [ first2 between? not ] with all? ] curry any? ]
curry reject
] keep [
[ nip flip ] dip >alist [
[
[ second [
[ first2 between? ] with any? ] curry all? ] keep
swap and
] with filter [ first ] map
] curry map
[ dup [ length 1 = ] all? ] [
dup dup [
over length 1 = [
[ first ] dip [ member? ] with count
2 >=
] [ 2drop f ] if
] curry find nip first
[ over length 1 > [ swap remove ] [ drop ] if ]
curry map
] until [ first ] map
] [
2drop [ [ "departure" head? ] dip and ] 2map
sift product .
] 3bi
] 3bi
New Annotation