MediumStringsNot started

Shipping code normalizer

Shipping labels arrive in mixed case and sometimes contain hyphens for readability. Remove all hyphens, uppercase the remaining letters and digits, discard duplicate normalized codes, then print the unique codes alphabetically. Do not confuse two labels that differ only before normalization.

Input

One line of space-separated non-empty codes containing letters, digits and optional hyphens.

Output

Normalized distinct codes, one per line in alphabetical order.

Example 1

Input

ab-12 AB12 x-9 X9

Output

AB12
X9

ab-12 and AB12 become the same normalized code, while x-9 and X9 collapse into one second code.

Constraints

  • The line contains 1 to 200 non-empty codes.
  • Codes contain only ASCII letters, digits and separator hyphens.

Hints

Hint 1 of 2

Use replace('-', '') before changing case.

Hint 2 of 2

A set removes duplicates after normalization; sort it for reporting.

Solution

Show a reference solution and explanation
 Python · reference solution
codes = {code.replace('-', '').upper() for code in input().split()}
for code in sorted(codes):
    print(code)

Why it works

Normalization must precede deduplication, or ab-12 and AB12 would be treated as different shipments. A set retains one normalized form of each code. Sorting at the end gives a deterministic report regardless of input order.

Lesson for this exercise: Strings in Python

Your program
codes = set()
for code in input().split():
    # Remove hyphens, uppercase, and add to the set.
    pass
for code in sorted(codes):
    print(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 CPython 3.11 at build time; runs in your browser on CPython 3.14 (Pyodide) 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.