From a2037e84ec9dd2ee9ad1528d94a5e4451a0fd41a Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Sat, 5 Dec 2020 17:44:23 +0100 Subject: day04 --- day04.ijs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 day04.ijs (limited to 'day04.ijs') diff --git a/day04.ijs b/day04.ijs new file mode 100644 index 0000000..83e779a --- /dev/null +++ b/day04.ijs @@ -0,0 +1,27 @@ +d =: ':' splitstring&> '\w+:\S+'&rxall&> cutpara 1!:1 <'day04' + +look =: 4 : 0 +{. > }. (y,('';'0')) {~ ({."1 y) i. < x +) + +inr =: 4 : '(-: /:~) ({. x), y, (}. x)' + +ks =: 0 = [: # (<;._1 ' byr iyr eyr hgt hcl ecl pid')&-. + +hv =: 3 : 0 +(>(('cm';'in') i. <_2 {. y) { 150 193;59 76; 1 0) inr ". _2 }. y +) + +rv =: 3 : 0 +l =. ks {."1 y +l =. l *. 1920 2002 inr ". 'byr' look y +l =. l *. 2010 2020 inr ". 'iyr' look y +l =. l *. 2020 2030 inr ". 'eyr' look y +l =. l *. '#[0-9a-f]{6}' rxeq 'hcl' look y +l =. l *. 'amb|blu|brn|gry|grn|hzl|oth' rxeq 'ecl' look y +l =. l *. '[0-9]{9}' rxeq 'pid' look y + l *. hv 'hgt' look y +) + ++/ks"1 {."1 d NB. 228 ++/rv"2 d NB. 175 -- cgit 1.4.1