diff --git a/01-1-1.py b/01-1-1.py index fb68bb2..e4fd4ba 100644 --- a/01-1-1.py +++ b/01-1-1.py @@ -1,2 +1,2 @@ -l=set(map(int,open("/dev/stdin").readlines())) +l=set(map(int,open("/dev/stdin"))) print([a*(2020-a) for a in l if 2020-a in l]) diff --git a/01-2-1.py b/01-2-1.py index a89b792..07f12fc 100644 --- a/01-2-1.py +++ b/01-2-1.py @@ -1,2 +1,2 @@ -l=list(map(int,open("/dev/stdin").readlines())) +l=list(map(int,open("/dev/stdin"))) print([a*b*c for a in l for b in l for c in l if a+b+c==2020]) diff --git a/02-1-1.py b/02-1-1.py index 48af935..9070502 100644 --- a/02-1-1.py +++ b/02-1-1.py @@ -1 +1 @@ -print(sum(int((s:=l[0].split('-'))[0])<=l[2].count(l[1][0])<=int(s[1]) for l in map(str.split,open("/dev/stdin").readlines()))) +print(sum(int((s:=l[0].split('-'))[0])<=l[2].count(l[1][0])<=int(s[1]) for l in map(str.split,open("/dev/stdin")))) diff --git a/02-2-1.py b/02-2-1.py index b22c1f3..300c294 100644 --- a/02-2-1.py +++ b/02-2-1.py @@ -1,4 +1,4 @@ def f(k): a,b,c=*map(int,k[0].split('-')),k[1][0] return (k[2][a-1]==c)^(k[2][b-1]==c) -print(sum(f(x.split()) for x in open("/dev/stdin").readlines())) +print(sum(f(x.split()) for x in open("/dev/stdin"))) diff --git a/03-1-1.py b/03-1-1.py index fb7df64..373e7a4 100644 --- a/03-1-1.py +++ b/03-1-1.py @@ -1 +1 @@ -print(sum('#'==open('/dev/stdin').readlines()[i][(i*3)%31] for i in range(323))) +print(sum('#'==list(open('/dev/stdin'))[i][(i*3)%31] for i in range(323))) diff --git a/03-2-1.py b/03-2-1.py index b046ef7..35521ff 100644 --- a/03-2-1.py +++ b/03-2-1.py @@ -1,3 +1,3 @@ -d=open("/dev/stdin").readlines() +d=list(open("/dev/stdin")) 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))