day3 done
This commit is contained in:
parent
63a8929425
commit
07af61effb
23
day3/day.py
Normal file
23
day3/day.py
Normal 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
2
day3/parser-second.sh
Executable 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
2
day3/parser.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
grep -o 'mul([0-9]*[0-9],[0-9]*[0-9])' $1
|
Loading…
x
Reference in New Issue
Block a user