Merge pull request #1893 from xexyl/ant93
Add 1993/ant/try.txt and ants.txt
This commit is contained in:
29 files changed
+597
-59
No files matched your search
+3
-3
@@ -9,12 +9,12 @@
|
||||
if(m && q=='T' && o=='T'){m=0;(void)fread(tt,11,1,stdin);(void)printf("T %9d\n",atoi(tt)*QQ);}else {q=o;(void)putchar(o);}}exit(0);}
|
||||
cc ouroboros.c -o x
|
||||
#define zxc ;{/*
|
||||
cat ./ouroboros.c | ./x $1 > x1
|
||||
cat ouroboros.c | ./x $1 > x1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
exit
|
||||
fi
|
||||
mv x1 ./ouroboros.c
|
||||
chmod +x ./ouroboros.c
|
||||
mv x1 ouroboros.c
|
||||
chmod +x ouroboros.c
|
||||
exec ./ouroboros.c $1
|
||||
exit
|
||||
*/
|
||||
+1
-2
@@ -9,8 +9,7 @@ fi
|
||||
|
||||
# run/compile it
|
||||
rm -f ouroboros.c x1 x
|
||||
ex - <<EOF
|
||||
r fubar.c
|
||||
ex fubar.c <<EOF
|
||||
8,9j
|
||||
w ouroboros.c
|
||||
EOF
|
||||
|
||||
@@ -13,8 +13,10 @@ adsleep
|
||||
adsleep.c
|
||||
adwc
|
||||
adwc.c
|
||||
adwc.adwc.txt
|
||||
*.dSYM
|
||||
indent
|
||||
indent.c
|
||||
indent.o
|
||||
prog.orig
|
||||
wc.adwc.txt
|
||||
+7
-10
@@ -20,7 +20,7 @@ For more detailed information see [1992 adrian in bugs.md](/bugs.md#1992-adrian)
|
||||
### Try:
|
||||
|
||||
```sh
|
||||
./adrian adrian.grep.try < README.md
|
||||
./try.sh
|
||||
```
|
||||
|
||||
For the slow minded, try:
|
||||
@@ -29,9 +29,6 @@ For the slow minded, try:
|
||||
./adsleep 32767
|
||||
```
|
||||
|
||||
NOTE: if you do not specify an arg some of the programs such as `adsleep` it
|
||||
will very likely segfault do something funny. This is supposed to happen.
|
||||
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
@@ -160,11 +157,11 @@ Running:
|
||||
|
||||
will perform a function similar to that of the unix `from` command.
|
||||
|
||||
If no filename is specified on the command line, then `__FILE__` is used
|
||||
as the specification for the automaton. (Originally `"adgrep.c"` the file was renamed
|
||||
to `adrian.c` by the judges but for more portability the arg was changed to
|
||||
`__FILE__`.) In this case, the program will search for
|
||||
matches to the regular expression:
|
||||
If no filename is specified on the command line, then `__FILE__` is used as the
|
||||
specification for the automaton. (Originally this was `"adgrep.c"` but the file
|
||||
was renamed to `adrian.c` by the judges and for more portability the arg was
|
||||
changed to `__FILE__`.) In this case, the program will search for matches to
|
||||
the regular expression:
|
||||
|
||||
```
|
||||
^.[^|C][^w[Q]*(Q|[w[]c).*|^.[C|]$
|
||||
@@ -219,7 +216,7 @@ you can search for matches to
|
||||
|
||||
By some freak happenstance, lines of `adrian.c` which match this regular
|
||||
expression form a unix `head(1)` command. It prints the first ten lines of
|
||||
the file specified on the command line or adrian.c if no file is
|
||||
the file specified on the command line or `adrian.c` if no file is
|
||||
specified (again this was changed to `__FILE__`).
|
||||
|
||||
By setting the first line to
|
||||
|
||||
Executable
+61
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 1992/adrian
|
||||
#
|
||||
|
||||
# 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
|
||||
|
||||
# don't redirect output to /dev/null so that they can see how it's done,
|
||||
# assuming it's not already built
|
||||
make CC="$CC" everything || exit 1
|
||||
# DON'T clear the screen so they can see how the files are generated!
|
||||
|
||||
echo 1>&2
|
||||
read -r -n 1 -p "Press any key to show: adrian.grep.try: "
|
||||
echo 1>&2
|
||||
cat adrian.grep.try
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./adrian adrian.grep.try < README.md: "
|
||||
echo 1>&2
|
||||
./adrian adrian.grep.try < README.md
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./adhead try.sh: "
|
||||
echo 1>&2
|
||||
./adhead try.sh
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./adecho 1992 IOCCC adrian: "
|
||||
echo 1>&2
|
||||
./adecho 1992 IOCCC adrian
|
||||
echo 1>&2
|
||||
|
||||
rm -f wc.adwc.txt adwc.adwc.txt
|
||||
echo "$ wc adwc.c | sed -e 's/^[[:space:]]//g' | tr -s '[:space:]' | cut -d' ' -f1-3 | tee wc.adwc.txt" 1>&2
|
||||
read -r -n 1 -p "Press any key to continue: "
|
||||
echo 1>&2
|
||||
wc adwc.c | sed -e 's/^[[:space:]]//g' | tr -s '[:space:]' | cut -d' ' -f1-3 | tee wc.adwc.txt
|
||||
echo 1>&2
|
||||
|
||||
echo "$ ./adwc adwc.c|tr -s ' '|sed -e 's/^[[:space:]]//g' | tee adwc.adwc.txt" 1>&2
|
||||
read -r -n 1 -p "Press any key to continue: "
|
||||
echo 1>&2
|
||||
./adwc adwc.c|tr -s ' '|sed -e 's/^[[:space:]]//g' | tee adwc.adwc.txt
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to show diff between wc.adwc.txt and adwc.adwc.txt: "
|
||||
echo 1>&2
|
||||
diff -s wc.adwc.txt adwc.adwc.txt
|
||||
echo 1>&2
|
||||
rm -f wc.adwc.txt adwc.adwc.txt
|
||||
|
||||
echo "$ ./adsleep 10" 1>&2
|
||||
read -r -n 1 -p "Press any key to take a 10 second nap: "
|
||||
echo 1>&2
|
||||
./adsleep 10
|
||||
@@ -29,7 +29,7 @@ For more detailed information see [1992 albert in bugs.md](/bugs.md#1992-albert)
|
||||
### Try:
|
||||
|
||||
```sh
|
||||
./albert 1234567890123456789
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -74,6 +74,12 @@ make alt
|
||||
Use `albert.alt` as you would `albert` above.
|
||||
|
||||
|
||||
### Alternate try:
|
||||
|
||||
```sh
|
||||
./try.alt.sh
|
||||
```
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
We were impressed with the speed at which it was able to factor
|
||||
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.alt.sh - demonstrate IOCCC winner 1992/albert alt code
|
||||
#
|
||||
|
||||
# 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" alt >/dev/null || exit 1
|
||||
|
||||
# clear screen after compilation so that only the entry is shown
|
||||
clear
|
||||
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./albert.alt 1234567890123456789: "
|
||||
echo 1>&2
|
||||
./albert.alt 1234567890123456789
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./albert.alt 12345678987654321: "
|
||||
echo 1>&2
|
||||
./albert.alt 12345678987654321
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./albert.alt 42: "
|
||||
echo 1>&2
|
||||
./albert.alt 42
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./albert.alt 4242424242: "
|
||||
echo 1>&2
|
||||
./albert.alt 4242424242
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./albert.alt 10000000001: "
|
||||
echo 1>&2
|
||||
./albert.alt 10000000001
|
||||
echo 1>&2
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 1992/albert
|
||||
#
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./albert 1234567890123456789: "
|
||||
echo 1>&2
|
||||
./albert 1234567890123456789
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./albert 12345678987654321: "
|
||||
echo 1>&2
|
||||
./albert 12345678987654321
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./albert 42: "
|
||||
echo 1>&2
|
||||
./albert 42
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./albert 4242424242: "
|
||||
echo 1>&2
|
||||
./albert 4242424242
|
||||
echo 1>&2
|
||||
+4
-10
@@ -9,24 +9,18 @@ make all
|
||||
|
||||
```sh
|
||||
./ant Makefile
|
||||
|
||||
./ant Makefile rule
|
||||
```
|
||||
|
||||
where `Makefile` is a Makefile to use.
|
||||
where `Makefile` is a Makefile to use and `rule` is an optional rule to use.
|
||||
|
||||
|
||||
### Try:
|
||||
|
||||
First build the tool itself with our Makefile:
|
||||
|
||||
```sh
|
||||
./ant Makefile am
|
||||
```
|
||||
|
||||
Now use `am` to do some things:
|
||||
|
||||
```sh
|
||||
./am Makefile am_clobber # clobber everything except am
|
||||
./am ant.test.mk # run the test Makefile with am
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ TEXT_2 = test macro split \
|
||||
three lines
|
||||
TEXT_3 = test dollar macro '$$'
|
||||
TEXT_4 = test dollar again "$$(TEXT_1)"
|
||||
TEXT_5 = imbeded macro '$(TEXT_1)'
|
||||
TEXT_5 = embedded macro '$(TEXT_1)'
|
||||
|
||||
redefine : r1 r2 r3 r4 r5
|
||||
|
||||
@@ -161,7 +161,7 @@ leaf.5 :
|
||||
|
||||
# Command lines split across lines.
|
||||
split.cmd:
|
||||
echo Try spliting command \
|
||||
echo Try splitting command \
|
||||
lines across more \
|
||||
than one line.
|
||||
|
||||
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 1992/ant
|
||||
#
|
||||
|
||||
# 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 "$ ./ant Makefile am # build the tool itself" 1>&2
|
||||
read -r -n 1 -p "Press any key to run: ./ant Makefile am: "
|
||||
echo 1>&2
|
||||
./ant Makefile am
|
||||
echo 1>&2
|
||||
|
||||
echo "$ ./am Makefile am_clobber # clobber everything except am" 1>&2
|
||||
read -r -n 1 -p "Press any key to continue: "
|
||||
echo 1>&2
|
||||
./am Makefile am_clobber # clobber everything except am
|
||||
echo 1>&2
|
||||
|
||||
echo "$ ./am ant.test.mk # run the test Makefile with am" 1>&2
|
||||
read -r -n 1 -p "Press any key to continue: "
|
||||
echo 1>&2
|
||||
./am ant.test.mk # run the test Makefile with am
|
||||
@@ -1,9 +1,11 @@
|
||||
#
|
||||
# sort with: sort -d -u
|
||||
buzzard.2
|
||||
buzzard.2.alt
|
||||
buzzard.2.orig
|
||||
*.dSYM
|
||||
first
|
||||
first.alt
|
||||
indent
|
||||
indent.c
|
||||
indent.o
|
||||
|
||||
@@ -114,7 +114,7 @@ DATA=
|
||||
TARGET= ${PROG} first
|
||||
#
|
||||
ALT_OBJ= ${PROG}.alt.o
|
||||
ALT_TARGET= ${PROG}.alt
|
||||
ALT_TARGET= ${PROG}.alt first.alt
|
||||
|
||||
|
||||
#################
|
||||
@@ -144,6 +144,10 @@ alt: data ${ALT_TARGET}
|
||||
${PROG}.alt: ${PROG}.alt.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
||||
|
||||
first.alt: ${PROG}.alt
|
||||
${RM} -f $@
|
||||
${LN} $< $@
|
||||
|
||||
# data files
|
||||
#
|
||||
data: ${DATA}
|
||||
|
||||
+22
-10
@@ -10,8 +10,8 @@ code](#alternate-code) below for details.
|
||||
|
||||
## To use:
|
||||
|
||||
First, you must make sure that first is made first (even though `make all`
|
||||
should do it :-) ):
|
||||
First, you must make sure that `first` is made first (even though `make all`
|
||||
should make first first :-) ):
|
||||
|
||||
```sh
|
||||
make first
|
||||
@@ -48,6 +48,13 @@ Sorry, this is third!
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
## Alternate code:
|
||||
|
||||
This alternate version, [buzzard.2.alt.c](buzzard.2.alt.c), does not contain a
|
||||
@@ -66,6 +73,12 @@ make alt
|
||||
Use `buzzard.2.alt` as you would `buzzard.2` above.
|
||||
|
||||
|
||||
### Alternate try:
|
||||
|
||||
```sh
|
||||
./try.alt.sh
|
||||
```
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
Have fun!
|
||||
@@ -99,8 +112,8 @@ further down.
|
||||
`first` expects you to first enter the names of the 13 primitives,
|
||||
separated by whitespace--it doesn't care what you name them, but
|
||||
if all the names aren't unique, you won't be able to use some of
|
||||
them. After this you may type any sequence of valid first input.
|
||||
Valid first input is defined as any sequence of whitespace-delimited
|
||||
them. After this you may type any sequence of valid `first` input.
|
||||
Valid `first` input is defined as any sequence of whitespace-delimited
|
||||
tokens which consist of primitives, new words you've defined, and
|
||||
integers (as parsed by `"%d"`). Invalid input behaves unpredictably,
|
||||
but gives no warning messages. A sample program, `demo1.1st`, is
|
||||
@@ -108,7 +121,7 @@ included, but it only works on ASCII systems.
|
||||
|
||||
Do not expect to be able to do anything interesting with `first`.
|
||||
|
||||
To do something interesting, you need to feed first the file
|
||||
To do something interesting, you need to feed `first` the file
|
||||
[third](third) first. In unix, you can do
|
||||
|
||||
```sh
|
||||
@@ -159,7 +172,7 @@ Other related obfuscations are still present. The top of the stack is cached in
|
||||
a variable, which increases performance massively if the compiler can figure out
|
||||
to keep it in a register; it also obfuscates the code. (Unfortunately, the top
|
||||
of stack is a global variable and neither gcc nor most bundled compilers seem to
|
||||
register allocate it.)
|
||||
`register` allocate it.)
|
||||
|
||||
More significant are the design obfuscations. `m[0]` is the "dictionary
|
||||
pointer", used when compiling words, and `m[1]` is the return stack index. Both
|
||||
@@ -205,15 +218,14 @@ are primitives in
|
||||
[FORTH](https://en.wikipedia.org/wiki/Forth_(programming_language)) (like swap)
|
||||
take a significant amount of time in THIRD.
|
||||
|
||||
When you get the `Ok.` message from third, try out some sample
|
||||
[FORTH](https://en.wikipedia.org/wiki/Forth_(programming_language)) code (first
|
||||
has no way of knowing if keyboard input is waiting, so it can't actually prompt
|
||||
When you get the `Ok.` message from `third`, try out some sample
|
||||
[FORTH](https://en.wikipedia.org/wiki/Forth_(programming_language)) code
|
||||
(`first` has no way of knowing if keyboard input is waiting, so it can't actually prompt
|
||||
you in a normal way. It only prints `'Ok.'` after you define a word).
|
||||
|
||||
|
||||
```sh
|
||||
2 3 + . cr
|
||||
|
||||
```
|
||||
|
||||
(which adds 2 and 3, and print the result and a newline.)
|
||||
|
||||
@@ -17,7 +17,7 @@ a(x)
|
||||
r(x)
|
||||
{
|
||||
switch(x++[m]){
|
||||
z 5: for(w=scanf("%s",s)<1?exit(0):L;strcmp(s,&w[&m[1]][s]);w=m[w]);
|
||||
z 5: for(w=scanf("%s",s)<1?exit(0),0:L;strcmp(s,&w[&m[1]][s]);w=m[w]);
|
||||
w-1 ? r(w+2) : (c 2,c atoi(s))
|
||||
z 12: I=1[m]--[m]
|
||||
z 15: f=S[-f]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
: help key ( flush the carriage return form the input buffer )
|
||||
|
||||
" The following are the standard known words; words marked with (*) are
|
||||
immediate words, which cannot be used from command mode, but only in
|
||||
immediate words, which cannot be used in command mode, but only in
|
||||
word definitions. Words marked by (**) declare new words, so are always
|
||||
followed by the new word.
|
||||
|
||||
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.alt.sh - demonstrate IOCCC winner 1992/buzzard.2 alt code
|
||||
#
|
||||
|
||||
# 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" alt >/dev/null || exit 1
|
||||
|
||||
# clear screen after compilation so that only the entry is shown
|
||||
clear
|
||||
|
||||
echo "$ echo help | cat third help.th - | ./first.alt" 1>&2
|
||||
read -r -n 1 -p "Press any key to read help (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
echo help | cat third help.th - | ./first.alt | less -rEXF
|
||||
|
||||
for i in demo[1-6].th; do
|
||||
# try out each demo
|
||||
#
|
||||
read -r -n 1 -p "Press any key to show $i (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
less -rEXF "$i"
|
||||
echo 1>&2
|
||||
read -r -n 1 -p "Press any key to run cat third $i | ./first.alt (demo $i): "
|
||||
echo 1>&2
|
||||
cat third "$i" | ./first.alt
|
||||
echo 1>&2
|
||||
done
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 1992/buzzard.2
|
||||
#
|
||||
|
||||
# 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 "$ echo help | cat third help.th - | ./first" 1>&2
|
||||
read -r -n 1 -p "Press any key to read help (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
echo help | cat third help.th - | ./first | less -rEXF
|
||||
|
||||
for i in demo[1-6].th; do
|
||||
# try out each demo
|
||||
#
|
||||
read -r -n 1 -p "Press any key to show $i (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
less -rEXF "$i"
|
||||
echo 1>&2
|
||||
read -r -n 1 -p "Press any key to run cat third $i | ./first (demo $i): "
|
||||
echo 1>&2
|
||||
cat third "$i" | ./first
|
||||
echo 1>&2
|
||||
done
|
||||
+1
-3
@@ -25,10 +25,8 @@ For more detailed information see [1993 ant in bugs.md](/bugs.md#1993-ant).
|
||||
|
||||
### Try:
|
||||
|
||||
You may also want to try the author's test suite:
|
||||
|
||||
```sh
|
||||
make -f ant.test.mk
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
The ants go marching one by one, hurrah, hurrah
|
||||
The ants go marching one by one, hurrah, hurrah
|
||||
The ants go marching one by one,
|
||||
The little one stops to suck his thumb
|
||||
And they all go marching down to the ground
|
||||
To get out of the rain, BOOM! BOOM! BOOM!
|
||||
The ants go marching two by two, hurrah, hurrah
|
||||
The ants go marching two by two, hurrah, hurrah
|
||||
The ants go marching two by two,
|
||||
The little one stops to tie his shoe
|
||||
And they all go marching down to the ground
|
||||
To get out of the rain, BOOM! BOOM! BOOM!
|
||||
The ants go marching three by three, hurrah, hurrah
|
||||
The ants go marching three by three, hurrah, hurrah
|
||||
The ants go marching three by three,
|
||||
The little one stops to climb a tree
|
||||
And they all go marching down to the ground
|
||||
To get out of the rain, BOOM! BOOM! BOOM!
|
||||
The ants go marching four by four, hurrah, hurrah
|
||||
The ants go marching four by four, hurrah, hurrah
|
||||
The ants go marching four by four,
|
||||
The little one stops to shut the door
|
||||
And they all go marching down to the ground
|
||||
To get out of the rain, BOOM! BOOM! BOOM!
|
||||
The ants go marching five by five, hurrah, hurrah
|
||||
The ants go marching five by five, hurrah, hurrah
|
||||
The ants go marching five by five,
|
||||
The little one stops to take a dive
|
||||
And they all go marching down to the ground
|
||||
To get out of the rain, BOOM! BOOM! BOOM!
|
||||
The ants go marching six by six, hurrah, hurrah
|
||||
The ants go marching six by six, hurrah, hurrah
|
||||
The ants go marching six by six,
|
||||
The little one stops to pick up sticks
|
||||
And they all go marching down to the ground
|
||||
To get out of the rain, BOOM! BOOM! BOOM!
|
||||
The ants go marching seven by seven, hurrah, hurrah
|
||||
The ants go marching seven by seven, hurrah, hurrah
|
||||
The ants go marching seven by seven,
|
||||
The little one stops to pray to heaven
|
||||
And they all go marching down to the ground
|
||||
To get out of the rain, BOOM! BOOM! BOOM!
|
||||
The ants go marching eight by eight, hurrah, hurrah
|
||||
The ants go marching eight by eight, hurrah, hurrah
|
||||
The ants go marching eight by eight,
|
||||
The little one stops to roller skate
|
||||
And they all go marching down to the ground
|
||||
To get out of the rain, BOOM! BOOM! BOOM!
|
||||
The ants go marching nine by nine, hurrah, hurrah
|
||||
The ants go marching nine by nine, hurrah, hurrah
|
||||
The ants go marching nine by nine,
|
||||
The little one stops to check the time
|
||||
And they all go marching down to the ground
|
||||
To get out of the rain, BOOM! BOOM! BOOM!
|
||||
The ants go marching ten by ten, hurrah, hurrah
|
||||
The ants go marching ten by ten, hurrah, hurrah
|
||||
The ants go marching ten by ten,
|
||||
The little one stops to shout "The End",
|
||||
And they all go marching down to the ground
|
||||
To get out of the rain.
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 1993/ant
|
||||
#
|
||||
|
||||
# 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
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./ant ant README.md: "
|
||||
echo 1>&2
|
||||
./ant ant README.md
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./ant '\[' ant.txt: "
|
||||
echo 1>&2
|
||||
./ant '\[' ant.txt
|
||||
echo 1>&2
|
||||
|
||||
echo "Note: the next one should show: ag: Pattern too long." 1>&2
|
||||
read -r -n 1 -p "Press any key to run: ./ant '[' ant.txt: "
|
||||
echo 1>&2
|
||||
./ant '[' ant.txt
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./ant ant ants.txt | cut -d: -f2 (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
./ant ant ants.txt | cut -d: -f2 | less -rEXF
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run the test suite (make -f ant.test.mk) (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
make -f ant.test.mk | less -rEXF
|
||||
@@ -19,7 +19,7 @@ where:
|
||||
### Try:
|
||||
|
||||
```sh
|
||||
./dgibson.sh dgibson.data3
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -38,7 +38,8 @@ There are a number of data files available:
|
||||
- [dgibson.data5](dgibson.data5)
|
||||
|
||||
For [dgibson.data5](dgibson.data5) you will need a large screen, lots of virtual
|
||||
memory and lots of time!
|
||||
memory and lots of time! The [try.sh](try.sh) script will run
|
||||
[dgibson.sh](dgibson.sh) on all the data files.
|
||||
|
||||
Good luck trying to use a debugger on this entry! Life is not
|
||||
always pretty.
|
||||
|
||||
+10
-2
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# dgibson.sh - run the dgibson entry
|
||||
# dgibson.sh - run the IOCCC winner 1993/dgibson
|
||||
#
|
||||
# usage:
|
||||
# dgibson.sh [data_file]
|
||||
@@ -45,7 +45,15 @@ fi
|
||||
# build a new copy of the program
|
||||
#
|
||||
rm -f dgibson
|
||||
make dgibson
|
||||
# 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
|
||||
|
||||
|
||||
# form the next generation
|
||||
#
|
||||
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 1993/dgibson
|
||||
#
|
||||
|
||||
# we make use of the script dgibson.sh so we don't need to compile it. In any
|
||||
# event that script rebuilds the program.
|
||||
if [[ -z "$CC" ]]; then
|
||||
CC="cc"
|
||||
fi
|
||||
|
||||
for f in dgibson.data[1-5]; do
|
||||
read -r -n 1 -p "Press any key to run: CC=$CC ./dgibson.sh $f: "
|
||||
echo 1>&2
|
||||
CC="$CC" ./dgibson.sh "$f"
|
||||
echo 1>&2
|
||||
done
|
||||
@@ -18,6 +18,14 @@ level a value from -128 to 127
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
A negative argument plays the patience puzzle. An argument
|
||||
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 1993/ejb
|
||||
#
|
||||
|
||||
# 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
|
||||
|
||||
read -r -n 1 -p "Press any key to play the patience puzzle: ./ejb -3: "
|
||||
echo 1>&2
|
||||
./ejb -3
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to play the Tower of Hanoi puzzle: ./ejb 3: "
|
||||
echo 1>&2
|
||||
./ejb 3
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./ejb 0: "
|
||||
echo 1>&2
|
||||
./ejb 0
|
||||
exit 0
|
||||
+3
-3
@@ -29,9 +29,7 @@ hexadecimal and decimal numbers.
|
||||
### Try:
|
||||
|
||||
```sh
|
||||
./vanb '1+1'
|
||||
|
||||
./vanb '4+4'
|
||||
./try.sh
|
||||
```
|
||||
|
||||
What happens if you use something other than valid digits?
|
||||
@@ -63,6 +61,7 @@ The program does no error checking - erroneous expressions will
|
||||
produce spurious results. Note that unary `-` is an operator. Thus,
|
||||
decimal `-46` would be entered as `-d46` and not `d-46`.
|
||||
|
||||
|
||||
### What Makes This Program Special:
|
||||
|
||||
0. Of course, the fact that the program takes input and produces output in
|
||||
@@ -86,6 +85,7 @@ format a program which has no explicit control structures (other than `?:`s).
|
||||
6. Many simple tasks are done many times. I tried to do these differently each
|
||||
time, to make the program harder to understand.
|
||||
|
||||
|
||||
### How It Works:
|
||||
|
||||
It's a recursive descent parser, calling `main()`
|
||||
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 1993/vanb
|
||||
#
|
||||
|
||||
# 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
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./vanb '1+1': "
|
||||
echo 1>&2
|
||||
./vanb '1+1'
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./vanb '4+4': "
|
||||
echo 1>&2
|
||||
./vanb '4+4'
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./vanb '+(1777-x11)*d2': "
|
||||
echo 1>&2
|
||||
./vanb '+(1777-x11)*d2'
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./vanb '-(1777-x11)*d2': "
|
||||
echo 1>&2
|
||||
./vanb '-(1777-x11)*d2'
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./vanb '(1777-xfeed*xdead-xd00d+xf00d)*d2': "
|
||||
echo 1>&2
|
||||
./vanb '(1777-xfeed*xdead-xd00d+xf00d)*d2'
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./vanb '777+777-111*111/123%155': "
|
||||
echo 1>&2
|
||||
./vanb '777+777-111*111/123%155'
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key: ./vanb '777-8': "
|
||||
echo 1>&2
|
||||
./vanb '777-8'
|
||||
echo "... what happened?" 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./vanb '777*8': "
|
||||
echo 1>&2
|
||||
./vanb '777*8'
|
||||
echo "... what happened?" 1>&2
|
||||
exit 0
|
||||
+68
-8
@@ -758,6 +758,27 @@ not strictly necessary but nonetheless more correct, even if not warned against.
|
||||
`$PATH`) to files referred to in the code. The path problem was also fixed in
|
||||
[fubar.sh](/1989/fubar/fubar.sh).
|
||||
|
||||
A strange problem occurred where if one made modifications to the C file it
|
||||
might end up failing to work even after changing it back. This was resolved by:
|
||||
|
||||
```diff
|
||||
--- i/1989/fubar/fubar.sh
|
||||
+++ w/1989/fubar/fubar.sh
|
||||
@@ -7,13 +7,12 @@ if [[ $# -ne 1 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# run/compile it
|
||||
rm -f ouroboros.c x1 x
|
||||
-ex - <<EOF
|
||||
-r fubar.c
|
||||
+ex fubar.c <<EOF
|
||||
8,9j
|
||||
w ouroboros.c
|
||||
EOF
|
||||
chmod +x ouroboros.c
|
||||
```
|
||||
|
||||
Cody also 'modernised' the script to use `bash` and fixed for ShellCheck. The
|
||||
`if [ .. ]` was changed in the C code as well as the script.
|
||||
|
||||
@@ -1406,7 +1427,7 @@ from (`__FILE__`), not `adgrep.c`, as the latter does not exist: `adgrep` is
|
||||
simply a link to `adrian` as `adgrep` is what the program was submitted as but
|
||||
the winner is `adrian.c`.
|
||||
|
||||
Not fixing the above problem would have also cause the program to crash if no
|
||||
Not fixing the above problem would have also caused the program to crash if no
|
||||
arg was specified as the file doesn't exist. In making the above fix, at first
|
||||
the change to check for a `NULL` file was added. Then it was noticed that the
|
||||
problem is that `adgrep.c` was an incorrect reference that never existed and it
|
||||
@@ -1468,6 +1489,11 @@ one must keep the `Y[strlen(Y)-1]='\0';` part and keep it there.
|
||||
These fixes are complex changes due to the way the program and Makefile generate
|
||||
the additional tools.
|
||||
|
||||
Cody finally added the [try.sh](/1992/adrian/try.sh) script that shows the entry
|
||||
and some of the tools this entry generates. Unlike other scripts, it does not
|
||||
clear the screen after compilation so that one can see how the other files are
|
||||
generated.
|
||||
|
||||
|
||||
## <a name="1992_albert"></a>[1992/albert](/1992/albert/albert.c) ([README.md](/1992/albert/README.md]))
|
||||
|
||||
@@ -1475,8 +1501,12 @@ the additional tools.
|
||||
applied to the code, provided as the alt code as that version is not obfuscated.
|
||||
Thus Cody's fix applies to the original entry. The problems were that `malloc.h`
|
||||
is not the correct header file now (at least in some systems?) and a non-void
|
||||
(implicit int) function returning without a value. That function was changed to
|
||||
return void.
|
||||
(implicit `int`) function returning without a value. That function was changed to
|
||||
return `void`.
|
||||
|
||||
Cody also added the [try.sh](/1992/albert/try.sh) and
|
||||
[try.alt.sh](/1992/albert/try.alt.sh) scripts that correspond to the entry and
|
||||
the alt code.
|
||||
|
||||
|
||||
## <a name="1992_ant"></a>[1992/ant](/1992/ant/ant.c) ([README.md](/1992/ant/README.md]))
|
||||
@@ -1484,7 +1514,7 @@ return void.
|
||||
[Cody](#cody) fixed the Makefile so that the program will actually work with it (or at
|
||||
least the rule to clobber files and link `am` to `ant`). The issue was that the
|
||||
variables in the Makefile could not be evaluated in the same way as it's not as
|
||||
feature-rich as other implementations of `make`. Thus the use of `${RM}` and
|
||||
feature-rich as other implementations of `make(1)`. Thus the use of `${RM}` and
|
||||
`${CP}` were in the respective rules changed to `rm` and `cp`, for two examples.
|
||||
A new rule had to be added as well. The variable situation might be because they
|
||||
are obtained from the root variable Makefile `var.mk` via `include` which the
|
||||
@@ -1495,7 +1525,10 @@ Cody also fixed another problem, unrelated, in the Makefile with the `.PHONY`
|
||||
rule where a line was not ended with a `\` but should have been.
|
||||
|
||||
The author stated that in some systems like DOS with Turbo C, it might be
|
||||
necessary to include `time.h` so Cody did this as well.
|
||||
necessary to include `time.h` so Cody did this as well as this exists in other
|
||||
systems too.
|
||||
|
||||
Cody also added the [try.sh](/1992/ant/try.sh) script.
|
||||
|
||||
|
||||
## <a name="1992_buzzard.1"></a>[1992/buzzard.1](/1992/buzzard.1/buzzard.1.c) ([README.md](/1992/buzzard.1/README.md))
|
||||
@@ -1505,8 +1538,18 @@ used. This was not originally done but at a time it was changed to be considered
|
||||
a bug so it was fixed at that point as it only took a few seconds and had to be
|
||||
verified that it was consistent with the [bugs.md](/bugs.md) file.
|
||||
|
||||
He also added the [try.sh](/1991/buzzard.1/try.sh) script to try out some
|
||||
commands that we suggested and some additional ones that provide for some fun.
|
||||
He also added the [try.sh](/1992/buzzard.1/try.sh) script to try out some
|
||||
commands that we suggested and some additional ones that he provide for some fun.
|
||||
|
||||
|
||||
## <a name="1992_buzzard.2"></a>[1992/buzzard.2](/1992/buzzard.2/buzzard.2.c) ([README.md](/1992/buzzard.2/README.md))
|
||||
|
||||
[Cody](#cody) fixed the alt code to compile. The problem was it assumed that
|
||||
`exit(3)` returns a value, not `void`. This was fixed with a `,0`.
|
||||
|
||||
Cody also added the [try.sh](/1992/buzzard.2/try.sh) and
|
||||
[try.alt.sh](/1992/buzzard.2/try.alt.sh) scripts that correspond to the entry
|
||||
and its alt code.
|
||||
|
||||
|
||||
## <a name="1992_gson"></a>[1992/gson](/1992/gson/gson.c) ([README.md](/1992/gson/README.md]))
|
||||
@@ -1660,6 +1703,12 @@ encourage you to try the original without two args :-)
|
||||
# <a name="1993"></a>1993
|
||||
|
||||
|
||||
## <a name="1993_ant"></a>[1993/ant](/1993/ant/ant.c) ([README.md](/1993/ant/README.md]))
|
||||
|
||||
[Cody](#cody) added the [try.sh](/1993/ant/try.sh) script and a data file,
|
||||
[ants.txt](/1993/ant/ants.txt), full of ants for the script.
|
||||
|
||||
|
||||
## <a name="1993_cmills"></a>[1993/cmills](/1993/cmills/cmills.c) ([README.md](/1993/cmills/README.md]))
|
||||
|
||||
[Yusuke](#yusuke) suggested that with modern systems this goes too fast so he added a call
|
||||
@@ -1670,7 +1719,16 @@ first.
|
||||
|
||||
## <a name="1993_dgibson"></a>[1993/dgibson](/1993/dgibson/dgibson.c) ([README.md](/1993/dgibson/README.md]))
|
||||
|
||||
[Cody](#cody) fixed the script to work which assumed that `.` is in the path.
|
||||
[Cody](#cody) fixed the [dgibson.sh](/1993/dgibson/dgibson.sh) script to work
|
||||
which assumed that `.` is in the path.
|
||||
|
||||
Cody also added the [try.sh](/1993/dgibson/try.sh) script which runs the above
|
||||
mentioned script on all the data files.
|
||||
|
||||
|
||||
## <a name="1993_ejb"></a>[1993/ejb](/1993/ejb/ejb.c) ([README.md](/1993/ejb/README.md]))
|
||||
|
||||
[Cody](#cody) added the [try.sh](/1993/ejb/try.sh) script.
|
||||
|
||||
|
||||
## <a name="1993_jonth"></a>[1993/jonth](/1993/jonth/jonth.c) ([README.md](/1993/jonth/README.md]))
|
||||
@@ -1766,6 +1824,8 @@ but fixed to work with clang as well.
|
||||
NOTE: the `N1` and `N2` are provided as notes in the README.md file describing
|
||||
this code. Other code is also described there.
|
||||
|
||||
Cody also added the [try.sh](/1993/vanb/try.sh) script.
|
||||
|
||||
|
||||
# <a name="1994"></a>1994
|
||||
|
||||
|
||||
Reference in new issue
Block a user