Advertisement
Guest User

day4_part2

a guest
Dec 16th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. def getSortedStr(s):
  2.     return ''.join(sorted(s))
  3.  
  4. _input = open('d3_passes.txt')
  5. n_good_pswd = 0
  6. for pswd in _input:
  7.     words = pswd.split()
  8.     n_words = len(words)
  9.    
  10.     for i in range(n_words):
  11.         words[i] = getSortedStr(words[i])
  12.     words.sort()
  13.     #print(words)
  14.    
  15.     n_good_pswd += 1
  16.     for i in range(n_words - 1):
  17.         if words[i] == words[i+1]:
  18.             n_good_pswd -= 1
  19.             break
  20. print(n_good_pswd)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement