Given an input of a list of days of the week, output the shortest sorted representation of the list.
The format of the input is a string consisting of one or more of the
Sa. The input may not necessarily be given in sorted order.
To convert the input to the output format,
Sort the input by day of week, starting from Sunday (ex.
Reduce the abbreviations down to one letter if it leaves no ambiguity. For example,
SMTWbecause the first S couldn't possible be Saturday, as that would make the output unsorted (same for the T). However,
ThFS, as both Tuesday and Thursday come before Friday and reducing it down to
TFSwould create ambiguity.
If the output is now
Dinstead (which stands for "weekdays"). Similarly,
Efor weekend. Finally,
Afor all days.
The input and output must both be a single string.
Since this is code-golf, the shortest code in bytes wins.
In Out | In Out -----------------------|-------------------- SuTu STu | SuTuWe STW SuTuSa STuS | SuWeTh SWT TuThSa TTS | TuThSu STT Su Su | Sa Sa WeTh WT | FrTh ThF WeTu TW | FrTu TuF FrWeMo MWF | SaWeSu SWS ThTu TT | We W ThTuMoFrWe D | SaSu E SuMoWeTuThFr SMTWTF | ThMoSaSuFrTuWe A