commit 2c6dc6e8be17faa9c7b76af8e719f3f9aea66bac Author: Valentin Ochs Date: Thu Dec 3 22:34:39 2020 +0100 Initial commit diff --git a/01-1-1.py b/01-1-1.py new file mode 100644 index 0000000..fb68bb2 --- /dev/null +++ b/01-1-1.py @@ -0,0 +1,2 @@ +l=set(map(int,open("/dev/stdin").readlines())) +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 new file mode 100644 index 0000000..ac44daa --- /dev/null +++ b/01-2-1.py @@ -0,0 +1,2 @@ +l=list(map(int, open("/dev/stdin").readlines())) +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 new file mode 100644 index 0000000..8e696ac --- /dev/null +++ b/02-1-1.py @@ -0,0 +1 @@ +print(sum(1 for l in map(lambda x:x.split(),open("/dev/stdin").readlines()) if int(l[0].split('-')[0])<=l[2].count(l[1][0])<=int(l[0].split('-')[1]))) diff --git a/02-2-1.py b/02-2-1.py new file mode 100644 index 0000000..a3ce182 --- /dev/null +++ b/02-2-1.py @@ -0,0 +1,4 @@ +def chk(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(chk(x.split()) for x in open("/dev/stdin").readlines()))