Update day 13 solution
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -3,29 +3,28 @@ from pathlib import Path
|
||||
|
||||
|
||||
def fold(i, dots):
|
||||
new_dots = []
|
||||
new_dots = set()
|
||||
for d in dots:
|
||||
if i[0] == 'x':
|
||||
for d in dots:
|
||||
n = (i[1] - abs(d[0] - i[1]), d[1])
|
||||
if d[0] != i[1] and n not in new_dots:
|
||||
new_dots.append(n)
|
||||
if d[0] != i[1]:
|
||||
new_dots.add(n)
|
||||
elif i[0] == 'y':
|
||||
for d in dots:
|
||||
n = (d[0], i[1] - abs(d[1] - i[1]))
|
||||
if d[1] != i[1] and n not in new_dots:
|
||||
new_dots.append(n)
|
||||
if d[1] != i[1]:
|
||||
new_dots.add(n)
|
||||
|
||||
return new_dots
|
||||
|
||||
|
||||
def part_1(input):
|
||||
result = 0
|
||||
dots = []
|
||||
dots = set()
|
||||
instructions = []
|
||||
for line in input:
|
||||
if ',' in line:
|
||||
x, y = line.strip().split(',')
|
||||
dots.append((int(x), int(y)))
|
||||
dots.add((int(x), int(y)))
|
||||
elif 'fold along' in line:
|
||||
d, c = line.strip().split()[-1].split('=')
|
||||
instructions.append([d, int(c)])
|
||||
@@ -36,12 +35,12 @@ def part_1(input):
|
||||
|
||||
def part_2(input):
|
||||
result = 0
|
||||
dots = []
|
||||
dots = set()
|
||||
instructions = []
|
||||
for line in input:
|
||||
if ',' in line:
|
||||
x, y = line.strip().split(',')
|
||||
dots.append((int(x), int(y)))
|
||||
dots.add((int(x), int(y)))
|
||||
elif 'fold along' in line:
|
||||
d, c = line.strip().split()[-1].split('=')
|
||||
instructions.append([d, int(c)])
|
||||
|
||||
Reference in New Issue
Block a user