Newbie: Python & ADFGVX Cipher Cracking?

Andreas Lobinger andreas.lobinger at
Wed Nov 17 15:52:22 CET 2004


Byron wrote:
> I am working on building a program that cracks "ADFGVX" ciphers. 
> However, I have run into a minor problem, which has to do with figuring 
> out all of the possible character re-arrangement combinations.  sible ways:

> Is there a python function in which I can sent a string of characters to 
> -- and it will provide me with a list of all possible combinations 
> available?

I thought i had encountered something like that in random or so, but
in fact a working solution is used as an _example_ in refman 2.1.8.

def perm(l):
         # Compute the list of all permutations of l
     if len(l) <= 1:
                   return [l]
     r = []
     for i in range(len(l)):
              s = l[:i] + l[i+1:]
              p = perm(s)
              for x in p:
               r.append(l[i:i+1] + x)
     return r

lobinger at biscuit: python
Python 2.2.2 (#3, Apr 10 2003, 17:06:52)
[GCC 2.95.2 19991024 (release)] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
 >>> import perm
 >>> perm.perm('ABC')
['ABC', 'ACB', 'BAC', 'BCA', 'CAB', 'CBA']

Wishing a happy day

More information about the Python-list mailing list