Skip to content

Instantly share code, notes, and snippets.

@4Kaylum
Created December 4, 2017 13:36
Show Gist options
  • Save 4Kaylum/7730db90e2de6a87b1a7e35ffd8d2e21 to your computer and use it in GitHub Desktop.
Save 4Kaylum/7730db90e2de6a87b1a7e35ffd8d2e21 to your computer and use it in GitHub Desktop.
def validate_passphrase(passphrases:str) -> int:
'''
Counts the number of valid passphrases
'''
passphrases = [[item for item in row.split(' ')] for row in passphrases.split('\n')]
valid = 0
for row in passphrases:
counter = 0
for item in row:
if row.count(item) > 1:
counter += 1
if not counter:
valid += 1
return valid
def validate_passphrase_part_2(passphrases:str) -> int:
'''
Counts the number of valid passphrases
'''
passphrases = [[sorted(item) for item in row.split(' ')] for row in passphrases.split('\n')]
valid = 0
for row in passphrases:
counter = 0
for item in row:
if row.count(item) > 1:
counter += 1
if not counter:
valid += 1
return valid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment