Dispatch code normalizer
Codes printed by different terminals may have lowercase letters and separator hyphens. Remove all hyphens, uppercase each code, keep only distinct normalized codes and print them alphabetically. A repeated code after normalization should appear only once.
Input
One line of space-separated letter, digit and hyphen codes.
Output
One normalized code per line in alphabetical order.
Example 1
Input
ab-2 AB2 c-9
Output
AB2 C9
ab-2 and AB2 normalize to one AB2; the remaining code becomes C9, so both print alphabetically.
Constraints
- The line has 1 to 200 non-empty codes.
- Codes contain ASCII letters, digits and formatting hyphens.
Hints
Hint 1 of 2
The global hyphen replacement removes every separator.
Hint 2 of 2
Deduplicate after normalization, then sort for reporting.
Solution
Show a reference solution and explanation
const codes = new Set(readline().split(' ').map(code => code.replace(/-/g, '').toUpperCase()));
for (const code of [...codes].sort()) console.log(code);
Why it works
Case and separator differences are formatting, not different dispatch IDs. Normalizing before insertion makes those variants collapse in the Set. Sorting the distinct values yields deterministic output regardless of scan order.
Lesson for this exercise: JavaScript Strings: Methods, Template Literals and Slicing