1
1
Fork 0

day 3 part 1

This commit is contained in:
nin0dev 2024-12-04 07:38:37 -05:00
parent a65d4fb1e8
commit b2508447dc
Signed by: nin0
SSH key fingerprint: SHA256:Is2DvJdw1OkSopR4wKJfdWV0fZhMLxpnCs1P1nPhIgA
3 changed files with 21 additions and 1 deletions

5
.gitignore vendored
View file

@ -5,4 +5,7 @@ bin/
obj/ obj/
.vscode/ .vscode/
*.sln *.sln
*.csproj *.csproj
*.so
workingFile.txt
database.db

5
2024/day3/run.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/bash
rm database.db
cp input.txt workingFile.txt
sqlite3 < solution.sql

12
2024/day3/solution.sql Normal file
View file

@ -0,0 +1,12 @@
.open database.db
.load ./sqlean
CREATE TABLE IF NOT EXISTS RESULTS (result number);
INSERT INTO results SELECT sum(regexp_capture(readfile('workingFile.txt'), 'mul\(([0-9]+),([0-9]+)\)', 1) * regexp_capture(readfile('workingFile.txt'), 'mul\(([0-9]+),([0-9]+)\)', 2));
SELECT fileio_write('workingFile.txt', text_replace(readfile('workingFile.txt'), regexp_substr(readfile('workingFile.txt'), 'mul\(([0-9]+),([0-9]+)\)'), ''));
SELECT 'answer (when 0 shows above):';
SELECT sum(result) FROM results;
.shell sqlite3 < solution.sql