Merge pull request #1602 from xexyl/birken2013-try-alt
This commit is contained in:
8 files changed
+193
-101
No files matched your search
+71
-44
@@ -4,26 +4,32 @@
|
||||
make alt
|
||||
```
|
||||
|
||||
To see why we recommend the alternate version instead of the original version,
|
||||
see the [original code](#original-code) section.
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
To see why we recommend the alternate version instead of the original version,
|
||||
see the [original code](#original-code) section.
|
||||
|
||||
```sh
|
||||
./birken.alt < 17_columns_wide_paint_by_numbers_file
|
||||
```
|
||||
|
||||
To see why we recommend the alternate version instead of the original version,
|
||||
see the [original code](#original-code) section.
|
||||
|
||||
|
||||
### Try:
|
||||
|
||||
This alternate version, which we recommend that you use in order to see what is
|
||||
happening with modern systems, and to not flash colours too quickly, which can
|
||||
be problematic for some people, can be configured to different speeds by way of
|
||||
the value used in `usleep()`. The default is `-DZ=15000`.
|
||||
the value used in `usleep(3)`. The default is `-DZ=13500`.
|
||||
|
||||
To see the program run on each text file, try:
|
||||
|
||||
```sh
|
||||
./try.alt.sh
|
||||
```
|
||||
|
||||
If you have perl installed it will also try a random run.
|
||||
|
||||
Finding the 'right' default value was a fine line; the default, 15000
|
||||
microseconds (0.015 seconds), will take quite a while to finish but it allows
|
||||
@@ -35,13 +41,10 @@ compile time. If you wish to speed it up by 100% you can instead do:
|
||||
|
||||
```sh
|
||||
make clobber CDEFINE=-DZ=7500 alt
|
||||
./birken.alt < ioccc.txt
|
||||
|
||||
perl -e 'map{map{print int(rand()*8);}(0..16);print chr(10);}(0..30);' | tr '[0-4]' ' '| ./birken.alt
|
||||
|
||||
./try.sh
|
||||
```
|
||||
|
||||
and then try `birken.alt` as above.
|
||||
|
||||
If you wish to speed that up 200% you can use instead `-DZ=3750`. Doing this you
|
||||
might find the right value to your liking; use ctrl-c to terminate the program
|
||||
early but note that the terminal is likely to be messed up. Try:
|
||||
@@ -56,19 +59,29 @@ to make it sane again (running to completion will do that for you).
|
||||
|
||||
## Original code:
|
||||
|
||||
Should you wish to see the original without having to mess with the compiler
|
||||
line, try:
|
||||
The original code will run faster with modern systems which is likely to make it
|
||||
hard to see the art of the entry but you may do so if you wish.
|
||||
|
||||
|
||||
### Original build:
|
||||
|
||||
|
||||
```sh
|
||||
make clobber all
|
||||
make all
|
||||
```
|
||||
|
||||
Use `birken` as you would `birken.alt` above. To use the demo script with the
|
||||
original code, try:
|
||||
|
||||
### Original use:
|
||||
|
||||
Use `birken` as you would `birken.alt` above.
|
||||
|
||||
|
||||
### Original try:
|
||||
|
||||
To use the demo script with the original code, try:
|
||||
|
||||
```sh
|
||||
BIRKEN=birken ./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
PLEASE be careful if you are sensitive to flashing colours!
|
||||
@@ -101,11 +114,13 @@ This document is best viewed as an HTML file in a browser that supports animated
|
||||
|
||||
See the files: `*.txt`, `*.png` and `*.gif`.
|
||||
|
||||
|
||||
### Abstract
|
||||
|
||||
By rotating, positioning and dropping a predetermined sequence of pieces, this
|
||||
program exploits the mechanics of Tetris to generate arbitrary images.
|
||||
|
||||
|
||||
### Algorithm Overview
|
||||
|
||||
The algorithm converts pixels from a source image into squares in the
|
||||
@@ -143,6 +158,7 @@ would not be necessary.
|
||||
|
||||

