Paste: aoc 2018 day 3

Author: jonenst
Mode: factor
Date: Mon, 3 Dec 2018 17:33:52
Plain Text |
: mark ( map str -- )
  " " split
  [ first 1 tail string>number ] 
  [ third ",:" split 2 head [ string>number ] map ]
  [ fourth "x" split [ string>number ] map ] tri
  [ dupd + [a,b) ] 2map first2
  [ [ 2array rot push-at ] with with with each ] curry with with each ;

H{ } clone [
  "/tmp/input" ascii file-lines [
    mark
  ] with each
] keep values
  [ [ length 2 >= ] count . ]
  [
       HS{ } clone [ swap
         [ dup length 2 >= [ union! ] [ drop ] if drop ]
         with each
       ] keep
    1 1399 [a,b] swap diff .
  ] bi

New Annotation

Summary:
Author:
Mode:
Body: