Improve 2019/karns/try.sh, force -O0
The try.sh script now prompts for input rather than just sleep for 2 seconds. The README.md file has been format/typo checked. Added issues reported by the author to bugs.md. Force disable optimiser as the program doesn't work in some cases with it enabled. If I recall correctly it crashed in some cases, something the author noted happens sometimes (it is unknown if it is because they had it enabled or if it was something else but I have not experienced a crash since then).
This commit is contained in:
1 parent
f25d431417
commit
5e92359ccb
4 files changed
+73
-26
No files matched your search
+6
-2
@@ -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}
|
||||
|
||||
+35
-15
@@ -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:
|
||||
|
||||
|
||||
+6
-9
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user