diff --git a/.gitignore b/.gitignore index 2943eb2..2a20608 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ day*.txt +venv/ diff --git a/2018/day2.py b/2018/day2.py new file mode 100644 index 0000000..c2108f8 --- /dev/null +++ b/2018/day2.py @@ -0,0 +1,30 @@ +def main(): + with open("day2.txt", "rt") as f: + lines = [line.rstrip() for line in f.readlines()] + + n2 = 0 + n3 = 0 + for line in lines: + occurences = [line.count(letter) for letter in line] + if 2 in occurences: + n2 += 1 + if 3 in occurences: + n3 += 1 + print(n2 * n3) + + for line in lines: + for other in lines: + diffs = 0 + common = "" + for c1, c2 in zip(line, other): + if c1 == c2: + common += c1 + else: + diffs += 1 + if diffs == 1: + print(common) + return + + +if __name__ == "__main__": + main() diff --git a/2018/skel.py.txt b/2018/skel.py.txt new file mode 100644 index 0000000..732477d --- /dev/null +++ b/2018/skel.py.txt @@ -0,0 +1,7 @@ +def main(): + with open("", "rt") as f: + lines = [line.rstrip() for line in f.readlines()] + + +if __name__ == "__main__": + main()