Overall a successfull challenge as far as visitor participation. Unfortunately there were a lot of questions with the rules as people created their entry. The hardest part about these type of challenges is covering every possibility.
There were 41 entries submitted with 16 valid entries. Out of the 16 valid entries 6 failed on 1 small error that was partly my fault. In the rules the limit on digits was 66, but in the numbertext form you could put any number of zeros and it would still return 'Zero'. I didn't want to disqualify those entries for this, I also didn't want to take away from the entries that knew and considered this bug. So each entry you see listed with a * means it is one of the semi-invalid entries.
warrior 228 bytes
I allowed warrior to send in his entry that sort of exploited the countcode script and endcoded his entry. This is not valid, but a clever idea and worth a mention.
Description:
In this challenge you're asked to convert any number to it's numeral term in smallest code possible.
For example: 12,345 would become Twelve Thousand Three Hundred Forty-Five or 371,933,002 converted would be Three Hundred Seventy-One Million Nine Hundred Thirty-Three Thousand Two.
I understand there will be some differences in the numeral term for different languages.
For this challenge we will be using American English.
I created a form that does the same conversion for validation purposes.
Rules:
Only one script file (as in remote file) allowed. Each file must be named <yourname>_numbertext.mrc (eg. fubar_numbertext.mrc)
One entry per person. Don't ask if you can re-submit.
Entries must convert numbers exactly how the numbertext form does.
Names of numbers must be spelled correctly.
No socket connections.
All entries must use $numconv(<num>) to return your conversion. (eg. //echo -a $numconv(123) )
Must do error checking. Making sure only numbers get converted. '$numconv(blah)' should return an error.
All errors must return "Invalid" only.
Commas and decimal points must be allowed when converting. (eg. 12345 or 12,345 or 12,345.123 should be acceptable) - Any number of commas are allowed. - One decimal allowed, extra decimals is not a valid number: 12.32.32 = Invalid, 12.32 = Twelve
You do not have to convert decimals. Whole numbers is all we're looking for.
Only positive numbers. (eg. -100 = Invalid).
Number limit will be 66 digits. 999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999
Important: Each challenge will be judged by correct conversion and smallest code size. The size of each entry will be measured using a script that removes carriage returns, linefeeds, empty lines, trailing or ending spaces.
This will be the file we'll be using, countcode.mrc.
Update: There's been a lot of questions about spaces being used in your identifier. So I made a little change.. You now only have to worry about the first number entered.
For example: " 1423 123 3312" should become One Thousand Four Hundred Twenty-Three
I also updated the numbertext form for this. Sorry for the confusion.
Info:
Here is a list of english names for numbers needed in order.
Zero, One, Two, Three, Four, Five, Six, Seven, Eight, Nine
If commas are used in the number to be converted do they have to be correct, as in 123,456,789 or can they be 1,2,3,4,5,65?
We're not going to be strict on the commas, only because they're optional. So you're basically removing them. You still must allow them with numbers as valid though.
Do the names have to be case sensitive?
Nope. For example you can do one thousand two hundred thirty-four. However they must be spelled correctly.
Why are there 3 different ways returned on the numbertext page?
That's just to make it optional for people that have a preference of using "," or "and" as a seperator.
What should .123 return?
Zero
What should +123 or -123 return?
Invalid
What happens if no parameters are supplied? ie. $numconv()
$numconv() shouldn't return anything. As in $null
What about spaces entered in $numconv()?
If you enter " 12 345" it should return Twelve. Only the first group of numbers separated by spaces should be evaluated.
Does the total length (66 digits) include numbers after the decimal point?
No, for example: 123.456 is 3 digits and 1,234.567 is 4 digits.