|
||||
|
||||
|
||||
### Single Square Emitters
|
||||
|
||||
For reference, the names of the 7
|
||||
@@ -188,7 +204,7 @@ leave holes in the upper row.
|
||||
The minimal number of rows required above the protruding square is 3 and as
|
||||
shown repeatedly above, such patterns do exist. 20 squares is the minimal width
|
||||
required to fit a 16 pixel wide sprite. But, `20 * 3 + 1 = 61`, which is not
|
||||
divisible by 4 and hence not constructible out of
|
||||
evenly divisible by 4 and hence not constructible out of
|
||||
[tetriminos](https://en.wikipedia.org/wiki/Tetromino). However, a width of 21
|
||||
yields `21 * 3 + 1 = 64`, which can be built with 16 tetriminos. That width
|
||||
actually enables the algorithm to render sprites up to 17 pixels wide.
|
||||
@@ -210,6 +226,7 @@ tetriminos. As the images below show, those patterns do exist.
|
||||
|
||||

|
||||
|
||||
|
||||
### Platforms
|
||||
|
||||
Before a row is constructed, the algorithm inspects the row below it. If the
|
||||
@@ -242,6 +259,7 @@ Also, of the 19 possible ways to start constructing a platform on top of a `T`
|
||||
[tetrimino](https://en.wikipedia.org/wiki/Tetromino), only the 10 patterns shown
|
||||
above exist.
|
||||
|
||||
|
||||
### Program Input
|
||||
|
||||
The input sprite is represented textually. Digit characters `0` to `7`
|
||||
@@ -265,6 +283,7 @@ fed into standard input. Several examples take advantage of the
|
||||
Instead of using character `0`, internal regions marked as transparent are
|
||||
effectively rendered as black.
|
||||
|
||||
|
||||
### Program Output
|
||||
|
||||
The program conceptually uses [Tetris](https://en.wikipedia.org/wiki/Tetris) as
|
||||
@@ -275,6 +294,7 @@ rotating, positioning and dropping
|
||||
[tetriminos](https://en.wikipedia.org/wiki/Tetromino). This process is visually
|
||||
represented using ANSI escape sequences.
|
||||
|
||||
|
||||
### ANSImation
|
||||
|
||||
The rate at which the program plays
|
||||
@@ -283,7 +303,8 @@ rate in which the terminal application receives and displays the [ANSI
|
||||
escape](https://en.wikipedia.org/wiki/ANSI_escape_code) sequences.
|
||||
|
||||
To slow down the output programmatically, introduce a delay immediately after the
|
||||
call to `fflush()` (N.B: see [birken.alt.c](birken.alt.c)).
|
||||
call to `fflush(3)` (N.B: see [birken.alt.c](birken.alt.c)).
|
||||
|
||||
|
||||
### IOCCC Size Tool Bug
|
||||
|
||||
@@ -311,6 +332,7 @@ Although this bug provides an easy means of circumventing contest rule 2, as
|
||||
demonstrated from the size value, this entry is not necessarily striving for a
|
||||
'worst abuse of the rules' award.
|
||||
|
||||
|
||||
### Obfuscations
|
||||
|
||||
This program is almost, but not quite, entirely unlike a demonstration of good
|
||||
@@ -378,6 +400,7 @@ with `Z`, necessitating a second list of 3-bit color values. Pairs of color
|
||||
values (6 bits) fit comfortably into a character that is offset by `#`. The
|
||||
result is a string of length 19.
|
||||
|
||||
|
||||
### Obfuscations
|
||||
|
||||
The program is full of subtle obfuscations:
|
||||
@@ -407,6 +430,7 @@ and 7 as longer.
|
||||
line also produces a prime-sized program. These properties do not qualify the
|
||||
program as a prime number generator.
|
||||
|
||||
|
||||
### Beyond Obfuscation
|
||||
|
||||
Due to the contest code size constraint, some optimizations reluctantly had to
|
||||
@@ -437,18 +461,20 @@ single emitted square.
|
||||
|
||||
The details of these enhancements are left as an exercise to the reader.
|
||||
|
||||
|
||||
### Example Files
|
||||
|
||||
The following example files were created by the program author. They can be freely used and distributed.
|
||||
The following example files were created by the program author. They can be
|
||||
freely used and distributed.
|
||||
|
||||
* [format.txt](format.txt) - The layout of the program
|
||||
* [helloworld.txt](helloworld.txt) - Hello World, Tetris-style
|
||||
* [hilbert.txt](hilbert.txt) - A graphic based on the Hilbert curve
|
||||
* [ioccc.txt](ioccc.txt) - IOCCC
|
||||
* [landon.txt](landon.txt) - Portrait of a man with glasses
|
||||
* [leo.txt](leo.txt) - Portrait of a man without glasses
|
||||
* [rhino.txt](rhino.txt) - A purple rhinoceros
|
||||
* [simon.txt](simon.txt) - Portrait of a man without hair
|
||||
* [format.txt](format.txt) - The layout of the program.
|
||||
* [helloworld.txt](helloworld.txt) - Hello World, Tetris-style.
|
||||
* [hilbert.txt](hilbert.txt) - A graphic based on the Hilbert curve.
|
||||
* [ioccc.txt](ioccc.txt) - IOCCC.
|
||||
* [landon.txt](landon.txt) - Portrait of a man with glasses.
|
||||
* [leo.txt](leo.txt) - Portrait of a man without glasses.
|
||||
* [rhino.txt](rhino.txt) - A purple rhinoceros.
|
||||
* [simon.txt](simon.txt) - Portrait of a man without hair.
|
||||
|
||||
The following files are based on graphics from non-free, copyrighted video
|
||||
games. The use of a limited number of textual representations of the graphics
|
||||
@@ -460,62 +486,63 @@ origin of each file is detailed below (character, game, company, year).
|
||||
* [belmont.txt](belmont.txt) - [Simon
|
||||
Belmont](https://en.wikipedia.org/wiki/Simon_Belmont),
|
||||
[Castlevania](https://en.wikipedia.org/wiki/Castlevania_(1986_video_game)),
|
||||
[Konami](https://en.wikipedia.org/wiki/Konami), 1986
|
||||
[Konami](https://en.wikipedia.org/wiki/Konami), 1986.
|
||||
|
||||
* [bloober.txt](bloober.txt) - Bloober, [Super Mario
|
||||
Brothers](https://www.mariowiki.com/Super_Mario_Bros.),
|
||||
[Nintendo](https://en.wikipedia.org/wiki/Nintendo), 1985
|
||||
[Nintendo](https://en.wikipedia.org/wiki/Nintendo), 1985.
|
||||
|
||||
* [bomberman.txt](bomberman.txt) -
|
||||
[Bomberman](https://en.wikipedia.org/wiki/Bomberman), Bomberman,
|
||||
[Hudson](https://en.wikipedia.org/wiki/Hudson_Soft), 1983
|
||||
[Hudson](https://en.wikipedia.org/wiki/Hudson_Soft), 1983.
|
||||
|
||||
* [boo.txt](boo.txt) - [Boo](https://www.mariowiki.com/Boo), [Super Mario
|
||||
Brothers 3](https://www.mariowiki.com/Super_Mario_Bros._3), Nintendo, 1988
|
||||
Brothers 3](https://www.mariowiki.com/Super_Mario_Bros._3), Nintendo, 1988.
|
||||
|
||||
* [bub.txt](bub.txt) - [Bub](https://bubblebobble.fandom.com/wiki/Bub), [Bubble
|
||||
Bobble](https://en.wikipedia.org/wiki/Bubble_Bobble), Taito, 1986
|
||||
Bobble](https://en.wikipedia.org/wiki/Bubble_Bobble), Taito, 1986.
|
||||
|
||||
* [cheepcheep.txt](cheepcheep.txt) - [Cheep
|
||||
Cheep](https://www.mariowiki.com/Cheep_Cheep), Super Mario Brothers, Nintendo, 1985
|
||||
Cheep](https://www.mariowiki.com/Cheep_Cheep), Super Mario Brothers, Nintendo,
|
||||
1985.
|
||||
|
||||
* [gurin.txt](gurin.txt) - Gurin, [Binary
|
||||
Land](https://en.wikipedia.org/wiki/Binary_Land), Hudson, 1983
|
||||
Land](https://en.wikipedia.org/wiki/Binary_Land), Hudson, 1983.
|
||||
|
||||
* [koopaparatroopa.txt](koopaparatroopa.txt) - [Koopa
|
||||
Paratroopa](https://www.mariowiki.com/Koopa_Paratroopa), Super Mario Brothers,
|
||||
Nintendo, 1985
|
||||
Nintendo, 1985.
|
||||
|
||||
* [lakitu.txt](lakitu.txt) - [Lakitu](https://www.mariowiki.com/Lakitu), Super
|
||||
Mario Brothers, Nintendo, 1985
|
||||
Mario Brothers, Nintendo, 1985.
|
||||
|
||||
* [mario.txt](mario.txt) - [Fire Mario](https://www.mariowiki.com/Fire_Mario),
|
||||
Super Mario Brothers, Nintendo, 1985
|
||||
Super Mario Brothers, Nintendo, 1985.
|
||||
|
||||
* [mspacman.txt](mspacman.txt) - [Ms.
|
||||
Pac-Man](https://pacman.fandom.com/wiki/Ms._Pac-Man) and Ghost, Ms. Pac-Man,
|
||||
[Midway](https://en.wikipedia.org/wiki/Midway_Games), 1982
|
||||
[Midway](https://en.wikipedia.org/wiki/Midway_Games), 1982.
|
||||
|
||||
* [paranaplant.txt](paranaplant.txt) - [Piranha
|
||||
Plant](https://www.mariowiki.com/Piranha_Plant), Super Mario Brothers, Nintendo,
|
||||
1985
|
||||
1985.
|
||||
|
||||
* [samus.txt](samus.txt) - [Samus
|
||||
Aran](https://metroid.fandom.com/wiki/Samus_Aran),
|
||||
[Metroid](https://metroid.fandom.com/wiki/Metroid_(game)), Nintendo/[Intelligent
|
||||
Systems](https://en.wikipedia.org/wiki/Intelligent_Systems), 1986
|
||||
Systems](https://en.wikipedia.org/wiki/Intelligent_Systems), 1986.
|
||||
|
||||
* [toad.txt](toad.txt) - [Toad](https://www.mariowiki.com/Toad), Super Mario
|
||||
Brothers 2, Nintendo, 1987
|
||||
Brothers 2, Nintendo, 1987.
|
||||
|
||||
The origin of the remaining files are described below:
|
||||
|
||||
* [happyface.txt](happyface.txt) - Based on a
|
||||
[smiley](https://en.wikipedia.org/wiki/Smiley); original trademark of smiley
|
||||
[Smiley Company](https://en.wikipedia.org/wiki/The_Smiley_Company)
|
||||
[Smiley Company](https://en.wikipedia.org/wiki/The_Smiley_Company).
|
||||
|
||||
* [snoo.txt](snoo.txt) - 8-bit version of [Snoo](https://www.reddit.com/r/Snoo/),
|
||||
[Reddit](https://www.reddit.com)'s alien mascot
|
||||
[Reddit](https://www.reddit.com)'s alien mascot.
|
||||
|
||||
|
||||
## Copyright and CC BY-SA 4.0 License:
|
||||
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 2013/birken alt code
|
||||
|
||||
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
|
||||
# this way allows us to have the user specify a different compiler in an easy
|
||||
# way.
|
||||
if [[ -z "$CC" ]]; then
|
||||
CC="cc"
|
||||
fi
|
||||
|
||||
make clobber CC="$CC" everything >/dev/null || exit 1
|
||||
|
||||
# clear screen after compilation so that only the entry is shown
|
||||
clear
|
||||
|
||||
|
||||
trap 'reset; exit' 0 1 2 3 15
|
||||
|
||||
PERL="$(type -P perl)"
|
||||
|
||||
if [[ -n "$PERL" ]]; then
|
||||
read -r -n 1 -p "Press any key to try a random run: "
|
||||
perl -e 'map{map{print int(rand()*8);}(0..16);print chr(10);}(0..30);' | tr '[0-4]' ' '| ./birken.alt
|
||||
fi
|
||||
|
||||
for i in *.txt; do
|
||||
NAME="$(echo "$i" | awk '{ print toupper(substr($1,1,1)) substr($1,2)}'|sed -e 's/\.txt//g' \
|
||||
-e 's/Ioccc/IOCCC/g' -e 's/Mspacman/Ms Pac-Man/g' -e 's/Helloworld/Hello World/g' \
|
||||
-e 's/Cheepcheep/Cheep Cheep/g' -e 's/Happyface/Happy Face/g' -e 's/Paranaplant/Piranha Plant/g' \
|
||||
-e 's/Koopaparatroopa/Koopa Paratroopa/g')"
|
||||
read -r -n1 -p "Press any key to try $NAME: "
|
||||
./birken.alt < "$i"
|
||||
echo
|
||||
done
|
||||
clear
|
||||
+9
-6
@@ -9,24 +9,27 @@ if [[ -z "$CC" ]]; then
|
||||
CC="cc"
|
||||
fi
|
||||
|
||||
make CC="$CC" everything >/dev/null || exit 1
|
||||
make clobber CC="$CC" everything >/dev/null || exit 1
|
||||
|
||||
# clear screen after compilation so that only the entry is shown
|
||||
clear
|
||||
|
||||
if [[ -z "$BIRKEN" ]]; then
|
||||
BIRKEN="birken.alt"
|
||||
fi
|
||||
|
||||
trap 'reset; exit' 0 1 2 3 15
|
||||
|
||||
PERL="$(type -P perl)"
|
||||
|
||||
if [[ -n "$PERL" ]]; then
|
||||
read -r -n 1 -p "Press any key to try a random run: "
|
||||
perl -e 'map{map{print int(rand()*8);}(0..16);print chr(10);}(0..30);' | tr '[0-4]' ' '| ./birken
|
||||
fi
|
||||
|
||||
for i in *.txt; do
|
||||
NAME="$(echo "$i" | awk '{ print toupper(substr($1,1,1)) substr($1,2)}'|sed -e 's/\.txt//g' \
|
||||
-e 's/Ioccc/IOCCC/g' -e 's/Mspacman/Ms Pac-Man/g' -e 's/Helloworld/Hello World/g' \
|
||||
-e 's/Cheepcheep/Cheep Cheep/g' -e 's/Happyface/Happy Face/g' -e 's/Paranaplant/Piranha Plant/g' \
|
||||
-e 's/Koopaparatroopa/Koopa Paratroopa/g')"
|
||||
read -r -n1 -p "Press any key to try $NAME: "
|
||||
./"${BIRKEN}" < "$i"
|
||||
./birken < "$i"
|
||||
echo
|
||||
done
|
||||
clear
|
||||
+17
-3
@@ -5,6 +5,17 @@ make
|
||||
```
|
||||
|
||||
|
||||
### Bugs and (Mis)features:
|
||||
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2013 mills in bugs.md](/bugs.md#2013-mills).
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
@@ -57,6 +68,7 @@ n=1,setsockopt(s,SOL_SOCKET,SO_REUSEADDR,&n,sizeof n),
|
||||
at an appropriate spot in the code (an exercise left to the reader). However,
|
||||
as this limitation is documented, it is not technically a bug.
|
||||
|
||||
|
||||
### Details of Operation
|
||||
|
||||
The program wears many hats (not literally). It is
|
||||
@@ -73,7 +85,7 @@ displayed initially at a lower resolution and allowed to be progressively
|
||||
refined as time goes on. The ray tracer is integrally tied to the PNG encoder,
|
||||
casting rays in the Adam7 order. The web server uses PNG primarily because of
|
||||
PNG's ability to return data progressively, and not as you might think it being
|
||||
because the PNG standard is so obfuscated as to require both little- and
|
||||
because the PNG standard is so obfuscated as to require both little and
|
||||
big-endian encodings at different spec layers.
|
||||
|
||||
Since ray-tracing was an obvious choice to return to a web server, I needed
|
||||
@@ -83,7 +95,7 @@ inspiration (as I often do) from the IOCCC remarks file which says
|
||||
> At least one judge prefers to maintain the use of the leap-second
|
||||
> as part of the world's time standard.
|
||||
|
||||
Then it was obvious; The code should display the time. It is believed (but
|
||||
Then it was obvious; the code should display the time. It is believed (but
|
||||
not confirmed) that the code will, in fact, display leap seconds correctly.
|
||||
|
||||
To display the time, of course we would need a font. This font is encoded
|
||||
@@ -92,6 +104,7 @@ intended this use of whitespace for data compression, since their tool
|
||||
doesn't count whitespace in strings differently than whitespace outside of
|
||||
them.
|
||||
|
||||
|
||||
### User-modifiable Features
|
||||
|
||||
The code can be user-modified simply by changing the build command line.
|
||||
@@ -107,6 +120,7 @@ list above (three times the number of lights).
|
||||
* `-DEY=x,y,z` defines the position of the viewer (the eye point) for the scene.
|
||||
The eye is looking at the origin `(0, 0, 0)`.
|
||||
|
||||
|
||||
### Other Build Flags
|
||||
|
||||
The original program bound the server to `INADDR_ANY` to allow everyone to
|
||||
@@ -117,7 +131,7 @@ of innumerable post-ship late feature additions, I have modified the
|
||||
spherical symmetry of the source code. In addition, I have altered the word
|
||||
`sin_port` to the more family-friendly version `win_port` (via
|
||||
`-Dwin_port="sin_addr.s_addr=htonl(2130706433),R.sin_port"`) to protect against
|
||||
curious impressionable youth trying to learn about sockets on Internet.
|
||||
curious impressionable youth trying to learn about sockets on the Internet.
|
||||
|
||||
|
||||
## Copyright and CC BY-SA 4.0 License:
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ r(e-p-8); while(p!=e){ c^=*p++; for(j=0; 8>j; j++)c=c/2^c%2*3988292384; } r(~c);
|
||||
(); } void q(int c){ w(c); m+=c; m%=c=65521; n+=m; n%=c; } void T(F c){ c=.5+255
|
||||
*c; q(0>c?0:c>255?255:c); } struct sockaddr_in R; int main(){ time_t i; struct
|
||||
tm*b; R.win_port=8224; s=socket(R.sin_family=AF_INET,SOCK_STREAM,0); bind(s,
|
||||
(void*)&R, sizeof R); listen(s,1); for(; ; ){ k=accept(s,0,0); for(; ; ){ ++j;
|
||||
(void*)&R, sizeof R); listen(s,10); for(; ; ){ k=accept(s,0,0); for(; ; ){ ++j;
|
||||
read(k,p,1); if(*p=='\n') { if(3>j)break; j=0; } } m=1; u("\n\032\n\rGNP"
|
||||
"\211\n\r\n\r1 :hserfeR\n\rKO 002 0.1/PTTH"); Z("RDHI"); r(800); r(600); w
|
||||
(8); r(33554433); J(); Z(0); w(120); w(1); J(); i=time(0); b=localtime(&
|
||||
|
||||
+15
-20
@@ -26,21 +26,6 @@ make understanding
|
||||
|
||||
Also try:
|
||||
|
||||
```sh
|
||||
seq 1 12 | ./horizontal_cat - - -
|
||||
|
||||
./long_cat
|
||||
./long_faat_cat
|
||||
./long_fat_cat
|
||||
./loong_cat
|
||||
./loooong_cat
|
||||
./loooooooong_cat
|
||||
|
||||
seq -f '%.0f ' 45 | ./horizontal_cat - misaka.c
|
||||
```
|
||||
|
||||
Alternately you can just try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
```
|
||||
@@ -57,6 +42,7 @@ NOTE: Use - for standard input. For example:
|
||||
There is more to cat than [mere cats](http://cheezburger.com/1680494336). Be
|
||||
they tall, fat, long or squat, this source code is sure to amuse.
|
||||
|
||||
|
||||
#### Slight diversion
|
||||
|
||||
While one of the judges was reviewing this entry on the stern of the
|
||||
@@ -66,7 +52,7 @@ in the middle of the Atlantic Ocean waiting for the
|
||||
the judge was struck by a
|
||||
[flying fish](http://en.wikipedia.org/wiki/Flying_fish).
|
||||
While the result of the impact was that the
|
||||
[Port](http://en.wikipedia.org/wiki/Port_wine) from Portugal was lost, but the
|
||||
[Port](http://en.wikipedia.org/wiki/Port_wine) from Portugal was lost, the
|
||||
[Grog](https://web.archive.org/web/20130702003043/http://www.travelforpassion.com/grog-factory-cape-verde-santo-antao-cape-verde-1602-photo)
|
||||
from Cape Verde and the laptop containing this entry was saved.
|
||||
|
||||
@@ -92,7 +78,8 @@ cc misaka2.c -o vertical_cat
|
||||
./vertical_cat [files...] > [output]
|
||||
```
|
||||
|
||||
Where `[files...]` are a list of text file names. Use `-` to read from stdin.
|
||||
Where `[files...]` is a list of text file names. Use `-` to read from `stdin`.
|
||||
|
||||
|
||||
### Details
|
||||
|
||||
@@ -118,7 +105,7 @@ original text alignments are preserved.
|
||||
|
||||
If `-` is specified as a file name, `horizontal_cat` will read from `stdin`.
|
||||
Unlike `cat`, `horizontal_cat` loads all input to memory first. Thus you
|
||||
can specify `-` multiple times to get stdin multiplied horizontally. For
|
||||
can specify `-` multiple times to get `stdin` multiplied horizontally. For
|
||||
example, if you have `seq(1)` in your shell, you can add line numbers to both
|
||||
sides of [misaka.c](misaka.c) like this:
|
||||
|
||||
@@ -126,6 +113,7 @@ sides of [misaka.c](misaka.c) like this:
|
||||
seq -f ' %.0f ' 45 | ./horizontal_cat - misaka.c -
|
||||
```
|
||||
|
||||
|
||||
### Vertical cat
|
||||
|
||||
Because `horizontal_cat` must know the maximum width of all files before
|
||||
@@ -151,6 +139,7 @@ gcc misaka2.c -o vertical_cat
|
||||
./vertical_cat - -
|
||||
```
|
||||
|
||||
|
||||
### Long cat
|
||||
|
||||
After `horizontal_cat` and `vertical_cat`, I thought, maybe all I really wanted
|
||||
@@ -214,6 +203,7 @@ MISAKA
|
||||
MISAKA MISAKA
|
||||
```
|
||||
|
||||
|
||||
### Return value
|
||||
|
||||
`horizontal_cat` and `vertical_cat` will exit with zero status on success.
|
||||
@@ -224,6 +214,7 @@ report the offending file name to `stdout`, and exit with nonzero status.
|
||||
If `horizontal_cat` and `vertical_cat` ran out of memory, they will exit
|
||||
with nonzero status without outputting anything.
|
||||
|
||||
|
||||
### Compatibility
|
||||
|
||||
`horizontal_cat` makes the following assumptions about input files:
|
||||
@@ -242,6 +233,7 @@ with nonzero status without outputting anything.
|
||||
`Misaka` requires a C99 compiler due to the use of single line comments.
|
||||
`Misaka` does not depend on any other C99 features.
|
||||
|
||||
|
||||
### Obfuscation
|
||||
|
||||
Main obfuscation is in having a C program that compiles when tiled
|
||||
@@ -263,21 +255,24 @@ Other features to look for:
|
||||
`gcc -Wall` should provide a hint to where the mode switch happens, it
|
||||
does not output any irrelevant other warnings (verified on 4.6.3).
|
||||
|
||||
|
||||
### Extra files
|
||||
|
||||
Extra files included in my submission are informational only, they are not
|
||||
needed for the program to work.
|
||||
|
||||
* [bf.pl](bf.pl) - a brainfuck interpreter, in case you don't have one handy.
|
||||
* [bf.pl](bf.pl) - a perl brainfuck interpreter, in case you don't have one
|
||||
handy.
|
||||
* [spoiler.html](spoiler.html) - making of this program.
|
||||
|
||||
|
||||
### About `Misaka`
|
||||
|
||||
The name, layout, and functionality of `Misaka` is inspired by a particular
|
||||
stackable figure:
|
||||
|
||||
* [Google images](http://google.co.jp/search?q=%E3%83%9F%E3%82%B5%E3%82%AB%E7%9B%9B%E3%82%8A&tbm=isch)
|
||||
* [Kotobukiya](http://main.kotobukiya.co.jp/figure/tsubucole_tmi_misakamori/)
|
||||
* [Kotobukiya](https://web.archive.org/web/20140325175014/http://main.kotobukiya.co.jp/figure/tsubucole_tmi_misakamori/)
|
||||
|
||||
|
||||
## Copyright and CC BY-SA 4.0 License:
|
||||
|
||||
+27
-17
@@ -15,33 +15,43 @@ make CC="$CC" all >/dev/null || exit 1
|
||||
# clear screen after compilation so that only the entry is shown
|
||||
clear
|
||||
|
||||
echo "$ seq 1 12 | ./horizontal_cat - - -"
|
||||
read -r -n 1 -p "Press any key to run: seq 1 12 | ./horizontal_cat - - -: "
|
||||
echo 1>&2
|
||||
seq 1 12 | ./horizontal_cat - - -
|
||||
sleep 1
|
||||
echo 1>&2
|
||||
|
||||
echo "$ ./long_cat"
|
||||
read -r -n 1 -p "Press any key to run: ./long_cat: "
|
||||
echo 1>&2
|
||||
./long_cat
|
||||
sleep 1
|
||||
echo 1>&2
|
||||
|
||||
echo "$ ./long_faat_cat"
|
||||
read -r -n 1 -p "Press any key to run: ./long_faat_cat: "
|
||||
echo 1>&2
|
||||
./long_faat_cat
|
||||
sleep 1
|
||||
echo 1>&2
|
||||
|
||||
echo "$ ./long_fat_cat"
|
||||
read -r -n 1 -p "Press any key to run: ./long_fat_cat: "
|
||||
echo 1>&2
|
||||
./long_fat_cat
|
||||
sleep 1
|
||||
echo 1>&2
|
||||
|
||||
echo "$ ./loong_cat"
|
||||
read -r -n 1 -p "Press any key to run: ./loong_cat: "
|
||||
echo 1>&2
|
||||
./loong_cat
|
||||
sleep 1
|
||||
echo 1>&2
|
||||
|
||||
echo "$ ./loooong_cat"
|
||||
read -r -n 1 -p "Press any key to run: ./loooong_cat: "
|
||||
echo 1>&2
|
||||
./loooong_cat
|
||||
sleep 1
|
||||
echo 1>&2
|
||||
|
||||
echo "$ ./loooooooong_cat"
|
||||
./loooooooong_cat
|
||||
sleep 1
|
||||
read -r -n 1 -p "Press any key to run: ./loooooooong_cat (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
./loooooooong_cat | less -EX
|
||||
echo 1>&2
|
||||
|
||||
echo "$ seq -f '%.0f ' 45 | ./horizontal_cat - misaka.c"
|
||||
seq -f '%.0f ' 45 | ./horizontal_cat - misaka.c
|
||||
echo "Press any key to run: seq -f '%.0f ' 45 | ./horizontal_cat - misaka.c"
|
||||
read -r -n 1 -p "(space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
seq -f '%.0f ' 45 | ./horizontal_cat - misaka.c | less -EX
|
||||
echo 1>&2
|
||||
+17
-10
@@ -3481,13 +3481,12 @@ the same) so that as long as it runs to completion the terminal will be sane and
|
||||
the cursor will be visible. Using `atexit(3)` will not work if the program is
|
||||
killed and signals are ugly so this was not done.
|
||||
|
||||
Cody also added the [try.sh](2013/birken/try.sh) script and the
|
||||
alternate version (that has the above fix) which allows one to control how fast the painting is done,
|
||||
based on the author's recommendations, except that Cody made it configurable at
|
||||
compile time just like he did with other entries that use `usleep(3)`. The
|
||||
alternate version and the original version were swapped in the `To build`, `To
|
||||
run` and `Try` sections, with what is normally `Alternate code` being `Original
|
||||
code`.
|
||||
Cody also added the alt version that lets one control how fast the painting is
|
||||
done, based on the author's recommendations, except that Cody made it
|
||||
configurable at compile time.
|
||||
|
||||
Cody also added the [try.sh](2013/birken/try.sh) script for the entry and the
|
||||
[try.alt.sh](2013/birken/try.alt.sh) script for the alt code.
|
||||
|
||||
|
||||
## [2013/cable3](2013/cable3/cable3.c) ([README.md](2013/cable3/README.md]))
|
||||
@@ -3617,11 +3616,19 @@ Further, after the file 2013/hou/doc/example.markdown was moved to
|
||||
this broke `make` which Cody also fixed.
|
||||
|
||||
|
||||
## [2013/mills](2013/mills/mills.c) ([README.md)[2013/mills/README.md))
|
||||
|
||||
[Cody](#cody) fixed this so that the server would not refuse the connection
|
||||
after the first call to `close(2)`. The problem was that because the backlog to
|
||||
`listen(2)` was 1 once the connection closed the server was essentially 'dead'.
|
||||
The backlog was changed to 10 and this solves the problem. It is not known if
|
||||
this was specific to macOS but it was not specific to a browser as Safari and
|
||||
Firefox both had the problem.
|
||||
|
||||
|
||||
## [2013/misaka](2013/misaka/misaka.c) ([README.md)[2013/misaka/README.md))
|
||||
|
||||
As there are a lot of commands to try, [Cody](#cody) added the
|
||||
[try.sh](2013/misaka/try.sh) script to do this, sleeping for approximately 1
|
||||
second between commands.
|
||||
[Cody](#cody) added the [try.sh](2013/misaka/try.sh) script.
|
||||
|
||||
|
||||
## [2013/morgan1](2013/morgan1/morgan1.c) ([README.md](2013/morgan1/README.md))
|
||||
|
||||
Reference in new issue
Block a user