|
@@ -34,7 +34,7 @@ pickups = lambda items: map(set, itertools.chain(itertools.combinations(items, 2
|
34
|
34
|
|
35
|
35
|
# Returns an enumeration of possible destinations for the lift (up or down one floor)
|
36
|
36
|
dests = lambda layout: filter(is_floor, [my_floor_index(layout) + 1, my_floor_index(layout) - 1])
|
37
|
|
-is_floor = lambda i: i >= 0 and i < len(floors)
|
|
37
|
+is_floor = lambda i: 0 <= i < len(floors)
|
38
|
38
|
|
39
|
39
|
# Returns an enumeration of possible moves that could be made from the given state
|
40
|
40
|
moves = lambda layout: itertools.product(pickups(items(my_floor(layout))), dests(layout))
|
|
@@ -74,7 +74,7 @@ def run(floors):
|
74
|
74
|
for items, to in moves(layout):
|
75
|
75
|
items = set(items).union({lift})
|
76
|
76
|
new_layout = [set(floor) - items for floor in layout]
|
77
|
|
- new_layout[to] |= (items)
|
|
77
|
+ new_layout[to] |= items
|
78
|
78
|
if valid_layout(new_layout):
|
79
|
79
|
serialised = serialise(new_layout)
|
80
|
80
|
if serialised not in distances:
|