Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
tilly,
Thank you for your feedback. You ask a number of questions and the answer to them is almost all of them is the same. I was lazy and in a hurry.

Why do you have the ability to store multiple words with the exact same characters?

Primarily because I was lazy and copied my own code from Re^3: One for the weekend: challenge. There it made sense and here it doesn't. While it is a cardinal sin to assume your input will be what you expect, the %seen hash should prevent duplicate solutions.

A stylistic issue. I'd recursively traverse the character to add words. Using eval there is an error-prone sledgehammer. What happens with words that include single quotes? You're trusting your input in a way that I avoid.

Well, we have had this conversation in the past. My brain just doesn't seem to think recursively without a lot of effort on my part. Even if I hadn't borrowed from a previous solution and avoided the evil eval, I still would have iterated. Regarding the evil eval sledgehammer: Any word containing anything other than lower case chars is skipped but I realize that it makes the code fragile and prone to breaking if requirements change. The real reason is laziness again. In the original solution, as with this solution, runtime speed was an issue and it took longer without the evil eval. In this case it is a moot point because build_db.pl runs independently of the main program so speed was not a factor and could have been avoided.

One minor note. Instead of a breadth-first search, my natural inclination would be a depth-first recursive search...

Yes, but my natural inclination is to avoid anything recursive with a very long pole. I have done a DFS iteratively and it is ugly. I was more interested in the results than in maintainable robust code. I spent far more time trying to compile a word list than the few minutes it took me to update a previous solution.

Thank you again for your feedback. I was able to buy an eBook containing the TWL ($0.99 + $0.40 tax) and have the solution I want without needing to change the algorithm. Currently, I am eating 12 seconds of the 3 minutes. This includes:

  1. Switching from the browser window to the command window
  2. Typing the 25 letters in the grid and hitting return
  3. Switching back to the browser window
The majority of that time is spent correctly typing the 25 letters and the artificial 1 second sleep delay to ensure I can switch to the browser window before the code starts generating results.

Cheers - L~R


In reply to Re^2: Improve My FaceBook Scramble Solver by Limbic~Region
in thread Improve My FaceBook Scramble Solver by Limbic~Region

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-04-19 13:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found