Exemplo n.º 1
0
from main import *
from output import Output

output = Output()
pizzas.sort(key=lambda p: -len(p[1]))

current_pizza = 0
for team_size, team_number in [(2, T2), (3, T3), (4, T4)]:
    for team in range(team_number):
        if current_pizza + team_size - 1 < len(pizzas):
            output.add_team(
                list(
                    map(lambda x: pizzas[x][0],
                        range(current_pizza, current_pizza + team_size))))
            current_pizza += team_size
        else:
            break

print("Score: " + str(output.score()))
output.write(FILE_NAME)
Exemplo n.º 2
0
        best_id = -1
        best_size = 0
        for i in range(len(teams)):
            if len(teams[i][0]) >= team_size_by_id(i):
                continue

            new_ingredients_number = len(teams[i][1].union(pizza[1]))
            #if len(teams[i][1].union(pizza[1])) == len(pizza[1]) + len(teams[i][1]):
            #    teams[i][0].append(pizza[0])
            #    teams[i][1] = teams[i][1].union(pizza[1])
            #
            #    best_id = -1
            #
            #    break

            if new_ingredients_number >= best_size:
                best_id = i
                best_size = new_ingredients_number

        if best_id != -1:
            teams[best_id][0].append(pizza[0])
            teams[best_id][1] = teams[best_id][1].union(pizza[1])

    #print(teams)

    for i in range(len(teams)):
        if team_size_by_id(i) == len(teams[i][0]):
            output.add_team(teams[i][0])

print("Score: " + str(output.score()))
output.write(FILE_NAME)