diff options
Diffstat (limited to '2024/3A.py')
| -rw-r--r-- | 2024/3A.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/2024/3A.py b/2024/3A.py new file mode 100644 index 0000000..2c7d249 --- /dev/null +++ b/2024/3A.py @@ -0,0 +1,21 @@ +import re + +with open('3.txt', 'r') as f: + data = f.read() + +mul = r'mul\(\d+,\d+\)' +matches = re.findall(mul, data) + +lmuls = [] +lmuls.extend(matches) + +ints = [l.split("mul(")[1].rstrip(')') for l in lmuls] +print(ints) + +muls = 0 + +for i in ints: + n1, n2 = map(int, i.split(',')) + print(n1, n2) + muls += n1 * n2 +print(muls) |
