Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Fun with words (Golf?)

by japhy (Canon)
on Nov 09, 2005 at 14:47 UTC ( [id://507083]=note: print w/replies, xml ) Need Help??


in reply to Fun with words (Golf?)

In regards to the link that itub posted, one my sisters pointed out that the email that circulated was contradictory. The text of the message is:
Aoccdrnig to rscheearch at Cmabrigde uinervtisy, it deosn't mttaer waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is taht the frist and lsat ltteres are at the rghit pclae. The rset can be a tatol mses and you can sitll raed it wouthit a porbelm. Tihs is bcuseae we do not raed ervey lteter by it slef but the wrod as a wlohe.
The two words in bold have no unjumbled English equivalent, and yet we read them as "research" (only one 'h') and "important" (and 'a' instead of an 'e') respectively.

That aside, it's interesting to see why this phenomenon seems to exist. I ran the following program against my /usr/dict/words file:

#!/usr/bin/perl use strict; use warnings; my %words; while (<>) { chomp($_ = lc); for (/\b\w+(?:'\w+)?\b/g) { next unless length > 3; my $order = join "", sort split //; $words{substr($_, 0, 1) . substr($_, -1, 1)}{$order}{$_} = 1; } } for my $k (sort keys %words) { my @multi = grep keys %{ $words{$k}{$_} } > 1, keys %{ $words{$k} } +or next; print "$k\n"; for my $o (sort @multi) { my $w = $words{$k}{$o}; print " $o (" . keys(%$w) . ") @{[ keys %$w ]}\n"; } }
I get back that there are 1058 pairs of words which are anagrams and that have their first and last letters in common. There are only 52 triplets of such words, and only 1 quadruplet. This is out of 95226 words with 4 or more characters in my /usr/dict/words file.

I ran this on my local copy of the King James bible (doesn't everyone have one of those?) and came up with only 60 pairs of words (and no triplets, quadruplets, etc.).


Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://507083]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-25 07:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found