def build_minimal_runs(events):
<EOL>events = [e for i, e in enumerate(events) if events.index(e) == i]<EOL>scheduled_runs = {}<EOL>scheduled_events = []<EOL>cur_run = <NUM_LIT:0><EOL>while len(scheduled_events) != len(events):<EOL><INDENT>for event_tpl in events:<EOL><INDENT>event, registers, parameters = event_tpl<EOL>if event_tpl in scheduled_events:<EOL><INDENT>continue<EOL><DEDENT>for possible_reg in register_options(registers):<EOL><INDENT>s = scheduled_runs.setdefault(cur_run, {})<EOL>if possible_reg not in s:<EOL><INDENT>s[possible_reg] = (event, possible_reg, parameters)<EOL>scheduled_events.append(event_tpl)<EOL>break<EOL><DEDENT><DEDENT><DEDENT>cur_run += <NUM_LIT:1><EOL><DEDENT>runs = [list(v.values()) for v in scheduled_runs.values()]<EOL>return runs<EOL>
Compile list of minimal runs for given events.