diff --git a/day3/day.py b/day3/day.py new file mode 100644 index 0000000..a34ff3e --- /dev/null +++ b/day3/day.py @@ -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) \ No newline at end of file diff --git a/day3/parser-second.sh b/day3/parser-second.sh new file mode 100755 index 0000000..ac71e69 --- /dev/null +++ b/day3/parser-second.sh @@ -0,0 +1,2 @@ +#!/bin/bash +grep -o "mul([0-9]*[0-9],[0-9]*[0-9])\|do()\|don't()" $1 | tr -d "'" \ No newline at end of file diff --git a/day3/parser.sh b/day3/parser.sh new file mode 100755 index 0000000..806f259 --- /dev/null +++ b/day3/parser.sh @@ -0,0 +1,2 @@ +#!/bin/bash +grep -o 'mul([0-9]*[0-9],[0-9]*[0-9])' $1 \ No newline at end of file