From b8574fd4d627035cab9b5c26d9d9561d4a60f081 Mon Sep 17 00:00:00 2001 From: icaema Date: Sat, 2 Dec 2023 15:37:27 -0500 Subject: [PATCH] Updated boilerplate code --- day-02/Makefile | 5 ++++- template-c-stdin-lines/Makefile | 25 +++++++++++++++++----- template-c-stdin-lines/src/part01.c | 19 ++++++++++++----- template-c-stdin-lines/src/part01.py | 31 ++++++++++++++++++++++++++++ template-c-stdin-lines/src/part02.c | 19 ++++++++++++----- template-c-stdin-lines/src/part02.py | 31 ++++++++++++++++++++++++++++ 6 files changed, 114 insertions(+), 16 deletions(-) create mode 100644 template-c-stdin-lines/src/part01.py create mode 100644 template-c-stdin-lines/src/part02.py diff --git a/day-02/Makefile b/day-02/Makefile index 2cd67dd..4ffd562 100644 --- a/day-02/Makefile +++ b/day-02/Makefile @@ -1,6 +1,9 @@ CC=gcc CFLAGS=-Wall +all: clean bin/part01 bin/part02 + @echo "built all" + run1: clean bin/part01 cat data/p01data.txt | bin/part01 @@ -19,7 +22,7 @@ bin/part01: bin/part02: $(CC) src/part02.c -o bin/part02 -.PHONY: clean,pytest1 +.PHONY: clean,pytest1,pytest2,pyrun1,pyrun2 clean: rm -f bin/* diff --git a/template-c-stdin-lines/Makefile b/template-c-stdin-lines/Makefile index 6ca3b33..4ffd562 100644 --- a/template-c-stdin-lines/Makefile +++ b/template-c-stdin-lines/Makefile @@ -1,16 +1,19 @@ CC=gcc CFLAGS=-Wall -run1: bin/part01 +all: clean bin/part01 bin/part02 + @echo "built all" + +run1: clean bin/part01 cat data/p01data.txt | bin/part01 -run2: bin/part02 +run2: clean bin/part02 cat data/p02data.txt | bin/part02 -test1: bin/part01 +test1: clean bin/part01 cat data/p01test.txt | bin/part01 -test2: bin/part02 +test2: clean bin/part02 cat data/p02test.txt | bin/part02 bin/part01: @@ -19,7 +22,19 @@ bin/part01: bin/part02: $(CC) src/part02.c -o bin/part02 -.PHONY: clean +.PHONY: clean,pytest1,pytest2,pyrun1,pyrun2 clean: rm -f bin/* + +pytest1: + cat data/p01test.txt | python3 src/part01.py + +pyrun1: + cat data/p01data.txt | python3 src/part01.py + +pytest2: + cat data/p02test.txt | python3 src/part02.py + +pyrun2: + cat data/p02data.txt | python3 src/part02.py \ No newline at end of file diff --git a/template-c-stdin-lines/src/part01.c b/template-c-stdin-lines/src/part01.c index 588b32c..db8ef6a 100644 --- a/template-c-stdin-lines/src/part01.c +++ b/template-c-stdin-lines/src/part01.c @@ -1,14 +1,18 @@ +#include +#include #include #include #include +#define DEBUG + #ifdef DEBUG #define debug_printf(...) do{ fprintf( stderr, __VA_ARGS__ ); } while( 0 ) #else #define debug_printf(...) do{ } while ( 0 ) #endif -#define LINE_MAX 90 +#define LINE_MAX 160 int main(int argc, char *argv[]){ int linesProcessed = 0; @@ -17,9 +21,14 @@ int main(int argc, char *argv[]){ while (fgets(line, LINE_MAX, stdin) != NULL) { linesProcessed++; } - - printf("\n Processed %d Lines\n", linesProcessed); + printf("\n Ingested %d Lines\n", linesProcessed); printf("===================================\n"); - printf("Answer: \nXXXX\n"); -} + //insert processing code + + printf("\n Processed XXX\n"); + printf("===================================\n"); + + + printf("Answer: \nXXXX\n"); +} \ No newline at end of file diff --git a/template-c-stdin-lines/src/part01.py b/template-c-stdin-lines/src/part01.py new file mode 100644 index 0000000..2301421 --- /dev/null +++ b/template-c-stdin-lines/src/part01.py @@ -0,0 +1,31 @@ +import sys +from dataclasses import dataclass + +DEBUG = True +padding=24 + +def debug_print(printname, *args): + if not DEBUG: + return + print(f"{'DEBUG::'+printname:<{padding}}", *args) + pass + + +FILENAME = "/home/icaema/Public/advent-of-code/day-XX/data/p01test.txt" +f = open(FILENAME, "r") + +#for line in sys.stdin: +for line in f.readlines(): + line = line.strip() + debug_print("input", line) + + +# Insert Processing Code + + + +print("") +print("Processed:") +print("") +print("===================================\n"); +print("Answer: XXX"); \ No newline at end of file diff --git a/template-c-stdin-lines/src/part02.c b/template-c-stdin-lines/src/part02.c index 588b32c..db8ef6a 100644 --- a/template-c-stdin-lines/src/part02.c +++ b/template-c-stdin-lines/src/part02.c @@ -1,14 +1,18 @@ +#include +#include #include #include #include +#define DEBUG + #ifdef DEBUG #define debug_printf(...) do{ fprintf( stderr, __VA_ARGS__ ); } while( 0 ) #else #define debug_printf(...) do{ } while ( 0 ) #endif -#define LINE_MAX 90 +#define LINE_MAX 160 int main(int argc, char *argv[]){ int linesProcessed = 0; @@ -17,9 +21,14 @@ int main(int argc, char *argv[]){ while (fgets(line, LINE_MAX, stdin) != NULL) { linesProcessed++; } - - printf("\n Processed %d Lines\n", linesProcessed); + printf("\n Ingested %d Lines\n", linesProcessed); printf("===================================\n"); - printf("Answer: \nXXXX\n"); -} + //insert processing code + + printf("\n Processed XXX\n"); + printf("===================================\n"); + + + printf("Answer: \nXXXX\n"); +} \ No newline at end of file diff --git a/template-c-stdin-lines/src/part02.py b/template-c-stdin-lines/src/part02.py new file mode 100644 index 0000000..2301421 --- /dev/null +++ b/template-c-stdin-lines/src/part02.py @@ -0,0 +1,31 @@ +import sys +from dataclasses import dataclass + +DEBUG = True +padding=24 + +def debug_print(printname, *args): + if not DEBUG: + return + print(f"{'DEBUG::'+printname:<{padding}}", *args) + pass + + +FILENAME = "/home/icaema/Public/advent-of-code/day-XX/data/p01test.txt" +f = open(FILENAME, "r") + +#for line in sys.stdin: +for line in f.readlines(): + line = line.strip() + debug_print("input", line) + + +# Insert Processing Code + + + +print("") +print("Processed:") +print("") +print("===================================\n"); +print("Answer: XXX"); \ No newline at end of file