The Shakespeare Conference: SHK 9.0424 Tuesday, 5 May 1998.
[1] From: Larry Weiss <
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
>
Date: Monday, 04 May 1998 13:37:40 -0400
Subj: Re: SHK 9.0391 Re: Illustrated Hamlet
[2] From: Ed Peschko <epeschko@den-mdev1>
Date: Monday, 4 May 1998 15:37:39 -0600 (MDT)
Subj: Re: SHK 9.0414 Re: Anagram
[1]-----------------------------------------------------------------
From: Larry Weiss <
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
>
Date: Monday, 04 May 1998 13:37:40 -0400
Subject: 9.0391 Re: Illustrated Hamlet
Comment: Re: SHK 9.0391 Re: Illustrated Hamlet
I recall that in the 50's Mad Comic Book (before it was a magazine) had
a "primer" version of Hamlet, or, perhaps, a lampoon of the Classics
Comics version. It might still be available in one of the book reprints.
[2]-----------------------------------------------------------------
From: Ed Peschko <epeschko@den-mdev1>
Date: Monday, 4 May 1998 15:37:39 -0600 (MDT)
Subject: 9.0414 Re: Anagram
Comment: Re: SHK 9.0414 Re: Anagram
> I'm from Missouri... show me!
Oh boy.. hope that after this message, you don't curse me as a wanton
waster of bandwith... If you take the first sentence:
To be or not to be: that is the question, whether tis nobler in the mind
to suffer the slings and arrows of outrageous fortune....
and break it into its component letters, you get:
a a a a
b b b
d d
e e e e e e e e e e e e
f f f f
g g
h h h h h h
i i i i i i
l l
m
n n n n n n n n
o o o o o o o o o o o o
q
r r r r r r r r
s s s s s s s s
t t t t t t t t t t t t t t
u u u u u
w w
ignoring punctuation marks. You get the same thing with the second
sentence.
Here's a small script I used to generate the above output, to check it
out (for those who are unix-ites, you can check it out by saving it
after 'cut here', naming the resulting file 'anagram_check.p' and
running:
perl anagram_check.p <file> <file2>
where <file> and <file2> are files containing the text you wish to check
for anagram-ship. If run on:
-------------------------------------------------------------------------------
'To be or not to be: that is the question, whether tis nobler in the
mind
to suffer the slings and arrows of outrageous fortune....'
and
'In one of the Bard's best-thought-of tragedies, our insistent hero,
Hamlet, queries on two fronts about how life turns rotten.'
-------------------------------------------------------------------------------
It should output:
To be or not to be: that is the question, whether tis nobler in the mind
to suffer the slings and arrows of outrageous fortune....
=
a a a a
b b b
d d
e e e e e e e e e e e e
f f f f
g g
h h h h h h
i i i i i i
l l
m
n n n n n n n n
o o o o o o o o o o o o
q
r r r r r r r r
s s s s s s s s
t t t t t t t t t t t t t t
u u u u u
w w
-------------------------------------------------------------
In one of the Bard's best-thought-of tragedies, our insistent hero,
Hamlet, queries on two fronts about how life turns rotten.
a a a a
b b b
d d
e e e e e e e e e e e e
f f f f
g g
h h h h h h
i i i i i i
l l
m
n n n n n n n n
o o o o o o o o o o o o
q
r r r r r r r r
s s s s s s s s
t t t t t t t t t t t t t t
u u u u u
w w
-------------------------------------------------------------
The two statements are anagrams!
If you don't trust the script, try changing any of the letters, adding
or deleting, or whatever. I dare you...
Ed
Here's the script:
-- cut here --
undef $/; # slurp everything in a file in
one step
open (FH, "$ARGV[0]"); # open first file
open (FH2,"$ARGV[1]"); # open second file
$line1 = <FH>; # slurp first file
$line2 = <FH2>; # slurp second file
while ($char = substr($line1, $xx++, 1))
{ # go through output a character
a time
$char = lc($char); # lowercase it
$charhash1{$char} .= " $char"; # save it in a hash ((aka
dictionary).
} # $dog{'name'} = 'spot';
# print $dog{'name'}; # prints
spot.)
$xx = 0;
while ($char = substr($line2, $xx++, 1))
{ # do same for second thing
(really
$char = lc($char); # should be a function)
$charhash2{$char} .= " $char";
}
%combined = (%charhash1, %charhash2); # get a combined hash, with both
of
# the lines letters
foreach $key (sort grep(m"[a-z]", keys(%combined))) # look through each
letter
{ # in both of the
anagram
if ($charhash1{$key} ne $charhash2{$key}) # candidates.
{ # If not equal,
note as
$output1 .= "> $charhash1{$key}\n"; # such.
$output2 .= "> $charhash2{$key}\n";
$not_anagram = 1;
}
else
{ # we have a match
for that
$output1 .= "$charhash1{$key}\n"; # letter.
$output2 .= "$charhash2{$key}\n";
}
}
print "$line1\n=\n"; # print everything out.
print "$output1";
print "----------------------------------------------------------\n";
print "$line2\n=\n";
print "$output2";
print "----------------------------------------------------------\n";
if ($not_anagram) # Make our judgement.
{ # based on all the
facts.
print "The two statements are NOT anagrams!\n";
}
else
{
print "The two statements are anagrams!\n";
}
|