Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: One for the weekend: challenge

by dragonchild (Archbishop)
on May 31, 2008 at 01:01 UTC ( #689372=note: print w/ replies, xml ) Need Help??


in reply to One for the weekend: challenge

The problem is not only suited to Lisp because of the reason Anonymonk gave, but also because the most elegant solution to this problem is one that requires more exposure to CS than most Java programmers (in my experience) tend to have. I just coded up something similar in JS for a Go-playing program I'm playing with (thanks to tye's NextPermute() implementation in Algorithm::Loops). I have no desire to actually write it, so I'll give my plan in readmore tags below.

The problem is really a graph-walking problem. Each letter corresponds to a set of vertices. The phone number creates a graph between each set of letters along with the punctuation. Once the graph is created, you walk all the various end-to-end paths (using NextPermute(), for example) and compare the resulting string with the dictionary. Shouldn't take more than 100 lines.


My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?


Comment on Re: One for the weekend: challenge
Re^2: One for the weekend: challenge
by BrowserUk (Pope) on May 31, 2008 at 01:16 UTC

    All I can say in response is a) I would love to see your approach coded; b) you will not appreciate the complexity of the problem until you have attempted to code a solution.

    The devil, as always, is in the detail. Performing the mappings is relatively simple, but avoiding the production of the cases that are explicitly excluded: Particularly

    1078-913-5: je Bo" 9 1 da , since there are two subsequent digits in the encoding

    Throws most initial and theoretical solutions into a cocked hat.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (13)
As of 2014-09-02 12:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (22 votes), past polls