diff --git a/2012/endoh1/.gitignore b/2012/endoh1/.gitignore index 5a4531782..2ab43d1b1 100644 --- a/2012/endoh1/.gitignore +++ b/2012/endoh1/.gitignore @@ -2,6 +2,7 @@ endoh1 endoh1.alt endoh1.alt2 endoh1_color +endoh1_color.alt2 endoh1_color.alt configuration.txt endoh1.orig diff --git a/2012/endoh1/Makefile b/2012/endoh1/Makefile index 73391dbac..028ae8d53 100644 --- a/2012/endoh1/Makefile +++ b/2012/endoh1/Makefile @@ -57,7 +57,7 @@ ARCH= # Defines that are needed to compile # -CDEFINE= -DG="$G" -DP="$P" -DV="$V" -DS=12321 +CDEFINE= -DG="$G" -DP="$P" -DV="$V" -DS=12321 -DA=10 # Include files that are needed to compile # @@ -151,7 +151,7 @@ ${PROG}_color: ${PROG}_color.c # alternative executable # -alt: data ${ALT_TARGET} ${PROG}.alt2 +alt: data ${ALT_TARGET} @${TRUE} ${PROG}.alt: ${PROG}.alt.c diff --git a/2012/endoh1/README.md b/2012/endoh1/README.md index 7bf3233ef..2ed6e2c0b 100644 --- a/2012/endoh1/README.md +++ b/2012/endoh1/README.md @@ -4,11 +4,11 @@ make ``` There are two alt versions that let you control the compile time variables that -control the fluid behaviour and the added variable to speed up or slow down the -fluid: one for the original black and white and the colour one added by the -author at the request of the judges. Another version is the deobfuscated version -provided by the author as well. See [alternate code](#alternate-code) below for -more details. +control the fluid behaviour and the added variables to speed up or slow down the +fluid as well as setting a timeout (if not 0): one for the original black and +white and the colour one added by the author at the request of the judges. +Another version is the deobfuscated version provided by the author as well. See +[alternate code](#alternate-code) below for more details. ## To use: @@ -52,6 +52,10 @@ make alt alt2 The `alt2` is only necessary if you wish to compile the deobfuscated version but it is equivalent in function to the original entry, [endoh1.c](endoh1.c). +In the `alt` versions a default time of 10 seconds is set as an alarm so that +one can more easily go through the list of files to see them all in succession +for fun. That is controlled by the variable `A`; 0 disables it. + If you wish to change the speed you should do: ```sh @@ -81,14 +85,13 @@ There is no restriction on what the number is because doing so prevents the macros from being defined to `I` which would prevent the author's remarks about it from being done. +If you want to disable the alarm time, set `A` to 0: -### Alternate use: +```sh +make clobber CDEFINE="-DA=0" alt +``` -Use `endoh1.alt`, `endoh1_color.alt` and `endoh1.alt2` as you would `endoh1` -and `endoh1_color` above. - - -### Alternate try: +It cannot be < 0 or > 60 (arbitrarily selected). Try slowing down the display by increasing the sleep time from `12321` to `50000`: @@ -125,13 +128,25 @@ You might try even: make clobber CDEFINE="-DG=I" alt ``` -and even: +See the author's remarks for details on these macros. + + +### Alternate use: + +Use `endoh1.alt`, `endoh1_color.alt` and `endoh1.alt2` as you would `endoh1` +and `endoh1_color` above. + + +### Alternate try: + +To see two different ways run on the source file and each of the text files, +try: ```sh -make clobber CDEFINE="-DG=I -DV=I" alt +./try.alt.sh ``` -See the author's remarks for details on these macros. +The second run of each will be with the gravity factor set to `I`. ## Judges' remarks: diff --git a/2012/endoh1/endoh1.alt.c b/2012/endoh1/endoh1.alt.c index dda0d2b3e..465ab5f4b 100644 --- a/2012/endoh1/endoh1.alt.c +++ b/2012/endoh1/endoh1.alt.c @@ -16,7 +16,12 @@ # ifndef V # define V 8 # endif - +# ifndef A +# define A 10 +# elif A < 0 || A > 60 +# undef A +# define A 10 +# endif # define h for( x=011; 2012/* # # */-1>x ++;)b[ x]//-' winner # @@ -26,7 +31,7 @@ ## */[i]=e)f(q,w=cabs (d=*p- *q)/2- 1)if(0 <(x=1- w))p[i]+=w*/// ## double complex a [ 97687] ,*p,*q ,*r=a, w=0,d; int x,y;char b/* ## ## */[6856]="\x1b[2J" "\x1b" "[1;1H ", *o= b, *t; int main (){/** ## -## */for( ;0<(x= getc ( stdin) );)w=x >10?32< x?4[/* ## +## */alarm(A);for( ;0<(x= getc ( stdin) );)w=x >10?32< x?4[/* ## ## */*r++ =w,r]= w+1,*r =r[5]= x==35, r+=9:0 ,w-I/* ## ## */:(x= w+2);; for(;; puts(o ),o=b+ 4){z(p [1]*/* ## ## */9,2) w;z(G, 3)(d*( 3-p[2] -q[2]) *P+p[4 ]*V-/* ## @@ -34,7 +39,7 @@ ## */80*( y=*p/2 ),*p+=p [4]+=p [3]/10 *!p[1]) )x=0/* ## ## */ <=x &&x<79 &&0<=y&&y<23?1[1 [*t|=8 ,t]|=4,t+=80]=1/* ## ## */, *t |=2:0; h=" '`-.|//,\\" "|\\_" "\\/\x23\n"[x/** ## -## */%80- 9?x[b] :16];;usleep( S) ;}return 0;}/* ## +## */%80- 9?x[b] :16];;usleep( S ) ;}return 0;}/* ## #### #### ############################################################################### **###########################################################################*/ diff --git a/2012/endoh1/endoh1_color.alt.c b/2012/endoh1/endoh1_color.alt.c index ca2b36c73..7f03cfab0 100644 --- a/2012/endoh1/endoh1_color.alt.c +++ b/2012/endoh1/endoh1_color.alt.c @@ -16,6 +16,12 @@ # ifndef V # define V 8 # endif +# ifndef A +# define A 10 +# elif A < 0 || A > 60 +# undef A +# define A 10 +# endif # define c y+=( x=ctanh( -cabs/* # # */(4[t ]-=20) /2+9)* 3+3)*// # @@ -30,7 +36,7 @@ ## */?(t- b)%960 ?(15-t [11])[ "\x23" "/\\_" "\\"/* ## ## */"||" ",//|" ".-`' "]:10: 0)) y= 0020,c 01;}/* ## ## */void g( int i){7[t +=i]|= x/=2;* t+=y=p [2];/* ## -## */}int main() {for(;( x=getc (stdin ))>0;)w =100;)w=10/dev/null || exit 1 +# we have to move the endoh1_color.alt to endoh1_color.alt3, not alt2, because +# we have to use make clobber which would wipe out endoh1_color.alt2. +mv endoh1_color.alt endoh1_color.alt3 +make clobber CC="$CC" CDEFINE="-DA=10 -DS=39000" alt >/dev/null || exit 1 +read -r -n 1 -p "Press any key run run slower fluid on endoh1_color.alt.c: " +mv endoh1_color.alt3 endoh1_color.alt2 +# clear screen before continuing +clear + + +# now that we have both binaries we can run each one on the data files, first +# the source file. +./endoh1_color.alt < endoh1_color.alt.c 2>/dev/null +./endoh1_color.alt2 < endoh1_color.alt.c 2>/dev/null +clear + +# for each of the supplied text files we will run both 'versions' on them, in +# succession, prompting the user for each text file so they know the name. +for i in clock.txt column.txt column2.txt column3.txt corners.txt \ + dripping-pan.txt evaporation.txt flat.txt fountain.txt funnel.txt \ + funnel2.txt funnel3.txt glass-half-empty.txt leidenfrost.txt logo.txt \ + pour-out.txt tanada.txt; do + + # to make it more 'fluid' :-) we only prompt once per file even though the + # second command is a different file in that the gravity factor is set to I. + read -r -n 1 -p "Press any key to run: ./endoh1_color.alt < $i: " + ./endoh1_color.alt < "$i" 2>/dev/null + clear + ./endoh1_color.alt2 < "$i" 2>/dev/null + clear +done diff --git a/2012/endoh2/README.md b/2012/endoh2/README.md index 5d9c91e0e..cb92caee0 100644 --- a/2012/endoh2/README.md +++ b/2012/endoh2/README.md @@ -27,7 +27,7 @@ gcc -o e e.c ### Try: ```sh -./everything.sh +./try.sh ``` @@ -50,7 +50,7 @@ program and [pi](https://en.wikipedia.org/wiki/Pi) or [e](https://en.wikipedia.org/wiki/E_(mathematical_constant))) computation. I know you're tired of them. -But have you ever seen **all-in-one**? +But have you ever seen them **all-in-one**? ### What it is @@ -72,7 +72,7 @@ rather than pi. ### Obfuscation This program itself is in the shape of a -[spigot](https://en.wikipedia.org/wiki/Tap_(valve)). This is derived from +[spigot](https://en.wikipedia.org/wiki/Tap_(valve)). This is derived as an analogy with [spigot algorithm](https://en.wikipedia.org/wiki/Spigot_algorithm) which infinitely computes the value of a mathematical constant such as [pi](https://en.wikipedia.org/wiki/Pi) or @@ -103,19 +103,24 @@ directives](https://en.wikipedia.org/wiki/C_preprocessor). In my program, These design requirements made my program well-obfuscated willy-nilly. + ### Portability I expect it to work in any major environment and C compiler. To build with no -warning, it requires two C99 features: string literal more than 509 characters -and not requiring a return in `main()` function. In fact, recent compilers with -`-std=c99 -Wall -W -Wextra -pedantic` would say nothing. +warning, it requires two C99 features: allow string literal to be more than 509 +characters and not requiring a return in `main()`. In fact, recent compilers +with `-std=c99 -Wall -W -Wextra -pedantic` would say nothing. - gcc -std=c99 -Wall -W -Wextra -pedantic spigot.c - clang -std=c99 -Wall -W -Wextra -pedantic spigot.c + +```sh +gcc -std=c99 -Wall -W -Wextra -pedantic spigot.c +clang -std=c99 -Wall -W -Wextra -pedantic spigot.c +``` I've tested with gcc-4.6.3 and clang-3.0 on Linux (Ubuntu 12.04) and gcc-4.5.3 and clang-3.1 on Cygwin. + ### Synopsis ```sh diff --git a/2012/endoh2/everything.sh b/2012/endoh2/everything.sh deleted file mode 100755 index 69ba30276..000000000 --- a/2012/endoh2/everything.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash - -make everything || exit 1 - -run() -{ - local program="$1" - echo "" 1>&2 - echo -n "$ ./${program}" 1>&2 - sleep 2 - "./${program}" | less -K -e -} -echo "running everything with $(type -P less): " 1>&2 -echo 1>&2 -run pi -run 314 -run 3141 -run 31415 -run 314159 -run 3141592 -run 31415926 -run 314159265 -run 3141592653 -run 31415926535 -run e 271 -run 2718 -run 27182 -run 271828 -run 2718281 -run 27182818 -run 271828182 -run 2718281828 -run 27182818284 diff --git a/2012/endoh2/try.sh b/2012/endoh2/try.sh new file mode 100755 index 000000000..8d02917ef --- /dev/null +++ b/2012/endoh2/try.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2000/tomx +# + +# 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" everything >/dev/null || exit 1 + +# clear screen after compilation so that only the entry is shown +clear + +run() +{ + local program="$1" + echo "" 1>&2 + read -r -n 1 -p "Press any key to run: ./${program} (space = next page, q = quit): " + "./${program}" | less -K -E -X +} +run pi +run 314 +run 3141 +run 31415 +run 314159 +run 3141592 +run 31415926 +run 314159265 +run 3141592653 +run 31415926535 +run e 271 +run 2718 +run 27182 +run 271828 +run 2718281 +run 27182818 +run 271828182 +run 2718281828 +run 27182818284 diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 5add99b95..b85db13be 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -3345,16 +3345,28 @@ implicitly (Linux doesn't seem to but macOS does). Cody also added two [alt versions](2012/endoh1/README.md#alternate-code) that let one control how fast the fluid moves (how long to sleep in between writes) -and also the gravity factor, the pressure factor and the viscosity factor, one -for the original entry and one for the alternate colour version that was added -by the author, [Yusuke](#yusuke), at the request of the judges. +and also the gravity factor, the pressure factor and the viscosity factor as +well as an alarm that lets one run it in a loop without having to hit +ctrl-c/intr in between (the alarm can be disabled, however). The two different +versions is because there are two versions: the original and the colour version +added by the author, [Yusuke](#yusuke), at the request of the judges. + +Cody also added the [try.alt.sh](2012/endoh1/try.alt.sh) script compiles the alt +code in two ways, one with setting the gravity factor to `I` and another with +the default, and which is run on the source file and each of the text files +supplied by the author. This code has an alarm set at 10 seconds so that one +need not hit ctrl-c/intr in between .. say to make it more fluid :-) + The [endoh1.alt2.c](2012/endoh1/endoh1.alt.c) was provided by Yusuke as a de-obfuscated version. ## [2012/endoh2](2012/endoh2/endoh2.c) ([README.md](2012/endoh2/README.md)) -[Cody](#cody) fixed a typo in the ruby script +[Cody](#cody) added the [try.sh](2012/endoh2/try.sh) script that runs +everything, filtered through less. + +Cody also fixed a typo in the ruby script [find-font-table.rb](2012/endoh2/find-font-table.rb).