Fix 2019/karns
A strange problem is that although it worked with macOS and linux for me numerous times in the past it stopped working under both. I went to try and figure it out but when disabling the optimiser for debug symbols the problem vanished. Changing it back to -O3 and the problem reappeared both with macOS and linux. Thus it appears that the entry should not have -O level > 0. I'm not sure if this is the same issue the author reported where it sometimes segfaults but I did not try and figure it out either (in any event the crash disappeared when -O0 was specified so it'd be harder to debug). Added to .gitignore the file the author noted the program is called (as the command he gives creates). To make it easier I just made it a symlink to prog. Fixed formatting in README.md.
This commit is contained in:
1 parent
946b73151b
commit
0791a31fc7
3 files changed
+35
-14
No files matched your search
@@ -1 +1,2 @@
|
||||
prog
|
||||
tbfs
|
||||
+10
-1
@@ -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
|
||||
#
|
||||
|
||||
+24
-13
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user