Exercise · beginner · 10 min
Normalize names without changing letters
The same accented name arrives in two Unicode forms and padded with unusual spaces. Make equal names equal without stripping accents.
The rules
These rules decide what a correct result is. Your answer is checked on this dataset and on hidden datasets that follow the same rules.
Input
people(id, name) — text. id is unique; name is always present.
Rules
name: remove Unicode whitespace at both ends (this includes no-break space U+00A0 and ideographic space U+3000),
then normalize to Unicode NFC. Never remove accents or transliterate (José stays José, not Jose).
Inner spaces are kept as they are.
Output (row order does not matter)
clean(id text, name text)The data
people · 9 rows
| id | name |
|---|---|
| pxbny | François Côté· |
| pyy5h | plain name· |
| pyxap | Ölçer Çağlar· |
| p4oqr | ·Zoë Brontë·· |
| pw9op | ·Müller & Söhne· |
| p49xg | ·Nguyễn Văn An· |
| pgtkr | ·Łukasz Żak· |
| p3chd | Ångström Lab· |
| p2bzh | ·Łukasz Żak· |
What you practise
- Unicode
- trimming
- normalization
Your answer is also checked on hidden datasets generated from the same rules.
Sign in to bookmark this and keep private notes.