lolamontes69

Python/ Cue Programming 3

May 19th, 2013
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. from itertools import combinations, chain
  2. allsubsets = lambda n: list(chain(*[combinations(range(n), ni) for ni in range(n+1)]))
  3.  
  4. print "Creating subsets..."
  5. a = allsubsets(22)
  6. # Example output [(), (0,), (1,), (2,), (0, 1), (0, 2), (1, 2), (0, 1, 2)]
  7.  
  8. list3 = [3, 4, 9, 14, 15, 19, 28, 37, 47, 50, 54, 56, 59, 61, 70, 73, 78, 81, 92, 95, 97, 99]
  9.  
  10. count = 0          # Used to filter out the first blank subset
  11. count1 = 0         # Used for the sum of the numbers in each subset
  12. result1 = 0        # When subsets
  13. for b in a:
  14.     if len(b) == 8:    # After len(subset) = 8 there are no possible further matches
  15.         print "The Third Password is :", result1
  16.         break
  17.     if count == 0: count += 1    # Filter out the first blank subset
  18.     else:
  19.         if len(b) > 1:    # Filter out subsets with one number in them
  20.             count1 = 0
  21.             for c in b: count1 += int(list3[c])
  22.             if count1 in list3: result1 = int(result1 + 1)
Advertisement
Add Comment
Please, Sign In to add comment