repositories
/
aoc20.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
43e2dbd
)
guard the frobbing regexes
author
Mart Lubbers
<mart@martlubbers.net>
Fri, 4 Dec 2020 08:44:32 +0000
(09:44 +0100)
committer
Mart Lubbers
<mart@martlubbers.net>
Fri, 4 Dec 2020 08:44:32 +0000
(09:44 +0100)
4/one.icl
patch
|
blob
|
history
diff --git
a/4/one.icl
b/4/one.icl
index
48744d4
..
5e7f5f0
100644
(file)
--- 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"]])
= (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)
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)
, ("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
between lo hi x = x >= lo && x <= hi