Expand all leading tabs in markdown files
Given how problematic leading tabs in markdown files can be,
we have expanded all leading tabs in markdown files by:
```sh
find * -type f -name '*.md' -print |
while read -r file; do
rm -f "$file.tmp" ;
expand < "$file" > "$file.tmp" ;
mv -f -v "$file.tmp" "$file" ;
done
```
Given the previous changes to `bin/pandoc-wrapper.sh` and other recent
commits and recent pull requests, the were were **NO** changes to
any HTML files. This is a **good thing** as the expression goes.
No there are no leading tabs in any markdown files.
A check to catch any re-introduction of leading tabs
into any markdown file is on the way.
BTW: We do not have anything against leading tabs in files,
even though we have had to deal with their impact on forming
HTML from markdown files (as well as the calc source code).
It is just that this is one of those cases where tabs conflict
(sometimes caused by people wanting to change the classic
8-space tab model) with a desired outcome.
Perform `make www` to perform the above and test under macOS.
This commit is contained in:
1 parent
bf28cac593
commit
7712db4a17
117 files changed
+1758
-1758
No files matched your search
@@ -42,15 +42,15 @@ Some new compilers (in 1984) dislike lines 6 and 10 of the source, so we changed
|
|||||||
them from:
|
them from:
|
||||||
|
|
||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
;++f)a[ b<<5|c] =d++,b+ =e;for( f=0;f<O
|
;++f)a[ b<<5|c] =d++,b+ =e;for( f=0;f<O
|
||||||
<<5|c]^ a[b<<5 |c]^=a[ (k-(b+1 ))<<5|c]
|
<<5|c]^ a[b<<5 |c]^=a[ (k-(b+1 ))<<5|c]
|
||||||
```
|
```
|
||||||
|
|
||||||
to:
|
to:
|
||||||
|
|
||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
;++f)a[ b<<5|c] =d++,b+= e;for( f=0;f<O
|
;++f)a[ b<<5|c] =d++,b+= e;for( f=0;f<O
|
||||||
<<5|c]^= a[b<<5 |c]^=a[ (k-(b+1 ))<<5|c]
|
<<5|c]^= a[b<<5 |c]^=a[ (k-(b+1 ))<<5|c]
|
||||||
```
|
```
|
||||||
|
|
||||||
I hope you have a C beautifier!
|
I hope you have a C beautifier!
|
||||||
|
|||||||
+66
-66
@@ -51,11 +51,11 @@ which is probably not as uncommon as you think :-).
|
|||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
./mullender.alt
|
./mullender.alt
|
||||||
|
|
||||||
./mullender.alt 5000 # wait for 5000 microseconds and see what happens
|
./mullender.alt 5000 # wait for 5000 microseconds and see what happens
|
||||||
|
|
||||||
./mullender.alt 20000 # wait for 20000 microseconds and see what happens
|
./mullender.alt 20000 # wait for 20000 microseconds and see what happens
|
||||||
|
|
||||||
./mullender.alt 100000 # wait for 100000 microseconds and see what happens
|
./mullender.alt 100000 # wait for 100000 microseconds and see what happens
|
||||||
```
|
```
|
||||||
|
|
||||||
What happens if you hit enter after it reaches the end of the line? Why? What
|
What happens if you hit enter after it reaches the end of the line? Why? What
|
||||||
@@ -258,8 +258,8 @@ The [PDP](https://en.wikipedia.org/wiki/Programmed_Data_Processor) and
|
|||||||
|
|
||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
for (;;) {
|
for (;;) {
|
||||||
write(1, " :-)\b\b\b\b", 9);
|
write(1, " :-)\b\b\b\b", 9);
|
||||||
delay();
|
delay();
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -286,17 +286,17 @@ no problem. The assembly code we came up with is as follows:
|
|||||||
|
|
||||||
``` <!---asm-->
|
``` <!---asm-->
|
||||||
pdp:
|
pdp:
|
||||||
mov pc,r4
|
mov pc,r4
|
||||||
tst -(r4)
|
tst -(r4)
|
||||||
sub $9, r4
|
sub $9, r4
|
||||||
mov r4,0f
|
mov r4,0f
|
||||||
mov $1, r0
|
mov $1, r0
|
||||||
sys 4; 0:0; 9
|
sys 4; 0:0; 9
|
||||||
mov $1000, r2
|
mov $1000, r2
|
||||||
1:
|
1:
|
||||||
sys 55
|
sys 55
|
||||||
sob r2,1b
|
sob r2,1b
|
||||||
br pdp
|
br pdp
|
||||||
```
|
```
|
||||||
|
|
||||||
This is not the code we originally wrote, but it is the code that we ultimately
|
This is not the code we originally wrote, but it is the code that we ultimately
|
||||||
@@ -334,20 +334,20 @@ program that we came up with is as follows:
|
|||||||
``` <!---asm-->
|
``` <!---asm-->
|
||||||
vax: .word 0400 + (pdp - vax) / 2 - 1
|
vax: .word 0400 + (pdp - vax) / 2 - 1
|
||||||
1:
|
1:
|
||||||
pushl $9
|
pushl $9
|
||||||
pushal str
|
pushal str
|
||||||
pushl $1
|
pushl $1
|
||||||
calls $3, write
|
calls $3, write
|
||||||
cvtwl $32767, r2
|
cvtwl $32767, r2
|
||||||
|
|
||||||
2:
|
2:
|
||||||
decl r2
|
decl r2
|
||||||
jneq 2b
|
jneq 2b
|
||||||
jbr 1b
|
jbr 1b
|
||||||
|
|
||||||
write: .word 0
|
write: .word 0
|
||||||
chmk $4
|
chmk $4
|
||||||
ret
|
ret
|
||||||
|
|
||||||
str: .ascii " :-)\b\b\b\b"
|
str: .ascii " :-)\b\b\b\b"
|
||||||
|
|
||||||
@@ -395,53 +395,53 @@ compiled in modern systems.
|
|||||||
|
|
||||||
main(argc, argv) char **argv;
|
main(argc, argv) char **argv;
|
||||||
{
|
{
|
||||||
register FILE *fp;
|
register FILE *fp;
|
||||||
register short pos = 0, c, n;
|
register short pos = 0, c, n;
|
||||||
register char *fmt;
|
register char *fmt;
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
fprintf (stderr, "Usage: %s file\n", argv[0]);
|
fprintf (stderr, "Usage: %s file\n", argv[0]);
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fp = fopen(argv[1], "r")) == NULL) {
|
if ((fp = fopen(argv[1], "r")) == NULL) {
|
||||||
fprintf(stderr, "%s: can't open %s\n", argv[0], argv[1]);
|
fprintf(stderr, "%s: can't open %s\n", argv[0], argv[1]);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek (fp, (long) sizeof (struct exec), 0);
|
fseek (fp, (long) sizeof (struct exec), 0);
|
||||||
printf("/* portable between VAX and PDP11 */\n\n");
|
printf("/* portable between VAX and PDP11 */\n\n");
|
||||||
printf ("short main[] = {\n");
|
printf ("short main[] = {\n");
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (pos == 0)
|
if (pos == 0)
|
||||||
printf("\t");
|
printf("\t");
|
||||||
|
|
||||||
c=getc(fp) & 0377;
|
c=getc(fp) & 0377;
|
||||||
if (feof(fp)) break;
|
if (feof(fp)) break;
|
||||||
n = getc(fp) << 8|c;
|
n = getc(fp) << 8|c;
|
||||||
|
|
||||||
switch (rand() % 5) {
|
switch (rand() % 5) {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
fmt = "%d"; break;
|
fmt = "%d"; break;
|
||||||
case 2:
|
case 2:
|
||||||
fmt = "%u"; break;
|
fmt = "%u"; break;
|
||||||
case 3:
|
case 3:
|
||||||
fmt = "0%o"; break;
|
fmt = "0%o"; break;
|
||||||
case 4:
|
case 4:
|
||||||
fmt = "0x%x"; break;
|
fmt = "0x%x"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (32 <= n && n < 127 && (rand() % 4)) fmt = "'%c'";
|
if (32 <= n && n < 127 && (rand() % 4)) fmt = "'%c'";
|
||||||
printf(n < 8 ? "%d" : fmt, n);
|
printf(n < 8 ? "%d" : fmt, n);
|
||||||
printf(",");
|
printf(",");
|
||||||
if (pos++ == 8) {
|
if (pos++ == 8) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
pos = 0;
|
pos = 0;
|
||||||
}
|
}
|
||||||
else printf(" ");
|
else printf(" ");
|
||||||
|
|
||||||
printf("};\n");
|
printf("};\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ disable the optimiser we might get something like:
|
|||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
$ ./marshall
|
$ ./marshall
|
||||||
choo choo
|
choo choo
|
||||||
Segmentation fault: 11
|
Segmentation fault: 11
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ supports the `-traditional-cpp` option.
|
|||||||
### Alternate build:
|
### Alternate build:
|
||||||
|
|
||||||
``` <!--sh-->
|
``` <!--sh-->
|
||||||
make alt
|
make alt
|
||||||
```
|
```
|
||||||
|
|
||||||
### Alternate use:
|
### Alternate use:
|
||||||
|
|||||||
+1
-1
@@ -45,7 +45,7 @@ is legal C, what type of value is `"have"`?
|
|||||||
3. Note that the following expressions yield the same value:
|
3. Note that the following expressions yield the same value:
|
||||||
|
|
||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
x[3] *(x+3) *(3+x)
|
x[3] *(x+3) *(3+x)
|
||||||
```
|
```
|
||||||
|
|
||||||
since addition is commutative. What can be said about this value?
|
since addition is commutative. What can be said about this value?
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ Note the unusual structure:
|
|||||||
|
|
||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
while (<condition>)
|
while (<condition>)
|
||||||
;
|
;
|
||||||
```
|
```
|
||||||
|
|
||||||
Did you notice that the body is empty?
|
Did you notice that the body is empty?
|
||||||
@@ -68,9 +68,9 @@ variables like:
|
|||||||
|
|
||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"argv=%lo *argv=%lo **argv=%c argv[1]=%lo *argv[1]=%c argc=%d\n",
|
"argv=%lo *argv=%lo **argv=%c argv[1]=%lo *argv[1]=%c argc=%d\n",
|
||||||
(long) argv, (long) *argv, *argv && **argv ? **argv : '@',
|
(long) argv, (long) *argv, *argv && **argv ? **argv : '@',
|
||||||
(long) argv[1], argv[1] && *argv[1] ? *argv[1] : '@', argc);
|
(long) argv[1], argv[1] && *argv[1] ? *argv[1] : '@', argc);
|
||||||
```
|
```
|
||||||
|
|
||||||
... which is what the [alternate code](#alternate-code) is.
|
... which is what the [alternate code](#alternate-code) is.
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ character.
|
|||||||
(+ 2.5 3.1)
|
(+ 2.5 3.1)
|
||||||
(defun fib (n)
|
(defun fib (n)
|
||||||
(if (< n 2)
|
(if (< n 2)
|
||||||
1
|
1
|
||||||
(+ (fib (- n 2)) (fib (- n 1)))))
|
(+ (fib (- n 2)) (fib (- n 1)))))
|
||||||
(fib 10)
|
(fib 10)
|
||||||
(defun ! (x) (if (equal x 0) 1 (* x (! (- x 1)))))
|
(defun ! (x) (if (equal x 0) 1 (* x (! (- x 1)))))
|
||||||
(! 7)
|
(! 7)
|
||||||
|
|||||||
+12
-12
@@ -23,12 +23,12 @@
|
|||||||
The second command, `./tromp 10 "hkl jq"`, will set up the keys kind of like
|
The second command, `./tromp 10 "hkl jq"`, will set up the keys kind of like
|
||||||
vim:
|
vim:
|
||||||
|
|
||||||
- h - left (left)
|
- h - left (left)
|
||||||
- k - rotate (up)
|
- k - rotate (up)
|
||||||
- l - right (right)
|
- l - right (right)
|
||||||
- j - drop (down)
|
- j - drop (down)
|
||||||
- space - pause (space)
|
- space - pause (space)
|
||||||
- q - quit (:q)
|
- q - quit (:q)
|
||||||
|
|
||||||
NOTE: after the game ends a file called `HI` will be in the directory with the
|
NOTE: after the game ends a file called `HI` will be in the directory with the
|
||||||
high scores (up to 20 runs saved) so one can see who has the highest score. The
|
high scores (up to 20 runs saved) so one can see who has the highest score. The
|
||||||
@@ -80,12 +80,12 @@ will drop in a second, is 2. The default `cmd_string` is
|
|||||||
`jkl pq`. The first 6 characters of `cmd_string` relate
|
`jkl pq`. The first 6 characters of `cmd_string` relate
|
||||||
to the following 6 game commands:
|
to the following 6 game commands:
|
||||||
|
|
||||||
- j - left
|
- j - left
|
||||||
- k - rotate
|
- k - rotate
|
||||||
- l - right
|
- l - right
|
||||||
- space - drop
|
- space - drop
|
||||||
- p - pause
|
- p - pause
|
||||||
- q - quit
|
- q - quit
|
||||||
|
|
||||||
Specifying `cmd_string` allows one to redefine the commands.
|
Specifying `cmd_string` allows one to redefine the commands.
|
||||||
The pause command pauses the game, clears the screen and
|
The pause command pauses the game, clears the screen and
|
||||||
|
|||||||
+6
-6
@@ -91,12 +91,12 @@ Boolean expressions evaluate to 0 for false and 1 for true.
|
|||||||
|
|
||||||
### Limits:
|
### Limits:
|
||||||
|
|
||||||
- Line numbers 1-10000
|
- Line numbers 1-10000
|
||||||
- Line length 999 characters
|
- Line length 999 characters
|
||||||
- FOR nesting 26
|
- FOR nesting 26
|
||||||
- GOSUB 999 levels
|
- GOSUB 999 levels
|
||||||
- Program Dynamically allocated
|
- Program Dynamically allocated
|
||||||
- Expressions -32768 - 32767 for 16 bit machines, -2147483648 - 2147483647 for 32 bit machines
|
- Expressions -32768 - 32767 for 16 bit machines, -2147483648 - 2147483647 for 32 bit machines
|
||||||
|
|
||||||
### Error checking / error reports:
|
### Error checking / error reports:
|
||||||
|
|
||||||
|
|||||||
+13
-13
@@ -180,8 +180,8 @@ with one shell cmd at the far end.
|
|||||||
p=0
|
p=0
|
||||||
for f in `ls /tmp/shark$$*`
|
for f in `ls /tmp/shark$$*`
|
||||||
do
|
do
|
||||||
p=`expr $p + 1`
|
p=`expr $p + 1`
|
||||||
mail -s "bundle ($p of $n) from '`whoami`'" $m < $f
|
mail -s "bundle ($p of $n) from '`whoami`'" $m < $f
|
||||||
done
|
done
|
||||||
rm /tmp/shark$$*
|
rm /tmp/shark$$*
|
||||||
```
|
```
|
||||||
@@ -190,33 +190,33 @@ with one shell cmd at the far end.
|
|||||||
### Shark history:
|
### Shark history:
|
||||||
|
|
||||||
- May 1987: Karl Fox introduces 1023-byte `zcat.c` to USENET.
|
- May 1987: Karl Fox introduces 1023-byte `zcat.c` to USENET.
|
||||||
It's too late for the 4th IOCCC.
|
It's too late for the 4th IOCCC.
|
||||||
|
|
||||||
- May 21, 1987: James A. Woods extends idea to construct self
|
- May 21, 1987: James A. Woods extends idea to construct self
|
||||||
decompressing `shar` Trojan horse, utilizing `cc`, `shar`,
|
decompressing `shar` Trojan horse, utilizing `cc`, `shar`,
|
||||||
`zcat`, & `btoa`; size: 2303 bytes.
|
`zcat`, & `btoa`; size: 2303 bytes.
|
||||||
|
|
||||||
- May 23, 1987: `jaw` trims 250 bytes without much thought.
|
- May 23, 1987: `jaw` trims 250 bytes without much thought.
|
||||||
|
|
||||||
- June 2, 1987: 52 lines of shell, 1991 bytes, now made with `tar`,
|
- June 2, 1987: 52 lines of shell, 1991 bytes, now made with `tar`,
|
||||||
short-circuit C-compile at far end, dual-use main.c,
|
short-circuit C-compile at far end, dual-use main.c,
|
||||||
portability mods. (jaw)
|
portability mods. (jaw)
|
||||||
|
|
||||||
- Mar-May 1988: abortive run at 5th IOCCC.
|
- Mar-May 1988: abortive run at 5th IOCCC.
|
||||||
`jaw.c` - 1529 bytes. compile line: 152 bytes.
|
`jaw.c` - 1529 bytes. compile line: 152 bytes.
|
||||||
generated funny code with `execvp()` to invoke shell.
|
generated funny code with `execvp()` to invoke shell.
|
||||||
|
|
||||||
- Aug 29, 1988: production version, now at 1830 bytes.
|
- Aug 29, 1988: production version, now at 1830 bytes.
|
||||||
|
|
||||||
- Jan 1990: Paul Eggert does tour-de-force shark re-engineering.
|
- Jan 1990: Paul Eggert does tour-de-force shark re-engineering.
|
||||||
|
|
||||||
- May 24, 1990: collaboration yields 999-byte `jaw.c` core (see above)
|
- May 24, 1990: collaboration yields 999-byte `jaw.c` core (see above)
|
||||||
and 1530-byte production shell code (w/comments).
|
and 1530-byte production shell code (w/comments).
|
||||||
Eggert comes through with lion's share of improvements.
|
Eggert comes through with lion's share of improvements.
|
||||||
7th IOCCC code now faster than the `btoa`/`zcat` it replaces.
|
7th IOCCC code now faster than the `btoa`/`zcat` it replaces.
|
||||||
|
|
||||||
- May 1990: `jaw` develops experimental replacement using
|
- May 1990: `jaw` develops experimental replacement using
|
||||||
Dan Bernstein's high-compression 'squeeze'.
|
Dan Bernstein's high-compression 'squeeze'.
|
||||||
|
|
||||||
|
|
||||||
To which we add:
|
To which we add:
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ The 'expression' `f(x,y)` is any function of `x` and `y` with the
|
|||||||
operators:
|
operators:
|
||||||
|
|
||||||
```
|
```
|
||||||
+ - * / ^
|
+ - * / ^
|
||||||
```
|
```
|
||||||
|
|
||||||
The symbol `^` is the power operator. Note that it only supports
|
The symbol `^` is the power operator. Note that it only supports
|
||||||
|
|||||||
@@ -71,10 +71,10 @@ For example, the first block of code would read:
|
|||||||
|
|
||||||
```
|
```
|
||||||
charlie,
|
charlie,
|
||||||
doubletime me, OXFACE!
|
doubletime me, OXFACE!
|
||||||
not interested, get out
|
not interested, get out
|
||||||
mainly die, charly, *die*
|
mainly die, charly, *die*
|
||||||
signed charlotte
|
signed charlotte
|
||||||
```
|
```
|
||||||
|
|
||||||
The original source had control-L's after each code block. To
|
The original source had control-L's after each code block. To
|
||||||
|
|||||||
+24
-24
@@ -88,23 +88,23 @@ results depending on the implementation of `curses`.
|
|||||||
### Commands
|
### Commands
|
||||||
|
|
||||||
```
|
```
|
||||||
h j k l left, down, up, right cursor movement
|
h j k l left, down, up, right cursor movement
|
||||||
H J K L word left, page down, page up, word right
|
H J K L word left, page down, page up, word right
|
||||||
[ ] beginning and end of line
|
[ ] beginning and end of line
|
||||||
t b top and bottom of file
|
t b top and bottom of file
|
||||||
i enter insert mode, form-feed to quit
|
i enter insert mode, form-feed to quit
|
||||||
x delete character under the cursor
|
x delete character under the cursor
|
||||||
W write buffer to file
|
W write buffer to file
|
||||||
R refresh the screen
|
R refresh the screen
|
||||||
Q quit
|
Q quit
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Exit status
|
### Exit status
|
||||||
|
|
||||||
```
|
```
|
||||||
0 success
|
0 success
|
||||||
2 missing edit filename
|
2 missing edit filename
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -142,24 +142,24 @@ screen with long lines. Paging up and down should work correctly, however.
|
|||||||
|
|
||||||
### References:
|
### References:
|
||||||
|
|
||||||
[Fin80] Craig A. Finseth, "Theory and Practice of Text Editors or<br>
|
[Fin80] Craig A. Finseth, "Theory and Practice of Text Editors or<br>
|
||||||
A Cookbook For An EMACS", TM-165, MIT Lab. for Computer<br>
|
A Cookbook For An EMACS", TM-165, MIT Lab. for Computer<br>
|
||||||
Science
|
Science
|
||||||
|
|
||||||
[KeP81] Kernighan & Plauger, "Software Tools in Pascal",<br>
|
[KeP81] Kernighan & Plauger, "Software Tools in Pascal",<br>
|
||||||
Addison-Wesley, 81, chapter 6
|
Addison-Wesley, 81, chapter 6
|
||||||
|
|
||||||
[Mil86] Eugene W. Myers & Webb Miller, "Row-replacement Algorithms
|
[Mil86] Eugene W. Myers & Webb Miller, "Row-replacement Algorithms
|
||||||
for Screen Editors", TR 86-19, Dept. of Computer Science,<br>
|
for Screen Editors", TR 86-19, Dept. of Computer Science,<br>
|
||||||
U. of Arizona
|
U. of Arizona
|
||||||
|
|
||||||
[MyM86] Eugene W. Myers & Webb Miller, "A simple row-replacement<br>
|
[MyM86] Eugene W. Myers & Webb Miller, "A simple row-replacement<br>
|
||||||
method", TR 86-28, Dept. of Computer Science, U. of Arizona
|
method", TR 86-28, Dept. of Computer Science, U. of Arizona
|
||||||
|
|
||||||
[Mil87] Webb Miller, "A Software Tools Sampler", Prentice Hall, 87
|
[Mil87] Webb Miller, "A Software Tools Sampler", Prentice Hall, 87
|
||||||
ISBN 0-13-822305-X, chapter 5
|
ISBN 0-13-822305-X, chapter 5
|
||||||
|
|
||||||
[net90] "Editor 101/102" articles from comp.editors
|
[net90] "Editor 101/102" articles from comp.editors
|
||||||
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|||||||
@@ -77,9 +77,9 @@ delimiters.
|
|||||||
- `D`: dup (duplicate) top of `i` stack
|
- `D`: dup (duplicate) top of `i` stack
|
||||||
- `'`: dup top of `s` stack
|
- `'`: dup top of `s` stack
|
||||||
- `s`: pop top of `i` stack. If it is `n`, swap `(n+1)`th-top of `i` stack with top.
|
- `s`: pop top of `i` stack. If it is `n`, swap `(n+1)`th-top of `i` stack with top.
|
||||||
`1s`, for example, swaps the top two elements; `2s` swaps the top with the
|
`1s`, for example, swaps the top two elements; `2s` swaps the top with the
|
||||||
third down; etc. This always pops the top of the `i` stack, even upon
|
third down; etc. This always pops the top of the `i` stack, even upon
|
||||||
failure.
|
failure.
|
||||||
- `S`: pop top of `i` stack, then act just like `s` but upon `s` stack
|
- `S`: pop top of `i` stack, then act just like `s` but upon `s` stack
|
||||||
- `l`: pop top of `s` stack, push its length onto `i` stack
|
- `l`: pop top of `s` stack, push its length onto `i` stack
|
||||||
- `a`: push argc onto `i` stack
|
- `a`: push argc onto `i` stack
|
||||||
@@ -91,8 +91,8 @@ delimiters.
|
|||||||
- `/`: pop top two elements of `i` stack, divide, push back quotient
|
- `/`: pop top two elements of `i` stack, divide, push back quotient
|
||||||
- `>`: pop top two elements of `i` stack, compare, push back 1 or 0 as in C
|
- `>`: pop top two elements of `i` stack, compare, push back 1 or 0 as in C
|
||||||
- `&`: pop top two elements of `i` stack, NAND, push back bitwise result
|
- `&`: pop top two elements of `i` stack, NAND, push back bitwise result
|
||||||
Note that NAND is sufficient to construct all bitwise operations, as
|
Note that NAND is sufficient to construct all bitwise operations, as
|
||||||
demonstrated by `icalc` in [sorta.README.html](sorta.README.html).
|
demonstrated by `icalc` in [sorta.README.html](sorta.README.html).
|
||||||
|
|
||||||
### System operations
|
### System operations
|
||||||
|
|
||||||
|
|||||||
@@ -35,12 +35,12 @@ This is self-explanatory.
|
|||||||
[1D=d2/1=1ddd1 ]:!ld
|
[1D=d2/1=1ddd1 ]:!ld
|
||||||
["0"Td]:0ld
|
["0"Td]:0ld
|
||||||
[DD=!1_+=0]:@ld [ input m, m assumed nonnegative, append
|
[DD=!1_+=0]:@ld [ input m, m assumed nonnegative, append
|
||||||
binary representation of m to top of s stack ]ld
|
binary representation of m to top of s stack ]ld
|
||||||
|
|
||||||
["-"T_]:+ld
|
["-"T_]:+ld
|
||||||
[D0 1s>=+1=@]:2ld [ input m, append - to top of s stack if m is negative,
|
[D0 1s>=+1=@]:2ld [ input m, append - to top of s stack if m is negative,
|
||||||
then append binary representation of abs(m) to
|
then append binary representation of abs(m) to
|
||||||
top of s stack ]ld
|
top of s stack ]ld
|
||||||
|
|
||||||
[d1A:A2=A]:A 27182 a1>=A
|
[d1A:A2=A]:A 27182 a1>=A
|
||||||
[d2A:A1=A]:A 3145 a2>=A
|
[d2A:A1=A]:A 3145 a2>=A
|
||||||
@@ -152,7 +152,7 @@ Notice that `"2 2+"` is a literal string inside the program.
|
|||||||
["rot13: fatal: cannot open "1ST`q]:hld
|
["rot13: fatal: cannot open "1ST`q]:hld
|
||||||
a2_+=g
|
a2_+=g
|
||||||
1A 0 [ that 0 is for RDONLY ]ld
|
1A 0 [ that 0 is for RDONLY ]ld
|
||||||
0 'o D0 1s>=hld
|
0 'o D0 1s>=hld
|
||||||
0Ou1=x [ in a more complex spawner, this would be done under a fork ]ld
|
0Ou1=x [ in a more complex spawner, this would be done under a fork ]ld
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -83,23 +83,23 @@ enjoyment high.
|
|||||||
Key to map:
|
Key to map:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
|
||||||
###### | | | /\ /--\ ==| /\ | | Directonal keys
|
###### | | | /\ /--\ ==| /\ | | Directonal keys
|
||||||
###### Solid Wall | ----|| \/ /\ ||---- (unlock doors of
|
###### Solid Wall | ----|| \/ /\ ||---- (unlock doors of
|
||||||
###### | \/ ==| \--/ \/ the same direction)
|
###### | \/ ==| \--/ \/ the same direction)
|
||||||
|
|
|
|
||||||
| << >> Doors. Unlocked by
|
| << >> Doors. Unlocked by
|
||||||
Blank space | << vvvvvv ^^^^^^ >> the above keys.
|
Blank space | << vvvvvv ^^^^^^ >> the above keys.
|
||||||
| << >>
|
| << >>
|
||||||
|
|
|
|
||||||
___ | o__O\ O__O ^__^ /O__o\
|
___ | o__O\ O__O ^__^ /O__o\
|
||||||
/ \ 'Crushable' | \___/ /----\ /----\ \___/ The four sprites for
|
/ \ 'Crushable' | \___/ /----\ /----\ \___/ The four sprites for
|
||||||
\___/ boulder | _/_\ _/ \_ _/ \_ /_\_ your character :-)
|
\___/ boulder | _/_\ _/ \_ _/ \_ /_\_ your character :-)
|
||||||
|
|
|
|
||||||
___ uncrushable | /\ Diamonds. They can either be found lying
|
___ uncrushable | /\ Diamonds. They can either be found lying
|
||||||
/@@@\ boulder | < > around (if only!) or manufacture by pushing
|
/@@@\ boulder | < > around (if only!) or manufacture by pushing
|
||||||
\@@@/ | \/ two 'crushable' rocks together.
|
\@@@/ | \/ two 'crushable' rocks together.
|
||||||
|
|
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The general idea of the game is to collect all the diamonds. This must
|
The general idea of the game is to collect all the diamonds. This must
|
||||||
|
|||||||
+12
-12
@@ -56,7 +56,7 @@ game:
|
|||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
make ttt
|
make ttt
|
||||||
./ttt [first_move] # <- omit first arg to have it move first
|
./ttt [first_move] # <- omit first arg to have it move first
|
||||||
./ttt next_move
|
./ttt next_move
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -65,8 +65,8 @@ The shell script determines when the game is over, and automatically replaces
|
|||||||
loss). The [ttt](%%REPO_URL%%/1991/westley/ttt.sh) script has two other modes:
|
loss). The [ttt](%%REPO_URL%%/1991/westley/ttt.sh) script has two other modes:
|
||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
./ttt quitgame # cancel any game in progress, revert to merlyn.c
|
./ttt quitgame # cancel any game in progress, revert to merlyn.c
|
||||||
./ttt clobber # remove all game files, revert to original source
|
./ttt clobber # remove all game files, revert to original source
|
||||||
```
|
```
|
||||||
|
|
||||||
For example here is a potentially losing game:
|
For example here is a potentially losing game:
|
||||||
@@ -81,9 +81,9 @@ The final might look like:
|
|||||||
|
|
||||||
|
|
||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
a(X){/*/X=- a(X){/*/X=-
|
a(X){/*/X=- a(X){/*/X=-
|
||||||
X -1;F;X=- -1;F;X=-
|
X -1;F;X=- -1;F;X=-
|
||||||
-1;F;}/*/ -1;F;}/*/
|
-1;F;}/*/ -1;F;}/*/
|
||||||
char z[][100]={"char z[][100]={","a(X){/*/X=-","-1;F;X=-","-1;F;}/*/","1999999999 :-) ",
|
char z[][100]={"char z[][100]={","a(X){/*/X=-","-1;F;X=-","-1;F;}/*/","1999999999 :-) ",
|
||||||
"int q,i,j,k,X,O=0,H;S(x)int*x;{X+=X;O+=O;*x+1?*x+2||X++:O++;*x=1;}L(n){for(*",
|
"int q,i,j,k,X,O=0,H;S(x)int*x;{X+=X;O+=O;*x+1?*x+2||X++:O++;*x=1;}L(n){for(*",
|
||||||
"z[i=1]=n+97;i<4;i++)M(256),s(i),M(128),s(i),M(64),N;X*=8;O*=8;}s(R){char*r=z",
|
"z[i=1]=n+97;i<4;i++)M(256),s(i),M(128),s(i),M(64),N;X*=8;O*=8;}s(R){char*r=z",
|
||||||
@@ -93,9 +93,9 @@ The final might look like:
|
|||||||
"c(1);*J=--u?O?*J:*v[1]:53;X|=u<<57-*v[u];y(X);K=40+q;q?e(O,X),q&&(K='|'),e(X",
|
"c(1);*J=--u?O?*J:*v[1]:53;X|=u<<57-*v[u];y(X);K=40+q;q?e(O,X),q&&(K='|'),e(X",
|
||||||
",O),R(),O|=1<<--i:J[*J-48+(X=O=0)]--;L(q=0);for(s(i=0);q=i<12;)s(i++),i>4&&N",
|
",O),R(),O|=1<<--i:J[*J-48+(X=O=0)]--;L(q=0);for(s(i=0);q=i<12;)s(i++),i>4&&N",
|
||||||
";s(q=12);P(48);P('}');P(59);N;q=0;L(1);for(i=5;i<13;)s(i++),N;L(2);}",0};
|
";s(q=12);P(48);P('}');P(59);N;q=0;L(1);for(i=5;i<13;)s(i++),N;L(2);}",0};
|
||||||
b(X){/*/X=- b(X){/*/X=-
|
b(X){/*/X=- b(X){/*/X=-
|
||||||
X -1;F;X=- -1;F;X=- X
|
X -1;F;X=- -1;F;X=- X
|
||||||
-1;F;}/*/ -1;F;}/*/
|
-1;F;}/*/ -1;F;}/*/
|
||||||
int q,i,j,k,X,O=0,H;S(x)int*x;{X+=X;O+=O;*x+1?*x+2||X++:O++;*x=1;}L(n){for(*
|
int q,i,j,k,X,O=0,H;S(x)int*x;{X+=X;O+=O;*x+1?*x+2||X++:O++;*x=1;}L(n){for(*
|
||||||
z[i=1]=n+97;i<4;i++)M(256),s(i),M(128),s(i),M(64),N;X*=8;O*=8;}s(R){char*r=z
|
z[i=1]=n+97;i<4;i++)M(256),s(i),M(128),s(i),M(64),N;X*=8;O*=8;}s(R){char*r=z
|
||||||
[R];for(q&&Q;*r;)P(*r++);q&&(Q,P(44));}M(m){P(9);i-2||P(X&m?88:O&m?48:32);P(
|
[R];for(q&&Q;*r;)P(*r++);q&&(Q,P(44));}M(m){P(9);i-2||P(X&m?88:O&m?48:32);P(
|
||||||
@@ -104,9 +104,9 @@ The final might look like:
|
|||||||
c(1);*J=--u?O?*J:*v[1]:53;X|=u<<57-*v[u];y(X);K=40+q;q?e(O,X),q&&(K='|'),e(X
|
c(1);*J=--u?O?*J:*v[1]:53;X|=u<<57-*v[u];y(X);K=40+q;q?e(O,X),q&&(K='|'),e(X
|
||||||
,O),R(),O|=1<<--i:J[*J-48+(X=O=0)]--;L(q=0);for(s(i=0);q=i<12;)s(i++),i>4&&N
|
,O),R(),O|=1<<--i:J[*J-48+(X=O=0)]--;L(q=0);for(s(i=0);q=i<12;)s(i++),i>4&&N
|
||||||
;s(q=12);P(48);P('}');P(59);N;q=0;L(1);for(i=5;i<13;)s(i++),N;L(2);}
|
;s(q=12);P(48);P('}');P(59);N;q=0;L(1);for(i=5;i<13;)s(i++),N;L(2);}
|
||||||
c(X){/*/X=- c(X){/*/X=-
|
c(X){/*/X=- c(X){/*/X=-
|
||||||
0 -1;F;X=- 0 -1;F;X=- 0
|
0 -1;F;X=- 0 -1;F;X=- 0
|
||||||
-1;F;}/*/ -1;F;}/*/
|
-1;F;}/*/ -1;F;}/*/
|
||||||
|
|
||||||
ttt: I win!
|
ttt: I win!
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -150,11 +150,11 @@ place to site some references on the AE, but I don't have any.
|
|||||||
O(c,a,b) let c = a Or
|
O(c,a,b) let c = a Or
|
||||||
boolean-or
|
boolean-or
|
||||||
b (a,b are
|
b (a,b are
|
||||||
0 or 1)
|
0 or 1)
|
||||||
|
|
||||||
B(b, a) let Boolean
|
B(b, a) let Boolean
|
||||||
b = boolean
|
b = boolean
|
||||||
value of a
|
value of a
|
||||||
|
|
||||||
P(b, a) let b = 1 if
|
P(b, a) let b = 1 if
|
||||||
a>0, else 0. Positive
|
a>0, else 0. Positive
|
||||||
@@ -228,8 +228,8 @@ ourselves to two operand operations:
|
|||||||
temp -= y; (temp == z-y)
|
temp -= y; (temp == z-y)
|
||||||
temp *= x; (temp == (z-y)*x)
|
temp *= x; (temp == (z-y)*x)
|
||||||
y += temp; (y == (z-y)*x + y)
|
y += temp; (y == (z-y)*x + y)
|
||||||
( == z*x - y*x + y)
|
( == z*x - y*x + y)
|
||||||
( == z*x + y*(1-x))
|
( == z*x + y*(1-x))
|
||||||
```
|
```
|
||||||
|
|
||||||
Next we imagine we have a [pc](https://en.wikipedia.org/wiki/Program_counter).
|
Next we imagine we have a [pc](https://en.wikipedia.org/wiki/Program_counter).
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
## Useful files to view
|
## Useful files to view
|
||||||
|
|
||||||
- [buzzard.2.README.html](buzzard.2.README.html) - this file
|
- [buzzard.2.README.html](buzzard.2.README.html) - this file
|
||||||
- [buzzard.2.design.html](buzzard.2.design.html) - description of FIRST (design documentation of THIRD)
|
- [buzzard.2.design.html](buzzard.2.design.html) - description of FIRST (design documentation of THIRD)
|
||||||
- [third](%%REPO_URL%%/1992/buzzard.2/third) - implementation of THIRD in FIRST
|
- [third](%%REPO_URL%%/1992/buzzard.2/third) - implementation of THIRD in FIRST
|
||||||
- [help.th](%%REPO_URL%%/1992/buzzard.2/help.th) - online listing of THIRD primitives
|
- [help.th](%%REPO_URL%%/1992/buzzard.2/help.th) - online listing of THIRD primitives
|
||||||
|
|
||||||
|
|
||||||
## FIRST demos:
|
## FIRST demos:
|
||||||
@@ -14,7 +14,7 @@ Use:
|
|||||||
./first < demo_file
|
./first < demo_file
|
||||||
```
|
```
|
||||||
|
|
||||||
- [demo1.1st](%%REPO_URL%%/1992/buzzard.2/demo1.1st) - prints Hello World! assuming ASCII
|
- [demo1.1st](%%REPO_URL%%/1992/buzzard.2/demo1.1st) - prints Hello World! assuming ASCII
|
||||||
|
|
||||||
|
|
||||||
## THIRD demos:
|
## THIRD demos:
|
||||||
@@ -28,12 +28,12 @@ Use:
|
|||||||
|
|
||||||
## Demo files:
|
## Demo files:
|
||||||
|
|
||||||
- [demo1.th](%%REPO_URL%%/1992/buzzard.2/demo1.th) - prints Hello World! regardless of character set
|
- [demo1.th](%%REPO_URL%%/1992/buzzard.2/demo1.th) - prints Hello World! regardless of character set
|
||||||
- [demo2.th](%%REPO_URL%%/1992/buzzard.2/demo2.th) - demonstrates a simple loop
|
- [demo2.th](%%REPO_URL%%/1992/buzzard.2/demo2.th) - demonstrates a simple loop
|
||||||
- [demo3.th](%%REPO_URL%%/1992/buzzard.2/demo3.th) - demonstrates a simple if test
|
- [demo3.th](%%REPO_URL%%/1992/buzzard.2/demo3.th) - demonstrates a simple if test
|
||||||
- [demo4.th](%%REPO_URL%%/1992/buzzard.2/demo4.th) - recursive factorial calculating on the way up
|
- [demo4.th](%%REPO_URL%%/1992/buzzard.2/demo4.th) - recursive factorial calculating on the way up
|
||||||
- [demo5.th](%%REPO_URL%%/1992/buzzard.2/demo5.th) - recursive factorial calculating on the way down
|
- [demo5.th](%%REPO_URL%%/1992/buzzard.2/demo5.th) - recursive factorial calculating on the way down
|
||||||
- [demo6.th](%%REPO_URL%%/1992/buzzard.2/demo6.th) - demonstrates switching from compiler to execution mode
|
- [demo6.th](%%REPO_URL%%/1992/buzzard.2/demo6.th) - demonstrates switching from compiler to execution mode
|
||||||
|
|
||||||
|
|
||||||
## Interactive THIRD:
|
## Interactive THIRD:
|
||||||
|
|||||||
+374
-374
File diff suppressed because it is too large.
Load diff
+8
-8
@@ -40,19 +40,19 @@ following locations though the last one is more ironic:
|
|||||||
/usr/share/dict/words
|
/usr/share/dict/words
|
||||||
/usr/share/lib/spell/words
|
/usr/share/lib/spell/words
|
||||||
/usr/ucblib/dict/words
|
/usr/ucblib/dict/words
|
||||||
/dev/null # <-- for machines with nothing to say
|
/dev/null # <-- for machines with nothing to say
|
||||||
```
|
```
|
||||||
|
|
||||||
Then using the proper dictionary file it does:
|
Then using the proper dictionary file it does:
|
||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
./ag free software foundation < /usr/share/dict/words
|
./ag free software foundation < /usr/share/dict/words
|
||||||
./ag obfuscated c contest < /usr/share/dict/words
|
./ag obfuscated c contest < /usr/share/dict/words
|
||||||
./ag unix international < /usr/share/dict/words
|
./ag unix international < /usr/share/dict/words
|
||||||
./ag george bush < /usr/share/dict/words
|
./ag george bush < /usr/share/dict/words
|
||||||
./ag bill clinton < /usr/share/dict/words
|
./ag bill clinton < /usr/share/dict/words
|
||||||
./ag ross perot < /usr/share/dict/words
|
./ag ross perot < /usr/share/dict/words
|
||||||
./ag paul e tsongas < /usr/share/dict/words
|
./ag paul e tsongas < /usr/share/dict/words
|
||||||
```
|
```
|
||||||
|
|
||||||
where `/usr/share/dict/words` is the dictionary file.
|
where `/usr/share/dict/words` is the dictionary file.
|
||||||
|
|||||||
+5
-5
@@ -126,23 +126,23 @@ The options of this program are:
|
|||||||
|
|
||||||
```
|
```
|
||||||
-centre x y (float x,y) Centre the picture at x+iy in the complex
|
-centre x y (float x,y) Centre the picture at x+iy in the complex
|
||||||
plane (default x=0 y=0)
|
plane (default x=0 y=0)
|
||||||
|
|
||||||
|
|
||||||
-factor f (float f) Use f pixels per unit of the plane (default
|
-factor f (float f) Use f pixels per unit of the plane (default
|
||||||
f=x/4 where x is the width)
|
f=x/4 where x is the width)
|
||||||
|
|
||||||
|
|
||||||
-julia x y (float x,y) Draw a julia set. Use x+iy as the constant
|
-julia x y (float x,y) Draw a julia set. Use x+iy as the constant
|
||||||
to add after squaring (default x=0 y=0)
|
to add after squaring (default x=0 y=0)
|
||||||
|
|
||||||
-limit l (int l) Use l iterations maximum (default l=128)
|
-limit l (int l) Use l iterations maximum (default l=128)
|
||||||
|
|
||||||
-mask m (int m) Use m as a mask in deciding the colour of each
|
-mask m (int m) Use m as a mask in deciding the colour of each
|
||||||
pixel (see below) (default m=1)
|
pixel (see below) (default m=1)
|
||||||
|
|
||||||
-size x y (int x,y) Produce an x-by-y output (default for raster
|
-size x y (int x,y) Produce an x-by-y output (default for raster
|
||||||
x=768 y=768; default for text x=63 y=23)
|
x=768 y=768; default for text x=63 y=23)
|
||||||
|
|
||||||
-text Produce text instead of raster.
|
-text Produce text instead of raster.
|
||||||
```
|
```
|
||||||
|
|||||||
+3
-3
@@ -19,7 +19,7 @@ For more detailed information see [1992/vern in bugs.html](../../bugs.html#1992_
|
|||||||
## To use:
|
## To use:
|
||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
./vern 3 # <-- default is 2
|
./vern 3 # <-- default is 2
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ You might start off by giving the following input:
|
|||||||
63 43
|
63 43
|
||||||
76 55
|
76 55
|
||||||
71 52
|
71 52
|
||||||
67 57 # <-- this may take a while
|
67 57 # <-- this may take a while
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ does:
|
|||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
sed <vern.c 's/{ /(/g;s/} /)/g;s/; /#define /' |
|
sed <vern.c 's/{ /(/g;s/} /)/g;s/; /#define /' |
|
||||||
sed 's/} /=/g;s/{ /i/g' >vern.tmp.c
|
sed 's/} /=/g;s/{ /i/g' >vern.tmp.c
|
||||||
```
|
```
|
||||||
|
|
||||||
and compiles `vern.tmp.c`.
|
and compiles `vern.tmp.c`.
|
||||||
|
|||||||
+10
-10
@@ -169,16 +169,16 @@ is reasonably accurate.
|
|||||||
### Here are some cities you might like to try:
|
### Here are some cities you might like to try:
|
||||||
|
|
||||||
```
|
```
|
||||||
New York 41 -74
|
New York 41 -74
|
||||||
London 52 0
|
London 52 0
|
||||||
Moscow 56 38
|
Moscow 56 38
|
||||||
New Delhi 29 77
|
New Delhi 29 77
|
||||||
Sydney -34 151
|
Sydney -34 151
|
||||||
Los Angeles 34 -118
|
Los Angeles 34 -118
|
||||||
Paris 45 2
|
Paris 45 2
|
||||||
Rio de Janeiro -23 -43
|
Rio de Janeiro -23 -43
|
||||||
Beijing 40 116
|
Beijing 40 116
|
||||||
Tokyo 36 140
|
Tokyo 36 140
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ For more detailed information see [1993/cmills in bugs.html](../../bugs.html#199
|
|||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
DISPLAY="your_X_server_display"
|
DISPLAY="your_X_server_display"
|
||||||
export DISPLAY
|
export DISPLAY
|
||||||
./cmills.alt [speed] # must be run on an X11 server
|
./cmills.alt [speed] # must be run on an X11 server
|
||||||
```
|
```
|
||||||
|
|
||||||
where:
|
where:
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ you need help.
|
|||||||
## To use:
|
## To use:
|
||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
./jonth # must be run on an X11 server
|
./jonth # must be run on an X11 server
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -74,15 +74,15 @@ Please don't type `^D` at the prompt!!
|
|||||||
```
|
```
|
||||||
$ ./leo
|
$ ./leo
|
||||||
(1296): 6433
|
(1296): 6433
|
||||||
?? 12 # one 3 is a bull, another is a cow, and 4 is a cow
|
?? 12 # one 3 is a bull, another is a cow, and 4 is a cow
|
||||||
(160): 5363
|
(160): 5363
|
||||||
?? 02 # both 3's are cows
|
?? 02 # both 3's are cows
|
||||||
(21): 4231
|
(21): 4231
|
||||||
?? 22 # 2 and 3 are bulls, 4 and 1 are cows
|
?? 22 # 2 and 3 are bulls, 4 and 1 are cows
|
||||||
(2): 4132
|
(2): 4132
|
||||||
?? 13 # 3 is a bull; 1, 2 and 4 are cows
|
?? 13 # 3 is a bull; 1, 2 and 4 are cows
|
||||||
(1): 1234
|
(1): 1234
|
||||||
?? 40 # you may enter everything there
|
?? 40 # you may enter everything there
|
||||||
```
|
```
|
||||||
|
|
||||||
##### EXAMPLE: Guess the computer's number
|
##### EXAMPLE: Guess the computer's number
|
||||||
@@ -100,7 +100,7 @@ Please don't type `^D` at the prompt!!
|
|||||||
(2): ???? 3355
|
(2): ???? 3355
|
||||||
00
|
00
|
||||||
(1): ???? 6444
|
(1): ???? 6444
|
||||||
40 # we have guessed the number
|
40 # we have guessed the number
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -197,11 +197,11 @@ These failed miserably:
|
|||||||
#### Debuggers: (tested at SunOS 4.1.2)
|
#### Debuggers: (tested at SunOS 4.1.2)
|
||||||
|
|
||||||
- `dbx` - Quit with a very 'informative' error message:
|
- `dbx` - Quit with a very 'informative' error message:
|
||||||
`"dbx: fatal error: Is a directory"`
|
`"dbx: fatal error: Is a directory"`
|
||||||
|
|
||||||
- `gdb` - Printed almost the same error message `": Is a directory"`.
|
- `gdb` - Printed almost the same error message `": Is a directory"`.
|
||||||
It was, however, possible to step through the code but
|
It was, however, possible to step through the code but
|
||||||
not list it.
|
not list it.
|
||||||
|
|
||||||
|
|
||||||
#### Lints
|
#### Lints
|
||||||
|
|||||||
@@ -126,9 +126,9 @@ must move after firing to be able to fire again.
|
|||||||
|
|
||||||
### Keys
|
### Keys
|
||||||
|
|
||||||
- `j` - Left
|
- `j` - Left
|
||||||
- `l` - Right
|
- `l` - Right
|
||||||
- `k` - Fire
|
- `k` - Fire
|
||||||
|
|
||||||
This is a new breed of generic games. For instance:
|
This is a new breed of generic games. For instance:
|
||||||
|
|
||||||
|
|||||||
+14
-14
@@ -10,9 +10,9 @@ For instance, assume you wish to make a boulder `o` roll off a hill `/`
|
|||||||
A standard automata would have 2 rules something like this:
|
A standard automata would have 2 rules something like this:
|
||||||
|
|
||||||
```
|
```
|
||||||
o.. ...
|
o.. ...
|
||||||
\.. --> 'o' .o. --> '.'
|
\.. --> 'o' .o. --> '.'
|
||||||
... .\.
|
... .\.
|
||||||
```
|
```
|
||||||
|
|
||||||
However, the system I devised, in order to keep things small and neat(!),
|
However, the system I devised, in order to keep things small and neat(!),
|
||||||
@@ -20,9 +20,9 @@ was to define a 3x3 to 3x3 map (instead of the 3x3 to 1x1 shown above).
|
|||||||
Hence:
|
Hence:
|
||||||
|
|
||||||
```
|
```
|
||||||
.o. ...
|
.o. ...
|
||||||
.\. --> .\o
|
.\. --> .\o
|
||||||
... ...
|
... ...
|
||||||
```
|
```
|
||||||
|
|
||||||
This does of course have the odd problem with clashes. What if we want to roll
|
This does of course have the odd problem with clashes. What if we want to roll
|
||||||
@@ -32,9 +32,9 @@ transition has priority win. Such a case may produce the following change of
|
|||||||
maps (depending on which 'roll' transition is used first).
|
maps (depending on which 'roll' transition is used first).
|
||||||
|
|
||||||
```
|
```
|
||||||
o.o ..o o..
|
o.o ..o o..
|
||||||
\./ changes to \o/ or to \o/
|
\./ changes to \o/ or to \o/
|
||||||
... ... ...
|
... ... ...
|
||||||
```
|
```
|
||||||
|
|
||||||
I claim that it is possible to perform all of the 3x3 to 1x1 transitions in a
|
I claim that it is possible to perform all of the 3x3 to 1x1 transitions in a
|
||||||
@@ -59,9 +59,9 @@ is hit we have a transition like:
|
|||||||
## Key: l
|
## Key: l
|
||||||
|
|
||||||
```
|
```
|
||||||
* * * * * *
|
* * * * * *
|
||||||
* @ . * . @
|
* @ . * . @
|
||||||
* * * * * *
|
* * * * * *
|
||||||
```
|
```
|
||||||
|
|
||||||
Here I also use wildcards. On the match side (left) of the transition, an
|
Here I also use wildcards. On the match side (left) of the transition, an
|
||||||
@@ -73,9 +73,9 @@ purposes of space saving, this transition is shrunk to a single line.
|
|||||||
## Key: K
|
## Key: K
|
||||||
|
|
||||||
```
|
```
|
||||||
a b c 1 2 3
|
a b c 1 2 3
|
||||||
d e f 4 5 6
|
d e f 4 5 6
|
||||||
g h i 7 8 9
|
g h i 7 8 9
|
||||||
```
|
```
|
||||||
|
|
||||||
is written as: `eabcdfghi512346789K`.
|
is written as: `eabcdfghi512346789K`.
|
||||||
|
|||||||
+39
-39
@@ -40,12 +40,12 @@ What happens if you use something other than valid digits?
|
|||||||
The octal expression may contain:
|
The octal expression may contain:
|
||||||
|
|
||||||
```
|
```
|
||||||
unary operators: +, -
|
unary operators: +, -
|
||||||
binary operators +, -, *, /, %
|
binary operators +, -, *, /, %
|
||||||
hex numbers: x or X followed by hex digits
|
hex numbers: x or X followed by hex digits
|
||||||
decimal numbers: d or D followed by decimal digits
|
decimal numbers: d or D followed by decimal digits
|
||||||
octal numbers: octal digits
|
octal numbers: octal digits
|
||||||
grouping: ()
|
grouping: ()
|
||||||
```
|
```
|
||||||
|
|
||||||
No spaces are allowed in the expression. To avoid shell expansion,
|
No spaces are allowed in the expression. To avoid shell expansion,
|
||||||
@@ -137,36 +137,36 @@ notes:
|
|||||||
#define O5 main
|
#define O5 main
|
||||||
O5(O2,O7,O3)char**O7;
|
O5(O2,O7,O3)char**O7;
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
/* N1 */ !(O2+=~01+01) ?\
|
/* N1 */ !(O2+=~01+01) ?\
|
||||||
00:
|
00:
|
||||||
/* N2 */ !(O2-=02>01) ?\
|
/* N2 */ !(O2-=02>01) ?\
|
||||||
printf("\045\157\012",O5(012,O7+01,00)):
|
printf("\045\157\012",O5(012,O7+01,00)):
|
||||||
/* O */ !(O2-=02>>01) ?\
|
/* O */ !(O2-=02>>01) ?\
|
||||||
(**O7<=067 && **O7>057 ? O5(03,O7,*(*O7)++-060+010*O3):O3):
|
(**O7<=067 && **O7>057 ? O5(03,O7,*(*O7)++-060+010*O3):O3):
|
||||||
/* D */ !(O2-=-O3-~O3) ?\
|
/* D */ !(O2-=-O3-~O3) ?\
|
||||||
(072>**O7 && 060<=**O7 ? O5(04,O7,012*O3-060+*(*O7)++):O3):
|
(072>**O7 && 060<=**O7 ? O5(04,O7,012*O3-060+*(*O7)++):O3):
|
||||||
/* X */ !(O2-=!O3+!!O3) ?\
|
/* X */ !(O2-=!O3+!!O3) ?\
|
||||||
(**O7>057 && **O7<=071 ? O5(05,O7,*(*O7)+++O3*020-060):
|
(**O7>057 && **O7<=071 ? O5(05,O7,*(*O7)+++O3*020-060):
|
||||||
**O7<=0106 && 0101<=**O7 ? O5(05,O7,020*O3+*(*O7)++-067):
|
**O7<=0106 && 0101<=**O7 ? O5(05,O7,020*O3+*(*O7)++-067):
|
||||||
0140<**O7 && **O7<0147 ? O5(05,O7,-0127+*(*O7)+++020*O3):O3):
|
0140<**O7 && **O7<0147 ? O5(05,O7,-0127+*(*O7)+++020*O3):O3):
|
||||||
/* F */ !(O2-=02-01) ?\
|
/* F */ !(O2-=02-01) ?\
|
||||||
(**O7==050 ? 050**++*O7,O5(013,O7,O5(012,O7,00)):
|
(**O7==050 ? 050**++*O7,O5(013,O7,O5(012,O7,00)):
|
||||||
**O7<056 && 054<**O7 ? 055**++*O7,-O5(06,O7,00):
|
**O7<056 && 054<**O7 ? 055**++*O7,-O5(06,O7,00):
|
||||||
054>**O7 && 052<**O7 ? 050**(*O7)++,O5(06,O7,00):
|
054>**O7 && 052<**O7 ? 050**(*O7)++,O5(06,O7,00):
|
||||||
!(**O7^0170)||!(0130^**O7) ? *++*O7,O5(05,O7,00):
|
!(**O7^0170)||!(0130^**O7) ? *++*O7,O5(05,O7,00):
|
||||||
**O7==0144||**O7==0104 ? ++*O7,O5(04,O7,00):O5(03,O7,00)):
|
**O7==0144||**O7==0104 ? ++*O7,O5(04,O7,00):O5(03,O7,00)):
|
||||||
/* T' */ !--O2 ?\
|
/* T' */ !--O2 ?\
|
||||||
(**O7==052 ? O5(07,O7,O3*(*++*O7,O5(06,O7,00))):
|
(**O7==052 ? O5(07,O7,O3*(*++*O7,O5(06,O7,00))):
|
||||||
!(045-**O7) ? O5(07,O7,O3%(03+(*O7)++,O5(06,O7,00))):
|
!(045-**O7) ? O5(07,O7,O3%(03+(*O7)++,O5(06,O7,00))):
|
||||||
!(**O7^057) ? O5(07,O7,O3/(03-*++*O7,O5(06,O7,00))):O3):
|
!(**O7^057) ? O5(07,O7,O3/(03-*++*O7,O5(06,O7,00))):O3):
|
||||||
/* T */ !(O2+=01-02) ?\
|
/* T */ !(O2+=01-02) ?\
|
||||||
O5(07,O7,O5(06,O7,00)):
|
O5(07,O7,O5(06,O7,00)):
|
||||||
/* E' */ !(O2+=-02/02) ?\
|
/* E' */ !(O2+=-02/02) ?\
|
||||||
(!(**O7-053)?O5(011,O7,O3+(++*O7,O5(010,O7,00))):
|
(!(**O7-053)?O5(011,O7,O3+(++*O7,O5(010,O7,00))):
|
||||||
!(055^**O7) ? O5(011,O7,O3-(03+*(*O7)++,O5(010,O7,00))):O3):
|
!(055^**O7) ? O5(011,O7,O3-(03+*(*O7)++,O5(010,O7,00))):O3):
|
||||||
/* E */ !(O2-=0563&0215) ?\
|
/* E */ !(O2-=0563&0215) ?\
|
||||||
O5(011,O7,O5(010,O7,00)):
|
O5(011,O7,O5(010,O7,00)):
|
||||||
/* C */ (++*O7,O3);
|
/* C */ (++*O7,O3);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -190,12 +190,12 @@ The `E'` and `T'` states work like this:
|
|||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
int eprime( int intermediate )
|
int eprime( int intermediate )
|
||||||
{
|
{
|
||||||
if( ch == '+' )
|
if( ch == '+' )
|
||||||
{
|
{
|
||||||
ch = nextchar();
|
ch = nextchar();
|
||||||
return eprime( intermediate + t() );
|
return eprime( intermediate + t() );
|
||||||
}
|
}
|
||||||
else return intermediate;
|
else return intermediate;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -205,13 +205,13 @@ called with `0`):
|
|||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
int octal( int intermediate )
|
int octal( int intermediate )
|
||||||
{
|
{
|
||||||
if( ch>='0' && ch<='7' )
|
if( ch>='0' && ch<='7' )
|
||||||
{
|
{
|
||||||
intermediate = intermediate * 8 + ch - '0';
|
intermediate = intermediate * 8 + ch - '0';
|
||||||
ch = nextchar();
|
ch = nextchar();
|
||||||
return octal( intermediate );
|
return octal( intermediate );
|
||||||
}
|
}
|
||||||
else return intermediate;
|
else return intermediate;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -60,7 +60,7 @@ Any of the following, though not required, would be a plus:
|
|||||||
If you think this may be you, send an email before 31 Dec 1995, to:
|
If you think this may be you, send an email before 31 Dec 1995, to:
|
||||||
|
|
||||||
```
|
```
|
||||||
judges@toad.com (use the Subject: 3rd judge)
|
judges@toad.com (use the Subject: 3rd judge)
|
||||||
```
|
```
|
||||||
|
|
||||||
Include in your message:
|
Include in your message:
|
||||||
@@ -82,7 +82,7 @@ access to put up some IOCCC html pages, please send an email (say prior
|
|||||||
to 31 Dec 1995) to:
|
to 31 Dec 1995) to:
|
||||||
|
|
||||||
```
|
```
|
||||||
judges@toad.com (use the Subject: www site)
|
judges@toad.com (use the Subject: www site)
|
||||||
```
|
```
|
||||||
|
|
||||||
describing your site and any other appropriate comments. Thanks!
|
describing your site and any other appropriate comments. Thanks!
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ For more information, see my article
|
|||||||
[Using GraphTab; USENIX ;login: Sept/Oct 1992, pages 28-31](login_sept92-pp28-31.pdf).
|
[Using GraphTab; USENIX ;login: Sept/Oct 1992, pages 28-31](login_sept92-pp28-31.pdf).
|
||||||
|
|
||||||
```
|
```
|
||||||
MMMM,M,MM"MM,,,
|
MMMM,M,MM"MM,,,
|
||||||
,,MMMMMMMMM"""""""",
|
,,MMMMMMMMM"""""""",
|
||||||
,MMMMM""" ",
|
,MMMMM""" ",
|
||||||
,MMM" "
|
,MMM" "
|
||||||
@@ -106,7 +106,7 @@ For more information, see my article
|
|||||||
",," , " "MMMMMMMM " , "
|
",," , " "MMMMMMMM " , "
|
||||||
,M , ""M,MMMMMMMM,M " ,,
|
,M , ""M,MMMMMMMM,M " ,,
|
||||||
,MM, MMMMMMMMMMMMMM,", M,
|
,MM, MMMMMMMMMMMMMM,", M,
|
||||||
M,M,MM"M"M" """M"MM,M M
|
M,M,MM"M"M" """M"MM,M M
|
||||||
,MMMMMM M,MMMMM"M MM""M
|
,MMMMMM M,MMMMM"M MM""M
|
||||||
M MMMMMM,M M"M"" M MMMM", ,
|
M MMMMMM,M M"M"" M MMMM", ,
|
||||||
"M"MMMMMMMMMM"M ,MMMMM M ,,
|
"M"MMMMMMMMMM"M ,MMMMM M ,,
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ The basic theme (pun) of this program is:
|
|||||||
|
|
||||||
```
|
```
|
||||||
"This time (everything) is not where it should be."
|
"This time (everything) is not where it should be."
|
||||||
~~~~
|
~~~~
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+15
-15
@@ -32,8 +32,8 @@ Mode may be a value from 0 to 12.
|
|||||||
## Try:
|
## Try:
|
||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
./try.color.sh # for colour displays
|
./try.color.sh # for colour displays
|
||||||
./try.bw.sh # for Black & White displays
|
./try.bw.sh # for Black & White displays
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -62,8 +62,8 @@ where `altmode` `1` - `4` correspond to mode `0` - `3` in the original entry and
|
|||||||
### Alternate try:
|
### Alternate try:
|
||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
./try.alt.color.sh # for colour displays
|
./try.alt.color.sh # for colour displays
|
||||||
./try.alt.bw.sh # for Black & White displays
|
./try.alt.bw.sh # for Black & White displays
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -169,15 +169,15 @@ compatible compiler (`gcc -ansi -pedantic` will do fine).
|
|||||||
This entry has been tested on wide variety of machines including:
|
This entry has been tested on wide variety of machines including:
|
||||||
|
|
||||||
```
|
```
|
||||||
Machine OS
|
Machine OS
|
||||||
------- --
|
------- --
|
||||||
Decstation 5000/240 Ultrix 4.3A
|
Decstation 5000/240 Ultrix 4.3A
|
||||||
DECAlpha 3000/300 OSF/1 v1.3 and v2.0
|
DECAlpha 3000/300 OSF/1 v1.3 and v2.0
|
||||||
IBM RS6000 AIX v3
|
IBM RS6000 AIX v3
|
||||||
SPARCStation IPX SunOS 4.1.3
|
SPARCStation IPX SunOS 4.1.3
|
||||||
i486 Linux v1.1.8 (binarysize 3576 bytes
|
i486 Linux v1.1.8 (binarysize 3576 bytes
|
||||||
using `gcc -O6 -s -N` ;)
|
using `gcc -O6 -s -N` ;)
|
||||||
HP 9000/730 HP-UX
|
HP 9000/730 HP-UX
|
||||||
```
|
```
|
||||||
|
|
||||||
Also, many of the X server and X library versions have been tested and the
|
Also, many of the X server and X library versions have been tested and the
|
||||||
@@ -205,7 +205,7 @@ Well, obfuscated or not, some of the effects are very nice ;)
|
|||||||
Mandelbrot set is calculated from the formula
|
Mandelbrot set is calculated from the formula
|
||||||
|
|
||||||
```
|
```
|
||||||
2
|
2
|
||||||
Z = Z + Z
|
Z = Z + Z
|
||||||
n+1 n 0
|
n+1 n 0
|
||||||
```
|
```
|
||||||
@@ -213,7 +213,7 @@ Mandelbrot set is calculated from the formula
|
|||||||
and the Julia set is calculated from the formula
|
and the Julia set is calculated from the formula
|
||||||
|
|
||||||
```
|
```
|
||||||
2
|
2
|
||||||
Z = Z + C
|
Z = Z + C
|
||||||
n+1 n
|
n+1 n
|
||||||
```
|
```
|
||||||
|
|||||||
+6
-6
@@ -97,10 +97,10 @@ Dessert: Chocolate torte
|
|||||||
Antipasti: crudites, olives, roasted red peppers, cheese selection
|
Antipasti: crudites, olives, roasted red peppers, cheese selection
|
||||||
Salad: Mixed greens with vinaigrette
|
Salad: Mixed greens with vinaigrette
|
||||||
Main Course: Spaghetti with tomato sauce containing mushrooms and black olives
|
Main Course: Spaghetti with tomato sauce containing mushrooms and black olives
|
||||||
selection of hot and mild Italian sausages
|
selection of hot and mild Italian sausages
|
||||||
Bread: Fresh French bread
|
Bread: Fresh French bread
|
||||||
Dessert: Cookie selection, featuring chocolate chocolate chip cookies and
|
Dessert: Cookie selection, featuring chocolate chocolate chip cookies and
|
||||||
chocolate butter cookies
|
chocolate butter cookies
|
||||||
|
|
||||||
|
|
||||||
### Session Three
|
### Session Three
|
||||||
@@ -108,7 +108,7 @@ Dessert: Cookie selection, featuring chocolate chocolate chip cookies and
|
|||||||
Antipasti: Crudites, olive selection
|
Antipasti: Crudites, olive selection
|
||||||
Salad: Mixed greens with mustard vinaigrette
|
Salad: Mixed greens with mustard vinaigrette
|
||||||
Main Course: Broiled salmon with lemon pepper mayonnaise, chard, mixture
|
Main Course: Broiled salmon with lemon pepper mayonnaise, chard, mixture
|
||||||
of white and wild rices
|
of white and wild rices
|
||||||
Bread: Cheese bread with herbs
|
Bread: Cheese bread with herbs
|
||||||
Dessert: Chocolate cheesecake (Courtesy of Elizabeth Watson)
|
Dessert: Chocolate cheesecake (Courtesy of Elizabeth Watson)
|
||||||
|
|
||||||
@@ -119,8 +119,8 @@ Antipasti: Crudites, olive selection, roasted red peppers, cheese selection
|
|||||||
Bread: Sourdough
|
Bread: Sourdough
|
||||||
Salad: Mixed spring greens with flowers, and mustard vinaigrette
|
Salad: Mixed spring greens with flowers, and mustard vinaigrette
|
||||||
Main Course: Surf and Turf--Grilled steaks of salmon and New York steak
|
Main Course: Surf and Turf--Grilled steaks of salmon and New York steak
|
||||||
grilled vegetables--onions, peppers, portobello mushrooms
|
grilled vegetables--onions, peppers, portobello mushrooms
|
||||||
wild rice
|
wild rice
|
||||||
Dessert: Chocolate mousse
|
Dessert: Chocolate mousse
|
||||||
|
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ Bread: Focaccia with black olives and mozzarella cheeses
|
|||||||
Salad: Mixed spring greens with flowers and mustard vinaigrette
|
Salad: Mixed spring greens with flowers and mustard vinaigrette
|
||||||
Soup: Homemade butternut squash soup with mushrooms
|
Soup: Homemade butternut squash soup with mushrooms
|
||||||
Main Course: Cracked Dungeness crab with lemon mayonnaise, broccoli,
|
Main Course: Cracked Dungeness crab with lemon mayonnaise, broccoli,
|
||||||
mixture of white and brown rice
|
mixture of white and brown rice
|
||||||
Dessert: Key lime pie
|
Dessert: Key lime pie
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ You might consider giving the following input:
|
|||||||
... a male (who) gets very, very frustrated sitting in a chair all
|
... a male (who) gets very, very frustrated sitting in a chair all
|
||||||
the time because males are biologically driven to go out and hunt
|
the time because males are biologically driven to go out and hunt
|
||||||
giraffes.
|
giraffes.
|
||||||
-- Adjunct Professor Newt Gingrich, Reinhardt College, 1/7/95
|
-- Adjunct Professor Newt Gingrich, Reinhardt College, 1/7/95
|
||||||
```
|
```
|
||||||
|
|
||||||
... which can be done like:
|
... which can be done like:
|
||||||
|
|||||||
+11
-11
@@ -78,7 +78,7 @@ You take a big sheet of "arithmetic" paper and draw a line
|
|||||||
of length 1 (between 2 crossings) at the center of the sheet:
|
of length 1 (between 2 crossings) at the center of the sheet:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This makes 2 open ends (I think the notion of an "open end" doesn't
|
This makes 2 open ends (I think the notion of an "open end" doesn't
|
||||||
@@ -123,15 +123,15 @@ Step 4:
|
|||||||
Step 5:
|
Step 5:
|
||||||
|
|
||||||
```
|
```
|
||||||
._| . |_.
|
._| . |_.
|
||||||
__| \./ \./ |__
|
__| \./ \./ |__
|
||||||
\__| |__/
|
\__| |__/
|
||||||
__./ \./ \.__
|
__./ \./ \.__
|
||||||
__I | I__
|
__I | I__
|
||||||
\__./ \.__/
|
\__./ \.__/
|
||||||
__./ | | \.__
|
__./ | | \.__
|
||||||
|_./ \./ \._|
|
|_./ \./ \._|
|
||||||
| |
|
| |
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -252,7 +252,7 @@ even want to explain what it does. You've been warned!
|
|||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
* * *
|
* * *
|
||||||
```
|
```
|
||||||
|
|
||||||
Special thanks:
|
Special thanks:
|
||||||
|
|||||||
+38
-38
@@ -203,61 +203,61 @@ Below is a description of the OC grammar.
|
|||||||
Terminals are in quotes, `()` is used for bracketing.
|
Terminals are in quotes, `()` is used for bracketing.
|
||||||
|
|
||||||
```
|
```
|
||||||
program: decl*
|
program: decl*
|
||||||
|
|
||||||
decl: vardecl
|
decl: vardecl
|
||||||
fundecl
|
fundecl
|
||||||
|
|
||||||
vardecl: type NAME ;
|
vardecl: type NAME ;
|
||||||
type NAME "[" INT "]" ;
|
type NAME "[" INT "]" ;
|
||||||
|
|
||||||
fundecl: type NAME "(" args ")" "{" body "}"
|
fundecl: type NAME "(" args ")" "{" body "}"
|
||||||
|
|
||||||
args: /*empty*/
|
args: /*empty*/
|
||||||
( arg "," )* arg
|
( arg "," )* arg
|
||||||
|
|
||||||
arg: type NAME
|
arg: type NAME
|
||||||
|
|
||||||
body: vardecl* stmt*
|
body: vardecl* stmt*
|
||||||
|
|
||||||
stmt: ifstmt
|
stmt: ifstmt
|
||||||
whilestmt
|
whilestmt
|
||||||
dowhilestmt
|
dowhilestmt
|
||||||
"return" expr ";"
|
"return" expr ";"
|
||||||
expr ";"
|
expr ";"
|
||||||
"{" stmt* "}"
|
"{" stmt* "}"
|
||||||
";"
|
";"
|
||||||
|
|
||||||
ifstmt: "if" "(" expr ")" stmt
|
ifstmt: "if" "(" expr ")" stmt
|
||||||
"if" "(" expr ")" stmt "else" stmt
|
"if" "(" expr ")" stmt "else" stmt
|
||||||
|
|
||||||
whilestmt: "while" "(" expr ")" stmt
|
whilestmt: "while" "(" expr ")" stmt
|
||||||
|
|
||||||
dowhilestmt:"do" stmt "while" "(" expr ")" ";"
|
dowhilestmt:"do" stmt "while" "(" expr ")" ";"
|
||||||
|
|
||||||
expr: expr binop expr
|
expr: expr binop expr
|
||||||
unop expr
|
unop expr
|
||||||
expr "[" expr "]"
|
expr "[" expr "]"
|
||||||
"(" expr ")"
|
"(" expr ")"
|
||||||
expr "(" exprs ")"
|
expr "(" exprs ")"
|
||||||
NAME
|
NAME
|
||||||
INT
|
INT
|
||||||
CHAR
|
CHAR
|
||||||
STRING
|
STRING
|
||||||
|
|
||||||
exprs: /*empty*/
|
exprs: /*empty*/
|
||||||
(expr ",")* expr
|
(expr ",")* expr
|
||||||
|
|
||||||
binop: "+" | "-" | "*" | "/" | "%" |
|
binop: "+" | "-" | "*" | "/" | "%" |
|
||||||
"=" |
|
"=" |
|
||||||
"<" | "==" | "!="
|
"<" | "==" | "!="
|
||||||
|
|
||||||
unop: "!" | "-" | "*"
|
unop: "!" | "-" | "*"
|
||||||
|
|
||||||
type: "int" stars
|
type: "int" stars
|
||||||
"char" stars
|
"char" stars
|
||||||
|
|
||||||
stars: "*"*
|
stars: "*"*
|
||||||
```
|
```
|
||||||
|
|
||||||
<hr style="width:10%;text-align:left;margin-left:0">
|
<hr style="width:10%;text-align:left;margin-left:0">
|
||||||
|
|||||||
@@ -104,16 +104,16 @@ A CGI script such as:
|
|||||||
${ECHO} "Content-type: text/html"
|
${ECHO} "Content-type: text/html"
|
||||||
${ECHO}
|
${ECHO}
|
||||||
if [ -z "${QUERY_STRING}" ]; then
|
if [ -z "${QUERY_STRING}" ]; then
|
||||||
${ECHO} "QUERY_STRING not found"
|
${ECHO} "QUERY_STRING not found"
|
||||||
else
|
else
|
||||||
URL=`${EXPR} "$QUERY_STRING" : '[Uu][Rr][Ll]=\(.*\)'`
|
URL=`${EXPR} "$QUERY_STRING" : '[Uu][Rr][Ll]=\(.*\)'`
|
||||||
if [ -z "${URL}" ]; then
|
if [ -z "${URL}" ]; then
|
||||||
${ECHO} "No URL given in QUERY_STRING"
|
${ECHO} "No URL given in QUERY_STRING"
|
||||||
elif [ X`${EXPR} "${URL}" : '[Ff][Ii][Ll][Ee]:'` != X0 ]; then
|
elif [ X`${EXPR} "${URL}" : '[Ff][Ii][Ll][Ee]:'` != X0 ]; then
|
||||||
${ECHO} "file: based URLs are not allowed"
|
${ECHO} "file: based URLs are not allowed"
|
||||||
else
|
else
|
||||||
${LYNX} -restrictions=all -source "${URL}" | ${POOT}
|
${LYNX} -restrictions=all -source "${URL}" | ${POOT}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
+21
-21
@@ -45,8 +45,8 @@ counter before shifting out each symbol, such as
|
|||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
length = (encoding & 96) >> 5;
|
length = (encoding & 96) >> 5;
|
||||||
do {
|
do {
|
||||||
putchar(encoding & 1 ? '-' : '.');
|
putchar(encoding & 1 ? '-' : '.');
|
||||||
encoding >>= 1;
|
encoding >>= 1;
|
||||||
} while (length--);
|
} while (length--);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -64,8 +64,8 @@ with 1 bit still to be chosen freely (let's assume it is 0). Now we can do
|
|||||||
|
|
||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
do {
|
do {
|
||||||
putchar(encoding & 1 ? '-' : '.');
|
putchar(encoding & 1 ? '-' : '.');
|
||||||
encoding >>= 1;
|
encoding >>= 1;
|
||||||
while (encoding > 1);
|
while (encoding > 1);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -89,8 +89,8 @@ is encoded still allows the encoding to be its own counter:
|
|||||||
|
|
||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
do {
|
do {
|
||||||
putchar(encoding & 1 ? '-' : '.');
|
putchar(encoding & 1 ? '-' : '.');
|
||||||
encoding = (encoding + 32) >> 1;
|
encoding = (encoding + 32) >> 1;
|
||||||
} while (encoding > 35);
|
} while (encoding > 35);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -145,21 +145,21 @@ The outline of the program is roughly as follows
|
|||||||
|
|
||||||
```
|
```
|
||||||
while (more lines) {
|
while (more lines) {
|
||||||
if (line is in morse) {
|
if (line is in morse) {
|
||||||
while (more characters) {
|
while (more characters) {
|
||||||
skip next sequence
|
skip next sequence
|
||||||
if (' ')
|
if (' ')
|
||||||
putchar(' ');
|
putchar(' ');
|
||||||
else
|
else
|
||||||
decode_sequence; /* backwards */
|
decode_sequence; /* backwards */
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (more characters) {
|
while (more characters) {
|
||||||
if (isalnum)
|
if (isalnum)
|
||||||
encode_character;
|
encode_character;
|
||||||
putchar(' ');
|
putchar(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Because of the *two* `while(more characters)` loops are the same, I've
|
Because of the *two* `while(more characters)` loops are the same, I've
|
||||||
|
|||||||
+39
-39
@@ -92,10 +92,10 @@ has the value `a`. Another function called `K` is defined as `\x\y(x)`
|
|||||||
and it evaluates as follows:
|
and it evaluates as follows:
|
||||||
|
|
||||||
```
|
```
|
||||||
K p q
|
K p q
|
||||||
-> \x\y(x) p q
|
-> \x\y(x) p q
|
||||||
-> \y(p) q
|
-> \y(p) q
|
||||||
-> p
|
-> p
|
||||||
```
|
```
|
||||||
|
|
||||||
Another function of interest is `S`, defined as `\f\g\x((f x) (g x))`.
|
Another function of interest is `S`, defined as `\f\g\x((f x) (g x))`.
|
||||||
@@ -106,15 +106,15 @@ variables or lambda abstractions. In fact, even `I` is unnecessary,
|
|||||||
since it is equivalent to `S K K`:
|
since it is equivalent to `S K K`:
|
||||||
|
|
||||||
```
|
```
|
||||||
I z
|
I z
|
||||||
-> \a(a) z
|
-> \a(a) z
|
||||||
-> z
|
-> z
|
||||||
|
|
||||||
S K K z
|
S K K z
|
||||||
-> \f\g\x((f x) (g x)) K K z
|
-> \f\g\x((f x) (g x)) K K z
|
||||||
-> (K z) (K z)
|
-> (K z) (K z)
|
||||||
-> \x\y(x) z (K z)
|
-> \x\y(x) z (K z)
|
||||||
-> z
|
-> z
|
||||||
```
|
```
|
||||||
|
|
||||||
The algorithm for translating lambda expressions into combinator
|
The algorithm for translating lambda expressions into combinator
|
||||||
@@ -122,9 +122,9 @@ expressions works as follows. There are three forms of lambda expression
|
|||||||
to consider: variables, applications, and abstractions.
|
to consider: variables, applications, and abstractions.
|
||||||
|
|
||||||
```
|
```
|
||||||
trans v -> v (variable)
|
trans v -> v (variable)
|
||||||
trans a b -> (trans a) (trans b ) (application)
|
trans a b -> (trans a) (trans b ) (application)
|
||||||
trans \ab -> abs a (trans b) (abstraction)
|
trans \ab -> abs a (trans b) (abstraction)
|
||||||
```
|
```
|
||||||
|
|
||||||
There are a further three cases to consider for the body of lambda
|
There are a further three cases to consider for the body of lambda
|
||||||
@@ -132,33 +132,33 @@ expressions, where we need to do the magic that transforms away the
|
|||||||
variables.
|
variables.
|
||||||
|
|
||||||
```
|
```
|
||||||
abs a f x -> S (abs a f) (abs a x)
|
abs a f x -> S (abs a f) (abs a x)
|
||||||
abs a b -> K b (b != a)
|
abs a b -> K b (b != a)
|
||||||
abs a a -> I
|
abs a a -> I
|
||||||
```
|
```
|
||||||
|
|
||||||
E.g. suppose we had combinator expressions for `+` and `3` and we wanted
|
E.g. suppose we had combinator expressions for `+` and `3` and we wanted
|
||||||
to see what the combinator expression for doubling 3 looked like:
|
to see what the combinator expression for doubling 3 looked like:
|
||||||
|
|
||||||
```
|
```
|
||||||
trans \x(+ x x) 3
|
trans \x(+ x x) 3
|
||||||
-> (trans \x(+ x x)) (trans 3)
|
-> (trans \x(+ x x)) (trans 3)
|
||||||
-> (abs x (trans + x x)) 3
|
-> (abs x (trans + x x)) 3
|
||||||
-> (abs x + x x) 3
|
-> (abs x + x x) 3
|
||||||
-> S (abs x + x) (abs x x) 3
|
-> S (abs x + x) (abs x x) 3
|
||||||
-> S (S (abs x +) (abs x x)) I 3
|
-> S (S (abs x +) (abs x x)) I 3
|
||||||
-> S (S (K +) I) I 3
|
-> S (S (K +) I) I 3
|
||||||
-> S (S (K +) I) I 3
|
-> S (S (K +) I) I 3
|
||||||
```
|
```
|
||||||
|
|
||||||
We can then check that this evaluates to the expected result:
|
We can then check that this evaluates to the expected result:
|
||||||
|
|
||||||
```
|
```
|
||||||
S (S (K +) I) I 3
|
S (S (K +) I) I 3
|
||||||
-> S (K +) I 3 (I 3)
|
-> S (K +) I 3 (I 3)
|
||||||
-> K + 3 (I 3) (I 3)
|
-> K + 3 (I 3) (I 3)
|
||||||
-> + (I 3) (I 3)
|
-> + (I 3) (I 3)
|
||||||
-> + 3 3
|
-> + 3 3
|
||||||
```
|
```
|
||||||
|
|
||||||
It is possible to perform a slightly more compact translation with a
|
It is possible to perform a slightly more compact translation with a
|
||||||
@@ -166,24 +166,24 @@ couple of simple optimisations. For example, note that `K (a b)` is the
|
|||||||
same as `S (K a) (K b)`, because
|
same as `S (K a) (K b)`, because
|
||||||
|
|
||||||
```
|
```
|
||||||
K (a b) x
|
K (a b) x
|
||||||
-> a b
|
-> a b
|
||||||
```
|
```
|
||||||
|
|
||||||
and
|
and
|
||||||
|
|
||||||
```
|
```
|
||||||
S (K a) (K b) x
|
S (K a) (K b) x
|
||||||
-> K a x (K b x)
|
-> K a x (K b x)
|
||||||
-> a b
|
-> a b
|
||||||
```
|
```
|
||||||
|
|
||||||
Also, `S (K a) I` is the same as just `a` because
|
Also, `S (K a) I` is the same as just `a` because
|
||||||
|
|
||||||
```
|
```
|
||||||
S (K a) I x
|
S (K a) I x
|
||||||
-> K a x (I x)
|
-> K a x (I x)
|
||||||
-> a x
|
-> a x
|
||||||
```
|
```
|
||||||
|
|
||||||
The program simply reads a lambda expression from the standard input,
|
The program simply reads a lambda expression from the standard input,
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ Shortly below that you will see, as noted above, the numbers:
|
|||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
if ((H = fopen (__FILE__+43, 43+__FILE__)))
|
if ((H = fopen (__FILE__+43, 43+__FILE__)))
|
||||||
while ((fgets (L, (int)sizeof L, H)) != 0) {
|
while ((fgets (L, (int)sizeof L, H)) != 0) {
|
||||||
I[strcspn (I, 45+__FILE__)] = O = 0;
|
I[strcspn (I, 45+__FILE__)] = O = 0;
|
||||||
```
|
```
|
||||||
|
|
||||||
The first number in the above C means the length starting from 0 up through the
|
The first number in the above C means the length starting from 0 up through the
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ often produced an error of the form:
|
|||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
gcc -ansi schweikh2.alt.c -o schweikh2.alt
|
gcc -ansi schweikh2.alt.c -o schweikh2.alt
|
||||||
as: Error: cca00NzV.s, line 58: Missing " at end of string
|
as: Error: cca00NzV.s, line 58: Missing " at end of string
|
||||||
"
|
"
|
||||||
as: Error: cca00NzV.s, line 58: malformed statement
|
as: Error: cca00NzV.s, line 58: malformed statement
|
||||||
*** Error code 1 (bu21)
|
*** Error code 1 (bu21)
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -113,14 +113,14 @@ following meanings:
|
|||||||
A = argv
|
A = argv
|
||||||
|
|
||||||
b = array of unsigned long variables
|
b = array of unsigned long variables
|
||||||
b[0] = bit-width of the CRC (argv[2])
|
b[0] = bit-width of the CRC (argv[2])
|
||||||
b[1] = CRC polynomial (argv[3])
|
b[1] = CRC polynomial (argv[3])
|
||||||
b[2] = nonzero if CRC is reflected (argv[4])
|
b[2] = nonzero if CRC is reflected (argv[4])
|
||||||
b[3] = initial value of CRC (argv[5])
|
b[3] = initial value of CRC (argv[5])
|
||||||
b[4] = value final CRC is XORed with (argv[6])
|
b[4] = value final CRC is XORed with (argv[6])
|
||||||
b[5] = CRC value
|
b[5] = CRC value
|
||||||
b[6] = byte from file
|
b[6] = byte from file
|
||||||
b[7] = counter
|
b[7] = counter
|
||||||
|
|
||||||
B = FILE * through which the file argv[1] is opened
|
B = FILE * through which the file argv[1] is opened
|
||||||
|
|
||||||
|
|||||||
@@ -53,13 +53,13 @@ characters (semaphore smileys, if you will). For example, given the
|
|||||||
input "Hello, world!", the output will be:
|
input "Hello, world!", the output will be:
|
||||||
|
|
||||||
```
|
```
|
||||||
<> <> <> <> <> <>
|
<> <> <> <> <> <>
|
||||||
_() ()/ ()/ ()/ _\) () (/_ _\)
|
_() ()/ ()/ ()/ _\) () (/_ _\)
|
||||||
[] /^ |^^ /^^ /^^ [] ^^ |^^| ^^ [] [] ^^
|
[] /^ |^^ /^^ /^^ [] ^^ |^^| ^^ [] [] ^^
|
||||||
<>[ [][ <>][ <>][ ][ [][] ][ ][
|
<>[ [][ <>][ <>][ ][ [][] ][ ][
|
||||||
|
|
||||||
|
|
||||||
<> []
|
<> []
|
||||||
_()_ ()/ |() ()
|
_()_ ()/ |() ()
|
||||||
[] ^^ [] /^^ ^^| |^^|
|
[] ^^ [] /^^ ^^| |^^|
|
||||||
][ <>][ ][] [][]
|
][ <>][ ][] [][]
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ The author recommended on linux/x86, glibc 2.0, libc4/5:
|
|||||||
|
|
||||||
``` <!---make-->
|
``` <!---make-->
|
||||||
bmeyer: bmeyer.c
|
bmeyer: bmeyer.c
|
||||||
CC -DY="__setfpucw(0x127f)" -O6 $? -o $@ -lm
|
CC -DY="__setfpucw(0x127f)" -O6 $? -o $@ -lm
|
||||||
```
|
```
|
||||||
|
|
||||||
However many compilers use `-O3` as the maximum level for `-O` optimization.
|
However many compilers use `-O3` as the maximum level for `-O` optimization.
|
||||||
@@ -42,7 +42,7 @@ And on linux/x86, glibc 2.1:
|
|||||||
|
|
||||||
``` <!---make-->
|
``` <!---make-->
|
||||||
bmeyer: bmeyer.c
|
bmeyer: bmeyer.c
|
||||||
gcc -DY='int x=0x127f; __asm__ ("fldcw %0" : : "m" (*&x))' $? -o $@ -lm
|
gcc -DY='int x=0x127f; __asm__ ("fldcw %0" : : "m" (*&x))' $? -o $@ -lm
|
||||||
```
|
```
|
||||||
|
|
||||||
Compile with the maximum possible optimization on your system.
|
Compile with the maximum possible optimization on your system.
|
||||||
|
|||||||
+12
-12
@@ -76,9 +76,9 @@ This program understands the following `dc(1)` commands:
|
|||||||
```
|
```
|
||||||
p prints the top stack value without altering the stack.
|
p prints the top stack value without altering the stack.
|
||||||
P prints the top stack value, removing it from the stack, and
|
P prints the top stack value, removing it from the stack, and
|
||||||
doesn't print a trailing newline.
|
doesn't print a trailing newline.
|
||||||
f prints the contents of the stack, one number per line,
|
f prints the contents of the stack, one number per line,
|
||||||
without modifying it.
|
without modifying it.
|
||||||
c clears the stack.
|
c clears the stack.
|
||||||
d pushes a copy of the top stack value onto the stack.
|
d pushes a copy of the top stack value onto the stack.
|
||||||
r reverses the order of the top two stack values.
|
r reverses the order of the top two stack values.
|
||||||
@@ -89,14 +89,14 @@ And the following arithmetic operators are supported:
|
|||||||
```
|
```
|
||||||
+ Pops 2 values and pushes their sum.
|
+ Pops 2 values and pushes their sum.
|
||||||
- Pops 2 values and pushes the result of subtracting the first
|
- Pops 2 values and pushes the result of subtracting the first
|
||||||
from the second.
|
from the second.
|
||||||
* Pops 2 values and pushes their product.
|
* Pops 2 values and pushes their product.
|
||||||
/ Pops 2 values and pushes the result of dividing the second
|
/ Pops 2 values and pushes the result of dividing the second
|
||||||
by the first.
|
by the first.
|
||||||
^ Pops 2 values and pushes the result of raising the second
|
^ Pops 2 values and pushes the result of raising the second
|
||||||
to the power of the first.
|
to the power of the first.
|
||||||
% Pops 2 values and pushes the remainder of the division that
|
% Pops 2 values and pushes the remainder of the division that
|
||||||
/ would do.
|
/ would do.
|
||||||
```
|
```
|
||||||
|
|
||||||
The precision and range are double, like it or not, except that the
|
The precision and range are double, like it or not, except that the
|
||||||
@@ -113,14 +113,14 @@ or EOF is encountered.
|
|||||||
### Diagnostics:
|
### Diagnostics:
|
||||||
|
|
||||||
```
|
```
|
||||||
"stack empty" Not enough on the stack for the requested command
|
"stack empty" Not enough on the stack for the requested command
|
||||||
"divide by zero" Attempt to divide by zero
|
"divide by zero" Attempt to divide by zero
|
||||||
"unimplemented" Invalid input
|
"unimplemented" Invalid input
|
||||||
|
|
||||||
Floating point exception (core dumped) (or something to that effect)
|
Floating point exception (core dumped) (or something to that effect)
|
||||||
Bug in Perl_sv_upgrade causes this in some cases when
|
Bug in Perl_sv_upgrade causes this in some cases when
|
||||||
the results of an operation are really huge (> 10^308)
|
the results of an operation are really huge (> 10^308)
|
||||||
This bug appears to be fixed in perl5.6.0
|
This bug appears to be fixed in perl5.6.0
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -115,13 +115,13 @@ from inside the monitor whilst standing on your head. In case of
|
|||||||
confusion, please consult the following chart (\*):
|
confusion, please consult the following chart (\*):
|
||||||
|
|
||||||
```
|
```
|
||||||
N
|
N
|
||||||
^
|
^
|
||||||
|
|
|
|
||||||
E <---+---> W
|
E <---+---> W
|
||||||
|
|
|
|
||||||
v
|
v
|
||||||
S
|
S
|
||||||
```
|
```
|
||||||
|
|
||||||
(\*) Not to scale.
|
(\*) Not to scale.
|
||||||
@@ -316,7 +316,7 @@ common tricks. Taken through the standard rounds listed in the
|
|||||||
`select()`, the following may suffice as an additional compiler argument:
|
`select()`, the following may suffice as an additional compiler argument:
|
||||||
|
|
||||||
```
|
```
|
||||||
-Dusleep={time_t v[2]={0,10000};select(0,0,0,0,v);}
|
-Dusleep={time_t v[2]={0,10000};select(0,0,0,0,v);}
|
||||||
```
|
```
|
||||||
|
|
||||||
`gcc` complains about "unreachable code at beginning of switch
|
`gcc` complains about "unreachable code at beginning of switch
|
||||||
|
|||||||
+33
-33
@@ -120,9 +120,9 @@ I claim, by letters patently absurd:
|
|||||||
operations.
|
operations.
|
||||||
|
|
||||||
6. The method of claim 1, further comprising a method where
|
6. The method of claim 1, further comprising a method where
|
||||||
* strings are encrypted in a manner suitable as C strings, and
|
* strings are encrypted in a manner suitable as C strings, and
|
||||||
* 7-bit ASCII characters with uniform distribution are maximally packed
|
* 7-bit ASCII characters with uniform distribution are maximally packed
|
||||||
subject to the restriction that each byte is not countable
|
subject to the restriction that each byte is not countable
|
||||||
|
|
||||||
7. A method for a computer-based system that uses a single shared code
|
7. A method for a computer-based system that uses a single shared code
|
||||||
sequence to either sum a plurality of bits in an N-bit word or reverses
|
sequence to either sum a plurality of bits in an N-bit word or reverses
|
||||||
@@ -134,46 +134,46 @@ I claim, by letters patently absurd:
|
|||||||
#### FIG 1.
|
#### FIG 1.
|
||||||
|
|
||||||
```
|
```
|
||||||
+--+--+--+--+--+--+--+--+
|
+--+--+--+--+--+--+--+--+
|
||||||
|32| |31| |30| |29| |
|
|32| |31| |30| |29| |
|
||||||
+--+--+--+--+--+--+--+--+
|
+--+--+--+--+--+--+--+--+
|
||||||
| |28| |27| |26| |25|
|
| |28| |27| |26| |25|
|
||||||
+--+--+--+--+--+--+--+--+
|
+--+--+--+--+--+--+--+--+
|
||||||
|24| |23| |22| |21| |
|
|24| |23| |22| |21| |
|
||||||
+--+--+--+--+--+--+--+--+
|
+--+--+--+--+--+--+--+--+
|
||||||
| |20| |19| |18| |17|
|
| |20| |19| |18| |17|
|
||||||
+--+--+--+--+--+--+--+--+
|
+--+--+--+--+--+--+--+--+
|
||||||
|16| |15| |14| |13| |
|
|16| |15| |14| |13| |
|
||||||
+--+--+--+--+--+--+--+--+
|
+--+--+--+--+--+--+--+--+
|
||||||
| |12| |11| |10| | 9|
|
| |12| |11| |10| | 9|
|
||||||
+--+--+--+--+--+--+--+--+
|
+--+--+--+--+--+--+--+--+
|
||||||
| 8| | 7| | 6| | 5| |
|
| 8| | 7| | 6| | 5| |
|
||||||
+--+--+--+--+--+--+--+--+
|
+--+--+--+--+--+--+--+--+
|
||||||
| | 4| | 3| | 2| | 1|
|
| | 4| | 3| | 2| | 1|
|
||||||
+--+--+--+--+--+--+--+--+
|
+--+--+--+--+--+--+--+--+
|
||||||
```
|
```
|
||||||
|
|
||||||
#### FIG. 2.
|
#### FIG. 2.
|
||||||
|
|
||||||
```
|
```
|
||||||
1 0
|
1 0
|
||||||
\ /
|
\ /
|
||||||
.
|
.
|
||||||
/ \
|
/ \
|
||||||
3 2
|
3 2
|
||||||
```
|
```
|
||||||
|
|
||||||
#### FIG. 3.
|
#### FIG. 3.
|
||||||
|
|
||||||
```
|
```
|
||||||
o o X . 29
|
o o X . 29
|
||||||
o . . . 25
|
o . . . 25
|
||||||
o . . o 21
|
o . . o 21
|
||||||
. o . o 17
|
. o . o 17
|
||||||
x . . . 13
|
x . . . 13
|
||||||
. . x . 9
|
. . x . 9
|
||||||
x x . . 5
|
x x . . 5
|
||||||
x x O x 1
|
x x O x 1
|
||||||
```
|
```
|
||||||
|
|
||||||
#### FIG. 4
|
#### FIG. 4
|
||||||
|
|||||||
@@ -113,9 +113,9 @@ type `./herrmann1` to see the final result. The output will be
|
|||||||
Final tape:
|
Final tape:
|
||||||
|
|
||||||
```
|
```
|
||||||
*
|
*
|
||||||
..OOIIIIIIIIIIIIIIIIOOOO..
|
..OOIIIIIIIIIIIIIIIIOOOO..
|
||||||
*
|
*
|
||||||
```
|
```
|
||||||
|
|
||||||
(Note that the last frame of the animation is _not_ the final
|
(Note that the last frame of the animation is _not_ the final
|
||||||
@@ -217,9 +217,9 @@ Undefined state start.
|
|||||||
Tape:
|
Tape:
|
||||||
|
|
||||||
```
|
```
|
||||||
*
|
*
|
||||||
..OOOOOOOOIIIIOO..
|
..OOOOOOOOIIIIOO..
|
||||||
*
|
*
|
||||||
```
|
```
|
||||||
|
|
||||||
and the return code will be 1. As you can see, the Turing machine
|
and the return code will be 1. As you can see, the Turing machine
|
||||||
@@ -320,8 +320,8 @@ to use many variables more than once.
|
|||||||
|
|
||||||
- I couldn't refrain from doing a little bit of nasty stuff like
|
- I couldn't refrain from doing a little bit of nasty stuff like
|
||||||
|
|
||||||
#define a 0&0
|
#define a 0&0
|
||||||
#if !a
|
#if !a
|
||||||
|
|
||||||
Of course, it is a bit more subtle, and even useful.
|
Of course, it is a bit more subtle, and even useful.
|
||||||
|
|
||||||
@@ -363,15 +363,15 @@ the insertion of `#line` directives. If your compiler doesn't
|
|||||||
support this option (and does insert `#line` directives), you
|
support this option (and does insert `#line` directives), you
|
||||||
should change the call to `sed` to remove them, too: Add
|
should change the call to `sed` to remove them, too: Add
|
||||||
|
|
||||||
-e "/^#line/ d"
|
-e "/^#line/ d"
|
||||||
|
|
||||||
to the sed parameters. Or, if your `#line` directives look like
|
to the sed parameters. Or, if your `#line` directives look like
|
||||||
|
|
||||||
# 15 "filename"
|
# 15 "filename"
|
||||||
|
|
||||||
add
|
add
|
||||||
|
|
||||||
-e "/^# [0-9]/ d"
|
-e "/^# [0-9]/ d"
|
||||||
|
|
||||||
instead.
|
instead.
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -33,9 +33,9 @@ NOTE: each player's paddle is at the bottom and the opponent at the top.
|
|||||||
## Try:
|
## Try:
|
||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
./kev # in one terminal
|
./kev # in one terminal
|
||||||
|
|
||||||
./kev localhost # in another terminal on the same host
|
./kev localhost # in another terminal on the same host
|
||||||
```
|
```
|
||||||
|
|
||||||
If you need to change the speed you can reconfigure it like (say
|
If you need to change the speed you can reconfigure it like (say
|
||||||
|
|||||||
@@ -78,12 +78,12 @@ A: Yes, there are types of entries that show up over and over again.
|
|||||||
|
|
||||||
generating small primes (below is the list of all prime related entries)
|
generating small primes (below is the list of all prime related entries)
|
||||||
|
|
||||||
1985/august
|
1985/august
|
||||||
1988/applin
|
1988/applin
|
||||||
1994/weisberg
|
1994/weisberg
|
||||||
1995/makarios
|
1995/makarios
|
||||||
1996/dalbec
|
1996/dalbec
|
||||||
2000/bellard
|
2000/bellard
|
||||||
|
|
||||||
As you can see, just a list of primes (let alone small primes)
|
As you can see, just a list of primes (let alone small primes)
|
||||||
does not cut it anymore.
|
does not cut it anymore.
|
||||||
@@ -92,8 +92,8 @@ A: Yes, there are types of entries that show up over and over again.
|
|||||||
|
|
||||||
entries that use some complex state machine/table to print something
|
entries that use some complex state machine/table to print something
|
||||||
|
|
||||||
1988/isaak
|
1988/isaak
|
||||||
1988/phillipps
|
1988/phillipps
|
||||||
|
|
||||||
Unbeaten for 12 years and counting...
|
Unbeaten for 12 years and counting...
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ You can use it for your shell scripting needs similar to a silent grep
|
|||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
if prog "${VARIABLE}" '<glob>'; then
|
if prog "${VARIABLE}" '<glob>'; then
|
||||||
echo VARIABLE matches
|
echo VARIABLE matches
|
||||||
else
|
else
|
||||||
echo no match
|
echo no match
|
||||||
fi
|
fi
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ the file `ring.pgm`:
|
|||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
./anonymous "ash nazg durhbatuluhk, ash nazg gimbatul, \
|
./anonymous "ash nazg durhbatuluhk, ash nazg gimbatul, \
|
||||||
ash nazg thrakatuluhk, agh burzhumh-ishi krimpatul." >ring.pgm
|
ash nazg thrakatuluhk, agh burzhumh-ishi krimpatul." >ring.pgm
|
||||||
```
|
```
|
||||||
|
|
||||||
The source code assumes the ASCII character set; also, due to space
|
The source code assumes the ASCII character set; also, due to space
|
||||||
|
|||||||
@@ -25,15 +25,15 @@ start with $100. Input alternates between your bet and which cards to keep.
|
|||||||
Example:
|
Example:
|
||||||
|
|
||||||
```
|
```
|
||||||
5 <== you enter a bet of $5 (defaults to $1)
|
5 <== you enter a bet of $5 (defaults to $1)
|
||||||
J Q J 9 5 <== your hand is Jack of Clubs, Queen of Hearts,
|
J Q J 9 5 <== your hand is Jack of Clubs, Queen of Hearts,
|
||||||
C H D S C Jack of Diamonds, 9 of Spades, 5 of Clubs
|
C H D S C Jack of Diamonds, 9 of Spades, 5 of Clubs
|
||||||
123 <== you enter which cards you want to keep
|
123 <== you enter which cards you want to keep
|
||||||
(enter 0 to 5 digits between 1 and 5)
|
(enter 0 to 5 digits between 1 and 5)
|
||||||
J Q J J Q <== your new hand is Jack of Clubs, Queen of Hearts,
|
J Q J J Q <== your new hand is Jack of Clubs, Queen of Hearts,
|
||||||
C H D S C Jack of Diamonds, Jack of Spaces, Queen of clubs
|
C H D S C Jack of Diamonds, Jack of Spaces, Queen of clubs
|
||||||
$145 (45) <== Your new balance is now $145. You had a Full House
|
$145 (45) <== Your new balance is now $145. You had a Full House
|
||||||
so your payoff is 9 times your bet == 45
|
so your payoff is 9 times your bet == 45
|
||||||
```
|
```
|
||||||
|
|
||||||
The payout is according to "Vegas rules":
|
The payout is according to "Vegas rules":
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ To stop the server:
|
|||||||
|
|
||||||
* Supports multiple `index.*` file extensions and types:
|
* Supports multiple `index.*` file extensions and types:
|
||||||
|
|
||||||
index.htm, index.html, index.php, index.pl, index.sh, index.rb, index.py
|
index.htm, index.html, index.php, index.pl, index.sh, index.rb, index.py
|
||||||
|
|
||||||
* Supports subset of [RFC 2616](https://datatracker.ietf.org/doc/html/rfc2616)
|
* Supports subset of [RFC 2616](https://datatracker.ietf.org/doc/html/rfc2616)
|
||||||
[HTTP/1.1](https://en.wikipedia.org/wiki/HTTP) methods: `GET`, `HEAD`, and
|
[HTTP/1.1](https://en.wikipedia.org/wiki/HTTP) methods: `GET`, `HEAD`, and
|
||||||
|
|||||||
+11
-11
@@ -124,38 +124,38 @@ numbers from 8 to 11.
|
|||||||
characteristics](https://en.wikipedia.org/wiki/Euler_characteristic) is the number of "vertexes"
|
characteristics](https://en.wikipedia.org/wiki/Euler_characteristic) is the number of "vertexes"
|
||||||
|
|
||||||
```
|
```
|
||||||
#
|
#
|
||||||
```
|
```
|
||||||
|
|
||||||
minus the number of "edges"
|
minus the number of "edges"
|
||||||
|
|
||||||
```
|
```
|
||||||
## # #. .#
|
## # #. .#
|
||||||
# .# #. ('.' must be empty)
|
# .# #. ('.' must be empty)
|
||||||
```
|
```
|
||||||
|
|
||||||
plus the number of "faces"
|
plus the number of "faces"
|
||||||
|
|
||||||
```
|
```
|
||||||
##
|
##
|
||||||
##
|
##
|
||||||
```
|
```
|
||||||
|
|
||||||
3. If we fill all these patterns to 2x2 squares,
|
3. If we fill all these patterns to 2x2 squares,
|
||||||
|
|
||||||
```
|
```
|
||||||
#? ## #? #. .# ##
|
#? ## #? #. .# ##
|
||||||
?? ?? #? .# #. ##
|
?? ?? #? .# #. ##
|
||||||
+1 -1 -1 -1 -1 +1
|
+1 -1 -1 -1 -1 +1
|
||||||
```
|
```
|
||||||
|
|
||||||
substitute all possible "values" of `?` and sum them up, we get that it is
|
substitute all possible "values" of `?` and sum them up, we get that it is
|
||||||
enough to calculate:
|
enough to calculate:
|
||||||
|
|
||||||
```
|
```
|
||||||
#. .# ##
|
#. .# ##
|
||||||
.. #. #.
|
.. #. #.
|
||||||
+1 -1 -1
|
+1 -1 -1
|
||||||
```
|
```
|
||||||
|
|
||||||
Note now it is simple and obfuscated enough to be used as
|
Note now it is simple and obfuscated enough to be used as
|
||||||
|
|||||||
+11
-11
@@ -62,21 +62,21 @@ The ALU has six instructions:
|
|||||||
- `CLR_Y` - Clear [register](https://en.wikipedia.org/wiki/Processor_register) `Y`.
|
- `CLR_Y` - Clear [register](https://en.wikipedia.org/wiki/Processor_register) `Y`.
|
||||||
|
|
||||||
- `ADD` - Calculates `X` + `Y` and stores the result in `X`. If the result
|
- `ADD` - Calculates `X` + `Y` and stores the result in `X`. If the result
|
||||||
is larger than 11 bits, the [CARRY
|
is larger than 11 bits, the [CARRY
|
||||||
bit](https://en.wikipedia.org/wiki/Carry_flag) in `SR` is set otherwise
|
bit](https://en.wikipedia.org/wiki/Carry_flag) in `SR` is set otherwise
|
||||||
the `CARRY` bit is cleared.
|
the `CARRY` bit is cleared.
|
||||||
|
|
||||||
- `SUB` - Calculates `X` - `Y` and stores the result in `X`. If `Y` was larger
|
- `SUB` - Calculates `X` - `Y` and stores the result in `X`. If `Y` was larger
|
||||||
than `X`, the [CARRY bit](https://en.wikipedia.org/wiki/Carry_flag)
|
than `X`, the [CARRY bit](https://en.wikipedia.org/wiki/Carry_flag)
|
||||||
in `SR` is set otherwise the `CARRY` bit is cleared.
|
in `SR` is set otherwise the `CARRY` bit is cleared.
|
||||||
|
|
||||||
- `TST` - If `X` == `Y` the `EQ` bit in `SR` is set, otherwise the `EQ` bit is
|
- `TST` - If `X` == `Y` the `EQ` bit in `SR` is set, otherwise the `EQ` bit is
|
||||||
cleared. If `X` < `Y` the `LT` bit in `SR` is set, otherwise the `LT`
|
cleared. If `X` < `Y` the `LT` bit in `SR` is set, otherwise the `LT`
|
||||||
bit is cleared.
|
bit is cleared.
|
||||||
|
|
||||||
- `INC2` - Calculates `X` + 2 and stores the result in `X`. The [CARRY
|
- `INC2` - Calculates `X` + 2 and stores the result in `X`. The [CARRY
|
||||||
bit](https://en.wikipedia.org/wiki/Carry_flag) is handled as in the
|
bit](https://en.wikipedia.org/wiki/Carry_flag) is handled as in the
|
||||||
`ADD` instruction.
|
`ADD` instruction.
|
||||||
|
|
||||||
Internally the [ALU](https://en.wikipedia.org/wiki/Arithmetic_logic_unit)
|
Internally the [ALU](https://en.wikipedia.org/wiki/Arithmetic_logic_unit)
|
||||||
implements a one bit adder with a carry in and carry out. This adder is the core
|
implements a one bit adder with a carry in and carry out. This adder is the core
|
||||||
@@ -209,7 +209,7 @@ taken to pre-process the program were measured using GNU `cpp` on my 2.0MHz P4
|
|||||||
with 512Mb ram and a lot of disk.
|
with 512Mb ram and a lot of disk.
|
||||||
|
|
||||||
```
|
```
|
||||||
Generated Recursive Max nest Intermediate
|
Generated Recursive Max nest Intermediate
|
||||||
Level prime nrs includes count file size Time
|
Level prime nrs includes count file size Time
|
||||||
|
|
||||||
_3 < 8 2 322 9 74 748 4"
|
_3 < 8 2 322 9 74 748 4"
|
||||||
@@ -221,7 +221,7 @@ with 512Mb ram and a lot of disk.
|
|||||||
_9 < 512 1 920 272 38 65 527 808(*) 1h 42'19"(*)
|
_9 < 512 1 920 272 38 65 527 808(*) 1h 42'19"(*)
|
||||||
_10 < 1024 6 826 389 114 63 782 912(*) 2h 47'58"(*)
|
_10 < 1024 6 826 389 114 63 782 912(*) 2h 47'58"(*)
|
||||||
|
|
||||||
(*) Before cpp crashed.
|
(*) Before cpp crashed.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -414,7 +414,7 @@ is equivalent to:
|
|||||||
|
|
||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
for (i=0; i<10; i++) {
|
for (i=0; i<10; i++) {
|
||||||
some_code;
|
some_code;
|
||||||
}
|
}
|
||||||
other_code;
|
other_code;
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ Use this to obfuscate your BF programs!
|
|||||||
|
|
||||||
For a challenge, figure out what this obfuscated BF program does:
|
For a challenge, figure out what this obfuscated BF program does:
|
||||||
|
|
||||||
J4mzt?Vazexx-20d~&&~AxdUV!x(~Jz&V)x*(P=J)JUN(dizz)xx_!xx'0&{Vz;}&Jj
|
J4mzt?Vazexx-20d~&&~AxdUV!x(~Jz&V)x*(P=J)JUN(dizz)xx_!xx'0&{Vz;}&Jj
|
||||||
|
|
||||||
It takes two integers as input and outputs one integer.
|
It takes two integers as input and outputs one integer.
|
||||||
|
|
||||||
|
|||||||
@@ -154,8 +154,8 @@ Supported operations and functions are:
|
|||||||
|
|
||||||
+,-,*,/ | Arithmetic operations, priority of * , / over +,- is respected.
|
+,-,*,/ | Arithmetic operations, priority of * , / over +,- is respected.
|
||||||
<,> | Compares the real parts of two complex numbers (the imaginary part
|
<,> | Compares the real parts of two complex numbers (the imaginary part
|
||||||
| is ignored). Any number of conditions is allowed, the iteration will
|
| is ignored). Any number of conditions is allowed, the iteration will
|
||||||
| just stop as soon as one of them fails.
|
| just stop as soon as one of them fails.
|
||||||
Abs2 | Calculates the squared norm, i.e.: Abs2(a+b*i) is (a*a+b*b)+0*i.
|
Abs2 | Calculates the squared norm, i.e.: Abs2(a+b*i) is (a*a+b*b)+0*i.
|
||||||
Re | Extract the real part, i.e.: Re(a+b*i) is a+0*i.
|
Re | Extract the real part, i.e.: Re(a+b*i) is a+0*i.
|
||||||
Im | Extract the imaginary part, i.e.: Im(a+b*i) is b+0*i.
|
Im | Extract the imaginary part, i.e.: Im(a+b*i) is b+0*i.
|
||||||
|
|||||||
@@ -60,17 +60,17 @@ This was done on a Rocky Linux 9.2 server with `Intel(R) Core(TM) i9-9900K CPU @
|
|||||||
3.60GHz` with 16 cores (via HyperThreading):
|
3.60GHz` with 16 cores (via HyperThreading):
|
||||||
|
|
||||||
```
|
```
|
||||||
real 6m35.524s
|
real 6m35.524s
|
||||||
user 6m35.159s
|
user 6m35.159s
|
||||||
sys 0m0.002s
|
sys 0m0.002s
|
||||||
```
|
```
|
||||||
|
|
||||||
and done with macOS Sonoma with the Max M1 chip:
|
and done with macOS Sonoma with the Max M1 chip:
|
||||||
|
|
||||||
```
|
```
|
||||||
real 7m10.786s
|
real 7m10.786s
|
||||||
user 7m8.322s
|
user 7m8.322s
|
||||||
sys 0m0.110s
|
sys 0m0.110s
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -180,8 +180,8 @@ the start of the program:
|
|||||||
|
|
||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
int s[ ] = { 186, 94, 1426, 3098
|
int s[ ] = { 186, 94, 1426, 3098
|
||||||
,1047 , 122 , 1082 , 3083 , 1039
|
,1047 , 122 , 1082 , 3083 , 1039
|
||||||
, 569 , 527 , 1054 , 531 } ;
|
, 569 , 527 , 1054 , 531 } ;
|
||||||
```
|
```
|
||||||
|
|
||||||
Each piece is a bitmap, and represents a 3x3x3 cube.
|
Each piece is a bitmap, and represents a 3x3x3 cube.
|
||||||
|
|||||||
+18
-18
@@ -62,32 +62,32 @@ To search regexp from file, do:
|
|||||||
Pipes might not work, see the section Limitations.
|
Pipes might not work, see the section Limitations.
|
||||||
The options `-i`, `-c`, `-v` and `-n` are the classic ones:
|
The options `-i`, `-c`, `-v` and `-n` are the classic ones:
|
||||||
|
|
||||||
* `-i` Ignore case.
|
* `-i` Ignore case.
|
||||||
|
|
||||||
* `-c` Count only, prints the number of matches, but not the matching lines.
|
* `-c` Count only, prints the number of matches, but not the matching lines.
|
||||||
|
|
||||||
* `-v` Invert match.
|
* `-v` Invert match.
|
||||||
|
|
||||||
* `-n` Prefixes each printed line by its line number (only if
|
* `-n` Prefixes each printed line by its line number (only if
|
||||||
`-c` was not given).
|
`-c` was not given).
|
||||||
|
|
||||||
This version of `grep` recognizes two more options, not present in normal
|
This version of `grep` recognizes two more options, not present in normal
|
||||||
`grep` implementations:
|
`grep` implementations:
|
||||||
|
|
||||||
* `-kN` Permit `N` insertions, deletions or mismatches of characters in the
|
* `-kN` Permit `N` insertions, deletions or mismatches of characters in the
|
||||||
matches, aka
|
matches, aka
|
||||||
[edit-distance](https://en.wikipedia.org/wiki/Edit_distance). E.g.,
|
[edit-distance](https://en.wikipedia.org/wiki/Edit_distance). E.g.,
|
||||||
"`obfuscated`" matches "`obfuscation`"
|
"`obfuscated`" matches "`obfuscation`"
|
||||||
with one deletion and two mismatches. Likewise, "`obfuscate`" and
|
with one deletion and two mismatches. Likewise, "`obfuscate`" and
|
||||||
"`oversimplify`" match with 7
|
"`oversimplify`" match with 7
|
||||||
[edit operations](https://en.wikipedia.org/wiki/Edit_distance#Formal_definition_and_properties).
|
[edit operations](https://en.wikipedia.org/wiki/Edit_distance#Formal_definition_and_properties).
|
||||||
The default is `-k0` (i.e. exact match).
|
The default is `-k0` (i.e. exact match).
|
||||||
|
|
||||||
* `-t` Add local transpositions to the set of allowed
|
* `-t` Add local transpositions to the set of allowed
|
||||||
[edit-operations](https://en.wikipedia.org/wiki/Edit_distance#Formal_definition_and_properties).
|
[edit-operations](https://en.wikipedia.org/wiki/Edit_distance#Formal_definition_and_properties).
|
||||||
That is, "`ab`" matches "`ba`" with one transposition (swap), and
|
That is, "`ab`" matches "`ba`" with one transposition (swap), and
|
||||||
"`obfuscated`" matches "`bofsuact`" with three swaps and two insertions,
|
"`obfuscated`" matches "`bofsuact`" with three swaps and two insertions,
|
||||||
i.e. use `-tk5` to find this.
|
i.e. use `-tk5` to find this.
|
||||||
|
|
||||||
Of course, one could construct a standard
|
Of course, one could construct a standard
|
||||||
[regexp](https://www.regular-expressions.info) that matches the same
|
[regexp](https://www.regular-expressions.info) that matches the same
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ You will probably get warnings while compiling the code. In particular:
|
|||||||
* I don't include any headers I don't strictly need to, so you'll get warnings
|
* I don't include any headers I don't strictly need to, so you'll get warnings
|
||||||
about (at least) `memcpy()`, `isdigit()`, `atoi()`, `calloc()`, `malloc()`
|
about (at least) `memcpy()`, `isdigit()`, `atoi()`, `calloc()`, `malloc()`
|
||||||
and `alloca()` if you didn't use `-DAH`.
|
and `alloca()` if you didn't use `-DAH`.
|
||||||
- NOTE from judges: we added these includes in 2023.
|
- NOTE from judges: we added these includes in 2023.
|
||||||
|
|
||||||
* GCC likes to complain about `while (a = b)` (assignments as a condition).
|
* GCC likes to complain about `while (a = b)` (assignments as a condition).
|
||||||
|
|
||||||
|
|||||||
@@ -73,15 +73,15 @@ Notation](https://en.wikipedia.org/wiki/Reverse_Polish_notation) with the
|
|||||||
following characters recognised:
|
following characters recognised:
|
||||||
|
|
||||||
```
|
```
|
||||||
+, -, *, / - usual arithmetic operations
|
+, -, *, / - usual arithmetic operations
|
||||||
^ - Exponentiation; valid for constant exponent only
|
^ - Exponentiation; valid for constant exponent only
|
||||||
s - sin
|
s - sin
|
||||||
c - cos
|
c - cos
|
||||||
0-9 - single digit integers
|
0-9 - single digit integers
|
||||||
d - duplicate number on stack
|
d - duplicate number on stack
|
||||||
t - transpose top two elements on stack
|
t - transpose top two elements on stack
|
||||||
x - x coordinate value
|
x - x coordinate value
|
||||||
y - y coordinate value
|
y - y coordinate value
|
||||||
```
|
```
|
||||||
|
|
||||||
NB: all arithmetic is done in double precision, so `23/` is two-thirds, rather
|
NB: all arithmetic is done in double precision, so `23/` is two-thirds, rather
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ To create a shared secret shared among `M` people with `N+1` needed to reconstru
|
|||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
./grothe -secret 1-/dev/urandom 2-/dev/urandom ... \
|
./grothe -secret 1-/dev/urandom 2-/dev/urandom ... \
|
||||||
N-/dev/urandom 1+shared1 2+shared2 ... M+sharedM
|
N-/dev/urandom 1+shared1 2+shared2 ... M+sharedM
|
||||||
```
|
```
|
||||||
|
|
||||||
To reconstruct the original (an arbitrary combination of `N+1` or
|
To reconstruct the original (an arbitrary combination of `N+1` or
|
||||||
@@ -77,17 +77,17 @@ this case the cookie recipe) back:
|
|||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
./grothe \
|
./grothe \
|
||||||
-cookie_recipe.txt\
|
-cookie_recipe.txt\
|
||||||
1-/dev/urandom 2-/dev/urandom\
|
1-/dev/urandom 2-/dev/urandom\
|
||||||
1+cookie_piece1.dat 2+cookie_piece2.dat 3+cookie_piece3.dat 4+cookie_piece4.dat
|
1+cookie_piece1.dat 2+cookie_piece2.dat 3+cookie_piece3.dat 4+cookie_piece4.dat
|
||||||
```
|
```
|
||||||
|
|
||||||
To put the recipe back together using the first, second and fourth pieces:
|
To put the recipe back together using the first, second and fourth pieces:
|
||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
./grothe \
|
./grothe \
|
||||||
1-cookie_piece1.dat 2-cookie_piece2.dat 4-cookie_piece4.dat
|
1-cookie_piece1.dat 2-cookie_piece2.dat 4-cookie_piece4.dat
|
||||||
+cookie_recipe_restore.txt
|
+cookie_recipe_restore.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -81,7 +81,7 @@ For example, one can use the following expression to match a certain declaration
|
|||||||
statement in [hou.c](%%REPO_URL%%/2012/hou/hou.c):
|
statement in [hou.c](%%REPO_URL%%/2012/hou/hou.c):
|
||||||
|
|
||||||
``` <!---re-->
|
``` <!---re-->
|
||||||
"char"[ *]*[a-zA-Z_][0-9a-zA-Z_]*[ ]*((=[0-9a-zA-Z_ ]+)|(\[[0-9a-zA-Z_ ]*\]))?[ ]*(,[ *]*[a-zA-Z_][0-9a-zA-Z_]*[ ]*((=[0-9a-zA-Z_ ]+)|(\[[0-9a-zA-Z_ ]*\]))?[ ]*)*;
|
"char"[ *]*[a-zA-Z_][0-9a-zA-Z_]*[ ]*((=[0-9a-zA-Z_ ]+)|(\[[0-9a-zA-Z_ ]*\]))?[ ]*(,[ *]*[a-zA-Z_][0-9a-zA-Z_]*[ ]*((=[0-9a-zA-Z_ ]+)|(\[[0-9a-zA-Z_ ]*\]))?[ ]*)*;
|
||||||
```
|
```
|
||||||
|
|
||||||
The regex engine is also algorithmically efficient. To illustrate the point,
|
The regex engine is also algorithmically efficient. To illustrate the point,
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
## To build:
|
## To build:
|
||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
make all # On a 64-bit machine (default)
|
make all # On a 64-bit machine (default)
|
||||||
|
|
||||||
make tromp32 # On a 32-bit machine
|
make tromp32 # On a 32-bit machine
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -371,7 +371,7 @@ and change it to BLC8 with
|
|||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
$ cat deflate.Blc reverse.blc | ./tromp > rev.Blc
|
$ cat deflate.Blc reverse.blc | ./tromp > rev.Blc
|
||||||
$ wc rev.Blc
|
$ wc rev.Blc
|
||||||
0 1 9 rev.Blc
|
0 1 9 rev.Blc
|
||||||
```
|
```
|
||||||
|
|
||||||
and then try it out with:
|
and then try it out with:
|
||||||
|
|||||||
+19
-19
@@ -38,30 +38,30 @@ free list.
|
|||||||
Here's what each variable does:
|
Here's what each variable does:
|
||||||
|
|
||||||
```
|
```
|
||||||
L Lambda term space
|
L Lambda term space
|
||||||
m mode: 0 for bits and 7 for bytes
|
m mode: 0 for bits and 7 for bytes
|
||||||
b bits remaining unread in I, -1 on EOF
|
b bits remaining unread in I, -1 on EOF
|
||||||
D Desirable temporary
|
D Desirable temporary
|
||||||
c continuation context
|
c continuation context
|
||||||
a active environment pointer
|
a active environment pointer
|
||||||
C Current term index
|
C Current term index
|
||||||
U Ultimate term pointer
|
U Ultimate term pointer
|
||||||
u utility entry
|
u utility entry
|
||||||
B Born to be free-list of closures
|
B Born to be free-list of closures
|
||||||
I Input character
|
I Input character
|
||||||
O Output character
|
O Output character
|
||||||
e entry of current term
|
e entry of current term
|
||||||
```
|
```
|
||||||
|
|
||||||
Here's what each of the 6 auxiliary functions do:
|
Here's what each of the 6 auxiliary functions do:
|
||||||
|
|
||||||
```
|
```
|
||||||
s variable lookup in active environment with de Bruijn index u
|
s variable lookup in active environment with de Bruijn index u
|
||||||
S gets one bit of input, setting b to -1 on EOF or to remaining number of bits in current byte
|
S gets one bit of input, setting b to -1 on EOF or to remaining number of bits in current byte
|
||||||
k copy fragment from string literal holding lambda terms xor 46 into current end of term space
|
k copy fragment from string literal holding lambda terms xor 46 into current end of term space
|
||||||
x expand input, adding 11 (resp. 99) entries to term space for bit (resp. byte) mode
|
x expand input, adding 11 (resp. 99) entries to term space for bit (resp. byte) mode
|
||||||
p parses BLC-encoded lambda term using S(), stores results in term space and returns length
|
p parses BLC-encoded lambda term using S(), stores results in term space and returns length
|
||||||
d decrease reference counter, add record to free list on reaching zero
|
d decrease reference counter, add record to free list on reaching zero
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -44,14 +44,14 @@ Several people discovered an undocumented feature in that
|
|||||||
certain comments such as:
|
certain comments such as:
|
||||||
|
|
||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
///*
|
///*
|
||||||
```
|
```
|
||||||
|
|
||||||
or:
|
or:
|
||||||
|
|
||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
*\
|
*\
|
||||||
/
|
/
|
||||||
```
|
```
|
||||||
|
|
||||||
were not correctly parsed by the tool. The guidelines stated:
|
were not correctly parsed by the tool. The guidelines stated:
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ Why late? Because:
|
|||||||
The IOCCC no longer uses twitter. Today the IOCCC uses Mastodon.
|
The IOCCC no longer uses twitter. Today the IOCCC uses Mastodon.
|
||||||
For more information and to see our IOCCC Mastodon posts, see:
|
For more information and to see our IOCCC Mastodon posts, see:
|
||||||
|
|
||||||
https://fosstodon.org/@ioccc
|
https://fosstodon.org/@ioccc
|
||||||
|
|
||||||
End of important 2023 update to this historic note.
|
End of important 2023 update to this historic note.
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ For extra fun, compile and run [fun.c](%%REPO_URL%%/2013/dlowe/fun.c):
|
|||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
int main() {
|
int main() {
|
||||||
printf("%d %d %d\n", (int)(-1.0/0.0), (int)(0.0/0.0), (int)(1.0/0.0));
|
printf("%d %d %d\n", (int)(-1.0/0.0), (int)(0.0/0.0), (int)(1.0/0.0));
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -99,8 +99,8 @@ would not be true, the application would be the following:
|
|||||||
,1,-1.3 ,1.3, 0, 0,0,0
|
,1,-1.3 ,1.3, 0, 0,0,0
|
||||||
,0 ,0,50, 80, 0,0,0 ,255
|
,0 ,0,50, 80, 0,0,0 ,255
|
||||||
, 8,0}; int main (
|
, 8,0}; int main (
|
||||||
int j) {if (j== 1 ){ if(
|
int j) {if (j== 1 ){ if(
|
||||||
_[12] >_[10] )_[17]=1 ;} if
|
_[12] >_[10] )_[17]=1 ;} if
|
||||||
(_[13] >_[11 ] ||_[17]==1) return 1
|
(_[13] >_[11 ] ||_[17]==1) return 1
|
||||||
;_[6] = _ [13] / _[11]*(_[1]-_[ 0])
|
;_[6] = _ [13] / _[11]*(_[1]-_[ 0])
|
||||||
+_[ 0]; _ [7]=_[12]/_[10]*(_[3]-_[2] )+_
|
+_[ 0]; _ [7]=_[12]/_[10]*(_[3]-_[2] )+_
|
||||||
@@ -108,8 +108,8 @@ would not be true, the application would be the following:
|
|||||||
;_[ 5]= _ [9]*_[9];_[9]=2*_[8]*_[9]+ _[7
|
;_[ 5]= _ [9]*_[9];_[9]=2*_[8]*_[9]+ _[7
|
||||||
];_[8 ] = _ [ 4 ]-_[5]+_[6];_[14 ]++
|
];_[8 ] = _ [ 4 ]-_[5]+_[6];_[14 ]++
|
||||||
;if((_ [14]< _ [15])&&(_[4]+ _[ 5]
|
;if((_ [14]< _ [15])&&(_[4]+ _[ 5]
|
||||||
<_[16 ])) goto l2; putchar(
|
<_[16 ])) goto l2; putchar(
|
||||||
" #@*+ "[( int) _[14]%
|
" #@*+ "[( int) _[14]%
|
||||||
5 ]);_ [13 ] ++ ; main (
|
5 ]);_ [13 ] ++ ; main (
|
||||||
0) ;_[12]++; _[13] =0
|
0) ;_[12]++; _[13] =0
|
||||||
;if(_ [17] !=1) putchar
|
;if(_ [17] !=1) putchar
|
||||||
|
|||||||
@@ -101,14 +101,14 @@ The compiler tool chain is the following.
|
|||||||
raw.txt |
|
raw.txt |
|
||||||
| |
|
| |
|
||||||
+---------+---------+
|
+---------+---------+
|
||||||
|
|
|
|
||||||
| [link.rb]
|
| [link.rb]
|
||||||
V
|
V
|
||||||
main.c
|
main.c
|
||||||
|
|
|
|
||||||
| [gen-prog.c]
|
| [gen-prog.c]
|
||||||
V
|
V
|
||||||
prog.c
|
prog.c
|
||||||
```
|
```
|
||||||
|
|
||||||
* [parse.rb](%%REPO_URL%%/2014/endoh1/parse.rb) converts Ruby to AST.
|
* [parse.rb](%%REPO_URL%%/2014/endoh1/parse.rb) converts Ruby to AST.
|
||||||
|
|||||||
+29
-29
@@ -234,10 +234,10 @@ here:
|
|||||||
|
|
||||||
Each row has six columns:
|
Each row has six columns:
|
||||||
|
|
||||||
1. `Screen X` : `x` position of the object in the level.
|
1. `Screen X` : `x` position of the object in the level.
|
||||||
2. `Screen Y` : `y` position of the object in the level.
|
2. `Screen Y` : `y` position of the object in the level.
|
||||||
3. `Sprite` : `id` of the sprite to be used for the object.
|
3. `Sprite` : `id` of the sprite to be used for the object.
|
||||||
4. `CLASSFLAGS` : a bitmask that describe how the object behaves.
|
4. `CLASSFLAGS` : a bitmask that describe how the object behaves.
|
||||||
5. `CLASSPARAM0`: a parameter that depends on `CLASSFLAGS`.
|
5. `CLASSPARAM0`: a parameter that depends on `CLASSFLAGS`.
|
||||||
6. `CLASSPARAM1`: a parameter that depends on `CLASSFLAGS`.
|
6. `CLASSPARAM1`: a parameter that depends on `CLASSFLAGS`.
|
||||||
|
|
||||||
@@ -245,52 +245,52 @@ Each row has six columns:
|
|||||||
|
|
||||||
* `ENEMY` (`1`)
|
* `ENEMY` (`1`)
|
||||||
|
|
||||||
An enemy. CLASSPARAM0 can be 0 if the enemies don't move, 1 if the
|
An enemy. CLASSPARAM0 can be 0 if the enemies don't move, 1 if the
|
||||||
initial move direction is right, -1 if that direction is left. All
|
initial move direction is right, -1 if that direction is left. All
|
||||||
enemies that walk will change their direction after 20 steps. The
|
enemies that walk will change their direction after 20 steps. The
|
||||||
sprite of an enemy must have 2 other adjacent sprites: SPRITE-1,
|
sprite of an enemy must have 2 other adjacent sprites: SPRITE-1,
|
||||||
used when the enemy dies, and SPRITE+1, used when it moves.
|
used when the enemy dies, and SPRITE+1, used when it moves.
|
||||||
|
|
||||||
* `BLOCK` (`2`)
|
* `BLOCK` (`2`)
|
||||||
|
|
||||||
A wall. Player can walk over the object but can not pass through it.
|
A wall. Player can walk over the object but can not pass through it.
|
||||||
|
|
||||||
* `OBJECT BLOCK` (`4`)
|
* `OBJECT BLOCK` (`4`)
|
||||||
|
|
||||||
When the player hits the object from below, a new object is created.
|
When the player hits the object from below, a new object is created.
|
||||||
CLASSFLAGS of the new object is defined in CLASSPARAM0. The sprite
|
CLASSFLAGS of the new object is defined in CLASSPARAM0. The sprite
|
||||||
used for the new object is defined in CLASSPARAM1. The sprite of the
|
used for the new object is defined in CLASSPARAM1. The sprite of the
|
||||||
new object must have an adjacent sprite: SPRITE+1, used when the
|
new object must have an adjacent sprite: SPRITE+1, used when the
|
||||||
block is hit.
|
block is hit.
|
||||||
|
|
||||||
* `POWERUP` (`8`)
|
* `POWERUP` (`8`)
|
||||||
|
|
||||||
This is a power-up like the classic Mario mushroom. When the
|
This is a power-up like the classic Mario mushroom. When the
|
||||||
character hits the power-up object, the character becomes the Super
|
character hits the power-up object, the character becomes the Super
|
||||||
character. If CLASSFLAGS has the bit ZOOM, the character height will
|
character. If CLASSFLAGS has the bit ZOOM, the character height will
|
||||||
be doubled. The Super character can hit the enemies without dying,
|
be doubled. The Super character can hit the enemies without dying,
|
||||||
but when this happens, the Super character goes back to being
|
but when this happens, the Super character goes back to being
|
||||||
normal.
|
normal.
|
||||||
|
|
||||||
* `END` (`16`)
|
* `END` (`16`)
|
||||||
|
|
||||||
When the player hits this object the level ends; the player wins.
|
When the player hits this object the level ends; the player wins.
|
||||||
|
|
||||||
* `ZOOM` (`32`)
|
* `ZOOM` (`32`)
|
||||||
|
|
||||||
This flag can be used with POWERUP to indicate a power-up that
|
This flag can be used with POWERUP to indicate a power-up that
|
||||||
will double the size of the player (like the Mario mushroom).
|
will double the size of the player (like the Mario mushroom).
|
||||||
|
|
||||||
* `DESTROY` (`64`)
|
* `DESTROY` (`64`)
|
||||||
|
|
||||||
When the player hits the object (e.g. the classic Mario coin) the
|
When the player hits the object (e.g. the classic Mario coin) the
|
||||||
object disappears but the engine does not count the points, so,
|
object disappears but the engine does not count the points, so,
|
||||||
from the player point of view, this object is useless.
|
from the player point of view, this object is useless.
|
||||||
|
|
||||||
* `DESTROYUP` (`128`)
|
* `DESTROYUP` (`128`)
|
||||||
|
|
||||||
This object is like a BLOCK but when the player hits the object
|
This object is like a BLOCK but when the player hits the object
|
||||||
from below, the object disappears.
|
from below, the object disappears.
|
||||||
|
|
||||||
If `CLASSFLAGS` is `0` the object only has an aesthetic function.
|
If `CLASSFLAGS` is `0` the object only has an aesthetic function.
|
||||||
|
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ shifts mod 32:
|
|||||||
|
|
||||||
```
|
```
|
||||||
1<<48
|
1<<48
|
||||||
65536 0x00010000
|
65536 0x00010000
|
||||||
```
|
```
|
||||||
|
|
||||||
gcc 4.2.1 without arguments compiles cleanly (e.g. `cc prog.c -o prog`).
|
gcc 4.2.1 without arguments compiles cleanly (e.g. `cc prog.c -o prog`).
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ were added over time.
|
|||||||
dance began (this is called foreshadowing):
|
dance began (this is called foreshadowing):
|
||||||
|
|
||||||
```
|
```
|
||||||
() forced precedence
|
() forced precedence
|
||||||
- ~ ? unary minus, compl, byteswap
|
- ~ ? unary minus, compl, byteswap
|
||||||
* / % & << >> mul, div, mod, bitand, shift: left, right
|
* / % & << >> mul, div, mod, bitand, shift: left, right
|
||||||
+ - | ^ add, sub, bitor, xor
|
+ - | ^ add, sub, bitor, xor
|
||||||
NUM 0-9
|
NUM 0-9
|
||||||
```
|
```
|
||||||
|
|
||||||
This seemed like a reasonable candidate to experiment with obfuscation; perhaps
|
This seemed like a reasonable candidate to experiment with obfuscation; perhaps
|
||||||
@@ -34,39 +34,39 @@ The algorithm was and is rather straightforward:
|
|||||||
|
|
||||||
```
|
```
|
||||||
expr() {
|
expr() {
|
||||||
n = term()
|
n = term()
|
||||||
t = token()
|
t = token()
|
||||||
if (t == ADD) return n += expr()
|
if (t == ADD) return n += expr()
|
||||||
if (t == SUB) return n -= expr()
|
if (t == SUB) return n -= expr()
|
||||||
if (t == BOR) return n |= expr()
|
if (t == BOR) return n |= expr()
|
||||||
if (t == XOR) return n ^= expr()
|
if (t == XOR) return n ^= expr()
|
||||||
ungettoken(t)
|
ungettoken(t)
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
term() {
|
term() {
|
||||||
n = factor()
|
n = factor()
|
||||||
t = token()
|
t = token()
|
||||||
if (t == MUL) return n *= term()
|
if (t == MUL) return n *= term()
|
||||||
if (t == DIV) return n /= term()
|
if (t == DIV) return n /= term()
|
||||||
if (t == AND) return n &= term()
|
if (t == AND) return n &= term()
|
||||||
if (t == RSH) return n >> term()
|
if (t == RSH) return n >> term()
|
||||||
if (t == LSH) return n << term()
|
if (t == LSH) return n << term()
|
||||||
ungettoken(t)
|
ungettoken(t)
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
factor() {
|
factor() {
|
||||||
t = token()
|
t = token()
|
||||||
if (t == LPAREN) {
|
if (t == LPAREN) {
|
||||||
n = expr()
|
n = expr()
|
||||||
if token() == RPAREN
|
if token() == RPAREN
|
||||||
return n
|
return n
|
||||||
error()
|
error()
|
||||||
}
|
}
|
||||||
if (t == SUB) return -factor()
|
if (t == SUB) return -factor()
|
||||||
if (t == CMP) return ~factor()
|
if (t == CMP) return ~factor()
|
||||||
if (t == QUE) return byteswap(factor())
|
if (t == QUE) return byteswap(factor())
|
||||||
if (t == DIG) return strtol()
|
if (t == DIG) return strtol()
|
||||||
error()
|
error()
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ proceeds from there, using some identities that are confusingly similar and
|
|||||||
interestingly combined (increasing obfuscation):
|
interestingly combined (increasing obfuscation):
|
||||||
|
|
||||||
```
|
```
|
||||||
obc clr
|
obc clr
|
||||||
--- ---
|
--- ---
|
||||||
-~x x+1
|
-~x x+1
|
||||||
~-x x-1
|
~-x x-1
|
||||||
y-~x y+x+1
|
y-~x y+x+1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -46,12 +46,12 @@ Compile the program as follows:
|
|||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
cc -O3 -std=c99 \
|
cc -O3 -std=c99 \
|
||||||
-Wall -Wextra -pedantic -o prog prog.c \
|
-Wall -Wextra -pedantic -o prog prog.c \
|
||||||
-Delta_u="Du*laplacian(u)-u*v*v+F*(1-u)" \
|
-Delta_u="Du*laplacian(u)-u*v*v+F*(1-u)" \
|
||||||
-Delta_v="Dv*laplacian(v)+u*v*v-v*(F+K)" \
|
-Delta_v="Dv*laplacian(v)+u*v*v-v*(F+K)" \
|
||||||
-DF=0.040 -DK=0.060 -DDu=0.200 -DDv=0.100 \
|
-DF=0.040 -DK=0.060 -DDu=0.200 -DDv=0.100 \
|
||||||
-DUV_BACKGROUND=1,0 -DUV_DROP=-0.5,0.5 \
|
-DUV_BACKGROUND=1,0 -DUV_DROP=-0.5,0.5 \
|
||||||
-DTIMESTEP=1.0 -DSPEED=2 -DRGB=255:128:192
|
-DTIMESTEP=1.0 -DSPEED=2 -DRGB=255:128:192
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, run it with the `tcpserver` command in the
|
Then, run it with the `tcpserver` command in the
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ More generally use:
|
|||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
cc -o prog prog.c foo.c
|
cc -o prog prog.c foo.c
|
||||||
./prog
|
./prog
|
||||||
^C # if necessary, where ^C is ctrl-C, interrrupt
|
^C # if necessary, where ^C is ctrl-C, interrrupt
|
||||||
```
|
```
|
||||||
|
|
||||||
to compile and run `prog` as whatever foo.c is in the joke PDP-11 emulator.
|
to compile and run `prog` as whatever foo.c is in the joke PDP-11 emulator.
|
||||||
|
|||||||
+13
-13
@@ -45,35 +45,35 @@ From the Makefile:
|
|||||||
# Game parameters
|
# Game parameters
|
||||||
#
|
#
|
||||||
DU=99999 # Time between steps in microseconds.
|
DU=99999 # Time between steps in microseconds.
|
||||||
# Make it larger if the game is too fast for you.
|
# Make it larger if the game is too fast for you.
|
||||||
|
|
||||||
DW=28 # Pipe-to-pipe spacing, in columns.
|
DW=28 # Pipe-to-pipe spacing, in columns.
|
||||||
# Farther apart is easier.
|
# Farther apart is easier.
|
||||||
|
|
||||||
DD=20 # Space between pipes.
|
DD=20 # Space between pipes.
|
||||||
# The difference between DD and DW is the width of a pipe.
|
# The difference between DD and DW is the width of a pipe.
|
||||||
# Narrow pipes are easier to fly though.
|
# Narrow pipes are easier to fly though.
|
||||||
|
|
||||||
DH=8 # Height of gap in pipe.
|
DH=8 # Height of gap in pipe.
|
||||||
# Make this larger to make the game easier.
|
# Make this larger to make the game easier.
|
||||||
|
|
||||||
DA=100 # Acceleration due to gravity (scaled by 256).
|
DA=100 # Acceleration due to gravity (scaled by 256).
|
||||||
# Smaller values make you glide slower.
|
# Smaller values make you glide slower.
|
||||||
|
|
||||||
DI=-200 # Impulse velocity of a flap (scaled by 256).
|
DI=-200 # Impulse velocity of a flap (scaled by 256).
|
||||||
# Make larger if you want a less intense tapping experience!
|
# Make larger if you want a less intense tapping experience!
|
||||||
|
|
||||||
DB='"<o^="' # Sprite for player when gliding.
|
DB='"<o^="' # Sprite for player when gliding.
|
||||||
# HINT: Try using various emojis.
|
# HINT: Try using various emojis.
|
||||||
# NOTE: The string MUST be enclosed inside double quotes.
|
# NOTE: The string MUST be enclosed inside double quotes.
|
||||||
|
|
||||||
DF='"<ov="' # Sprite for player when flapping.
|
DF='"<ov="' # Sprite for player when flapping.
|
||||||
# HINT: Try using various emojis.
|
# HINT: Try using various emojis.
|
||||||
# NOTE: The string MUST be enclosed inside double quotes.
|
# NOTE: The string MUST be enclosed inside double quotes.
|
||||||
|
|
||||||
DG='"Tap to Flap!"' # Instruction text.
|
DG='"Tap to Flap!"' # Instruction text.
|
||||||
# Change to your native tongue.
|
# Change to your native tongue.
|
||||||
# NOTE: The string MUST be enclosed inside double quotes.
|
# NOTE: The string MUST be enclosed inside double quotes.
|
||||||
```
|
```
|
||||||
|
|
||||||
WARNING: if you have good eye-hand coordination and too much time on your hands
|
WARNING: if you have good eye-hand coordination and too much time on your hands
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ for a `compress(1)`-like compressor using a similar idea.
|
|||||||
Why is the sad smiley on line 12 in that particular place?
|
Why is the sad smiley on line 12 in that particular place?
|
||||||
|
|
||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
c=0) :( O
|
c=0) :( O
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+59
-59
@@ -58,9 +58,9 @@ Bell](http://members.tip.net.au/~dbell/) once described
|
|||||||
as having one of the largest "yummo quotients" in number theory:
|
as having one of the largest "yummo quotients" in number theory:
|
||||||
|
|
||||||
```
|
```
|
||||||
complexity of the solution
|
complexity of the solution
|
||||||
yummo quotient = -----------------------------------
|
yummo quotient = -----------------------------------
|
||||||
complexity of the problem statement
|
complexity of the problem statement
|
||||||
```
|
```
|
||||||
|
|
||||||
[Erdős](https://en.wikipedia.org/wiki/Paul_Erdős) privately told one of the IOCCC judges:
|
[Erdős](https://en.wikipedia.org/wiki/Paul_Erdős) privately told one of the IOCCC judges:
|
||||||
@@ -261,31 +261,31 @@ built. In biochemistry, each is assigned a TLI (see [Proteinogenic amino
|
|||||||
acid](https://en.wikipedia.org/wiki/Proteinogenic_amino_acid) for more info):
|
acid](https://en.wikipedia.org/wiki/Proteinogenic_amino_acid) for more info):
|
||||||
|
|
||||||
```
|
```
|
||||||
ala Alanine
|
ala Alanine
|
||||||
cys Cysteine
|
cys Cysteine
|
||||||
asp Aspartic acid
|
asp Aspartic acid
|
||||||
glu Glutamic acid
|
glu Glutamic acid
|
||||||
phe Phenylalanine
|
phe Phenylalanine
|
||||||
gly Glycine
|
gly Glycine
|
||||||
his Histidine
|
his Histidine
|
||||||
ile Isoleucine
|
ile Isoleucine
|
||||||
lys Lysine
|
lys Lysine
|
||||||
leu Leucine
|
leu Leucine
|
||||||
met Methionine
|
met Methionine
|
||||||
asn Asparagine
|
asn Asparagine
|
||||||
pyl Pyrrolysine
|
pyl Pyrrolysine
|
||||||
pro Proline
|
pro Proline
|
||||||
gln Glutamine
|
gln Glutamine
|
||||||
arg Arginine
|
arg Arginine
|
||||||
ser Serine
|
ser Serine
|
||||||
thr Threonine
|
thr Threonine
|
||||||
sec Selenocysteine
|
sec Selenocysteine
|
||||||
val Valine
|
val Valine
|
||||||
trp Tryptophan
|
trp Tryptophan
|
||||||
tyr Tyrosine
|
tyr Tyrosine
|
||||||
asx Asparagine or Aspartic acid
|
asx Asparagine or Aspartic acid
|
||||||
glx Glutamic acid or Glutamine
|
glx Glutamic acid or Glutamine
|
||||||
xle Leucine or Isoleucine
|
xle Leucine or Isoleucine
|
||||||
unk Unknown
|
unk Unknown
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -294,10 +294,10 @@ the rule "[No original
|
|||||||
research](https://en.wikipedia.org/wiki/Wikipedia:No_original_research)"):
|
research](https://en.wikipedia.org/wiki/Wikipedia:No_original_research)"):
|
||||||
|
|
||||||
```
|
```
|
||||||
and Androgynine
|
and Androgynine
|
||||||
xor Xenoricine
|
xor Xenoricine
|
||||||
not Notanamine
|
not Notanamine
|
||||||
tla Triletramine
|
tla Triletramine
|
||||||
```
|
```
|
||||||
|
|
||||||
Interestingly, the TLI are the perfect mnemonics for C language source.
|
Interestingly, the TLI are the perfect mnemonics for C language source.
|
||||||
@@ -336,23 +336,23 @@ Another identity operation. I've done it for you already. Use this
|
|||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
$ cat .indent.pro
|
$ cat .indent.pro
|
||||||
-bad /* blank line after decls */
|
-bad /* blank line after decls */
|
||||||
-bap /* blank line after functions */
|
-bap /* blank line after functions */
|
||||||
-br /* braces on if line */
|
-br /* braces on if line */
|
||||||
-i8 /* indent */
|
-i8 /* indent */
|
||||||
-l999 /* line length */
|
-l999 /* line length */
|
||||||
-npcs /* no space after function call names */
|
-npcs /* no space after function call names */
|
||||||
-npsl /* don't break procedure type */
|
-npsl /* don't break procedure type */
|
||||||
-ut /* use tabs */
|
-ut /* use tabs */
|
||||||
-ce /* cuddle else */
|
-ce /* cuddle else */
|
||||||
-nip /* no parameter indentation */
|
-nip /* no parameter indentation */
|
||||||
-di1 /* declaration indent */
|
-di1 /* declaration indent */
|
||||||
-Tand
|
-Tand
|
||||||
-Tmet
|
-Tmet
|
||||||
-Tthr
|
-Tthr
|
||||||
-Tpro
|
-Tpro
|
||||||
-Tser
|
-Tser
|
||||||
-Tala
|
-Tala
|
||||||
```
|
```
|
||||||
|
|
||||||
It looks like a perfect program should have:
|
It looks like a perfect program should have:
|
||||||
@@ -390,15 +390,15 @@ Pseudocode, with comments matching those in the C source:
|
|||||||
n = convert(argv[1])
|
n = convert(argv[1])
|
||||||
print n /* 2hx */
|
print n /* 2hx */
|
||||||
while (n != 1) { /* one */
|
while (n != 1) { /* one */
|
||||||
if (n is odd) { /* odd */
|
if (n is odd) { /* odd */
|
||||||
m = deep copy of n /* cpy */
|
m = deep copy of n /* cpy */
|
||||||
n <<= 1 /* shl */
|
n <<= 1 /* shl */
|
||||||
n += m /* add */
|
n += m /* add */
|
||||||
increment n /* inc */
|
increment n /* inc */
|
||||||
} else { /* eve */
|
} else { /* eve */
|
||||||
n >>= 1 /* shr */
|
n >>= 1 /* shr */
|
||||||
}
|
}
|
||||||
print n /* 2hx */
|
print n /* 2hx */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -407,8 +407,8 @@ Pseudocode, with comments matching those in the C source:
|
|||||||
|
|
||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
typedef struct {
|
typedef struct {
|
||||||
size_t places; /* number of places in base 2 to the power of (8*sizeof(type)) */
|
size_t places; /* number of places in base 2 to the power of (8*sizeof(type)) */
|
||||||
type *number; /* dynamically allocated memory for number */
|
type *number; /* dynamically allocated memory for number */
|
||||||
} bignum
|
} bignum
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ For more detailed information see [2018/algmyr in bugs.html](../../bugs.html#201
|
|||||||
## To use:
|
## To use:
|
||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
./prog < prog.c # Print garbage: might mess up your terminal
|
./prog < prog.c # Print garbage: might mess up your terminal
|
||||||
./prog <file1> <file2> > out.raw
|
./prog <file1> <file2> > out.raw
|
||||||
./prog -d 2 0 out.raw # Decode the first (0th) channel out of two
|
./prog -d 2 0 out.raw # Decode the first (0th) channel out of two
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ E.g:
|
|||||||
|
|
||||||
|
|
||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
main(){system("hd");} // it's turtles all the way down!
|
main(){system("hd");} // it's turtles all the way down!
|
||||||
```
|
```
|
||||||
|
|
||||||
is not acceptable.
|
is not acceptable.
|
||||||
|
|||||||
+21
-21
@@ -137,7 +137,7 @@ The discrepancies found are documented and explained in the file
|
|||||||
|
|
||||||
``` <!---sh-->
|
``` <!---sh-->
|
||||||
find ~/src/obc -type f -a -name "*.c" | xargs ./spotcheck.sh ./prog | ./spotdiff.sh |
|
find ~/src/obc -type f -a -name "*.c" | xargs ./spotcheck.sh ./prog | ./spotdiff.sh |
|
||||||
grep -v keep | diff -bw - discrep* | grep "[<>] cl "
|
grep -v keep | diff -bw - discrep* | grep "[<>] cl "
|
||||||
```
|
```
|
||||||
|
|
||||||
In summary, there are only 6 unique entries out of 366 that have any variation
|
In summary, there are only 6 unique entries out of 366 that have any variation
|
||||||
@@ -228,38 +228,38 @@ language_. It really is this easy with `tac`:
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
script='
|
script='
|
||||||
BEGIN {
|
BEGIN {
|
||||||
last=nl="\n";
|
last=nl="\n";
|
||||||
f="c11"; while(getline <f > 0) kw[$0]++; close(f);
|
f="c11"; while(getline <f > 0) kw[$0]++; close(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
function iskw(a) { return a in kw }
|
function iskw(a) { return a in kw }
|
||||||
function indent(a) { return sprintf("%*s", n*3, " ") }
|
function indent(a) { return sprintf("%*s", n*3, " ") }
|
||||||
function newline() { if (!infor && last != nl) printf last=nl; }
|
function newline() { if (!infor && last != nl) printf last=nl; }
|
||||||
function show(a) {
|
function show(a) {
|
||||||
if (last==nl) printf "%s", indent()
|
if (last==nl) printf "%s", indent()
|
||||||
printf "%s%s", space(), a
|
printf "%s%s", space(), a
|
||||||
last=a
|
last=a
|
||||||
}
|
}
|
||||||
function space() {
|
function space() {
|
||||||
return iskw(last) ||
|
return iskw(last) ||
|
||||||
(last ~ /[A-Za-z0-9_+-\/%^[&\]\)=:<>;]$/ && $0 !~ /[:;()\[\],]/) ? " " : ""
|
(last ~ /[A-Za-z0-9_+-\/%^[&\]\)=:<>;]$/ && $0 !~ /[:;()\[\],]/) ? " " : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
/^\(/ { ++paren }
|
/^\(/ { ++paren }
|
||||||
/^\)/ { --paren }
|
/^\)/ { --paren }
|
||||||
|
|
||||||
/^for/ { newline(); infor=1 }
|
/^for/ { newline(); infor=1 }
|
||||||
infor && /^;/ { ++infor; show($0 " "); next }
|
infor && /^;/ { ++infor; show($0 " "); next }
|
||||||
infor==1 && /^:/ { ++infor }
|
infor==1 && /^:/ { ++infor }
|
||||||
infor>1 && paren==0 { infor=0 }
|
infor>1 && paren==0 { infor=0 }
|
||||||
|
|
||||||
/^\?/ { tern++; n++; newline(); show($0 " "); next }
|
/^\?/ { tern++; n++; newline(); show($0 " "); next }
|
||||||
tern && /^:/ { newline(); show($0); --tern; --n; next }
|
tern && /^:/ { newline(); show($0); --tern; --n; next }
|
||||||
|
|
||||||
/^#/ { newline(); show($0); newline(); next }
|
/^#/ { newline(); show($0); newline(); next }
|
||||||
/^;/ { show($0); newline(); next }
|
/^;/ { show($0); newline(); next }
|
||||||
/^{/ { show($0); ++n; newline(); next }
|
/^{/ { show($0); ++n; newline(); next }
|
||||||
/^}/ { n--; newline(); show($0); newline(); next }
|
/^}/ { n--; newline(); show($0); newline(); next }
|
||||||
|
|
||||||
{ show($0) }
|
{ show($0) }
|
||||||
'
|
'
|
||||||
@@ -329,9 +329,9 @@ The following reserved word files are included:
|
|||||||
* [kandr](%%REPO_URL%%/2018/burton2/kandr) from my venerable 1978 18th printing "The C Programming Language"
|
* [kandr](%%REPO_URL%%/2018/burton2/kandr) from my venerable 1978 18th printing "The C Programming Language"
|
||||||
* [v7unix](%%REPO_URL%%/2018/burton2/v7unix) 7th edition Unix source code, extracted from c00.c
|
* [v7unix](%%REPO_URL%%/2018/burton2/v7unix) 7th edition Unix source code, extracted from c00.c
|
||||||
* [kandr2](%%REPO_URL%%/2018/burton2/kandr2) from my 1988 1st printing "The C Programming Language", 2e
|
* [kandr2](%%REPO_URL%%/2018/burton2/kandr2) from my 1988 1st printing "The C Programming Language", 2e
|
||||||
* [ansi](%%REPO_URL%%/2018/burton2/ansi) ANSI X3.159-1989
|
* [ansi](%%REPO_URL%%/2018/burton2/ansi) ANSI X3.159-1989
|
||||||
* [c99](%%REPO_URL%%/2018/burton2/c99) ISO/IEC 9899:1999(E)
|
* [c99](%%REPO_URL%%/2018/burton2/c99) ISO/IEC 9899:1999(E)
|
||||||
* [c11](%%REPO_URL%%/2018/burton2/c11) ISO/IEC 9899:201x(E) N1570
|
* [c11](%%REPO_URL%%/2018/burton2/c11) ISO/IEC 9899:201x(E) N1570
|
||||||
* [c++98](%%REPO_URL%%/2018/burton2/c++98) http://en.cppreference.com/w/cpp/keyword
|
* [c++98](%%REPO_URL%%/2018/burton2/c++98) http://en.cppreference.com/w/cpp/keyword
|
||||||
* [c++11](%%REPO_URL%%/2018/burton2/c++11) ISO/IEC 14882:2011(E) N3337 2012-01-16
|
* [c++11](%%REPO_URL%%/2018/burton2/c++11) ISO/IEC 14882:2011(E) N3337 2012-01-16
|
||||||
* [c++14](%%REPO_URL%%/2018/burton2/c++14) ISO/IEC 14882:2014(E) N4296 2014-11-09
|
* [c++14](%%REPO_URL%%/2018/burton2/c++14) ISO/IEC 14882:2014(E) N4296 2014-11-09
|
||||||
|
|||||||
+14
-14
@@ -59,20 +59,20 @@ different"](https://en.wikipedia.org/wiki/And_Now_for_Something_Completely_Diffe
|
|||||||
is also used in the opening.
|
is also used in the opening.
|
||||||
|
|
||||||
```
|
```
|
||||||
___-----__
|
___-----__
|
||||||
_-- --__
|
_-- --__
|
||||||
_- _--_ \
|
_- _--_ \
|
||||||
_- /\ +-.:.:-+ /\ \
|
_- /\ +-.:.:-+ /\ \
|
||||||
/ \/ |.:.:.:| \/ |
|
/ \/ |.:.:.:| \/ |
|
||||||
/ |:.:.:.| |
|
/ |:.:.:.| |
|
||||||
/ |.:.:.:| | ___-----___
|
/ |.:.:.:| | ___-----___
|
||||||
| |.:.:| | / \
|
| |.:.:| | / \
|
||||||
| |:.:.| | < It's ... |
|
| |:.:.| | < It's ... |
|
||||||
\ |:.| | \ /
|
\ |:.| | \ /
|
||||||
\ || | ---_____---
|
\ || | ---_____---
|
||||||
_--\ |
|
_--\ |
|
||||||
_- -__ |
|
_- -__ |
|
||||||
__- --___ |
|
__- --___ |
|
||||||
_- |
|
_- |
|
||||||
/ |
|
/ |
|
||||||
| |
|
| |
|
||||||
|
|||||||
+12
-12
@@ -3,9 +3,9 @@
|
|||||||
- [prog.c](prog.c)
|
- [prog.c](prog.c)
|
||||||
* This is the source file to the `weasel` program [1].
|
* This is the source file to the `weasel` program [1].
|
||||||
- [prog.alt.c](prog.alt.c)
|
- [prog.alt.c](prog.alt.c)
|
||||||
* This is the source code file to the `weasel.alt` program [1].
|
* This is the source code file to the `weasel.alt` program [1].
|
||||||
- [test.sh](test.sh)
|
- [test.sh](test.sh)
|
||||||
* Script provided to test the weasel program [1].
|
* Script provided to test the weasel program [1].
|
||||||
- [test-strings.txt](test-strings.txt)
|
- [test-strings.txt](test-strings.txt)
|
||||||
* The `test.sh` script reads from this file and runs the program with these
|
* The `test.sh` script reads from this file and runs the program with these
|
||||||
target strings.
|
target strings.
|
||||||
@@ -47,18 +47,18 @@ remarks I have kept it in place. Please note that the paths below are dependent
|
|||||||
on the prefix used in installation; where I suggest `/usr` it is equally
|
on the prefix used in installation; where I suggest `/usr` it is equally
|
||||||
possible it could be under '/usr/local', for example.
|
possible it could be under '/usr/local', for example.
|
||||||
|
|
||||||
[1] Note that [prog.c](prog.c) and
|
[1] Note that [prog.c](prog.c) and
|
||||||
[prog.alt.c](prog.alt.c) would be
|
[prog.alt.c](prog.alt.c) would be
|
||||||
linked to `weasel.c` and `weasel.alt.c`
|
linked to `weasel.c` and `weasel.alt.c`
|
||||||
(respectively) in the `/usr/src/weasel`
|
(respectively) in the `/usr/src/weasel`
|
||||||
subdirectory.
|
subdirectory.
|
||||||
|
|
||||||
[2] The file would most likely be compressed as
|
[2] The file would most likely be compressed as
|
||||||
`weasel.1.gz` under the `/usr/share/man/man1`
|
`weasel.1.gz` under the `/usr/share/man/man1`
|
||||||
subdirectory.
|
subdirectory.
|
||||||
|
|
||||||
[3] These files would be in the `/usr/share/doc/weasel`
|
[3] These files would be in the `/usr/share/doc/weasel`
|
||||||
subdirectory.
|
subdirectory.
|
||||||
|
|
||||||
<hr style="width:10%;text-align:left;margin-left:0">
|
<hr style="width:10%;text-align:left;margin-left:0">
|
||||||
|
|
||||||
|
|||||||
@@ -372,11 +372,11 @@ precise the following characters are acceptable; it equates to this in C (note
|
|||||||
it includes a literal space `' '` but it doesn't include other
|
it includes a literal space `' '` but it doesn't include other
|
||||||
`isspace()` characters) and this is why some of the characters are escaped:
|
`isspace()` characters) and this is why some of the characters are escaped:
|
||||||
|
|
||||||
const char keyboard[]=" !\"#$<%:>&'()*+,-./0123456789;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`{|}~";
|
const char keyboard[]=" !\"#$<%:>&'()*+,-./0123456789;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`{|}~";
|
||||||
|
|
||||||
The simpler keyboard looks like:
|
The simpler keyboard looks like:
|
||||||
|
|
||||||
const char keyboard[]=" !\"&'(),.0123456789;?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
const char keyboard[]=" !\"&'(),.0123456789;?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
|
||||||
The program makes sure that the target string only has characters the keyboard
|
The program makes sure that the target string only has characters the keyboard
|
||||||
can actually produce but there is a certain type of input error that might
|
can actually produce but there is a certain type of input error that might
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ Assuming you're more careful than that, we can try a few commands:
|
|||||||
# cat > foo.c
|
# cat > foo.c
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
printf("Hello, World!\n");
|
printf("Hello, World!\n");
|
||||||
}
|
}
|
||||||
^D
|
^D
|
||||||
# cc foo.c
|
# cc foo.c
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ be applied.
|
|||||||
[6]: https://en.wikipedia.org/wiki/Lambda_calculus "Lambda Calculus on Wikipedia"
|
[6]: https://en.wikipedia.org/wiki/Lambda_calculus "Lambda Calculus on Wikipedia"
|
||||||
[7]: https://en.wikipedia.org/wiki/Combinatory_logic "Combinatory Logic on Wikipedia"
|
[7]: https://en.wikipedia.org/wiki/Combinatory_logic "Combinatory Logic on Wikipedia"
|
||||||
[8]: https://inazz.jp/unlambda/ "Online Unlambda interpreter"
|
[8]: https://inazz.jp/unlambda/ "Online Unlambda interpreter"
|
||||||
[9]: ../../2014/birken/index.html "Best use of port 1701"
|
[9]: ../../2014/birken/index.html "Best use of port 1701"
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ We truly have not much more to add, except two things:
|
|||||||
model RAM, you'd want to reduce the value of the Z define in the Makefile
|
model RAM, you'd want to reduce the value of the Z define in the Makefile
|
||||||
to `0x10000000`, otherwise the entry will promptly crash. To do this you can do:
|
to `0x10000000`, otherwise the entry will promptly crash. To do this you can do:
|
||||||
|
|
||||||
make clobber MEMORY=0x10000000 all
|
make clobber MEMORY=0x10000000 all
|
||||||
|
|
||||||
Notice that that value must be a power of two!
|
Notice that that value must be a power of two!
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ Okay, check the backtrace.
|
|||||||
#5 0x00005555555557ce in x69 () at prog.c:105
|
#5 0x00005555555557ce in x69 () at prog.c:105
|
||||||
#6 0x0000555555555828 in x6e () at prog.c:110
|
#6 0x0000555555555828 in x6e () at prog.c:110
|
||||||
#7 0x0000555555555747 in x65 () at prog.c:101
|
#7 0x0000555555555747 in x65 () at prog.c:101
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
See the line numbers and lookup the ASCII table.
|
See the line numbers and lookup the ASCII table.
|
||||||
|
|||||||
@@ -532,8 +532,8 @@ assignments. For example, the simple one-layer RNN could be defined like
|
|||||||
|
|
||||||
``` <!---make-->
|
``` <!---make-->
|
||||||
-DNW=' x = I(n), hp = I(128), \
|
-DNW=' x = I(n), hp = I(128), \
|
||||||
h = C(hp, T(A(L(128, x), L(128, hp)))), \
|
h = C(hp, T(A(L(128, x), L(128, hp)))), \
|
||||||
y = L(n, h)'
|
y = L(n, h)'
|
||||||
```
|
```
|
||||||
|
|
||||||
The network declares `x` as an input vector (there must be a declaration for
|
The network declares `x` as an input vector (there must be a declaration for
|
||||||
@@ -578,14 +578,14 @@ GRU network:
|
|||||||
``` <!---make-->
|
``` <!---make-->
|
||||||
-DHS=128, \
|
-DHS=128, \
|
||||||
-DNW=' x = I(n), \
|
-DNW=' x = I(n), \
|
||||||
y = L(n, MD(MD(x)))' \
|
y = L(n, MD(MD(x)))' \
|
||||||
-DBK=' hp = I(HS), \
|
-DBK=' hp = I(HS), \
|
||||||
z = S(A(L(HS, x), L(HS, hp))), \
|
z = S(A(L(HS, x), L(HS, hp))), \
|
||||||
r = S(A(L(HS, x), L(HS, hp))), \
|
r = S(A(L(HS, x), L(HS, hp))), \
|
||||||
c = T(A(L(HS, x), L(HS, hp))), \
|
c = T(A(L(HS, x), L(HS, hp))), \
|
||||||
zc = OG(1, -1, z), \
|
zc = OG(1, -1, z), \
|
||||||
h = C(hp, A(M(zc, hp), M(z, c))), \
|
h = C(hp, A(M(zc, hp), M(z, c))), \
|
||||||
y = h'
|
y = h'
|
||||||
```
|
```
|
||||||
|
|
||||||
We are using a few new tricks here -- first, we are defining `HS` as the size
|
We are using a few new tricks here -- first, we are defining `HS` as the size
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ The entirety of the program consists of a single iterated call to `printf(3)`.
|
|||||||
|
|
||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
int main() {
|
int main() {
|
||||||
while(*d) printf(fmt, arg);
|
while(*d) printf(fmt, arg);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -316,8 +316,8 @@ One option would be to implement the logic as
|
|||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
printf()
|
printf()
|
||||||
while (*ok) {
|
while (*ok) {
|
||||||
scanf();
|
scanf();
|
||||||
printf();
|
printf();
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -326,8 +326,8 @@ implement it like this
|
|||||||
|
|
||||||
``` <!---c-->
|
``` <!---c-->
|
||||||
while (*ok) {
|
while (*ok) {
|
||||||
scanf();
|
scanf();
|
||||||
printf();
|
printf();
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ flagged.
|
|||||||
```
|
```
|
||||||
? ? ? ? ! ? ? ?
|
? ? ? ? ! ? ? ?
|
||||||
? 3 1 2 => ! 3 1 2
|
? 3 1 2 => ! 3 1 2
|
||||||
2 2 . . 2 2 . .
|
2 2 . . 2 2 . .
|
||||||
```
|
```
|
||||||
|
|
||||||
`A` and `B` are probed cells whose numbers are, respectively, 3 and 1. The
|
`A` and `B` are probed cells whose numbers are, respectively, 3 and 1. The
|
||||||
|
|||||||
+16
-16
@@ -29,7 +29,7 @@ snake's syllabary) for all snake and herpetologist programmers alike.
|
|||||||
* Modifications
|
* Modifications
|
||||||
|
|
||||||
- Modifying the colours
|
- Modifying the colours
|
||||||
- Background colour
|
- Background colour
|
||||||
- Modifying the characters for the wall, bug and snake
|
- Modifying the characters for the wall, bug and snake
|
||||||
- Modifying input keys
|
- Modifying input keys
|
||||||
- Modifying the status/score line
|
- Modifying the status/score line
|
||||||
@@ -40,7 +40,7 @@ snake's syllabary) for all snake and herpetologist programmers alike.
|
|||||||
- Health (and/or Lives)
|
- Health (and/or Lives)
|
||||||
- Saving the game
|
- Saving the game
|
||||||
- Different types of walls
|
- Different types of walls
|
||||||
- Blockades
|
- Blockades
|
||||||
- Diagonal movement
|
- Diagonal movement
|
||||||
- Special abilities
|
- Special abilities
|
||||||
- Obstacles
|
- Obstacles
|
||||||
@@ -228,27 +228,27 @@ More generally the following expressions and data types (with format specifiers)
|
|||||||
come to mind as information that might be of interest.
|
come to mind as information that might be of interest.
|
||||||
|
|
||||||
```
|
```
|
||||||
DESCRIPTION EXPRESSION TYPE FORMAT SPECIFIER
|
DESCRIPTION EXPRESSION TYPE FORMAT SPECIFIER
|
||||||
|
|
||||||
Snake size A size_t %zu
|
Snake size A size_t %zu
|
||||||
|
|
||||||
Y coordinate Y int %d
|
Y coordinate Y int %d
|
||||||
of snake head
|
of snake head
|
||||||
|
|
||||||
X coordinate X int %d
|
X coordinate X int %d
|
||||||
of snake head
|
of snake head
|
||||||
|
|
||||||
Max snake size g size_t %zu
|
Max snake size g size_t %zu
|
||||||
|
|
||||||
Bugs eaten c size_t %zu
|
Bugs eaten c size_t %zu
|
||||||
|
|
||||||
Bug line (Y) *U int %d
|
Bug line (Y) *U int %d
|
||||||
|
|
||||||
Bug column (X) *V int %d
|
Bug column (X) *V int %d
|
||||||
|
|
||||||
Snake size A size_t %zu
|
Snake size A size_t %zu
|
||||||
|
|
||||||
Growth size (per N size_t %zu
|
Growth size (per N size_t %zu
|
||||||
bug)
|
bug)
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -398,10 +398,10 @@ 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 (p && !(*O>=O[1]||H>=M(1)))
|
||||||
{
|
{
|
||||||
if (X<1||X>=H)
|
if (X<1||X>=H)
|
||||||
X = X<1?H-1:1;
|
X = X<1?H-1:1;
|
||||||
if (Y<2||Y>=*O)
|
if (Y<2||Y>=*O)
|
||||||
Y = Y<2?*O-1:2;
|
Y = Y<2?*O-1:2;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
+11
-11
@@ -161,8 +161,8 @@ Here are some other features of the game:
|
|||||||
* A drawing/practising mode (**WAIT** < 0 makes `timeout()` block).
|
* A drawing/practising mode (**WAIT** < 0 makes `timeout()` block).
|
||||||
|
|
||||||
* Computer plays the game (**WAIT=0**).<br>
|
* Computer plays the game (**WAIT=0**).<br>
|
||||||
- **EPILEPSY/STIMULATION OVERLOAD WARNING** included in the relevant
|
- **EPILEPSY/STIMULATION OVERLOAD WARNING** included in the relevant
|
||||||
section (this goes for a low **EVADE** value too).
|
section (this goes for a low **EVADE** value too).
|
||||||
|
|
||||||
* Grow-Shrink mode (Positive and Negative Winning) mode (see
|
* Grow-Shrink mode (Positive and Negative Winning) mode (see
|
||||||
[gameplay.html](gameplay.html) for more details).
|
[gameplay.html](gameplay.html) for more details).
|
||||||
@@ -234,15 +234,15 @@ very important.
|
|||||||
<div id="toc">
|
<div id="toc">
|
||||||
* ['Bugs'](#bugs)
|
* ['Bugs'](#bugs)
|
||||||
* [NAQs/IAQs - Never/Infrequently Asked Questions](#naqs)
|
* [NAQs/IAQs - Never/Infrequently Asked Questions](#naqs)
|
||||||
- [Do I have any inspirations for this entry?](#inspirations)
|
- [Do I have any inspirations for this entry?](#inspirations)
|
||||||
- [Are there any features I thought of that I wanted to implement but did not get to for some reason or another?](#features)
|
- [Are there any features I thought of that I wanted to implement but did not get to for some reason or another?](#features)
|
||||||
- [Are there ways that one can make this game easier?](#easier)
|
- [Are there ways that one can make this game easier?](#easier)
|
||||||
- [Are there ways to make it harder?](#harder)
|
- [Are there ways to make it harder?](#harder)
|
||||||
- [How do snakes grow in real life?](#moult)
|
- [How do snakes grow in real life?](#moult)
|
||||||
- [Any other interesting things about snakes?](#other)
|
- [Any other interesting things about snakes?](#other)
|
||||||
- [Why can you go the opposite direction and so immediately die when not cannibalising?](#opposite)
|
- [Why can you go the opposite direction and so immediately die when not cannibalising?](#opposite)
|
||||||
- [Do you have any **DELICIOUS CHOCOLATE CAKE** recipes?](#chocolatecake)
|
- [Do you have any **DELICIOUS CHOCOLATE CAKE** recipes?](#chocolatecake)
|
||||||
- [What are the files prog.alt.c, prog.2.c, prog-j.c and prog.alt.c ?](#alt)
|
- [What are the files prog.alt.c, prog.2.c, prog-j.c and prog.alt.c ?](#alt)
|
||||||
|
|
||||||
|
|
||||||
* [Winning thoughts, dedications and thanks](#winning)
|
* [Winning thoughts, dedications and thanks](#winning)
|
||||||
|
|||||||
@@ -184,8 +184,8 @@ rest of the snake has gone through). Doing `SHED=100 SHEDS=-1`:
|
|||||||
|
|
||||||
```
|
```
|
||||||
ooooooooo>ooo>
|
ooooooooo>ooo>
|
||||||
^
|
^
|
||||||
>
|
>
|
||||||
```
|
```
|
||||||
|
|
||||||
The `^` points to the part that's split from the snake and which will be
|
The `^` points to the part that's split from the snake and which will be
|
||||||
@@ -194,8 +194,8 @@ it being `SHEDS=-3`:
|
|||||||
|
|
||||||
```
|
```
|
||||||
<ooo<ooooo
|
<ooo<ooooo
|
||||||
^^^
|
^^^
|
||||||
<oo
|
<oo
|
||||||
```
|
```
|
||||||
|
|
||||||
If you go through the part that has split (which for some might be difficult
|
If you go through the part that has split (which for some might be difficult
|
||||||
@@ -258,7 +258,7 @@ adjusts the max snake size. For 10 lines and 10 columns you would see:
|
|||||||
terminal cols 10 (8 playable)
|
terminal cols 10 (8 playable)
|
||||||
|
|
||||||
snake size: 49 (max size: 49)
|
snake size: 49 (max size: 49)
|
||||||
bugs: 9 (max size: 9)
|
bugs: 9 (max size: 9)
|
||||||
|
|
||||||
at least 28 columns recommended for snake size 49 (is 10)
|
at least 28 columns recommended for snake size 49 (is 10)
|
||||||
at least 28 columns recommended for snake size 49 (is 10)
|
at least 28 columns recommended for snake size 49 (is 10)
|
||||||
|
|||||||
Loaded 100 of 117 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user