Merge pull request #1559 from xexyl/kopczynski2004-main

This commit is contained in:
Landon Curt Noll authored and GitHub committed 2023-11-26 00:49:06 -07:00
commit 8b07693dc1
18 files changed
+164 -63

No files matched your search

+1 -1
View File
@@ -60,7 +60,7 @@ ARCH=
#
CDEFINE= -Dc='n*n>x?p:((m=*(b+1)),N))' \
-DN='((b=t+1),x+=2,x>e?exit(0):o' \
-Dp='(a-t<o?*(a++)=x:47),printf("%d ",x),N)'
-Dp='(a-t<o?*(a++)=x:47),printf("%d\n",x),N)'
# Include files that are needed to compile
#
+22 -3
View File
@@ -4,6 +4,9 @@
make all
```
There is an alternate version that uses more memory. See [alternate
code](#alternate-code) below.
## To use:
@@ -12,14 +15,30 @@ make all
```
### Try:
```sh
./weisberg | head -n 15
```
## Alternate code:
If you liked what you saw from the above program, and happen to
have some 512 Megabytes of virtual memory lying around with to do,
you could try:
have some 512 Megabytes of virtual memory lying around with to do
something with you might try this version.
### Alternate build:
```sh
make alt
```
### Alternate use:
```sh
make weisberg.alt
./weisberg.alt
```
+5 -5
View File
@@ -8,13 +8,13 @@ char*u0="<RET> to begin... ",*u1="Already been here!",*u2="Found a wall! \
",*u3="Walking... ",*u4="Finished. ",*u5="Going back..\
. ",*o="\033[23;1HDone!!\n",*x="\033[2J",*y="\033[1;1H",*z="\033[%d;%\
dH%c",*w="\033[1;1H%s",*v="\033[%d;%dH%c\033[%d;%dH%c\033[%d;%dH%c",b[1841
];int c,d,e,f,g;typedef int(*h)();h i,k,l,m,n;rand(
),time(),getchar();int main(int a){k=rand,l=time,m=getchar,
];int c,d,e,f,g;typedef int(*h)();h i,k,l,m;int(*n)(int,char**);rand(
),time(),getchar();int main(int a,char**j){k=rand,l=time,m=getchar,
n=main;if(!c)for(srand(l(0)),g=a=1000,--d;++d<1840;b[c=d]=" #\n"[d%80==79?2:d/80
&&d%80&&d/80-22&&d%80-78]);if(!(c-1839))++c,printf("%s%s%s",x,y,b);k:if(!(c-1840)
&&(b[a+2]+b[a-2]+b[a+160]+b[a-160]-4*' ')){while(b[a+(f=(e=k()%4)?e-1?e-2?-1
:1:-80:80)*2]!='#');b[a]=b[a+f]=b[f+a+f]=' ';printf(v,a/80+1,1+a%80,' ',(a+f)/80+
1,1+(a+f)%80,' ',(f+a+f)/80+1,1+(f+a+f)%80,' ');n(f+a+f);goto k;}else if(!(g
1,1+(a+f)%80,' ',(f+a+f)/80+1,1+(f+a+f)%80,' ');n(f+a+f,0);goto k;}else if(!(g
-a))c=1,a=162,printf(w,u0),m();if(c-1){}else r b[a]!=' '?(usleep(Z),printf(w,b[a]=='.'?u1:u2),0)
:(b[a]='.',printf(w,u3),printf(z,a/80+1,1+a%80,'.'),a==1676?(printf(w,u4),printf(o),1):n(a+1)||n
(a+80)||n(a-80)||n(a-1)?1:(b[a]=' ',printf(w,u5),printf(z,a/80+1,1+a%80,' '),0));r 0;}
:(b[a]='.',printf(w,u3),printf(z,a/80+1,1+a%80,'.'),a==1676?(printf(w,u4),printf(o),1):n(a+1,0)||n
(a+80,0)||n(a-80,0)||n(a-1,0)?1:(b[a]=' ',printf(w,u5),printf(z,a/80+1,1+a%80,' '),0));r 0;}
+5 -5
View File
@@ -4,13 +4,13 @@ char*u0="<RET> to begin... ",*u1="Already been here!",*u2="Found a wall! \
",*u3="Walking... ",*u4="Finished. ",*u5="Going back..\
. ",*o="\033[23;1HDone!!\n",*x="\033[2J",*y="\033[1;1H",*z="\033[%d;%\
dH%c",*w="\033[1;1H%s",*v="\033[%d;%dH%c\033[%d;%dH%c\033[%d;%dH%c",b[1841
];int c,d,e,f,g;typedef int(*h)();h i,k,l,m,n;rand(
),time(),getchar();int main(int a){k=rand,l=time,m=getchar,
];int c,d,e,f,g;typedef int(*h)();h i,k,l,m;int(*n)(int,char**);rand(
),time(),getchar();int main(int a,char**j){k=rand,l=time,m=getchar,
n=main;if(!c)for(srand(l(0)),g=a=1000,--d;++d<1840;b[c=d]=" #\n"[d%80==79?2:d/80
&&d%80&&d/80-22&&d%80-78]);if(!(c-1839))++c,printf("%s%s%s",x,y,b);k:if(!(c-1840)
&&(b[a+2]+b[a-2]+b[a+160]+b[a-160]-4*' ')){while(b[a+(f=(e=k()%4)?e-1?e-2?-1
:1:-80:80)*2]!='#');b[a]=b[a+f]=b[f+a+f]=' ';printf(v,a/80+1,1+a%80,' ',(a+f)/80+
1,1+(a+f)%80,' ',(f+a+f)/80+1,1+(f+a+f)%80,' ');n(f+a+f);goto k;}else if(!(g
1,1+(a+f)%80,' ',(f+a+f)/80+1,1+(f+a+f)%80,' ');n(f+a+f,0);goto k;}else if(!(g
-a))c=1,a=162,printf(w,u0),m();if(c-1){}else r b[a]!=' '?(printf(w,b[a]=='.'?u1:u2),0)
:(b[a]='.',printf(w,u3),printf(z,a/80+1,1+a%80,'.'),a==1676?(printf(w,u4),printf(o),1):n(a+1)||n
(a+80)||n(a-80)||n(a-1)?1:(b[a]=' ',printf(w,u5),printf(z,a/80+1,1+a%80,' '),0));r 0;}
:(b[a]='.',printf(w,u3),printf(z,a/80+1,1+a%80,'.'),a==1676?(printf(w,u4),printf(o),1):n(a+1,0)||n
(a+80,0)||n(a-80,0)||n(a-1,0)?1:(b[a]=' ',printf(w,u5),printf(z,a/80+1,1+a%80,' '),0));r 0;}
+2 -6
View File
@@ -15,9 +15,7 @@ make all
### Try:
```sh
./garry.test.sh
./garry < README.md
./try.sh
```
@@ -46,9 +44,7 @@ make alt
### Alternate try:
```sh
GARRY=garry.alt ./garry.test.sh
./garry.alt < README.md
./try.alt.sh
```
-13
View File
@@ -1,13 +0,0 @@
#!/usr/bin/env sh
#
# garry.alt.test.sh - example of how to use garry.alt
EXAMPLEON="\33\133\61\73\67\155"
EXAMPLEOFF="\33\133\155"
DOLLAR="$"
export EXAMPLEON EXAMPLEOFF DOLLAR
# make sure alt code is built, first
make alt || exit 1
./garry.alt <garry.data
-13
View File
@@ -1,13 +0,0 @@
#!/usr/bin/env sh
#
# garry.test.sh - example of how to use garry
EXAMPLEON="\33\133\61\73\67\155"
EXAMPLEOFF="\33\133\155"
DOLLAR="$"
export EXAMPLEON EXAMPLEOFF DOLLAR
# make sure code is built, first
make all || exit 1
./garry <garry.data
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env sh
#
# try.alt.sh - demonstrate IOCCC winner 1995/garry alt code
#
# 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" alt >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
echo "$ EXAMPLEON=\"\33\133\61\73\67\155\"; EXAMPLEOFF=\"\33\133\155\"; DOLLAR=\"$\"" 1>&2
EXAMPLEON="\33\133\61\73\67\155"
EXAMPLEOFF="\33\133\155"
DOLLAR="$"
export EXAMPLEON EXAMPLEOFF DOLLAR
read -r -n 1 -p "Press any key to run: ./garry.alt < garry.data | less (q = quit, space = next page): "
./garry.alt <garry.data | less -r -X
echo 1>&2
read -r -n 1 -p "Press any key to run: ./garry.alt < README.md | less (q = quit, space = next page): "
./garry.alt < README.md | less -X
+31
View File
@@ -0,0 +1,31 @@
#!/usr/bin/env sh
#
# try.sh - demonstrate IOCCC winner 1995/garry
#
# 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 "$ EXAMPLEON=\"\33\133\61\73\67\155\"; EXAMPLEOFF=\"\33\133\155\"; DOLLAR=\"$\"" 1>&2
EXAMPLEON="\33\133\61\73\67\155"
EXAMPLEOFF="\33\133\155"
DOLLAR="$"
export EXAMPLEON EXAMPLEOFF DOLLAR
read -r -n 1 -p "Press any key to run: ./garry < garry.data | less (q = quit, space = next page): "
./garry <garry.data | less -r -X
echo 1>&2
read -r -n 1 -p "Press any key to run: ./garry < README.md | less (q = quit, space = next page): "
./garry < README.md | less -X
+1 -1
View File
@@ -1 +1 @@
main(h,m)int h;char**m;{if(h>4){for(time(*m);h/=2;);puts(m[4]);}}
main(h,m)char**m;{if(h>4){for(time(*m);h/=2;);puts(m[4]);}}
+1 -1
View File
@@ -23,7 +23,7 @@ char r[]="C#S3K+[;G'W7OB/_? ?
[48][3]={ { { 2} } } ; void**V,*D,*F[32][48];
void*Q(void**O){ return*O?(*O=Q(*O)):O; } U(
O){return E+=(O/=2)-1?U((A=A/2^57525273+(A&
1^O&1)*9583591<<5,O)),0:O,16; } main(O){ A
1^O&1)*9583591<<5,O)),0:O,16; } main(O,S)char**S;{ A
=O?time(D):953351751; z I=0; I<26; ++I){z
N=I/2; N<30+I/2; ++N){ z M=0; M<3; ++M){
p Z=O)z; (B=I+Z*!!M) <26&&N+Z*(M!=2)-B/
+2 -1
View File
@@ -1,6 +1,7 @@
#define i int
#define n struct n
#define T , char **C) { return (
#define x ){ return (
#define A ->
#define N n*
@@ -56,7 +57,7 @@ i j k c ? O U r u U U X : y b k y d k y
#define b(b) ( ( b a d
#define E(E) b ( M E u X )
main k i ) ! (
main ( i c T
#define I b ( m I u X )
#define J b ( m J u X )
+1 -1
View File
@@ -9,7 +9,7 @@ static volatile sig_atomic_t One;
in??/
t
#line 10 ONE(O(1,1,2,6,0,6))
main (register zero, char **ONE)
main (register int zero, char **ONE)
%:
<% switch (sizeof __FILE__ < zero) case 1: return One /= zero;
{ auto one = zero = atoi (ONE<:zero-1:>);
+1 -1
View File
@@ -77,7 +77,7 @@ i-3; w =e+s+1; l=q+N* (j-1)- j*(j-1 )/ 2 ; do{ *
2; } } M5(q); } Z M2 P(t*p ){ H p){ P(p _ R); H p _ c>1){ M1 i=0
; f*l= p _ l; for (; i< p _ c; ++i ){ A[i
]= l _ n; l=l _ x; } C (p _ s, p _ c); } P (p _
L) ; } } int main V { t*r= 0; I F ; for (; ; )
L) ; } } int main (M7,M6)I*M6; { t*r= 0; I F ; for (; ; )
{ H!(F U 1024)) )X H ! fgets( F,1024 ,stdin) )break; *(F+(y
=strlen(F))-1)= 0; H!( F=M3(F, y)))X H stat(F,&S)==0 &&S_ISREG(S.
st_mode)&&S O )r=J(r ,F ); } H r)P(r ); u 0; }/* Obfuscated C
+1 -1
View File
@@ -53,7 +53,7 @@ i-3; w =e+s+1; l=q+N* (j-1)- j*(j-1 )/ 2 ; do{ *
2; } } M5(q); } Z M2 P(t*p ){ H p){ P(p _ R); H p _ c>1){ M1 i=0
; f*l= p _ l; for (; i< p _ c; ++i ){ A[i
]= l _ n; l=l _ x; } C (p _ s, p _ c); } P (p _
L) ; } } int main V { t*r= 0; I F ; for (; ; )
L) ; } } int main (M7,M6)I*M6; { t*r= 0; I F ; for (; ; )
{ H!(F U 1024)) )X H ! fgets( F,1024 ,stdin) )break; *(F+(y
=strlen(F))-1)= 0; H!( F=M3(F, y)))X H stat(F,&S)==0 &&S_ISREG(S.
st_mode)&&S O )r=J(r ,F ); } H r)P(r ); u 0; }/* Obfuscated C
+1 -1
View File
@@ -1 +1 @@
main(O){int I,Q,l=O;if(I=l*4){l=6;if(l>5)l+=Q-8?l-(Q=getchar()-2)%2:l;if(Q*=2)O+="has dirtiest IF"[(I/-Q&12)-l/Q%4];}printf("%d\n",8+O%4);}
main(O,S)char**S;{int I,Q,l=O;if(I=l*4){l=6;if(l>5)l+=Q-8?l-(Q=getchar()-2)%2:l;if(Q*=2)O+="has dirtiest IF"[(I/-Q&12)-l/Q%4];}printf("%d\n",8+O%4);}
+56 -9
View File
@@ -1780,6 +1780,13 @@ more like the original entry this was done in the Makefile.
Note that the alt code does not use `fgets(3)` but rather `gets(3)`.
## [1994/weisberg](1994/weisberg/weisberg.c) ([README.md](1994/weisberg/README.md]))
Cody changed the Makefile to make this program more user friendly and easier to
use with other tools as well by making the program output not a space after each
number but rather a newline.
## [1994/westley](1994/westley/westley.c) ([README.md](1994/westley/README.md]))
Cody converted the spoiler compiler options (provided by the author) to be
@@ -1801,6 +1808,13 @@ particular to make it easier to see the program do what it does in systems that
are too fast ... if there is such a thing anyway :-) ). See the README.md for
details on this.
Out of an abundance of caution with clang, Cody also added a second arg to
`main()` as some versions of clang whine about the number of args on top of the
type of args. In particular some versions supposedly only allow 0, 2 or 3 args.
It actually appears to allow 1 but if you specify 4 it says 0, 2 or 3 and it is
an error but it's entirely possible that they will eventually make the defect
function as the error message claims.
## [1995/dodsond1](1995/dodsond1/dodsond1.c) ([README.md](1995/dodsond1/README.md]))
@@ -1820,15 +1834,15 @@ problem was a missing `int` for the `f` variable. He felt it was even more
important that it works because the layout does indeed look to him like a rat is
dropping core :-), something that the judges suggested.
Cody also improved the script [garry.test.sh](1995/garry/garry.test.sh) to make
sure the program is compiled before trying to use it and he also added the
[garry.alt.test.sh](1995/garry/garry.alt.test.sh) script to use the alt version,
Cody also renamed `garry.test.sh` to [try.sh](1995/garrytry.sh) and improved it
to to make sure the program is compiled before trying to use it and he also
added the [try.alt.sh](1995/garry/try.alt.sh) script to use the alt version,
though the alt version is not as important as alt code in other entries.
The reason the alt script was added rather than using an environmental variable
to specify which one to use is to make it easier on the user as typing
`GARRY=garry.alt ./garry.test.sh` is not as simple (even though simple) as just
running `./garry.alt.test.sh`.
`GARRY=garry.alt ./try.sh` is not as simple (even though simple) as just
running `./try.alt.sh`.
## [1995/leo](1995/leo/leo.c) ([README.md](1995/leo/README.md]))
@@ -1841,7 +1855,7 @@ by the author, putting it in [spoiler1.md](1995/leo/spoiler1.md).
Cody fixed this so that it will compile with versions of clang that has a defect
which only allows `main()` to have 0, 2 or 3 args. This is done by a new
function (`pain()` as it's annoying that clang is this way :-) ) that main()
function (`pain()` as it's annoying that clang is this way :-) ) that `main()`
calls which has the four args.
@@ -1965,6 +1979,9 @@ clocks, both with the fixed version and the original (alt) version.
Also, to fix any potential problem with displaying in GitHub the scripts
provided by the author, Cody added '.sh'.
Later Cody made the entry look more like the original, removing the `argc` in
`main()` (K&R style functions).
# <a name="1998"></a>1998
@@ -1979,6 +1996,16 @@ they do have page up and page down but this gives a default for those who don't
have them like with Macs.
## [1998/bas1](1998/bas1/bas1.c) ([README.md](1998/bas1/README.md]))
Cody, out of an abundance of caution, added a second arg to `main()` as some
versions of clang whine about the number of args on top of what type they are
In particular some versions claim that they only allow 0, 2 or 3 args. It
appears that they do allow 1 but for instance 4 is not allowed. However as it's
quite possible they will 'fix' this defect it would be better to have this not
be a problem at such a time.
## [1998/bas2](1998/bas2/bas2.c) ([README.md](1998/bas2/README.md]))
Cody added the [try.sh](1998/bas2/try.sh) script which runs some default actions
@@ -1997,9 +2024,9 @@ Cody changed a `int *` used for `fopen(3)` to be a `FILE *` to be more correct
and prevent any possible problems in some systems (which has happened).
Cody also made the fixed version look more like the original version by using
the old style of `main()` args so that it read `i,love_unix` more naturally, and
by changing the typedef `lint` (to `int` - see the code for why this has to be
done in modern systems) to be `_int`.
the old style of `main()` args so that it reads `i,love_unix` more naturally,
and by changing the typedef `lint` (to `int` - see the code for why this has to
be done in modern systems) to be `_int`.
## [1998/dlowe](1998/dlowe/dlowe.c) ([README.md](1998/dlowe/README.md]))
@@ -2035,6 +2062,13 @@ final code that is compiled. The code is now what it essentially becomes when
processed completely. The intermediate steps can now be performed to see how it
expands but it can still compile and be used.
Cody also added a second arg to `main()` out of an abundance of caution as some
versions of clang whine about the number of args to `main()`. These versions
claim that only 0, 2 or 3 are allowed but it does allow 1 anyway. It is quite
possible though that this will change so it is fixed in case this happens. As it
is mostly just through the C pre-processor Cody added a new macro to do
translate to the rest of `main()`'s args.
Cody also added the [try.sh](1998/fanf/try.sh) script to show the output of some
of the expressions that we selected.
@@ -2138,6 +2172,10 @@ interesting historical explanation and further details and fun, see the
[historical remarks](1998/schweikh2/README.md#historical-remarks) in the
README.md.
Cody also added an `int` after `register` in `main()` in case clang decides to
have a problem with that in the future which is not entirely out of the
question.
## [1998/schweikh3](1998/schweikh3/schweikh3.c) ([README.md](1998/schweikh3/README.md]))
@@ -2145,6 +2183,11 @@ Cody added the [alternate code](1998/schweikh3/README.md#alternate-code) which a
to reconfigure the size constant in the rare case that the author wrote about
occurs.
Cody made `main()` have two args out of an abundance of caution as some versions
of clang say that `main()` can only have 0, 2 or 3 args. These versions accept 1
arg but it is entirely possible that they fix this so this should prevent it
from breaking if that happens.
Cody added the [try.sh](1998/schweikh3/try.sh) script to make it easier to try
the commands that we suggested. One command was not added, that of the to use
command.
@@ -2707,6 +2750,10 @@ Finally Cody added [try.sh](2004/jdalbec/try.sh) and
Cody reported that this entry cannot be optimised by the compiler as otherwise
it will not work.
Cody, out of an abundance of caution for clang, added a second arg to `main()`
as some versions complain about the number of args and although they accept 1 it
is entirely possible it will eventually be that they don't.
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
+4 -1
View File
@@ -1,5 +1,5 @@
# A todo list of known things to check and/or do
*Last updated: Wed 22 Nov 2023 13:02:04 UTC*
*Last updated: Sat 25 Nov 2023 19:01:07 UTC*
This document is primarily for [Cody Boone
Ferguson](/winners.html#Cody_Boone_Ferguson) as he (that is I :-) ) wanted a way
@@ -157,3 +157,6 @@ make it consistent and easy to remember.
going too fast we should say not what it looks like in modern systems but rather
what it LOOKED LIKE AT THE TIME. At Wed 22 Nov 2023 13:02:04 UTC the only entry
that has had this done is [1985/lycklama](1985/lycklama/README.md).
- Check 2001/westley for making `main()` have two args. Easy to make it have two
args but harder to make it function right.