Merge pull request #395 from xexyl/1998-schnitzi

This commit is contained in:
Landon Curt Noll authored and GitHub committed 2023-04-10 15:54:10 -07:00
commit 9ce789f4a6
3 files changed
+50 -45

No files matched your search

+47 -34
View File
@@ -1,47 +1,56 @@
# Best Flow Control: # Best Flow Control
Mark Schnitzius Mark Schnitzius
ISX Corporation ISX Corporation
1280 West Peachtree St. Apt. 1507 1280 West Peachtree St. Apt. 1507
Atlanta, GA 30309 Atlanta, GA 30309
USA USA
<http://computronium.org/ioccc.html>
http://east.isx.com/~schnitzi/
## To build: ## To build:
make all ```sh
make all
```
## To run ## To run:
./schnitzi 5 > sort.c ```sh
make sort ./schnitzi 5 > sort.c
make sort
```
## Try: ## Try:
./schnitzi 3 > sort.c ```sh
make sort ./schnitzi 3 > sort.c
echo 123 > data make sort
echo 234 >> data echo 123 > data
echo 413 >> data echo 234 >> data
echo 134 >> data echo 413 >> data
echo 324 >> data echo 134 >> data
./sort < data echo 324 >> data
./sort < data
```
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed invalid data [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed invalid data
types which prevented this entry from working. There are two other segfaults types which prevented this entry from working, causing a segfault. This showed
that should not be fixed and they are discussed in [bugs.md](/bugs.md). Thank itself in two parts which required two fixes, one for linux and further changes
you Cody for your assistance! for macOS. He also fixed a segfault (after printing garbage) when the arg
specified evaluated to 0. Thank you Cody for your assistance!
NOTE: the larger the number the number of lines of output can become ### INABIAF - it's not a bug it's a feature
substantially higher as well. Doing `./schnitzi 9` will actually print 771999
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! lines!
## Judges' comments ## Judges' remarks:
This is a beautiful program. How can a program with no conditional This is a beautiful program. How can a program with no conditional (except for
behavior at all have output which depends on anything? the fixes for modern systems made by Cody) behavior at all have output which
depends on anything?
For hints on deciphering this, see below past the Author's Comments; For hints on deciphering this, see below past the Author's Comments;
they're a nice summary, but they leave the mystery intact. they're a nice summary, but they leave the mystery intact.
@@ -52,7 +61,7 @@ letter E in the story. He did not note this but it has over 50000 (50 thousand)
(!!) words without the letter E which is one of the most common letters! (!!) words without the letter E which is one of the most common letters!
## Author's comments ## Author's remarks:
In literary circles, there is a poetic form called a "lipogram", In literary circles, there is a poetic form called a "lipogram",
which is a poem in which a specific letter has been distinctly which is a poem in which a specific letter has been distinctly
@@ -87,15 +96,19 @@ a depth of one.
So what does it do? Give it an integer (1 < n < 27) on the command So what does it do? Give it an integer (1 < n < 27) on the command
line, such as line, such as
./schnitzi 5 ```sh
./schnitzi 5
```
The output will itself be a lipographic program, one which inputs The output will itself be a lipographic program, one which inputs
(in this case) five numbers and prints them out sorted. It sorts (in this case) five numbers and prints them out sorted. It sorts
them, however, using only "if/else" statements, without arrays or them, however, using only "if/else" statements, without arrays or
looping. To see the resulting program run, redirect the output from looping. To see the resulting program run, redirect the output from
"schnitzi" into another file, like this `schnitzi` into another file, like this
schnitzi 4 > sort.c ```sh
schnitzi 4 > sort.c
```
and then compile it. and then compile it.
@@ -105,10 +118,10 @@ The big key to this program is figuring out what the names of the
functions ought to be; a bit of research may allow you to guess at functions ought to be; a bit of research may allow you to guess at
a few crucial ones. a few crucial ones.
The only function ever called is "O", but "O" is just set to point to The only function ever called is `O`, but `O` is just set to point to
other functions all the time. Or, almost all the time. other functions all the time. Or, almost all the time.
So how does 'h' get set, and what to? So how does `h` get set, and what to?
## Copyright and CC BY-SA 4.0 License: ## Copyright and CC BY-SA 4.0 License:
+3 -2
View File
@@ -52,5 +52,6 @@ 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 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 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; } void r_(){ O=_b; _=x[17]; s=(char**)_d; s=s+1; i=*s; q=0; }
main(int v,char **V){ O=r_; _d=V; main(int v,char **V){ if (V[1]) {if(atoi(V[1])!=0) {
x: (O)(); goto x; } q=0; O=r_; _d=V;
x: (O)(); goto x; }}}
-9
View File
@@ -764,15 +764,6 @@ $ ./schnitzi 9|wc -l
771999 771999
``` ```
There are two segfaults that were initially fixed but the fixes were undone to
make the entry as close to possible as the original. These should not be fixed
either:
- if one does not specify an arg the program will crash.
- if the arg had any characters that were not digits 1 - 9 it will show invalid
output and then crash. If it starts with 0 it can work as long as another digit
follows it and there are no other non-digits.
# 1999 # 1999