From 948ea60ff6d861c263c716f074e133ad24b52304 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 19 Dec 2023 05:42:16 -0800 Subject: [PATCH 1/2] Add note about optimiser in 1986/marshall --- 1986/marshall/Makefile | 8 ++++++-- 1986/marshall/README.md | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/1986/marshall/Makefile b/1986/marshall/Makefile index 44dbc46bc..13ac7b81f 100644 --- a/1986/marshall/Makefile +++ b/1986/marshall/Makefile @@ -69,7 +69,9 @@ CINCLUDE= # Optimization # -OPT= +# We DISABLE the optimiser due to funny problems in different compilers and +# systems. See compilers.md for more details on this problem. +OPT= -O0 # Default flags for ANSI C compilation # @@ -132,8 +134,10 @@ all: data ${TARGET} clean clobber install love haste waste maker easter_egg \ sandwich supernova deep_magic magic charon pluto +# We FORCE disable the optimiser due to funny problems in different compilers +# and systems. See compilers.md for details. ${PROG}: ${PROG}.c - ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} + ${CC} ${CFLAGS} -O0 $< -o $@ ${LDFLAGS} # alternative executable # diff --git a/1986/marshall/README.md b/1986/marshall/README.md index 2fe2ce2fb..dd98343e8 100644 --- a/1986/marshall/README.md +++ b/1986/marshall/README.md @@ -4,6 +4,10 @@ make all ``` + +NOTE: we FORCE disable the optimiser due to a funny problem with different +compilers and systems. See below and [compilers.md](compilers.md) for details. + There is an [alternate version](#alternate-code). The reason is a funny problem: in modern systems, depending on the platform, compiler and the optimiser, it would work with one compiler with the optimiser but it would not work with the From 9c4ca9603b63af0bfb8508550853d4ee804f5141 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 19 Dec 2023 06:00:37 -0800 Subject: [PATCH 2/2] Fixes in 1987/lievaart The optimiser was left disabled by accident. Check for !isdigit(*A) before using atoi(3) on A. This was part of the bug fixes I made (infinite loop flooding the user with invalid input which is frequent if one does not know how to play or if one makes a typo). This is in both versions, the one with the board and the entry itself (the board being too big to fit in the contest size limits of the time). --- 1987/lievaart/Makefile | 2 +- 1987/lievaart/lievaart.c | 4 ++-- 1987/lievaart/lievaart2.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/1987/lievaart/Makefile b/1987/lievaart/Makefile index 467a4f339..686e169c1 100644 --- a/1987/lievaart/Makefile +++ b/1987/lievaart/Makefile @@ -66,7 +66,7 @@ CINCLUDE= -include stdio.h # Optimization # -OPT= +OPT= -O3 # Default flags for ANSI C compilation # diff --git a/1987/lievaart/lievaart.c b/1987/lievaart/lievaart.c index 79d8b8356..7ca51ea1e 100644 --- a/1987/lievaart/lievaart.c +++ b/1987/lievaart/lievaart.c @@ -14,8 +14,8 @@ bz,lv=60,*x,*y,m,t;S(d,v,f,a,b)l*v;{l c=0,*n=v+100,bw=dbw ){zb=z;bw=w;if(w>=b||w>=8003)Y w;}}}if(!c){bz=0;C;Y-S(d+1,n,q,-b,-bw);}bz=zb;Y d>=u-1?bw+(c<<3):bw;}main(){R(;t<1100;t+=100)R(m=0;m<100;m++)V[t+m]=m<11||m>88 -||(m+1)%10<2?3:0;V[44]=V[55]=1;V[45]=V[54]=2;x:*A='\0';I("Level:");s(A);if((u -=atoi(A))>10||u<0||!isdigit(*A))goto x;e(lv>0){do{I("You:");s(A);m=atoi(A);*A='\0'; +||(m+1)%10<2?3:0;V[44]=V[55]=1;V[45]=V[54]=2;x:*A='\0';I("Level:");s(A);if((! +isdigit(*A)||(u=atoi(A))>10||u<0))goto x;e(lv>0){do{I("You:");s(A);m=atoi(A);*A='\0'; }e(!GZ(V,m,2,0)&&m!=99);if(m!=99)lv--;if(lv<15&&u<10)u+=2;I("Wait\n") ;I("Value:%d\n",S(0,V,1,-9000,9000));I("move: %d\n",(lv-=GZ(V,bz,1,0),bz));}}GZ (v,z,f,o)l*v;{l*j,q=3-f,g=0,i,h,*k=v+z;if(*k==0)R(i=7;i>=0;i--){j=k+(h=r[i]);e( diff --git a/1987/lievaart/lievaart2.c b/1987/lievaart/lievaart2.c index 25e15cc56..78280f2d9 100644 --- a/1987/lievaart/lievaart2.c +++ b/1987/lievaart/lievaart2.c @@ -19,7 +19,7 @@ t==q?50:0;Y w;}H(z,0){W(E(v,z,f,100)){c++;w= -S(d+1,n,q,0,-b,-j);W(w>j){g=bz=z; j=w;W(w>=b||w>=8003)Y w;}}}W(!c){g=0;W(_){H(x,v)c+= *x==f?1:*x==3-f?-1:0;Y c>0? 8000+c:c-8000;}C;j= -S(d+1,n,q,1,-b,-j);}bz=g;Y d>=u-1?j+(c<<3):j;}main(){R(;t< 1600;t+=100)R(m=0;m<100;m++)V[t+m]=m<11||m>88||(m+1)%10<2?3:0;x:I("Level:");V[44] -=V[55]=1;V[45]=V[54]=2;s(A);if(((u=atoi(A))>10)||u<0||!isdigit(*A))goto x;e(lv>0){Z +=V[55]=1;V[45]=V[54]=2;s(A);if(!isdigit(*A)||((u=atoi(A))>10)||u<0)goto x;e(lv>0){Z do{I("You:");s(A);m=atoi(A);*A='\0';}e(!E(V,m,2,0)&&m!=99); W(m!=99)lv--;W(lv<15&&u<10)u+=2;U("Wait\n");I("Value:%d\n",S(0,V,1,0,-9000,9000 ));I("move: %d\n",(lv-=E(V,bz,1,0),bz));}}E(v,z,f,o)l*v;{l*j,q=3-f,g=0,i,w,*k=v