day3 done

This commit is contained in:
PoliEcho 2024-12-12 22:11:26 +01:00
parent 63a8929425
commit 07af61effb
3 changed files with 27 additions and 0 deletions

23
day3/day.py Normal file
View File

@ -0,0 +1,23 @@
res = 0
write = True
def mul(a, b):
global write
if write:
global res
res += (a * b)
def do():
global write
write = True
def dont():
global write
write = False
with open('parsed_sec', 'r') as file:
# Read each line in the file
for line in file:
# Print each line
exec(line)
print(res)

2
day3/parser-second.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
grep -o "mul([0-9]*[0-9],[0-9]*[0-9])\|do()\|don't()" $1 | tr -d "'"

2
day3/parser.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
grep -o 'mul([0-9]*[0-9],[0-9]*[0-9])' $1