On Sat, 26 Mar 2005 05:18:43 +0900, Ruby Quiz <james / grayproductions.net> wrote: > The three rules of Ruby Quiz: > > 1. Please do not post any solutions or spoiler discussion for this quiz until > 48 hours have passed from the time on this message. > > 2. Support Ruby Quiz by submitting ideas as often as you can: > > http://www.rubyquiz.com/ > > 3. Enjoy! > > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > > by Timothy Byrd > > While we normally write numbers using Arabic (or since Quiz #22, Roman) > numerals, numbers can also be written out as English phrases. > > For example: > > 7 == seven (the hard way) > 42 == forty-two (a very important number) > 2001 == two thousand and one (a space odyssey) > 1999 == (party like it's) nineteen hundred and ninety-nine > > So the quiz is a problem from a Pi Mu Epsilon (US national math club) > newsletter: > > "When the integers 1 to 10_000_000_000 are written in the English language, then > sorted as strings, which odd number appears first in the list?" > > Your mission, should you choose to accept it, is to: > > - Create Ruby code to translate a number to it's English language form. (My > sample version works with integers up to 10**72-1.) > > - Determine programmatically which odd number in 1..10_000_000_000 would sort > first if written in English. (Brute force is the obvious solution, but the > computer may have to think about it...) > > - Would the answer change for a larger range of values, say 10**30? > > - Do French and German Rubyists get a different answer than the Americans? > > Extra credit: > > -Add a Pinyin translator: http://www.mandarintools.com/numbers.html > > Ok sounds interesting, is the rule, less than 2000 1000 -> ten hundred 1800 -> eighteen hundred 2000 -> two thousand Also what are the rules for the "and"? 1050050 -> one million fifty thousand and fifty or 1050050 -> one million and fifty thousand and fifty Also we hyphenate when 20 < x > 100 (and not a multple of 10)?