improve how markdown code language is commented
We added a space between the markdown triple code mark and language that was enclosed in HTML comments. So a line of the form: ```` ```<!---c---> ```` became: ```` ``` <!---c---> ```` This was done to **help** some code see that the HTML comment string was not a markdown code specifier. Not all code understands this after this changed. For example, `pandoc(1)` still forms HTML classes of the form "<!---c-->" when it encounters the above mentioned change. We also fixed a problem with `2019/dogon/README.md` regarding a markdown code block. We also fixed a problem with `2020/yang/README.md` regarding a markdown code block.
This commit is contained in:
1 parent
c549f6585e
commit
3ddbac9e6b
357 files changed
+2432
-2399
No files matched your search
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
@@ -18,14 +18,14 @@ For more detailed information see [2020 burton bugs](../../bugs.html#2020_burton
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog arg ...
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -67,7 +67,7 @@ result?
|
||||
|
||||
This code may be tested by:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make test
|
||||
```
|
||||
|
||||
@@ -107,19 +107,19 @@ Compiles cleanly under `clang -Wall -Weverything -pedantic`, but you need to add
|
||||
|
||||
On a little-endian machine:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
clang -include stdio.h -include stdlib.h -Wall -Weverything -pedantic -DB=6945503773712347754LL -DI=5859838231191962459LL -DT=0 -DS=7 -o prog prog.c
|
||||
```
|
||||
|
||||
On a big-endian machine:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
clang -include stdio.h -include stdlib.h -Wall -Weverything -pedantic -DB=7091606191627001958LL -DI=6006468689561538903LL -DT=1 -DS=0 -o prog_be prog.c
|
||||
```
|
||||
|
||||
You might be interested to compile it both ways on the same host, and try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog 1; ./prog_be 1
|
||||
```
|
||||
|
||||
|
||||
+23
-23
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
@@ -18,20 +18,20 @@ For more detailed information see [2020 carlini bugs](../../bugs.html#2020_carli
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
Or if you actually want to play:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
# Play with a friend, real or imagined, P1 and P2, squares are numbered 1..9
|
||||
./prog
|
||||
```
|
||||
@@ -51,7 +51,7 @@ HOW ABOUT A NICE GAME OF <strike>CHESS</strike>TIC-TAC-TOE?
|
||||
|
||||
### USAGE
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
cc -o prog prog.c
|
||||
./prog
|
||||
```
|
||||
@@ -92,7 +92,7 @@ compilers unhappy, and others slow. (For example, passing GCC the flags `-Wall
|
||||
|
||||
Under some terminals the program may exit early. The following should always work:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
echo "1 2 3 4 5 6 7" | ./prog
|
||||
```
|
||||
|
||||
@@ -100,7 +100,7 @@ Under some terminals the program may exit early. The following should always wor
|
||||
|
||||
The entirety of the program consists of a single iterated call to `printf(3)`.
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
int main() {
|
||||
while(*d) printf(fmt, arg);
|
||||
}
|
||||
@@ -144,13 +144,13 @@ Format specifiers can take extra "arguments".
|
||||
|
||||
For example, the following expression
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
printf("%1$.*2$d%3$hhn", 5, 10, &x)
|
||||
```
|
||||
|
||||
will have the same effect as if we had written
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
x = 10;
|
||||
```
|
||||
|
||||
@@ -174,37 +174,37 @@ We can use format strings to compute the OR/NOT of arbitrary "bits".
|
||||
|
||||
We'll start with the simplest, OR:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
printf("%1$s%2$s%3$hhn", a, b, c)
|
||||
```
|
||||
|
||||
will compute
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
*c = strlen(a) + strlen(b)
|
||||
```
|
||||
|
||||
but given that `strlen(x)` is `1` for a 1-bit and `0` for a 0-bit, we have
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
*c = a | b
|
||||
```
|
||||
|
||||
Computing the NOT of a single value is also easy:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
printf("%1$255d%1$s%hhn", a, b)
|
||||
```
|
||||
|
||||
will compute
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
*b = (strlen(a)+255)%256 = strlen(a)-1
|
||||
```
|
||||
|
||||
and again, because `strlen(x)` is either `1` or `0` we have
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
*c = !b
|
||||
```
|
||||
|
||||
@@ -221,7 +221,7 @@ To detect who has won, we implement the following logic. Let `A`, `B`, and `C` b
|
||||
pointers to three squares in a row to test, and `D` be where to save if there is a
|
||||
win or not.
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
"%A$s%B$s%C$s%1$253d%11$hhn" // r11 = !(*A & *B & *C)
|
||||
ZERO
|
||||
"%11$s%1$255d%11hhn" // r11 = !r11
|
||||
@@ -235,7 +235,7 @@ possible three-in-a-row configurations, for both players.
|
||||
The ZERO macro ensures that the number of bytes written out is 0 mod 256 with
|
||||
the following expression
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
"%1$hhn%1$s" (repeated 256 times)
|
||||
```
|
||||
|
||||
@@ -254,13 +254,13 @@ bits to Xs and Os to print out. This is actually rather straightforward. Given
|
||||
in `1$` the pointer to player 1's square, and `2$` the pointer to player 2's, and
|
||||
in `3$` the pointer to the board string, we can compute
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
"%1$s" (repeated 47 times) "%2$s" (repeated 56 times) %1$32d%3$hhn"
|
||||
```
|
||||
|
||||
which will, in effect, compute
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
*r3 = (*r1) * 47 + (*r2) * 56 + 32
|
||||
```
|
||||
|
||||
@@ -273,7 +273,7 @@ which will output `' '` if neither are true, `'X'` if `r1` is true, or `'O'` if
|
||||
In order to be able to finally display the board, while still only using one
|
||||
`printf(3)` statement, we finish the statement with
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
"\n\033[2J\n%26$s"
|
||||
```
|
||||
|
||||
@@ -299,7 +299,7 @@ won, or the game is over and it is a draw.
|
||||
This turns out not to be as hard as it might look. Using the same trick as
|
||||
before, we set byte four to be
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
*byte4 = is_win * 'W' + is_tie * 'T'
|
||||
```
|
||||
|
||||
@@ -313,7 +313,7 @@ ends. It should just exit.
|
||||
|
||||
One option would be to implement the logic as
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
printf()
|
||||
while (*ok) {
|
||||
scanf();
|
||||
@@ -324,7 +324,7 @@ One option would be to implement the logic as
|
||||
but this would DOUBLE the number of calls to `printf(3)` we require. So instead we
|
||||
implement it like this
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
while (*ok) {
|
||||
scanf();
|
||||
printf();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
@@ -10,7 +10,7 @@ code](#alternate-code) below.
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
# IMPORTANT for macOS: run under Terminal.app
|
||||
|
||||
./prog
|
||||
@@ -19,7 +19,7 @@ code](#alternate-code) below.
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
# IMPORTANT for macOS: run under Terminal.app
|
||||
|
||||
# Try resizing the terminal window before the first click.
|
||||
@@ -41,7 +41,7 @@ Author's remarks for more details.
|
||||
|
||||
### Alternate build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make alt
|
||||
```
|
||||
|
||||
@@ -94,7 +94,7 @@ All you have to do is (0). You can test if you are lucky or not.
|
||||
|
||||
It uses ncurses:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
gcc -o prog prog.c -lncurses
|
||||
./prog
|
||||
```
|
||||
@@ -200,7 +200,7 @@ Analyze the code.
|
||||
|
||||
You can also play with a prepared map.
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog ioccc.txt
|
||||
```
|
||||
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
What happens if you do
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog prog.c
|
||||
```
|
||||
|
||||
@@ -41,7 +41,7 @@ render for a larger terminal window? How about adding more glyphs?
|
||||
|
||||
No! Try not. Do, or do not. There is no try.
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
cc -std=c99 prog.c
|
||||
./a.out
|
||||
./a.out hello.txt
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
@@ -10,14 +10,14 @@ code](#alternate-code) below.
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./run_clock
|
||||
# And watch closely for 15-20 seconds
|
||||
```
|
||||
@@ -31,7 +31,7 @@ alternate code uses Unicode letters.
|
||||
|
||||
### Alternate build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make alt
|
||||
```
|
||||
|
||||
@@ -43,7 +43,7 @@ Use `prog.alt` as you would `prog` above.
|
||||
|
||||
### Alternate try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./run_clock.alt
|
||||
# And watch closely for 15-20 seconds
|
||||
```
|
||||
@@ -63,7 +63,7 @@ time might depend on what time it is.
|
||||
|
||||
Prepare a mirror!
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make clock
|
||||
```
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ I imagine that it works for 32-bit systems but I do not know for sure.
|
||||
|
||||
You should be able to get the compiler with:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
sudo xcode-select --install
|
||||
```
|
||||
|
||||
@@ -53,13 +53,13 @@ you want to use the Makefile) to compile and link this entry. With Fedora more
|
||||
recent versions there's the `dnf` package manager but I cannot help with any of
|
||||
the GUI installers since I don't use them. Something like:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
sudo dnf install ncurses-devel ncurses make gcc
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
# dnf install ncurses-devel ncurses make gcc
|
||||
```
|
||||
|
||||
@@ -69,25 +69,25 @@ Just like Fedora you will need `gcc`, `ncurses`, `ncurses-devel` (and if you
|
||||
want to use the Makefile `make`). CentOS uses `yum` and CentOS 8 uses `dnf`.
|
||||
So:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
sudo yum install ncurses-devel ncurses make gcc
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
# yum install ncurses-devel ncurses make gcc
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
sudo dnf install ncurses-devel ncurses make gcc
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
# dnf install ncurses-devel ncurses make gcc
|
||||
```
|
||||
|
||||
|
||||
+13
-13
@@ -78,7 +78,7 @@ initialise a pair (make it 5 so as to not interfere with the script
|
||||
customisability) and then you use the bkgd() function with the colour pair.
|
||||
Something like this:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
init_pair(5, COLOR_BLACK, COLOR_WHITE);
|
||||
bkgd(COLOR_PAIR(5));
|
||||
```
|
||||
@@ -88,7 +88,7 @@ but that changes the background of the program anyway.
|
||||
|
||||
The standard colour identifiers are:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
COLOR_BLACK
|
||||
COLOR_RED
|
||||
COLOR_GREEN
|
||||
@@ -124,7 +124,7 @@ Let's say you don't want to use arrow keys or you don't have arrow keys. Instead
|
||||
you might want the keys `l`, `r`, `u` and `d` for the directions. Find the case
|
||||
statements:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
case KEY_LEFT:
|
||||
case KEY_RIGHT:
|
||||
case KEY_UP:
|
||||
@@ -133,7 +133,7 @@ statements:
|
||||
|
||||
Replace `KEY_LEFT` with:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
'l'
|
||||
```
|
||||
|
||||
@@ -141,7 +141,7 @@ and do the same thing for the other directions too. If you want more than one
|
||||
key e.g. the arrow keys and the letters just add another case statement e.g. for
|
||||
left it might be:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
case KEY_LEFT: case 'l':
|
||||
```
|
||||
|
||||
@@ -166,13 +166,13 @@ different sets. Please also be aware that if you don't want any information you
|
||||
must set it to the below at the very least; defining it without a value is not
|
||||
enough (it amounts to the parameters to a printf call):
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
#define J " " );
|
||||
```
|
||||
|
||||
If you don't care about brief displays of 'o' at 0,0 you can just have:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
#define J "");
|
||||
```
|
||||
|
||||
@@ -194,7 +194,7 @@ coordinates of where the snake is plus the other things that are there (a number
|
||||
of which were added over time). Obviously this would take many bug sized bytes
|
||||
(bites) even once let alone twice! Thus I made it into a define:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
#define J Z(X:%d/%d Y:%d/%d S:%zu/%zu B:%zu\n), Y, y[-2], X,*y,A,g, c);
|
||||
```
|
||||
|
||||
@@ -220,7 +220,7 @@ For an example this would only include the size of the snake and the number of
|
||||
bugs eaten (I think I have this correct; I've made many changes to the point of
|
||||
not wanting to mess with anything that's unnecessary):
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
#define J Z(SIZE: %zu BUGS: %zu\n), A, c);
|
||||
```
|
||||
|
||||
@@ -257,13 +257,13 @@ come to mind as information that might be of interest.
|
||||
|
||||
Quite simply change:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
X = H / 2; Y = *x / 2;
|
||||
```
|
||||
|
||||
To be something like:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
X = R(1,H-1);
|
||||
Y = R(2,*x-1);
|
||||
```
|
||||
@@ -395,7 +395,7 @@ street!).
|
||||
If you look at the walls code you will see a ternary operator for both `X` and `Y`
|
||||
coordinates. This of course is very different now but the idea remains the same:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
if (p && !(*O>=O[1]||H>=M(1)))
|
||||
{
|
||||
if (X<1||X>=H)
|
||||
@@ -414,7 +414,7 @@ coordinates to the correct new location.
|
||||
If however you wanted the walls to act as a barrier you could do something like
|
||||
this instead (omitting the inner if statements here):
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
X=X<1?1:*H-1;
|
||||
|
||||
Y=Y<2?2:*O-1;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
@@ -18,7 +18,7 @@ For more detailed information see [2020 ferguson1 bugs](../../bugs.html#2020_fer
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WAIT=N WALLS=[01] EVADE=N SIZE=N MAXSIZE=N GROW=N SHEDS=N SHED=N CANNIBAL=[01] ./prog
|
||||
# start pressing some arrow keys
|
||||
```
|
||||
@@ -87,7 +87,7 @@ and non-zero).
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make test
|
||||
|
||||
WAIT=75 WALLS=1 CANNIBAL=1 ./prog
|
||||
@@ -211,7 +211,7 @@ features.
|
||||
Because all IOCCC entries should have a man page I have included one (even
|
||||
though much of it is what's also above). To render try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
man ./snake.1
|
||||
```
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ simply a fun consequence of the features I did implement.
|
||||
Let's say you want to verify that the evade mode is at the right count. How
|
||||
can you verify it without modifying the code? Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SIZE=0 SHED=1 SHEDS=1 EVADE=10 ./prog
|
||||
```
|
||||
|
||||
@@ -44,7 +44,7 @@ don't at this time remember any I might have done.
|
||||
One way to show this is in full is to set the initial size and growth size to a
|
||||
high value; then try each one individually. For example:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SIZE=100 ./prog
|
||||
```
|
||||
|
||||
@@ -113,7 +113,7 @@ Here's a fun output:
|
||||
|
||||
That's from:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SHED=1 SHEDS=-1 ./prog
|
||||
```
|
||||
|
||||
@@ -126,7 +126,7 @@ And right after that you would see:
|
||||
|
||||
Try this though:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SHEDS=-1 SHED=25 ./prog
|
||||
```
|
||||
|
||||
@@ -138,7 +138,7 @@ this is the basis of the grow/shrink mode of play that I talk about in the
|
||||
|
||||
Here's another thing to be aware of. Let's say you do:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SIZE=1 GROW=-1 ./prog
|
||||
```
|
||||
|
||||
@@ -146,7 +146,7 @@ How many bugs will it take before you win? In fact it's two: you would see the
|
||||
head twice: the second time once you 'shrink' down to size 0; it would then be
|
||||
that if you get another bug you will be at the 'max size':
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
YOU WIN!
|
||||
X:81/156 Y:35/41 S:997/997 B:2
|
||||
```
|
||||
@@ -228,7 +228,7 @@ the game is 10 x 10. This includes the walls and score line.
|
||||
Now the default max snake size is 997 but when the terminal is too small it
|
||||
adjusts the max snake size. For 10 lines and 10 columns you would see:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ make test
|
||||
terminal supports cursor movement
|
||||
terminal supports making cursor invisible
|
||||
|
||||
@@ -184,7 +184,7 @@ most of them.
|
||||
Another example invocation where the snake head is in the snake and where the snake
|
||||
hadn't yet moved (that is it was still growing):
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
CANNIBAL=1 SIZE=1500 GROW=2 MAXSIZE=1600 ./prog
|
||||
```
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
The following are a few screen dumps of:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SIZE=100 SHEDS=5 GROW=-10 SHED=50 MAXSIZE=250 ./prog
|
||||
```
|
||||
|
||||
|
||||
+20
-20
@@ -415,7 +415,7 @@ default) or setting the size to higher than the default (or < 0 which will end
|
||||
up being > the max size though I suppose there might be some value that makes it
|
||||
less than again - I'm not going to try and figure that out however). Anyway:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SIZE=-1 ./prog
|
||||
YOU WIN!
|
||||
X:24/49 Y:8/16 S:658/658 B:0
|
||||
@@ -487,7 +487,7 @@ If you want to draw the snake wherever you like on the screen you can do this by
|
||||
modifying the wait time (for input) to -1 (or any value < 0): then the snake
|
||||
does not move until you press a movement key. For example:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WAIT=-1 ./prog
|
||||
```
|
||||
|
||||
@@ -495,7 +495,7 @@ does not move until you press a movement key. For example:
|
||||
When you eat a bug the snake will grow and you can draw more. If you want to
|
||||
make it so you can go through yourself:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WAIT=-1 CANNIBAL=1 ./prog
|
||||
```
|
||||
|
||||
@@ -503,7 +503,7 @@ If you don't want to start out so small (i.e. you want to be able to draw more
|
||||
quickly) you can just set the size to a bigger number (and you could do the same
|
||||
with growth and moult/shed):
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SIZE=50 CANNIBAL=1 WAIT=-1 ./prog
|
||||
```
|
||||
|
||||
@@ -513,14 +513,14 @@ time.
|
||||
Okay but then if you get too many bugs the drawing will be over. If this proves
|
||||
to be a problem simply do:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SIZE=100 CANNIBAL=1 WAIT=-1 GROW=0 ./prog
|
||||
```
|
||||
|
||||
Or something like that (maybe make the size bigger but that's up to you). You
|
||||
could also set the max size to be the highest possible by saying
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
MAXSIZE=-1
|
||||
```
|
||||
|
||||
@@ -556,7 +556,7 @@ too.
|
||||
|
||||
If you're still here you can create this effect like:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WAIT=0 WALLS=1 CANNIBAL=1 ./prog
|
||||
```
|
||||
|
||||
@@ -582,7 +582,7 @@ so with fewer available it has a harder time finding a place in that one line.
|
||||
|
||||
Here's how to make the bug move every time the snake moves:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
CANNIBAL=1 WALLS=1 WAIT=0 EVADE=1 ./prog
|
||||
```
|
||||
|
||||
@@ -591,7 +591,7 @@ Here's how to make the bug move every time the snake moves:
|
||||
|
||||
If you want to see the game 'win' try something like:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
CANNIBAL=1 WALLS=1 WAIT=0 EVADE=1 MAXSIZE=10 ./prog
|
||||
```
|
||||
|
||||
@@ -601,7 +601,7 @@ If you want to see the game 'win' try something like:
|
||||
Here's a fun one I just thought of (a long time after these other modes were
|
||||
thought of):
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WAIT=0 EVADE=1 GROW=-1 SIZE=9 MAXSIZE=10 CANNIBAL=1 ./prog
|
||||
```
|
||||
|
||||
@@ -616,7 +616,7 @@ then the head again (i.e. 1 then 0 in size) and then win! This is also in the
|
||||
|
||||
Of course you can also do something like:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WAIT=5 WALLS=1 CANNIBAL=1 ./prog
|
||||
```
|
||||
|
||||
@@ -635,7 +635,7 @@ of success in catching bugs? Obviously the dimensions will affect this value.
|
||||
|
||||
How long will it take for the snake to run into itself? For instance by doing:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WAIT=0 ./prog
|
||||
```
|
||||
|
||||
@@ -660,7 +660,7 @@ You have a negative shedding growth and a positive growth size: negative and
|
||||
positive winning. Depending on the parameters specified it might go one way over
|
||||
the other. Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SIZE=150 SHEDS=-5 GROW=10 SHED=50 MAXSIZE=250 ./prog
|
||||
```
|
||||
|
||||
@@ -683,7 +683,7 @@ You could also have it so that eating a bug makes you shrink and moving so many
|
||||
moves you grow. I tried this and for me it was far more fun. The [play.sh][]
|
||||
also has this mode:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SIZE=100 SHEDS=5 GROW=-10 SHED=50 MAXSIZE=250 ./prog
|
||||
```
|
||||
|
||||
@@ -705,7 +705,7 @@ snake moving too.
|
||||
|
||||
Anyway this might sound absurd but it can be somewhat hypnotic by doing:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
EVADE=1 CANNIBAL=1 ./prog
|
||||
```
|
||||
|
||||
@@ -721,7 +721,7 @@ the growth size to 0 and then just move the snake round and round eating bugs
|
||||
until you want to quit. You can enable cannibalism so that you don't have to
|
||||
worry about even running into yourself and losing:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
GROW=0 CANNIBAL=1 ./prog
|
||||
```
|
||||
|
||||
@@ -752,13 +752,13 @@ this file discusses as well as allowing to easily change the colours.
|
||||
|
||||
To do this use the [snake-colours][] script like so:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./snake-colours
|
||||
```
|
||||
|
||||
If you want to pass in specific variables you can do that too e.g.:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
CANNIBAL=1 ./snake-colours
|
||||
```
|
||||
|
||||
@@ -777,13 +777,13 @@ you choose uses then the script will override what you pass in.
|
||||
|
||||
To use you can do something like:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./play.sh
|
||||
```
|
||||
|
||||
Or to make it so walls are an obstacle:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WALLS=0 ./play.sh
|
||||
```
|
||||
|
||||
|
||||
+10
-10
@@ -818,13 +818,13 @@ returned. In either case curses is ended.
|
||||
One of these optimisations saved four bytes simply by taking advantage of the
|
||||
value of a loop iterator after the loop. The loop is:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
for (I = 0; A && I < A - 1; ++I)
|
||||
```
|
||||
|
||||
However after the loop I had this:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
A > 1 && q(n[A - 1],e[A - 1], 'o');
|
||||
```
|
||||
|
||||
@@ -847,7 +847,7 @@ the problem.
|
||||
|
||||
First, the function that turns on colours looked like:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
if (h) attron(m(PAIR(L)));
|
||||
else attroff(m(PAIR(L)));
|
||||
```
|
||||
@@ -857,14 +857,14 @@ that the `attroff()` is called first then I could just do an `if (h)` -
|
||||
therefore getting rid of the `else`! But then I thought why not do what I've
|
||||
done elsewhere? I had:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
attroff(m(PAIR(L)));
|
||||
if (h) attron(m(PAIR(L)));
|
||||
```
|
||||
|
||||
But I then saved an extra byte by making it:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
attroff(m(PAIR(L)));
|
||||
h && attron(m(PAIR(L)));
|
||||
```
|
||||
@@ -875,7 +875,7 @@ Second let's look at the `B()` function: there were two things I thought of that
|
||||
would save some bytes (I no longer know how many but a few at least possibly six
|
||||
or even more). I had the following code:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
if (V && U && o) { S(N); b(1); }
|
||||
```
|
||||
|
||||
@@ -886,13 +886,13 @@ called with `1` (thus `o` is 1 so the if is true) was if the bug actually is
|
||||
caught. That means I could remove the `V && U &&` part of the if! Thus it became
|
||||
instead:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
if (o) { S(N); b(1); }
|
||||
```
|
||||
|
||||
Then this
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
!o && V && U && q U,V,' ');
|
||||
```
|
||||
|
||||
@@ -913,7 +913,7 @@ where the snake already is. So if I had to make sure the game had started (the
|
||||
snake has moved at least once) what could I check? In fact that means the
|
||||
direction is not 0! So I could just replace it with:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
!o && D && q *U,*V,' ');
|
||||
```
|
||||
|
||||
@@ -930,7 +930,7 @@ the score line is updated: so the empty space will be overwritten anyway. And if
|
||||
the score line is made an empty string it doesn't matter because it'll appear as
|
||||
all spaces anyway. Thus I could save another three bytes by changing it to:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
!o && q *U,*V,' ');
|
||||
```
|
||||
|
||||
|
||||
+13
-13
@@ -30,7 +30,7 @@ for the capabilities I use in the entry.
|
||||
It also tries to determine the minimum number of columns to play without the
|
||||
status line overflowing - even with the dynamic length. Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ make test
|
||||
```
|
||||
|
||||
@@ -67,7 +67,7 @@ If I pass in any of the variables **GROW**, **MAXSIZE**, **SIZE** and/or
|
||||
**LINES** or **COLUMNS** it bases its calculations on those variables. For
|
||||
example:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
terminal supports cursor movement
|
||||
terminal supports making cursor invisible
|
||||
terminal supports bold
|
||||
@@ -129,7 +129,7 @@ To specify the lines/columns of curses program per instance use the `LINES` and
|
||||
|
||||
For demonstration consider the following:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo $LINES $COLUMNS
|
||||
42 157
|
||||
```
|
||||
@@ -139,7 +139,7 @@ include the walls and score line but these values are for the terminal itself.
|
||||
|
||||
Say you want 55 columns:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ COLUMNS=55 ./prog
|
||||
```
|
||||
|
||||
@@ -166,7 +166,7 @@ In my tests there is one thing that at least allows you to see the final score
|
||||
and that is by running `clear` before running the program. That's what the
|
||||
prog.alt version does. You might run it as one of:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
LINES=20 ./prog.alt
|
||||
LINES=20 ./snake.alt
|
||||
```
|
||||
@@ -190,7 +190,7 @@ The Linux man page says:
|
||||
|
||||
If you don't have the reset utility you can try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
echo -e \\033c
|
||||
```
|
||||
|
||||
@@ -209,14 +209,14 @@ along and thinks he/she will be clever and mess with the dimensions a bit. Let's
|
||||
say they have a 13" monitor and they think it'd be funny to see how 997 lines
|
||||
would work; they might try something like:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
LINES=997 ./prog
|
||||
```
|
||||
|
||||
What then? Well expect trouble; curses will not know any better and the max
|
||||
number of lines will be 997. If they were to do:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
COLUMNS=997 ./prog
|
||||
```
|
||||
|
||||
@@ -265,7 +265,7 @@ According to my tests for monochrome terminals the screen has the white and
|
||||
black background; if terminal is configured to be black background white
|
||||
foreground that is the order it is too. You can try that like:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
TERM=linux-m ./prog
|
||||
```
|
||||
|
||||
@@ -301,7 +301,7 @@ Based on the two as well as the fact that monochrome terminals (I've tried under
|
||||
both Linux and macOS) seem to work fine I believe I am fine here too. And to
|
||||
confirm this I wrote the following code with the output below:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
#include <curses.h>
|
||||
|
||||
int main()
|
||||
@@ -314,7 +314,7 @@ confirm this I wrote the following code with the output below:
|
||||
}
|
||||
```
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
TERM=linux-m ./colour_pairs
|
||||
COLORS: 0
|
||||
COLOR_PAIRS: 0
|
||||
@@ -332,7 +332,7 @@ possible colour pairs than I have used so that's not a problem either. Perhaps
|
||||
even it would only be a runtime error if the colours are supported and the
|
||||
number is out of the range? To try and figure this out I did another test:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
int main()
|
||||
{
|
||||
initscr();
|
||||
@@ -351,7 +351,7 @@ number is out of the range? To try and figure this out I did another test:
|
||||
|
||||
Running it like
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
TERM=linux-m ./colour_pairs
|
||||
```
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ hit a key every time to move because it is blocking.
|
||||
|
||||
What happens if you do:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WALLS= ./prog
|
||||
```
|
||||
|
||||
@@ -342,20 +342,20 @@ for a number could have a better value than 0.
|
||||
If however you were to give valid input followed by invalid input the valid
|
||||
input would be parsed. For example:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WALLS=1test ./prog
|
||||
```
|
||||
|
||||
would let you go through the walls. On the other hand
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WALLS=test1 ./prog
|
||||
```
|
||||
|
||||
would not. Furthermore if you specify the same variable more than once it's the
|
||||
last one that counts. For example:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
WALLS=0 WALLS=1 CANNIBAL=1 CANNIBAL=0 ./prog
|
||||
```
|
||||
|
||||
@@ -414,7 +414,7 @@ If `calloc()` fails to obtain the needed memory you'll see something like (here
|
||||
was before I added proper - to make the perfect and obvious pun - capsizing
|
||||
so that by setting the size to -1 it went to the max unsigned value):
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ MAXSIZE=-1 ./prog
|
||||
memory error
|
||||
X:0/157 Y:0/42 S:3/18446744073709551614 B:0
|
||||
@@ -428,7 +428,7 @@ not know but what I do know is that because it's unsigned it can't be negative;
|
||||
if the max size is 0 then the array size will be 1 but it won't matter because
|
||||
the snake size will be >= that max anyway. But here's a curious output:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
SIZE=1 MAXSIZE=0 ./prog
|
||||
YOU WIN!
|
||||
X:78/156 Y:20/41 S:0/0 B:0
|
||||
|
||||
+24
-24
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
@@ -11,7 +11,7 @@ at once. See [Alternate code](#alternate-code) below.
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog
|
||||
|
||||
# get recode help:
|
||||
@@ -49,13 +49,13 @@ are allowed.
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
What does:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
echo | ./recode
|
||||
echo | ./recode -v
|
||||
```
|
||||
@@ -72,14 +72,14 @@ and to make it a bit more like the real thing.
|
||||
|
||||
### Alternate build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make alt
|
||||
```
|
||||
|
||||
The default time to sleep is 400000 microseconds but you can change this by
|
||||
doing:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make clobber SLEEP=600000 alt
|
||||
```
|
||||
|
||||
@@ -93,7 +93,7 @@ Use `prog.alt` as you would `prog` above.
|
||||
|
||||
### Alternate try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.alt.sh
|
||||
```
|
||||
|
||||
@@ -110,7 +110,7 @@ There is a good deal of useful documentation that is provided with this entry:
|
||||
* [enigma.1](enigma.1) - A useful man page for this entry. To render, try:
|
||||
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
man ./enigma.1
|
||||
```
|
||||
|
||||
@@ -251,7 +251,7 @@ the result (after finishing the enciphering).
|
||||
|
||||
If you run it like:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog -
|
||||
```
|
||||
|
||||
@@ -283,7 +283,7 @@ program as well as how to use the two winning entries of the [Morse
|
||||
code](https://en.wikipedia.org/wiki/Morse_code) that I referred to earlier:
|
||||
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ ./prog -
|
||||
Ring 1: 3
|
||||
Setting 1: I
|
||||
@@ -317,7 +317,7 @@ default settings; as the judges suggest this invocation I will not show it here.
|
||||
|
||||
But you can also type it out like this:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ ./prog
|
||||
IOCCC
|
||||
UUMMX
|
||||
@@ -328,7 +328,7 @@ The IOCCC comes from stdin; the `UUMMX` is written to stdout.
|
||||
If I compile the 2014 entry and copy it to my local directory as
|
||||
`vik` I might do:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo TEST|./prog |./vik | mplayer -demuxer rawaudio -
|
||||
```
|
||||
|
||||
@@ -340,7 +340,7 @@ a bug in that entry (Fedora, CentOS and macOS all affected).
|
||||
For example I can use the syntax provided in the winning remarks along with my
|
||||
entry to write it to a file. Say:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo TEST|./prog |./vik > test.raw
|
||||
$ ./vik e < test.raw | ./prog
|
||||
LEST
|
||||
@@ -348,21 +348,21 @@ entry to write it to a file. Say:
|
||||
|
||||
Why did that happen? This shows more details:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ ./vik e < test.raw
|
||||
SCWV
|
||||
```
|
||||
|
||||
However as can be seen the first char is wrong:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo TEST|./prog
|
||||
KCWV
|
||||
```
|
||||
|
||||
And piping the original output to my entry itself you get the original input:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo TEST | ./prog | ./prog
|
||||
TEST
|
||||
```
|
||||
@@ -372,7 +372,7 @@ idea anyway. Neither do I know if the original transcoding is correct.
|
||||
|
||||
What if I use the input string `LEST` instead? In that case it worked fine:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo LEST | ./prog | ./vik > lest.raw
|
||||
$ ./vik e < lest.raw | ./prog
|
||||
LEST
|
||||
@@ -380,7 +380,7 @@ What if I use the input string `LEST` instead? In that case it worked fine:
|
||||
|
||||
But there's one obvious question, right? Let's try the most important one:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo IOCCC | ./prog | ./vik > ioccc.raw
|
||||
$ ./vik e < ioccc.raw
|
||||
UUMMX
|
||||
@@ -396,7 +396,7 @@ too. Notice also how it showed the same output that my program gave it - `UUMMX`
|
||||
|
||||
What about the other [Morse code entry](../../1998/dorssel/dorssel.c)?
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo IOCCC | ./prog | ./dorssel
|
||||
..- ..- -- -- -..-
|
||||
```
|
||||
@@ -441,7 +441,7 @@ The parser is in a sense rather rudimentary but allows for both interactive and
|
||||
automatic (e.g. via the [recode](recode.c) program) input. This does mean that
|
||||
something like the following can happen:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ ./prog -
|
||||
Ring 1: 1AB
|
||||
Setting 1: Position 1: Ring 2: 2CD
|
||||
@@ -504,7 +504,7 @@ should help you remember (though not at this time in our world it might help you
|
||||
later on?). This might become even more useful after the challenge is accepted,
|
||||
accomplished and made use of! :)
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo ABC | ./prog
|
||||
GYM
|
||||
$ echo ABC | ./prog | ./prog
|
||||
@@ -536,7 +536,7 @@ ended his life. (I later made a bug fix but I consider this inconsequential).
|
||||
|
||||
As for [recode.c][] though I really love this:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
/\
|
||||
/ This is *not* what you think:
|
||||
```
|
||||
@@ -552,13 +552,13 @@ It's an [Enigma machine](https://en.wikipedia.org/wiki/Enigma_machine) simulator
|
||||
that proof that it's obfuscated itself?! :) Silliness aside [obfuscation.txt][]
|
||||
has some of the ways I think this entry is obfuscated. To decipher try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./recode -Robfuscation.key -fobfuscation.txt | ./prog - 2>/dev/null > obfuscation.md
|
||||
```
|
||||
|
||||
To encipher:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./recode -Robfuscation.key -fobfuscation.md | ./prog - 2>/dev/null > obfuscation.txt
|
||||
```
|
||||
|
||||
|
||||
@@ -19,13 +19,13 @@ there is an aesthetic appeal to my eyes too).
|
||||
Y<:19:><:27:> but it's not the only example. Here the compound literal of 13
|
||||
ints:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
int *z=(int[13]) { 0 } , *e, *g;
|
||||
```
|
||||
|
||||
Then in main:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
e = z + 10;
|
||||
g = e + 1;
|
||||
|
||||
@@ -39,14 +39,14 @@ ints:
|
||||
more confusing still. There are at least two other ways that are much easier
|
||||
to read that could accomplish the same thing. It continues on:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
/* ... */
|
||||
e<:i-3:> = (j < 1 ? 1 : (j > 5 ? 5 : j))-1;
|
||||
```
|
||||
|
||||
* Observe these two functions:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
void w(char *s, int k, int v)
|
||||
{
|
||||
for(e<:2:> = 0; s<:*P:>; ++e<:2:>)
|
||||
@@ -96,7 +96,7 @@ temporary variable instead of a regular int in the function (so make it global);
|
||||
and (2) I didn't want to risk changing all the offsets: thus I just made that
|
||||
address `e[1]`. Thus I also have:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
for (*g = 0 ; *g < 10; ++*g)
|
||||
{
|
||||
r<:-2:> = Y<:14:><:*(e+1):>; r<:-3:> = Y<:15:><:1<:e:>:>;
|
||||
@@ -117,7 +117,7 @@ address `e[1]`. Thus I also have:
|
||||
* The above function Z() takes a `char x` but you won't notice it being used
|
||||
at all. Why? In fact I call it like so:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
k = Z(r<:-1:>=k);
|
||||
```
|
||||
|
||||
@@ -132,7 +132,7 @@ at all. Why? In fact I call it like so:
|
||||
refer to the same variable in more than one way (or in some cases maybe more
|
||||
correct to say 'same location'). In the Z() function for example:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
r<:-2:> = Y<:14:><:*(e+1):>; r<:-3:> = Y<:15:><:1<:e:>:>;
|
||||
```
|
||||
|
||||
@@ -153,7 +153,7 @@ index (sort of).
|
||||
* Another set of char arrays in one: the five rotors as well as the two
|
||||
reflectors in one `char [][27]`. This makes for some fun code like:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
(Y<:e<:-10:>+5:><:k-'A':>) && (k = Y<:e<:-10:>+5:><:k-'A':>);
|
||||
```
|
||||
|
||||
@@ -194,7 +194,7 @@ enough because as they rightly point out they can just use the C preprocessor
|
||||
itself. But although I have quite a few cpp directives I am not using them for
|
||||
obfuscation but rather to save bytes. For examples:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
%:define J(x) do(*x)=getchar(); while((*x)=='\n')
|
||||
```
|
||||
|
||||
@@ -205,7 +205,7 @@ obfuscation but rather to save bytes. For examples:
|
||||
particular I want to bring up though because I think it's a curious one and
|
||||
it ties in to another point above:
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
%:define A(y) *(&Y<:7:><:1:>+(y))
|
||||
```
|
||||
|
||||
@@ -213,7 +213,7 @@ obfuscation but rather to save bytes. For examples:
|
||||
to the notch settings (I think it was the notch settings anyway). Now I
|
||||
could have done say
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
char a = Y[7][1], b = Y[7][3], c = Y[7][5];
|
||||
```
|
||||
|
||||
@@ -248,7 +248,7 @@ variables in recode.c, move them to prog.c, compile and expect it to work right.
|
||||
|
||||
* Also what is this about ?
|
||||
|
||||
```<!---c-->
|
||||
``` <!---c-->
|
||||
/\
|
||||
/ This is *not* what you think:
|
||||
void D(char*x){ /* ... */ }
|
||||
|
||||
+21
-21
@@ -55,7 +55,7 @@ wonderful 'challenge' for everyone.
|
||||
|
||||
# <a name="options" href="#toc">Options</a>
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./recode -h
|
||||
usage: ./recode [options]
|
||||
-v display selected settings
|
||||
@@ -71,7 +71,7 @@ if you don't give the option to read in a file for input.
|
||||
|
||||
`-v` shows selected settings. For example combining `-r` and `-v`:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo IOCCC | ./recode -r -v
|
||||
Ring 1: ( I) EKMFLGDQVZNTOWYHXUSPAIBRCJ
|
||||
Ring 2: ( V) VZBRGITYUPSDNHLXAWMJQOFECK
|
||||
@@ -104,7 +104,7 @@ encipherment/decipherment). If the file cannot be opened it sets back to stdin.
|
||||
or is the same file name (see below) then only stdout will be used. Example of
|
||||
randomised output going to a file:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ ./recode -r -oconfig
|
||||
IOCCC
|
||||
3PP4UB5GG1ELGTKFCOPVBNUYXJAWSDIOCCC
|
||||
@@ -143,7 +143,7 @@ what about if one exists but the other does not?
|
||||
Due to the way the parsing of options is done (no spaces between option char and
|
||||
argument) shell expansion will not work right so for example doing:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ ./recode -R~/config
|
||||
```
|
||||
|
||||
@@ -163,7 +163,7 @@ the program interactively.
|
||||
If stdin is not a tty (`!isatty(0)`) and neither randomised mode nor reading in
|
||||
from a file is specified then you might just see something like:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo testing test tests | ./recode
|
||||
1AB2BB3CC1testing test tests
|
||||
|
||||
@@ -189,7 +189,7 @@ input manually (if you randomise or read in from previously saved file no input
|
||||
need be done at all) then make sure to redirect stderr to /dev/null. If you
|
||||
don't you might see something like:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ ./recode -r | ./prog -
|
||||
Ring 1: IOCCC
|
||||
Setting 1: Position 1: Ring 2: Setting 2: Position 2: Ring 3: Setting 3: Position 3: Reflector: Plugboard pair 1: Plugboard pair 2: Plugboard pair 3: Plugboard pair 4: Plugboard pair 5: Plugboard pair 6: Plugboard pair 7: Plugboard pair 8: Plugboard pair 9: Plugboard pair 10: DEVIY
|
||||
@@ -205,7 +205,7 @@ That's why after I sent EOF it printed out the remaining strings to stderr.
|
||||
|
||||
# <a name="manuallytest" href="#toc">Manually test the recode program with the Enigma program</a>
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ cat input
|
||||
IOCCC
|
||||
|
||||
@@ -249,7 +249,7 @@ than the simulator: because with the size restrictions on my entry I saved bytes
|
||||
by using the same loop where I could. It just felt more natural to have them
|
||||
grouped together in a configurator for the [simulator](prog.c).
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC | ./prog - 2>/dev/null
|
||||
HQNVO
|
||||
$ echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC | ./prog - 2>/dev/null | echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRHQNVO | ./prog - 2>/dev/null
|
||||
@@ -273,21 +273,21 @@ What happens if the plugboard pairs are the same but in a different order? It's
|
||||
the same output:
|
||||
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo 1AA2AA3AA2AB..CDEFGHIJKLMNOPQRIOCCC|./prog - 2>/dev/null
|
||||
HQNVO
|
||||
```
|
||||
|
||||
Also if you flip the order of the letters in the pair e.g. the AB as BA instead:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo 1AA2AA3AA2BA..CDEFGHIJKLMNOPQRIOCCC|./prog - 2>/dev/null
|
||||
HQNVO
|
||||
```
|
||||
|
||||
# <a name="onlyconfig" href="#toc">Only write config file</a>
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ ./recode -v -oconfig -finput >/dev/null
|
||||
Rotors:
|
||||
(1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ
|
||||
@@ -345,7 +345,7 @@ pair. This is because it consumes input overflow.
|
||||
It shouldn't be this way for the simulator though because that could cause
|
||||
inconsistent number of characters expected before the text to encipher.
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ cat config
|
||||
1AB2CD3EF2ABCDEFGHIJKLMNOPQRST
|
||||
|
||||
@@ -363,7 +363,7 @@ directly type ctrl-d (or whatever you have EOF set to) or give it an empty file.
|
||||
The following are all equivalent in that they will write to a settings file (the
|
||||
first one will print a newline with the echo but that won't matter):
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo | ./recode -r -osettings
|
||||
$ echo -n | ./recode -r -osettings
|
||||
$ > empty
|
||||
@@ -380,7 +380,7 @@ set another variable to indicate if it should be printed.)
|
||||
|
||||
# <a name="reuseconfig" href="#toc">Reusing a configuration</a>
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo -n|./recode -r -oconfig
|
||||
4UH5II1RJ1SPIFEJLYGZWRTBHVCAMN$
|
||||
|
||||
@@ -405,7 +405,7 @@ set another variable to indicate if it should be printed.)
|
||||
|
||||
Alternatively you can just use the `-R` and `-f` options:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ ./recode -finput.txt -Rconfig | ./prog - 2>/dev/null > output2
|
||||
$ diff output output2
|
||||
$
|
||||
@@ -456,7 +456,7 @@ participants of the IOCCC do). Other things there don't mean anything but what
|
||||
does is the output:
|
||||
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ cat output
|
||||
DBFAF 2020 Ittejg ltblwriac uqdfqvr dhqh ghhf
|
||||
|
||||
@@ -477,7 +477,7 @@ does is the output:
|
||||
|
||||
This is like the above only randomised:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ ./recode -r -oconfig|./prog - 2>/dev/null
|
||||
IOCCC
|
||||
UGEVP
|
||||
@@ -489,14 +489,14 @@ the config file (for deciphering later) and then all of it was piped to the
|
||||
Enigma entry resulting in the line below IOCCC. But let's verify it worked out
|
||||
okay:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ cat config
|
||||
2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ
|
||||
```
|
||||
|
||||
Without having to copy/paste intermediate results:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo IOCCC | ./recode -Rconfig | ./prog - 2>/dev/null | ./recode -Rconfig | ./prog - 2>/dev/null
|
||||
IOCCC
|
||||
```
|
||||
@@ -504,7 +504,7 @@ Without having to copy/paste intermediate results:
|
||||
You can also use a string for the `-R` option. I'll use command substitution and
|
||||
actual pasting to demonstrate:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ echo IOCCC | ./recode -R$(cat config) | ./prog - 2>/dev/null | ./recode -R2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ | ./prog - 2>/dev/null
|
||||
IOCCC
|
||||
```
|
||||
@@ -612,7 +612,7 @@ the key you wish to select is
|
||||
|
||||
you can do:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./recode -R0EZ4PC1CC0PGTAQSOXWNMDRYKFUZEI -fencrypted.html | ./prog - 2>/dev/null > decrypted.html
|
||||
```
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
@@ -18,7 +18,7 @@ For more detailed information see [2020 giles bugs](../../bugs.html#2020_giles).
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog < dtmf.wav
|
||||
|
||||
./prog [digits] > digits.wav
|
||||
@@ -33,7 +33,7 @@ will be converted to the DTMF sound!
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
./prog < pi.wav
|
||||
|
||||
@@ -71,7 +71,7 @@ exactly 16 bits per sample, but it allows any sample rate and any number of
|
||||
audio channels.
|
||||
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ ./prog < pi.wav
|
||||
31415926
|
||||
```
|
||||
@@ -80,7 +80,7 @@ If the program is executed with a command-line argument, it will generate the
|
||||
tones corresponding to the specified characters, writing them to standard output
|
||||
as a WAV file.
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ ./prog 867-5309 | aplay
|
||||
```
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
@@ -10,7 +10,7 @@ code](#alternate-code) below for more details.
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog
|
||||
# input some text
|
||||
|
||||
@@ -22,7 +22,7 @@ code](#alternate-code) below for more details.
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -46,7 +46,7 @@ are the program in assembly for x86_64 linux and x86 linux respectively.
|
||||
|
||||
To build [prog.alt.c](prog.alt.c):
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make alt
|
||||
```
|
||||
|
||||
|
||||
+13
-13
@@ -1,20 +1,20 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
# Take a selfie
|
||||
./prog 1000 selfie.jpg output.jpg
|
||||
# Admire your portrait in cubist style
|
||||
@@ -41,7 +41,7 @@ This program divides the image into a specified number of rectangles. This
|
||||
process is content aware, so the algorithm tries to match most of the information.
|
||||
However, it doesn't find the best theoretically possible layout.
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog 1000 input.jpg output.jpg
|
||||
```
|
||||
|
||||
@@ -56,13 +56,13 @@ If you want to use `libjpeg` compiled from sources, then use the `LIBJPEG` defin
|
||||
specify the path to includes and the library. For example using
|
||||
[libjpeg source](https://mac-dev-env.patrickbougie.com/libjpeg/) version 9c:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make prog LIBJPEG="-Ijpeg-9c jpeg-9c/libjpeg.a"
|
||||
```
|
||||
|
||||
Use this command to build a PNG version (you need `libpng`):
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make prog_png LIBPNG="-lpng"
|
||||
```
|
||||
|
||||
@@ -80,13 +80,13 @@ information!
|
||||
|
||||
First, make sure you have the compiler tools installed e.g. by:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
sudo xcode-select --install
|
||||
```
|
||||
|
||||
Make sure you install [MacPorts](https://www.macports.org/install.php). Then do:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
sudo port install jpeg libpng ImageMagick
|
||||
```
|
||||
|
||||
@@ -95,7 +95,7 @@ GIFs from the results using `makegif.sh`.
|
||||
|
||||
After that’s installed you need to run make with these options:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make LDFLAGS="-I/opt/local/include -L/opt/local/lib"
|
||||
```
|
||||
|
||||
@@ -103,7 +103,7 @@ After that’s installed you need to run make with these options:
|
||||
|
||||
First, make sure you have the compiler tools installed e.g. by:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
sudo xcode-select --install
|
||||
```
|
||||
|
||||
@@ -111,14 +111,14 @@ Make sure you install [Homebrew](https://brew.sh).
|
||||
|
||||
Then:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
brew install libjpeg libpng
|
||||
eval "$(brew shellenv)"
|
||||
```
|
||||
|
||||
You are now ready to compile this entry:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make clobber all
|
||||
```
|
||||
|
||||
@@ -139,7 +139,7 @@ vertically to get the minimum difference.
|
||||
You can use this command to make a GIF from output images (uses ImageMagick).
|
||||
For instance after running the command suggested by the judges:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
convert -delay 10 -dither none -loop 0 $(find . -maxdepth 1 -type f -name '*jpg' | sort -V) $(find . -maxdepth 1 -type f -name '*jpg' | sort -rV) +map out.gif
|
||||
```
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
@@ -10,14 +10,14 @@ code](#alternate-code) below.
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -29,7 +29,7 @@ The alternate version, [prog.alt.c](prog.alt.c), has the main code as a macro.
|
||||
|
||||
### Alternate build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make alt
|
||||
```
|
||||
|
||||
@@ -61,7 +61,7 @@ exactly what it says nonetheless.
|
||||
|
||||
Compile and try this:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
cat input.txt | ./prog
|
||||
```
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog text_file output_length context_length random_seed
|
||||
```
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
When running this, ask yourself why it gets progressively slower when the
|
||||
context length decreases:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -70,7 +70,7 @@ Now can you appreciate the award title a bit better?
|
||||
|
||||
### Building:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
cc prog.c -o prog
|
||||
```
|
||||
|
||||
@@ -79,7 +79,7 @@ Now can you appreciate the award title a bit better?
|
||||
This program generates random text from the provided dictionary using a Markov
|
||||
chain, outputting to `stdout`.
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog input.txt 2000 10 12345
|
||||
```
|
||||
|
||||
@@ -110,7 +110,7 @@ You can try this with the inputs provided with
|
||||
[2019/mills](../../2019/mills/index.html) from the IOCCC entries.
|
||||
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
$ ./prog Shakespeare.txt 2001 10 12345
|
||||
```
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
@@ -18,14 +18,14 @@ For more detailed information see [2020 otterness bugs](../../bugs.html#2020_ott
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -74,7 +74,7 @@ for most of my testing (see [cvikl.mid](cvikl.mid)).
|
||||
Compile the program using the following command (I tested this using both
|
||||
`clang` and `gcc`):
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
cc -pedantic -Wall -Werror -Wextra -O3 -o prog prog.c
|
||||
```
|
||||
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
## To build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
@@ -11,14 +11,14 @@ to those familiar with vi. See [Alternate code](#alternate-code) below.
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
./prog
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
# Make your terminal as large as possible, possibly reduce your font size
|
||||
# then...
|
||||
./prog
|
||||
@@ -33,14 +33,14 @@ where instead of `w`, `a`, `s` and `d`, you can use `k`, `h`, `j` and `l`.
|
||||
|
||||
### Alternate build:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
make alt
|
||||
```
|
||||
|
||||
|
||||
### Alternate use:
|
||||
|
||||
```<!---sh-->
|
||||
``` <!---sh-->
|
||||
# Make your terminal as large as possible, possibly reduce your font size
|
||||
# then...
|
||||
./prog.alt
|
||||
|
||||
+7
-7
@@ -1,20 +1,20 @@
|
||||
## To build:
|
||||
|
||||
```<!---<!---sh-->-->
|
||||
``` <!---sh-->
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```<!---<!---sh-->-->
|
||||
``` <!---sh-->
|
||||
./prog [PIN] < input.txt > output.c
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```<!---<!---sh-->-->
|
||||
``` <!---sh-->
|
||||
./try.sh
|
||||
```
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
The author provided the file [cppp.cc](cppp.cc) which can preprocess the
|
||||
generated output to make them more acceptable to typical compilers. To build:
|
||||
|
||||
```<!---<!---sh-->-->
|
||||
``` <!---sh-->
|
||||
make cppp
|
||||
```
|
||||
|
||||
@@ -44,7 +44,7 @@ spoiler](spoiler.html) that shows how this entry was written.
|
||||
|
||||
### Synopsis
|
||||
|
||||
```<!---<!---sh-->-->
|
||||
``` <!---sh-->
|
||||
echo "Hello world" | ./prog 12345 > encoded.c
|
||||
|
||||
gcc -DPIN=12345 encoded.c -o ./decoded && ./decoded
|
||||
@@ -63,14 +63,14 @@ Mile is a C code generator. Run without arguments for the help message below:
|
||||
When run with an encoding PIN (first command line argument), Mile will
|
||||
read bytes from `stdin` and generate C code on `stdout`. Example:
|
||||
|
||||
```<!---<!---sh-->-->
|
||||
``` <!---sh-->
|
||||
echo "Hello, world!" | ./prog 56789 > encoded.c
|
||||
```
|
||||
|
||||
This generated code will reproduce the same input bytes on `stdout` when
|
||||
executed, if it was compiled with the same encoding PIN.
|
||||
|
||||
```<!---<!---sh-->-->
|
||||
``` <!---sh-->
|
||||
gcc -DPIN=56789 encoded.c -o decoded
|
||||
```
|
||||
|
||||
|
||||
@@ -141,14 +141,14 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<pre class="<!---<!---sh-->-->"><code> make</code></pre>
|
||||
<pre class="<!---sh-->"><code> make</code></pre>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<pre class="<!---<!---sh-->-->"><code> ./prog [PIN] < input.txt > output.c</code></pre>
|
||||
<pre class="<!---sh-->"><code> ./prog [PIN] < input.txt > output.c</code></pre>
|
||||
<h2 id="try">Try:</h2>
|
||||
<pre class="<!---<!---sh-->-->"><code> ./try.sh</code></pre>
|
||||
<pre class="<!---sh-->"><code> ./try.sh</code></pre>
|
||||
<p>The author provided the file <a href="cppp.cc">cppp.cc</a> which can preprocess the
|
||||
generated output to make them more acceptable to typical compilers. To build:</p>
|
||||
<pre class="<!---<!---sh-->-->"><code> make cppp</code></pre>
|
||||
<pre class="<!---sh-->"><code> make cppp</code></pre>
|
||||
<p>See the author’s remarks for more details.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>You might think of this entry as code obfuscater with a code.
|
||||
@@ -159,7 +159,7 @@ What is compiling this entry about?
|
||||
spoiler</a> that shows how this entry was written.</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<h3 id="synopsis">Synopsis</h3>
|
||||
<pre class="<!---<!---sh-->-->"><code> echo "Hello world" | ./prog 12345 > encoded.c
|
||||
<pre class="<!---sh-->"><code> echo "Hello world" | ./prog 12345 > encoded.c
|
||||
|
||||
gcc -DPIN=12345 encoded.c -o ./decoded && ./decoded</code></pre>
|
||||
<h3 id="details">Details</h3>
|
||||
@@ -169,10 +169,10 @@ spoiler</a> that shows how this entry was written.</p>
|
||||
where [PIN] is an integer in the range of 1..65535</code></pre>
|
||||
<p>When run with an encoding PIN (first command line argument), Mile will
|
||||
read bytes from <code>stdin</code> and generate C code on <code>stdout</code>. Example:</p>
|
||||
<pre class="<!---<!---sh-->-->"><code> echo "Hello, world!" | ./prog 56789 > encoded.c</code></pre>
|
||||
<pre class="<!---sh-->"><code> echo "Hello, world!" | ./prog 56789 > encoded.c</code></pre>
|
||||
<p>This generated code will reproduce the same input bytes on <code>stdout</code> when
|
||||
executed, if it was compiled with the same encoding PIN.</p>
|
||||
<pre class="<!---<!---sh-->-->"><code> gcc -DPIN=56789 encoded.c -o decoded</code></pre>
|
||||
<pre class="<!---sh-->"><code> gcc -DPIN=56789 encoded.c -o decoded</code></pre>
|
||||
<p>The generated code reconstructs all data at compile time by seeding a
|
||||
random number generator with the given PIN to reproduce the input bytes,
|
||||
and simply does one <code>fwrite(3)</code> call at run time to print those bytes. Not
|
||||
|
||||
Reference in new issue
Block a user