There was a challenge to convert a number to its numeral in English, but that was too straightforward. Given a number 0–100, your task is to output the corresponding numeral in French. The French numeral system has a more complex logic behind it compared to the English one:
Number Numeral --------------- 0 zéro (note the accent) 1 un 2 deux 3 trois 4 quatre 5 cinq 6 six 7 sept 8 huit 9 neuf 10 dix 11 onze 12 douze 13 treize 14 quatorze 15 quinze 16 seize 17 dix-sept (literally ten seven) 18 dix-huit 19 dix-neuf 20 vingt 21 vingt et un (no hyphens) 22 vingt-deux ... 30 trente ... 40 quarante ... 50 cinquante ... 60 soixante ... 70 soixante-dix (literally sixty ten) 71 soixante et onze ... 80 quatre-vingts (note the s; literally four twenties) 81 quatre-vingt-un (note the hyphens) ... 90 quatre-vingt-dix 91 quatre-vingt-onze ... 99 quatre-vingt-dix-neuf (4*20+10+9) 100 cent
- There will always be a hyphen between words EXCEPT when the number ends in 1.
- When the number ends in 1, the word et (meaning and) is added before the un or onze. (31 = trente et un)
- However, 81 and 91 are formatted the same as the other numbers. (81 = quatre-vingt-un)
- At 60, the system switches from base 10 to base 20.
- There are some minor discrepancies across the web about this; refer to the list linked above for questions.
- Standard "loopholes" which are no longer funny are not allowed.
- Using an external source such as a website, as well as any libraries, APIs, functions, or the like that convert numbers to numerals or translate to French are not allowed.
- This is code-golf, so the answer with the fewest bytes wins.
- If available, please link to an online compiler to allow for easy testing of your code.
- Input shall be taken from however your language takes input. (STDIN, command line, etc.)
- Input will be a single string, consisting of a whole number between 0 and 100 inclusive (leading zeroes optional).
- You can assume the input will always be well-formed.
- The result shall be output to the most convenient method for your language. (STDOUT, dialog box, etc.)
- Case does not matter in the output.
Test your code against these:
Input Output ------------- 0 zéro 18 dix-huit 51 cinquante et un 80 quatre-vingts 91 quatre-vingt-onze 99 quatre-vingt-dix-neuf