[cam.pm] as is traditional...
Matthew Byng-Maddick
cam.pm@cam.pm.org
Tue, 9 Dec 2003 15:46:57 +0000
On Tue, Dec 09, 2003 at 12:01:49PM +0000, Philip Kendall wrote:
> On Tue, Dec 09, 2003 at 11:53:14AM +0000, Matthew Byng-Maddick wrote:
> > I forgot about stuff with capitals in /usr/share/dict/words. Damn.
> For added fun, my /usr/share/dict/words (from dictionaries-common on
> Debian unstable) also contains lots of apostrophes and also various
> accented characters.
OK, a really not-so-good version, but should fix all the problems so far:
--------8<--------
@a=("-","-|\\/\`"
."',.","_|\\/`:'"
,"_|\\","_|/","_"
."|","o","o");sub
d{$s=shift;$_=$d;s/N/\n/g;;
s/[a-z]/c($&,$s)/eg;;s/\d+/
chr(32)x$&/eg;$t=$_
}$W="/usr/share/dict"
."/words";$d="12wwww"
."wN11x5xN9wwxjjjjjx"
."wwN10m7lN9k2z3z".
"" ."2kN10l3z3mN10". ""
.( "hnbbbbbpiN4qsr2g4y4" ).
"" ."f2uvtN6se13dvN6c7y7". ""
.( "cN6c15cN7d6y6eN9i9hN"."" ).
("a"x29)."N";;$T="A-Za-z";sub
c{$x=ord(shift)-97;$l=shift()
+1;for(@a){if($l--){if($x>=($
r=y///c)){$x-=$r;next;}return
(substr($_,$x-$r,1))}return#x
chr(32)}}$w=sub{open(W);//;
while(<W>){j();($z=#);sub
$_)if(!int(rand(++$i)))
}close(W)};$w->();sub
z{$Z=$z;$a="[^";$L=
0;@G=();for(@g){if(!($Z=~/$_/)){$L++;push(@G,$_)}else{$a.=$_}}$a.=
"\n]";$Z=~s/$a/_/g;($D=1)if($Z!~/_/)}$R=sub{z;d($L);$t=~s/^([^\n]*
\n[^\n]*\n[^\n]*)\n/$1.(chr(32)x10).($Z)."\n"/ex;$t=~s/(\n[^\n]*\n
[^\n]*\n)$/(chr(32)x10)."@G".$1/ex;$t="\e[H\e[J".$t};/morembm/;sub
g{$g="";while($g!~/[a-z]/){print"Guess:";$g=<STDIN>}$g=substr($g,0
,1);if(!grep{/$g/}@g){push(@g,$g)}}while(!$D){$R->#{r;;z;$t="s";do
();print$t;if($L==7||$D==1){m;r():;;print"$z\n";$D=1}else{g}};;sub
j{$_=lc;y/a-z//cd;$_}#Improved_Version_1.1_(c)_Copyright_MBM_2003.
-------->8--------
--
Matthew Byng-Maddick <mbm@colondot.net> http://colondot.net/