From 55ca7f433f12c398a9cb60da58b746ff5effa2fd Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 05:50:43 -0800 Subject: [PATCH 01/26] Improve and add scripts to 2018/ferguson The id.sh and id.alt.sh scripts are (for entry and alt entry that I submitted to the contest) are for those who want to try and prove that '"intelligent" design' is real or for those who know better to see how long it'll take Eric the monkey to type 'EVOLUTION IS A PROVEN FACT'. These were both added by the judges at time of publication but I moved them to the try scripts. Now however the id scripts limit to 250000 max attempts (see below on this change) before giving up to save time (and to maybe let them move on to the next step, see below also). The monkey-words.sh and monkey-words.alt.sh are to see how long it is before the monkey Eric can type 'words' or more likely how long it'll take before he gives up or falls asleep. I am no longer sure if I added this or the judges did but I'm pretty sure I did. As for the max attempts this one might need to be moved to a second alt version for both but if so I don't know what to name them. This reconfiguration option was not originally submitted but to show what will happen when Eric fails it was added. It would normally be put in prog.alt.c but prog.alt.c already exists: a simpler keyboard. But if the new feature was moved to prog.alt.c what would prog.alt.c be? Maybe prog.alt2.c but then what about the simpler keyboard version? This can be discussed because I am not sure I want it in prog.c and I am not sure if it should be either as it was not part of the original entry (though in retrospect it should have been). The try.sh and try.alt.sh scripts now show what happens when Eric fails where previously one would have to wait a very long time (max attempts SIZE_MAX - 1 is what it was set to and still defaults to, being reset to it if it's < 100 which was arbitrarily selected). The Makefile has been improved to simplify redefining the macros that specify how many offspring per generation to have and the max length of the string (this has also been used in the try.sh and try.alt.sh scripts if the user says they want to see the undocumented Easter egg). The test.sh script now uses less(1) so one can look at the output one page at a time. The make test rule now has a '@' to silent the command being executed ('./test.sh'). --- 2018/ferguson/Makefile | 21 ++++- 2018/ferguson/README.md | 130 ++++++++++++++++++++++++------ 2018/ferguson/id.alt.sh | 27 +++++++ 2018/ferguson/id.sh | 24 ++++++ 2018/ferguson/monkey-words.alt.sh | 17 ++++ 2018/ferguson/monkey-words.sh | 17 ++++ 2018/ferguson/prog.alt.c | 5 ++ 2018/ferguson/prog.c | 5 ++ 2018/ferguson/test-strings.txt | 2 +- 2018/ferguson/test.sh | 12 ++- 2018/ferguson/try.alt.sh | 63 +++++++++------ 2018/ferguson/try.sh | 61 ++++++++------ 12 files changed, 304 insertions(+), 80 deletions(-) create mode 100755 2018/ferguson/id.alt.sh create mode 100755 2018/ferguson/id.sh create mode 100755 2018/ferguson/monkey-words.alt.sh create mode 100755 2018/ferguson/monkey-words.sh diff --git a/2018/ferguson/Makefile b/2018/ferguson/Makefile index bd100fedc..694e87d91 100644 --- a/2018/ferguson/Makefile +++ b/2018/ferguson/Makefile @@ -55,9 +55,26 @@ CSTD= -std=gnu17 # ARCH= +# Variables to help simplify configuring the build +# + +# Maximum size of the target string defaults at 38. See README.md for why this +# is. +# +MAX_SIZE= 38 + +# Number of offspring per generation defaults at 25. +# +OFFSPRING= 25 + +# Max attempts defaults at SIZE_MAX - 1 but one can change it to see what +# happens when the maximum is reached. +MAX_ATTEMPTS= SIZE_MAX-1 + # Defines that are needed to compile # -CDEFINE= -DQ='typedef' -D'g(o)'='goto o;' -D'w(x)'="x:" -D'H(main)'='r(main)' +CDEFINE= -DQ='typedef' -D'g(o)'='goto o;' -D'w(x)'="x:" -D'H(main)'='r(main)' -DM=${MAX_ATTEMPTS} \ + -DS=${MAX_SIZE} -DN=${OFFSPRING} # Include files that are needed to compile # @@ -135,7 +152,7 @@ weasel: ${PROG} ${CP} -f $< $@ test: ${PROG} test.sh - ./test.sh + @./test.sh # alternative executable # diff --git a/2018/ferguson/README.md b/2018/ferguson/README.md index f848705e8..aa1f73c44 100644 --- a/2018/ferguson/README.md +++ b/2018/ferguson/README.md @@ -19,8 +19,24 @@ monkey Eric. See [Alternate code](#alternate-code) below. ```sh ./try.sh + +# For those who believe in '"intelligent" design' or want to see how easy it is +# to prove evolution is a proven fact: +./id.sh + +# For those who want to see if Eric the monkey can type the word 'words' before +# falling asleep or giving up: +./monkey-words.sh ``` +NOTE: the [try.sh](try.sh) script will run the other two scripts but if the +first one, [id.sh](id.sh) is terminated early in the try script, the second one, +[monkey-words.sh](monkey-words.sh) will not be run. + +You can reconfigure certain values. These are described by the author in more +detail in the [S, M and N Constants](#constants) section. The script above will +make use of some of these. + ## Alternate code: @@ -45,8 +61,33 @@ Use `weasel.alt` as you would `weasel` above. ```sh ./try.alt.sh + +# For those who believe in '"intelligent" design' or want to see how easy it is +# to prove evolution is a proven fact: +./id.alt.sh + +# For those who want to see if Eric the monkey can type the word 'words' before +# falling asleep or giving up: +./monkey-words.alt.sh ``` +NOTE: the [try.alt.sh](try.alt.sh) script will run the other two scripts but if the +first one, [id.alt.sh](id.alt.sh) is terminated early in the try script, the second one, +[monkey-words.alt.sh](monkey-words.alt.sh) will not be run. + +You can reconfigure certain values. These are described by the author in more +detail in the [S, M and N Constants](#constants) section. The script above will +make use of some of these. + + +```sh +./try.alt.sh +``` + +You can reconfigure certain values. These are described by the author in more +detail in the [S, M and N Constants](#constants) section. The script above will +make use of some of these. + ## Judges' remarks: @@ -131,9 +172,10 @@ don't need this unless there is something specific you're after. **[Obfuscation](#obfuscation):** Some of the techniques that might not be used. **[How to build](#build):** Here I describe briefly -[the constants that can be redefined](#constants) `S` and `N`: the +[the constants that can be redefined](#constants) `S`, `M` and `N`: the maximum size of the chromosome (target string; the maximum length is `S - 1` -but it must be >= the default 38) and the number of offspring, respectively. I +but it must be >= the default 38), the number of maximum attempts before giving +up and the number of offspring, respectively. I also give [example compiler invocations](#compiling), [portability notes](#portability), an [more portability notes](#bugs) and a [note on rpm.md](#rpm). @@ -865,21 +907,24 @@ be made clear in the comments! :)* ## **5. How to build** -### S and N Constants +### S, M and N Constants Skip to [Compilation](#compiling). -These two `#define`d constants can be redefined at compilation to modify the +There are three `#define`d constants that can be redefined at compilation to modify the behaviour of the program in a number of ways (see the **[Compilation](#compiling)** subsection for example invocations). Both are -capped to be no greater than `SIZE_MAX - 1`. This is handled by the C -preprocessor. +capped to be no greater than `SIZE_MAX - 1` or whatever `M` (which can't be +lower than 100) is set to (maximum attempts before giving up). This is handled +by the C preprocessor. -`S` -This determines the maximum size of the target string but it **must be at least -38**; this is because `38 >= 29` and because `strlen("METHINKS IT IS LIKE -A WEASEL") == 28` (which is the default target string - it would hardly be an +* `S` + +The macro `S` (or `MAX_SIZE` in the Makefile) is the maximum size of the target +string but it **must be at least 38** (which is protected against in the code); +this is because `38 >= 29` and because `strlen("METHINKS IT IS LIKE A WEASEL") +== 28` (which is the default target string - it would hardly be an implementation of the Weasel program otherwise). There is obviously a reason `38` is the chosen size but the only hints I @@ -888,14 +933,43 @@ referenced there (it's *not the only Easter egg* but it's the only Easter egg I won't spoil; yes this ironically and amusingly means I've left a rotten egg somewhere!). -`N` +The Makefile simplifies how to reconfigure this value with the variable +`MAX_SIZE`: -This is the number of offspring per generation. Anything less than 4 will be set -to 3 (that's not a typo!) and this is part of an Easter egg. +```sh +make clobber MAX_SIZE=55 all +``` + +The next macro that can be reconfigured, `M` (or `MAX_ATTEMPTS` in the +Makefile), is the maximum attempts before giving up. This was added as another +feature in 2024 but it was not made an alt version because there already is an +alt version. This macro allows for seeing what happens when reaching the maximum +number attempts without waiting for a very long time. + +The Makefile simplifies how to reconfigure this value with the variable +`MAX_ATTEMPTS`: + +```sh +make clobber MAX_ATTEMPTS=100 all +``` + +The final macro, `N` (or `OFFSPRING` in the Makefile), is the number of offspring +per generation. + +Anything less than 4 will be set to 3 (that's not a typo!) and this is part of +an Easter egg. + +Be aware that depending on the size of `S` (`MAX_SIZE`) and `N` (`OFFSPRING`) +both individually and together the program will use varying amounts of memory +and the larger the values the more memory it'll require. + +The Makefile simplifies how to reconfigure this value with the variable +`OFFSPRING`: + +```sh +make clobber OFFSPRING=55 all +``` -Be aware that depending on the size of `S` and `N` (individually and -together) the program will use varying amounts of memory and the larger the -values the more memory it'll require. ### Compilation @@ -907,23 +981,33 @@ The following options **must always be passed to the compiler:** -DQ='typedef' -D'g(o)'='goto o;' -D'w(x)'="x:" -D'H(main)'='r(main)' ``` -If you want to increase the number of offspring to `50` and the size of the -chromosome to `75` you would pass to the compiler: +which running `make` will always do. + + +If you want to increase the number of offspring to `50` (`N`) and the size of the +chromosome to `75` (`S`) you would do: ```sh --DQ='typedef' -D'g(o)'='goto o;' -D'w(x)'="x:" -D'H(main)'='r(main)' -DN=50 -DS=75 +make clobber OFFSPRING=50 MAX_SIZE=75 everything ``` If you wanted to change `N` to `3`: ```sh --DQ='typedef' -D'g(o)'='goto o;' -D'w(x)'="x:" -D'H(main)'='r(main)' -DN=3 +make clobber OFFSPRING=3 everything ``` Remember that it cannot be less than `3`; *more correctly if it's less than -4 it's redefined to 3* so you could have passed in `-DN=2` and have the same -result. Remember too that `S` cannot be less than `38`. Both `S` and -`N` are capped at `SIZE_MAX - 1`. +4 it's redefined to 3* so you could have passed in `-DN=2` (or `MAX_SIZE=2`) and have the same +result. Remember too that `S` (`MAX_SIZE`) cannot be less than `38`. Both `S` and +`N` are capped at `SIZE_MAX - 1` or whatever `M` (`MAX_ATTEMPTS`) is set to. + +If you wanted to change the maximum number attempts to 100 you could do: + +```sh +make clobber MAX_ATTEMPTS=100 everything +``` + ### Portability diff --git a/2018/ferguson/id.alt.sh b/2018/ferguson/id.alt.sh new file mode 100755 index 000000000..b4d4e25c2 --- /dev/null +++ b/2018/ferguson/id.alt.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# +# id.alt.sh - determine exactly how real '"intelligent" design' is with alt code +# + +# limit to 250000 attempts to save them time if they really wish to try and +# prove that '"intelligent" design' is real (or more correctly so that they +# might last long enough in the try scripts to move on to the next step) +make -B MAX_ATTEMPTS=250000 everything >/dev/null || exit 1 + +read -r -p "Do you wish to try and prove '\"intelligent\" design' (Y/N)? " +if [[ "$REPLY" = "Y" || "$REPLY" = "y" ]]; then + echo "$ ./weasel.alt -m 'INTELLIGENT DESIGN'" 1>&2 + echo "Limiting to 250000 attempts to save you time." 1>&2 + echo 1>&2 + echo "Press any key to continue. Send ctrl-c when convinced that intelligent" 1>&2 + read -r -n 1 -p "design is not real or you're tired of waiting: " + echo 1>&2 + ./weasel.alt -m 'INTELLIGENT DESIGN' + echo 1>&2 + exit 1 +else + read -r -n 1 -p "Press any key to run: time ./weasel.alt -r8 'EVOLUTION IS A PROVEN FACT': " + echo 1>&2 + time ./weasel.alt -r8 'EVOLUTION IS A PROVEN FACT' + exit 0 +fi diff --git a/2018/ferguson/id.sh b/2018/ferguson/id.sh new file mode 100755 index 000000000..f0eb90e3e --- /dev/null +++ b/2018/ferguson/id.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# +# id.sh - determine exactly how real '"intelligent" design' is +# + +# limit to 250000 attempts to save them time if they really wish to try and +# prove that '"intelligent" design' is real (or more correctly so that they +# might last long enough in the try scripts to move on to the next step) +make -B MAX_ATTEMPTS=250000 everything >/dev/null || exit 1 + +read -r -p "Do you wish to try and prove '\"intelligent\" design' (Y/N)? " +if [[ "$REPLY" = "Y" || "$REPLY" = "y" ]]; then + echo "$ ./weasel -m 'INTELLIGENT DESIGN'" 1>&2 + echo "Limiting to 250000 attempts to save you time." 1>&2 + echo "Press any key to continue. Send ctrl-c when convinced that intelligent" 1>&2 + read -r -n 1 -p "design is not real or you're tired of waiting: " + ./weasel -m 'INTELLIGENT DESIGN' + echo 1>&2 + exit 1 +else + echo "$ ./weasel -r8 'EVOLUTION IS A PROVEN FACT'" 1>&2 + time ./weasel -r8 'EVOLUTION IS A PROVEN FACT' + exit 0 +fi diff --git a/2018/ferguson/monkey-words.alt.sh b/2018/ferguson/monkey-words.alt.sh new file mode 100755 index 000000000..53bc3222e --- /dev/null +++ b/2018/ferguson/monkey-words.alt.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# +# monkey-words.sh - try and get Eric the monkey to type 'words'. +# +echo 1>&2 +make -B MAX_ATTEMPTS=SIZE_MAX-1 >/dev/null || exit 1 +echo 1>&2 +read -r -n 1 -p "Do you want to see how long it might take the monkey Eric to type 'words'? (Y/N)? " +if [[ "$REPLY" == "Y" || "$REPLY" == "y" ]]; then + echo 1>&2 + echo "Will let Eric try until he succeeds, gives up or he falls asleep." 1>&2 + echo "Hit ctrl-c/intr to let him nap early." 1>&2 + echo 1>&2 + read -r -n 1 -p "Press any key to continue: " + echo 1>&2 + time ./weasel -m words +fi diff --git a/2018/ferguson/monkey-words.sh b/2018/ferguson/monkey-words.sh new file mode 100755 index 000000000..53bc3222e --- /dev/null +++ b/2018/ferguson/monkey-words.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# +# monkey-words.sh - try and get Eric the monkey to type 'words'. +# +echo 1>&2 +make -B MAX_ATTEMPTS=SIZE_MAX-1 >/dev/null || exit 1 +echo 1>&2 +read -r -n 1 -p "Do you want to see how long it might take the monkey Eric to type 'words'? (Y/N)? " +if [[ "$REPLY" == "Y" || "$REPLY" == "y" ]]; then + echo 1>&2 + echo "Will let Eric try until he succeeds, gives up or he falls asleep." 1>&2 + echo "Hit ctrl-c/intr to let him nap early." 1>&2 + echo 1>&2 + read -r -n 1 -p "Press any key to continue: " + echo 1>&2 + time ./weasel -m words +fi diff --git a/2018/ferguson/prog.alt.c b/2018/ferguson/prog.alt.c index 6c80797e3..8f99f09ae 100644 --- a/2018/ferguson/prog.alt.c +++ b/2018/ferguson/prog.alt.c @@ -7,7 +7,12 @@ Q unsigned d; Q char E; Q int k; Q long u; Q size_t t; Q const char U; #define L toupper + #ifndef M #define M SIZE_MAX-1 + #elif M < 100 + #undef M + #define M SIZE_MAX-1 + #endif #ifndef S #define S 38 #elif S < 38 diff --git a/2018/ferguson/prog.c b/2018/ferguson/prog.c index 18de651dd..5e64cf10b 100644 --- a/2018/ferguson/prog.c +++ b/2018/ferguson/prog.c @@ -7,7 +7,12 @@ Q unsigned d; Q char E; Q int k; Q long u; Q size_t t; Q const char U; #define L toupper + #ifndef M #define M SIZE_MAX-1 + #elif M < 100 + #undef M + #define M SIZE_MAX-1 + #endif #ifndef S #define S 38 #elif S < 38 diff --git a/2018/ferguson/test-strings.txt b/2018/ferguson/test-strings.txt index 6a1c48a5f..181132d3f 100644 --- a/2018/ferguson/test-strings.txt +++ b/2018/ferguson/test-strings.txt @@ -13,5 +13,5 @@ STOP MONKEYING ABOUT! WHAT DO YOU MEAN I'M A MONKEY?! PROBLEM BETWEEN KEYBOARD AND CHAIR MY PRECIOUS. YES, MY PRECIOUS. -MY PRECIOUS! O MY PRECIOUS! +MY PRECIOUS! O MY PRECIOUS! PRECIOUS IOCCC BEST USE OF WEASEL WORDS diff --git a/2018/ferguson/test.sh b/2018/ferguson/test.sh index 77c62b13f..431332cbe 100755 --- a/2018/ferguson/test.sh +++ b/2018/ferguson/test.sh @@ -1,11 +1,17 @@ #!/usr/bin/env bash +# +# test.sh - make test script for IOCCC winner 2018/ferguson # Make sure the program has been compiled make everything 1> /dev/null|| exit 1 +read -r -n 1 -p "Press any key to run tests (space = next page, G = end, q = quit): " +echo 1>&2 + while read -r f; do - ./weasel "$@" "${f}" # full line because of quotes - # NOTE: ./weasel $* $f would just be the final word - sleep 2 + # NOTE: ./weasel $* $f would just be the final word. We quote it for the + # full line: + ./weasel "$@" "${f}" | less -rEXFK done < test-strings.txt || exit 1 + echo "All done. Goodbye, you old monkeying weasel!" diff --git a/2018/ferguson/try.alt.sh b/2018/ferguson/try.alt.sh index 83713b706..54dcfa152 100755 --- a/2018/ferguson/try.alt.sh +++ b/2018/ferguson/try.alt.sh @@ -10,43 +10,54 @@ if [[ -z "$CC" ]]; then CC="cc" fi -make CC="$CC" alt >/dev/null || exit 1 +make CC="$CC" everything >/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: ./weasel.alt words (space = next page, q = quit): " +read -r -n 1 -p "Press any key to run: ./weasel.alt words (space = next page, q = quit, G = end): " echo 1>&2 -time ./weasel.alt words | less -EXF +time ./weasel.alt words | less -rEXFK read -r -n 1 -p "Press any key to see how long it'll take Eric the monkey to type his name: " echo 1>&2 time ./weasel.alt -mq Eric echo 1>&2 -read -r -n 1 -p "Press any key to run: make test: " +read -r -p "Do you want to run make test (Y/N)? " +if [[ "$REPLY" = "Y" || "$REPLY" = "y" ]]; then + make test +fi + +read -r -p "Do you wish to see the undocumented Easter egg (Y/N)? " +if [[ "$REPLY" = "Y" || "$REPLY" = "y" ]]; then + make -B OFFSPRING=97 everything 1>/dev/null || exit 1 + read -r -n 1 -p "Press any key to show Easter egg (./weasel.alt): " + echo 1>&2 + ./weasel.alt + echo 1>&2 +fi + echo 1>&2 -make test +read -r -n 1 -p "Press any key to change max attempts to 100: " +echo 1>&2 +echo "$ make -B MAX_ATTEMPTS=100 everything >/dev/null || exit 1" 1>&2 +echo 1>&2 +make -B MAX_ATTEMPTS=100 everything >/dev/null || exit 1 +read -r -n 1 -p "Press any key to see what happens when the maximum attempts are reached: " +echo 1>&2 +./weasel.alt -m 'Eric the Monkey' -read -r -p "Do you wish to try and prove 'intelligent design' (Y/N)? " -if [[ "$REPLY" == "Y" || "$REPLY" == "y" ]]; then - echo "$ ./weasel.alt -m 'INTELLIGENT DESIGN'" 1>&2 - echo "Press any key to continue. Send ctrl-c when convinced that intelligent" 1>&2 - read -r -n 1 -p "design is not real or you're tired of waiting: " - echo 1>&2 - time ./weasel.alt -m 'INTELLIGENT DESIGN' - echo 1>&2 -else - echo "$ ./weasel.alt -q -r8 'EVOLUTION IS A PROVEN FACT'" 1>&2 - time ./weasel.alt -q -r8 'EVOLUTION IS A PROVEN FACT' -fi +# recompile with default max attempts for the next steps +make -B everything >/dev/null || exit 1 -read -r -n 1 -p "Do you want to see how long it might take the monkey Eric to type 'words'? (Y/N)? " -if [[ "$REPLY" == "Y" || "$REPLY" == "y" ]]; then - echo 1>&2 - echo "Will not display until Eric succeeds or too many generations. Hit ctrl-c" 1>&2 - echo "to stop him early." 1>&2 - read -r -n 1 -p "Press any key to continue: " - echo 1>&2 - time ./weasel.alt -mq words -fi +# obviously '"intelligent" design' is false but who wants to try and prove +# otherwise? Or if they know better how long will it take to show that evolution +# is a proven fact? +./id.alt.sh + +# If the user did not try and prove '"intelligent" design' or they waited a +# long time (though saving them some time by limiting it to 900000 attempts) I +# ask: can Eric the monkey type the word 'words' before falling asleep or +# getting too hungry to continue? +./monkey-words.alt.sh diff --git a/2018/ferguson/try.sh b/2018/ferguson/try.sh index 9552e1e21..831b9fb8c 100755 --- a/2018/ferguson/try.sh +++ b/2018/ferguson/try.sh @@ -15,38 +15,49 @@ 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: ./weasel words (space = next page, q = quit): " +read -r -n 1 -p "Press any key to run: ./weasel words (space = next page, q = quit, G = end): " echo 1>&2 -time ./weasel words | less -EXF +time ./weasel words | less -rEXFK read -r -n 1 -p "Press any key to see how long it'll take Eric the monkey to type his name: " echo 1>&2 time ./weasel -mq Eric echo 1>&2 -read -r -n 1 -p "Press any key to run: make test: " +read -r -p "Do you want to run make test (Y/N)? " +if [[ "$REPLY" = "Y" || "$REPLY" = "y" ]]; then + make test +fi + +read -r -p "Do you wish to see the undocumented Easter egg (Y/N)? " +if [[ "$REPLY" = "Y" || "$REPLY" = "y" ]]; then + make -B OFFSPRING=97 everything 1>/dev/null || exit 1 + read -r -n 1 -p "Press any key to show Easter egg (./weasel): " + echo 1>&2 + ./weasel + echo 1>&2 +fi + echo 1>&2 -make test +read -r -n 1 -p "Press any key to change max attempts to 100: " +echo 1>&2 +echo "$ make -B MAX_ATTEMPTS=100 everything >/dev/null || exit 1" 1>&2 +echo 1>&2 +make -B MAX_ATTEMPTS=100 everything >/dev/null || exit 1 +read -r -n 1 -p "Press any key to see what happens when the maximum attempts are reached: " +echo 1>&2 +./weasel -m 'Eric the Monkey' -read -r -p "Do you wish to try and prove 'intelligent design' (Y/N)? " -if [[ "$REPLY" == "Y" || "$REPLY" == "y" ]]; then - echo "$ ./weasel -m 'INTELLIGENT DESIGN'" 1>&2 - echo "Press any key to continue. Send ctrl-c when convinced that intelligent" 1>&2 - read -r -n 1 -p "design is not real or you're tired of waiting: " - echo 1>&2 - time ./weasel -m 'INTELLIGENT DESIGN' - echo 1>&2 -else - echo "$ ./weasel -q -r8 'EVOLUTION IS A PROVEN FACT'" 1>&2 - time ./weasel -q -r8 'EVOLUTION IS A PROVEN FACT' -fi +# recompile with default max attempts for the next steps +make -B everything >/dev/null || exit 1 -read -r -n 1 -p "Do you want to see how long it might take the monkey Eric to type 'words'? (Y/N)? " -if [[ "$REPLY" == "Y" || "$REPLY" == "y" ]]; then - echo 1>&2 - echo "Will not display until Eric succeeds or too many generations. Hit ctrl-c" 1>&2 - echo "to stop him early." 1>&2 - read -r -n 1 -p "Press any key to continue: " - echo 1>&2 - time ./weasel -mq words -fi +# obviously '"intelligent" design' is false but who wants to try and prove +# otherwise? Or if they know better how long will it take to show that evolution +# is a proven fact? +./id.sh + +# If the user did not try and prove '"intelligent" design' or they waited a +# long time (though saving them some time by limiting it to 900000 attempts) I +# ask: can Eric the monkey type the word 'words' before falling asleep or +# getting too hungry to continue? +./monkey-words.sh From c30387cce54faa1a5c8db3911e797832ebb10757 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 06:02:39 -0800 Subject: [PATCH 02/26] Update todo file Removed an item that I already finished. Merge two items that were related. Added an item (does that mean I didn't remove an item?) for 2018/ferguson that has to be done after the other tasks are done and on specific systems (was done for personal reasons at submission but since the judges referred to it in their remarks I have kept it and will continue to keep it). --- tmp/things-todo.md | 48 ++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/tmp/things-todo.md b/tmp/things-todo.md index 011fcbeb9..9cbf0bc2c 100644 --- a/tmp/things-todo.md +++ b/tmp/things-todo.md @@ -1,30 +1,28 @@ # A todo list of known things to check and/or do -*Last updated: Thu 11 Jan 2024 16:42:28 UTC* +*Last updated: Wed 31 Jan 2024 12:22:09 UTC* -This document is primarily for [Cody Boone -Ferguson](/winners.html#Cody_Boone_Ferguson) as he (that is I :-) ) wanted a way -to keep track of things in a way that did not require the information getting -lost in the thousands of changes in the repo and because it might be too much to -add to the todo list in the issues themselves. +This document is for [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) as +he (that is I :-) ) wanted a way to keep track of things in a way that did not +require the information getting lost in the thousands of changes in the repo and +because it might be too much to add to the todo list in the issues themselves. More things will likely be added over time and as items are done they _should be_ removed from the list IF AND ONLY IF (!!) we are _absolutely certain_ it is done (many times it's thought that a task was done only to find out it wasn't). -It is hoped that this will be referenced and updated as this is an easy way to -keep track of things that have been done already and what hasn't been done (in -this file the case is mostly _NOT_ been done). + +Every so often this file is checked and updated to remove items and when +something needs to be done is thought of it is also updated unless it can be +done right then and there or it seems more appropriate to add to the issue (#3) +todo list. - Typo fix ALL markdown files. For the README.md files the entries have all been done (along with format fixes) but the YYYY/README.md files have not been -completed. See below item for details on that (several items in this file refer -to those). - -- Go through all year README.md files: that is 1984/README.md, 1985/README.md and -so on. As of **Mon 16 Oct 11:22:52 UTC 2023** the following years have had a -first pass: 1984 through 2001. However there are changes that are required -namely to do with email addresses that no longer exist. At this point it is not -determined if this will be done with the typo pass (what should be the final -pass) or not but it's very possible that it can be just to speed things along. +completed. + * Go through all year README.md files: that is 1984/README.md, + 1985/README.md and so on. As of **Mon 16 Oct 11:22:52 UTC 2023** the + following years have had a first pass: 1984 through 2001. However there are + changes that might be required in those years too so a pass over all of them + will have to be done at the time the files are to be reviewed. - Check the [GitHub issue #3 comment 1615962832](https://github.com/ioccc-src/temp-test-ioccc/issues/3#issuecomment-1615962832) @@ -38,13 +36,13 @@ embedded into the README.md files themselves. An entry that the video file is downloaded already is 2006/sykes1. There are others that I need to look at once the rest of the entries are done, assuming that it's possible. -- Although I will have to do this when another issue is opened up I am aware of -some issues in 2020/ferguson1/.winner.json. I do not want to forget this, -however, so I am noting it here. A reference to a file in 2020/ferguson2 is in -1992/buzzard.2. This type of thing will have to be checked for all entries in -the new issue. - - Verify that all entries that should have (or could be benefited by) a try script do in fact have one. Also verify (mostly in earlier years) consistency in the way it is displayed and interactivity. The later years are probably done -better. +better. As of *Wed 31 Jan 2024 12:22:09 UTC* almost all of this is done: just +some of 2018 and then all of 2019 and 2020 have to be checked. It is very likely +that before the day is over 2018 will be done and possibly part of 2019 will be +done but this is currently unknown. The shellcheck updates is another issue +entirely. + +- Test and fix as and if necessary 2018/ferguson/weasel.spec. From f6188dd4d87e2cead339f73403dbe694fd656476 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 06:13:21 -0800 Subject: [PATCH 03/26] Improve 2018/yang/try.sh + fix make clobber The script now compiles generated1.c and runs it. This might actually be one of the others (some of the generated*.c files have the same effect) but it's perhaps interesting to show nonetheless. This is only done if the spoilers option is selected. Update .gitignore with better globs. Fixed make clobber to remove generated* rather than generated*.c. --- 2018/yang/.gitignore | 8 ++------ 2018/yang/Makefile | 2 +- 2018/yang/try.sh | 5 +++++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/2018/yang/.gitignore b/2018/yang/.gitignore index c6778fac1..036a96ef2 100644 --- a/2018/yang/.gitignore +++ b/2018/yang/.gitignore @@ -1,16 +1,12 @@ # # sort with: sort -d -u *.dSYM -generated1.c -generated2.c -generated3.c -generated4.c -generated5.c +generated* indent indent.c indent.o left -msg[0-9] +msg* no_leading_space.txt prog prog.orig diff --git a/2018/yang/Makefile b/2018/yang/Makefile index 69358ef13..796b3104a 100644 --- a/2018/yang/Makefile +++ b/2018/yang/Makefile @@ -324,7 +324,7 @@ clean: clobber: clean ${RM} -f ${TARGET} ${ALT_TARGET} ${RM} -rf *.dSYM - ${RM} -f generated*.c msg* + ${RM} -f generated* msg* @-if [ -e sandwich ]; then \ ${RM} -f sandwich; \ echo 'ate sandwich'; \ diff --git a/2018/yang/try.sh b/2018/yang/try.sh index e0af83658..0c506a83f 100755 --- a/2018/yang/try.sh +++ b/2018/yang/try.sh @@ -80,4 +80,9 @@ if [[ "$REPLY" == "Y" || "$REPLY" == "y" ]]; then read -r -n 1 -p "Press any key to run: ./msg9 < prog.c: " echo 1>&2 ./msg9 < prog.c + + make generated1 1>/dev/null || exit 1 + read -r -n 1 -p "Press any key to run: echo IOCCC | ./generated1: " + echo 1>&2 + echo IOCCC | ./generated1 fi From a85ebbcfc6f658df335fcac0214365211d056113 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 06:21:09 -0800 Subject: [PATCH 04/26] Improve 2018/burton1/try.sh --- 2018/burton1/try.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/2018/burton1/try.sh b/2018/burton1/try.sh index 6deb1b5cb..a016dc50e 100755 --- a/2018/burton1/try.sh +++ b/2018/burton1/try.sh @@ -13,27 +13,27 @@ fi make CC="$CC" everything >/dev/null || exit 1 for i in prog scripthd.sh; do - echo "$ ./$i < prog.c" 1>&2 + read -r -n 1 -p "Press any key to run: ./$i < prog.c: " + echo 1>&2 ./"$i" < prog.c echo 1>&2 read -r -n 1 -p "Press any key to run: ./$i < prog (space = next page, q = quit): " echo 1>&2 - ./"$i" < prog | less -EXF + ./"$i" < prog | less -rEXFK echo 1>&2 read -r -n 1 -p "Press any key to run: ./$i < scripthd.sh (space = next page, q = quit): " echo 1>&2 - ./"$i" < scripthd.sh | less -EXF + ./"$i" < scripthd.sh | less -rEXFK echo 1>&2 - read -r -n 1 -p "Press any key to run: head $0 | ./$i: " echo 1>&2 head "$0" | ./"$i" echo 1>&2 - read -r -n 1 -p "Press any key to run: tail -n 15 Makefile | ./$i: " + read -r -n 1 -p "Press any key to run: tail -n 15 Makefile | ./$i (space = next page, q = quit): " echo 1>&2 - tail -n 15 Makefile | ./"$i" + tail -n 15 Makefile | ./"$i" | less -rEXFK done From a1cac7d803e3371082b085c9ffb17d2e8fde3551 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 06:23:12 -0800 Subject: [PATCH 05/26] Improve 2018/burton2/try.sh --- 2018/burton2/try.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/2018/burton2/try.sh b/2018/burton2/try.sh index f69d7001b..9b2f7cea6 100755 --- a/2018/burton2/try.sh +++ b/2018/burton2/try.sh @@ -16,15 +16,21 @@ make CC="$CC" all >/dev/null || exit 1 clear -echo "$ ./prog -i < prog.c" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog -i < prog.c: " +echo 1>&2 ./prog -i < prog.c +echo 1>&2 -echo "$ ./prog -s < prog.c" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog -s < prog.c: " +echo 1>&2 ./prog -s < prog.c +echo 1>&2 -echo "$ ./prog -sk < prog.c" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog -sk < prog.c: " +echo 1>&2 ./prog -sk < prog.c +echo 1>&2 read -r -n 1 -p "Press any key to run: make test (space = next page, q = quit): " echo 1>&2 -make test | less -EXF +make test | less -rEXFK From 89b7d13c73f4589c3d901bced1b5bc7e96db8140 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 06:24:38 -0800 Subject: [PATCH 06/26] Improve 2018/endoh1/try.sh --- 2018/endoh1/try.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/2018/endoh1/try.sh b/2018/endoh1/try.sh index 6e6a8839f..ad654fbf8 100755 --- a/2018/endoh1/try.sh +++ b/2018/endoh1/try.sh @@ -17,27 +17,27 @@ clear read -r -n 1 -p "Press any key to show prog.c (space = next page, q = quit): " echo 1>&2 -less -EXF prog.c +less -rEXFK prog.c echo "$ ./prog < prog.c > prog.gif" 1>&2 ./prog < prog.c > prog.gif echo 1>&2 read -r -n 1 -p "Press any key to show golem.txt (space = next page, q = quit): " echo 1>&2 -less -EXF golem.txt +less -rEXFK golem.txt echo "$ ./prog < golem.txt > golem.gif" 1>&2 ./prog < golem.txt > golem.gif echo 1>&2 read -r -n 1 -p "Press any key to show smily.txt (space = next page, q = quit): " echo 1>&2 -less -EXF smily.txt +less -rEXFK smily.txt echo "$ ./prog < smily.txt > smily.gif" 1>&2 ./prog < smily.txt > smily.gif echo 1>&2 read -r -n 1 -p "Press any key to show invisible.txt (space = next page, q = quit): " -less -EXF invisible.txt +less -rEXFK invisible.txt echo "$ ./prog < invisible.txt > invisible.gif" 1>&2 ./prog < invisible.txt > invisible.gif echo 1>&2 From 5259fc9b6944fd316bc92e94ab36e89f94f92b5e Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 06:25:28 -0800 Subject: [PATCH 07/26] Improve wording in 2018/endoh2/try.sh --- 2018/endoh2/try.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/2018/endoh2/try.sh b/2018/endoh2/try.sh index cd96419d5..e411196dd 100755 --- a/2018/endoh2/try.sh +++ b/2018/endoh2/try.sh @@ -15,12 +15,12 @@ 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 continue (ctrl-c/intr = skip to next early, runs 20 seconds): " +read -r -n 1 -p "Press any key to continue (ctrl-c/intr = skip to next step early, runs 20 seconds): " echo 1>&2 ./run.sh echo 1>&2 -read -r -n 1 -p "Press any key to run a few times (ctrl-c/intr exits script): " +read -r -n 1 -p "Press any key to run a few times: " echo 1>&2 ./prog | tee prog_next.c make prog_next @@ -28,12 +28,12 @@ make prog_next make prog_next ./prog_next | tee prog_next.c -read -r -n 1 -p "Press any key to sleep 1 sec between runs (intr/ctrl-c to exit): " +read -r -n 1 -p "Press any key to sleep 1 sec between runs (intr/ctrl-c to stop): " echo 1>&2 ./python.sh echo 1>&2 -read -r -n 1 -p "Press any key run without sleeping (intr/ctrl-c to exit): " +read -r -n 1 -p "Press any key run without sleeping (intr/ctrl-c to stop): " echo 1>&2 ./python3.sh From 35ca2f8d1f454adf433b79c370c569ad87b3c81c Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 07:01:45 -0800 Subject: [PATCH 08/26] Add 2018/anderson/try.alt.sh + improve try.sh --- 2018/anderson/try.alt.sh | 35 +++++++++++++++++++++++++++++++++++ 2018/anderson/try.sh | 4 ++-- thanks-for-help.md | 3 ++- 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100755 2018/anderson/try.alt.sh diff --git a/2018/anderson/try.alt.sh b/2018/anderson/try.alt.sh new file mode 100755 index 000000000..fe8ffc32b --- /dev/null +++ b/2018/anderson/try.alt.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2018/anderson 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: ./prog.alt < prog.alt.c: " +echo 1>&2 +./prog.alt < prog.alt.c +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./prog.alt < prog.c: " +echo 1>&2 +./prog.alt < prog.c +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./prog.alt < README.md (space = next page, q = quit): " +echo 1>&2 +./prog.alt < README.md | less -rEXFK +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./prog.alt < Makefile (space = next page, q = quit): " +echo 1>&2 +./prog.alt < Makefile | less -rEXFK diff --git a/2018/anderson/try.sh b/2018/anderson/try.sh index 18cdfae8a..37d9f7446 100755 --- a/2018/anderson/try.sh +++ b/2018/anderson/try.sh @@ -27,9 +27,9 @@ echo 1>&2 read -r -n 1 -p "Press any key to run: ./prog < README.md (space = next page, q = quit): " echo 1>&2 -./prog < README.md | less -EXF +./prog < README.md | less -rEXFK echo 1>&2 read -r -n 1 -p "Press any key to run: ./prog < Makefile (space = next page, q = quit): " echo 1>&2 -./prog < Makefile | less -EXF +./prog < Makefile | less -rEXFK diff --git a/thanks-for-help.md b/thanks-for-help.md index 73ff69c70..bc529d2b0 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -4352,7 +4352,8 @@ He also added the [try.sh](/2015/yang/try.sh) script. ## [2018/anderson](/2018/anderson/prog.c) ([README.md](/2018/anderson/README.md)) -[Cody](#cody) added the [try.sh](/2018/anderson/try.sh) script. +[Cody](#cody) added the [try.sh](/2018/anderson/try.sh) and +[try.alt.sh](/2018/anderson/try.alt.sh) scripts. ## [2018/algmyr](/2018/algmyr/prog.c) ([README.md](/2018/algmyr/README.md)) From 485b24beab5d44f4b73033707ed550d2647319fc Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 08:52:06 -0800 Subject: [PATCH 09/26] Add 2018/bellard/try.sh --- 2018/bellard/README.md | 20 +++++++++-------- 2018/bellard/try.sh | 50 ++++++++++++++++++++++++++++++++++++++++++ thanks-for-help.md | 12 +++++----- 3 files changed, 68 insertions(+), 14 deletions(-) create mode 100755 2018/bellard/try.sh diff --git a/2018/bellard/README.md b/2018/bellard/README.md index 2aa24d3c9..cf6dccd09 100644 --- a/2018/bellard/README.md +++ b/2018/bellard/README.md @@ -17,18 +17,20 @@ code](#alternate-code) below. ## Try: -```sh -eog lena.ppm # On Linux -open -a Preview lena.ppm # On macOS +First open [Lenna.png](Lenna.png) in your graphics viewer of choice. Next, after +running the above command (`./prog > lena.ppm`), open `lena.ppm` in your +graphics viewer of choice. After that try: -pngtopam < Lenna.png | pnmscale 0.25 | cjpeg -arithmetic -dct float -quality 14 > small.jpg +```sh +./try.sh ``` -NOTE: `pngtopam(1)` (or `pngtopnm(1)` for older versions) and `pnmscale` come from -the netpbm project and `cjpeg(1)` comes from `libjpeg-turbo`. If you don't have -these tools already see [FAQ 3.15 - How do I compile and install netpbm for -entries that require it?](/faq.md#netpbm) and [FAQ 3.16 - How do I compile and -install libjpeg-turbo for entries that require it?](/faq.md#libjpeg). +NOTE: the script uses the tools `pngtopam(1)` (or `pngtopnm(1)` for older +versions) and `pnmscale` come from the netpbm project and `cjpeg(1)` comes from +`libjpeg-turbo`. If you don't have these tools already see [FAQ 3.15 - How do I +compile and install netpbm for entries that require it?](/faq.md#netpbm) and +[FAQ 3.16 - How do I compile and install libjpeg-turbo for entries that require +it?](/faq.md#libjpeg). NOTE: [Lenna.png](Lenna.png) is from . diff --git a/2018/bellard/try.sh b/2018/bellard/try.sh new file mode 100755 index 000000000..1cf92002f --- /dev/null +++ b/2018/bellard/try.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2018/bellard +# + +# 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. +[[ -z "$CC" ]] && CC="cc" + +make CC="$CC" all >/dev/null || exit 1 + +# clear screen after compilation so that only the entry is shown +clear + +# find out if we have necessary tools +PNGTOPAM="$(type -P pngtopam)" +PNMSCALE="$(type -P pnmscale)" +PNGTOPNM="$(type -P pngtopnm)" +CJPEG="$(type -P cjpeg)" + +rm -f small.jpg + +if [[ -n "$PNGTOPAM" && -n "$PNMSCALE" && -n "$CJPEG" ]]; then + echo "$ $PNGTOPAM < Lenna.png | $PNMSCALE 0.25 | $CJPEG -arithmetic -dct float -quality 14 > small.jpg" 1>&2 + read -r -n 1 -p "Press any key to continue: " + echo 1>&2 + "$PNGTOPAM" < Lenna.png | "$PNMSCALE" 0.25 | "$CJPEG" -arithmetic -dct float -quality 14 > small.jpg + if [[ -f small.jpg ]]; then + echo "Now open small.jpg in your graphics viewer of choice." 1>&2 + fi +elif [[ -n "$PNGTOPNM" && -n "$PNMSCALE" && -n "$CJPEG" ]]; then + echo "$ $PNGTOPNM < Lenna.png | $PNMSCALE 0.25 | $CJPEG -arithmetic -dct float -quality 14 > small.jpg" 1>&2 + read -r -n 1 -p "Press any key to continue: " + echo 1>&2 + "$PNGTOPNM" < Lenna.png | "$PNMSCALE" 0.25 | "$CJPEG" -arithmetic -dct float -quality 14 > small.jpg + if [[ -f small.jpg ]]; then + echo "Now open small.jpg in your graphics viewer of choice." 1>&2 + fi +else + if [[ -z "$PNGTOPAM" || -z "$PNGTOPNM" || "$PNMSCALE" ]]; then + echo "Cannot find pngtopam(1) or pnmscale(1). Try installing netpbm first." 1>&2 + echo "See https://github.com/ioccc-src/temp-test-ioccc/blob/master/faq.md#netpbm" 1>&2 + echo 1>&2 + fi + if [[ -z "$CJPEG" ]]; then + echo "Cannot find cjpeg. Try installing libjpeg-turbo." 1>&2 + echo "See https://github.com/ioccc-src/temp-test-ioccc/blob/master/faq.md#libjpeg." 1>&2 + echo 1>&2 +fi diff --git a/thanks-for-help.md b/thanks-for-help.md index bc529d2b0..acefd8efa 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -4364,11 +4364,13 @@ He also added the [try.sh](/2015/yang/try.sh) script. ## [2018/bellard](/2018/bellard/prog.c) ([README.md](/2018/bellard/README.md)) -[Cody](#cody), out of abundance of caution, added a second arg to `main()` -because some versions of clang object to the number of args of `main()`, saying -that it must be 0, 2 or 3. The version this has been observed in does not -actually object to 1 arg but it is entirely possible that this changes so a -second arg (that's not needed and is unused) has been added just in case. +[Cody](#cody) added the [try.sh](/2018/bellard/try.sh) script. + +Cody also, out of abundance of caution, added a second arg to `main()` because +some versions of clang object to the number of args of `main()`, saying that it +must be 0, 2 or 3. The version this has been observed in does not actually +object to 1 arg but it is entirely possible that this changes so a second arg +(that's not needed and is unused) has been added just in case. Cody also added explicit linking of libm (`-lm`) for systems that do not do this (Linux doesn't seem to but macOS does). From a4a153cd74729d553141d91d6242272b2371526b Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 09:04:41 -0800 Subject: [PATCH 10/26] Improve 2018/algmyr/try.sh + update FAQ The script now does more (another feature of the program). The FAQ now has a name of 'sox' for FAQ 3.10 which the script refers to and the README.md file now refers it too (instead of 3.10). Fix make clobber: rm *.wav. Update .gitignore. --- 2018/algmyr/.gitignore | 1 + 2018/algmyr/Makefile | 2 +- 2018/algmyr/README.md | 6 +++--- 2018/algmyr/try.sh | 44 ++++++++++++++++++++++++++++-------------- faq.md | 2 +- 5 files changed, 35 insertions(+), 20 deletions(-) diff --git a/2018/algmyr/.gitignore b/2018/algmyr/.gitignore index 818b89eca..f4ce4bc96 100644 --- a/2018/algmyr/.gitignore +++ b/2018/algmyr/.gitignore @@ -9,3 +9,4 @@ prog prog.alt prog.orig spectrogram.png +*.wav diff --git a/2018/algmyr/Makefile b/2018/algmyr/Makefile index 595e9f9ca..377979c86 100644 --- a/2018/algmyr/Makefile +++ b/2018/algmyr/Makefile @@ -207,7 +207,7 @@ clean: clobber: clean ${RM} -f ${TARGET} ${ALT_TARGET} - ${RM} -rf *.dSYM + ${RM} -rf *.dSYM *.wav ${RM} -f out.raw @-if [ -e sandwich ]; then \ ${RM} -f sandwich; \ diff --git a/2018/algmyr/README.md b/2018/algmyr/README.md index b6f28a285..f07a1b6a9 100644 --- a/2018/algmyr/README.md +++ b/2018/algmyr/README.md @@ -6,7 +6,7 @@ make To use this entry requires, in some invocations, a sound processing program. This can be ALSA or SoX but we recommend the latter. See [FAQ 3.10 - How do I -compile and use an IOCCC winner that requires sound?](/faq.md#faq3_10). +compile and use an IOCCC winner that requires sound?](/faq.md#sox). ### Bugs and (Mis)features: @@ -23,9 +23,9 @@ For more detailed information see [2018 algmyr in bugs.md](/bugs.md#2018-algmyr) ## To use: ```sh -cat prog.c | ./prog # Print garbage: might mess up your terminal +./prog < prog.c # Print garbage: might mess up your terminal ./prog > out.raw -./prog -d 2 0 out.raw # Decode the first (0th) channel out of two +./prog -d 2 0 out.raw # Decode the first (0th) channel out of two ``` diff --git a/2018/algmyr/try.sh b/2018/algmyr/try.sh index 4c0f8045a..1c22a0125 100755 --- a/2018/algmyr/try.sh +++ b/2018/algmyr/try.sh @@ -15,46 +15,60 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear -echo "$ ./prog -h | ./prog -d 1 0" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog -h | ./prog -d 1 0: " +echo 1>&2 ./prog -h | ./prog -d 1 0 echo 1>&2 # Who needs cat? Answer: more people than you think. read -r -n 1 -p "Press any key to run: ./prog prog.c | ./prog -d 1 0 (space = next page, q = quit): " echo 1>&2 -./prog prog.c | ./prog -d 1 0 | less -EXF +./prog prog.c | ./prog -d 1 0 | less -rEXFK echo 1>&2 APLAY="$(type -P aplay)" SOX="$(type -P sox)" if [[ -z "$SOX" && -z "$APLAY" ]]; then - echo "Missing both sox and aplay, cannot do this step." + echo "Missing both sox and aplay, cannot do this step." 1>&2 + echo "NOTE: see https://github.com/ioccc-src/temp-test-ioccc/blob/master/faq.md#sox." 1>&2 elif [[ -n "$SOX" ]]; then -echo "$ echo -n ' MENE MENE TEKEL UPHARSIN ' | ./prog | \ -sox -t raw -c 1 -r 44100 -L -e floating-point -b 32 \ + echo "$ echo -n ' MENE MENE TEKEL UPHARSIN ' | ./prog | \ +$SOX -t raw -c 1 -r 44100 -L -e floating-point -b 32 \ - -n spectrogram -d 10 -X 300" 1>&2 echo -n ' MENE MENE TEKEL UPHARSIN ' | ./prog |\ - sox -t raw -c 1 -r 44100 -L -e floating-point -b 32 - -n spectrogram -d 10 -X 300 + $SOX -t raw -c 1 -r 44100 -L -e floating-point -b 32 - -n spectrogram -d 10 -X 300 echo "Now open spectrogram.png in an image viewer or editor." 1>&2 + echo 1>&2 read -r -n 1 -p "Press any key to continue: " echo 1>&2 - echo "$ echo "IOCCC 2018" | ./prog | sox -t raw -c 1 -r 44100 -L -e floating-point -b 32 - ioccc.wav" - echo "IOCCC 2018" | ./prog | sox -t raw -c 1 -r 44100 -L -e floating-point -b 32 - ioccc.wav + echo "$ echo \"IOCCC 2018\" | ./prog | $SOX -t raw -c 1 -r 44100 -L -e floating-point -b 32 - ioccc.wav" + read -r -n 1 -p "Press any key to continue: " + echo 1>&2 + echo "IOCCC 2018" | ./prog | "$SOX" -t raw -c 1 -r 44100 -L -e floating-point -b 32 - ioccc.wav echo "Now listen to ioccc.wav." 1>&2 - else -echo '<<<<<< /\_/\_/\ _-_-_-_ !!!!! :.:.:.: >>>>>> ****** ~~~~~~~' | -./prog | aplay -c1 -fFLOAT_LE -r44100 - echo '<<<<<< /\_/\_/\ _-_-_-_ !!!!! :.:.:.: >>>>>> ****** ~~~~~~~' | - ./prog | aplay -c1 -fFLOAT_LE -r44100 + echo "$ echo \"<<<<<< /\_/\_/\ _-_-_-_ !!!!! :.:.:.: >>>>>> ****** ~~~~~~~\" | +./prog | $APLAY -c1 -fFLOAT_LE -r44100" 1>&2 + read -r -n 1 -p "Press any key to continue: " + echo 1>&2 + echo "<<<<<< /\_/\_/\ _-_-_-_ !!!!! :.:.:.: >>>>>> ****** ~~~~~~~" | ./prog | "$APLAY" -c1 -fFLOAT_LE -r44100 -echo "Now open spectrogram.png in an image viewer or editor." 1>&2 + echo "Now open spectrogram.png in an image viewer or editor." 1>&2 fi echo 1>&2 -echo "$ echo "IOCCC 2018!" | ./prog | ./prog -d 1 0" 1>&2 +read -r -n 1 -p "Press any key to run: echo \"IOCCC 2018!\" | ./prog | ./prog -d 1 0: " +echo 1>&2 echo "IOCCC 2018!" | ./prog | ./prog -d 1 0 +read -r -n 1 -p "Press any key to run: ./prog README.md prog.c > out.raw: " +echo 1>&2 +./prog README.md prog.c > out.raw +echo 1>&2 +read -r -n 1 -p "Press any key to run: ./prog -d 2 0 out.raw (space = next page, q = quit): " +echo 1>&2 +./prog -d 2 0 out.raw | less -rEXFK +echo 1>&2 diff --git a/faq.md b/faq.md index 164bbeb2b..39ee39604 100644 --- a/faq.md +++ b/faq.md @@ -1249,7 +1249,7 @@ for downloading, installing and using ncurses. We recommend trying a method suitable for your environment first, if possible. -### FAQ 3.10: How do I compile and use an IOCCC winner that requires sound? +### FAQ 3.10: How do I compile and use an IOCCC winner that requires sound? This might depend on the entry but most likely the Swiss Army Knife of sound processing programs, [SoX](https://sox.sourceforge.net), will work. How to From 5989b570dd82db88cefdd8d67d95fe00bb094b1b Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 09:17:37 -0800 Subject: [PATCH 11/26] Improve 2019/adamovsky/try.sh --- 2019/adamovsky/try.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/2019/adamovsky/try.sh b/2019/adamovsky/try.sh index 463ec7a25..e4bd66cde 100755 --- a/2019/adamovsky/try.sh +++ b/2019/adamovsky/try.sh @@ -15,19 +15,17 @@ 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: ./prog spam.unl | head -n 100 (space = next page, q =quit): " echo 1>&2 -echo "$ ./prog spam.unl | head -n 100 | less -EXF" 1>&2 -read -r -n 1 -p "Press any key to continue: " -echo 1>&2 -./prog spam.unl | head -n 100 | less -EXF +./prog spam.unl | head -n 100 | less -rEXFK echo 1>&2 -echo "$ ./prog sierpinski.unl | head -n 200 | less -EXF" 1>&2 -read -r -n 1 -p "Press any key to continue: " +read -r -n 1 -p "Press any key to run: ./prog sierpinski.unl | head -n 200 (space = next page, q = quit): " echo 1>&2 -./prog sierpinski.unl | head -n 200 | less -EXF +./prog sierpinski.unl | head -n 200 | less -rEXFK -echo "$ make identify" 1>&2 +read -r -n 1 -p "Press any key to run: make identify: " +echo 1>&2 make identify echo 1>&2 From 6285cfd883cc99630bb88e08fd12a787a9f270ad Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 09:22:08 -0800 Subject: [PATCH 12/26] Improve 2019/burton/try.sh + shellcheck comments The shellcheck comments are in cow.sh and check.sh: added the URL for each supposed problem as per that issue. --- 2019/burton/check.sh | 7 +++++-- 2019/burton/cow.sh | 4 ++-- 2019/burton/try.sh | 10 +++++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/2019/burton/check.sh b/2019/burton/check.sh index 5be27498e..732ac6372 100755 --- a/2019/burton/check.sh +++ b/2019/burton/check.sh @@ -16,8 +16,11 @@ echo | $x /bin/echo -n a | $x echo a | $x $x < newlines -# ^---^ SC2210 (warning): This is a file redirection. Was it supposed to be a comparison or fd operation? -# Answer: 256 is a file so it is supposed to be file redirection. +# 256 is a file so it is supposed to be file redirection. Thus we have to +# disable this warning: +# +# SC2210 (warning): This is a file redirection. Was it supposed to be a comparison or fd operation? +# https://www.shellcheck.net/wiki/SC2210 # shellcheck disable=SC2210 $x < 256 $x < remarks diff --git a/2019/burton/cow.sh b/2019/burton/cow.sh index 0c6ef792d..31a4f3013 100755 --- a/2019/burton/cow.sh +++ b/2019/burton/cow.sh @@ -14,8 +14,8 @@ do if test -r "$name"; then # (or, to use Bart Simpson's advice, make it 'not have a cow.sh'), as we # actually need this to happen: # - # ^-- SC2086 (info): Double quote to prevent globbing and word splitting. - # + # SC2086 (info): Double quote to prevent globbing and word splitting. + # https://www.shellcheck.net/wiki/SC2086 # shellcheck disable=SC2086 set -- $s ((a += $1)) diff --git a/2019/burton/try.sh b/2019/burton/try.sh index 51e164fee..a0e9e1267 100755 --- a/2019/burton/try.sh +++ b/2019/burton/try.sh @@ -15,15 +15,19 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear -echo "$ cat prog.c" 1>&2 +read -r -n 1 -p "Press any key to show prog.c: " +echo 1>&2 cat prog.c echo 1>&2 for i in prog.c Makefile README.md; do - echo "$ ./prog < $i && wc < $i" 1>&2 + read -r -n 1 -p "Press any key to run: ./prog < $i && wc < $i: " + echo 1>&2 printf "prog: %s\n%4s: %s\n\n" "$(./prog < "$i"|tr -s ' ')" "wc" "$(wc "$i" | tr -s ' ')" done echo 1>&2 -echo "$ make test" 1>&2 +read -r -n 1 -p "Press any key to run: make test: " +echo 1>&2 make test +echo 1>&2 From 19afcc9d45f9699eecca3738765ee92fb69cab63 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 09:34:14 -0800 Subject: [PATCH 13/26] Improve 2019/diels-grabsch1/try.sh --- 2019/diels-grabsch1/try.sh | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/2019/diels-grabsch1/try.sh b/2019/diels-grabsch1/try.sh index 7ae705288..f2d046e16 100755 --- a/2019/diels-grabsch1/try.sh +++ b/2019/diels-grabsch1/try.sh @@ -15,34 +15,43 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear -echo "$ dd bs=1024 count=2048 < /dev/zero | compress > ref.Z" 1>&2 +read -r -n 1 -p "Press any key to run: dd bs=1024 count=2048 < /dev/zero | compress > ref.Z: " +echo 1>&2 dd bs=1024 count=2048 < /dev/zero | compress > ref.Z echo 1>&2 -echo "$ dd bs=1024 count=2048 < /dev/zero | ./prog > dg1.Z" 1>&2 +read -r -n 1 -p "Press any key to run: dd bs=1024 count=2048 < /dev/zero | ./prog > dg1.Z: " +echo 1>&2 dd bs=1024 count=2048 < /dev/zero | ./prog > dg1.Z echo 1>&2 -echo "$ cmp ref.Z dg1.Z" 1>&2 +read -r -n 1 -p "Press any key to run: cmp ref.Z dg1.Z: " +echo 1>&2 cmp ref.Z dg1.Z echo "Exit code of: cmp ref.Z dg1.Z: $?" 1>&2 echo 1>&2 -echo "$ compress < Shakespeare.txt > ref.Z" 1>&2 +read -r -n 1 -p "Press any key to run: compress < Shakespeare.txt > ref.Z: " +echo 1>&2 compress < Shakespeare.txt > ref.Z echo 1>&2 -echo "$ ./prog < Shakespeare.txt > dg1.Z" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog < Shakespeare.txt > dg1.Z: " +echo 1>&2 ./prog < Shakespeare.txt > dg1.Z echo 1>&2 -echo "Notice how the files differ:" 1>&2 -echo "$ cmp ref.Z dg1.Z" 1>&2 +echo "Notice how the two files differ:" 1>&2 +read -r -n 1 -p "Press any key to run: cmp ref.Z dg1.Z: " +echo 1>&2 cmp ref.Z dg1.Z # Oops, the files differ echo "Exit code of: cmp ref.Z dg1.Z: $?" 1>&2 echo 1>&2 echo "... and notice how this works fine:" 1>&2 -echo "$ zcat < dg1.Z | cmp - Shakespeare.txt" 1>&2 +read -r -n 1 -p "Press any key to run: zcat < dg1.Z | cmp - Shakespeare.txt: " +echo 1>&2 zcat < dg1.Z | cmp - Shakespeare.txt +echo "Exit code of zcat < dg1.Z | cmp - Shakespeare.txt: ${PIPESTATUS[1]}" +echo 1>&2 echo "What happened?" From f0cf419cefee23abacffcd718e04364b6925609f Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 09:39:50 -0800 Subject: [PATCH 14/26] Improve 2019/diels-grabsch2/try.sh --- 2019/diels-grabsch2/try.sh | 52 ++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/2019/diels-grabsch2/try.sh b/2019/diels-grabsch2/try.sh index bfdc91131..690248387 100755 --- a/2019/diels-grabsch2/try.sh +++ b/2019/diels-grabsch2/try.sh @@ -19,54 +19,68 @@ SHA512SUM="$(type -P sha512sum)" SHASUM="$(type -P shasum)" if [[ -z "$SHA512SUM" && -z "$SHASUM" ]]; then - echo "$ ./prog" 1>&2 + read -r -n 1 -p "Press any key to run: ./prog: " + echo 1>&2 ./prog + echo 1>&2 elif [[ -n "$SHA512SUM" ]]; then - echo "$ $SHA512SUM prog.c" 1>&2 + read -r -n 1 -p "Press any key to run: $SHA512SUM prog.c: " + echo 1>&2 "$SHA512SUM" prog.c echo 1>&2 - echo "$ ./prog" 1>&2 + read -r -n 1 -p "Press any key to run: ./prog: " + echo 1>&2 ./prog echo 1>&2 - echo "$ $SHA512SUM prog.c | cut -f 1 -d' ' > sha512sum.txt" 1>&2 - "$SHA512SUM" prog.c | cut -f 1 -d' ' > sha512sum.txt - echo "$ ./prog > prog.txt" 1>&2 - ./prog > prog.txt + read -r -n 1 -p "Press any key to run: $SHA512SUM prog.c | cut -f 1 -d' ' | tee sha512sum.txt: " + echo 1>&2 + "$SHA512SUM" prog.c | cut -f 1 -d' ' | tee sha512sum.txt + read -r -n 1 -p "Press any key to run: ./prog | tee prog.txt: " + echo 1>&2 + ./prog | tee prog.txt echo 1>&2 - echo "$ cat sha512sum.txt prog.txt" 1>&2 + read -r -n 1 -p "Press any key to run: cat sha512sum.txt prog.txt: " + echo 1>&2 cat sha512sum.txt prog.txt echo 1>&2 - echo "$ diff -s sha512sum.txt prog.txt" 1>&2 + read -r -n 1 -p "Press any key to run: diff -s sha512sum.txt prog.txt: " + echo 1>&2 diff -s sha512sum.txt prog.txt rm -f sha512sum prog.txt elif [[ -n "$SHASUM" ]]; then # Be extra careful and don't use 'else' - echo "$ $SHASUM -a 512 prog.c" 1>&2 + read -r -n 1 -p "Press any key to run: $SHASUM -a 512 prog.c: " + echo 1>&2 "$SHASUM" -a 512 prog.c echo 1>&2 - echo "$ ./prog" 1>&2 + read -r -n 1 -p "Press any key to run: ./prog: " + echo 1>&2 ./prog echo 1>&2 - echo "$ $SHASUM -a 512 prog.c | cut -f 1 -d' ' > sha512sum.txt" 1>&2 - "$SHASUM" -a 512 prog.c | cut -f 1 -d' ' > sha512sum.txt - echo "$ ./prog > prog.txt" 1>&2 - ./prog > prog.txt + read -r -n 1 -p "Press any key to run: $SHASUM -a 512 prog.c | cut -f 1 -d' ' | tee sha512sum.txt: " + echo 1>&2 + "$SHASUM" -a 512 prog.c | cut -f 1 -d' ' | tee sha512sum.txt echo 1>&2 - echo "$ cat sha512sum.txt prog.txt" 1>&2 + read -r -n 1 -p "Press any key to run: ./prog | tee prog.txt: " + echo 1>&2 + ./prog | tee prog.txt + echo 1>&2 + + read -r -n 1 -p "Press any key to run: cat sha512sum.txt prog.txt: " + echo 1>&2 cat sha512sum.txt prog.txt echo 1>&2 - echo "$ diff -s sha512sum.txt prog.txt" 1>&2 + read -r -n 1 -p "Press any key to run: diff -s sha512sum.txt prog.txt: " + echo 1>&2 diff -s sha512sum.txt prog.txt rm -f sha512sum prog.txt - - fi From d5b272c43836adab0a6ac4de528bd8747514dcac Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 09:41:56 -0800 Subject: [PATCH 15/26] Improve 2019/dogon/try.sh --- 2019/dogon/try.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/2019/dogon/try.sh b/2019/dogon/try.sh index 5585dfd3b..ac61430f6 100755 --- a/2019/dogon/try.sh +++ b/2019/dogon/try.sh @@ -43,5 +43,7 @@ for i in glider.mc infinite_5x5.mc mosquito5.mc message.mc; do if [[ "$REPLY" == "q" || "$REPLY" == "Q" ]]; then exit 0 fi + read -r -n 1 -p "Press any key to run: ./prog < $i: " + echo 1>&2 ./prog < "$i" 2>/dev/null done From fa688756249a4c42440a719015d8758f2bb0a365 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 09:44:04 -0800 Subject: [PATCH 16/26] Improve 2019/endoh/try.sh --- 2019/endoh/try.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/2019/endoh/try.sh b/2019/endoh/try.sh index 764447e0e..5f83da324 100755 --- a/2019/endoh/try.sh +++ b/2019/endoh/try.sh @@ -35,9 +35,12 @@ echo 1>&2 "$GDB" -q -x prog.c ./prog | cat | grep : | cut -f 2 -d: | xargs ./ascii | less -rEXF echo 1>&2 +echo "$ $GDB -q -x prog.c ./prog | cat | grep : | cut -f 2 -d: | xargs ./ascii > prog2.c" 1>&2 read -r -n 1 -p "Press any key to compare reconstructed code with original: " echo 1>&2 -echo "$ "$GDB" -q -x prog.c ./prog | cat | grep : | cut -f 2 -d: | xargs ./ascii > prog2.c" 1>&2 "$GDB" -q -x prog.c ./prog | cat | grep : | cut -f 2 -d: | xargs ./ascii > prog2.c -echo "$ diff -s prog.c prog2.c" 1>&2 +echo 1>&2 + +read -r -n 1 -p "Press any key to run: diff -s prog.c prog2.c: " +echo 1>&2 diff -s prog.c prog2.c From bbed912243bebe28eff70b30a012f7425d90e47b Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 09:47:28 -0800 Subject: [PATCH 17/26] Improve 2019/karns/try.sh --- 2019/karns/try.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/2019/karns/try.sh b/2019/karns/try.sh index 33cf2aa63..75e4c6089 100755 --- a/2019/karns/try.sh +++ b/2019/karns/try.sh @@ -16,8 +16,9 @@ make CC="$CC" all >/dev/null || exit 1 clear # display prog.c to the user -echo "$ cat prog.c" -cat prog.c +read -r -n 1 -p "Press any key to show prog.c (space = next page, q = quit): " +echo 1>&2 +less -rEXFK prog.c # run the program on its own source code read -r -n 1 -p "Press any key to run: ./prog < prog.c: " @@ -28,7 +29,9 @@ echo 1>&2 reset # display maze -echo "$ cat maze" +read -r -n 1 -p "Press any key to run: cat maze: " +echo 1>&2 +# Role swap: cat in maze instead of mice cat maze # run the program on maze From 0ee1e2af37f3bea58dac0997f90d26277e1776aa Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 09:53:45 -0800 Subject: [PATCH 18/26] Improve 2019/lynn/try.sh + update CSILENCE --- 2019/lynn/Makefile | 2 +- 2019/lynn/try.sh | 44 +++++++++++++++++++++++++++----------------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/2019/lynn/Makefile b/2019/lynn/Makefile index c90d62c2c..226492879 100644 --- a/2019/lynn/Makefile +++ b/2019/lynn/Makefile @@ -38,7 +38,7 @@ include ../../var.mk # Common C compiler warnings to silence # -CSILENCE= -Wno-strict-prototypes +CSILENCE= -Wno-strict-prototypes -Wno-comment # Common C compiler warning flags # diff --git a/2019/lynn/try.sh b/2019/lynn/try.sh index fce906ce4..3f5b5a5fc 100755 --- a/2019/lynn/try.sh +++ b/2019/lynn/try.sh @@ -15,31 +15,42 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear -echo "$ (./prog < fib.hs; cat prog.c) > fib.c" 1>&2 -(./prog < fib.hs; cat prog.c) > fib.c -echo "$ cc -Wno-everything fib.c -o fib" 1>&2 -cc -Wno-everything fib.c -o fib -echo "$ ./fib" 1>&2 -./fib +echo "$ (./prog < fib.hs; cat prog.c) | tee fib.c" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +(./prog < fib.hs; cat prog.c) | tee fib.c | less -rEXFK + +read -r -n 1 -p "Press any key to run: make fib: " echo 1>&2 -read -r -n 1 -p "Press any key to continue: " +make CC="$CC" fib echo 1>&2 -echo "$ (./prog < lol.hs ; cat prog.c) > lol.c" 1>&2 -(./prog < lol.hs ; cat prog.c) > lol.c -echo "$ make lol" 1>&2 -make lol +read -r -n 1 -p "Press any key to run: ./fib: " +echo 1>&2 +./fib + +echo "$ (./prog < lol.hs ; cat prog.c) | tee lol.c" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +(./prog < lol.hs ; cat prog.c) | tee lol.c | less -rEXFK + +read -r -n 1 -p "Press any key to run: make lol: " 1>&2 +echo 1>&2 +make CC="$CC" lol read -r -n 1 -p "Press any key to run: ./lol: " echo 1>&2 ./lol echo 1>&2 -read -r -n 1 -p "Press any key to continue: " echo 1>&2 -echo "$ (./prog < scc.hs ; cat prog.c) > scc.c" 1>&2 -(./prog < scc.hs ; cat prog.c) > scc.c -echo "$ make scc" 1>&2 -make scc +echo "$ (./prog < scc.hs ; cat prog.c) | tee scc.c" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +(./prog < scc.hs ; cat prog.c) | tee scc.c | less -rEXFK +echo 1>&2 + +read -r -n 1 -p "Press any key to run: make scc: " +echo 1>&2 +make CC="$CC" scc + read -r -n 1 -p "Press any key to run: ./scc < example-1.txt: " echo 1>&2 ./scc < example-1.txt @@ -47,6 +58,5 @@ read -r -n 1 -p "Press any key to run: ./scc < example-2.txt: " echo 1>&2 ./scc < example-2.txt - exit 0 From c3d8609064a3008ae30a0104ea8c62c67498dbd0 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 09:56:03 -0800 Subject: [PATCH 19/26] Fix 2019/mills/try.sh (missing less(1) calls) --- 2019/mills/try.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/2019/mills/try.sh b/2019/mills/try.sh index 531abf0a9..78cd9f72b 100755 --- a/2019/mills/try.sh +++ b/2019/mills/try.sh @@ -18,17 +18,16 @@ echo 1>&2 echo "This may take a while:" make test-64bit - echo "$ less IOCCC-Rules-Guidelines.output.txt" 1>&2 read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " echo 1>&2 -less -rEXF IOCCC-Rules-Guidelines.output.txt +less -rEXFK IOCCC-Rules-Guidelines.output.txt echo 1>&2 echo "$ less IOCCC-hints.output.txt" 1>&2 read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " echo 1>&2 -less -rEXF IOCCC-hints.output.txt +less -rEXFK IOCCC-hints.output.txt echo 1>&2 echo "$ less Eugene_Onegin.output.txt" 1>&2 @@ -36,17 +35,17 @@ echo "You should be able to safely ignore the warnings about this file" 1>&2 echo "being a binary file." 1>&2 read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " echo 1>&2 -less -rEXF Eugene_Onegin.output.txt +less -rEXFK Eugene_Onegin.output.txt echo 1>&2 echo "$ ./prog < IOCCC-Rules-Guidelines.cp98_0.175 |head -n 100" read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " echo 1>&2 -./prog < IOCCC-Rules-Guidelines.cp98_0.175 |head -n 100 +./prog < IOCCC-Rules-Guidelines.cp98_0.175 |head -n 100 | less -rEXFK echo 1>&2 echo "$ ./prog < Shakespeare.cp04_1.633 | head -n 100" 1>&2 read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " echo 1>&2 -./prog < Shakespeare.cp04_1.633 | head -n 100 +./prog < Shakespeare.cp04_1.633 | head -n 100 | less -rEXFK echo 1>&2 From 1ae087249fde0b146ed26d50593d2c0cb8a938ae Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 09:59:58 -0800 Subject: [PATCH 20/26] Improve 2019/poikola/try scripts --- 2019/poikola/try.alt.sh | 11 +++++------ 2019/poikola/try.sh | 5 ++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/2019/poikola/try.alt.sh b/2019/poikola/try.alt.sh index a359be1a2..9084bdb20 100755 --- a/2019/poikola/try.alt.sh +++ b/2019/poikola/try.alt.sh @@ -19,22 +19,21 @@ make clobber CC="$CC" alt >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear -echo "$ ./prog.alt 512 ./prog.alt" 1>&2 -read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +read -r -n 1 -p "Press any key to run: ./prog.alt 512 ./prog.alt (space = next page, q = quit): " echo 1>&2 -./prog.alt 512 ./prog.alt | less -rEXF +./prog.alt 512 ./prog.alt | less -rEXFK echo 1>&2 echo "$ TZ=UTC24 make CC="$CC" clobber prog.alt" 1>&2 TZ=UTC24 make CC="$CC" clobber prog.alt || exit 1 read -r -n 1 -p "Press any key to run: ./prog.alt 512 ./prog.alt (space = next page, q = quit): " echo 1>&2 -./prog.alt 512 ./prog.alt | less -rEXF +./prog.alt 512 ./prog.alt | less -rEXFK echo 1>&2 echo "$ TZ=UTC48 make CC="$CC" clobber prog.alt" 1>&2 TZ=UTC48 make CC="$CC" clobber prog.alt || exit 1 -read -r -n 1 -p "Press any key to run: ./prog.alt 512 ./prog.alt (space = next page, q = quit): " +read -r -n 1 -p "Press any key to run: ./prog.alt 512 ./prog.alt: " echo 1>&2 -./prog.alt 512 ./prog.alt | less -rEXF +./prog.alt 512 ./prog.alt echo 1>&2 diff --git a/2019/poikola/try.sh b/2019/poikola/try.sh index 27299f0cf..9776f8cd3 100755 --- a/2019/poikola/try.sh +++ b/2019/poikola/try.sh @@ -20,13 +20,12 @@ make clobber CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear -echo "$ ./prog 512 ./prog" 1>&2 -read -r -n 1 -p "Press any key to continue: " +read -r -n 1 -p "Press any key to run: ./prog 512 ./prog: " echo 1>&2 ./prog 512 ./prog echo 1>&2 -echo "$ TZ=UTC24 make CC="$CC" clobber prog" 1>&2 +echo "$ TZ=UTC24 make CC=$CC clobber prog" 1>&2 TZ=UTC24 make CC="$CC" clobber prog || exit 1 read -r -n 1 -p "Press any key to run: ./prog 512 ./prog: " echo 1>&2 From da3bfa5eb0e2c9eef4616ce641a9b3d224b9980a Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 10:05:17 -0800 Subject: [PATCH 21/26] Improve 2019/yang/try.sh --- 2019/yang/try.sh | 52 +++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/2019/yang/try.sh b/2019/yang/try.sh index 40efb17bd..2d65b3a15 100755 --- a/2019/yang/try.sh +++ b/2019/yang/try.sh @@ -15,28 +15,28 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear +echo "$ ./prog ioccc.txt a b c d e" 1>&2 read -r -n 1 -p "Press any key to scramble ioccc.txt into five files: " echo 1>&2 -echo "$ ./prog ioccc.txt a b c d e" 1>&2 ./prog ioccc.txt a b c d e -read -r -n 1 -p "Press any key to unscramble part a with cat: " +read -r -n 1 -p "Press any key to unscramble part a with: cat a: " clear cat a -read -r -n 1 -p "Press any key to unscramble part b with cat: " +read -r -n 1 -p "Press any key to unscramble part b with: cat b: " clear cat b -read -r -n 1 -p "Press any key to unscramble part c with cat: " +read -r -n 1 -p "Press any key to unscramble part c with: cat c: " clear cat c -read -r -n 1 -p "Press any key to unscramble part d with cat: " +read -r -n 1 -p "Press any key to unscramble part d with: cat d: " clear cat d -read -r -n 1 -p "Press any key to unscramble part e with cat: " +read -r -n 1 -p "Press any key to unscramble part e with: cat e: " clear cat e @@ -46,8 +46,7 @@ echo 1>&2 cat a b c d e | ./prog echo 1>&2 -echo "$ cat a b c d e | ./prog | diff - ioccc.txt" 1>&2 -read -r -n 1 -p "Press any key to continue: " +read -r -n 1 -p "Press any key to run: cat a b c d e | ./prog | diff -s - ioccc.txt: " echo 1>&2 cat a b c d e | ./prog | diff -s - ioccc.txt @@ -58,28 +57,29 @@ if [[ "$COLS" -lt 75 || "$LINES" -lt 13 ]]; then exit 0 fi -read -r -n 1 -p "Press any key to scramble sample_input.txt into five files: " echo 1>&2 echo "$ ./prog sample_input.txt a b c d e" 1>&2 +read -r -n 1 -p "Press any key to scramble sample_input.txt into five files: " +echo 1>&2 ./prog sample_input.txt a b c d e -read -r -n 1 -p "Press any key to unscramble part a with cat: " +read -r -n 1 -p "Press any key to unscramble part a with: cat a: " clear cat a -read -r -n 1 -p "Press any key to unscramble part b with cat: " +read -r -n 1 -p "Press any key to unscramble part b with: cat b: " clear cat b -read -r -n 1 -p "Press any key to unscramble part c with cat: " +read -r -n 1 -p "Press any key to unscramble part c with: cat c: " clear cat c -read -r -n 1 -p "Press any key to unscramble part d with cat: " +read -r -n 1 -p "Press any key to unscramble part d with: cat d: " clear cat d -read -r -n 1 -p "Press any key to unscramble part e with cat: " +read -r -n 1 -p "Press any key to unscramble part e with: cat e: " clear cat e @@ -89,11 +89,10 @@ echo 1>&2 cat a b c d e | ./prog echo 1>&2 -echo "$ cat a b c d e | ./prog | diff - sample_input.txt" 1>&2 -read -r -n 1 -p "Press any key to continue: " +read -r -n 1 -p "Press any key to run: cat a b c d e | ./prog | diff -s - sample_input.txt: " echo 1>&2 cat a b c d e | ./prog | diff -s - sample_input.txt - +echo 1>&2 if [[ "$COLS" -lt 80 || "$LINES" -lt 25 ]]; then # if screen size < 80 x 25 then exit @@ -105,28 +104,28 @@ echo 1>&2 cat prog.c echo 1>&2 +echo "$ ./prog prog.c a b c d e" 1>&2 read -r -n 1 -p "Press any key to scramble prog.c into five files: " echo 1>&2 -echo "$ ./prog prog.c a b c d e" 1>&2 ./prog prog.c a b c d e -read -r -n 1 -p "Press any key to unscramble part a with cat: " +read -r -n 1 -p "Press any key to unscramble part a with: cat a: " clear cat a -read -r -n 1 -p "Press any key to unscramble part b with cat: " +read -r -n 1 -p "Press any key to unscramble part b with: cat b: " clear cat b -read -r -n 1 -p "Press any key to unscramble part c with cat: " +read -r -n 1 -p "Press any key to unscramble part c with: cat c: " clear cat c -read -r -n 1 -p "Press any key to unscramble part d with cat: " +read -r -n 1 -p "Press any key to unscramble part d with: cat d: " clear cat d -read -r -n 1 -p "Press any key to unscramble part e with cat: " +read -r -n 1 -p "Press any key to unscramble part e with: cat e: " clear cat e @@ -136,16 +135,17 @@ echo 1>&2 cat a b c d e | ./prog echo 1>&2 -echo "$ cat a b c d e | ./prog | diff - prog.c" 1>&2 -read -r -n 1 -p "Press any key to continue: " +read -r -n 1 -p "Press any key to run: cat a b c d e | ./prog | diff -s - prog.c: " echo 1>&2 cat a b c d e | ./prog | diff -s - prog.c +echo 1>&2 # For the next three we have to see if ruby is installed RUBY="$(type -P ruby)" if [[ -n "$RUBY" ]]; then read -r -p "Do you want to see the slow scrambling: ./prog prog.c | ruby prog.c (Y/N)? " + echo 1>&2 if [[ "$REPLY" == "y" || "$REPLY" == "Y" ]]; then echo "This may take a while, hit ctrl-c to exit script." 1>&2 echo 1>&2 @@ -153,6 +153,7 @@ if [[ -n "$RUBY" ]]; then fi read -r -p "Do you want to see the slow scrambling: ./prog violet.c | ruby prog.c (Y/N)? " + echo 1>&2 if [[ "$REPLY" == "y" || "$REPLY" == "Y" ]]; then echo "This may take a while, hit ctrl-c to exit script." 1>&2 echo 1>&2 @@ -160,6 +161,7 @@ if [[ -n "$RUBY" ]]; then fi read -r -p "Do you want to see the slow scrambling: ./prog violet.c | ruby violet.c (Y/N)? " + echo 1>&2 if [[ "$REPLY" == "y" || "$REPLY" == "Y" ]]; then echo "This may take a while, hit ctrl-c to exit script." 1>&2 echo 1>&2 From 1d060870e0becf552d6a06ed035969837360a6d1 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 10:06:59 -0800 Subject: [PATCH 22/26] Improve 2019/ciura/try.sh, add fr.alt.sh --- 2019/ciura/fr.alt.sh | 3 +++ 2019/ciura/try.alt.sh | 14 ++++++++------ 2019/ciura/try.sh | 12 +++++++----- 3 files changed, 18 insertions(+), 11 deletions(-) create mode 100755 2019/ciura/fr.alt.sh diff --git a/2019/ciura/fr.alt.sh b/2019/ciura/fr.alt.sh new file mode 100755 index 000000000..ffd72789e --- /dev/null +++ b/2019/ciura/fr.alt.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +set -x +./getwords.sh fr | ./prog.alt aàâbcdeéèêfghiîjklmnoôpqrstuùûvwxyz\' diff --git a/2019/ciura/try.alt.sh b/2019/ciura/try.alt.sh index 3d0d58bdc..d7d914a7e 100755 --- a/2019/ciura/try.alt.sh +++ b/2019/ciura/try.alt.sh @@ -15,22 +15,24 @@ make CC="$CC" everything >/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: ./getwords.sh en | grep .. | ./prog.alt aeiouvwxyz: " -./getwords.sh en | grep .. | ./prog.alt aeiouvwxyz | less -EXF +echo "$ ./getwords.sh en | grep .. | ./prog.alt aeiouvwxyz" +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./getwords.sh en | grep .. | ./prog.alt aeiouvwxyz | less -rEXFK echo 1>&2 echo "$ ./getwords.sh en | grep .. | ./prog.alt aeiouhjklmnvwxyz" 1>&2 read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " echo 1>&2 -./getwords.sh en | grep .. | ./prog.alt aeiouhjklmnvwxyz | less -EXF +./getwords.sh en | grep .. | ./prog.alt aeiouhjklmnvwxyz | less -rEXFK echo "$ ./getwords.sh en | grep .. | ./prog.alt mrjocktvquizphdbagsfewlynx | head -n 256" 1>&2 read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " echo 1>&2 -./getwords.sh en | grep .. | ./prog.alt mrjocktvquizphdbagsfewlynx | head -n 256 | less -EXF - +./getwords.sh en | grep .. | ./prog.alt mrjocktvquizphdbagsfewlynx | head -n 256 | less -rEXFK echo "$ ./en.alt.sh" 1>&2 echo "There will likely be a lot of output. Quit when bored. No logophiles will be hurt." 1>&2 read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " -./en.alt.sh | less -EXF +echo 1>&2 +./en.alt.sh | less -rEXFK diff --git a/2019/ciura/try.sh b/2019/ciura/try.sh index d714d19e9..4aa183b2a 100755 --- a/2019/ciura/try.sh +++ b/2019/ciura/try.sh @@ -15,22 +15,24 @@ 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: ./getwords.sh en | grep .. | ./prog aeiouvwxyz: " -./getwords.sh en | grep .. | ./prog aeiouvwxyz | less -EXF +echo "$ ./getwords.sh en | grep .. | ./prog aeiouvwxyz" +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./getwords.sh en | grep .. | ./prog aeiouvwxyz | less -rEXFK echo 1>&2 echo "$ ./getwords.sh en | grep .. | ./prog aeiouhjklmnvwxyz" 1>&2 read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " echo 1>&2 -./getwords.sh en | grep .. | ./prog aeiouhjklmnvwxyz | less -EXF +./getwords.sh en | grep .. | ./prog aeiouhjklmnvwxyz | less -rEXFK echo "$ ./getwords.sh en | grep .. | ./prog mrjocktvquizphdbagsfewlynx | head -n 256" 1>&2 read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " echo 1>&2 -./getwords.sh en | grep .. | ./prog mrjocktvquizphdbagsfewlynx | head -n 256 | less -EXF +./getwords.sh en | grep .. | ./prog mrjocktvquizphdbagsfewlynx | head -n 256 | less -rEXFK echo "$ ./en.sh" 1>&2 echo "There will likely be a lot of output. Quit when bored. No logophiles will be hurt." 1>&2 read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " -./en.sh | less -EXF +./en.sh | less -rEXFK From 1fc630c45fcbc29966a4cb07694658a59ab214a8 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 10:19:20 -0800 Subject: [PATCH 23/26] Add 2019/giles/try.sh --- 2019/giles/README.md | 10 ++++------ 2019/giles/try.sh | 40 ++++++++++++++++++++++++++++++++++++++++ thanks-for-help.md | 5 +++++ 3 files changed, 49 insertions(+), 6 deletions(-) create mode 100755 2019/giles/try.sh diff --git a/2019/giles/README.md b/2019/giles/README.md index 9acd8a397..ac74a8e21 100644 --- a/2019/giles/README.md +++ b/2019/giles/README.md @@ -15,15 +15,13 @@ make ## Try: ```sh -play MonodyVocals.wav -./prog MonodyVocals.wav -play out.wav +./try.sh ``` -NOTE: `play` comes from SoX, the Swiss Army Knife of sound processing programs. -If you don't have this installed, see [FAQ 3.10: How do I compile and use an -IOCCC winner that requires sound](/faq.md#faq3_10). +NOTE: `play`, which [try.sh](try.sh) uses, comes from SoX, the Swiss Army Knife +of sound processing programs. If you don't have this installed, see [FAQ 3.10: +How do I compile and use an IOCCC winner that requires sound](/faq.md#faq3_10). ## Judges' remarks: diff --git a/2019/giles/try.sh b/2019/giles/try.sh new file mode 100755 index 000000000..ac7c7138e --- /dev/null +++ b/2019/giles/try.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2019/giles +# + +# 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 + +# find out if SoX is installed +PLAY="$(type -P play)" + +if [[ -n "$PLAY" ]]; then + read -r -n 1 -p "Press any key to run: $PLAY MonodyVocals.wav: " + echo 1>&2 + "$PLAY" MonodyVocals.wav + echo 1>&2 + + read -r -n 1 -p "Press any key to run: ./prog MonodyVocals.wav: " + echo 1>&2 + ./prog MonodyVocals.wav + echo 1>&2 + + read -r -n 1 -p "Press any key to run: $PLAY MonodyVocals.wav: " + echo 1>&2 + "$PLAY" MonodyVocals.wav + echo 1>&2 +else + echo "play(1) from SoX not installed." 1>&2 + echo "NOTE: see https://github.com/ioccc-src/temp-test-ioccc/blob/master/faq.md#sox." 1>&2 +fi + diff --git a/thanks-for-help.md b/thanks-for-help.md index acefd8efa..2886a8801 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -4623,6 +4623,11 @@ to easily reconstruct the source code through GDB by the fact it's a backtrace quine. +## [2019/giles](/2019/giles/prog.c) ([README.md](/2019/giles/README.md])) + +[Cody](#cody) added the [try.sh](/2019/giles/try.sh) script. + + ## [2019/karns](/2019/karns/prog.c) ([README.md](/2019/karns/README.md])) [Cody](#cody) reported that with `-O` level > 0 this program segfaults (sometimes?). He's From d56c2c7371a03982d77ee63b09ee996580593b77 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 10:23:47 -0800 Subject: [PATCH 24/26] Improve 2020/burton/try.sh --- 2020/burton/try.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/2020/burton/try.sh b/2020/burton/try.sh index 71fe6f3ec..6941e7b40 100755 --- a/2020/burton/try.sh +++ b/2020/burton/try.sh @@ -15,7 +15,8 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear -echo "$ make test" 1>&2 +read -r -n 1 -p "Press any key to run: make test: " +echo 1>&2 make test echo 1>&2 @@ -75,3 +76,4 @@ echo 1>&2 read -r -n 1 -p "Press any key to run: ./prog 1; ./prog_be 1: " echo 1>&2 ./prog 1; ./prog_be 1 +echo 1>&2 From c06ac5088840c4aea0bbbc46246460768b1c3901 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 10:35:31 -0800 Subject: [PATCH 25/26] Add 2020/endoh3/run_clock.alt.sh for alt code The alt code provided by the author back in 2020 uses Unicode but there wasn't a script for it (the script run_clock.sh which I made some fixes in last year was added by the judges but no version for the alt code was added). The scripts also have another fix in them: make clock or make clock.alt first as if not and the program does not exist the script will happily overwrite the C files and prevent it from being compiled. They use 'make -B' just to be sure that it's compiled. --- 2020/endoh3/.gitignore | 2 ++ 2020/endoh3/Makefile | 12 ++++++++++-- 2020/endoh3/README.md | 8 ++++++++ 2020/endoh3/run_clock.alt.sh | 9 +++++++++ 2020/endoh3/run_clock.sh | 1 + thanks-for-help.md | 8 ++++++++ 6 files changed, 38 insertions(+), 2 deletions(-) create mode 100755 2020/endoh3/run_clock.alt.sh diff --git a/2020/endoh3/.gitignore b/2020/endoh3/.gitignore index 022c5af38..1914fcb60 100644 --- a/2020/endoh3/.gitignore +++ b/2020/endoh3/.gitignore @@ -1,6 +1,8 @@ # # sort with: sort -d -u clock +clock.alt +clock.alt.c clock.c *.dSYM indent diff --git a/2020/endoh3/Makefile b/2020/endoh3/Makefile index fc213a1c5..8c6841dfa 100644 --- a/2020/endoh3/Makefile +++ b/2020/endoh3/Makefile @@ -113,8 +113,8 @@ OBJ= ${PROG}.o DATA= TARGET= ${PROG} clock # -ALT_OBJ= ${PROG}.alt.o -ALT_TARGET= ${PROG}.alt +ALT_OBJ= ${PROG}.alt.o clock.alt.o +ALT_TARGET= ${PROG}.alt clock.alt ################# @@ -146,6 +146,14 @@ alt: data ${ALT_TARGET} ${PROG}.alt: ${PROG}.alt.c ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} +clock.alt: clock.alt.c + +clock.alt.c: ${PROG}.alt.c + @${RM} -f $@ + ${CP} -f $< $@ + + + # data files # data: ${DATA} diff --git a/2020/endoh3/README.md b/2020/endoh3/README.md index e54527e4a..38b255e8b 100644 --- a/2020/endoh3/README.md +++ b/2020/endoh3/README.md @@ -41,6 +41,14 @@ make alt Use `prog.alt` as you would `prog` above. +### Alternate try: + +```sh +./run_clock.alt +# And watch closely for 15-20 seconds +``` + + ## Judges' remarks: You may be tempted to use a mirror. Resist the temptation! Try figuring out how diff --git a/2020/endoh3/run_clock.alt.sh b/2020/endoh3/run_clock.alt.sh new file mode 100755 index 000000000..f4bbeaf50 --- /dev/null +++ b/2020/endoh3/run_clock.alt.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +make -B clock.alt || exit 1 +while true; do + cc -std=c11 -Wall -Wextra -pedantic -O3 clock.alt.c -o clock.alt + clear + ./clock.alt | tee clock.alt.c + sleep 5 +done diff --git a/2020/endoh3/run_clock.sh b/2020/endoh3/run_clock.sh index 702da8b07..f83f6d8ca 100755 --- a/2020/endoh3/run_clock.sh +++ b/2020/endoh3/run_clock.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash +make -B clock || exit 1 while true; do cc -std=c11 -Wall -Wextra -pedantic -O3 clock.c -o clock clear diff --git a/thanks-for-help.md b/thanks-for-help.md index 2886a8801..2c96a47fd 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -4737,6 +4737,10 @@ What was wrong? A typo in the shebang which had `/usr/bin/end` instead of `/usr/bin/env`. Anyone who knows Cody would know that he'd zoom in on that quite quick. +Also if `clock` did not exist and one tried to run the script it would make an +invalid `clock.c` which meant it could not compile so it now runs `make clock` +first. + Cody also reported (during the preview period of 2020) for some systems (at some point?) like macOS the use of `make clock` would not work due possibly to a timing issue so [Yusuke](#yusuke) changed it to compile the @@ -4748,6 +4752,10 @@ that if someone moves something of his even a millimetre from where it was he knows it so he might be called unusual (and he argues, with pride, eccentric :-) ) :-) +Cody also added the [run_clock.alt.sh](/2020/endoh3/run_clock.alt.sh) script +which is analogous to the [run_clock.sh](/2020/endoh3/run_clock.sh) but for the +alt code provided by the author, Yusuke. + ## [2020/ferguson1](/2020/ferguson1/prog.c) ([README.md](/2020/ferguson1/README.md)) From 1feaa1d5af9fc235baa152698437287f9a09657d Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 10:41:34 -0800 Subject: [PATCH 26/26] Fix 2020/ferguson2/try scripts --- 2020/ferguson2/try.alt.sh | 3 +-- 2020/ferguson2/try.sh | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/2020/ferguson2/try.alt.sh b/2020/ferguson2/try.alt.sh index 31050677e..9a3bc0210 100755 --- a/2020/ferguson2/try.alt.sh +++ b/2020/ferguson2/try.alt.sh @@ -29,7 +29,7 @@ if [[ -z "$CC" ]]; then CC="cc" fi -make CC="$CC" alt >/dev/null || exit 1 +make CC="$CC" everything >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear @@ -138,6 +138,5 @@ echo 1>&2 read -r -n 1 -p "Press any key to compare input and output2: " echo 1>&2 diff -s input output2 -diff -s input output2 # final clean up rm -f conf input output output2 diff --git a/2020/ferguson2/try.sh b/2020/ferguson2/try.sh index 22a2f3a96..9f67a416d 100755 --- a/2020/ferguson2/try.sh +++ b/2020/ferguson2/try.sh @@ -138,6 +138,5 @@ echo 1>&2 read -r -n 1 -p "Press any key to compare input and output2: " echo 1>&2 diff -s input output2 -diff -s input output2 # final clean up rm -f conf input output output2