Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: (Golf) mobile phone numbers - words

by Masem (Monsignor)
on May 29, 2001 at 17:32 UTC ( #83918=note: print w/ replies, xml ) Need Help??


in reply to (Golf) mobile phone numbers -> words

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


Comment on Re: (Golf) mobile phone numbers - words
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://83918]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2015-07-05 13:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls