We have another challenge from MMMAAANNN on Codewars. Today, you are asked to:
Turn a given number (an integer > 0, < 1000) into the equiva...
For further actions, you may consider blocking this person and/or reporting abuse
I would cheat and use google translate api xD
Common Lisp is a good choice for this:
JavaScript
Live demo on CodePen.
I tried to not dictionary everything, but the exceptions are real. Lots of amusing output as I got closer, that I'll paste for your enjoyment. I did actually get it working though :P
In Perl, we have CPAN, where you can find modules for almost any task imaginable. Including Lingua::EN::Numbers.
English is fun what with all the exceptions...
Gist: gist.github.com/kerrishotts/ea2bd9...
Try French. I’ll pass you the details of “quatre-vingt-dix-neuf” for 99, but you also have “vingt et un” (21), “vingt deux” (22), “deux cents” (200, note the s) but “deux cent un” (201).
Rust Solution!
Pretty hard coded. Probably could be made much more compact and general. But this satisfies the requirements!
Here's a JS one that goes into the gazillions 🤔
I’m learning Erlang, and I got to use file I/O and a list comprehension for the unit tests (in the Gist version).
Short version:
In this Gist, there’s a test file with all values from 1 to 999, and a EUnit test that loads this file and generates a test for each value.