commit
e491f7718e
5 changed files with 78 additions and 0 deletions
@ -0,0 +1,8 @@ |
||||
measures = [int(i) for i in open("input.txt", 'r').read().splitlines()] |
||||
|
||||
increases = 0 |
||||
for i in range(1,len(measures)): |
||||
if measures[i] > measures[i-1]: |
||||
increases += 1 |
||||
|
||||
print(increases) |
@ -0,0 +1,11 @@ |
||||
measures = [int(i) for i in open("input.txt", 'r').read().splitlines()] |
||||
|
||||
increases = 0 |
||||
old = measures[0]+measures[1]+measures[2] |
||||
for i in range(3,len(measures)): |
||||
new = measures[i] + measures[i-1] + measures[i-2] |
||||
if new > old: |
||||
increases += 1 |
||||
old = new |
||||
|
||||
print(increases) |
@ -0,0 +1,15 @@ |
||||
depth = 0 |
||||
forw = 0 |
||||
|
||||
for s in open("input.txt", 'r').read().splitlines(): |
||||
split = s.split() |
||||
match split[0]: |
||||
case "forward": |
||||
forw += int(split[1]) |
||||
case "down": |
||||
depth += int(split[1]) |
||||
case "up": |
||||
depth -= int(split[1]) |
||||
|
||||
print(depth*forw) |
||||
|
@ -0,0 +1,18 @@ |
||||
aim = 0 |
||||
depth = 0 |
||||
forw = 0 |
||||
|
||||
for s in open("input.txt", 'r').read().splitlines(): |
||||
split = s.split() |
||||
match split[0]: |
||||
case "forward": |
||||
i = int(split[1]) |
||||
forw += i |
||||
depth += aim * i |
||||
case "down": |
||||
aim += int(split[1]) |
||||
case "up": |
||||
aim -= int(split[1]) |
||||
|
||||
print(depth*forw) |
||||
|
@ -0,0 +1,26 @@ |
||||
lines = open("input.txt", 'r').read().splitlines() |
||||
leng = len(lines) |
||||
count = [0] * len(lines[0]) |
||||
|
||||
for s in lines: |
||||
for i in range(0, len(s)): |
||||
if bool(int(s[i])): |
||||
count[i] += 1 |
||||
|
||||
s = "" |
||||
t = "" |
||||
print(count) |
||||
for i in count: |
||||
if i > leng/2: |
||||
s += "1" |
||||
t += "0" |
||||
else: |
||||
s += "0" |
||||
t += "1" |
||||
|
||||
gama = int(s, 2) |
||||
epsi = int(t, 2) |
||||
print(gama) |
||||
print(epsi) |
||||
print(gama*epsi) |
||||
|
Loading…
Reference in new issue