From eb9c9795e23ee05421ef8677e9025684478cfab0 Mon Sep 17 00:00:00 2001 From: Valentin Ochs Date: Fri, 4 Dec 2020 09:11:08 +0100 Subject: [PATCH] Initial solutions for day 4 --- 04-1-1.py | 1 + 04-2-1.py | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 04-1-1.py create mode 100644 04-2-1.py diff --git a/04-1-1.py b/04-1-1.py new file mode 100644 index 0000000..cba980a --- /dev/null +++ b/04-1-1.py @@ -0,0 +1 @@ +print(sum(map(lambda x:7==len(set(['byr','iyr','eyr','hgt','hcl','ecl','pid'])&set(map(lambda y:y[:3],x.replace('\n',' ').split(' ')))),open("/dev/stdin").read().split("\n\n")))) diff --git a/04-2-1.py b/04-2-1.py new file mode 100644 index 0000000..a253549 --- /dev/null +++ b/04-2-1.py @@ -0,0 +1,2 @@ +u=lambda x:7==sum(map(lambda y:{'byr':lambda x:1920<=int(x)<=2002,'iyr':lambda x:2010<=int(x)<=2020,'eyr':lambda x:2020<=int(x)<=2030,'hgt':lambda x:(x[-2:]=='cm' and 150<=int(x[:-2])<=193)or(x[-2:]=='in' and 59<=int(x[:-2])<=76),'hcl':lambda x:x[0]=='#' and len(x)==7 and int(x[1:],16)>=0,'ecl':lambda x:x in ['amb','blu','brn','gry','grn','hzl','oth'],'pid':lambda x:len(x)==9 and int(x)>=0,'cid':lambda x:False,'':lambda x:False}[y[:3]](y[4:]),x)) +print(sum(map(lambda x:u(x.replace('\n',' ').split(' ')),open("/dev/stdin").read().split("\n\n"))))