import calendar


def create_disjunctive_constraints(solver, flat_vars):
    """
    Create constrains that forbids multiple events from taking place at the same time.
    Returns a list of `SequenceVar`s, one for each day. These are then used in the first
    phase of the solver.
    """
    events_for_day = [[] for _ in range(5)]

    for v in flat_vars:
        events_for_day[v.day].append(v)

    sequences_for_day = []

    for day_num, day in enumerate(events_for_day):
        if not day:
            # For empty arrays, OR-tools complains:
            # "operations_research::Solver::MakeMax() was called with an empty list of variables."
            continue

        disj = solver.DisjunctiveConstraint(day, calendar.day_abbr[day_num])
        solver.Add(disj)
        sequences_for_day.append(disj.SequenceVar())

    return sequences_for_day