diff --git a/2019/karns/.gitignore b/2019/karns/.gitignore index ea1749132..ce21b5d86 100644 --- a/2019/karns/.gitignore +++ b/2019/karns/.gitignore @@ -1 +1,2 @@ prog +tbfs diff --git a/2019/karns/Makefile b/2019/karns/Makefile index be200ef25..1542ad0aa 100644 --- a/2019/karns/Makefile +++ b/2019/karns/Makefile @@ -68,7 +68,7 @@ CINCLUDE= # Optimization # -OPT= -O3 +OPT= # Default flags for ANSI C compilation # @@ -120,6 +120,10 @@ TARGET= ${PROG} ALT_OBJ= ALT_TARGET= +############################ +# FORCE no -O level # +# ########################## +COPT+= -O0 ################# # build the entry @@ -134,6 +138,11 @@ all: data ${TARGET} ${PROG}: ${PROG}.c ${CC} ${CFLAGS} $< -o $@ ${LIBS} + ${LN} -sf ${PROG} tbfs + +test: prog + ${CAT} prog.c | ./prog + # alternative executable # diff --git a/2019/karns/README.md b/2019/karns/README.md index 8496c667c..01d2103a5 100644 --- a/2019/karns/README.md +++ b/2019/karns/README.md @@ -1,7 +1,7 @@ # Most in need of whitespace - Joshua Karns - Twitter: @jkarnss +Joshua Karns +Twitter: @jkarnss ## To build: @@ -15,6 +15,14 @@ make ./prog < textfile_that_fits_on_the_screen ``` +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) reported that with `-O` +level > 0 this program segfaults (sometimes?). He's not sure why as it worked +fine before on the same systems tested but `-O0` appears to fix the problem in +both macOS and linux. Perhaps this is the problem that the author reported where +it sometimes segfaults but Cody did not try debugging it. Thank you Cody for +your assistance! + + ## Try: ```sh @@ -34,21 +42,24 @@ the terminal, like: ## Judges' comments: -If you typically get lost in mazes, watching this program run might -- or might not, YMMV -- -teach you how to find your way in a maze. The algorithm is well-known but the drawing is amazing! +If you typically get lost in mazes, watching this program run might -- or might +not, YMMV -- teach you how to find your way in a maze. The algorithm is +well-known but the drawing is amazing! -Before running, make sure that your terminal can accommodate the whole file. Before running "make test", -make it about 120x40 to be safe, ensuring that you see the @ sign as well as the exclamation mark. +Before running, make sure that your terminal can accommodate the whole file. +Before running "make test", make it about 120x40 to be safe, ensuring that you +see the @ sign as well as the exclamation mark. ...Oh, and the first M in YMMV stands for "mazing". -A puzzle for the reader: Can you change the program to consider a diagonal movement as one step? +A puzzle for the reader: Can you change the program to consider a diagonal +movement as one step? ## Author's comments: -### The Program +### The Program: -This program is pretty simple! It performs a breadth first search on the +This program is pretty simple! It performs a breadth first search on the specified graph. The graph can be any ascii text file that has an 'at' character, which is going to be the starting location, and a '!' character which will be the destination. @@ -57,7 +68,7 @@ The nodes on this graph that are spaces are connected with any directly adjacent nodes that are also spaces. Nodes that aren't spaces are not connected with anything. -### Compiling and Running +### Compiling and Running: This program usually compiles under both GCC and clang. Build with: @@ -65,7 +76,7 @@ This program usually compiles under both GCC and clang. Build with: $(CC) -std=c99 -o tbfs prog.c ``` -where $(CC) is cc, gcc, clang, or somet other c compiler. +where $(CC) is cc, gcc, clang, or some other c compiler. You can then run it with: @@ -85,8 +96,8 @@ Examples: - The program must be ran in a terminal that supports ANSI escape codes for moving the cursor and changing colors. - Segfaults happen sometimes. -- I don't know what memergy management there is, if any. -- Ths program will not compile by an ANSI C compiler: it uses for loops, and +- I don't know what memory management there is, if any. +- The program will not compile by an ANSI C compiler: it uses for loops, and it uses C++ style comments. It should compile cleanly using a C99 standard. - Breadth first search is slow (and very slow on certain maps), but my A star version of this program is too big.