Compare commits
2 commits
fc223c2746
...
e8c84a0cb6
Author | SHA1 | Date | |
---|---|---|---|
e8c84a0cb6 | |||
1befbf9c37 |
3 changed files with 1022 additions and 0 deletions
2
2021/data/day2.expected
Normal file
2
2021/data/day2.expected
Normal file
|
@ -0,0 +1,2 @@
|
|||
1714680
|
||||
1963088820
|
1000
2021/data/day2.input
Normal file
1000
2021/data/day2.input
Normal file
File diff suppressed because it is too large
Load diff
20
2021/day2/day2.py
Executable file
20
2021/day2/day2.py
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
if __name__ == '__main__':
|
||||
x = 0
|
||||
y = 0
|
||||
z = 0
|
||||
for line in sys.stdin.readlines():
|
||||
dir, amount = line.split()
|
||||
amount = int(amount)
|
||||
if dir == 'forward':
|
||||
x += amount
|
||||
z += y * amount
|
||||
elif dir == 'down':
|
||||
y += amount
|
||||
elif dir == 'up':
|
||||
y -= amount
|
||||
print(x*y)
|
||||
print(x*z)
|
Loading…
Reference in a new issue