diff --git a/2019/karns/Makefile b/2019/karns/Makefile index a2dee8f07..387adba46 100644 --- a/2019/karns/Makefile +++ b/2019/karns/Makefile @@ -68,7 +68,8 @@ CINCLUDE= # Optimization # -OPT= +# We disable the optimiser because the entry has problems with it enabled. +OPT= -O0 # Default flags for ANSI C compilation # @@ -137,8 +138,11 @@ all: data ${TARGET} clean clobber install love haste waste maker easter_egg \ sandwich supernova deep_magic magic charon pluto + +# We FORCE the use of -O0 even if someone overrides it because this entry has +# problems with it enabled. ${PROG}: ${PROG}.c - ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} + ${CC} ${CFLAGS} -O0 $< -o $@ ${LDFLAGS} ${LN} -sf ${PROG} tbfs test: ${PROG} diff --git a/2019/karns/README.md b/2019/karns/README.md index 257946013..32db17a0c 100644 --- a/2019/karns/README.md +++ b/2019/karns/README.md @@ -4,6 +4,21 @@ make ``` +NOTE: we disable the optimiser because this program has problems with it +enabled. + + +### Bugs and (Mis)features: + +The current status of this entry is: + +``` +STATUS: INABIAF - please **DO NOT** fix +``` + +For more detailed information see [2019 karns in bugs.md](/bugs.md#2019-karns). + + ## To use: @@ -11,22 +26,25 @@ make ./prog < textfile_that_fits_on_the_screen ``` +You might want to type: + +```sh +reset +``` + +after running the program to restore the terminal to its previous state. + ### Try: ```sh -./prog < README.md - -./prog < prog.c - -./prog < maze +./try.sh ``` -The last two can be done in a sequence, first showing the respective files at -the terminal, like: +If you have more time you might want to try: ```sh -./try.sh +./prog < README.md ``` @@ -37,10 +55,10 @@ 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 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". +...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? @@ -50,15 +68,17 @@ movement as one step? ### The Program: -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 +This program is pretty simple! It performs a [breadth first +search](https://en.wikipedia.org/wiki/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. 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: This program usually compiles under both GCC and clang. Build with: @@ -67,7 +87,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 some other c compiler. +where `$(CC)` is cc, gcc, clang, or some other C compiler. You can then run it with: diff --git a/2019/karns/try.sh b/2019/karns/try.sh index e8e02483d..715cf4928 100755 --- a/2019/karns/try.sh +++ b/2019/karns/try.sh @@ -20,13 +20,11 @@ clear # display prog.c to the user echo "$ cat prog.c" cat prog.c -sleep 2 -# run the program on itself -echo "$ ./prog < prog.c" -sleep 2 +# run the program on its own source code +read -r -n 1 -p "Press any key to run: ./prog < prog.c: " +echo 1>&2 ./prog < prog.c -sleep 2 # reset terminal for colours reset @@ -34,13 +32,12 @@ reset # display maze echo "$ cat maze" cat maze -sleep 2 # run the program on maze -echo "$ ./prog < maze" -sleep 2 +read -r -n 1 -p "Press any key to run: ./prog < maze: " +echo 1>&2 ./prog < maze -sleep 2 +read -r -n 1 -p "Press any key to exit: " # reset terminal reset diff --git a/bugs.md b/bugs.md index d61bffcaa..9a291d015 100644 --- a/bugs.md +++ b/bugs.md @@ -3466,6 +3466,32 @@ As a backtrace quine this entry is **SUPPOSED to segfault** so this should not b touched either. +## 2019 karns + +### STATUS: INABIAF - please **DO NOT** fix +### Source code: [2019/karns/prog.c](2019/karns/prog.c) +### Information: [2019/karns/README.md](2019/karns/README.md) + +The author stated the following: + +--- + +- 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 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. +- Lots of extra whitespace may be needed if you want to feed in an arbitrary +file. +- It fails to compile on GCC sometimes (according to a friend of mine, I've +not encountered this myself). +- The program could be obfuscated much further. +- The program contains some unused code and data. + + ## 2019 poikola ### STATUS: INABIAF - please **DO NOT** fix