EsperantoNumbers
SRM 312 · 2006-07-22 · by Petr
Problem Statement
Numbers are far easier to spell in Esperanto than in English. Numbers 1 through 10 are spelled as follows: "unu", "du", "tri", "kvar", "kvin", "ses", "sep", "ok", "nau", "dek". Numbers 11 through 19 are spelled: "dek unu", "dek du", ..., "dek nau" - a "dek" followed by a single space and the number for the last digit. Numbers 20 through 29 are spelled: "dudek", "dudek unu", "dudek du", ..., "dudek nau". Similarly, 30 is "tridek", ..., 90 is "naudek" - we just join together the number of tens and "dek". There are no exceptions like "twelve" or "thirty" in English.
Given an int x between 1 and 99, inclusive, return its Esperanto spelling.
Constraints
- x will be between 1 and 99, inclusive.
1 Returns: "unu"
90 Returns: "naudek"
11 Returns: "dek unu"
57 Returns: "kvindek sep"
1 Returns: "unu"
Submissions are judged against all 121 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class EsperantoNumbers with a public method string nameThisNumber(int x) · 121 test cases · 2 s / 256 MB per case