Paste: aoc 4 p2

Author: jon
Mode: factor
Date: Fri, 4 Dec 2020 09:46:21
Plain Text |
"/tmp/input" ascii file-lines { "" } split [
  " " join " " split [ ":" split first2 ] H{ } map>assoc
   {
     [ "byr" of string>number dup [ 1920 2002 between? ] when ]
     [ "iyr" of string>number dup [ 2010 2020 between? ] when ]
     [ "eyr" of string>number dup [ 2020 2030 between? ] when ]
     [ "hgt" of {
         { [ "cm" ?tail ] [ 150 193 ] }
         { [ "in" ?tail ] [ 59 76 ] }
         [ f f ]
     } cond [ [ string>number ] 2dip pick [ between? ] [ 3drop f ] if ] [ nip ] if* ]
     [ "hcl" of "#" ?head [ [ length 6 = ] [ "0123456789abcdef" subset? ] bi and ] [ drop f ] if ]
     [ "ecl" of { "amb" "blu" "brn" "gry" "grn" "hzl" "oth" } in? ]
     [ "pid" of [ length 9 = ] [ "0123456789" subset? ] bi and ]
   } 1&& 
 ] count .

New Annotation

Summary:
Author:
Mode:
Body: