First of all, I'm not a perl monk, so my coding style isn't quite as pretty as yours. I have to stare at stuff like:

return if grep /$let/,join("",values %seen);

for about 3 minutes before I say "ok, I know what you're doing, but I didn't know you could do that..." :)

I did find the bug in my code before I saw your solution, but yours is obviously more elegant. I just might steal your version. :)

As for using this as a brute force decrypter -- yes, it is easy in theory. But it takes me about 4 hours to code up the thing you just saw above. Writing the entire thing is not a trivial task for me.

Can you give me some tips on how I should approach the rest of the problem? So far, my approach has been pretty unelegant. What's the best way to recurse through all the possible words for each codeword? I have written a program that generates a partial cipher alphabet and compares two cipher alphabets to see how many entries mismatch. I'm concerned about doing the recursive part in a dumb way and eating up a ton of memory resources unnecessarily.

Thanks again for all your help guys.


In reply to Re: Re: Cryptogram Solver by pchou
in thread Cryptogram Solver by pchou

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.