From 9d6c5c0a4c4adec7549b78946db37cf5df0f9a41 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sat, 18 Nov 2023 11:22:34 -0800 Subject: [PATCH] Add 2004/kopczynski/try.sh + data files Added try.sh. Add data files with reversed output of their respective file. I used rev(1) to make these but kopczynski-10-rev had to be modified a bit more to get it to work. Format/typo check README.md. --- 2004/kopczynski/README.md | 19 +++++++++++++------ 2004/kopczynski/kopczynski-10-rev | 6 ++++++ 2004/kopczynski/kopczynski-11-rev | 5 +++++ 2004/kopczynski/kopczynski-8a-rev | 10 ++++++++++ 2004/kopczynski/kopczynski-8b-rev | 4 ++++ 2004/kopczynski/kopczynski-8c-rev | 6 ++++++ 2004/kopczynski/kopczynski-9-rev | 6 ++++++ 2004/kopczynski/kopczynski-a-rev | 8 ++++++++ 2004/kopczynski/try.sh | 24 ++++++++++++++++++++++++ thanks-for-fixes.md | 11 ++++++++--- 10 files changed, 90 insertions(+), 9 deletions(-) create mode 100644 2004/kopczynski/kopczynski-10-rev create mode 100644 2004/kopczynski/kopczynski-11-rev create mode 100644 2004/kopczynski/kopczynski-8a-rev create mode 100644 2004/kopczynski/kopczynski-8b-rev create mode 100644 2004/kopczynski/kopczynski-8c-rev create mode 100644 2004/kopczynski/kopczynski-9-rev create mode 100644 2004/kopczynski/kopczynski-a-rev create mode 100755 2004/kopczynski/try.sh diff --git a/2004/kopczynski/README.md b/2004/kopczynski/README.md index e82f74f76..2ffcef98c 100644 --- a/2004/kopczynski/README.md +++ b/2004/kopczynski/README.md @@ -40,11 +40,15 @@ why? The judges modified the program to print its result. The original program returned the result as an exit code: +### Alternate build: + + ```sh make alt ``` -Then try: + +### Alternate try: ```sh ./kopczynski.alt < kopczynski-10 @@ -61,7 +65,7 @@ we have seen in years! Compile and run without arguments. As input, give it an ASCII graphics figure 8, 9, 10, or 11 made of pound signs and spaces, of any size, -shape, or orientation (that's right, an upside down 9 is still 9 :-). +shape, or orientation (that's right, an upside down 9 is still 9 :-) ). There is one restriction: the only line not containing "#" characters must be the last. @@ -92,7 +96,7 @@ just `$?`).) **NOTE: The judges altered the primary version to output a number.** -On the input, give numbers formed as a sequences of empty spaces and # +On the input, give numbers formed as a sequences of empty spaces and `#` signs (you can also use dots instead of spaces), ending with an empty line. (No number has an empty line in it.) The program should return the number from 8 to 11 that it thinks it is. @@ -121,7 +125,7 @@ lines). 1. This program works by calculating the [Euler characteristics](https://en.wikipedia.org/wiki/Euler_characteristic) of input, -plus 9. It is the number of digits (i.e. separated #-regions) minus the number +plus 9. It is the number of digits (i.e. separated `#`-regions) minus the number of holes in them. It turns out that this algorithm works correctly for all numbers from 8 to 11. @@ -178,10 +182,13 @@ routine also sets `n=8` in an obfuscated and concise way. 6. Since we always return the number from 8 to 11, we can calculate modulo 4. Instead of `16 {-1,0,+1}` values, we use a 15-character string which agrees -modulo 4 to the array in (`4`). (`NUL` fits very well as the 16th character, so +modulo 4 to the array in (`4`). (`'\0'` fits very well as the 16th character, so we use 15-character string.) -7. Since the rule found in (3) did not produce any funny messages, I changed it until it did. (The `#` character to find vertexes is in the top right corner, not the top left one.) The following messages will also work instead of `has dirtiest IF`: +7. Since the rule found in (3) did not produce any funny messages, I changed it +until it did. (The `#` character to find vertexes is in the top right corner, +not the top left one.) The following messages will also work instead of `has +dirtiest IF`: ``` HighlandYachter diff --git a/2004/kopczynski/kopczynski-10-rev b/2004/kopczynski/kopczynski-10-rev new file mode 100644 index 000000000..0604af4fb --- /dev/null +++ b/2004/kopczynski/kopczynski-10-rev @@ -0,0 +1,6 @@ +### # +# #### +# # # +# # # +### ### + diff --git a/2004/kopczynski/kopczynski-11-rev b/2004/kopczynski/kopczynski-11-rev new file mode 100644 index 000000000..6e5da3f61 --- /dev/null +++ b/2004/kopczynski/kopczynski-11-rev @@ -0,0 +1,5 @@ +# # +# # +# # +# # + diff --git a/2004/kopczynski/kopczynski-8a-rev b/2004/kopczynski/kopczynski-8a-rev new file mode 100644 index 000000000..d4a7529c2 --- /dev/null +++ b/2004/kopczynski/kopczynski-8a-rev @@ -0,0 +1,10 @@ +#### +###### +## ## +## ## +#### +## ## +## ## +###### +#### + diff --git a/2004/kopczynski/kopczynski-8b-rev b/2004/kopczynski/kopczynski-8b-rev new file mode 100644 index 000000000..59533a065 --- /dev/null +++ b/2004/kopczynski/kopczynski-8b-rev @@ -0,0 +1,4 @@ +##### +# # # +##### + diff --git a/2004/kopczynski/kopczynski-8c-rev b/2004/kopczynski/kopczynski-8c-rev new file mode 100644 index 000000000..aa150a734 --- /dev/null +++ b/2004/kopczynski/kopczynski-8c-rev @@ -0,0 +1,6 @@ +# +# # +# +# # +# + diff --git a/2004/kopczynski/kopczynski-9-rev b/2004/kopczynski/kopczynski-9-rev new file mode 100644 index 000000000..56b7ce5f6 --- /dev/null +++ b/2004/kopczynski/kopczynski-9-rev @@ -0,0 +1,6 @@ +### +# # +### +# +### + diff --git a/2004/kopczynski/kopczynski-a-rev b/2004/kopczynski/kopczynski-a-rev new file mode 100644 index 000000000..07a019895 --- /dev/null +++ b/2004/kopczynski/kopczynski-a-rev @@ -0,0 +1,8 @@ +#### +###### +## ## +### ### +########## +## ## +## ## + diff --git a/2004/kopczynski/try.sh b/2004/kopczynski/try.sh new file mode 100755 index 000000000..7bb122634 --- /dev/null +++ b/2004/kopczynski/try.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2004/kopczynski +# + +# 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 + +for f in kopczynski-{8{a,b,c},a,9{,-rev},10{,-rev},11{,-rev}}; do + echo "$ cat $f" 1>&2 + cat "$f" + read -r -n 1 -p "Press any key to continue: " + ./kopczynski < "$f" + echo "" 1>&2 +done diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index f927d0056..e18ba68e7 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -2738,9 +2738,14 @@ and various other problems. ## [2004/kopczynski](2004/kopczynski/kopczynski.c) ([README.md](2004/kopczynski/README.md])) -Cody reported that this entry cannot be optimised by the compiler if it's to -work. He also added the file [kopczynski-a](kopczynski-a) to demonstrate what -happens when art more like a letter is fed to the program. +Cody reported that this entry cannot be optimised by the compiler as otherwise +it will not work. + +Cody also added the [try.sh](2004/kopczynski/try.sh) script and various data +files: [kopczynski-a](kopczynski-a) to demonstrate what happens when art more +like a letter is fed to the program and the `kopczynski*-rev` files which are +the data files reversed with `rev(1)`. One had to be modified additionally to +get it to work, that being `kopczynski-10-rev`. ## [2004/newbern](2004/newbern/newbern.c) ([README.md](2004/newbern/README.md]))