From: Mart Lubbers Date: Fri, 4 Dec 2020 08:44:32 +0000 (+0100) Subject: guard the frobbing regexes X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=f2afc59d520cebef23416e7f9907e7e0e59c4dee;p=aoc20.git guard the frobbing regexes --- diff --git a/4/one.icl b/4/one.icl index 48744d4..5e7f5f0 100644 --- a/4/one.icl +++ b/4/one.icl @@ -27,7 +27,6 @@ Start w = (one passports, two passports) one = length o filter (valid [(n, const True)\\n<-["byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"]]) - two = length o filter (valid [ ("byr", fourDigit 1920 2002) , ("iyr", fourDigit 2010 2020) @@ -41,5 +40,5 @@ two = length o filter (valid , ("pid", reg "\\d{9}") ]) fourDigit lo hi x = reg "\\d{4}" x && between lo hi (toInt x) -reg p = not o isEmpty o match p +reg p = not o isEmpty o match ("^"+++p+++"$") between lo hi x = x >= lo && x <= hi