-
-
Save pawlos/00f277220389cf221c747ce883f1859e to your computer and use it in GitHub Desktop.
Solution to Day 4: High-Entropy Passphrases - Part 2
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
# aoc_42.py | |
lines = open('input_d4.txt','r').readlines()#["abcde fghij","abcde xyz ecdab","a ab abc abd abf abj","iiii oiii ooii oooi oooo","oiii ioii iioi iiio"]# | |
lines = [w.replace('\n','').split(' ') for w in lines] | |
print lines | |
count = 0 | |
match = True | |
for l in lines: | |
match = True | |
for j in range(len(l)): | |
for k in range(j+1, len(l)): | |
if l[j] == l[k]: | |
match = False | |
break | |
elif l[j] != l[k] and ''.join(sorted(l[j]))==''.join(sorted((l[k]))): | |
match = False | |
if match: | |
count += 1 | |
print count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment