Velocity Reviews > Ruby > [QUIZ] English Numerals (#25)

# [QUIZ] English Numerals (#25)

Ruby Quiz
Guest
Posts: n/a

 03-25-2005
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)

"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:

Patrick Hurley
Guest
Posts: n/a

 03-25-2005
On Sat, 26 Mar 2005 05:18:43 +0900, Ruby Quiz <(E-Mail Removed)> 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)
>
> "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)?

Timothy Byrd
Guest
Posts: n/a

 03-25-2005
> Ok sounds interesting, is the rule, less than 2000

Close. It's at least 1100 and less than 2000, so:

1000 -> one thousand
1100 -> eleven hundred
1900 -> nineteen hundred
2000 -> two thousand

> Also what are the rules for the "and"?

I was assuming the "and" only goes in the final three digits and only
if not a multiple of 100, so your:

> 1050050 -> one million fifty thousand and fifty

is what I'd pick.

> Also we hyphenate when 20 < x > 100 (and not a multple of 10)?

Yes, between 20 and 100 (non-inclusive). This applies to each group of
three digits, so:

57057057 -> fifty-seven million fifty-seven thousand and fifty-seven

Hope that clears things up.

BTW, here's a fun-fact on the original post:

7 == seven (the hard way)

In the dice game craps, a "hardway" bet is that a number
will come up as a pair rather than some other combination.
For example a six would have to be a pair of 3's rather than
5 & 1 or 4 & 2. Sevewn the hard way would require rolling a
pair of 3.5's, which is generally considered quite difficult.
(See http://stuffo.howstuffworks.com/craps7.htm )

-- Timothy

Hal Fulton
Guest
Posts: n/a

 03-25-2005
Hans Fugal wrote:
> Patrick Hurley wrote:
>
>> 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)?

>
>
> I was always taught there is no and (except at the decimal place), e.g.
> one million fifty thousand fifty and five tenths. I don't remember who
> taught this but I remember learning it disctinctly.

I was taught this, too. They stressed it, in fact, as though it
were something that actually mattered.

> That hyphenation thing gives me a headache. What's wrong with
> one hundred twenty five?

I have never seen "twenty five" in English -- AFAIK it's always
hyphenated.

Hal

Joe Van Dyk
Guest
Posts: n/a

 03-25-2005
Ruby Quiz 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

Why is one "two thousand and one" and one "nineteen hundred and
ninety-nine"?

>
> So the quiz is a problem from a Pi Mu Epsilon (US
>
> "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:
>
> http://www.mandarintools.com/numbers.html

Timothy Byrd
Guest
Posts: n/a

 03-25-2005
> I was always taught there is no and (except at the decimal
> place), e.g. one million fifty thousand fifty and five tenths.
> I don't remember who taught this but I remember learning it
> disctinctly.

Well, numbers aren't really exact things, after all.

I wanted to put a little twist into the quiz, and "two thousand and
one" simply sounds right. (Though I had to break 1776 to get it.)

http://www.absoluteastronomy.com/enc...in_English.htm

-- Timothy

Hal Fulton
Guest
Posts: n/a

 03-25-2005
Timothy Byrd wrote:
>>I was always taught there is no and (except at the decimal
>>place), e.g. one million fifty thousand fifty and five tenths.
>>I don't remember who taught this but I remember learning it
>>disctinctly.

>
>
> Well, numbers aren't really exact things, after all.
>
> I wanted to put a little twist into the quiz, and "two thousand and
> one" simply sounds right. (Though I had to break 1776 to get it.)
>
>
> http://www.absoluteastronomy.com/enc...in_English.htm

The "and" is not my only problem with that page.

For example, they think "one hundred" is singular? Please.

By the way, I hear that one hundred are expected at the
next Ruby Conf...

Hal

Timothy Byrd
Guest
Posts: n/a

 03-26-2005
> For example, they think "one hundred" is singular? Please.
>
> By the way, I hear that one hundred are expected at the
> next Ruby Conf...

Well, "one hundred" is a good number.

(Going even more off topic.) That just reminded me of something. In
the US, the media refer to corporations in the singular - "Microsoft is
a ...". But I seem to recall reading British articles that use
"Microsoft are going to ..."

-- Timothy

Hal Fulton
Guest
Posts: n/a

 03-26-2005
Timothy Byrd wrote:
>>For example, they think "one hundred" is singular? Please.
>>
>>By the way, I hear that one hundred are expected at the
>>next Ruby Conf...

>
>
> Well, "one hundred" is a good number.
>
> (Going even more off topic.) That just reminded me of something. In
> the US, the media refer to corporations in the singular - "Microsoft is
> a ...". But I seem to recall reading British articles that use
> "Microsoft are going to ..."

Yes. Don't get me started.

Those are called "collective nouns." They appear singular but
act as a plural and should be treated plurally. Thus "Microsoft
are" is correct, and "Microsoft is" is a failure of the US
education system.

I can see the rationale that a corporation is a single entity.
But when it's time for a pronoun, even Americans go for the
plural -- even in the same sentence:

"Microsoft are angry, and they plan to sue." (UK/correct)
"Microsoft is angry, and it plans to sue." (at least consistent)
"Microsoft is angry, and they plan to sue." (American)

Hal

Patrick Hurley
Guest
Posts: n/a

 03-26-2005
On Sat, 26 Mar 2005 07:54:49 +0900, Timothy Byrd <(E-Mail Removed)> wrote:
> > I was always taught there is no and (except at the decimal
> > place), e.g. one million fifty thousand fifty and five tenths.
> > I don't remember who taught this but I remember learning it
> > disctinctly.

>
> Well, numbers aren't really exact things, after all.
>
> I wanted to put a little twist into the quiz, and "two thousand and
> one" simply sounds right. (Though I had to break 1776 to get it.)
>
>
> http://www.absoluteastronomy.com/enc...in_English.htm
>
> -- Timothy
>
>

Ok almost done asking for information before I hide from my kids and
do the quiz

One last quesiton should'nt we have comma's between number clauses?

i.e.

1_111_111_111

one billion, one hundred eleven million, one hundred eleven thousand
and one hundred eleven

Patrick