And as a starting solution, here's mine at 133 characters:
my @d = qw( respect strength ); # yeah, weak dictionary, sue me!
my $n = "7377328";
my %a = ( 1=>[],
2=>['a','b','c'],
3=>['d','e','f'],
4=>['g','h','i'],
5=>['j','k','l'],
6=>['m','n','o'],
7=>['p','q','r','s'],
8=>['t','u','v'],
9=>['w','x','y','z']
);
my @r = words( $n, \%a, \@d );
print join ",",@r;
print "\n";
sub words{
#234567890123456789012345678901234567890123456789012345678901234567890
+123456789012345678901234567890123
my($n,$a,$d,@l,@b,$c,$e)=@_;@b=split//,$n;@a=('');for(@b){$c=$_;@a=map
+{$e=$_;map{$e.$_}@{$a->{$c}}}@a};
grep{$c=$_;grep{$c eq$_}@$d}@a
}
Note that if %a was an array, it would only change a set of curly braces to square ones, and would not change the character count.
update ok, this only handles the case of matching exactly one word from the dictionary; more work would be needed to find any word combo.
Dr. Michael K. Neylon - mneylon-pm@masemware.com
||
"You've left the lens cap of your mind on again, Pinky" - The Brain
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.