mgw VC
def vacuum_cleaner(location, dirty_locations):
dirty = set(dirty_locations)
total_cost = 0
while dirty:
if location in dirty:
print(f"Cleaning {location}: 1")
dirty.remove(location)
total_cost += 1
else:
print(f"Moving to {location}: 0")
location = get_next_location(location)
print("Total cost:", total_cost)
def get_next_location(location):
if location == 'A':
return 'B'
elif location == 'B':
return 'C'
else:
return 'A'
vacuum_cleaner('A', ['B', 'C'])