Day 02 (minify)
This commit is contained in:
@@ -1 +1 @@
|
||||
l=[int(x.strip())for x in open("input.txt")];print(sum(int(l[i]<l[i+1]) for i in range(len(l)-1)))
|
||||
l=[int(x.strip())for x in open("input.txt")];print(sum(l[i]<l[i+1]for i in range(len(l)-1)))
|
||||
|
||||
@@ -1 +1 @@
|
||||
l=[int(x.strip())for x in open("input.txt")];print(sum(int(l[i]<l[i+3]) for i in range(len(l)-3)))
|
||||
l=[int(x.strip())for x in open("input.txt")];print(sum(l[i]<l[i+3]for i in range(len(l)-3)))
|
||||
|
||||
3
day02/part1.min.py
Normal file
3
day02/part1.min.py
Normal file
@@ -0,0 +1,3 @@
|
||||
h,d=0,0
|
||||
for c,s in(x.strip().split()for x in open("input.txt")):v=int(s);h,d=(h+v,d)if c[0]=='f'else(h,d+(-v if c=='up'else v))
|
||||
print(h*d)
|
||||
3
day02/part2.min.py
Normal file
3
day02/part2.min.py
Normal file
@@ -0,0 +1,3 @@
|
||||
h,d,a=0,0,0
|
||||
for c,s in(x.strip().split()for x in open("input.txt")):v=int(s);h,d,a=(h+v,d+a*v,a)if c[0]=='f'else(h,d,a+(-v if c=='up'else v))
|
||||
print(h*d)
|
||||
Reference in New Issue
Block a user