[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] crypt() fun



On Mon, Jun 12, 2000 at 05:46:34PM -0400, Jeff Pinyan wrote:
> I'm not sure my sysadmin would be thrilled if I ran a program that did
>   @chars = ('a' .. 'z', 'A' .. 'Z', 0 .. 9, '/', '.');
>   for $a (@chars) {
>     for $b (@chars) {
>       # later...
>         for $l (@chars) {
>           for $m (@chars) {
>             $word = "$a$b$c$d$e$f$g$h$i$j$k$l$m";
>             print $word if $word eq crypt($word,$word);

I did a similar thing to find Sallows pangrams (you know, like:

Adam Sampson found this sentence, which includes five As, one B, four Cs,
five Ds, thirty-eight Es, nine Fs, five Gs, thirteen Hs, seventeen Is, one
J, one K, two Ls, three Ms, twenty-three Ns, thirteen Os, two Ps, one Q,
eight Rs, twenty-eight Ss, twenty-four Ts, five Us, eight Vs, seven Ws, one
X, five Ys, and one Z.

). The way you find those is to start off with a wrong sentence (random
numbers), then produce a new one which counts the letters in the old one and
repeat until you find a sentence that describes itself. You could apply the
same method to this:

#!/usr/bin/perl
@a = ('a'..'z', 'A'..'Z', '0'..'9', '/', '.');
$w = join "", map { $a[rand @a] } 0..10;
$w = crypt($c = $w, (substr $w, 2)) while ($c ne $w);
print "$w\n";

Not that it's found any results yet. ;)

-- 

Adam Sampson
azz@gnu.org

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe