Update day 15 solution
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Don't neet to remember the path
This commit is contained in:
@@ -11,7 +11,6 @@ def part_1(input):
|
|||||||
start = (0, 0)
|
start = (0, 0)
|
||||||
end = (x_size - 1, y_size - 1)
|
end = (x_size - 1, y_size - 1)
|
||||||
cost = {start: 0}
|
cost = {start: 0}
|
||||||
prev = {start: None}
|
|
||||||
queue = set([start])
|
queue = set([start])
|
||||||
done = set()
|
done = set()
|
||||||
neighbors = set([(-1, 0), (0, -1), (0, 1), (1, 0)])
|
neighbors = set([(-1, 0), (0, -1), (0, 1), (1, 0)])
|
||||||
@@ -32,7 +31,6 @@ def part_1(input):
|
|||||||
next_cost = cur_cost + nodes[n]
|
next_cost = cur_cost + nodes[n]
|
||||||
if not n in cost or next_cost < cost[n]:
|
if not n in cost or next_cost < cost[n]:
|
||||||
cost[n] = next_cost
|
cost[n] = next_cost
|
||||||
prev[n] = current
|
|
||||||
queue.add(n)
|
queue.add(n)
|
||||||
done.add(current)
|
done.add(current)
|
||||||
result = cost[end]
|
result = cost[end]
|
||||||
@@ -58,7 +56,6 @@ def part_2(input):
|
|||||||
start = (0, 0)
|
start = (0, 0)
|
||||||
end = ((x_size * repeat) - 1, (y_size * repeat) - 1)
|
end = ((x_size * repeat) - 1, (y_size * repeat) - 1)
|
||||||
cost = {start: 0}
|
cost = {start: 0}
|
||||||
prev = {start: None}
|
|
||||||
queue = set([start])
|
queue = set([start])
|
||||||
done = set()
|
done = set()
|
||||||
neighbors = set([(-1, 0), (0, -1), (0, 1), (1, 0)])
|
neighbors = set([(-1, 0), (0, -1), (0, 1), (1, 0)])
|
||||||
@@ -81,7 +78,6 @@ def part_2(input):
|
|||||||
next_cost = cur_cost + nodes[n]
|
next_cost = cur_cost + nodes[n]
|
||||||
if not n in cost or next_cost < cost[n]:
|
if not n in cost or next_cost < cost[n]:
|
||||||
cost[n] = next_cost
|
cost[n] = next_cost
|
||||||
prev[n] = current
|
|
||||||
queue.add(n)
|
queue.add(n)
|
||||||
done.add(current)
|
done.add(current)
|
||||||
result = cost[end]
|
result = cost[end]
|
||||||
|
|||||||
Reference in New Issue
Block a user