Replace /dev/stdin with 0

This commit is contained in:
Valentin Ochs 2020-12-04 12:37:31 +01:00
parent ad867f9646
commit 6f12ad0e48
8 changed files with 8 additions and 8 deletions

View File

@ -1,2 +1,2 @@
l=set(map(int,open("/dev/stdin")))
l=set(map(int,open(0)))
print([a*b for a in l if (b:=2020-a) in l])

View File

@ -1,2 +1,2 @@
l=list(map(int,open("/dev/stdin")))
l=list(map(int,open(0)))
print([a*b*c for a in l for b in l for c in l if a+b+c==2020])

View File

@ -1 +1 @@
print(sum(int((s:=a.split('-'))[0])<=c.count(b[0])<=int(s[1]) for a,b,c in map(str.split,open("/dev/stdin"))))
print(sum(int((s:=a.split('-'))[0])<=c.count(b[0])<=int(s[1]) for a,b,c in map(str.split,open(0))))

View File

@ -1,4 +1,4 @@
def f(d,e,f):
a,b=*map(int,d.split('-'))
return (f[a-1]==e[0])^(f[b-1]==e[0])
print(sum(f(*x.split()) for x in open("/dev/stdin")))
print(sum(f(*x.split()) for x in open(0)))

View File

@ -1 +1 @@
print(sum('#'==list(open('/dev/stdin'))[i][(i*3)%31] for i in range(323)))
print(sum('#'==list(open(0))[i][(i*3)%31] for i in range(323)))

View File

@ -1,3 +1,3 @@
d=list(open("/dev/stdin"))
d=list(open(0))
def f(y,x=1):return sum(d[i][i*y//x%31]=='#' for i in range(0,323,x))
print(f(1)*f(3)*f(5)*f(7)*f(1,2))

View File

@ -1 +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"))))
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(0).read().split("\n\n"))))

View File

@ -1,2 +1,2 @@
u=lambda x:6<sum(map(lambda y:5<len(y)and{'by':lambda x:1919<int(x)<2003,'iy':lambda x:2009<int(x)<2021,'ey':lambda x:2019<int(x)<2031,'hg':lambda x:(x[-1]=='m'and 149<int(x[:-2])<194)or(x[-1]=='n'and 58<int(x[:-2])<77),'hc':lambda x:7==len(x)and'#'==x[0]and int(x[1:],16)>0,'ec':lambda x:x[2]in'buynlh','pi':lambda x:len(x)==9,'ci':lambda x:0}[y[:2]](y[4:]),x))
print(sum(map(lambda x:u(x.split()),open("/dev/stdin").read().split("\n\n"))))
print(sum(map(lambda x:u(x.split()),open(0).read().split("\n\n"))))