From eb1bed18bb135437c09f449e0730e6ecde3f7851 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 14 Nov 2023 10:10:44 -0800 Subject: [PATCH] Add 2000/primenum/try.sh + format/typo checks --- 2000/primenum/README.md | 7 ++++--- 2000/primenum/try.sh | 34 ++++++++++++++++++++++++++++++++++ thanks-for-fixes.md | 2 ++ 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100755 2000/primenum/try.sh diff --git a/2000/primenum/README.md b/2000/primenum/README.md index 409002cd2..f571ad955 100644 --- a/2000/primenum/README.md +++ b/2000/primenum/README.md @@ -29,7 +29,7 @@ NOTE: `n` is an integer. ### Try: ```sh -echo IOCCC 23209 | ./primenum 23209 +./try.sh ``` @@ -45,6 +45,7 @@ it successfully fooled half of the judges, including me. ## Author's remarks: + ### Description For 15 years, IOCCC winners have obfuscated programs using esoteric, @@ -61,8 +62,8 @@ syntax "mistakes" (e.g. `LessThanOrEqualTo`) and blatant "errors" (e.g. `Zero`). This program clearly requires "debugging." As a result of these "bugs", the program does not calculate primes at all. -Instead, the program reads input from stdin and returns garbled text on -stdout. Fortunately, you can recover the original message simply by +Instead, the program reads input from `stdin` and returns garbled text on +`stdout`. Fortunately, you can recover the original message simply by running the program a second time. Try: ```sh diff --git a/2000/primenum/try.sh b/2000/primenum/try.sh new file mode 100755 index 000000000..46772a117 --- /dev/null +++ b/2000/primenum/try.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2000/primenum +# + +# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it +# this way allows us to have the user specify a different compiler in an easy +# way. +if [[ -z "$CC" ]]; then + CC="cc" +fi + +make CC="$CC" all >/dev/null || exit 1 + +# clear screen after compilation so that only the entry is shown +clear + + +echo "$ echo IOCCC 23209 | ./primenum 23209" 1>&2 +echo IOCCC 23209 | ./primenum 23209 +echo 1>&2 + +echo "$ echo THIS MESSAGE IS IN ALL CAPS | ./primenum 32" 1>&2 +echo THIS MESSAGE IS IN ALL CAPS | ./primenum 32 +echo 1>&2 + +rm -f try.sh.txt +echo "$ ./primenum 101 < try.sh | ./primenum n > try.sh.txt" 1>&2 +./primenum 101 < try.sh | ./primenum n > try.sh.txt +echo "$ diff try.sh try.sh.txt" +read -r -n 1 -p "Press any key to see diff (through less): " 1>&2 +diff try.sh try.sh.txt|less + + diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 78039e4e1..ba8a1fb13 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -2296,6 +2296,8 @@ like the original entry but with the two fixes. Cody made this more portable by changing the `void main` to `int main`. +Cody also added the [try.sh](2000/primenum/try.sh) script. + ## [2000/rince](2000/rince/rince.c) ([README.md](2000/rince/README.md]))