diff --git a/1992/albert/Makefile b/1992/albert/Makefile index 1ef61ad36..d1f3f0a41 100644 --- a/1992/albert/Makefile +++ b/1992/albert/Makefile @@ -166,8 +166,8 @@ OBJ= ${PROG}.o DATA= TARGET= ${PROG} # -ALT_OBJ= -ALT_TARGET= +ALT_OBJ= ${PROG}.alt.o +ALT_TARGET= ${PROG}.alt ################# @@ -184,6 +184,9 @@ all: data ${TARGET} ${PROG}: ${PROG}.c ${CC} ${CFLAGS} $< -o $@ ${LIBS} +${PROG}.alt: ${PROG}.alt.c + ${CC} ${CFLAGS} $< -o $@ ${LIBS} + # alternative executable # alt: data ${ALT_TARGET} diff --git a/1992/albert/README.md b/1992/albert/README.md index c78f16702..21c817a9e 100644 --- a/1992/albert/README.md +++ b/1992/albert/README.md @@ -14,6 +14,38 @@ ./albert 1234567890123456789 +### Alternate code + +An alternate version of this entry, albert.fix.c, is provided. +Leo Broukhis, before he was an IOCCC judge, sent the IOCCC +judges this Email message: + +``` +From: leo _at_ zycad -dot- com (Leo Broukhis) +Date: Tue, 30 Jan 96 17:37:51 PST +To: judges _at_ toad -dot- com +Subject: IOCCC 1992 - a bug + +Dear Judges, + +albert.c (even in its fixed form) still has a bug. Although I don't +remember the number that exposed the bug (afair, resulting in coredump) +in albert.orig.c that has been fixed in albert.c, + +I've found a number exposing another bug: 10000000001 (that's 9 0's). +Both albert and albert.orig loop without printing anything, although +the first factor is 101 and is usually found in an instant. +``` + +The `albert.c` file is the fixed file, where as the `albert.alt.c` +is file before aookying Leo Broukhis' fix. + +To compile this alternate version: + + make alt + +Use `albert.alt` as you would `albert` above. + ## Judges' comments We were impressed with the speed at which it was able to factor diff --git a/1992/albert/albert.alt.c b/1992/albert/albert.alt.c new file mode 100644 index 000000000..489f27cdf --- /dev/null +++ b/1992/albert/albert.alt.c @@ -0,0 +1,152 @@ +#include +#include +#include +#include +#define new(PP) (PP *) malloc(sizeof(PP)) +typedef struct q { + jmp_buf ppp; + long qq; + struct q *P; + struct q *p; +} +PP; + +PP *P; +int aaaaaa=2; +int aaaaaaa=1; + +long qqq; + + +aaAaaa(aa,aaa) +char *aa; +char *aaa; +{ + char aaaa = 0; + if ((((( aaa ))))) + { + aaaa = *aa; + *aa=0; + aa+=strlen(aa+1); + P =new(PP); + P->P=P; + P->p=P; + } + + if ((((( !setjmp(P->ppp) ))))) + { + if ((((( !isdigit(*aa) ))))) + longjmp(P->ppp,aaaaaaa); + else { + P->p->P = new(PP); + P->p->P->P = P; + P->p->P->p = P->p; + P->p = P->p->P; + + P->qq = *aa--; + P = P->p; + aaAaaa(aa,0); + } + } else { + if ( !aaaa&&!*aa ) + longjmp(P->p->ppp,aaaaaaa); + + if ((((( (P->qq=aaaa)<10 &&! + (isdigit(aaaa)) ||! + (isdigit(*aa) ||! + *aa )))))) + { + fprintf(stderr,"Usage %c%s \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); +} + + diff --git a/1992/albert/albert.fix.hint.md b/1992/albert/albert.fix.hint.md deleted file mode 100644 index 315060ef5..000000000 --- a/1992/albert/albert.fix.hint.md +++ /dev/null @@ -1,22 +0,0 @@ -From: leo _at_ zycad -dot- com (Leo Broukhis) -Date: Tue, 30 Jan 96 17:37:51 PST -To: judges _at_ toad -dot- com -Subject: IOCCC 1992 - a bug - -Dear Judges, - -albert.c (even in its fixed form) still has a bug. Although I don't -remember the number that exposed the bug (afair, resulting in coredump) -in albert.orig.c that has been fixed in albert.c, -I've found a number exposing another bug: 10000000001 (that's 9 0's). -Both albert and albert.orig loop without printing anything, although -the first factor is 101 and is usually found in an instant. - -Unfortunately, the e-mail address in albert.hint is no longer valid, -and neither whois, nor replacing old domain name with a new one according -to the MX records, nor Altavista Web search were successful. - -...Fortunately, Albert van der Horst did send me an unobfuscated -(but somewhat limited - it doesn't check the number for factors 2, 3, 5, 7) -version of his program. I didn't have a chance to augment its functionality -to the one of the contest entry.