Fix 1992/albert, swap alt/main code
The alt code was the original; the entry was a bug fixed version by Leo
(before he was a judge). However that version, the fixed version, was
not obfuscated and as the judges say in the FAQ:
the contest is called the IOCCC, not the INVOCCC :-)
so it seems better to have the version that has a bug as the entry. But
that code no longer compiled. This has been fixed.
Updated .gitignore.
Minor changes to README.md wrt the swapping of alt code/entry code. The
formatting has not been checked and no typos have been fixed either.
These will come later.
This commit is contained in:
1 parent
8b893ddfde
commit
456120f825
5 files changed
+184
-174
No files matched your search
@@ -1,3 +1,4 @@
|
|||||||
albert
|
albert
|
||||||
|
albert.alt
|
||||||
albert.orig
|
albert.orig
|
||||||
prog.orig
|
prog.orig
|
||||||
@@ -42,8 +42,8 @@ Both albert and albert.orig loop without printing anything, although
|
|||||||
the first factor is 101 and is usually found in an instant.
|
the first factor is 101 and is usually found in an instant.
|
||||||
```
|
```
|
||||||
|
|
||||||
The [albert.c](albert.c) file is the fixed file, whereas the
|
The [albert.alt.c](albert.c) file is the fixed file, whereas the
|
||||||
[albert.alt.c](albert.alt.c) is the file before applying Leo Broukhis' fix.
|
[albert.c](albert.c) is the file before applying Leo Broukhis' fix.
|
||||||
|
|
||||||
To compile this alternate version:
|
To compile this alternate version:
|
||||||
|
|
||||||
@@ -65,8 +65,8 @@ a long.
|
|||||||
|
|
||||||
The Obfuscated version of the Horst algorithm.
|
The Obfuscated version of the Horst algorithm.
|
||||||
|
|
||||||
This program will factor unlimited length numbers and print the\
|
This program will factor unlimited length numbers and print the
|
||||||
factors in ascending order. Numbers of one digit (e.g. 8)\
|
factors in ascending order. Numbers of one digit (e.g. 8)
|
||||||
are rejected without notice.
|
are rejected without notice.
|
||||||
|
|
||||||
It quits as soon as there is at most one factor left, but that factor will not
|
It quits as soon as there is at most one factor left, but that factor will not
|
||||||
|
|||||||
+26
-144
@@ -1,152 +1,34 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <setjmp.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#define new(PP) (PP *) malloc(sizeof(PP))
|
|
||||||
typedef struct q {
|
|
||||||
jmp_buf ppp;
|
|
||||||
long qq;
|
|
||||||
struct q *P;
|
|
||||||
struct q *p;
|
|
||||||
}
|
|
||||||
PP;
|
|
||||||
|
|
||||||
PP *P;
|
main(argc,argv)
|
||||||
int aaaaaa=2;
|
int argc;
|
||||||
int aaaaaaa=1;
|
char **argv;
|
||||||
|
|
||||||
long qqq;
|
|
||||||
|
|
||||||
|
|
||||||
aaAaaa(aa,aaa)
|
|
||||||
char *aa;
|
|
||||||
char *aaa;
|
|
||||||
{
|
{
|
||||||
char aaaa = 0;
|
long arg[100];
|
||||||
if ((((( aaa )))))
|
int i,j;
|
||||||
{
|
int base = 10;
|
||||||
aaaa = *aa;
|
int start = 0;
|
||||||
*aa=0;
|
int end= strlen(argv[1]);
|
||||||
aa+=strlen(aa+1);
|
|
||||||
P =new(PP);
|
|
||||||
P->P=P;
|
|
||||||
P->p=P;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((((( !setjmp(P->ppp) )))))
|
|
||||||
|
for (i=0;i<end;i++)
|
||||||
|
arg[i] = argv[1][i]-'0';
|
||||||
|
|
||||||
|
while ( end-start > 2 )
|
||||||
{
|
{
|
||||||
if ((((( !isdigit(*aa) )))))
|
while ( arg[end-1] == 0 ) {
|
||||||
longjmp(P->ppp,aaaaaaa);
|
printf("%d\n",base);
|
||||||
else {
|
end--;
|
||||||
P->p->P = new(PP);
|
}
|
||||||
P->p->P->P = P;
|
while ( arg[start] == 0 ) start +=1;
|
||||||
P->p->P->p = P->p;
|
base += 1;
|
||||||
P->p = P->p->P;
|
|
||||||
|
|
||||||
P->qq = *aa--;
|
for (i=start+1;i<end;i++)
|
||||||
P = P->p;
|
for (j=i;j>start;j--)
|
||||||
aaAaaa(aa,0);
|
if ( (arg[j]-=arg[j-1])<0 )
|
||||||
|
{
|
||||||
|
arg[j]+=base;
|
||||||
|
arg[j-1] -= 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if ( !aaaa&&!*aa )
|
|
||||||
longjmp(P->p->ppp,aaaaaaa);
|
|
||||||
|
|
||||||
if ((((( (P->qq=aaaa)<10 &&!
|
|
||||||
(isdigit(aaaa)) ||!
|
|
||||||
(isdigit(*aa) ||!
|
|
||||||
*aa ))))))
|
|
||||||
{
|
|
||||||
fprintf(stderr,"Usage %c%s <number>\n",
|
|
||||||
(aaa[0]?7:aaaa),aaa+!aaa[0]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ppPppp(pp,ppp)
|
|
||||||
PP **pp, *ppp;
|
|
||||||
{
|
|
||||||
int aa;
|
|
||||||
if ((((( !(aa=setjmp(ppp->ppp))||aa==aaaaaa )))))
|
|
||||||
{
|
|
||||||
if ((((( *pp==ppp )))))
|
|
||||||
{
|
|
||||||
ppp = (*pp)->p;
|
|
||||||
|
|
||||||
if ( qqq<47 ) return;
|
|
||||||
if ( ppp->qq!=48 ) return;
|
|
||||||
|
|
||||||
while ( ppp->qq==48 )
|
|
||||||
{
|
|
||||||
printf("%ld\n",qqq-45);
|
|
||||||
*pp = ppp;
|
|
||||||
ppp = ppp->p;
|
|
||||||
}
|
|
||||||
qqq -= 1;
|
|
||||||
longjmp(ppp->ppp,aaaaaaa);
|
|
||||||
} else {
|
|
||||||
PP *p;
|
|
||||||
|
|
||||||
ppPppp(pp,ppp->p);
|
|
||||||
for (p=ppp;p!=*pp;p=p->p)
|
|
||||||
{
|
|
||||||
int qq=4;
|
|
||||||
if ((((( qqq<47 &&
|
|
||||||
(qq=0,p->qq+=p->p->qq-96)>=48-qqq ||
|
|
||||||
qqq>46 &&
|
|
||||||
(p->qq-=p->p->qq)<0 )))))
|
|
||||||
{
|
|
||||||
p->qq += qqq+qq;
|
|
||||||
if ( p->p==P && qqq<=46 )
|
|
||||||
{
|
|
||||||
P->p->P = new(PP);
|
|
||||||
P->p->P->P = P;
|
|
||||||
P->p->P->p = P->p;
|
|
||||||
*pp = P = P->p = P->p->P;
|
|
||||||
P->qq = 48;
|
|
||||||
}
|
|
||||||
|
|
||||||
p->p->qq+=qq==0;
|
|
||||||
p->p->qq-=qq!=0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p->qq += 48;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( ppp->P==P ) longjmp(ppp->ppp,aaaaaaa);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qqq += 1;
|
|
||||||
|
|
||||||
while (48==P->qq )
|
|
||||||
{
|
|
||||||
P->P->p = P->p;
|
|
||||||
P = P->p->P = P->P;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ppp!=ppp->p->p )
|
|
||||||
longjmp(ppp->ppp,aaaaaa);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("At most one remains\n");
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
main(aaa,aaaa)
|
|
||||||
int aaa;
|
|
||||||
char **aaaa;
|
|
||||||
{
|
|
||||||
aaAaaa(aaa==aaaaaaa?aaaa[0]:aaaa[1],aaaa[0]);
|
|
||||||
qqq = 39;
|
|
||||||
ppPppp(&P,P->p);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
+144
-26
@@ -1,34 +1,152 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <setjmp.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#define new(PP) (PP *) malloc(sizeof(PP))
|
||||||
|
typedef struct q {
|
||||||
|
jmp_buf ppp;
|
||||||
|
long qq;
|
||||||
|
struct q *P;
|
||||||
|
struct q *p;
|
||||||
|
}
|
||||||
|
PP;
|
||||||
|
|
||||||
main(argc,argv)
|
PP *P;
|
||||||
int argc;
|
int aaaaaa=2;
|
||||||
char **argv;
|
int aaaaaaa=1;
|
||||||
|
|
||||||
|
long qqq;
|
||||||
|
|
||||||
|
|
||||||
|
aaAaaa(aa,aaa)
|
||||||
|
char *aa;
|
||||||
|
char *aaa;
|
||||||
{
|
{
|
||||||
long arg[100];
|
char aaaa = 0;
|
||||||
int i,j;
|
if ((((( aaa )))))
|
||||||
int base = 10;
|
{
|
||||||
int start = 0;
|
aaaa = *aa;
|
||||||
int end= strlen(argv[1]);
|
*aa=0;
|
||||||
|
aa+=strlen(aa+1);
|
||||||
|
P =new(PP);
|
||||||
|
P->P=P;
|
||||||
|
P->p=P;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((((( !setjmp(P->ppp) )))))
|
||||||
for (i=0;i<end;i++)
|
|
||||||
arg[i] = argv[1][i]-'0';
|
|
||||||
|
|
||||||
while ( end-start > 2 )
|
|
||||||
{
|
{
|
||||||
while ( arg[end-1] == 0 ) {
|
if ((((( !isdigit(*aa) )))))
|
||||||
printf("%d\n",base);
|
longjmp(P->ppp,aaaaaaa);
|
||||||
end--;
|
else {
|
||||||
}
|
P->p->P = new(PP);
|
||||||
while ( arg[start] == 0 ) start +=1;
|
P->p->P->P = P;
|
||||||
base += 1;
|
P->p->P->p = P->p;
|
||||||
|
P->p = P->p->P;
|
||||||
|
|
||||||
for (i=start+1;i<end;i++)
|
P->qq = *aa--;
|
||||||
for (j=i;j>start;j--)
|
P = P->p;
|
||||||
if ( (arg[j]-=arg[j-1])<0 )
|
aaAaaa(aa,0);
|
||||||
{
|
|
||||||
arg[j]+=base;
|
|
||||||
arg[j-1] -= 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if ( !aaaa&&!*aa )
|
||||||
|
longjmp(P->p->ppp,aaaaaaa);
|
||||||
|
|
||||||
|
if ((((( (P->qq=aaaa)<10 &&!
|
||||||
|
(isdigit(aaaa)) ||!
|
||||||
|
(isdigit(*aa) ||!
|
||||||
|
*aa ))))))
|
||||||
|
{
|
||||||
|
fprintf(stderr,"Usage %c%s <number>\n",
|
||||||
|
(aaa[0]?7:aaaa),aaa+!aaa[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ppPppp(pp,ppp)
|
||||||
|
PP **pp, *ppp;
|
||||||
|
{
|
||||||
|
int aa;
|
||||||
|
if ((((( !(aa=setjmp(ppp->ppp))||aa==aaaaaa )))))
|
||||||
|
{
|
||||||
|
if ((((( *pp==ppp )))))
|
||||||
|
{
|
||||||
|
ppp = (*pp)->p;
|
||||||
|
|
||||||
|
if ( qqq<47 ) return;
|
||||||
|
if ( ppp->qq!=48 ) return;
|
||||||
|
|
||||||
|
while ( ppp->qq==48 )
|
||||||
|
{
|
||||||
|
printf("%ld\n",qqq-45);
|
||||||
|
*pp = ppp;
|
||||||
|
ppp = ppp->p;
|
||||||
|
}
|
||||||
|
qqq -= 1;
|
||||||
|
longjmp(ppp->ppp,aaaaaaa);
|
||||||
|
} else {
|
||||||
|
PP *p;
|
||||||
|
|
||||||
|
ppPppp(pp,ppp->p);
|
||||||
|
for (p=ppp;p!=*pp;p=p->p)
|
||||||
|
{
|
||||||
|
int qq=4;
|
||||||
|
if ((((( qqq<47 &&
|
||||||
|
(qq=0,p->qq+=p->p->qq-96)>=48-qqq ||
|
||||||
|
qqq>46 &&
|
||||||
|
(p->qq-=p->p->qq)<0 )))))
|
||||||
|
{
|
||||||
|
p->qq += qqq+qq;
|
||||||
|
if ( p->p==P && qqq<=46 )
|
||||||
|
{
|
||||||
|
P->p->P = new(PP);
|
||||||
|
P->p->P->P = P;
|
||||||
|
P->p->P->p = P->p;
|
||||||
|
*pp = P = P->p = P->p->P;
|
||||||
|
P->qq = 48;
|
||||||
|
}
|
||||||
|
|
||||||
|
p->p->qq+=qq==0;
|
||||||
|
p->p->qq-=qq!=0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p->qq += 48;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( ppp->P==P ) longjmp(ppp->ppp,aaaaaaa);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qqq += 1;
|
||||||
|
|
||||||
|
while (48==P->qq )
|
||||||
|
{
|
||||||
|
P->P->p = P->p;
|
||||||
|
P = P->p->P = P->P;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ppp!=ppp->p->p )
|
||||||
|
longjmp(ppp->ppp,aaaaaa);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("At most one remains\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
main(aaa,aaaa)
|
||||||
|
int aaa;
|
||||||
|
char **aaaa;
|
||||||
|
{
|
||||||
|
aaAaaa(aaa==aaaaaaa?aaaa[0]:aaaa[1],aaaa[0]);
|
||||||
|
qqq = 39;
|
||||||
|
ppPppp(&P,P->p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1331,6 +1331,15 @@ This is a complex change due to the way the program and Makefile generate
|
|||||||
additional tools.
|
additional tools.
|
||||||
|
|
||||||
|
|
||||||
|
## [1992/albert](1992/albert/albert.c) ([README.md](1992/albert/README.md]))
|
||||||
|
|
||||||
|
Cody fixed this to compile with modern systems. Note that in 1996 a bug fix was
|
||||||
|
applied to the code, provided as the alt code as that version is not obfuscated.
|
||||||
|
Thus Cody's fixed applies to the original entry. The problems were that
|
||||||
|
`malloc.h` is not the correct header file now and a non-void (implicit int)
|
||||||
|
function returning without a value. The function was changed to return void.
|
||||||
|
|
||||||
|
|
||||||
## [1992/buzzard.1](1992/buzzard.1/buzzard.1.c) ([README.md](1992/buzzard.1/README.md))
|
## [1992/buzzard.1](1992/buzzard.1/buzzard.1.c) ([README.md](1992/buzzard.1/README.md))
|
||||||
|
|
||||||
Cody added a check for the right number of args, exiting 1 if not enough (2)
|
Cody added a check for the right number of args, exiting 1 if not enough (2)
|
||||||
|
|||||||
Reference in new issue
Block a user