On 28 Mar 2001, Jasvir Nagra wrote: > > print "love" & "hate"; # Hate if you want both > print "love" | "hate"; # Love if you have a choice > print "good" & "bad"; # Badness overwhelms > > The challenge is to write some perl, that looks through a list of > words and prints pairs of Bulleans. > > perl -e'chomp(@_=<>);map{$c=$_;map{print"$c $_\n"if!($_ eq$c)&&(($_&$c)eq$_)}@_}@_' perl -le'chop(@x=<>);for$x(@x){($x&$_)eq$_&&$_ ne$x&&print"$x $_"for@x}' And I didn't even really try to shorten that, except for s/chomp/chop/. There's probably still room for improvement. However, the output of either program isn't particularly interesting, since there's a lot of repetition. The reason for that is that for any Bullean pair ($a, $b), ($a.$c, $b) is also a Bullean for any string $c. So, for that matter, is ($a, substr($b,0,$n)) for any integer $n. And for any words $a and $b, ($a.$b, $a) is trivially a Bullean pair. It would therefore seem more interesting to only select those pairs of Bulleans where the first string is as short and the second as long as possible. Equal length is the best possible solution, but can't always be achieved in practice. It might be a good idea to eliminate some other pairs as well, such as those that are like another known pair except for a common prefix. No I haven't written that. Yet.. -- Ilmari Karonen - http://www.sci.fi/~iltzu/ "[A nuclear bomb] *is* controlled - they want it to explode, they make it explode." -- JamesBWard in rec.arts.sf.science ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe