Der Lösung erster Teil
This commit is contained in:
parent
4082da3a9f
commit
37cf0c9e7e
|
@ -1,3 +1,25 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
with
|
|
||||||
|
# start position
|
||||||
|
forward = 0
|
||||||
|
depth = 0
|
||||||
|
|
||||||
|
with open('input.txt', 'r') as myfile:
|
||||||
|
for line in myfile:
|
||||||
|
# read file line by line
|
||||||
|
command, value = line.split(' ')
|
||||||
|
# print('command {} value {}'.format(command, value))
|
||||||
|
if command == 'forward':
|
||||||
|
forward = forward + int(value)
|
||||||
|
elif command == 'down':
|
||||||
|
depth = depth - int(value)
|
||||||
|
elif command == 'up':
|
||||||
|
depth = depth + int(value)
|
||||||
|
|
||||||
|
|
||||||
|
print('forward: {} depth: {}'.format(forward, depth))
|
||||||
|
print('Submit value: {}'.format(forward * abs(depth)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue