diff --git a/2000/natori/README.md b/2000/natori/README.md index 0c0cc7e7c..ab66de871 100644 --- a/2000/natori/README.md +++ b/2000/natori/README.md @@ -22,6 +22,9 @@ version](#alternate-code) below. ./try.sh ``` +Try running this on different days, say a few days apart, and each time run it +several times in a row (or several times in a day). + Also try modifying the code so that it will show another Moon phase based on input or else just by the code itself. Bonus points if you can make it show all~ @@ -47,6 +50,9 @@ make alt ./natori.alt ``` +Try running this on different days, say a few days apart, and each time run it +several times in a row (or several times in a day). + What happens if you run it in the northern hemisphere? Are there any differences? @@ -54,6 +60,15 @@ Can you identify any Moon phases that result in the same output of both versions? Or are there any? +### Alternate try: + +```sh +./try.alt.sh +``` + +Like with [try.sh](try.sh), try using this multiple times. + + ## Judges' remarks: Here is a nice compact program that changes with the phase of the Moon. diff --git a/2000/natori/try.alt.sh b/2000/natori/try.alt.sh new file mode 100755 index 000000000..f5590e189 --- /dev/null +++ b/2000/natori/try.alt.sh @@ -0,0 +1,162 @@ +#!/usr/bin/env bash +# +# try.alt.sh - demonstrate IOCCC winner 2000/natori 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" everything >/dev/null || exit 1 + +# clear screen after compilation so that only the entry is shown +clear + +NATORI="natori" +moon() +{ + read -r -n 1 -p "Press any key to randomly show the northern/southern hemisphere Moon: " + echo 1>&2 + for ((i=0;i<=10;i++)); do + RAND=$((RANDOM % 1000)) + if [[ "$RAND" -le 500 ]]; then + ./"$NATORI".alt + echo 1>&2 + else + ./"$NATORI" + echo 1>&2 + fi + done + + echo 1>&2 + RAND=$((RANDOM % 1000)) + if [[ "$RAND" -gt 500 ]]; then + read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: " + echo 1>&2 + ./"$NATORI".alt + ./"$NATORI" + ./"$NATORI".alt + ./"$NATORI" + ./"$NATORI".alt + ./"$NATORI" + else + read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: " + echo 1>&2 + ./"$NATORI" + ./"$NATORI".alt + ./"$NATORI" + ./"$NATORI".alt + ./"$NATORI" + ./"$NATORI".alt + fi + + echo 1>&2 + echo "We will now reverse the order." 1>&2 + echo 1>&2 + + if [[ "$RAND" -le 499 ]]; then + read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: " + echo 1>&2 + ./"$NATORI".alt + ./"$NATORI" + ./"$NATORI".alt + ./"$NATORI" + ./"$NATORI".alt + ./"$NATORI" + else + read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: " + echo 1>&2 + ./"$NATORI" + ./"$NATORI".alt + ./"$NATORI" + ./"$NATORI".alt + ./"$NATORI" + ./"$NATORI".alt + fi + + echo 1>&2 + echo "Will now use less(1): 'q' = quit, space = next page, enter = next line." 1>&2 + echo "We recommend that you try holding space down." 1>&2 + echo 1>&2 + RAND=$((RANDOM % 1000)) + if [[ "$RAND" -gt 500 ]]; then + read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: " + echo 1>&2 + ( ./"$NATORI.alt"; ./"$NATORI" ; ./"$NATORI.alt" ; ./"$NATORI"; \ + ./"$NATORI.alt"; ./"$NATORI" ) | less -rEXF + else + read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: " + echo 1>&2 + ( ./"$NATORI"; ./"$NATORI.alt" ; ./"$NATORI" ; ./"$NATORI.alt"; \ + ./"$NATORI"; ./"$NATORI.alt" ) | less -rEXF + fi + + echo 1>&2 + echo "Will now use less(1): 'q' = quit, space = next page, enter = next line." 1>&2 + echo "We now recommend that you try holding enter down." 1>&2 + echo 1>&2 + if [[ "$RAND" -gt 500 ]]; then + read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: " + echo 1>&2 + ( ./"$NATORI.alt"; ./"$NATORI" ; ./"$NATORI.alt" ; ./"$NATORI"; \ + ./"$NATORI.alt"; ./"$NATORI" ) | less -rEXF + else + read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: " + echo 1>&2 + ( ./"$NATORI"; ./"$NATORI.alt" ; ./"$NATORI" ; ./"$NATORI.alt"; \ + ./"$NATORI"; ./"$NATORI.alt" ) | less -rEXF + fi + echo 1>&2 + + echo "We will now reverse the order." 1>&2 + echo 1>&2 + echo "Will now use less(1): 'q' = quit, space = next page, enter = next line." 1>&2 + echo "We recommend that you try holding space down." 1>&2 + echo 1>&2 + if [[ "$RAND" -le 499 ]]; then + read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: " + echo 1>&2 + ( ./"$NATORI.alt"; ./"$NATORI" ; ./"$NATORI.alt" ; ./"$NATORI"; \ + ./"$NATORI.alt"; ./"$NATORI" ) | less -rEXF + else + read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: " + echo 1>&2 + ( ./"$NATORI"; ./"$NATORI.alt" ; ./"$NATORI" ; ./"$NATORI.alt"; \ + ./"$NATORI"; ./"$NATORI.alt" ) | less -rEXF + fi + + echo 1>&2 + echo "Will now use less(1): 'q' = quit, space = next page, enter = next line." 1>&2 + echo "We now recommend that you try holding enter down." 1>&2 + echo 1>&2 + if [[ "$RAND" -le 499 ]]; then + read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: " + echo 1>&2 + ( ./"$NATORI.alt"; ./"$NATORI" ; ./"$NATORI.alt" ; ./"$NATORI"; \ + ./"$NATORI.alt"; ./"$NATORI" ) | less -rEXF + else + read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: " + echo 1>&2 + ( ./"$NATORI"; ./"$NATORI.alt" ; ./"$NATORI" ; ./"$NATORI.alt"; \ + ./"$NATORI"; ./"$NATORI.alt" ) | less -rEXF + fi + echo 1>&2 + + # Finally, for the try.alt.sh (alt code, southern hemisphere), force + # starting with southern hemisphere. + echo "Will now use less(1): 'q' = quit, space = next page, enter = next line." 1>&2 + echo "We now recommend that you try holding enter down." 1>&2 + read -r -n 1 -p "Press any key to alternate between the southern/northern hemisphere Moon: " + echo 1>&2 + ( ./"$NATORI.alt"; ./"$NATORI" ; ./"$NATORI.alt" ; ./"$NATORI"; \ + ./"$NATORI.alt"; ./"$NATORI" ) | less -rEXF + + echo 1>&2 + +} + +# show the Moon phase in artistic ways! +moon diff --git a/2000/natori/try.sh b/2000/natori/try.sh index e3536cc23..e5b58237c 100755 --- a/2000/natori/try.sh +++ b/2000/natori/try.sh @@ -144,6 +144,17 @@ moon() ./"$NATORI.alt"; ./"$NATORI" ) | less -rEXF fi echo 1>&2 + + # Finally, for the try.sh (original entry, northern hemisphere), force + # starting with northern hemisphere. + echo "Will now use less(1): 'q' = quit, space = next page, enter = next line." 1>&2 + echo "We now recommend that you try holding enter down." 1>&2 + read -r -n 1 -p "Press any key to alternate between the northern/southern hemisphere Moon: " + echo 1>&2 + ( ./"$NATORI"; ./"$NATORI.alt" ; ./"$NATORI" ; ./"$NATORI.alt"; \ + ./"$NATORI"; ./"$NATORI.alt" ) | less -rEXF + + echo 1>&2 } # show the Moon phase in artistic ways! diff --git a/thanks-for-help.md b/thanks-for-help.md index 149d21e13..d0543f890 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -2534,8 +2534,12 @@ segfault when run or not compile at all (gcc and clang respectively). Cody also provided alternate code that supports the southern hemisphere. -Cody also provided the [try.sh](/2000/natori/try.sh) script that shows the Moon -phase in artistic ways. +Cody also provided the [try.sh](/2000/natori/try.sh) and +[try.alt.sh](/2000/natori/try.alt.sh) scripts that show the Moon phase in +artistic ways. It is recommended one try both a number of times in a row on +different days (that is run `./try.sh` several times in a row a few days apart, +until you see all the Moon phases, and run `./try.alt.sh` a few times in a row a +few days apart, until you see all the Moon phases). Later on Cody restored the `#include`s in the source code which had been changed by us to make it a one-liner again but this was an error as it was not a