completed 2017.04.2

This commit is contained in:
dusk 2025-07-26 14:42:02 +00:00
parent 0349bf6d0e
commit f6089b46b3

25
2017/04/2passphrases.py Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env python3
# passphrase validity checker. see file `notes` for details
# only strings with NO DUPLICATE words are valid
if __name__ == '__main__':
total_valid = 0
def check_for_duplicates(list):
has_duplicate = False
for i in range(1, len(list)):
for j in range(i):
if list[i] == list[j]:
has_duplicate = True
return has_duplicate
with open("input", "r", encoding="utf-8") as passphrase_input:
for passphrase in passphrase_input:
is_valid = False
passwords = passphrase.split()
for i in range(len(passwords)):
passwords[i] = "".join(sorted(passwords[i]))
is_valid = not check_for_duplicates(passwords)
if is_valid:
total_valid += 1
print(total_valid)