Files
ioccc/1995/cdua/README.md
T
Cody Boone Ferguson 42b4d27ff2 Move usleep() version of 1995/cdua to cdua.alt.c
This is to both preserve the original code (notwithstanding the bug
fixes I made) and also to allow you to compare the two versions. I now
have played with even slower values and I recommended trying it to see
different results in the README.md (which of course describes the alt
code, how to use it and reconfigure it etc.).

It's encouraged to use this version but it's also recommended to try the
original version as well.

Updated Makefile to do this. This reinstates the -include stdio.h
-include unistd.h in CINCLUDE but the -DZ=3000 is still in the CDEFINE
variable.  Why? It doesn't hurt having it in the cdua.c compilation and
it makes it easier to find. The cdua.alt.c still uses #include
directives so that redefining CFLAGS at compilation does not cause any
problems.

Thank you Landon for recommending that it's moved to an alt version; I
had thought of it but did not do it and this is much, much better!
2023-04-12 02:27:55 -07:00

2.7 KiB

Best Output

Carlos Duarte
Instituto Superior Tecnico
Largo da Igreja, 5 R/C DTo
Damaia
2720 Amadora
Portugal

To build:

make all

Cody Boone Ferguson fixed this so that it would work with macOS. Once it could compile it additionally segfaulted under macOS which he also fixed. Thank you Cody for your assistance!

NOTE: on modern systems this was hard to see it solve it in real time because it goes so quickly so Cody added an alternate version which makes it easier with modern systems to see the maze actually being solved in real time. We encourage you to use this version but we keep the original here to both preserve the original code (the bug fixes notwithstanding) and it will also let you see just how fast your computer is :-) (and you can also use both to see the difference). For this alternate, slower version, please see below.

To run:

./cdua

NOTE: sometimes the program needs you to press enter a second time to continue solving the maze. See bugs.md for more details.

Alternate code:

This version uses usleep(3) with the Z (defined in the Makefile, default 3000) microseconds to make it easier to see the maze being solved in real time. You can redefine Z to reconfigure it in case it's going too slow, too fast :-) or you're doing some strange experiment like making it 100000 (which Cody did for fun :-) ). To compile and use without reconfiguring the 3000 microseconds, try:

make clobber alt
./cdua.alt # press enter

Use cdua.alt as you would cdua above.

To use a 1500 for Z try something like:

make CFLAGS="-DZ=1500" clobber alt
./cdua.alt # press enter and watch it move a bit slower

Also try:

make CFLAGS="-DZ=65000" clobber alt
./cdua.alt # press enter and watch it go much slower!

Do you see anything strange in this version when Z is a high value like 65000? What happens if you use 100000? Is this strange output still there? Why?

Judges' remarks:

This could be used as the basis of an a-maze-ing screen exerciser.

Author's remarks:

A program that generates a maze, and then solves it, all this being seen by the user. Some highlights of obfuscation are: 3 steps functions in one - main(), several recursive calls with conditional actions, and just one (big and ugly) statement to solve the maze.

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved. You are free to share and adapt this file under the terms of this license:

Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)

For more information, see: https://creativecommons.org/licenses/by-sa/4.0/