Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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 - || "You've left the lens cap of your mind on again, Pinky" - The Brain

Comment on Re: (Golf) mobile phone numbers - words
Download Code
Replies are listed 'Best First'.
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...
      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 - || "You've left the lens cap of your mind on again, Pinky" - The Brain
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'],
      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.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (11)
As of 2015-11-25 18:52 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (685 votes), past polls