Solve 2018 day 22 and 2019 day 20
This commit is contained in:
4
lib.py
4
lib.py
@@ -229,6 +229,7 @@ class A_Star(object):
|
||||
"""
|
||||
open_set = []
|
||||
g_score = {}
|
||||
self.cost = None
|
||||
|
||||
for start in starts:
|
||||
heapq.heappush(open_set, (h(start), start))
|
||||
@@ -237,7 +238,8 @@ class A_Star(object):
|
||||
while open_set:
|
||||
current_f_score, current = heapq.heappop(open_set)
|
||||
if is_goal(current):
|
||||
self.cost = current_f_score
|
||||
assert current_f_score == g_score[current]
|
||||
self.cost = g_score[current]
|
||||
break
|
||||
|
||||
for neighbor in neighbors(current):
|
||||
|
||||
Reference in New Issue
Block a user