-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday4-2.py
More file actions
43 lines (37 loc) · 1.03 KB
/
Copy pathday4-2.py
File metadata and controls
43 lines (37 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
#input function for both python2.7 and 3
def getInput(prompt=''):
try:
line = raw_input(prompt)
except NameError:
line = input(prompt)
return line
print('Enter/paste content. Ctrl-D to save. ', end='')
pw_list = []
while True:
try:
line = getInput()
except EOFError:
break
pw_list.append(line)
def sortList(list):
for word in range(len(list)):
sorted_word = ''.join(sorted(list[word]))
list[word] = sorted_word
return list
ok_passphrases = 0
for line in pw_list:
this_row = line.split()
this_row = sortList(this_row)
last_word = len(this_row) - 1
current_word = 0
for word in this_row:
if this_row.count(word) != 1:
continue
elif current_word != last_word:
current_word += 1
elif current_word == last_word:
ok_passphrases += 1
print("acceptable passphrases: ", ok_passphrases)