2019 day 1 to not derail
This commit is contained in:
32
2019/d1.py
Normal file
32
2019/d1.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
from lib import get_data
|
||||||
|
|
||||||
|
|
||||||
|
def f(i):
|
||||||
|
i //= 3
|
||||||
|
i -= 2
|
||||||
|
return i
|
||||||
|
|
||||||
|
|
||||||
|
def part_1(data):
|
||||||
|
print(sum([f(int(line)) for line in data.splitlines()]))
|
||||||
|
|
||||||
|
|
||||||
|
def part_2(data):
|
||||||
|
r = 0
|
||||||
|
for line in data.splitlines():
|
||||||
|
i = f(int(line))
|
||||||
|
while i > 0:
|
||||||
|
r += i
|
||||||
|
i = f(i)
|
||||||
|
print(r)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
data = get_data(__file__)
|
||||||
|
part_1(data)
|
||||||
|
part_2(data)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
1
2019/lib.py
Symbolic link
1
2019/lib.py
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../lib.py
|
||||||
1
2019/monitor.py
Symbolic link
1
2019/monitor.py
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../monitor.py
|
||||||
@@ -109,6 +109,11 @@ written in Python.
|
|||||||
- Day 18: 24:04
|
- Day 18: 24:04
|
||||||
- Day 19:
|
- Day 19:
|
||||||
|
|
||||||
|
# 2019
|
||||||
|
|
||||||
|
- Day 1: 4:25 (copy and paste error)
|
||||||
|
- Day 2:
|
||||||
|
|
||||||
# 2022
|
# 2022
|
||||||
|
|
||||||
Done with this. Overall everything is solvable. It's more about consistency
|
Done with this. Overall everything is solvable. It's more about consistency
|
||||||
|
|||||||
Reference in New Issue
Block a user