diff --git a/2013/misaka/README.md b/2013/misaka/README.md index 4b1c4c816..73279cfc0 100644 --- a/2013/misaka/README.md +++ b/2013/misaka/README.md @@ -1,8 +1,8 @@ # Most catty - Don Yang - - +Don Yang
+
+ ## To build: @@ -10,7 +10,8 @@ make ``` -This will build a bunch of versions of the code. See the author's details for information on all of these builds. +This will build a bunch of versions of the code. See the author's details for +information on all of these builds. ## To run: @@ -42,6 +43,12 @@ seq 1 12 | ./horizontal_cat - - - seq -f '%.0f ' 45 | ./horizontal_cat - misaka.c ``` +Alternately you can just try: + +```sh +./demo.sh +``` + NOTE: Use - for standard input. For example: ```sh @@ -50,31 +57,32 @@ NOTE: Use - for standard input. For example: ## Judges' remarks: -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. +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 [Island Sky](http://www.noble-caledonia.co.uk/information/detail.asp?id=2&spid=76) -in the middle of the Atlantic Ocean waiting the +in the middle of the Atlantic Ocean waiting for the [total solar eclipse of 2013](http://en.wikipedia.org/wiki/Solar_eclipse_of_November_3,_2013) -the judge was stuck by a +the judge was struck by a [flying fish](http://en.wikipedia.org/wiki/Flying_fish). -While result the impact was that the -[Port](http://en.wikipedia.org/wiki/Port_wine) from Portugal was lost, the -[Grog](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. +While the result of the impact was that the +[Port](http://en.wikipedia.org/wiki/Port_wine) from Portugal was lost, but 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. -While I'm sure most cats would have preferred otherwise, -the flying fish was returned to *em*swim with the fishes*em*. :-) -No cats were harmed in the process of judging this entry. +While I'm sure most [cats](https://rationalwiki.org/wiki/Fun:Cat) would have +preferred otherwise, the flying fish was returned to *swim with the fishes*. :-) +No [cats](https://rationalwiki.org/wiki/Fun:Cat) were harmed in the process of +judging this entry. ## Author's remarks: ### Overview -Misaka is a file concatenation utility, with at least two modes of +`Misaka` is a file concatenation utility, with at least two modes of operation: ```sh @@ -86,16 +94,17 @@ 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...]` are a list of text file names. Use `-` to read from stdin. ### Details ### Horizontal cat -One of my favorite unix utilities is *cat*. The best thing about it was -that it was named "cat". That, and it's useful for quickly showing contents -of a file. Though it was primary meant for concatenating files, that -function only seem to work if I wanted to concatenate files vertically. +One of my favorite unix utilities is `cat`. The best thing about it was that it +was named "[cat](https://rationalwiki.org/wiki/Fun:Cat)". That, and it's useful +for quickly showing contents of a file. Though it was primary meant for +concatenating files, that function only seem to work if I wanted to concatenate +files vertically. I thought the lack of horizontal concatenation must have been an oversight, so I implemented this utility: @@ -105,15 +114,15 @@ cc misaka.c -o horizontal_cat ./horizontal_cat files... ``` -*horizontal_cat* concatenates files horizontally and write the output to -stdout. Each input file is padded with spaces on the right so that the +`horizontal_cat` concatenates files horizontally and write the output to +`stdout`. Each input file is padded with spaces on the right so that the 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 -example, if you have seq(1) in your shell, you can add line numbers to both -sides of misaka.c like this: +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 +example, if you have `seq(1)` in your shell, you can add line numbers to both +sides of [misaka.c](misaka.c) like this: ```sh seq -f ' %.0f ' 45 | ./horizontal_cat - misaka.c - @@ -121,12 +130,12 @@ seq -f ' %.0f ' 45 | ./horizontal_cat - misaka.c - ### Vertical cat -Because *horizontal_cat* must know the maximum width of all files before +Because `horizontal_cat` must know the maximum width of all files before writing any output, all files must be processed at least twice. To support -stdin, file must be buffered to memory. This lead to the feature that -*horizontal_cat* can be used to duplicate stdin. +`stdin`, file must be buffered to memory. This lead to the feature that +`horizontal_cat` can be used to duplicate `stdin`. -Seems like the stdin doubling feature might be useful even for concatenating +Seems like the `stdin` doubling feature might be useful even for concatenating files vertically, so I included a vertical mode. But supporting vertical mode with command line options would be no fun. Instead, vertical mode is enabled by concatenating the source code horizontally: @@ -137,8 +146,8 @@ gcc misaka2.c -o vertical_cat ./vertical_cat files... ``` -*vertical_cat* works more or less like *cat*, except you can use -*vertical_cat* to duplicate stdin: +`vertical_cat` works more or less like `cat`, except you can use +`vertical_cat` to duplicate `stdin`: ```sh ./vertical_cat - - @@ -146,9 +155,10 @@ gcc misaka2.c -o vertical_cat ### Long cat -After *horizontal_cat* and *vertical_cat*, I thought, maybe all I really -wanted was just more cats. So I implemented one more mode, this one is -enabled by concatenating misaka.c vertically: +After `horizontal_cat` and `vertical_cat`, I thought, maybe all I really wanted +was just more [cats](https://rationalwiki.org/wiki/Fun:Cat). So I implemented +one more mode, this one is enabled by concatenating [misaka.c](misaka.c) +vertically: ```sh ./vertical_cat misaka.c misaka.c > misaka3.c @@ -156,9 +166,9 @@ gcc misaka3.c -o long_cat ./long_cat ``` -*long_cat* outputs ASCII art of a cat to stdout. You can make this cat +`long_cat` outputs ASCII art of a cat to `stdout`. You can make this cat exponentially longer by concatenating more files vertically (up to 31 levels -high, depending on sizeof(int) for your compiler): +high, depending on `sizeof(int)` for your compiler): ```sh ./vertical_cat misaka.c misaka.c misaka.c > misaka4.c @@ -190,9 +200,10 @@ triangle like the following will not have horizontally expanded output: gcc misaka9.c -o same_as_long_cat ``` -Finally, if you lost track of how many misaka.c you have stacked together, -you can feed the source to a brainfuck interpreter to get a overview of how -the programs are stacked. Example: +Finally, if you lost track of how many [misaka.c](misaka.c) you have stacked +together, you can feed the source to a +[brainfuck](https://en.wikipedia.org/wiki/Brainfuck) interpreter to get an +overview of how the programs are stacked. Example: ```sh perl bf.pl misaka9.c @@ -200,43 +211,44 @@ perl bf.pl misaka9.c This outputs: - MISAKA - MISAKA MISAKA +``` +MISAKA +MISAKA MISAKA +``` ### Return value -*horizontal_cat* and *vertical_cat* will exit with zero status on success. +`horizontal_cat` and `vertical_cat` will exit with zero status on success. -If any input file fails to open, *horizontal_cat* and *vertical_cat* will -report the offending file name to stdout, and exit with nonzero status. +If any input file fails to open, `horizontal_cat` and `vertical_cat` will +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 +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: +`horizontal_cat` makes the following assumptions about input files: - * ASCII with LF end of line sequences. If CR-LF sequences are used, CR - characters will appear in the middle of output lines. - * All characters are of equal width, even tab characters. +* ASCII with LF end of line sequences. If CR-LF sequences are used, CR + characters will appear in the middle of output lines. +* All characters are of equal width, even tab characters. -Misaka has been verified to work on these following compiler+OS -combinations: +`Misaka` has been verified to work on these following compiler+OS combinations: - * gcc 4.6.3 on Linux 3.5.0-41 - * gcc 4.4.5 on Linux 2.6.32-5 - * gcc 4.3.5 on JS/Linux 2.6.20 - * gcc 4.8.1 on Windows (Cygwin and MingW) +* gcc 4.6.3 on Linux 3.5.0-41 +* gcc 4.4.5 on Linux 2.6.32-5 +* gcc 4.3.5 on JS/Linux 2.6.20 +* gcc 4.8.1 on Windows (Cygwin and MingW) -Misaka requires a C99 compiler due to the use of single line comments. -Misaka does not depend on any other C99 features. +`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 horizontally and vertically, while using single line comments in less than -half of the lines. *And* maintaining a meaningful layout while doing that. +half of the lines *and* maintaining a meaningful layout while doing that. There are other challenges too, of course, like getting a Brainfuck program to tile horizontally and vertically. Really, tiling code of any sort @@ -245,12 +257,12 @@ once. Other features to look for: - * Peculiar bits that switches horizontal cat to vertical cat. - * Run-length encoded long cat. - * Symmetric and recycled variable names. - * CRC of the source code in the source code. +* Peculiar bits that switches horizontal cat to vertical cat. +* Run-length encoded long cat. +* Symmetric and recycled variable names. +* CRC of the source code in the source code. -"gcc -Wall" should provide a hint to where the mode switch happens, it +`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 @@ -258,16 +270,16 @@ does not output any irrelevant other warnings (verified on 4.6.3). Extra files included in my submission are informational only, they are not needed for the program to work. - * bf.pl = a brainfuck interpreter, in case if you don't have one handy. - * spoiler.html = making of this program. +* [bf.pl](bf.pl) - a brainfuck interpreter, in case you don't have one handy. +* [spoiler.html](spoiler.html) - making of this program. -### About Misaka +### About `Misaka` -The name, layout, and functionality of Misaka is inspired by a particular +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/) +* [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/) ## Copyright and CC BY-SA 4.0 License: diff --git a/2013/misaka/demo.sh b/2013/misaka/demo.sh new file mode 100755 index 000000000..1a22107d8 --- /dev/null +++ b/2013/misaka/demo.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# make sure code compiled +make all || exit 1 + +echo "$ seq 1 12 | ./horizontal_cat - - -" +seq 1 12 | ./horizontal_cat - - - +sleep 1 + +echo "$ ./long_cat" +./long_cat +sleep 1 + +echo "$ ./long_faat_cat" +./long_faat_cat +sleep 1 + +echo "$ ./long_fat_cat" +./long_fat_cat +sleep 1 + +echo "$ ./loong_cat" +./loong_cat +sleep 1 + +echo "$ ./loooong_cat" +./loooong_cat +sleep 1 + +echo "$ ./loooooooong_cat" +./loooooooong_cat +sleep 1 + +echo "$ seq -f '%.0f ' 45 | ./horizontal_cat - misaka.c" +seq -f '%.0f ' 45 | ./horizontal_cat - misaka.c diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index de53a0762..d2eb0202b 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1779,6 +1779,13 @@ Further, after the file 2013/hou/doc/example.markdown was moved to this broke `make` which Cody also fixed. +## [2013/misaka](2013/misaka/misaka.c) ([README.md)[2013/misaka/README.md)) + +As there are a lot of commands to try, Cody added the +[demo.sh](2013/misaka/demo.sh) script to do this, sleeping for approximately 1 +second between commands. + + ## [2013/morgan1](2013/morgan1/morgan1.c) ([README.md](2013/morgan1/README.md)) Cody added explicit linking of libm (`-lm`) as not all systems do this