"""Exhaustively enumerate a small synthetic integer product-mix model."""
def solve(machine_hours=8, labour_hours=8):
    for value in (machine_hours, labour_hours):
        if isinstance(value, bool) or not isinstance(value, int) or value < 0:
            raise ValueError('capacities must be nonnegative integers')
    feasible=[]
    for x in range(min(machine_hours//2, labour_hours)+1):
        for y in range(min(machine_hours, labour_hours//2)+1):
            if 2*x+y <= machine_hours and x+2*y <= labour_hours:
                feasible.append((30*x+40*y,x,y))
    best=max(row[0] for row in feasible)
    return best, [(x,y) for score,x,y in feasible if score==best]

if __name__=='__main__':
    print('Base:', solve())
    print('One extra machine hour:', solve(9,8))
    print('One extra labour hour:', solve(8,9))
