MediumStringsNot started

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
 JavaScript · reference solution
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

Your program
const codes = new Set();
for (const code of readline().split(' ')) {
  // Normalize before adding to the Set.
}
for (const code of [...codes].sort()) console.log(code);

Tests: 3 cases including the examples. Passing every test marks the exercise solved in this browser.

Ready for a challenge?

How this page was checked. Every program on it was run with Node.js 22 at build time; runs in your browser in an isolated Web Worker by the publishing checks, and the output shown is what it printed. The Run buttons execute the same code on your device; nothing you type is sent anywhere.