[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[QUIZ] Panagrams (#86

James Gray

7/7/2006 3:02:00 PM

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.rub...

3. Enjoy!

Suggestion: A [QUIZ] in the subject of emails about the problem helps everyone
on Ruby Talk follow the discussion. Please reply to the original quiz message,
if you can.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

by Darren Kirby

One thing that interests me are word puzzles and language oddities. One such
example is the self-documenting panagram. If a panagram is a sentence that uses
every letter in the alphabet, then a self-documenting panagram is a sentence
that enumerates its own letter count. Simple enough, but what if we state that
the letter count must be spelled ie: 'twenty-seven' instead of '27'. Now we
have a challenge.

A while back I wrote a script in Python that finds these sentences. Today I
rewrote it in Ruby and it found me this sentence:

Darren's ruby panagram program found this sentence which contains exactly
nine 'a's, two 'b's, five 'c's, four 'd's, thirty-five 'e's, nine 'f's,
three 'g's, nine 'h's, sixteen 'i's, one 'j', one 'k', two 'l's, three 'm's,
twenty-seven 'n's, fourteen 'o's, three 'p's, one 'q', fifteen 'r's,
thirty-four 's's, twenty-two 't's, six 'u's, six 'v's, seven 'w's, six 'x's,
seven 'y's, and one 'z'.

My script does have its problems, and I would love to see what kind of code the
Ruby experts could come up with to find self-documenting panagrams.

There is a lot more info on self-documenting panagrams at this address:

http://www.cs.indiana.edu/~tanaka/GEB/p...

28 Answers

matthew.moss.coder

7/7/2006 3:13:00 PM

0

So is it "pangram" or "panagram"?

> There is a lot more info on self-documenting panagrams at this address:
>
> http://www.cs.indiana.edu/~tanaka/GEB/p...

matthew.moss.coder

7/7/2006 3:20:00 PM

0

Nevermind, answered my own question with the dictionary: pangram.


On 7/7/06, Matthew Moss <matthew.moss.coder@gmail.com> wrote:
> So is it "pangram" or "panagram"?
>
> > There is a lot more info on self-documenting panagrams at this address:
> >
> > http://www.cs.indiana.edu/~tanaka/GEB/p...

James Gray

7/7/2006 3:21:00 PM

0

On Jul 7, 2006, at 10:13 AM, Matthew Moss wrote:

> So is it "pangram" or "panagram"?
>
>> There is a lot more info on self-documenting panagrams at this
>> address:
>>
>> http://www.cs.indiana.edu/~tanaka/GEB/p...

Good catch, I didn't even notice the name discrepancy. Pangram does
appear to be the correct term.

James Edward Gray II



Warren Brown

7/7/2006 3:22:00 PM

0

> So is it "pangram" or "panagram"?

The word is "pangram". Some people misspell it as "panagram",
probably due to an association with the word "anagram", another word
puzzle favorite.

- Warren Brown


Brian Mattern

7/7/2006 5:34:00 PM

0

Is it a spoiler if we post a resulting pangram (no code)?

I got one in:
real 1m17.089s
user 1m8.444s
sys 0m2.492s

on an athlon 64 300+

Brian


Brian Mattern

7/7/2006 5:39:00 PM

0

On Sat, Jul 08, 2006 at 02:34:23AM +0900, brian.mattern@gmail.com wrote:
> Is it a spoiler if we post a resulting pangram (no code)?
>
> I got one in:
> real 1m17.089s
> user 1m8.444s
> sys 0m2.492s
>
> on an athlon 64 300+
>
> Brian
>
>

Actually, I lied. Almost correct, but at least one number is off...



James Gray

7/7/2006 6:18:00 PM

0

On Jul 7, 2006, at 12:34 PM, brian.mattern@gmail.com wrote:

> Is it a spoiler if we post a resulting pangram (no code)?

Not at all. Please do.

James Edward Gray II

Brian Mattern

7/7/2006 6:39:00 PM

0

On Sat, Jul 08, 2006 at 03:18:26AM +0900, James Edward Gray II wrote:
> On Jul 7, 2006, at 12:34 PM, brian.mattern@gmail.com wrote:
>
> >Is it a spoiler if we post a resulting pangram (no code)?
>
> Not at all. Please do.
>

How about:

rephorm@boru ~/code/ruby/quiz/pangram $ time ruby pangram.rb > p
real 0m28.613s
user 0m27.474s
sys 0m1.000s

rephorm@boru ~/code/ruby/quiz/pangram $ cat p
a ruby quiz solution found this sentence enumerating four a's, two b's,
two c's, three d's, thirty-four e's, nine f's, three g's, eight h's,
sixteen i's, one j, one k, three l's, two m's, twenty-five n's, fifteen
o's, one p, two q's, eleven r's, twenty-nine s's, twenty-five t's, nine
u's, four v's, nine w's, three x's, six y's, and two z's

rephorm@boru ~/code/ruby/quiz/pangram $ ruby verify.rb p
Sentence passes!



It looks like the exact wording of the prelude has a large effect on how
quickly a solution can be found.

Brian



Brian Mattern

7/7/2006 6:47:00 PM

0

On Sat, Jul 08, 2006 at 03:38:36AM +0900, brian.mattern@gmail.com wrote:
> It looks like the exact wording of the prelude has a large effect on how
> quickly a solution can be found.

... and a good bit of luck rolling the rand() dice :)


Martin DeMello

7/7/2006 7:01:00 PM

0

On 7/8/06, brian.mattern@gmail.com <brian.mattern@gmail.com> wrote:
> On Sat, Jul 08, 2006 at 03:38:36AM +0900, brian.mattern@gmail.com wrote:
> > It looks like the exact wording of the prelude has a large effect on how
> > quickly a solution can be found.
>
> ... and a good bit of luck rolling the rand() dice :)

And here's to you, Mr. Robinson....

martin