Skip to content

Commit

Permalink
maj
Browse files Browse the repository at this point in the history
  • Loading branch information
glassus committed Dec 2, 2021
1 parent 2c8e8dc commit 1d845cf
Show file tree
Hide file tree
Showing 4 changed files with 1,047 additions and 0 deletions.
18 changes: 18 additions & 0 deletions day02/02_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
data_str = open('input1.txt').read().splitlines()
#data_str = open('input_test.txt').read().splitlines()


data = [chaine.split(' ') for chaine in data_str]

hor = 0
depth = 0

for couple in data:
if couple[0] == 'forward':
hor += int(couple[1])
if couple[0] == 'down':
depth += int(couple[1])
if couple[0] == 'up':
depth -= int(couple[1])

print(hor*depth)
23 changes: 23 additions & 0 deletions day02/02_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
data_str = open('input1.txt').read().splitlines()
#data_str = open('input_test.txt').read().splitlines()


data = [chaine.split(' ') for chaine in data_str]

hor = 0
depth = 0
aim = 0

for couple in data:
if couple[0] == 'forward':
hor += int(couple[1])
depth += aim * int(couple[1])

if couple[0] == 'down':
aim += int(couple[1])

if couple[0] == 'up':
aim -= int(couple[1])


print(hor*depth)
Loading

0 comments on commit 1d845cf

Please sign in to comment.