Advertisement
Guest User

Untitled

a guest
May 19th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. s = input()
  2. i = s.find(' ')
  3. n = int(s[0: i])
  4. m = int(s[i + 1: len(s)])
  5. strings = []
  6. for i in range(n):
  7. s = input()
  8. strings.append(s[0: m + 1])
  9. pn = int(input())
  10.  
  11. passwords = ['']
  12.  
  13. def generate_password(i = 0, j = 0, n = 0, m = 0, password = ''):
  14. if ((i < n) or (j < m)):
  15. password = password + strings[i][j]
  16. if (i < n):
  17. generate_password(i + 1, j, n, m, password)
  18. if (j < m):
  19. generate_password(i, j + 1, n, m, password)
  20. else:
  21. passwords.append(password)
  22. print(password)
  23.  
  24. generate_password(0, 0, n, m, '')
  25.  
  26. passwords
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement