Ordinal to Cardinal
Given a positive integer represented as the English spelling of an ordinal number, return the equivalent cardinal number.
Rules
Where an integer requires multiple words to spell, only the last word changes.
The following integers are strongly irregular:
- "one" becomes "first"
- "two" becomes "second"
- "three" becomes "third"
Other integers take a suffix of "th", however there are a few integers that are weakly irregular:
- "five" becomes "fif(th)"
- "eight" becomes "eigh(th)"
- "nine" becomes "nin(th)"
- "twelve" becomes "twelf(th)"
- "twenty" to "ninety" become "twentie(th)" to "ninetie(th)".
The input can be assumed to be the English spelling of an ordinal number that follows the above rules to transform it into the equivalent cardinal number.
Examples
- "nineteen""one hundred and nineteen" becomes "nineteenth""one hundred and nineteenth"
- "twenty""one hundred and twenty" becomes "twentieth""one hundred and twentieth"
- "twenty"one hundred and twenty one" becomes "twenty"one hundred and twenty first"
This is code-golf, so the shortest program or function that breaks no standard loopholes wins!