diff --git a/1989/fubar/fubar.c b/1989/fubar/fubar.c index 34ac78bdf..38d8a7621 100644 --- a/1989/fubar/fubar.c +++ b/1989/fubar/fubar.c @@ -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 */ diff --git a/1989/fubar/fubar.sh b/1989/fubar/fubar.sh index 816a1147d..74929c5ea 100755 --- a/1989/fubar/fubar.sh +++ b/1989/fubar/fubar.sh @@ -9,8 +9,7 @@ fi # run/compile it rm -f ouroboros.c x1 x -ex - <&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 diff --git a/1992/albert/README.md b/1992/albert/README.md index 2fcd9d9b3..ce571df55 100644 --- a/1992/albert/README.md +++ b/1992/albert/README.md @@ -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 diff --git a/1992/albert/try.alt.sh b/1992/albert/try.alt.sh new file mode 100755 index 000000000..e4ec13e02 --- /dev/null +++ b/1992/albert/try.alt.sh @@ -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 diff --git a/1992/albert/try.sh b/1992/albert/try.sh new file mode 100755 index 000000000..ec9439684 --- /dev/null +++ b/1992/albert/try.sh @@ -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 diff --git a/1992/ant/README.md b/1992/ant/README.md index ade2667ad..e89334ba4 100644 --- a/1992/ant/README.md +++ b/1992/ant/README.md @@ -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 ``` diff --git a/1992/ant/ant.test.mk b/1992/ant/ant.test.mk index 6004c4fae..987b232ac 100644 --- a/1992/ant/ant.test.mk +++ b/1992/ant/ant.test.mk @@ -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. diff --git a/1992/ant/try.sh b/1992/ant/try.sh new file mode 100755 index 000000000..465a0cb2b --- /dev/null +++ b/1992/ant/try.sh @@ -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 diff --git a/1992/buzzard.2/.gitignore b/1992/buzzard.2/.gitignore index 8ae53d7e6..023828d87 100644 --- a/1992/buzzard.2/.gitignore +++ b/1992/buzzard.2/.gitignore @@ -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 diff --git a/1992/buzzard.2/Makefile b/1992/buzzard.2/Makefile index 3074e911d..9fccec062 100644 --- a/1992/buzzard.2/Makefile +++ b/1992/buzzard.2/Makefile @@ -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} diff --git a/1992/buzzard.2/README.md b/1992/buzzard.2/README.md index abb57e09d..5985703b4 100644 --- a/1992/buzzard.2/README.md +++ b/1992/buzzard.2/README.md @@ -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.) diff --git a/1992/buzzard.2/buzzard.2.alt.c b/1992/buzzard.2/buzzard.2.alt.c index 7f77ab117..6b11b6ad3 100644 --- a/1992/buzzard.2/buzzard.2.alt.c +++ b/1992/buzzard.2/buzzard.2.alt.c @@ -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] diff --git a/1992/buzzard.2/help.th b/1992/buzzard.2/help.th index 7afab271a..025d9ca1c 100644 --- a/1992/buzzard.2/help.th +++ b/1992/buzzard.2/help.th @@ -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. diff --git a/1992/buzzard.2/try.alt.sh b/1992/buzzard.2/try.alt.sh new file mode 100755 index 000000000..9f6159c2b --- /dev/null +++ b/1992/buzzard.2/try.alt.sh @@ -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 diff --git a/1992/buzzard.2/try.sh b/1992/buzzard.2/try.sh new file mode 100755 index 000000000..64482e8a5 --- /dev/null +++ b/1992/buzzard.2/try.sh @@ -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 diff --git a/1993/ant/README.md b/1993/ant/README.md index d8e45d594..e509d18b0 100644 --- a/1993/ant/README.md +++ b/1993/ant/README.md @@ -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 ``` diff --git a/1993/ant/ants.txt b/1993/ant/ants.txt new file mode 100644 index 000000000..50037e126 --- /dev/null +++ b/1993/ant/ants.txt @@ -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. diff --git a/1993/ant/try.sh b/1993/ant/try.sh new file mode 100755 index 000000000..331d88553 --- /dev/null +++ b/1993/ant/try.sh @@ -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 diff --git a/1993/dgibson/README.md b/1993/dgibson/README.md index 9c265098d..046b90d25 100644 --- a/1993/dgibson/README.md +++ b/1993/dgibson/README.md @@ -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. diff --git a/1993/dgibson/dgibson.sh b/1993/dgibson/dgibson.sh index 35bb9d8f0..c3482fce9 100755 --- a/1993/dgibson/dgibson.sh +++ b/1993/dgibson/dgibson.sh @@ -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 # diff --git a/1993/dgibson/try.sh b/1993/dgibson/try.sh new file mode 100755 index 000000000..c5ffa0550 --- /dev/null +++ b/1993/dgibson/try.sh @@ -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 diff --git a/1993/ejb/README.md b/1993/ejb/README.md index 51cc9d0e4..57208d11e 100644 --- a/1993/ejb/README.md +++ b/1993/ejb/README.md @@ -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 diff --git a/1993/ejb/try.sh b/1993/ejb/try.sh new file mode 100755 index 000000000..cca8f30b4 --- /dev/null +++ b/1993/ejb/try.sh @@ -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 diff --git a/1993/vanb/README.md b/1993/vanb/README.md index 0ecea9fdf..35020f285 100644 --- a/1993/vanb/README.md +++ b/1993/vanb/README.md @@ -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()` diff --git a/1993/vanb/try.sh b/1993/vanb/try.sh new file mode 100755 index 000000000..febf723f9 --- /dev/null +++ b/1993/vanb/try.sh @@ -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 diff --git a/thanks-for-help.md b/thanks-for-help.md index 3bb0db57f..3c805708d 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -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 - <[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. ## [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. ## [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. + + +## [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. ## [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 :-) # 1993 +## [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. + + ## [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. ## [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. + + +## [1993/ejb](/1993/ejb/ejb.c) ([README.md](/1993/ejb/README.md])) + +[Cody](#cody) added the [try.sh](/1993/ejb/try.sh) script. ## [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. + # 1994