completed 2017.04.1

This commit is contained in:
dusk 2025-07-25 23:46:53 +00:00
parent e01bd4c86d
commit 0349bf6d0e
2 changed files with 30 additions and 0 deletions

23
2017/04/1passphrases.py Executable file
View File

@ -0,0 +1,23 @@
#!/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()
is_valid = not check_for_duplicates(passwords)
if is_valid:
total_valid += 1
print(total_valid)

7
2017/04/notes Normal file
View File

@ -0,0 +1,7 @@
high-entropy passphrases!
passphrases have all-lowercase space-separated strings of words.
valid passphrases have NO DUPLICATE words.
how many of the provided passphrases ARE VALID, i.e., have NO DUPLICATE words?
provided passphrases are in file `input`