• + 1 comment
    def solve(a):
    	min_bus, max_bus = max(a), sum(a)
    	buses = {}
    	current = 0
    	for ai in a:
    		buses = {i: (bus+ai) % i  \
    			for i,bus in buses.items() \
    				if bus+ai <= i}
    		current += ai
    		if max_bus % current == 0 and current >= min_bus:
    			buses[current] = 0
    	return sorted(list(buses.keys()))