Add 2000/primenum/try.sh + format/typo checks

This commit is contained in:
Cody Boone Ferguson committed 2023-11-14 10:10:44 -08:00
1 parent 4cb76ef506
commit eb1bed18bb
3 files changed
+40 -3

No files matched your search

+4 -3
View File
@@ -29,7 +29,7 @@ NOTE: `n` is an integer.
### Try: ### Try:
```sh ```sh
echo IOCCC 23209 | ./primenum 23209 ./try.sh
``` ```
@@ -45,6 +45,7 @@ it successfully fooled half of the judges, including me.
## Author's remarks: ## Author's remarks:
### Description ### Description
For 15 years, IOCCC winners have obfuscated programs using esoteric, 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." `Zero`). This program clearly requires "debugging."
As a result of these "bugs", the program does not calculate primes at all. 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 Instead, the program reads input from `stdin` and returns garbled text on
stdout. Fortunately, you can recover the original message simply by `stdout`. Fortunately, you can recover the original message simply by
running the program a second time. Try: running the program a second time. Try:
```sh ```sh
+34
View File
@@ -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
+2
View File
@@ -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 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])) ## [2000/rince](2000/rince/rince.c) ([README.md](2000/rince/README.md]))