···11+import fileinput
22+33+44+part_1 = 0
55+part_2 = 0
66+77+for line in fileinput.input():
88+ elf_1, elf_2 = line.strip().split(',')
99+ a, b = [int(x) for x in elf_1.split('-')]
1010+ c, d = [int(x) for x in elf_2.split('-')]
1111+1212+ # Part 1
1313+ if a <= c <= b and a <= d <= b:
1414+ part_1 += 1
1515+ elif c <= a <= d and c <= b <= d:
1616+ part_1 += 1
1717+1818+1919+ # Part 2
2020+ if a <= c <= b or a <= d <= b:
2121+ part_2 += 1
2222+ elif c <= a <= d or c <= b <= d:
2323+ part_2 += 1
2424+2525+print("Part 1:", part_1)
2626+print("Part 2:", part_2)
+1-1
2022/starter.py
···1515# combinations_with_replacement('ABCD', 2) AA AB AC AD BB BC BD CC CD DD
1616# combinations('ABCD', 2) AB AC AD BC BD CD
17171818-# day .lines .nlines .pars .npars .board .pboard .tboard
1818+# day .lines .nlines(negs=True) .pars .npars(negs=True) .board .pboard .tboard
19192020tot = 0
2121res = []
+7-2
2022/utils.py
···198198 needs to be consumed afterwards, and b is a Counter over the values
199199 in `grid`.
200200201201- f: a function to transform the values of grid to something printable.
202202- quiet: don't output to stdout.
201201+ Arguments:
202202+ f: a function to transform the values of grid to something printable.
203203+ quiet: don't output to stdout.
204204+205205+ Returns:
206206+ List[String]: Serialized, printable version of the grid.
207207+ Counter: The values contained in the grid.
203208 """
204209 if f is None:
205210 f = lambda x: str(x) # NOQA