[Tutor] comapring lists

Kent Johnson kent37 at tds.net
Wed Dec 1 04:18:43 CET 2004


And the arithmetic needs to be on the indices in the character arrays, not the actual character 
values, because the intended character set actually has several distinct ranges - a-z, A-Z and 0-9.

Kent

Max Noel wrote:
> 
> On Dec 1, 2004, at 03:03, Kent Johnson wrote:
> 
>> If you want to stay within the same character set you need to do some 
>> wraparound at the ends, otherwise you have things like
>> >>> chr(ord('9') + 1)
>> ':'
>> >>> chr(ord('Z') + 1)
>> '['
> 
> 
>     For that, it's best to use the modulo operator (%), of course. The 
> "general" algorithm is something like:
> 
> character = base_offset + ((original - base_offset + key) % size)
> 
> -- Max
> maxnoel_fr at yahoo dot fr -- ICQ #85274019
> "Look at you hacker... A pathetic creature of meat and bone, panting and 
> sweating as you run through my corridors... How can you challenge a 
> perfect, immortal machine?"
> 
> 


More information about the Tutor mailing list