my cryptogram program

John Salerno johnjsal at NOSPAMgmail.com
Tue May 16 10:08:23 EDT 2006


Paul Rubin wrote:

> You're trying to make sure that no character maps to itself in the
> cryptogram.  I'm not sure if that's one of the "rules". 

It's a rule for cryptogram puzzles, which is what I'm working on. I'm 
not trying to make complicated hacker-proof codes or anything. :)

> It also looks like upper and lower case letters in the input are
> treated as separate.  For example, "George" become "abcdef" while
> "george" becomes "abcde".  Did you want that?  I don't think it can be
> right, because "trans_letters" has at most 26 characters, but there
> can be 52 separate original letters (26 upper and 26 lower).

You're absolutely right. I forgot about this when I changed some of the 
stuff in the convert_quote function. Originally I did convert the 
original quote to uppercase first, and I forgot to keep that when I made 
some changes.

> As for the efficiency of the above algorithm, well, look at what
> happens after you shuffle the alphabet: the probability that any given
> character maps to something other than itself is 25/26.  That means
> the probability that N letters all map to something other than
> themselves is (25/26)**N.  If N=26, this is about 0.36, so on average
> you'll shuffle about three times, which is not too bad, if you're just
> doing something casual. 

It seems okay so far. I should feed it a really long quote just to see 
how it acts, but aside from that there won't be much heavy processing 
going on.

Thanks for the tips!



More information about the Python-list mailing list