From: landman@hal.COM (Howard Landman)
Newsgroups: alt.fan.mike-jittlov,alt.religion.kibology
Subject: Re: WIZARD - the Nostradamus of Movies!
Keywords: Wizard, Kuwait, bizarre, "coincidence"
Date: 19 Dec 92 02:58:55 GMT
Organization: HaL Computer Systems, Inc.
NNTP-Posting-Host: bang.hal.com

>In <1gnb87INNp40@gap.caltech.edu> jittlov@gumby.cs.caltech.edu (Mike Jittlov) writes:
>>A studious glance reveals a mere handful:  by, lo, bay, boy, buy,
>>dew, dow, flu, got, get, leo, man, men, ssh, tag, teg, tog, tug,
>>wad, wed, vole (love), bevy, trig, girt, wold, world, Ariz(ona).
>> ghost ...

In article <BzDwnG.Kxo@world.std.com> kibo@world.std.com (James "Kibo" Parry) writes:
>ghost->tslhg?  Are you skipping the central letter?
>
> egrep -v '[A-Z]' </usr/dict/words >/tmp/words
> tr a-z zyxwvutsrqponmlkjihgfedcba </tmp/words | rev >/tmp/wurds
> sort /tmp/wurds | comm -12 - /tmp/words | egrep '..' | pr -5 -l20 -t
>
>On a UNIX system, that will give you all words which map onto other ones.
>picking out of those words that map to themselves, like "wizard", is
>left as an exercise for the reader.

A nice try, but Kibo's algorithm begins by throwing out all words which
contain capital letters.  There's no justification for this, and it leads
to missing "Polk", as well as some 2 letter state codes.

Here's a Perl script which is better, but still doesn't match Mike.
-------------------------------------------------------
#!/usr/local/bin/perl
open(DICT,"/usr/dict/words") ;
while(<DICT>)
{
	chop ;						# Get rid of newline
	next if /[^A-Za-z]/ ;				# No non-alpha chars
	($word = ($Word = $_)) =~ tr/A-Z/a-z/ ;		# convert to lower case
	$palin = reverse($word) ;
	$palin =~ tr/a-z/zyxwvutsrqponmlkjihgfedcba/ ;
	print $Word, "\n" if ($palin eq $word) ;
}
close(DICT) ;
-------------------------------------------------------

The difference is that Mike allows the middle letter of words with odd numbers
of letters to be anything.  This is perhaps reasonable, because no letter is
its own inverse (in an alphabet with an even number of letters), and so by
my script no word with an odd number of letters can possibly qualify.

Anyway what I got was:
AZ bevy by grit IR lo MN NM Polk RI trig wizard wold

It's interesting that both AZ and Ariz work.

The necessary correction to match Mike's criterion is to insert the lines:
-------------------------------------------------------
	# Only have to compare half the word.
	$l = length($Word) ;
	substr($word,$l/2) = '' ;			# Chop off last half
	substr($palin,$l/2) = '' ;			# of both strings.
-------------------------------------------------------
just before the "print" statement in the previous program.  Then I get:

AZ bay bevy bey bigotry boy buy by cox Croix dew Dow flu get ghost GMT got
grit gut his IR Lao Leo lo man men min MN NM oil owl Polk RI shish tag tog
trig tug UHF vee verve vie wad wed wizard wold world would
(plus of course all the single letters)

Apparently, "vole" and "girt" are missing from /usr/dict/words.  Ah well.
Also "ssh" and "teg", which I don't recognize as words.

Note that this code subtly drops the middle character of odd-length words
due to the rounding down of $l/2.  If I didn't want to do this, I'd have
to write ($l+1)/2.  So in that sense, Mike's criterion is more natural,
at least in Perl.

	Howard A. Landman
	landman@hal.com
	(408) 246-7853 (CHORTLE)
	Observe how this phone number was carefully chosen to use seven
	different digits, thus maximizing the exercise your fingers get
	and reducing the probability of repetitive stress disorder from
	frequent dialing!
Newsgroups: alt.fan.mike-jittlov,alt.politics.kibo