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

Re: (Golf) mobile phone numbers - words

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


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

Not a solution, just helping others to solve the problem:

I would assume that the dictionary is already stored as @d. Also, the number to letters translation matrix is stored as a hash of arrays:

my %a = ( 1 => [], 2 => [a,b,c], 3 => [d,e,f], etc... );
This should help everyone start from the same footing.


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
Re: Re: (Golf) mobile phone numbers - words
by mischief (Hermit) on May 29, 2001 at 15:57 UTC
    You could also store it as an array:
    my @letters = ( undef, undef, ['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i'], ['j', 'k', 'l'],
    etc.
      As it's a Golf, you should use $[=1 or 2 to change array's indice.
      BTW: I don't really understand your problem.

      Update: thanks mischief, for yor explanation.

      BobiOne KenoBi

        The challenge is to write the shortest sub, so changing the indice wouldn't matter.

        The problem is to figure out possible words that you could use instead of your number. Like someone can say "call me on 0602 SEX MAD", and their number would be 0602 739 623, because the letters S E X M A D correspond to the numbers 739 623 on the keypad.

Re (tilly) 2: (Golf) mobile phone numbers - words
by tilly (Archbishop) on May 29, 2001 at 16:57 UTC
    I think there is room for creativity here...
    %d=map{($_,int((-90+ord)/3.14))}"a".."p","r".."y";
      The only critique I have on that is that some phones do have 'q' and 'z' (on the 7 and 9 respectively). While chances are that for the problem at hand, adding q and z won't increase the word set that much, there's still a possiblity of doing so.

      Though I find it rather interesting that PI comes into play, though that's probably a rementent from the rotary phone era.


      Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2014-12-29 09:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (185 votes), past polls