Merge pull request #1515 from xexyl/monge06-bugs
Update 2006/monge bugs status
This commit is contained in:
18 files changed
+484
-70
No files matched your search
@@ -18,9 +18,9 @@ see below and the [original code](#original-code) section.
|
||||
### Try:
|
||||
|
||||
This alternate version, which we recommend you you try first, prior to the
|
||||
original, so that you can see what it does in modern systems, slows down the
|
||||
output which will provide more fun output. It is slowed down by the `usleep(3)`
|
||||
library call with a configurable time to sleep. The default is 500 but you can
|
||||
original, so that you can see what it did back in 1985, slows down the output
|
||||
which will provide more fun output. It is slowed down by the `usleep(3)` library
|
||||
call with a configurable time to sleep. The default is 500 but you can
|
||||
reconfigure it like:
|
||||
|
||||
|
||||
|
||||
+3
-2
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "Running shark.sh:"
|
||||
sh shark.sh shark.sh README.md jaw.c try.sh > receive || exit 1
|
||||
./shark.sh shark.sh README.md jaw.c try.sh > receive || exit 1
|
||||
echo "Done."
|
||||
|
||||
|
||||
@@ -13,9 +13,10 @@ mkdir -p test || exit 0
|
||||
|
||||
# make sure we can cd to the new directory
|
||||
cd test || exit
|
||||
chmod +x ../receive
|
||||
# run the script
|
||||
echo "Attempting to extract files:"
|
||||
sh ../receive
|
||||
../receive
|
||||
|
||||
echo 1>&2
|
||||
echo "$ ls -al" 1>&2
|
||||
|
||||
@@ -45,6 +45,7 @@ say to 5, try:
|
||||
make clobber CDEFINE="-DW=5" alt
|
||||
```
|
||||
|
||||
|
||||
### Alternate use:
|
||||
|
||||
```sh
|
||||
|
||||
@@ -3,3 +3,4 @@ test.svg
|
||||
test.png
|
||||
boutines.orig
|
||||
prog.orig
|
||||
result.svg
|
||||
+32
-12
@@ -20,11 +20,18 @@ ruby -e '20.times{puts "#{rand} #{rand}"}' | ./boutines > test.svg
|
||||
|
||||
### Try:
|
||||
|
||||
After running the above, use [ImageMagick](https://imagemagick.org/index.php)'s
|
||||
`convert` tool to convert the image to a png file:
|
||||
|
||||
```sh
|
||||
./boutines < input.txt > result.svg
|
||||
```
|
||||
|
||||
After running the above commands, use [ImageMagick](https://imagemagick.org/index.php)'s
|
||||
`convert` tool to convert the images to a png file:
|
||||
|
||||
```sh
|
||||
convert test.svg test.png
|
||||
|
||||
convert result.svg result.png
|
||||
```
|
||||
|
||||
and then open it with your preferred graphics viewer or editor.
|
||||
@@ -47,13 +54,17 @@ their name suggests"?
|
||||
|
||||
_In memory of my father Pierre Boutines-Vignard._
|
||||
|
||||
|
||||
### Walk-through
|
||||
|
||||
My program works as follows:
|
||||
|
||||
|
||||
#### Input
|
||||
|
||||
A list of 2D points in the unit square.
|
||||
A list of 2D points in the [unit
|
||||
square](https://en.wikipedia.org/wiki/Unit_square).
|
||||
|
||||
|
||||
#### Output
|
||||
|
||||
@@ -63,7 +74,7 @@ an [SVG](https://www.w3.org/TR/SVG11/expanded-toc.html) stream.
|
||||
This will possibly save a compressed SVG file and may be useful:
|
||||
|
||||
```sh
|
||||
./boutines | gzip > result.svgz
|
||||
./boutines | gzip > result.svg.gz
|
||||
```
|
||||
|
||||
Input consists of a list of floating points values separated by whitespaces
|
||||
@@ -72,11 +83,11 @@ whitespace then the other coordinate (pointing downwards in the resulting
|
||||
graph) and a newline will just go fine:
|
||||
|
||||
```
|
||||
0 0
|
||||
0 1
|
||||
1 0
|
||||
1 1
|
||||
.5 .5
|
||||
0 0
|
||||
0 1
|
||||
1 0
|
||||
1 1
|
||||
.5 .5
|
||||
```
|
||||
|
||||
Strictly speaking, you have to provide a **set** of points. If there are
|
||||
@@ -84,6 +95,7 @@ duplicates in the list, there is no guarantee on the one to be shown (in
|
||||
addition their labels will overlap) in the resulting colored [Voronoi
|
||||
diagram](https://en.wikipedia.org/wiki/Voronoi_diagram).
|
||||
|
||||
|
||||
### Caution
|
||||
|
||||
This program might have been a lot shorter, but nearly impractical even for
|
||||
@@ -113,8 +125,10 @@ for most devices (including many inkjet printers). If you ever miss precision
|
||||
on a particular dataset or peripheral, you may want to dive in and let `U` be
|
||||
the next power of `__LINE__`.
|
||||
|
||||
NOTE: bad inputs will be sanctioned by the production of the 42nd Mersenne
|
||||
prime (ie. 2^25964951 -1); memory will be kept.
|
||||
NOTE: bad inputs will be sanctioned by the production of the 42nd [Mersenne
|
||||
prime](https://en.wikipedia.org/wiki/Mersenne_prime) (i.e. 2^25964951 -1);
|
||||
memory will be kept.
|
||||
|
||||
|
||||
### Why I think this code is Obfuscated ?
|
||||
|
||||
@@ -129,34 +143,40 @@ complicated output statements.
|
||||
|
||||
Be sure to check the antepenultimate line of code.
|
||||
|
||||
|
||||
### Missing Features
|
||||
|
||||
|
||||
#### Color control
|
||||
|
||||
Cell colors are chosen randomly (with a questionable rejection scheme). It
|
||||
might have been useful to input them along with sites coordinates, turning the
|
||||
application into a puzzling graphics engine.
|
||||
|
||||
|
||||
#### Site labelling
|
||||
|
||||
The points are implicitly numbered in the order they were entered
|
||||
(starting at one). This can be overridden however, via a simple XSL
|
||||
transformation.
|
||||
|
||||
|
||||
#### Site radius
|
||||
|
||||
The site radius is hardwired in the code, I still wonder why I did not
|
||||
The site radius is hardcoded in the code, I still wonder why I did not
|
||||
design it as a function of the underlying cell's area (which can be averaged
|
||||
for free) or at least a command line parameter. Same with the char set, the
|
||||
viewport and potentially every
|
||||
[SVG](https://www.w3.org/TR/SVG11/expanded-toc.html) property.
|
||||
|
||||
|
||||
### See Also
|
||||
|
||||
- [Voronoi at Wikipedia](http://en.wikipedia.org/wiki/Voronoi_diagram),
|
||||
- [An Excerpt from The Algorithm Design Manual](http://www2.toki.or.id/book/AlgDesignManual/BOOK/BOOK4/NODE187.HTM),
|
||||
- [Voronoi and Art](http://www.snibbe.com/scott/bf)
|
||||
|
||||
|
||||
### Example Output
|
||||
|
||||
> 
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
0 0
|
||||
0 1
|
||||
1 0
|
||||
1 1
|
||||
.5 .5
|
||||
@@ -15,7 +15,7 @@ make
|
||||
### Try:
|
||||
|
||||
```sh
|
||||
./klausler peter klausler | head
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ Rules might have to be changed!
|
||||
## Author's remarks:
|
||||
|
||||
A useful tool to help one appear extra smart and witty when
|
||||
[IRC](https://en.wikipedia.org/wiki/Internet_Relay_Chat)ing, or even
|
||||
[IRCing](https://en.wikipedia.org/wiki/Internet_Relay_Chat), or even to
|
||||
just be highly annoying.
|
||||
|
||||
Finds best anagrams for word or phrase given as program arguments. Use only
|
||||
|
||||
Executable
+49
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 2005/klausler
|
||||
#
|
||||
|
||||
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
|
||||
# this way allows us to have the user specify a different compiler in an easy
|
||||
# way.
|
||||
if [[ -z "$CC" ]]; then
|
||||
CC="cc"
|
||||
fi
|
||||
|
||||
make CC="$CC" all >/dev/null || exit 1
|
||||
|
||||
# clear screen after compilation so that only the entry is shown
|
||||
clear
|
||||
|
||||
echo "$ ./klausler peter klausler | head -n 10" 1>&2
|
||||
./klausler peter klausler | head -n 10
|
||||
|
||||
echo "$ ./klausler abc def ghi jkl mno | head -n 10" 1>&2
|
||||
./klausler abc def ghi jkl mno | head -n 10
|
||||
|
||||
echo "$ ./klausler foo bar baz | head -n 10" 1>&2
|
||||
./klausler foo bar baz | head -n 10
|
||||
|
||||
echo "$ ./klausler zebra elephant bear fox | head -n 10" 1>&2
|
||||
./klausler zebra elephant bear fox | head -n 10
|
||||
|
||||
echo "$ ./klausler the lion king | head -n 10" 1>&2
|
||||
./klausler the lion king | head -n 10
|
||||
|
||||
echo "$ ./klausler fire breathing dragon | head -n 10" 1>&2
|
||||
./klausler fire breathing dragon | head -n 10
|
||||
|
||||
echo "$ ./klausler lord of the rings | head -n 10" 1>&2
|
||||
./klausler lord of the rings | head -n 10
|
||||
|
||||
echo "$ ./klausler fawlty towers | head -n 10" 1>&2
|
||||
./klausler fawlty towers | head -n 10
|
||||
|
||||
echo "$ ./klausler carriown fowl | head -n 10" 1>&2
|
||||
./klausler carriown fowl | head -n 10
|
||||
|
||||
echo "$ ./klausler werewolf vampire dragon | head -n 10" 1>&2
|
||||
./klausler werewolf vampire dragon | head -n 10
|
||||
|
||||
echo "$ ./klausler werewolf vampire | head -n 10" 1>&2
|
||||
./klausler werewolf vampire | head -n 10
|
||||
+26
-11
@@ -5,22 +5,33 @@ make
|
||||
```
|
||||
|
||||
|
||||
### Bugs and (Mis)features:
|
||||
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2005 mikeash in bugs.md](/bugs.md#2005-mikeash).
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./mikeash
|
||||
```
|
||||
|
||||
NOTE: the author stated that they tested this under i386 machines but this works
|
||||
under 64-bit (x86_64, arm64) machines too.
|
||||
|
||||
|
||||
### Try:
|
||||
|
||||
```sh
|
||||
./mikeash < mikeash.c
|
||||
./mikeash < mikeash.c | diff - mikeash.c
|
||||
./try.sh
|
||||
```
|
||||
|
||||
NOTE: the author stated that they tested this under i386 machines but this works
|
||||
under 64-bit (x86_64, arm64) machines too.
|
||||
|
||||
|
||||
## Judges' remarks:
|
||||
@@ -46,7 +57,7 @@ interpreter for an extremely limited and highly broken subset of [Common
|
||||
Lisp](https://en.wikipedia.org/wiki/Common_Lisp).
|
||||
|
||||
It requires C99 because of `C99`'s ability to declare variables in the
|
||||
initializer of a for loop. Unfortunately, C99 mode typically warns about
|
||||
initializer of a `for` loop. Unfortunately, C99 mode typically warns about
|
||||
implicitly declared functions, and preprocessor directives prevent the program
|
||||
from being valid [Common Lisp](https://en.wikipedia.org/wiki/Common_Lisp). As a
|
||||
result, several warnings will be printed about implicit declarations of
|
||||
@@ -70,9 +81,10 @@ used:
|
||||
echo '(format t "~s" (* (+ 2 2 ) (- 5 (/ 9 3 ))))' | ./mikeash
|
||||
```
|
||||
|
||||
This evaluates the expression `(2+2) * (5 - 9/3)` giving the correct
|
||||
result, 8. Note that due to the highly ad-hoc nature of the tokenizer,
|
||||
the spaces before the closing parentheses are mandatory.
|
||||
This evaluates the expression `(2+2) * (5 - 9/3)` giving the correct result,
|
||||
`8"` (with the same issue of no newline after the `"`). Note that due to the
|
||||
highly ad-hoc nature of the tokenizer, the spaces before the closing parentheses
|
||||
are mandatory.
|
||||
|
||||
The program can also be run in an interactive mode, by simply executing
|
||||
`./mikeash` and then typing lisp expressions, but this is difficult due to the
|
||||
@@ -104,8 +116,8 @@ constants such as `#\x`.
|
||||
* The `char-upcase` function will give strange results if passed something
|
||||
other than a lowercase character.
|
||||
|
||||
* The format function takes exactly three parameters. The first parameter is
|
||||
ignored; output always goes to stdout. The second parameter must have exactly
|
||||
* The `format` function takes exactly three parameters. The first parameter is
|
||||
ignored; output always goes to `stdout`. The second parameter must have exactly
|
||||
one `~s` format specifier in it, and no other format specifiers are permitted.
|
||||
|
||||
* The arithmetic functions take exactly two parameters.
|
||||
@@ -126,7 +138,7 @@ diff mikeash.c mikeash2.c
|
||||
|
||||
The program can also be run from an implementation of [common
|
||||
lisp](https://en.wikipedia.org/wiki/Common_Lisp). To do
|
||||
this, run the [common lisp compiler and then type the following command:
|
||||
this, run the common lisp compiler and then type the following command:
|
||||
|
||||
```
|
||||
(load "mikeash.c")
|
||||
@@ -134,6 +146,9 @@ this, run the [common lisp compiler and then type the following command:
|
||||
|
||||
The source code of [mikeash.c](mikeash.c) will be printed.
|
||||
|
||||
|
||||
### Obfuscation
|
||||
|
||||
`Lispob` is obfuscated in several ways. First, it's actually two programs
|
||||
in one, which actually share a small amount of code. Running a C code
|
||||
beautifier will destroy the [LISP][] program contained within. Second and
|
||||
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 2005/mikeash
|
||||
#
|
||||
|
||||
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
|
||||
# this way allows us to have the user specify a different compiler in an easy
|
||||
# way.
|
||||
if [[ -z "$CC" ]]; then
|
||||
CC="cc"
|
||||
fi
|
||||
|
||||
make CC="$CC" all >/dev/null || exit 1
|
||||
|
||||
# clear screen after compilation so that only the entry is shown
|
||||
clear
|
||||
|
||||
|
||||
echo "$ ./mikeash < mikeash.c" 1>&2
|
||||
./mikeash < mikeash.c
|
||||
|
||||
echo 1>&2
|
||||
echo "The next command should print nothing." 1>&2
|
||||
read -r -n 1 -p "Press any key to continue: "
|
||||
echo "$ ./mikeash < mikeash.c | diff - mikeash.c" 1>&2
|
||||
./mikeash < mikeash.c | diff - mikeash.c
|
||||
|
||||
echo 1>&2
|
||||
echo "For the next two commands we will add a newline after the command's output" 1>&2
|
||||
echo "for your convenience as they will not print a newline themselves." 1>&2
|
||||
echo 1>&2
|
||||
echo "The next command should show: \"4." 1>&2
|
||||
read -r -n 1 -p "Press any key to continue: "
|
||||
echo "$ echo '(format t "~s" (+ 2 2 ))' | ./mikeash" 1>&2
|
||||
echo '(format t "~s" (+ 2 2 ))' | ./mikeash
|
||||
echo 1>&2
|
||||
|
||||
echo "The next command will evaluate the expression: (2+2) * (5 - 9/3), giving 8\"." 1>&2
|
||||
read -r -n 1 -p "Press any key to continue: "
|
||||
echo "$ echo '(format t "~s" (* (+ 2 2 ) (- 5 (/ 9 3 ))))' | ./mikeash" 1>&2
|
||||
echo '(format t "~s" (* (+ 2 2 ) (- 5 (/ 9 3 ))))' | ./mikeash
|
||||
echo 1>&2
|
||||
+33
-23
@@ -4,6 +4,9 @@
|
||||
make
|
||||
```
|
||||
|
||||
There is an alternate version that scans for (_ONLY_ scans) the string `https`
|
||||
as a starting point. See [alternate code](#alternate-code) below.
|
||||
|
||||
|
||||
### Bugs and (Mis)features:
|
||||
|
||||
@@ -30,32 +33,39 @@ the issue of https.
|
||||
|
||||
```sh
|
||||
./mynx http://www.textfiles.com
|
||||
|
||||
./mynx manual.html
|
||||
```
|
||||
|
||||
|
||||
Some have pointed out that this will not work for https initially
|
||||
for two reasons. For a starting point see the alternate code section below.
|
||||
|
||||
|
||||
## Alternate code:
|
||||
|
||||
As noted this will not work for https. This is because it does not scan for
|
||||
https but also a secure connection needs to be set up before http commands can
|
||||
be sent. One would also have to specify a port in the URL. Fortunately or
|
||||
unfortunately many more websites use https nowadays so this entry will not work
|
||||
as well as it used to. If one were to try and connect to `https://www.ioccc.org`
|
||||
with this entry they'll just get a 301 error.
|
||||
Obviously this will not work with `https` as it only scans for `http` in the URL
|
||||
(if not specified it tries to open it as a local file). But even if it scanned
|
||||
for `https` one would need to do more work as it would have to set up a secure
|
||||
connection before http commands could be sent. Fortunately or unfortunately
|
||||
many more websites use https so this entry will not work as well as it used to.
|
||||
If one were to try and connect to <https://ioccc.org> with this entry they'll
|
||||
just get a 301 error.
|
||||
|
||||
In case someone can come up with a clever pipeline or some other hack or
|
||||
workaround (perhaps [stunnel](https://www.stunnel.org)),
|
||||
The alternate code is a starting point that scans for `https` too (note you have
|
||||
to specify the port in this case) but that is all it does. It will not work with
|
||||
https websites as it does not set up a secure connection. But should anyone wish
|
||||
to either come up with a pipeline (or some other command line) that allows it to
|
||||
work with https or to update the code to support https they may. Otherwise you
|
||||
must just appreciate the entry for what it once was.
|
||||
|
||||
To compile:
|
||||
|
||||
### Alternate build:
|
||||
|
||||
|
||||
```sh
|
||||
make alt
|
||||
```
|
||||
|
||||
|
||||
### Alternate use:
|
||||
|
||||
Use `mynx.alt` as you would `mynx`. You'd have to specify a port at the end of
|
||||
the URL like:
|
||||
|
||||
@@ -84,13 +94,13 @@ it inspired me to try my hand at writing the client side complement.
|
||||
A typical build command would be:
|
||||
|
||||
```sh
|
||||
cc -omynx mynx.c
|
||||
cc -o mynx mynx.c
|
||||
```
|
||||
|
||||
While some others like to be a little different:
|
||||
|
||||
```sh
|
||||
cc -omynx mynx.c -lnsl -lsocket
|
||||
cc -o mynx mynx.c -lnsl -lsocket
|
||||
```
|
||||
|
||||
I even managed to figure out a basic configure script, given last year's
|
||||
@@ -111,14 +121,14 @@ After which, the rest of the documentation can be read by saying:
|
||||
Manifest:
|
||||
|
||||
```
|
||||
mynx.c
|
||||
makefile pre-built generic Unix
|
||||
README.TXT
|
||||
manual.html
|
||||
makefile.in makefile template
|
||||
entities.txt ISO 8859-1 entites
|
||||
configure.in configure script description
|
||||
configure pre-built configure script
|
||||
mynx.c
|
||||
makefile pre-built generic Unix
|
||||
README.md
|
||||
manual.html
|
||||
makefile.in makefile template
|
||||
entities.txt ISO 8859-1 entites
|
||||
configure.in configure script description
|
||||
configure pre-built configure script
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -114,8 +114,8 @@ OBJ= ${PROG}.o
|
||||
DATA=
|
||||
TARGET= ${PROG}
|
||||
#
|
||||
ALT_OBJ=
|
||||
ALT_TARGET=
|
||||
ALT_OBJ= ${PROG}.alt.o
|
||||
ALT_TARGET= ${PROG}.alt
|
||||
|
||||
|
||||
#################
|
||||
@@ -138,6 +138,9 @@ ${PROG}: ${PROG}.c
|
||||
alt: data ${ALT_TARGET}
|
||||
@${TRUE}
|
||||
|
||||
${PROG}.alt: ${PROG}.alt.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
||||
|
||||
# data files
|
||||
#
|
||||
data: ${DATA}
|
||||
|
||||
+37
-1
@@ -4,6 +4,9 @@
|
||||
make
|
||||
```
|
||||
|
||||
There is an alternate version of this entry which should work for Windows by
|
||||
setting binary mode on `stdout`. See [alternate code](#alternate-code) below.
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
@@ -25,6 +28,34 @@ manipulate animated GIFs - to slow down the animation and to compress the GIFs
|
||||
generated by the entry).
|
||||
|
||||
|
||||
## Alternate code:
|
||||
|
||||
This (untested as we have no Windows system) version uses the Windows API
|
||||
functions `_setmode()` and `_fileno(3)` to set binary mode on `stdout` which should
|
||||
let it work with Windows.
|
||||
|
||||
|
||||
### Alternate build:
|
||||
|
||||
```
|
||||
make alt
|
||||
```
|
||||
|
||||
### Alternate use:
|
||||
|
||||
Use `persano.alt` as you would `persano` above.
|
||||
|
||||
|
||||
### Alternate try:
|
||||
|
||||
```sh
|
||||
./persano.alt 3 16 > knot3-16.gif
|
||||
```
|
||||
|
||||
Follow the same instructions, using different tools if necessary, as the above
|
||||
try section.
|
||||
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
If your system is one of those that distinguish between text and binary
|
||||
@@ -52,9 +83,10 @@ knots](https://en.wikipedia.org/wiki/Torus_knot) to standard output.
|
||||
./persano p q [num frames]
|
||||
```
|
||||
|
||||
|
||||
### DESCRIPTION
|
||||
|
||||
A (p,q)-[torus knot](https://en.wikipedia.org/wiki/Torus_knot) is a closed,
|
||||
A `(p,q)`-[torus knot](https://en.wikipedia.org/wiki/Torus_knot) is a closed,
|
||||
non-intersecting curve on the surface of a
|
||||
[torus](https://en.wikipedia.org/wiki/Torus) in R3 that winds `p` times around
|
||||
one cycle of the torus and `q` times around the other. `p` and `q` should be
|
||||
@@ -83,6 +115,7 @@ output; since the number of frames is not specified, an animation with
|
||||
|
||||
Please view the code with 8-character tabs!
|
||||
|
||||
|
||||
### OUTPUT FORMAT
|
||||
|
||||
The program writes fully valid GIF 89 streams.
|
||||
@@ -98,6 +131,7 @@ to GIF overhead.
|
||||
The GIF format supports only a limited number of bits per pixel, so the
|
||||
program uses ordered dithering to emulate full RGB output.
|
||||
|
||||
|
||||
### PORTABILITY
|
||||
|
||||
The program was tested on Linux, with gcc 3.1; Cygwin, with gcc 3.3; and
|
||||
@@ -109,6 +143,7 @@ It should also be mentioned that the program won't work on systems that
|
||||
distinguish between text and binary streams; however, since hardly
|
||||
anyone uses such systems in this day and age, this is a minor issue. [4]
|
||||
|
||||
|
||||
### EXERCISES FOR THE READER
|
||||
|
||||
1. (1 point) The surface is composed of many small polygons. Try to make it
|
||||
@@ -119,6 +154,7 @@ smoother by increasing the number of polygons.
|
||||
3. (5 points) Locate the famous transcendental constant
|
||||
[π](https://en.wikipedia.org/wiki/Pi) in the code.
|
||||
|
||||
|
||||
### FOOTNOTES
|
||||
|
||||
[1] You can call such a transformation an "ambient isotopy" if you want to
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
|
||||
#define H 20
|
||||
|
||||
#define X for
|
||||
#define F(v,b) X(k = 0; k < 3; k++) v[k] = b;
|
||||
|
||||
typedef double R, V[3], U[4], (*J)(R);
|
||||
typedef void Z;
|
||||
typedef int _;
|
||||
|
||||
V o, d, v;
|
||||
R (*q)[H][6], C[4*H][H][6], sr = 15, br = 25, A, s, t;
|
||||
_ P, Q, g, S, k, e = 256, (*u)(_) = putchar, D[64];
|
||||
J f = cos, Y = sin;
|
||||
char B[256];
|
||||
|
||||
Z
|
||||
T(_ *p, _ k, _ n)
|
||||
{
|
||||
_ g;
|
||||
|
||||
*p = n;
|
||||
|
||||
X(g = 0; k && g < 4; g++)
|
||||
T(p + (9 & (g * 4|g))*(1<<k - 1), k - 1,
|
||||
n + (1<<6-2 * k)*(4 - g&3));
|
||||
}
|
||||
|
||||
Z
|
||||
O(_ c)
|
||||
{
|
||||
B[++S] = c,
|
||||
|
||||
(S > e-2 || c==129) && (*B = S, S = fwrite(B, S+1, 1, stdout) - 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Z N
|
||||
(R*v){R w=sqrt
|
||||
(*v**v +1[v]*v[1]
|
||||
+v[2]*2[v]);F(v,v[k]
|
||||
/w)}Z K(_ j){V
|
||||
n,p ;R*b=(*
|
||||
q) [j],w=f
|
||||
(A),x=
|
||||
Y(A);
|
||||
F(p,
|
||||
br*o[
|
||||
k]+sr
|
||||
* (n[ k] =f(t)*k[v]+
|
||||
Y(t)*(v[(k+1)%3]* d[( k+2)%3]-v[(k+2)%
|
||||
3]*d[(k+1)%3])))*b++=p[1 ]+e/ 2,*b++=-*p*x+
|
||||
p[2]*w-e*e,*b++=(*p*w+p[2]*x)+e/2;F( b,fabs(*n
|
||||
*!!k+n[1]*( k<2)+n[2])/sqrt(2+ !(k-1)))
|
||||
}Z M(R*a,_ s,Z(*m)(_)){_ i;R d=
|
||||
pow(25/log (36),4)/s/ 377;X(
|
||||
*a=i=0;i<s ;i++,*a+=d )m(i);
|
||||
}Z G(_ i ){R w=-Y (P*s),
|
||||
x=f(P*s), y=Y(Q*s ),z=f
|
||||
(Q*s);F( v,k[o] =(k<2
|
||||
)*(x+3)*( k?y:z) -!(k-2 )*w)N(
|
||||
v);F(d,P* (k?k- 1?x:w*y:w*z )+Q*(k?
|
||||
k-1?0:*o:- o[1]) )N(d),w=*d**v+d[1]
|
||||
*v[1]+d[2] *v[2 ];F(v,k[v]-w
|
||||
*d[k])N(v),q =&C[
|
||||
i],M(&t,H,K); }Z W
|
||||
(char*s){*s&&( W(s
|
||||
+1),u(*s-98*(*s>
|
||||
97)));}Z E(_ z){R
|
||||
*r,*a,*b;U*q,l,x,d
|
||||
,I[256];_ i,j,m,c,y,
|
||||
w,h,Y=sizeof l;fputc(
|
||||
46,stderr),M(&s,4*H,G),
|
||||
W("ibcbcbbbbb,"),g=130,
|
||||
O(e/2);X(y=0;y<e;y++){X(i
|
||||
=e;i;)*(I[--i])=0;X(;i<4
|
||||
*H*H;i++)X(*l=k=0;k-5;k++
|
||||
,a=b)if(b=C[(i/H+((k^k/
|
||||
2)&1))%(4*H)][(i+(k/2&1
|
||||
))%H],k&&y<*a^y<*b){X(
|
||||
h=0;h<4;h++)h[x]=a[h
|
||||
+2]+(b[h+2]-a[h+2])
|
||||
*(y-*a)/(*b-*a),h?
|
||||
*l&&(d[h]=(l[h]
|
||||
-h [x])/w):(w=1+
|
||||
fabs (*l-(*x=(_)*x)
|
||||
) ); X(q=I+(_)*x;
|
||||
*l&& w--;q+=2*(
|
||||
*x<* l)-1)X(**q
|
||||
>C[i /H][i%H][1
|
||||
]&&( memcpy(*q,
|
||||
x,Y),* *q=C[i/H][
|
||||
i%H][1 ]),h=1;h<
|
||||
4;h++)x [h]+=h[d];
|
||||
memcpy(l ,x,Y);}X(
|
||||
i=0;i<e;i++ ,O(*r?c:
|
||||
127),g=g<e-1 ?g+1:(O(e/
|
||||
2),130))X(r=&I[ i][3],c=0,j
|
||||
=2;j+1;j--,r--)k=3|!( j-1)*4,m=*r*k+
|
||||
(63*( *r*k-(_)(*r*k))>D[(y*8&56)+(i&7)
|
||||
]), c<<=k/4+2,c|=(m|-(m>k))&
|
||||
k;} O(129);u(0);}_
|
||||
|
||||
|
||||
|
||||
main(_ c, char **v)
|
||||
{
|
||||
if (c < 3)
|
||||
return fprintf(stderr, "Usage: %s P Q [F]\n", *v), 1;
|
||||
|
||||
_setmode(_fileno(stdout), _O_BINARY);
|
||||
|
||||
P = atoi(v[1]),
|
||||
Q = atoi(v[2]),
|
||||
|
||||
T(D, 3, 0);
|
||||
|
||||
W("bb\346cbcba98FIG");
|
||||
|
||||
X(; k < 384; k++)
|
||||
u(k / 3<<("gdb"[k%3] - 97) | 31 | (k % 3!=1)<<5);
|
||||
|
||||
W("bbbce0.2EPACSTEN\x0b\xff!"),
|
||||
|
||||
M(&A, c > 3 ? atoi(v[3]) : 40, E),
|
||||
|
||||
u(59);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vi:set ts=8: */
|
||||
@@ -12,7 +12,8 @@ make
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: known bug - please help us fix
|
||||
STATUS: doesn't work with some platforms - please help us fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2006 monge in bugs.md](/bugs.md#2006-monge).
|
||||
@@ -63,11 +64,13 @@ effort to work on both `i386` and `x86_64`. Portable it is! :)
|
||||
|
||||
0. Compile using the Makefile, or just run:
|
||||
|
||||
gcc monge.c -o monge -O3 `sdl-config --libs --cflags`
|
||||
```sh
|
||||
gcc monge.c -o monge -O3 `sdl-config --libs --cflags`
|
||||
```
|
||||
|
||||
1. Run:
|
||||
|
||||
```
|
||||
```sh
|
||||
./monge "z = 0" "z = z*z + c; Abs2(z) < 4"
|
||||
```
|
||||
|
||||
@@ -113,7 +116,7 @@ Operation | Description
|
||||
`Im` | Extract the imaginary part, i.e.: `Im(a+b*i) is b+0*i`.
|
||||
`Exp` | Calculates the complex exponential, i.e. `Exp(a+b*i)` is
|
||||
| `e^a*(cos(b)+sin(b)*i)`
|
||||
Ln | Calculates the principal value of the natural logarithm, i.e.
|
||||
`Ln` | Calculates the principal value of the natural logarithm, i.e.
|
||||
`Ln(a+b*i)` is `ln(a*a+b*b)/2` + `atan(b/a)*i`
|
||||
|
||||
Here are a few examples of fractals you can draw:
|
||||
@@ -175,6 +178,7 @@ If you want you can change the window width and height, or the default
|
||||
number of iterations (that one can be tweaked at runtime, anyway) by
|
||||
changing the definitions of `W`, `H` and `I` at the beginning of the code.
|
||||
|
||||
|
||||
### Caveats (I just a selected few of them!)
|
||||
|
||||
- The zooming speed depends on the speed of the computer.
|
||||
|
||||
@@ -2209,6 +2209,51 @@ does not exist.
|
||||
This entry requires that `sed` and `make` are in the path.
|
||||
|
||||
|
||||
## 2005 mikeash
|
||||
|
||||
### STATUS: INABIAF - please **DO NOT** fix
|
||||
### Source code: [2005/mikeash/mikeash.c](2005/mikeash/mikeash.c)
|
||||
### Information: [2005/mikeash/README.md](2005/mikeash/README.md)
|
||||
|
||||
The author states:
|
||||
|
||||
* The only built-in functions are `defvar`, `format`, `substitute`,
|
||||
`char-upcase`, `+`, `-`, `*`, and `/`.
|
||||
|
||||
* Only one variable is available. This variable is called `q`, although any
|
||||
symbol name starting with the letter `q` will be mapped to this variable.
|
||||
|
||||
* Only the first letter of a function name is significant. For example,
|
||||
`format`, `f`, `farm`, and various other words starting with `f` will all map to
|
||||
the `format` function.
|
||||
|
||||
* The `defvar` function completely ignores its first parameter. It will always
|
||||
store the result of evaluating its second parameter in `q`. Unlike in [Common
|
||||
Lisp](https://en.wikipedia.org/wiki/Common_Lisp), multiple invocations of
|
||||
`defvar` on the same variable will overwrite old values.
|
||||
|
||||
* Character constants are limited to `#\Newline` and single-character
|
||||
constants such as `#\x`.
|
||||
|
||||
* The `char-upcase` function will give strange results if passed something
|
||||
other than a lowercase character.
|
||||
|
||||
* The `format` function takes exactly three parameters. The first parameter is
|
||||
ignored; output always goes to `stdout`. The second parameter must have exactly
|
||||
one `~s` format specifier in it, and no other format specifiers are permitted.
|
||||
|
||||
* The arithmetic functions take exactly two parameters.
|
||||
|
||||
* All tokens must be separated from a following `)` by whitespace.
|
||||
|
||||
* A lot of other things. Notably, the language which this program interprets is
|
||||
nowhere near
|
||||
[Turing-complete](https://en.wikipedia.org/wiki/Turing_completeness).
|
||||
|
||||
Basically, the [LISP][] interpreter is good for some basic math operations, and
|
||||
for running itself.
|
||||
|
||||
|
||||
## 2005 mynx
|
||||
|
||||
### STATUS: INABIAF - please **DO NOT** fix
|
||||
@@ -2218,10 +2263,11 @@ This entry requires that `sed` and `make` are in the path.
|
||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) notes that, though
|
||||
probably obvious, this entry will not work with https. He added an alt version
|
||||
that scans for https in case someone wants to set up a pipeline or other
|
||||
workaround (perhaps with stunnel) but the problem otherwise is a secure
|
||||
connection has to first be set up in order to give http commands. This is not a
|
||||
bug but it's worth pointing out as it won't work on as many websites as it used
|
||||
to including the [IOCCC website](https://www.ioccc.org) itself.
|
||||
workaround (perhaps with stunnel) or even add additional code to it to make it
|
||||
work with https but the problem otherwise is a secure connection has to first be
|
||||
set up in order to give http commands. This is not a bug but it's worth pointing
|
||||
out as it won't work on as many websites as it used to including the [IOCCC
|
||||
website](https://www.ioccc.org) itself.
|
||||
|
||||
|
||||
## 2005 sykes
|
||||
@@ -2261,14 +2307,18 @@ used decimal mode, or any of the "undocumented" instructions.
|
||||
|
||||
## 2006 monge
|
||||
|
||||
### STATUS: known bug - please help us fix
|
||||
### STATUS: doesn't work with some platforms - please help us fix
|
||||
### Source code: [2006/monge/monge.c](2006/monge/monge.c)
|
||||
### Information: [2006/monge/README.md](2006/monge/README.md)
|
||||
|
||||
Incorrect formulas will ungracefully crash the program.
|
||||
This program requires being able to read, write and execute memory. With the
|
||||
Apple silicon chips this is not allowed. Fixing this might be quite challenging
|
||||
but you are welcome to try and fix it.
|
||||
|
||||
Fixing the (Mis)feature is likely to be a difficult challenge.
|
||||
You are welcome to try and fix it if you can!
|
||||
|
||||
### STATUS: INABIAF - please **DO NOT** fix
|
||||
|
||||
Incorrect formulas will ungracefully crash the program.
|
||||
|
||||
|
||||
## 2006 toledo2
|
||||
|
||||
+31
-1
@@ -2915,6 +2915,12 @@ Cody added the [alt code](2005/anon/README.md#alternate-code) with vi(m) like
|
||||
movements.
|
||||
|
||||
|
||||
## [2005/boutines](2005/boutines/boutines.c) ([README.md](2005/boutines/README.md]))
|
||||
|
||||
Cody added the [input.txt](2005/boutines/input.txt) data file based on suggested
|
||||
input from the author, adapting it to a command to try out.
|
||||
|
||||
|
||||
## [2005/giljade](2005/giljade/giljade.c) ([README.md](2005/giljade/README.md]))
|
||||
|
||||
After Landon fixed the entry to compile with clang Cody noticed this does not
|
||||
@@ -2989,6 +2995,12 @@ Cody added explicit linking of libm (`-lm`) for systems like linux that seem to
|
||||
not do it implicitly (like macOS does).
|
||||
|
||||
|
||||
|
||||
## [2005/klausler](2005/klausler/klausler.c) ([README.md](2005/klausler/README.md))
|
||||
|
||||
Cody added the [try.sh](2005/klausler/try.sh) script.
|
||||
|
||||
|
||||
## [2005/mikeash](2005/mikeash/mikeash.c) ([README.md](2005/mikeash/README.md))
|
||||
|
||||
Cody fixed this to work in linux. The problem was an unknown escape sequence,
|
||||
@@ -3011,6 +3023,15 @@ updated in both the string and the code to be `'n'`.
|
||||
The array size of `c` was updated by 1 out of caution just in case as the array
|
||||
is used to store at least part of the string.
|
||||
|
||||
It might be worth noting that the author stated that the reason for the `\N` is
|
||||
due to LISP having different escape sequences. The code was modified so that
|
||||
feeding the program itself will print itself, showing no difference, which is
|
||||
what is supposed to happen. It is not known, however, if having to change the
|
||||
`\N` to `\n` ended up breaking any LISP. The other examples given by the author
|
||||
also show correct output though.
|
||||
|
||||
Cody also added the [try.sh](2005/mikeash/try.sh) script.
|
||||
|
||||
|
||||
## [2005/mynx](2005/mynx/mynx.c) ([README.md](2005/mynx/README.md]))
|
||||
|
||||
@@ -3020,7 +3041,16 @@ needed but part of the entry) would work with compilers that have by default
|
||||
|
||||
Cody also added the alt code which does scan for https. Futile, maybe, based on
|
||||
how https is set up, in which case just enjoy it for what it was. But there
|
||||
might be some command line that will let it work that way.
|
||||
might be some command line that will let it work that way or perhaps someone
|
||||
wants to add the necessary code.
|
||||
|
||||
|
||||
## [2005/persano](2005/persano/persano.c) ([README.md](2005/persano/README.md]))
|
||||
|
||||
Cody added the (untested) [alternate
|
||||
code](2005/persano/README.md#alternate-code) which should work for Windows as it
|
||||
sets binary mode on `stdout`. It is untested as Cody has no Windows system to
|
||||
test it on.
|
||||
|
||||
|
||||
## [2005/sykes](2005/sykes/sykes.c) ([README.md](2005/sykes/README.md]))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# A todo list of known things to check and/or do
|
||||
*Last updated: Thu 16 Nov 2023 11:20:54 UTC**
|
||||
*Last updated: Wed 22 Nov 2023 13:02:04 UTC*
|
||||
|
||||
This document is primarily for [Cody Boone
|
||||
Ferguson](/winners.html#Cody_Boone_Ferguson) as he (that is I :-) ) wanted a way
|
||||
@@ -152,3 +152,8 @@ that it might be that `S` will work in all cases (currently?) though one has two
|
||||
values so the second would could be changed to `SS` (which is convenient as it's
|
||||
for SDL). This is low priority but it would be nice to have done as it would
|
||||
make it consistent and easy to remember.
|
||||
|
||||
- With the entries that we recommend the alt code first when it comes to it
|
||||
going too fast we should say not what it looks like in modern systems but rather
|
||||
what it LOOKED LIKE AT THE TIME. At Wed 22 Nov 2023 13:02:04 UTC the only entry
|
||||
that has had this done is [1985/lycklama](1985/lycklama/README.md).
|
||||
Reference in new issue
Block a user