My Advent of Code solutions in Python. kevinyap.ca/2019/12/going-fast-in-advent-of-code/
advent-of-code python
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 17 lines 439 B view raw
1import fileinput 2 3fst_valids = 0 4snd_valids = 0 5 6for line in fileinput.input(): 7 passphrase = [x for x in line.split()] 8 anagrams = [''.join(sorted(p)) for p in passphrase] 9 10 if len(set(passphrase)) == len(passphrase): 11 fst_valids += 1 12 13 if len(set(anagrams)) == len(anagrams): 14 snd_valids += 1 15 16print "Valid passphrases under first policy:", fst_valids 17print "Valid passphrases under second policy:", snd_valids