Add one liner

This commit is contained in:
Isaac Shoebottom 2024-12-03 15:01:48 -04:00
parent fa259faa2b
commit e97762a3f7

View File

@ -10,6 +10,9 @@ for match in matches:
total += int(match[0]) * int(match[1]) total += int(match[0]) * int(match[1])
print(total) print(total)
# One-liner
# print(sum(int(x) * int(y) for x, y in re.findall(r"mul\((\d+),(\d+)\)", data, re.MULTILINE)))
# Part two # Part two
matches = re.finditer(r"mul\((\d+),(\d+)\)", data, re.MULTILINE) matches = re.finditer(r"mul\((\d+),(\d+)\)", data, re.MULTILINE)
total = 0 total = 0