Skip to content

Commit 96fdfa1

Browse files
committed
cosmetics
1 parent 83a800e commit 96fdfa1

File tree

9 files changed

+18
-16
lines changed

9 files changed

+18
-16
lines changed

2018/day07/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def load_data(filename):
1616
if step not in deps:
1717
deps[step] = set([ must_be_finished_before ])
1818
else:
19-
deps[step] |= set([ must_be_finished_before ])
19+
deps[step].add(must_be_finished_before)
2020

2121
if must_be_finished_before not in deps:
2222
deps[must_be_finished_before] = set()

2020/day16/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def load_data(filename):
5656
possible_fields = set()
5757
for field_no in range(nearby_tickets.shape[1]):
5858
if all( x in s for x in nearby_tickets[:,field_no] ):
59-
possible_fields |= set([field_no])
59+
possible_fields.add(field_no)
6060
field_map[rule_no] = possible_fields
6161

6262
found = []

2022/day15/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def load_data(filename):
1818
all_intervals = []
1919
for (sx, sy), (bx, by) in load_data('input.txt'):
2020
if by == the_row:
21-
beacons_in_the_row |= set([bx])
21+
beacons_in_the_row.add(bx)
2222
distance = abs(sx - bx) + abs(sy - by)
2323
interval = (sx - distance + abs(sy - the_row), sx + distance - abs(sy - the_row))
2424
if interval[0] <= interval[1]:

2022/day22/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def merge(p):
148148
for e in c2e[p]:
149149
key = tuple(sorted(e))
150150
for f in e2f[key]:
151-
faces |= set([f[1]])
151+
faces.add(f[1])
152152
n_faces = len(e2f[key])
153153
if n_faces == 1:
154154
g.append(e)

2023/day16/run.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ def trace_light(tracing):
2828
dx, dy = -dy, -dx
2929
elif a[y, x] == '|' and dx != 0:
3030
dx, dy = dy, dx
31-
new_tracing |= set([ (x, y, 0, -1), (x, y, 0, 1) ])
31+
new_tracing.add( (x, y, 0, -1) )
32+
new_tracing.add( (x, y, 0, 1) )
3233
elif a[y, x] == '-' and dy != 0:
3334
dx, dy = dy, dx
34-
new_tracing |= set([ (x, y, -1, 0), (x, y, 1, 0) ])
35-
new_tracing |= set([ (x, y, dx, dy) ])
35+
new_tracing.add( (x, y, -1, 0) )
36+
new_tracing.add( (x, y, 1, 0) )
37+
new_tracing.add( (x, y, dx, dy) )
3638
new_tracing -= light
3739
light |= new_tracing
3840
tracing = new_tracing

2023/day18/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def neighbours(x, y):
5454
to_paint -= set([cell])
5555
for n_cell in neighbours(*cell):
5656
if f.get(n_cell, None) is None:
57-
to_paint |= set([n_cell])
57+
to_paint.add(n_cell)
5858

5959
print(len(f))
6060

2023/day21/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def neighbours(x, y):
1717
yield x, y+1
1818
yield x, y-1
1919

20-
y, x = next(iter(zip(*np.where(a == 'S'))))
20+
y, x = next(zip(*np.where(a == 'S')))
2121

2222
def plots(x, y, steps):
2323
visited = [ set(), { (x, y) } ]

2023/day22/run.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ def __repr__(self):
8989
break
9090
else:
9191
continue
92-
brick.under |= set([stack[(cx, cy, z)]])
92+
brick.under.add(stack[(cx, cy, z)])
9393
for cx, cy, cz in brick.top_cubes():
9494
for z in range(cz+1, TOP+1):
9595
if (cx, cy, z) in stack:
9696
break
9797
else:
9898
continue
99-
brick.over |= set([stack[(cx, cy, z)]])
99+
brick.over.add(stack[(cx, cy, z)])
100100

101101
def all_fall():
102102
moved = 0
@@ -137,7 +137,7 @@ def test(fallen):
137137
add = set()
138138
for b in to_test:
139139
if b.would_fall_without(fallen):
140-
add |= set([b])
140+
add.add(b)
141141
return add
142142

143143
add = test(fallen)

2024/day06/run.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ def load_data(filename):
1515

1616
# Part One
1717

18-
y, x = next(iter(zip(*np.where(a == '^'))))
18+
y, x = next(zip(*np.where(a == '^')))
1919
dx, dy = 0, -1
2020

2121
visited = set()
2222

2323
while True:
24-
visited |= set([(x, y)])
24+
visited.add( (x, y) )
2525
fx, fy = x + dx, y + dy
2626
if a[fy, fx] == '%':
2727
break
@@ -38,7 +38,7 @@ def walk_is_cycled(x, y, dx, dy, trail, obstacles, try_obstacle=None):
3838
while True:
3939
if (x, y, dx, dy) in trail:
4040
return True
41-
trail |= set([(x, y, dx, dy)])
41+
trail.add( (x, y, dx, dy) )
4242
fx, fy = x + dx, y + dy
4343
if a[fy, fx] == '%':
4444
return False
@@ -50,7 +50,7 @@ def walk_is_cycled(x, y, dx, dy, trail, obstacles, try_obstacle=None):
5050
obstacles[ (fx, fy) ] = walk_is_cycled(x, y, -dy, dx, trail.copy(), obstacles, try_obstacle=(fx, fy))
5151
x, y = fx, fy
5252

53-
y, x = next(iter(zip(*np.where(a == '^'))))
53+
y, x = next(zip(*np.where(a == '^')))
5454
dx, dy = 0, -1
5555

5656
# The new obstruction can't be placed at the guard's starting position

0 commit comments

Comments
 (0)