Improve fixes to 1998/schnitzi

The author stated that there was no 'if's and I have made it that way
now.

The author stated that the number should be > 0 && < 27 so I added the
range check (was previously != 0). Too high value could segfault and < 0
was problematic too. 27 itself was code that could not compile. Since
the program is so beautiful it had been decided to fix the problems
which is why these changes were added too.

The above was done like:

    ((V[1]&&((atoi(V[1])>0&&atoi(V[1])<27)||(exit(1),1))));

The try.sh script has been added to the entry to try out a lot of
commands instead of copy pasting it from the judges' remarks.

Removed duplicate INABIAF information from README.md (which is why the
other updates).

Updated bugs.md with more information to the features like how output
can end up being gigabytes in length depending on the number specified
to the program. Removed from the bugs.md details about warnings to
ignore as the compiler -Wno- options take care of that now. Extra
parentheses were added to the above to prevent another warning (I was
not sure if all compilers and versions had the -Wno- so I decided to fix
it in the code itself).

The try section has a question to ponder as well. The detail is also in
the bugs.md file.
This commit is contained in:
Cody Boone Ferguson committed 2023-11-02 09:53:57 -07:00
1 parent 723df90fa3
commit 459fff8859
6 files changed
+120 -48

No files matched your search

+1 -1
View File
@@ -40,7 +40,7 @@ include ../../var.mk
#
CSILENCE= -Wno-error -Wno-implicit-function-declaration -Wno-format-security \
-Wno-int-to-pointer-cast -Wno-int-conversion -Wno-unused-parameter \
-Wno-incompatible-pointer-types
-Wno-incompatible-pointer-types -Wno-implicit-int -Wno-unused-value
# Common C compiler warning flags
#
+22 -19
View File
@@ -1,9 +1,6 @@
# Best Flow Control
Mark Schnitzius
ISX Corporation
1280 West Peachtree St. Apt. 1507
Atlanta, GA 30309
US
<http://computronium.org/ioccc.html>
@@ -29,29 +26,35 @@ For more detailed information see [1998 schnitzi in bugs.md](/bugs.md#1998-schni
## To use:
```sh
./schnitzi 5 > sort.c
./schnitzi n > sort.c
make sort
./sort
# enter three numbers, space separated
echo x y z | ./sort
```
where `n` and `x`, `y` and `z` are numbers.
## Try:
```sh
./schnitzi 3 > sort.c
make sort
echo 123 > data
echo 234 >> data
echo 413 >> data
echo 134 >> data
echo 324 >> data
./sort < data
./try.sh
```
### INABIAF - it's not a bug it's a feature :-)
What happens if at the command line you don't specify `n` numbers that the
program expects? For instance try:
NOTE: the larger the number given to the program the longer the output becomes
and quite substantially so. Doing `./schnitzi 9` will actually print 771999
lines!
```sh
./schnitzi 5 > sort.c
make sort
# try running the next command four or five times:
echo 2 5 3 1 | ./sort
```
Why does this happen?
## Judges' remarks:
@@ -81,9 +84,9 @@ the letter 'e'.
The IOCCC has been no stranger to this concept. Several winning entries from
years past have accomplished interesting feats while completely avoiding the use
of certain C constructs thought to be essential (e.g. 1988's
[robison.c](//1988/robison/robison.c)). If you have to ask why they would do it
this way, then this contest just isn't for you.
of certain C constructs thought to be essential (e.g.
[1988/robison.c](/1988/robison/robison.c)). If you have to ask why they would
do it this way, then this contest just isn't for you.
In continuing with this fine tradition, this program suggests to the ANSI
committee some new practical simplifications for the C language. For instance,
+4 -2
View File
@@ -52,6 +52,8 @@ void x_(){ O=g; *r=y[k-2]; _=r; j=o_; }
void d (){ O=g; *r=y[k]; _=r; k=k+1; m=k<z; w=_t; l=p_; j=p; }
void y_(){ O=g; *r=x[17][1]+k; _=r; j=q_; }
void r_(){ O=_b; _=x[17]; s=(char**)_d; s=s+1; i=*s; q=0; }
main(int v,char **V){ if (V[1]) {if(atoi(V[1])!=0) {
main(int v,char **V){
((V[1]&&((atoi(V[1])>0&&atoi(V[1])<27)||(exit(1),1))));
q=0; O=r_; _d=V;
x: (O)(); goto x; }}}
x: (O)(); goto x; }
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
make all || exit 1
echo "$ ./schnitzi 3 > sort.c" 1>&2
./schnitzi 3 > sort.c
echo "Compiling sort.c:" 1>&2
make sort >/dev/null || exit 1
echo "...built sort." 1>&2
echo "Creating data:" 1>&2
echo "$ echo 234 > data" 1>&2
echo 234 > data
echo "$ echo 413 >> data" 1>&2
echo 413 >> data
echo "$ echo 123 >> data" 1>&2
echo 123 >> data
echo "Sorting data:" 1>&2
echo "$ ./sort < data" 1>&2
./sort < data
echo 1>&2
echo "Using stdin/stdout:" 1>&2
echo "$ echo 10 7 9 | ./sort" 1>&2
echo "10 7 9" | ./sort
echo "$ ./schnitzi 5 > sort.c" 1>&2
./schnitzi 5 > sort.c
echo "Compiling sort.c:" 1>&2
make sort >/dev/null || exit 1
echo "...built sort." 1>&2
echo "Creating data:" 1>&2
echo "$ echo 124 > data" 1>&2
echo 124 > data
echo "$ echo 422 >> data" 1>&2
echo 422 >> data
echo "$ echo 120 >> data" 1>&2
echo 120 >> data
echo "$ echo 100 >> data" 1>&2
echo 100 >> data
echo "$ echo 777 >> data" 1>&2
echo 777 >> data
echo "Sorting data:" 1>&2
echo "$ ./sort < data" 1>&2
./sort < data
echo 1>&2
echo "Using stdin/stdout:" 1>&2
echo "$ echo 5 10 7 9 1 | ./sort" 1>&2
echo "5 10 7 9 1" | ./sort