Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
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

In reply to Re: (Golf) mobile phone numbers - words by Masem
in thread (Golf) mobile phone numbers -> words by mischief

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (11)
    As of 2014-08-28 11:34 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (259 votes), past polls