Merge pull request #1174 from xexyl/1989-westley-alt
This commit is contained in:
29 files changed
+318
-120
No files matched your search
+1
-1
@@ -38,7 +38,7 @@ behaviour?
|
||||
./dale "$(printf "the following files exist in this directory:\n%s\n" *)"
|
||||
```
|
||||
|
||||
### Alternate code
|
||||
### Alternate code:
|
||||
|
||||
If you have an old enough compiler you can try the original version in
|
||||
[dale.alt.c](dale.alt.c). To use:
|
||||
|
||||
@@ -115,8 +115,8 @@ OBJ= ${PROG}.o
|
||||
DATA=
|
||||
TARGET= ${PROG}
|
||||
#
|
||||
ALT_OBJ= ver0.o ver1.o ver2.o ver3.o
|
||||
ALT_TARGET= ver0 ver1 ver2 ver3
|
||||
ALT_OBJ= ${PROG}.alt.o
|
||||
ALT_TARGET= ${PROG}.alt
|
||||
|
||||
|
||||
#################
|
||||
|
||||
+35
-8
@@ -10,9 +10,17 @@ US\
|
||||
make all
|
||||
```
|
||||
|
||||
### Bugs and (Mis)features
|
||||
|
||||
This entry a listed in [bugs.md](/bugs.md) as:
|
||||
|
||||
```
|
||||
STATUS: main() function args not allowed - please help us fix
|
||||
STATUS: known bug - please help us fix
|
||||
```
|
||||
|
||||
For more detailed information see [bugs.md](/bugs.md#1989westley-readmemd).
|
||||
|
||||
NOTE: this entry only partly works with clang and only some versions of clang,
|
||||
due to defects in the compiler. See [bugs.md](/bugs.md) for more details.
|
||||
|
||||
## Try:
|
||||
|
||||
@@ -51,20 +59,39 @@ Finally try:
|
||||
```sh
|
||||
./westley
|
||||
# input some lines of text, sending EOF (usually ctrl-d) to end
|
||||
|
||||
echo IOCCC | ./westley
|
||||
echo IOCCC | ./westley 1
|
||||
echo IOCCC | ./westley 1 2
|
||||
echo IOCCC | ./westley 1 2 3
|
||||
|
||||
echo IOCCC | ./ver0
|
||||
echo Version 1 | ./ver1
|
||||
echo Version 2 | ./ver2
|
||||
echo Version 3 | ./ver3
|
||||
```
|
||||
|
||||
## Alternate code:
|
||||
|
||||
### INAFIAB - it's not a feature it's a bug :-(
|
||||
The alternate code allows SOME of the features to work with clang but some of
|
||||
the code it generates (see [compile.sh](compile.sh), which does not use this
|
||||
version) is not compilable even in gcc let alone clang. Nevertheless the main
|
||||
feature should work for clang.
|
||||
|
||||
There might have been a segfault that was fixed in the original code but as we
|
||||
no longer know what condition or conditions caused this we cannot be sure. It
|
||||
seems like, according to various files, that `ver1` and/or `ver2` also have this
|
||||
problem but we also do not know about the status of this. See
|
||||
[bugs.md](/bugs.md) for more information.
|
||||
### To build:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
```
|
||||
|
||||
### Try:
|
||||
|
||||
```sh
|
||||
echo IOCCC | ./westley.alt
|
||||
echo IOCCC | ./westley.alt 1
|
||||
echo IOCCC | ./westley.alt 1 2
|
||||
echo IOCCC | ./westley.alt 1 2 3
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -13,9 +13,7 @@
|
||||
#
|
||||
# CC=/opt/local/bin/gcc-mp-12 ./compile.sh
|
||||
#
|
||||
# We sleep (by default) for approximately 1 second after each command so that
|
||||
# the you can read what is being done. If this is too fast you can change it in
|
||||
# a similar way to the above but using the variable DELAY like so:
|
||||
# If you wish to slow down the script you can use the DELAY variable like:
|
||||
#
|
||||
# DELAY=2 ./compile.sh
|
||||
#
|
||||
@@ -36,11 +34,11 @@ if [[ -z "$CC" ]]; then
|
||||
fi
|
||||
|
||||
# get sleep duration
|
||||
# we cannot use the form '${DELAY:=5}' because at least in some versions of bash
|
||||
# we cannot use the form '${DELAY:=0}' because at least in some versions of bash
|
||||
# it tries to invoke the command and obviously that won't work. Thus we check if
|
||||
# it's empty before setting the default.
|
||||
if [[ -z "$DELAY" ]]; then
|
||||
DELAY=2
|
||||
DELAY=0
|
||||
fi
|
||||
|
||||
# make clobber to make the directory clean and then compile westley which we
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
/**//*/};)/**/main(/*//**/tang ,gnat/**//*/,ABBA~,0-0(avnz;)0-0,tang,raeN
|
||||
,ABBA(niam&&)))2-]--tang-[kri - =raeN(&&0<)/*clerk*/,noon,raeN)char
|
||||
**gnat, **noon, **raeN;{int gn = gnat, ra = raeN, no = noon; (!tang&&
|
||||
no!=-1&&(gn&2)&&((raeN&&( getchar(no+0)))||(1-ra&&(trgpune(no
|
||||
)))))||tang&&znva(/*//**/tang ,tang,tang/**|**//*/((||)))0(enupgrt=raeN
|
||||
(&&tang!(||)))0(rahcteg=raeN( &&1==tang((&&1-^)gnat=raeN(;;;)tang,gnat
|
||||
,ABBA,0(avnz;)gnat:46+]552&)191+gnat([kri?0>]652%)191+gnat([kri=gnat
|
||||
(&&)1-^gnat(&&)1& ABBA(!;)raeN,tang,gnat,ABBA(avnz&&0>ABBA{)raeN
|
||||
,/**/);}znva(/*//**/tang,gnat,ABBA/**//*/(niam;}1-,78-,611-,321
|
||||
-,321-,001-,64-,43-,801-,001-,301-,321-,511-,53-,54,44,34,24
|
||||
,14,04,93,83,73,63,53,43,33,85,75,65,55,45,35,25,15,05,94,84
|
||||
,74,64,0,0,0,0,0,0,/**/){ABBA='N'==65;(ABBA&&(gnat=trgpune
|
||||
(0)))||(!ABBA&&(gnat=getchar(0-0)));(--tang&1)&&(gnat='n'<=
|
||||
gnat&&gnat<='z'||'a'<=gnat&&gnat<='m'||'N'<=gnat&&gnat<='Z'
|
||||
||'A'<=gnat&&gnat<='M'?(((gnat&/*//**/31/**//*/,21,11,01,9,8
|
||||
,7,6,5,4,3,2,1,62,52,42,/**/)+12)%26)+(gnat&/*//**/32/**//*/,
|
||||
22,12,02,91,81,71,61,51,41{=]652[kri};)/*pry*/)+65:gnat);main
|
||||
(/*//**\**/tang^tang/**//*/,/* */,~/*//*-*/tang,gnat,ABBA-
|
||||
0/**//*/(niam&&ABBA||))))tang( rahcteg&&1-1=<enrA(||))tang(
|
||||
enupgrt&&1==enrA((&&)2&gnat(&& )1-^tang(&&ABBA!(;)85- =tang
|
||||
(&&)'a\'=gnat(&&)1-==gnat(&&)4 ==ABBA(&&tang!;))))0(enupgrt=
|
||||
gnat(&&)tang!((||)))0(rahcteg =gnat(&&tang((&&ABBA;;)1-'A'=!
|
||||
'Z'=tang(&&ABBA{)enrA/***/);gnat ^-1&&znva(tang+1,gnat,1+gnat);
|
||||
main(ABBA&2/*//*\\**/,tang,gnat ,ABBA/**//*/(avnz/**/);}/*//**/
|
||||
@@ -1,8 +1,7 @@
|
||||
|
||||
/**//*/};)/**/main(/*//**/tang ,gnat/**//*/,ABBA~,0-0(avnz;)0-0,tang,raeN
|
||||
,ABBA(niam&&)))2-]--tang-[kri - =raeN(&&0<)/*clerk*/,noon,raeN)char
|
||||
**gnat, **noon, **raeN;{int gn = gnat, ra = raeN, no = noon; (!tang&&
|
||||
no!=-1&&(gn&2)&&((raeN&&( getchar(no+0)))||(1-ra&&(trgpune(no
|
||||
,ABBA(niam&&)))2-]--tang-[kri - =raeN(&&0<)/*clerk*/,noon,raeN){(!tang&&
|
||||
noon!=-1&&(gnat&2)&&((raeN&&( getchar(noon+0)))||(1-raeN&&(trgpune(noon
|
||||
)))))||tang&&znva(/*//**/tang ,tang,tang/**|**//*/((||)))0(enupgrt=raeN
|
||||
(&&tang!(||)))0(rahcteg=raeN( &&1==tang((&&1-^)gnat=raeN(;;;)tang,gnat
|
||||
,ABBA,0(avnz;)gnat:46+]552&)191+gnat([kri?0>]652%)191+gnat([kri=gnat
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
# Best Small Program
|
||||
|
||||
Baruch Nissenbaum\
|
||||
Tel-Aviv University\
|
||||
The Faculty of Engineering\
|
||||
Tel-Aviv\
|
||||
Israel
|
||||
|
||||
Doron Osovlanski\
|
||||
CADTECH - CAD/CAM Systems Ltd\
|
||||
24 Ben-Yosef St.\
|
||||
Givat-Shmuel 51905\
|
||||
Israel
|
||||
|
||||
## To build:
|
||||
@@ -59,7 +53,7 @@ Use `baruch.alt` as you would `baruch`.
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
This program reads an integer between 4 and 99 from the stdin.
|
||||
This program reads an integer between 4 and 99 from the `stdin`.
|
||||
|
||||
NOTE: The original program did not have a newline at the end of the file. We
|
||||
added a final newline to the file to make unpacking easy.
|
||||
@@ -95,7 +89,7 @@ long enough..
|
||||
|
||||
### For PC users:
|
||||
|
||||
In order to compile the program under Turbo-C or MSC, `'int '` should be inserted
|
||||
In order to compile the program under Turbo-C or MSC, `int ` should be inserted
|
||||
at the beginning of the program. For better looking results it is recommended
|
||||
to replace the `" #Q"` string with `" \261\2"`.
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ If you have gcc < 2.3.3 (i.e. the entry can compile):
|
||||
```
|
||||
|
||||
|
||||
### Alternate code
|
||||
### Alternate code:
|
||||
|
||||
To use:
|
||||
|
||||
|
||||
+17
-2
@@ -35,13 +35,28 @@ judges noted that the C pre-processed version (with the `#include`s
|
||||
left intact) looked very much like a rat "dropping core". See
|
||||
[garry.alt.c](garry.alt.c) and judge for yourself!
|
||||
|
||||
To use try:
|
||||
#### To build:
|
||||
|
||||
|
||||
```sh
|
||||
make alt
|
||||
```
|
||||
|
||||
Use `garry.alt` as you would `garry` above.
|
||||
#### To use:
|
||||
|
||||
```sh
|
||||
./garry.alt <input_file >output_file
|
||||
```
|
||||
|
||||
#### Try:
|
||||
|
||||
```sh
|
||||
|
||||
GARRY=garry.alt ./garry.test.sh
|
||||
|
||||
./garry.alt < README.md
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
#!/usr/bin/env sh
|
||||
#
|
||||
# garry.test - example of how to use garry
|
||||
# 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
|
||||
@@ -31,16 +31,18 @@ make clobber all LEVEL=6
|
||||
The authors provided a spoiler version of the program. Originally uuencoded we
|
||||
have decoded it for the wider audience in [spoiler.c](spoiler.c). The
|
||||
`uuencode`d blob is still available in their remarks below. They encourage you
|
||||
to first try and figure it out without it.
|
||||
to first try and figure out the program without the spoiler.
|
||||
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
Warning: in the past, values of LEVEL>8 have been known to cause compilers (and
|
||||
in one case a system) to crash during compilation. We tested it in 2023 on a
|
||||
MacBook Pro with the M1 chip and found that LEVEL > 6 caused problems.
|
||||
Back in 1995, values of `LEVEL>8` caused some compilers (and in one case a
|
||||
system) to crash during compilation. In 2023 with modern systems this is not
|
||||
really a problem.
|
||||
|
||||
Back in 1995 we also suggested that for a bad/slow time to try `LEVEL=15` but
|
||||
this is not a big deal in 2023 either.
|
||||
|
||||
For a bad/slow time try LEVEL=15.
|
||||
|
||||
## Authors' remarks:
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ QWERTY keyboards. Rogue players, vi users, and Dvorak typists are
|
||||
invited to get lost (or use the alt version)!
|
||||
|
||||
|
||||
### Alternate code
|
||||
### Alternate code:
|
||||
|
||||
To use:
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ make
|
||||
./hoyle 2 0 1 0 -0.001
|
||||
```
|
||||
|
||||
### Alternate code
|
||||
### Alternate code:
|
||||
|
||||
An alternate version of this entry, [hoyle.alt.c](hoyle.alt.c), is provided.
|
||||
This alternate code has a missing newline and used a non-standard tab stop size.
|
||||
|
||||
@@ -42,7 +42,7 @@ What happens if you feed the program source to the program? Can you figure out
|
||||
why?
|
||||
|
||||
|
||||
### Alternate code
|
||||
### Alternate code:
|
||||
|
||||
The judges modified the program to print its result. The original
|
||||
program returned the result as an exit code:
|
||||
|
||||
@@ -91,5 +91,5 @@ u, v, d, s = find_params(fonts)
|
||||
puts "Found."
|
||||
puts
|
||||
puts "Let s = %p." % s
|
||||
puts "You can get the font data of dicimal character 'n' (0--9):"
|
||||
puts "You can get the font data of decimal character 'n' (0--9):"
|
||||
puts " %d * s[n+10] - %d * s[n] - %d" % [u, v, d]
|
||||
+28
-23
@@ -2,26 +2,31 @@
|
||||
#include<stdlib.h>
|
||||
#include<ctype.h>
|
||||
|
||||
int u,z,q[0400],O[0x101],o[0401],I[257],w[258][0403],W[0x100],Z[0x103],c[0403],k
|
||||
,i,j,n,l,p,m;const char*J[0416],*M[0400];FILE*K[280],*s[0x102];void f(char*n,int
|
||||
a){char*e=n;while(*e!='\0'){if(tolower((int)*e)!=*e)fputc(040,stderr);fputc((*e)
|
||||
-a,stderr);e+=1;}(void)fputc('\n',stderr);}int y(int a,int b);int t(int i,int j)
|
||||
{int k=i&j,l=i^j,n,m=1;for(n=1;k>=n;n<<=1)if(k&n)m=y(m,1<<n|1<<(n-1));return m>1
|
||||
?y(m,1<<l):1<<l;}int y(int a,int b){int n,i=0x0,j;if((n=w[a][b]))return n;for(;a
|
||||
>>i;++i)for(j=0x0;b>>j;j++)if(((a>>i)&1)&&((b>>j)&1))n^=t(i,j);return w[a][b]=w[
|
||||
b][a]=n;}void a(void){for(i=0;i<z;i++){n=0;if(!i[I]){for(j=0;j<u;++j)if(i[O]==q[
|
||||
j])n=Z[j];}else for(j=0;j<u;j++)n^=w[Z[j]][w[I[i]][W[w[o[j]][O[i]^q[j]]]]];c[i]=
|
||||
n;}}void X(int v,int u){char*y=0;v-=1;switch(v){case(0x2):y ="HckngfVqQrgpKprwv"
|
||||
"Hkng"; BC(4):y="JempihXsStirMrtyxJmpi"; BC(0):y="PointValueTooLarge"; BC 0x1:y=
|
||||
"EvqmjdbufJoqvuQpjou";BC(6):y="TuOtv{zLorky";BC(3):y="WrrPdq|RxwsxwSrlqwv";BC(5)
|
||||
:y="GfiFwlzrjsyX~syf}"; BC(07):y="UvV|{w|{Mpslz";}if(u)exit(0); f(y,v);exit(1);}
|
||||
int main(int t,const char*T[]){for(i=00;i<0x100;++i)for(j=0;j<=i;++j)if(1==y(i,j
|
||||
))W[i]=j,W[j]=i;for(k=0x1;k<t;k++){p=0;for(l=0;(T[k][l]>=toupper('0'))&&(T[k][l]
|
||||
<=tolower('9'));l++){p=p*10+(T[k][l]-'0');if(p>=256)X(1,0);}if(T[k][l]=='-'){for
|
||||
(m=0;m<u;m++)if(q[m]==p)X(2,0);q[u]=p;J[u]=T[k]+l+1;K[u]=fopen(J[u],"r");if(!u[K
|
||||
])X(3,0);u++;}else if(T[k][l]=='+'){if(z>=256)X(4,0); O[z]=p;M[z]=T[k]+l+1;s[z]=
|
||||
fopen(M[z],"w");if(!s[z])X(5,0);z++;}else X(6,0);}if(!(u!=0))X(7,0);if(!(z!= 0))
|
||||
X(8,0);for(i=0;i<u;i++){n=1;for(j=0;j<u; j+=1)if(j!=i)n=w[n][q[i]^q[j]];o[i]=n;}
|
||||
for(i=0;i<z;i++){n=1;for(j=0;j<u;j++)n=w[n][O[i]^q[j]];I[i]=n;}while(!(0)){for(k
|
||||
=0;k<u;k++){int n;n=getc(K[k]); if(n==EOF)X(42,1); Z[k]=n;}a();for(k=0;k<z;k++)(
|
||||
void)putc(c[k],s[k]);}X(11,1);}
|
||||
static const int x[010][8]={{01,02,04,0x8,020,32,0x40,128,},{02,03,0x8,12,32,48,
|
||||
128,192,},{04,0x8,06,11,64,128,96,176,},{0x8,12,11,13,128,192,176,208,},{020,32,
|
||||
64,128,24,44,75,141,},{32,48,128,192,44,52,141,198,},{64,128,96,0260,75,141,103,
|
||||
185,},{0200,192,176,208,0x8D,0306,0271,0xDE,},};static int u,z,q[0400],O[0x101],
|
||||
o[0401],I[257],w[258][0403],W[0x100],Z[0x103],c[0403],k,i,j,n,l,p,m;static const
|
||||
char*J[0416],*M[0400];static FILE *K[280],*s[0x102];static void f(char *n,int a)
|
||||
{char *e=n;while(*e!='\0'){if(tolower((int)*e)!=*e)(void)fputc(040,stderr);fputc
|
||||
((*e)-a,stderr);e+=1;}(void)fputc('\n',stderr);}static int y(int a,int b){int n=
|
||||
0,i=0x0,j;for(;a>>i;++i)for(j=0x0;b>>j;j++)if(((a>>i)&1)&&((b>>j)&1))n^=x[i][j];
|
||||
return n;}static void a(void){for(i=0;i<z;i++){n=0;if(!i[I]){for(j=0;j<u;++j)if(
|
||||
i[O]==q[j])n=Z[j];}else for(j=0;j<u;j++)n^=w[Z[j]][w[I[i]][W[w[o[j]][O[i]^q[j]]]
|
||||
]];c[i]=n;}}static void X(int v,int u){char*y;v-=_STDIO_H;switch(v){case(0x2):y=
|
||||
"H""c""k""ngfVqQrgpKprwvHkng";break;case(4):y="J""e""m""p""ih""XsStirMrtyxJmpi";
|
||||
break;case(EXIT_SUCCESS):y="P""o""i""ntValueTooLarge";break;case 0x1:y="E""v""q"
|
||||
"m""j""d""b""u""f""J""o""q""v""u""Q""p""j""o""u";break;case(6):y="T""u""O""t""v"
|
||||
"{""z""L""o""r""k""y";break;case(3):y="WrrPdq|Rx""w""sx" "wSrlqwv";break;case(5)
|
||||
:y="GfiFwlzrjsyX~syf}";break;case(07):y="U""v""V""|""{""w""|""{""M""p""s""l""z";
|
||||
}if(u)exit(EXIT_SUCCESS);f(y,v);exit(EXIT_FAILURE);}int main(int t,const char*T[
|
||||
]){for(i=00;i<0x100;++i)for(j=0;j<=0xff;++j)w[i][j]=y(i,j);W[0]=0;for(i=1;i<256;
|
||||
i+=1){for(j=1;w[i][j]!=1;j+=1);i[W]=j;}for(k=0x1;k<t;k++){p=0;for(l=0;(T[k][l]>=
|
||||
toupper('0'))&&(T[k][l]<=tolower('9'));l++){p=p*10+(T[k][l]-'0');if(p>=256)X(1,0
|
||||
);}if(T[k][l]=='-'){for(m=0;m<u;m++)if(q[m]==p)X(2,0);q[u]=p;J[u]=T[k]+l+1;K[u]=
|
||||
fopen(J[u],"r");if(!u[K])X(3,0);u++;}else if(T[k][l]=='+'){if(z>=256)X(4,0);O[z]
|
||||
=p;M[z]=T[k]+l+1;s[z]=fopen(M[z],"w");if(!s[z])X(5,0);z++;}else X(6,0);}if(!(u!=
|
||||
0))X(7,0);if(!(z!=0))X(8,0);for(i=0;i<u;i++){n=1;for(j=0;j<u;j+=1)if(j!=i)n=w[n]
|
||||
[q[i]^q[j]];o[i]=n;}for(i=0;i<z;i++){n=1;for(j=0;j<u;j++)n=w[n][O[i]^q[j]];I[i]=
|
||||
n;}while(!(0)){for(k=0;k<u;k++){int n;n=getc(K[k]);if(n==EOF)X(42,1);Z[k]=n;}a()
|
||||
;for(k=0;k<z;k++)(void)putc(c[k],s[k]);}X(11,1);}
|
||||
+22
-10
@@ -24,11 +24,7 @@ echo "full spelling of an English cardinal numeral less than a quadrillion" | ./
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
echo Nineteen hundred and eighty-four | ./kang
|
||||
echo uno | ./kang
|
||||
echo trois | ./kang
|
||||
echo fier | ./kang # notice the issue here, see alternate code instead
|
||||
echo "shest'" | ./kang
|
||||
./try.sh # try various languages
|
||||
|
||||
./en.sh # English 0 through 13
|
||||
|
||||
@@ -42,8 +38,11 @@ How does it have no `u` or `o` in a string in the source code and yet it gets
|
||||
|
||||
This alternate code fixes the program that would throw off those who know German
|
||||
where the sound of 'V' is 'F' and so the program had the letter be 'F'. A
|
||||
problem, however, with changing it is that it breaks other words. Thus there is
|
||||
the alternate version instead which fixes the problem.
|
||||
problem, however, with changing it is that it breaks other words including in
|
||||
German. Thus there is the alternate version instead which fixes a problem for
|
||||
Germans that causes other problems for Germans so if you're German you'll just
|
||||
have to deal with it :-) It is, however, good as you can appreciate the entry
|
||||
even more.
|
||||
|
||||
#### To build:
|
||||
|
||||
@@ -58,12 +57,12 @@ echo vier | ./kang.alt
|
||||
echo uno | ./kang.alt
|
||||
```
|
||||
|
||||
#### Also try:
|
||||
#### Try:
|
||||
|
||||
|
||||
```sh
|
||||
KANG=kang.alt ./de.sh # German 0 through 13 both with and without umlaut
|
||||
KANG=kang.alt ./en.sh # English 0 through 13
|
||||
./de.alt.sh # German 0 through 13 both with and without umlaut
|
||||
./en.alt.sh # English 0 through 13
|
||||
```
|
||||
|
||||
What does it get right? What does it get wrong? How does it compare to the
|
||||
@@ -83,6 +82,19 @@ colloquial year numbers of the last millennium.
|
||||
|
||||
We've added a linefeed to the print format for convenience.
|
||||
|
||||
Can you explain why:
|
||||
|
||||
```sh
|
||||
echo f hundr|./kang
|
||||
```
|
||||
|
||||
correctly reports 500 but:
|
||||
|
||||
```sh
|
||||
echo hundr|./kang
|
||||
```
|
||||
|
||||
does not report 100, instead printing 0?
|
||||
|
||||
## Author's remarks:
|
||||
|
||||
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# run 2012/kang with German words for 0 through 13
|
||||
#
|
||||
# For five, fünf, it uses both ue and umlaut (ü) form, and for twelve, zwölf, it
|
||||
# uses both oe and ö.
|
||||
#
|
||||
# What does it get right and what does it get wrong? Why does it get what it
|
||||
# gets wrong wrong?
|
||||
|
||||
make everything || exit 1
|
||||
|
||||
# set up path to program if not set
|
||||
if [[ -z "$KANG" ]]; then
|
||||
KANG="kang.alt"
|
||||
fi
|
||||
|
||||
# first set up translation (for those who don't know German):
|
||||
declare -a NUMBERS
|
||||
j=0
|
||||
for i in 0 1 2 3 4 5 5 6 7 8 9 10 11 12 12 13; do
|
||||
NUMBERS["$j"]="$i";
|
||||
((j++))
|
||||
done
|
||||
|
||||
|
||||
j=0
|
||||
for i in Null eins zwei drei vier fünf fuenf sechs sieben acht neun zehn elf zwoelf zwölf dreizehn ; \
|
||||
do
|
||||
echo -n "$i (${NUMBERS[$j]}): "
|
||||
echo "$i"|"./$KANG"
|
||||
((j++))
|
||||
done
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# run 2012/kang with English words for 1 through 13
|
||||
#
|
||||
# What does it get right and what does it get wrong? Why does it get what it
|
||||
# gets wrong wrong?
|
||||
|
||||
make everything || exit 1
|
||||
|
||||
# set up path to program if not set
|
||||
if [[ -z "$KANG" ]]; then
|
||||
KANG="kang.alt"
|
||||
fi
|
||||
|
||||
declare -a NUMBERS
|
||||
j=0
|
||||
for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13; do
|
||||
NUMBERS["$j"]="$i";
|
||||
((j++))
|
||||
done
|
||||
|
||||
j=0
|
||||
for i in zero one two three four five six seven eight nine ten eleven twelve thirteen ; \
|
||||
do
|
||||
echo -n "$i (${NUMBERS[$j]}): "
|
||||
echo "$i"|"./$KANG"
|
||||
((j++))
|
||||
done
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
make everything || exit 1
|
||||
|
||||
echo "$ echo Nineteen hundred and eighty-four | ./kang"
|
||||
echo Nineteen hundred and eighty-four | ./kang
|
||||
|
||||
echo "$ echo uno | ./kang"
|
||||
echo uno | ./kang
|
||||
|
||||
echo "$ echo trois | ./kang"
|
||||
echo trois | ./kang
|
||||
|
||||
echo "$ echo fier | ./kang # notice the issue here, see alternate code instead"
|
||||
echo fier | ./kang # notice the issue here, see alternate code instead
|
||||
|
||||
echo "$ echo \"shest'\" | ./kang"
|
||||
echo "shest'" | ./kang
|
||||
@@ -24,7 +24,7 @@ NOTE: N is an integer from 0 to 255.
|
||||
./konno 30
|
||||
```
|
||||
|
||||
### Alternate code
|
||||
### Alternate code:
|
||||
|
||||
An alternate version of this entry, [konno.alt.c](konno.alt.c), is provided.
|
||||
This alternate code is an unobfuscated version of the winning code.
|
||||
|
||||
@@ -28,7 +28,7 @@ try [incorrect.c](incorrect.c) and the program itself.
|
||||
NOTE: it prints an error and exits on the first nesting error so it will not
|
||||
detect multiple issues!
|
||||
|
||||
### Alternate code
|
||||
### Alternate code:
|
||||
|
||||
An alternate version of this entry, [zeitak.alt.c](zeitak.alt.c), is provided.
|
||||
The file [zeitak.alt.c](zeitak.alt.c) provides a version that has been slightly
|
||||
|
||||
@@ -29,7 +29,7 @@ DRAFT=1 ./prog < prog.c
|
||||
./prog < prog.c
|
||||
```
|
||||
|
||||
## Alternate code
|
||||
## Alternate code:
|
||||
|
||||
An alternate version of this entry, prog.alt.c, is provided. This alternate
|
||||
code is discussed below in the "prog.c vs prog.alt.c" section of the Author's
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ cp war-and-peace.txt nuked.tmp
|
||||
./avgtime.sh 100 ./prog war-and-peace.txt nuked.tmp
|
||||
```
|
||||
|
||||
### Alternate code
|
||||
### Alternate code:
|
||||
|
||||
An alternate version of this entry, `prog.alt.c`, is provided.
|
||||
This alternate code does not use a 64 bit FNV hash.
|
||||
|
||||
@@ -25,7 +25,7 @@ echo IOCCC | ./prog
|
||||
./prog < prog.x86_64.asm
|
||||
```
|
||||
|
||||
### Alternate code
|
||||
### Alternate code:
|
||||
|
||||
An even smaller alternate version of this entry, prog.alt.c, is provided. This code does not contain any headers, nor any workaround for WIN32 based platforms.
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ echo International Obfuscated C Code Contest | ./prog
|
||||
./prog < input.txt
|
||||
```
|
||||
|
||||
### Alternate code
|
||||
### Alternate code:
|
||||
|
||||
There is an alternate version of this code in `prog.alt.c` where the main code is a macro.
|
||||
|
||||
|
||||
@@ -568,26 +568,22 @@ numbers with non-binary digits.
|
||||
## [1989/westley](1989/westley/westley.c) ([README.md](1989/westley/README.md))
|
||||
### STATUS: main() function args not allowed - please help us fix
|
||||
|
||||
Although [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this for
|
||||
some of the versions that are generated (see below tip) it will not work for all
|
||||
with the clang compiler (gcc works fine) and in some versions of clang it will
|
||||
not work at all due to yet another defect (see below also).
|
||||
This entry is a big problem for clang due to the way it is designed. Earlier a
|
||||
change was made to let it compile with clang but although it appeared to work
|
||||
with gcc, all generated versions (see the README.md for details), this was
|
||||
either a mistake or it no longer does.
|
||||
|
||||
Thus the original was copied and this does not work at all in clang. It is very
|
||||
easy to get the first one or two to work with clang but the others result in
|
||||
compilation failures even besides clang.
|
||||
|
||||
The problems with clang is that it does not allow `int` for any arg in `main()`
|
||||
except the first one, argc, and some versions of clang do not even allow a
|
||||
fourth arg at all (0, 2 or 3 args only).
|
||||
|
||||
Cody noted that trying to fix it in some cases causes a segfault and in other
|
||||
cases it fails to generate some of the files (others are okay) at all (empty
|
||||
files).
|
||||
|
||||
There is another change that was thought up on 08 July 2023 which allows for
|
||||
another version to be compiled with clang but it causes some of the versions to
|
||||
not be correctly generated (whereas the current way does generate all files but
|
||||
is not compilable with clang) so for now this is not in. If it is put in it will
|
||||
be an alternate version.
|
||||
|
||||
Some versions of clang have an additional defect where in additional to forcing
|
||||
the args of `main()` to be of type `int` (for first arg) and the rest to be
|
||||
`char **` it also does not allow a fourth arg to main(). This in fact is part of
|
||||
the change thought up on 08 July 2023: main() calls a function which has the old
|
||||
types of variables.
|
||||
files). These changes were never committed.
|
||||
|
||||
Cody gives these tips on the problem: `main()`'s second, third and fourth args
|
||||
(but on fourth arg see above) are supposed to be a `char **`. This didn't use to
|
||||
@@ -597,10 +593,14 @@ to decrypt the function `znva` to be main in _generated files_ (see the
|
||||
[README.md](1989/westley/README.md) for details).
|
||||
|
||||
Since that function does not have the correct types when converted to main() it
|
||||
fails to compile. But as he said changing the type causes either a segfault or
|
||||
files not generated at all. `ver1`, `ver2` and `ver3` are the problematic ones.
|
||||
The segfault happens when running the main program. Cody fixed that but as noted
|
||||
as for the generated files only `ver0` will compile with clang.
|
||||
fails to compile. But as he said changing the type causes either a segfault,
|
||||
files not generated at all or files ended up with syntax errors. `ver1`, `ver2`
|
||||
and `ver3` are the problematic ones.
|
||||
|
||||
The file [westley.alt.c](1989/westley/westley.alt.c) will compile with clang
|
||||
but although it can perform some of its functions it will generate code that
|
||||
does not work.
|
||||
|
||||
|
||||
### STATUS: known bug - please help us fix
|
||||
|
||||
|
||||
File renamed without changes.
+59
-20
@@ -643,7 +643,10 @@ not his only reason :-) )
|
||||
|
||||
Cody got some of the versions (the original and `ver0`) to work with some
|
||||
versions of `clang`. Unfortunately there are some defects in `clang` that break
|
||||
this entry either in full or in part.
|
||||
this entry either in full or in part. Also, some of the code generated by it
|
||||
cannot be compiled by gcc either. Thus these changes are in the alt code.
|
||||
Nevertheless the main features of the program does work in the alt version, it
|
||||
just cannot generate every C file correctly.
|
||||
|
||||
Cody provided the compile.sh script to generate the files and then try and
|
||||
compile them (which ones succeed depend on whether or not clang is the
|
||||
@@ -1144,14 +1147,23 @@ 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.
|
||||
|
||||
|
||||
|
||||
|
||||
## [1995/garry](1995/garry/garry.c) ([README.md](1995/garry/README.md]))
|
||||
|
||||
Cody fixed this so that it will compile with modern compilers. The 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 fixed the alt code so that it will compile with modern compilers. The
|
||||
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,
|
||||
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`.
|
||||
|
||||
|
||||
## [1995/makarios](1995/makarios/makarios.c) ([README.md](1995/makarios/README.md))
|
||||
|
||||
@@ -1160,6 +1172,14 @@ 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()
|
||||
calls which has the four args.
|
||||
|
||||
## [1995/vanschnitz](1995/vanschnitz/vanschnitz.c) ([README.md](1995/vanschnitz/README.md))
|
||||
|
||||
Cody added the authors' spoiler as a C file as in 2023 we have decided that in
|
||||
most cases all the code should be available for the wider audience, without
|
||||
having to extract it. The exception is when the files are created by the entry
|
||||
or the entry decrypts the text or whatever else.
|
||||
|
||||
|
||||
## [1996/august](1996/august/august.c) ([README.md](1996/august/README.md]))
|
||||
|
||||
Cody fixed a segfault in this program that prevented it from working right but
|
||||
@@ -1963,23 +1983,42 @@ implicitly (linux doesn't seem to but macOS does).
|
||||
Cody added explicit linking of libm (`-lm`) as not all systems do this
|
||||
implicitly (linux doesn't seem to but macOS does).
|
||||
|
||||
## [2012/endoh2](2012/endoh2/endoh2.c) ([README.md](2012/endoh2/README.md))
|
||||
|
||||
Cody fixed a typo in the ruby script
|
||||
[find-font-table.rb](2012/endoh2/find-font-table.rb).
|
||||
|
||||
|
||||
## [2012/grothe](2012/grothe/grothe.c) ([README.md](2012/grothe/README.md))
|
||||
|
||||
Cody restored the original code from the archive.
|
||||
|
||||
## [2012/kang](2012/kang/kang.c) ([README.md](2012/kang/README.md]))
|
||||
|
||||
Cody added alt code that fixes the problem where in German 'v' sounds like 'f'
|
||||
which the program has as 'f'. Thus with the original version it would translate
|
||||
'fier' to '4' when the word is 'vier'. Originally this was updated in the
|
||||
original code but it was noticed that this caused _other_ words to be incorrect
|
||||
so it was set as an alt version since the code was already there. It might also
|
||||
be considered a feature and not a bug so an alt version is the better way to go
|
||||
about it. Using both allows one to experience different capabilities and also
|
||||
enjoy or appreciate the entry more.
|
||||
Cody added alt code that fixes a problem where in German 'v' sounds like 'f'
|
||||
which the program has as 'f': with the original version it would translate
|
||||
'fier' to '4' when the word is 'vier'. But see below.
|
||||
|
||||
Cody also added two scripts, [en.sh](2012/kang/en.sh) and
|
||||
[de.sh](2012/kang/de.sh) which counts from 0 through 13 in English and German.
|
||||
In the German script it uses the umlaut and also does it without the umlaut (add
|
||||
an 'e'). Both scripts can use either version to see the differences. See the
|
||||
README.md file for details.
|
||||
Originally this was updated in the original code but it was noticed that this
|
||||
caused _other_ German (and maybe other languages?) words to be incorrect so it
|
||||
was set as an alt version since the code was already there. It might also be
|
||||
considered a feature and not a bug so an alt version is the better way to go
|
||||
about it. Using both, however, allows one to experience different capabilities
|
||||
and also enjoy or appreciate the entry even more, given how simple the
|
||||
difference is.
|
||||
|
||||
Cody also added five scripts: [en.sh](2012/kang/en.sh),
|
||||
[de.sh](2012/kang/de.sh), [en.alt.sh](2012/kang/en.alt.sh) and
|
||||
[de.alt.sh](2012/de.alt.sh) which count from 0 through 13 in English and German
|
||||
using the original entry and the alt version respectively.
|
||||
|
||||
In the German scripts it uses the umlaut and also does it without the umlaut
|
||||
(add an 'e'). Notice how the program picks up on this! All scripts can use
|
||||
either version but the `.alt.sh` versions default to the `alt` version whereas
|
||||
the other defaults to the submitted entry. See the README.md for details.
|
||||
|
||||
The fifth script, [try.sh](2012/kang/try.sh), runs a sequence of commands to
|
||||
show different languages and numbers.
|
||||
|
||||
|
||||
## [2012/vik](2012/vik/vik.c) ([README.md](2012/vik/README.md]))
|
||||
|
||||
Reference in new issue
Block a user