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.
This commit is contained in:
Cody Boone Ferguson committed 2023-11-18 11:34:45 -08:00
1 parent 8236f9ac54
commit 9d6c5c0a4c
10 files changed
+90 -9

No files matched your search

+13 -6
View File
@@ -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
+6
View File
@@ -0,0 +1,6 @@
### #
# ####
# # #
# # #
### ###
+5
View File
@@ -0,0 +1,5 @@
# #
# #
# #
# #
+10
View File
@@ -0,0 +1,10 @@
####
######
## ##
## ##
####
## ##
## ##
######
####
+4
View File
@@ -0,0 +1,4 @@
#####
# # #
#####
+6
View File
@@ -0,0 +1,6 @@
#
# #
#
# #
#
+6
View File
@@ -0,0 +1,6 @@
###
# #
###
#
###
+8
View File
@@ -0,0 +1,8 @@
####
######
## ##
### ###
##########
## ##
## ##
+24
View File
@@ -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
+8 -3
View File
@@ -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]))