tools = ('hammer', 2), ('screwdriver', 4), ('nail gun', 6), ('wrench', 4), (
    'pillow', 5)
job_requirements = (('hammer', 2), ('screwdriver', 4)), (('hammer', 2), (
    'nail gun', 6)), (('hammer', 2), ('wrench', 4)), (('wrench', 4), (
    'nail gun', 6)), (('screwdriver', 4), ('pillow', 5))

def satisfies_job(tools, job):
    return all(tool in tools for tool in job)
setups = []
for comb in itertools.combinations(tools, num_stations):
    if len(set(tool[1] for tool in comb)) == len(comb):
        setups.append(comb)
for num_setups in range(1, len(setups)):
    for setups_comb in itertools.combinations(setups, num_setups):
        if all(any(satisfies_job(comb, job) for comb in setups_comb) for
            job in job_requirements):
            print('found valid tool setup combination:')
for comb in setups_comb:
    print(comb)
exit(0)
Алгоритм планирования заданий для минимизации изменений