diff options
author | romangraef <romangraef@loves.dicksinhisan.us> | 2018-12-02 10:54:22 +0100 |
---|---|---|
committer | romangraef <romangraef@loves.dicksinhisan.us> | 2018-12-02 10:54:22 +0100 |
commit | 96497901685d21c275a1cfd8f03c7484de29ca22 (patch) | |
tree | 916afc0ce48f18314789ff4f8fb9fc08c2cb33e7 /day2/solve.py | |
parent | 37a85f8df1fb3a0dac50152daabf243316f2d31d (diff) | |
download | aoc2018-96497901685d21c275a1cfd8f03c7484de29ca22.tar.gz aoc2018-96497901685d21c275a1cfd8f03c7484de29ca22.tar.bz2 aoc2018-96497901685d21c275a1cfd8f03c7484de29ca22.zip |
day 2
Diffstat (limited to 'day2/solve.py')
-rw-r--r-- | day2/solve.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/day2/solve.py b/day2/solve.py new file mode 100644 index 0000000..dc19aad --- /dev/null +++ b/day2/solve.py @@ -0,0 +1,25 @@ +from collections import Counter + +from commons import get_input, remove_empty + +txt = set(remove_empty(get_input(2).split('\n'))) +counts = [set(Counter(l).values()) for l in txt] +threes = sum(3 in count for count in counts) +twos = sum(2 in count for count in counts) + + +def find(): + for i in txt: + for j in txt: + if i == j: + continue + for k in range(len(j)): + i_, j_ = list(i), list(j) + i_[k] = j_[k] + if i_ == j_: + return i[:k] + i[k + 1:] + + +if __name__ == '__main__': + print("first: ", twos * threes) + print("second:", find()) |