(I meant to post this while 1542: Scheduling Conflict was still the current xkcd, but I had a scheduling conflict.)
Input
The input will be a list of 3n
elements, which represent n
events. The
first element in each group of 3 will be the name of an event; the second and
third, the start and end time respectively. For example:
foo 12 34 bar 56 78
represents an event foo
that starts at "time 12" (times are represented
simply by integers; you can think of them as minutes past midnight) and ends at
34, and a second event bar
that starts at 56 and ends at 78.
The names of events will always consist of only alphanumeric characters, and the times will always be integers ≥ 0 and < 1440. The end time will always be at least 1 greater than the start time. They are not guaranteed to be sorted in any way.
If you would like, you may take this as a single space-separated string; otherwise it should be taken as an array, list, vector, or your language's equivalent.
Output
The output should be a space-separated list of event names. The rules for which event names to output are as follows:
None of the events that you output may conflict with each other. For example, with the input
a 0 10 b 5 15
, you may not output botha
andb
because the times conflict (that is, partially overlap). If an event ends exactly as another one starts, you may include both.You may not output the event called
NSCC
("National Scheduling Conflict Competition"), of which there will always be exactly one of in the input. You also must output at least one event that conflicts (partially overlaps) withNSCC
(and there will always be at least one of those as well).You must output as many events as possible while following the above two rules. (This is so that you look as busy as possible, so that missing the NSCC seems more credible.)
This may also be output as either a single space-separated string or an array, list, vector, etc.
There can be more than one possible output.
Test cases
Note that the outputs listed are only examples. Your code may output something different, as long as it still follows the three rules above (notably, this means there must be the same amount of events as the example).
In: UnderwaterBasketWeavingConvention 50 800 NSCC 500 550
Out: UnderwaterBasketWeavingConvention
In: SconeEating 0 50 RegexSubbing 45 110 CodeGolfing 95 105 NSCC 100 200
Out: SconeEating CodeGolfing
In: VelociraptorHunting 0 300 NerdSniping 200 500 SEChatting 400 700 DoorknobTurning 650 750 NSCC 725 775
Out: NerdSniping DoorknobTurning
In: NSCC 110 115 A 100 120 B 120 140 C 105 135 D 100 105 E 135 500
Out: C D E
In: A 800 900 NSCC 700 1000 B 650 750 C 950 1050 D 655 660 E 660 665 F 1030 1040 G 1040 1060
Out: A D E F G
In: A 10 11 B 11 12 C 12 13 D 13 14 NSCC 15 1090 E 10 16
Out: E
Feel free to add more test cases in an edit if there are edge-cases that I missed.
Rules
Your code must complete within 30 seconds for all of the provided test cases (this is more of a sanity check, as it should probably complete much faster for all the test cases combined) on a reasonable personal machine.
This is code-golf, so the shortest code in bytes wins.
underwaterBasketWeavingConvention 50 800 nscc 550
instead of your example? \$\endgroup\$