Created
December 4, 2017 13:36
-
-
Save 4Kaylum/7730db90e2de6a87b1a7e35ffd8d2e21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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