diff --git a/2024/ferguson1/README.md b/2024/ferguson1/README.md
index ba65efa1b..a10029084 100644
--- a/2024/ferguson1/README.md
+++ b/2024/ferguson1/README.md
@@ -47,18 +47,20 @@ practical reasons.
```
./prog.alt
+ ./prog.alt 55 # 55 = number of turns, default 21
+ ./prog.alt 42 6666 # 42 = number of turns (default 21), 6666 = hp (default 666)
- ./prog.alt2
+ ./prog.alt2 # submitted code with bug fix
```
## Judges' remarks:
You will have to go to "Fun-Damentals" to understand the logic flow of this
-game. While you goto as many as 149 times and jump hundreds if not over one
-thousand times to travel from `main()` to a successful `exit(666)` you may have
-a devil of a time trying to figure out how this program actually does what it
-does.
+game. While the code might goto as many as 149 times to travel from `main()` to
+a successful `exit(666)` you may have a devil of a time trying to figure out how
+this program actually does what it does as it jumps hundreds if not thousands of
+times.
Before you set off on your adventure to decode this program's logic, make
sure you have enough food, ammo, clothes, oxen, and programming supplies.
@@ -76,19 +78,37 @@ finish and not counting macros but counting all function calls (not libc
functions just the few functions in prog.c), there were a total of **1416** (!)
line jumps. Skipping prog.c function calls and it was still **1131** jumps! The
prog.c, if you remove `#include`s, blank lines, lines with just a brace and
-lines that have only variables, **has just 58 (!) lines of code**. A very tiny
+lines that have only variables, **only has 58 (!) lines of code**. A very tiny
fraction of the time a line might be repeated in a row ONCE but that does not
-really matter.
-
-**NOTE**: I actually submitted two versions. This one is not encrypted. The
-encrypted one even encrypted emojis without having to decrypt them in order to
-print them (and everything else). I have kept references to encryption in this
-file even after publication. I do have a copy of it if anyone is interested.
+really matter, as it is still technically a jump.
**SUGGESTION**: if you dare, try opening
[prog.gotos.c](%%REPO_URL%%/2024/ferguson1/prog.gotos.c) in an editor with
syntax highlighting and then highlight `goto`. Alternatively, try it with `grep`
-if your grep has colours enabled (probably easier).
+if your grep has colours enabled (probably easier). This is a nice one to try:
+
+```
+ grep -E 'heaven|goto|666|hell' prog.gotos.c
+```
+
+Alternatively, in vim you might try, making sure you're in command mode first
+(hit ESC if you don't know - if that doesn't work try hitting it again as it can
+depend on what you're doing):
+
+```
+ /heaven\|goto\|666\|hell
+```
+
+Read it and weep and scream (or curse :-) )!
+
+**NOTE**: I actually submitted two versions, one encrypted (even emojis); any
+document mentioning encryption is left for personal reasons out of
+laziness and exhaustion from working on improving the presentation even after it
+won. I have a copy of the code and data files
+[here](https://ioccc.xexyl.net/2024/oregon/encrypted.txz) (more details on it
+can be found [here](https://ioccc.xexyl.net/2024/oregon/) or else in the
+markdown files in the tarball), if anyone is interested, assuming there's not an
+extended power cut or something else goes wrong.
diff --git a/2024/ferguson1/data.asc.src b/2024/ferguson1/data.asc.src
index 9a7f87591..f7b040e3d 100644
Binary files a/2024/ferguson1/data.asc.src and b/2024/ferguson1/data.asc.src differ
diff --git a/2024/ferguson1/data.scrnshot.src b/2024/ferguson1/data.scrnshot.src
index f5e0f9ae2..b45b61568 100644
Binary files a/2024/ferguson1/data.scrnshot.src and b/2024/ferguson1/data.scrnshot.src differ
diff --git a/2024/ferguson1/data.src b/2024/ferguson1/data.src
index 905480e43..88853b9e6 100644
Binary files a/2024/ferguson1/data.src and b/2024/ferguson1/data.src differ
diff --git a/2024/ferguson1/deobfuscation.html b/2024/ferguson1/deobfuscation.html
index f80c430ea..02bcbfd07 100644
--- a/2024/ferguson1/deobfuscation.html
+++ b/2024/ferguson1/deobfuscation.html
@@ -458,22 +458,24 @@ wish to more easily follow the code, though that might or might not help that
much. If a variable or other kind of symbol is missing or is not what it says
here that was by (in some cases) simply missing it or (in other cases) due to
having changed things a fair amount; this submission took a lot of work and time
-to get everything in. One variable,
p, is for the encrypted version only.
+to get everything in.
The following variables are of primary concern (some temporary ones are not
documented I think):
- O: how much you spend on oxen
-- R: amount spent on food
-- E: amount spent on ammo
-- G: amount spent on clothing
-- O: how much you spend on oxen
-- N: amount spent on miscellaneous supplies
-- T: how much money you have
+- R: amount spent on food (and how much you have)
+- E: amount spent on ammo (and how much you have)
+- G: amount spent on clothing (and how ‘much’ you have - a misnomer)
+- O: how much you spend on oxen (and how ‘many’ you have - a misnomer)
+- N: amount spent on miscellaneous supplies (and how ‘many’ you have - a misnomer)
+- T: how much money you have (in US dollars)
- e: ate an ox
- b: hp (hit points, starts out at 666, allows for survival in conditions you
can’t in the original) or stamina (kind of a combination - if you get injured
and you see the doctor and can afford it you will not keep losing hp but you
-won’t gain any either).
+won’t gain any either). Alt code allows you to specify how many hp (default
+666), if you specify also max number of turns (NB: only prog.alt.c, not
+prog.alt2.c).
- A: turn number for setting date (the first week, Monday 29 March 1847 is at
16 so to print the second week day date month and year (though it does it March
29 like the American way) you would do
V(A+16)) (note that the date is not set
@@ -512,6 +514,8 @@ certain messages. But if you buy more that could in theory happen again. Note
that some messages might be printed instead of the you have run out of oxen
message, if they’re the ones causing it, though I’m not going to say this is in
every case as there are a lot of ways for this to happen.
+C: alt code only, max number of turns (specified at command line, default
+21).
- any other variable I haven’t the foggiest, even if it’s not related to fog (of
which there is an event where you encounter fog) - sorry. An example here is
m.
diff --git a/2024/ferguson1/deobfuscation.md b/2024/ferguson1/deobfuscation.md
index eae1f13ee..d5055be5f 100644
--- a/2024/ferguson1/deobfuscation.md
+++ b/2024/ferguson1/deobfuscation.md
@@ -3,23 +3,25 @@ wish to more easily follow the code, though that might or might not help that
much. If a variable or other kind of symbol is missing or is not what it says
here that was by (in some cases) simply missing it or (in other cases) due to
having changed things a fair amount; this submission took a lot of work and time
-to get everything in. One variable, `p`, is for the encrypted version only.
+to get everything in.
The following variables are of primary concern (some temporary ones are not
documented I think):
- O: how much you spend on oxen
-- R: amount spent on food
-- E: amount spent on ammo
-- G: amount spent on clothing
-- O: how much you spend on oxen
-- N: amount spent on miscellaneous supplies
-- T: how much money you have
+- R: amount spent on food (and how much you have)
+- E: amount spent on ammo (and how much you have)
+- G: amount spent on clothing (and how 'much' you have - a misnomer)
+- O: how much you spend on oxen (and how 'many' you have - a misnomer)
+- N: amount spent on miscellaneous supplies (and how 'many' you have - a misnomer)
+- T: how much money you have (in US dollars)
- e: ate an ox
- b: hp (hit points, starts out at 666, allows for survival in conditions you
can't in the original) or stamina (kind of a combination - if you get injured
and you see the doctor and can afford it you will not keep losing hp but you
-won't gain any either).
+won't gain any either). Alt code allows you to specify how many hp (default
+666), if you specify also max number of turns (NB: only prog.alt.c, not
+prog.alt2.c).
- A: turn number for setting date (the first week, Monday 29 March 1847 is at
16 so to print the second week day date month and year (though it does it March
29 like the American way) you would do `V(A+16)`) (note that the date is not set
@@ -59,10 +61,13 @@ certain messages. But if you buy more that could in theory happen again. Note
that some messages might be printed instead of the you have run out of oxen
message, if they're the ones causing it, though I'm not going to say this is in
every case as there are a lot of ways for this to happen.
+- `C`: alt code only, max number of turns (specified at command line, default
+21).
- any other variable I haven't the foggiest, even if it's not related to fog (of
which there is an event where you encounter fog) - sorry. An example here is
`m`.
+
When an amount spent (if it happens, not necessarily going to for every
variable) spent ends up being < 0 (it's not allowed to go that low when
purchasing) it means that there is an insufficient amount (thus a variable
diff --git a/2024/ferguson1/index.html b/2024/ferguson1/index.html
index 1e63a16d7..44e30c8c1 100644
--- a/2024/ferguson1/index.html
+++ b/2024/ferguson1/index.html
@@ -495,14 +495,16 @@ practical reasons.
make alt
Alternate use:
./prog.alt
+ ./prog.alt 55 # 55 = number of turns, default 21
+ ./prog.alt 42 6666 # 42 = number of turns (default 21), 6666 = hp (default 666)
- ./prog.alt2
+ ./prog.alt2 # submitted code with bug fix
You will have to go to “Fun-Damentals” to understand the logic flow of this
-game. While you goto as many as 149 times and jump hundreds if not over one
-thousand times to travel from main() to a successful exit(666) you may have
-a devil of a time trying to figure out how this program actually does what it
-does.
+game. While the code might goto as many as 149 times to travel from
main() to
+a successful
exit(666) you may have a devil of a time trying to figure out how
+this program actually does what it does as it jumps hundreds if not thousands of
+times.
Before you set off on your adventure to decode this program’s logic, make
sure you have enough food, ammo, clothes, oxen, and programming supplies.
You’ll be driving for 2170 miles through a wild wilderness inspired
@@ -517,18 +519,28 @@ finish and not counting macros but counting all function calls (not libc
functions just the few functions in prog.c), there were a total of 1416 (!)
line jumps. Skipping prog.c function calls and it was still 1131 jumps! The
prog.c, if you remove #includes, blank lines, lines with just a brace and
-lines that have only variables, has just 58 (!) lines of code. A very tiny
+lines that have only variables, only has 58 (!) lines of code. A very tiny
fraction of the time a line might be repeated in a row ONCE but that does not
-really matter.
+really matter, as it is still technically a jump.
-
NOTE: I actually submitted two versions. This one is not encrypted. The
-encrypted one even encrypted emojis without having to decrypt them in order to
-print them (and everything else). I have kept references to encryption in this
-file even after publication. I do have a copy of it if anyone is interested.
SUGGESTION: if you dare, try opening
prog.gotos.c in an editor with
syntax highlighting and then highlight goto. Alternatively, try it with grep
-if your grep has colours enabled (probably easier).
+if your grep has colours enabled (probably easier). This is a nice one to try:
+
grep -E 'heaven|goto|666|hell' prog.gotos.c
+
Alternatively, in vim you might try, making sure you’re in command mode first
+(hit ESC if you don’t know - if that doesn’t work try hitting it again as it can
+depend on what you’re doing):
+
/heaven\|goto\|666\|hell
+
Read it and weep and scream (or curse :-) )!
+
NOTE: I actually submitted two versions, one encrypted (even emojis); any
+document mentioning encryption is left for personal reasons out of
+laziness and exhaustion from working on improving the presentation even after it
+won. I have a copy of the code and data files
+here (more details on it
+can be found here or else in the
+markdown files in the tarball), if anyone is interested, assuming there’s not an
+extended power cut or something else goes wrong.
A Pact With the Devil On the Oregon Trail (…and his 134 149 regrets of goto)
diff --git a/2024/ferguson1/prog.alt.c b/2024/ferguson1/prog.alt.c
index f031b6500..904aa727a 100644
--- a/2024/ferguson1/prog.alt.c
+++ b/2024/ferguson1/prog.alt.c
@@ -4,19 +4,19 @@
#include
#include
long x(long y,long z){ return rand()%(z-y+1)+y; }
-unsigned m,D,Q,v,l,Y,f,g,X,z,B,i,h,
+unsigned m,D,Q,v,l,Y,f,g,X,z,B,i,h,C=21,
r,u,d,e; long
O,R,E,G,O,N, T,R,A,I,L,
*o[]={ &O,&R,&E,&G,&O,&N,&I} ,a,t[7],q,M, b=666,c,W;
-char *y; FILE*K; size_t J;
+char *y,*p; FILE*K; size_t J;
#define j E=I/5;
#define w(i) { V(i); V(4); goto hell; }
-long Z(long x){ return x *1663; }
+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(void) { ++ Y; return I>0?x(1,101)+ Y>53 +a?9:0+f?9:0:0; } int main(void){ srand(time(0));
-
-K=fopen(DATA,"r"); if(!K||getdelim(&y,&J,EOF,K)<0)goto hell; goto s; aa:goto dd; u: goto M; ee:goto ff; jj:goto kk; N:for (X=
+void V(long x){ printf("%s",&y[Z(x)]); }
+long k() { return E>0?x(0,99)>49:0; } int main(int argc, char **argv) {
+b=argc>2?strtol(2[argv],0,0):b; C=1[argv]?strtoul(1[argv],0,0):C;
+K=fopen(DATA,"r"); if(!K||getdelim(&y,&J,EOF,K)<0)goto hell; goto s; aa:goto dd; u: goto M; ee:goto ff; N:for (X=
1; X < 6; ++X) { x:V(X+--(
@@ -25,19 +25,19 @@ K=fopen(DATA,"r"); if(!K||getdelim(&y,&J,EOF,K)<0)goto hell; goto s; aa:goto dd;
t[X]) if(t[X]<0 ||t[X]>
666){ V(14); goto x; goto
- heaven; l:goto C; JJ:goto W; qq:goto rr; } L=T; for(u
+ heaven; l:goto C; jj:goto kk; } L=T; for(u
=0; u < 6; ++u)L-=t[u];
if(L<0){ V(46); memset(&t,0,
- sizeof t); goto v; ZZ:goto II; } }
+ sizeof t); goto v; kk:goto ll; } }
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; c: goto d; oo:goto pp; } } } if(z)goto A; B:I=E*5;
+ goto x; } T=1666-O-R-E-G-0-N; if(T<0){ V(46); O=R=E=G=N=0; goto v; c: goto d; oo:goto W; } } } if(z)goto A; B:I=E*5;
printf(&y[Z(12)],T); if(z) goto F; switch(1) { dd:goto cc; I:goto R; default: do { if(b<1||M<0||M>2169) break; goto i;
@@ -54,42 +54,41 @@ case 2: goto T; default: goto y; } } L:goto v; T:l=1; if (I<9)V(16); else { if (
R += 23; if(!x(0,9))i=17; } else{ V(51); R+=18; } } else { V(53); } I-=9; j M-=45; } l=0; f: z=0;
- X: if(R<1){ if(O>39){ V(e=x(0,1)?18:19); O -= 40; goto q; o: goto Y; ii:goto l; } w(24) } else goto K; Y: switch(q=x(0,24))
+ X: if(R<1){ if(O>39){ V(e=x(0,1)?18:19); O -= 40; goto q; o: goto Y; ii:goto l; } w(24) } else goto K; Y: switch(q=x(0,23))
{ s: goto h;
- case 24:if(++g<4) V(73); else w(147) break;
- case 23:
-if (d) V(39); if (e) V(25); break; case 1: V(95); R+=5; break; S: if (I>1999) w(27) V(82); M-=9; N-=5; R-=20; goto Z;
+ case 23:if(++g<4) V(73); else w(147) break;
+case 1: V(95); R+=5; break; S: if (I>1999) w(27) V(82); M-=9; N-=5; R-=20; goto Z;
case 18:V(26); break; case 13: V(28); break;
- case 2: O-=40; V(71); break; mm:goto nn;
+ case 2: O-=40; V(71); break;mm:goto nn;
case 3: V(a=76); b-=70; goto jj; case 4:V(77); N-=7; M-=7; break; case 5:case
-10: if(q<6) { V(78); if(k()) { V(81); R+=9; N+=3; } else { V(f=79); b-=80; T/=4; } I=0; j } else
+10: if(q<6) { V(78); if(k()) { V(81); R+=9; N+=3; } else { V(f=79); b-=80; T/=4; I=E=0; } } else
{ V(56); if (k()) { V(a=29); T+=70; break; cc:goto ee; } else { V(f=62); M-=50; b-=35; } } break;
case 9: case 19:V(30); break; case 20:V(32); break; case 21: V(31); break; case 6: goto g; Z: break; case 16: case 22:V(49); break; case 17: V(72); break;
-case 7: V(83); M-=10; break; D: goto P; case 8: V(86); R-=30; G-=20; O-=40; V
+case 7: V(83); M-=10; break; D: goto P; case 8: V(86); R-=30; G-=20; O-=40; break; V
:switch(x(1,9)) { case 2: if(q>9){ switch(x(1,2)){ q:R+=40; goto o; case 1: switch (x(2,3)) { case 2: V(a=54); goto
m; b: w(48)
- case 3:goto J; } case 2: V(5); } goto E; ll:goto mm; J: V(a=54); } goto O; KK:goto JJ; m
+ case 3:goto J; } case 2: V(5); } goto E; ll:goto mm; J: V(a=54); } goto O; m
:goto O; goto m; default: if(q>10) goto E; if(q>7) { if(N<5) w(99) V(13); N-=5; } break; } M-=17; break; C:goto k; K:R-=R
>23 ? 23 : R > 18 ? 18 : R > 13 ? 13 :
R; goto Y; case 14: V(74); break; case 15: V(x(0,1)?69:68);
- break; d: goto I; case 11: goto V; kk:goto ll; case
+ break; d: goto I; case 11: goto V; goto m; case
- 12:V(94); M-=5; b-=19; N -= 5; break; G:goto a; case 0:V(20); } if(O>39&&!x(0,9)){ V(e = 19); O -= 40; R+=40; } 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; V(97); M-= 60; goto n; p: if (x(0,9)<5) goto t; V(21); M -=100;
+ 12:V(94); M-=5; b-=19; N -= 5; break; G:goto a; case 0:V(20); } if(O>39&&!x(0,9)){ V(e = 19); O -= 40; R+=40; } if(M<951) goto jj; if (G < 36) goto b; if (x(0,9) > 2) goto n; V(96); if (x(0,1)) goto p; V(97); M-= 60; goto n; p: if (x(0,9)<5) goto t; V(21); M -=100;
- goto n; t: V(22); M -= 85; n:if(m) goto z; m=1; if (x(0,9) < 5) goto w; V(23); z: if(M<1951||W) goto
+ goto n; t: V(22); M -= 85; n:if(m) goto z; m=1; if (x(0,9) < 5) goto w; V(23); z: if(M<1950||W) goto
U; W=1;
- if(!d&&!x(0,4)) { V(75); d=1; R+= 50; } if (G<20)w(92)
- if(!x(0,4)) w(x(0,5)?84:x(0,3)?33:34) if (x(0,9) < 7) goto w; U: goto W; w:V(35); c=1; M-=101; I += 1; j k: M-=10; goto U; W: if(d&&x(0,1)){ V(39); } while(i)heaven:w(i) if (! B && (f ||
+ if(!d&&!x(0,4)) { V(75); d=1; R+= 50; }
+ if(!x(0,4)) w(x(0,5)?84:x(0,3)?33:34) if (x(0,9) < 7) goto w; U: goto W; w:V(35); c=1; M-=101; I += 1; j k: M-=10; goto U; 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) V(B=38); else { Q=a ? 1: Q; h = f?1:h; f=a=0; V(93); T-=666; } } b-=f ? 15
:h ? 5:0; b-= a ? 5 : Q ? 15 : 0; M+=170; M+=O> 99 ? 30:- 99;
- b-=10; } while (A++<21); } if(b<1) { if(a){ w(40) XX:goto ZZ; } if(f)w(41) w(45) II:goto KK; } w(M>2169?47:36) hell:return 666; g:goto S; h:goto u; E:goto aa; Q: goto H; ff:goto ii; pp: goto qq; rr:goto XX; }
+ b-=10; } while (A++2169?47:36) hell:return 666; g:goto S; h:goto u; E:goto aa; Q: goto H; ff:goto ii; }
diff --git a/2024/ferguson1/prog.c b/2024/ferguson1/prog.c
index d310f86ed..b15fa68fc 100644
--- a/2024/ferguson1/prog.c
+++ b/2024/ferguson1/prog.c
@@ -8,7 +8,7 @@ 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;
+char *y; 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');
diff --git a/2024/ferguson1/strings.asc.loc.txt b/2024/ferguson1/strings.asc.loc.txt
index fc6ac88d5..df0eb78a4 100644
--- a/2024/ferguson1/strings.asc.loc.txt
+++ b/2024/ferguson1/strings.asc.loc.txt
@@ -820,8 +820,9 @@ one of your oxen and somehow you managed to upturn your wagon.
<90>
-Really? You tried to shoot a dragon? Well that was pointless. They ate one
-of your oxen and upturned your wagon train, causing further delays.
+Why in the absolute HELL did you fire your pistol?! There is nobody here to
+shoot, except your stupid self! And you nearly blew my head off, you did, you
+BLOODY IDIOT!
<91>
diff --git a/2024/ferguson1/strings.loc.txt b/2024/ferguson1/strings.loc.txt
index 08d6df83d..acbdc2370 100644
--- a/2024/ferguson1/strings.loc.txt
+++ b/2024/ferguson1/strings.loc.txt
@@ -981,8 +981,11 @@ one of your oxen and somehow you managed to upturn your wagon.
<90>
-Really? You tried to shoot a dragon? Well that was pointless. They ate one
-of your oxen and upturned your wagon train, causing further delays.
+🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀🔫
+💀Why in the absolute HELL did you fire your pistol?! There is nobody here to💀
+🔫shoot, except your stupid self! And you nearly blew my head off, you did, 🔫
+💀you BLOODY IDIOT! 💀
+🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀🔫
<91>
diff --git a/2024/ferguson1/strings.scrnshot.loc.txt b/2024/ferguson1/strings.scrnshot.loc.txt
index eb9bb6ee8..8c6b91cc3 100644
--- a/2024/ferguson1/strings.scrnshot.loc.txt
+++ b/2024/ferguson1/strings.scrnshot.loc.txt
@@ -1200,8 +1200,12 @@ one of your oxen and somehow you managed to upturn your wagon.
<90>
-Really? You tried to shoot a dragon? Well that was pointless. They ate one
-of your oxen and upturned your wagon train, causing further delays.
+🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫
+💀Why in the absolute HELL did you fire your pistol?! 💀
+🔫 There is nobody here to shoot, except your stupid 🔫
+💀 self! And you nearly blew my head off, you did, you💀
+🔫 BLOODY IDIOT! 🔫
+💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀 🔫 💀
<91>