Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import Counter
- #Läs fil och rengör den...
- myfile = open('input.txt', 'r')
- contents = myfile.read().strip().splitlines()
- myfile.close()
- #Del 1
- #c = 2d array
- c = [0, 0]
- def p1():
- for i in contents:
- a = [b for i,b in Counter(i).most_common()]
- if 3 in a:
- c[0] += 1
- if 2 in a:
- c[1] += 1
- return c[0] * c[1]
- def p2():
- for i in contents:
- for b in contents:
- diffs = 0
- for y, x in enumerate(i):
- if x != b[y]:
- diffs += 1
- if diffs == 1:
- ans = [x for y, x in enumerate(i) if b[y] == x]
- return ans
- print(p1())
- print(''.join(p2()))
Advertisement
Add Comment
Please, Sign In to add comment