diff --git a/2024/ferguson1/.entry.json b/2024/ferguson1/.entry.json index ca541a256..8957547e4 100644 --- a/2024/ferguson1/.entry.json +++ b/2024/ferguson1/.entry.json @@ -37,6 +37,14 @@ "display_via_github" : true, "entry_text" : "alternate source code" }, + { + "file_path" : "prog.goto.max.c", + "inventory_order" : 40, + "OK_to_edit" : true, + "display_as" : "c", + "display_via_github" : true, + "entry_text" : "entry source code with maxed out gotos" + }, { "file_path" : "prog.orig.c", "inventory_order" : 50, @@ -102,12 +110,20 @@ "entry_text" : "hints on how to deobfuscate" }, { - "file_path" : "gotos.txt", + "file_path" : "gotos.c.txt", "inventory_order" : 100, "OK_to_edit" : true, "display_as" : "text", "display_via_github" : true, - "entry_text" : "text file showing all the line changes in a run" + "entry_text" : "text file showing only the gotos in the entry code" + }, + { + "file_path" : "jumps.txt", + "inventory_order" : 100, + "OK_to_edit" : true, + "display_as" : "text", + "display_via_github" : true, + "entry_text" : "text file showing all the line changes in a single run" }, { "file_path" : "lencount.c", diff --git a/2024/ferguson1/.gitignore b/2024/ferguson1/.gitignore index e04469a91..551096ebd 100644 --- a/2024/ferguson1/.gitignore +++ b/2024/ferguson1/.gitignore @@ -20,4 +20,7 @@ printer prog.alt.asc prog.alt.scrnshot prog.asc +prog.goto.max +prog.goto.max.asc +prog.goto.max.scrnshot prog.scrnshot diff --git a/2024/ferguson1/Makefile b/2024/ferguson1/Makefile index 234d2d9ae..1528d00f3 100644 --- a/2024/ferguson1/Makefile +++ b/2024/ferguson1/Makefile @@ -154,8 +154,10 @@ TARGET= ${PROG} ${PROG}.asc ${PROG}.scrnshot # .alt is as above more events # -ALT_OBJ= ${PROG}.alt.o ${PROG}.alt.asc.o ${PROG}.alt.scrnshot.o -ALT_TARGET= ${PROG}.alt ${PROG}.alt.asc ${PROG}.alt.scrnshot +ALT_OBJ= ${PROG}.alt.o ${PROG}.alt.asc.o ${PROG}.alt.scrnshot.o ${PROG}.goto.max.o \ + ${PROG}.goto.max.asc.o ${PROG}.goto.max.scrnshot.o +ALT_TARGET= ${PROG}.alt ${PROG}.alt.asc ${PROG}.alt.scrnshot ${PROG}.goto.max \ + ${PROG}.goto.max.asc ${PROG}.goto.max.scrnshot # list any data files supplied with the submission # @@ -350,12 +352,30 @@ ${PROG}.alt.asc: ${PROG}.alt.c ${MAKE} padding ${CC} ${CFLAGS} -DDATA='"data.asc"' ${PROG}.alt.c -o $@ ${LDFLAGS} +# goto maxed out - regular data file +# +${PROG}.goto.max: ${PROG}.goto.max.c + ${MAKE} padding + ${CC} ${CFLAGS} -DDATA='"data"' ${PROG}.goto.max.c -o $@ ${LDFLAGS} + +# goto maxed out - ASCII only data file +# +${PROG}.goto.max.asc: ${PROG}.goto.max.c + ${MAKE} padding + ${CC} ${CFLAGS} -DDATA='"data.asc"' ${PROG}.goto.max.c -o $@ ${LDFLAGS} + # screenshot friendly version of alt code # ${PROG}.alt.scrnshot: ${PROG}.alt.c ${MAKE} padding ${CC} ${CFLAGS} -DDATA='"data.scrnshot"' ${PROG}.alt.c -o $@ ${LDFLAGS} +# goto maxed out - screenshot friendly version +# +${PROG}.goto.max.scrnshot: ${PROG}.goto.max.c + ${MAKE} padding + ${CC} ${CFLAGS} -DDATA='"data.scrnshot"' ${PROG}.goto.max.c -o $@ ${LDFLAGS} + # data files # data: ${DATA} diff --git a/2024/ferguson1/README.md b/2024/ferguson1/README.md index eaa28b6b1..c8622d77f 100644 --- a/2024/ferguson1/README.md +++ b/2024/ferguson1/README.md @@ -2455,11 +2455,15 @@ really does not seem to be dead (it's quite sneaky). I could be wrong on whether this is one the compiler missed though: it's hard to follow all the `goto`s. As you find out in [obfuscation.html](obfuscation.html) it's -134 after pre-processing! Yes I might be mad. But then again I might just be -the Devil. Who knows? What I do know is code that is meant to be reached is -reached! Yes I've played it many times. Some code I made dead seemed totally -useless but why not add to confusion? If that includes one that the compiler -misses that's even better! +134 after pre-processing! One of the alt versions I supplied is 131 before the +cpp and 149 after. I did not submit that for practical reasons but I kind of +wish I had, now that it won. Nonetheless 134 is already way too many. 149 is +much worse. + +Yes I might be mad. But then again I might just be the Devil. Who knows? What I +do know is code that is meant to be reached is reached! Yes I've played it many +times. Some code I made dead seemed totally useless but why not add to +confusion? If that includes one that the compiler misses that's even better! It is **NOT** a bug where in the inner switch there is a missing case. That is done because I do not want it to always trigger. That is the one that is in a @@ -3017,7 +3021,12 @@ In general I think it's extremely hard to follow the flow of this program due to the abuse of 116 `goto`s, more than the BASIC game. 134 when pre-processed. But let's be honest, or 134 for a small C program is too many but to be only six fewer than a larger BASIC program? That is hard to fathom. Not that 116 is not -too many for larger programs...or one goto, for that matter. +too many for larger programs...or one goto, for that matter. As noted elsewhere, +an alt version has 131/149 gotos, before/after the cpp. I did not make it the +main version when submitting because I did not want to make the judges weep and +curse any more than they already had to (besides, it can't be 4666 bytes with +the extra `goto`s) but now that it's in I have no qualms about providing it as +alt code: if I am going to ruin `goto`s I might as well do it properly. Some things are clear about the program from visual inspection: @@ -3257,7 +3266,7 @@ Except on the Oregon Trail. I was right too: the entire game is worse, far far worse. After this won I did a full sequence. This is from start to finish and I include it for your amusement -(see [gotos.txt](gotos.txt) for the line changes including calls to prog.c +(see [jumps.txt](jumps.txt) for the line changes including calls to prog.c functions). Or horror. There are a few times where the line is the same but that only shows how very often the line changes. It is a total of **985** (!) changes, counting function calls, and **776** (!) excluding diff --git a/2024/ferguson1/gotos.c.txt b/2024/ferguson1/gotos.c.txt new file mode 100644 index 000000000..3d2b13bc4 --- /dev/null +++ b/2024/ferguson1/gotos.c.txt @@ -0,0 +1,134 @@ + goto A; + goto f; + goto PP; + goto hell; + goto M; + goto hell; + goto M; + goto G; + goto hell; + goto M; + goto hell; + goto M; + goto S; + goto hell; + goto M; + goto OO; + goto L; + goto i; + goto kk; + goto HA; + goto at; + goto I; + goto r; + goto II; + goto F; + goto c; + goto zz; + goto qq; + goto C; + goto N; + goto dd; + goto jj; + goto oo; + goto ee; + goto x; + goto heaven; + goto XT; + goto ET; + goto v; + goto x; + goto v; + goto ZZ; + goto bb; + goto s; + goto X; + goto v; + goto T; + goto y; + goto E; + goto d; + goto P; + goto to; + goto y; + goto TA; + goto BB; + goto LL; + goto uu; + goto JJ; + goto B; + goto h; + goto l; + goto e; + goto hell; + goto M; + goto Y; + goto P; + goto K; + goto tt; + goto Z; + goto W; + goto ha; + goto D; + goto m; + goto Z; + goto H; + goto Z; + goto g; + goto Z; + goto Z; + goto Z; + goto Y; + goto MM; + goto hell; + goto M; + goto J; + goto Q; + goto k; + goto W; + goto hell; + goto M; + goto q; + goto TT; + goto P; + goto U; + goto hell; + goto M; + goto QQ; + goto KK; + goto z; + goto k; + goto k; + goto k; + goto hell; + goto M; + goto M; + goto yy; + goto Z; + goto rr; + goto hell; + goto M; + goto a; + goto Z; + goto Z; + goto Z; + goto go; + goto ii; + goto o; + goto V; + goto Z; + goto Y; + goto O; + goto W; + goto b; + goto n; + goto p; + goto x; + goto j; + goto n; + goto R; + goto t; + goto n; + goto u; + goto w; + goto _; diff --git a/2024/ferguson1/index.html b/2024/ferguson1/index.html index 24da10042..008d95bf5 100644 --- a/2024/ferguson1/index.html +++ b/2024/ferguson1/index.html @@ -2450,11 +2450,14 @@ might be one that the compiler does not trigger a dead code warning on. It really does not seem to be dead (it’s quite sneaky).
I could be wrong on whether this is one the compiler missed though: it’s hard to
follow all the gotos. As you find out in obfuscation.html it’s
-134 after pre-processing! Yes I might be mad. But then again I might just be
-the Devil. Who knows? What I do know is code that is meant to be reached is
-reached! Yes I’ve played it many times. Some code I made dead seemed totally
-useless but why not add to confusion? If that includes one that the compiler
-misses that’s even better!
Yes I might be mad. But then again I might just be the Devil. Who knows? What I +do know is code that is meant to be reached is reached! Yes I’ve played it many +times. Some code I made dead seemed totally useless but why not add to +confusion? If that includes one that the compiler misses that’s even better!
It is NOT a bug where in the inner switch there is a missing case. That is
done because I do not want it to always trigger. That is the one that is in a
sense polymorphic. One of the events is actually immediate death, in particular
@@ -2897,7 +2900,12 @@ I mentioned in obfuscation.html (and some briefly
the abuse of 116 gotos, more than the BASIC game. 134 when pre-processed. But
let’s be honest, or 134 for a small C program is too many but to be only six
fewer than a larger BASIC program? That is hard to fathom. Not that 116 is not
-too many for larger programs…or one goto, for that matter.
gotos) but now that it’s in I have no qualms about providing it as
+alt code: if I am going to ruin gotos I might as well do it properly.
Some things are clear about the program from visual inspection:
I was right too: the entire game is worse, far far worse. After this won I did a full sequence. This is from start to finish and I include it for your amusement -(see gotos.txt for the line changes including calls to prog.c +(see jumps.txt for the line changes including calls to prog.c functions). Or horror. There are a few times where the line is the same but that only shows how very often the line changes. It is a total of 985 (!) changes, counting function calls, and 776 (!) excluding @@ -3708,6 +3716,7 @@ helps you appreciate the careful design even more.prog.c - entry source code
goto
Here’s the horrifying and hilarious truth: I beat it out by 92 MORE, BEFORE the
cpp at 116 and after the cpp is through I beat it by 110 MORE (!!), AT
-134! Yes, you read that right. 134 gotos!
+134! Yes, you read that right. 134 gotos! I even went further in an alt
+version, where before the cpp it was 131 gotos and after the cpp 149 (!!)
+gotos. I didn’t do this in the main entry for practical reasons but I wish I
+had.
Even removing what I think are the only dead gotos, two of them, including one
that is in the w() macro that would be translated into more, I beat it by 90
more, at 114 before the cpp, and 99 more after the cpp, at 123!
diff --git a/2024/ferguson1/obfuscation.md b/2024/ferguson1/obfuscation.md
index 103c7868f..2663455cf 100644
--- a/2024/ferguson1/obfuscation.md
+++ b/2024/ferguson1/obfuscation.md
@@ -50,7 +50,10 @@ many. Unless I am very much mistaken, I have broken the record by a huge margin.
Here's the horrifying and hilarious truth: I beat it out by 92 MORE, **BEFORE** the
cpp at 116 and after the cpp is through I beat it by **110** MORE (!!), **AT
-134!** Yes, you read that right. 134 `goto`s!
+134!** Yes, you read that right. 134 `goto`s! I even went further in an alt
+version, where before the cpp it was 131 `goto`s and after the cpp 149 (!!)
+`goto`s. I didn't do this in the main entry for practical reasons but I wish I
+had.
Even removing what I think are the only dead `goto`s, two of them, including one
that is in the `w()` macro that would be translated into more, I beat it by 90
diff --git a/2024/ferguson1/prog.goto.max.c b/2024/ferguson1/prog.goto.max.c
new file mode 100644
index 000000000..28edc5aa5
--- /dev/null
+++ b/2024/ferguson1/prog.goto.max.c
@@ -0,0 +1,85 @@
+#include
+#include
+#include
+#include
+#include
+long x(long y, long z){ return rand()%(z-y+1)+y; }
+unsigned m,D,Q,v,l,f,X,z,B,i,h,
+ r,u,d,e; long
+O,R,E,G,O,N, T,R,A,I,L,
+*o[]={ &O,&R,&E,&G,&O,&N} ,a,t[7],q,M, b=666,c,W;
+char *y,*p; FILE*K; size_t J;
+#define w(i) { V(i); V(4); goto hell; goto M; }
+long Z(long x){ return x * 1663; }
+#define S(x,z) while(scanf(&y[Z(x)],&z)!=1)while(getchar()!='\n');
+void V(long x){ printf("%s",&y[Z(x)]); }
+long k() { return E>0?x(0,99)>49:0; } int main() {
+switch(1)
+ { j:if(z)goto A; E*=5; B:
+ printf(&y[Z(12)],T); if(z) { goto f; } goto PP; default: srand(time(0));
+K=fopen(DATA,"r"); if(!K||getdelim(&y,&J,EOF,K)<0)
+ goto hell; goto M; OO: if(b<1) { if(a){ w(40) PP: goto G; } if(f) w(41) w(45) g:goto S; } w(M>2169?47:45)
+ hell:
+ return
+ 666; rr:;
+
+ goto CC; yy:
+{ if(b<1||M<0||M>2169){ goto _; F:V(51); R+=18; goto L; } goto i;
+
+P:for(X=1; X<--(unsigned){ 7 } ; ){ goto kk; BB:*o[X]+=(X==2?t[X]*5:t[X]); goto HA; TA:++X; goto at; ZZ:; }
+printf(&y[Z(11)],R,E,G,O,N,T,b,M); if(x(0,1))goto I; R:if(R<14)V(37); if(z) { z=0; l: { if (k()) { if (x(0,9) > 4) { V(52);
+
+R+=23; if(!x(0,9)){ goto r; L: goto II; } c:; } else{ goto F; r: goto c; qq: { V(53); goto zz; } II:; } } else { goto qq; } zz: E-=9; M-=45; } goto C; y:V(42); S(2,r) switch(r) { M:V(1); v:memset(&t,0,sizeof t); goto
+ N; D:{ if (k()) { goto dd; ii:V(f=79); b -= 80; T/=4; goto jj; ee:; } else { goto oo; dd:V(a=29); T+=70; goto ee; x:V(X+--(
+unsigned){ 6 } ); if(z){ S(3,
+
+t[X])if(t[X]<0||t[X]>
+
+ 666 ){ V(14); goto x; goto
+ heaven ; ET:L-=t[u]; goto XT; } L=T; for(u
+
+ =0; u < 6; ++u){ goto ET; XT:; }
+
+ if(L<0){ V(46); memset(&t,0,
+
+ sizeof t); goto v; } }
+
+ else{ S(3 ,*(o[X])) if(
+
+ *o[X]<0||*o[X] >
+ 666) { V(14);
+
+ goto x; } T=1666-O-R-E-G-0-N; if(T<0){ V(46); O=R=E=G=N=0; goto v; LL:*o[X]=0; uu:++X; goto ZZ; } } goto bb; } } goto s; case 3: goto X; case 1:z=1; M-=45; goto v;
+case 2:goto T; } goto y;
+O:{ V(e = 19); O -= 40; R+=40; } goto E; i:if(O<1){ goto d; } else { goto vv; mm:; } goto P; go: V(81); R+=9; N+=3; goto to;
+} else{ goto y; HA:T-=X[t]; goto TA; A:for(X=1; X < 6; ){ goto BB; kk:if (*o[X]<0) goto LL; goto uu; QQ:V(B=38); goto JJ; at:; } goto B;
+} T:l=1; if (E<9){ goto h; } else { goto l; h: V(16); goto C; DD: goto u; } C: l=0; f:z=0;
+X:if(R<1){ goto e; U: w(24) K:R-=R
+ >23?23:R>18? 18 : R > 13 ? 13 :
+ R; goto Y; TT:V(v=15); O=0; goto P; } else { goto K; } goto tt; Y:switch(q=x(0,23))
+{ case 1:V(95); R+=5; goto Z; case 18:V(26); goto Z; case 13:V(28); goto Z;
+case 2:O-=40; V(71); goto Z; case 3:V(a=76); b-=70; goto W; case 4:V(77); N-=7; M-=7; goto Z; case 5:case
+10:if(q<6) { goto ha; m: V(56); goto D; CC: goto OO; o:; } else
+{ goto m; oo:V(f=62); M-=50; b-=35; s:; } goto Z; a:goto H;
+case 9:case 19:V(30); goto Z; case 20:V(32); goto Z; case 21 :V(31); goto Z; case 6:goto g; case 16: case 22:V(49); goto Z; case 17:V(72); goto Z;
+case 7:V(83); M-=10; goto Z; case 8:V(86); R-=30; G-=20; O-=40; V
+ :switch(x(1,9)){ case 2:if(q>9){ switch(x(1,2)){ q:R+=40; goto Y; case 1:{ switch (x(2,5)) { case 2:V(a=54); goto
+ MM; b:w(48)
+case 3:goto J; N:goto Q; case 4:i=17; } } case 2: V(5); } goto k; u: if(M<1951||W){ goto
+W; } W=1;
+if(!d&&!x(0,4)){ V(75); d=1; R+= 50; }
+if(!x(0,3)){ w(x(0,4)?84:x(0,4)?33:34) e:if(O>39){ goto xx; vv:v=0; goto mm; d:{ if(!v)goto TT; goto P; } } goto U; } if (x(0,9) < 5) w:V(35); c=1; M-=101; ++E; k: M-=10; W: if(x(0,1)){ if (d) V(39); if(e)V(25); } while(i)heaven:{ w(i) } if (!B&&(f||
+a)){ if(d&&a) V(91); if(T<666){ goto QQ; KK:Q=a?1:Q; h=f?1:h; f=a=0; V(93); T-=666; } else{ goto KK; } JJ:; } b-=f?15
+
+ :h?5:0; b-=a?5:Q?15:0; M+=170; M+=O> 99 ? 30:- 99;
+
+b-=10; goto z; J: V(a=54); } goto k; MM
+
+ :goto k; default: if(q>10) { goto k; } if(q>7) { if(N<5) { w(99) goto M; G:goto yy; } V(13); N-=5; } goto Z; _:goto rr; S:if (E>1999){ w(27) I:goto a; } V(82); M-=9; N-=5; R-=20; goto Z;
+ } M-=17; goto Z; case 14: V(74); goto Z; case 15: V(x(0,1)?69:68);
+ goto Z; ha:V(78); if(k()){ goto go; to:; } else { goto ii; jj:; } goto o; case 11: goto V; case
+ 12:V(94); M-=5; b-=19; N -= 5; goto Z; tt: goto Y; case 0:V(20); Z:; } if(O>39&&!x(0,9)){goto O; xx: V(e=x(0,1)?18:19); O -= 40; goto q; } E: if(M<951) goto W; if (G < 36){ goto b; } if (x(0,9) > 2) goto n; V(96); if (x(0,1)) { goto p; Q: for (X=
+1; X < 6; ++X) { goto x; bb:; } goto j; } V(97); M-= 60; goto n; H:goto R; p: if (x(0,9)<3) goto t; V(21); M -=99;
+goto n; t: V(22); M -= 85; n:if(m){ goto DD; } m=1; if (x(0,9) > 5) goto w; V(23); z:; } if (A++<21) goto yy; goto _;
+}
+}