From dc538865afba3e5f14d7dda6485671c5554d3ea0 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 5 Dec 2023 13:05:16 -0800 Subject: [PATCH] Add alt code to 2014/maffiodo2 + try.sh script The alt code is from the author. The try.sh script has the example command provided by the judges as well as some by the author. One was removed because of a syntax error (removed from the author's examples). Format/typo check README.md file. The only thing that has to be done is to update the references to twitter to note how the IOCCC no longer endorses twitter or whatever the rocket destroyer wishes to call it (though certainly it won't be worded like that :-) ). --- 2014/maffiodo2/Makefile | 8 ++++-- 2014/maffiodo2/README.md | 54 +++++++++++++++++++++++++++++++----- 2014/maffiodo2/prog.alt.c | 1 + 2014/maffiodo2/try.sh | 58 +++++++++++++++++++++++++++++++++++++++ bugs.md | 9 ++++++ thanks-for-fixes.md | 7 +++++ 6 files changed, 128 insertions(+), 9 deletions(-) create mode 100644 2014/maffiodo2/prog.alt.c create mode 100755 2014/maffiodo2/try.sh diff --git a/2014/maffiodo2/Makefile b/2014/maffiodo2/Makefile index 737778cfd..82b7456a4 100644 --- a/2014/maffiodo2/Makefile +++ b/2014/maffiodo2/Makefile @@ -113,8 +113,8 @@ OBJ= ${PROG}.o DATA= image.rgb TARGET= ${PROG} # -ALT_OBJ= -ALT_TARGET= +ALT_OBJ= ${PROG}.alt.o +ALT_TARGET= ${PROG}.alt ################# @@ -137,6 +137,10 @@ ${PROG}: ${PROG}.c alt: data ${ALT_TARGET} @${TRUE} + +${PROG}.alt: ${PROG}.alt.c + ${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} + # data files # data: ${DATA} diff --git a/2014/maffiodo2/README.md b/2014/maffiodo2/README.md index ac7880a22..be59bfd5b 100644 --- a/2014/maffiodo2/README.md +++ b/2014/maffiodo2/README.md @@ -4,6 +4,21 @@ make ``` +There is a 121 byte version provided by the author. See [Alternate +code](#alternate-code) below. + + +### Bugs and (Mis)features: + +The current status of this entry is: + +``` +STATUS: INABIAF - please **DO NOT** fix +``` + +For more detailed information see [2014 maffiodo2 in bugs.md](/bugs.md#2014-maffiodo2). + + ## To use: @@ -15,7 +30,28 @@ make ### Try: ```sh -cat image.rgb | ./prog ' .,:;!$#@' +./try.sh +``` + + +## Alternate code: + +This shorter version is provided by the author. It has a fixed ramp and so not +as fun but it's 121 bytes instead of 140. + + +### Alternate build: + + +```sh +make alt +``` + + +### Alternate use: + +```sh +cat image.rgb | ./prog.alt ``` @@ -34,14 +70,15 @@ get? And how many people will really understand the tweet? ### Remarks This program convert an image to an ASCII ART. The program reads a raw RGB image -from **stdin** and print the ASCII ART to **stdout**. +from `stdin` and print the ASCII ART to `stdout`. The build process will raise some warnings about: - declaration specifier missing, defaulting to 'int' - implicitly declaring library function -The program crash if run without parameters. +The program will crash if run without parameters. + ### Screen size @@ -60,13 +97,17 @@ Type this: cat image.rgb | ./prog " .:;Y0" ``` -You can use your own image. Convert the image to a raw RGB image, using imagemagick it's very simple: +You can use your own image. Convert the image to a raw RGB image. Using +ImageMagick it's very simple: ```sh convert -geometry 80x source.jpg image.rgb ``` -This program require one parameter, or crash. The parameter of the program is the *convertion ramp*. You can use different ramps or create your own (for ex. using some letters of your name). +This program require one parameter or it will crash. The parameter of the +program is the *conversion ramp*. You can use different ramps or create your own +(for example using some letters of your name). + These are some ramps you can try: ```sh @@ -74,7 +115,6 @@ These are some ramps you can try: ./prog " .:;Y0" ./prog " .:-=+*#%@" ./prog " .,:!-iots&8%#@$" -./prog "$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,"^`'. " ``` ### 121 byte version @@ -85,7 +125,7 @@ An alternative version of this program is only 121bytes long: d=80,e,j;g(){j+=getchar();}main(){for(;;){j=0;g();if(j<0)break;g(g());putchar(" .:#@"[j/3*5>>8]);if(!(++e%d))puts("");}} ``` -This alternative version have a **fixed ramp**. It's smaller but it's not so fun to use... +This alternative version has a **fixed ramp**. It's smaller but it's not so fun to use... ## Copyright and CC BY-SA 4.0 License: diff --git a/2014/maffiodo2/prog.alt.c b/2014/maffiodo2/prog.alt.c new file mode 100644 index 000000000..6115cd506 --- /dev/null +++ b/2014/maffiodo2/prog.alt.c @@ -0,0 +1 @@ +d=80,e,j;g(){j+=getchar();}main(){for(;;){j=0;g();if(j<0)break;g(g());putchar(" .:#@"[j/3*5>>8]);if(!(++e%d))puts("");}} diff --git a/2014/maffiodo2/try.sh b/2014/maffiodo2/try.sh new file mode 100755 index 000000000..bad1431ef --- /dev/null +++ b/2014/maffiodo2/try.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2014/maffiodo2 +# + +# 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 CC="$CC" all >/dev/null || exit 1 + +# clear screen after compilation so that only the entry is shown +clear + +echo "$ cat image.rgb | ./prog ' .,:;!$#@'" 1>&2 +read -r -n 1 -p "Press any key to run command (space = next page, q = quit): " +echo 1>&2 +# ^-------^ SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# shellcheck disable=SC2002 +cat image.rgb | ./prog ' .,:;!$#@' | less -EXF + +echo "$ cat image.rgb | ./prog ' .:;Y0'" 1>&2 +read -r -n 1 -p "Press any key to run command (space = next page, q = quit): " +echo 1>&2 +# ^-------^ SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# shellcheck disable=SC2002 +cat image.rgb | ./prog " .:;Y0" | less -EXF + +echo "$ cat image.rgb | ./prog ' :1'" 1>&2 +read -r -n 1 -p "Press any key to run command (space = next page, q = quit): " +echo 1>&2 +# ^-------^ SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# shellcheck disable=SC2002 +cat image.rgb | ./prog ' :1' | less -EXF + +echo "$ cat image.rgb | ./prog ' .:;Y0'" 1>&2 +read -r -n 1 -p "Press any key to run command (space = next page, q = quit): " +echo 1>&2 +# ^-------^ SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# shellcheck disable=SC2002 +cat image.rgb | ./prog ' .:;Y0' | less -EXF + +echo "$ cat image.rgb | ./prog ' .:-=+*#%@'" 1>&2 +read -r -n 1 -p "Press any key to run command (space = next page, q = quit): " +echo 1>&2 +# ^-------^ SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# shellcheck disable=SC2002 +cat image.rgb | ./prog ' .:-=+*#%@' | less -EXF + +echo "$ cat image.rgb | ./prog ' .,:!-iots&8%#@$'" 1>&2 +read -r -n 1 -p "Press any key to run command (space = next page, q = quit): " +echo 1>&2 +# ^-------^ SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# shellcheck disable=SC2002 +cat image.rgb | ./prog ' .,:!-iots&8%#@$' | less -EXF diff --git a/bugs.md b/bugs.md index bc46279bf..c70d3f949 100644 --- a/bugs.md +++ b/bugs.md @@ -2988,6 +2988,15 @@ player become bigger, stay away from blocks! but since it's documented it's considered a feature, not a bug to fix. +## 2014 maffiodo2 + +### STATUS: INABIAF - please **DO NOT** fix +### Source code: [2014/maffiodo2/prog.c](2014/maffiodo2/prog.c) +### Information: [2014/maffiodo2/README.md](2014/maffiodo2/README.md) + +This program will very likely crash if no arg is given. + + ## 2014 vik ### STATUS: known bug - please help us fix diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 52a1fdc24..673a5f3a0 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -3722,6 +3722,13 @@ Great Giana Sisters](http://en.wikipedia.org/wiki/The_Great_Giana_Sisters), but which let one configure the width and height of the game. +## [2014/maffiodo2](2014/maffiodo2/prog.c) ([README.md](2014/maffiodo2/README.md])) + +[Cody](#cody) added the [try.sh](2014/maffiodo2/try.sh) script and the +[alternate code](2014/maffiodo2/README.md#alternate-code) provided by the +author. + + ## [2014/morgan](2014/morgan/prog.c) ([README.md](2014/morgan/README.md)) [Cody](#cody) added the [try.sh](2014/morgan/try.sh) script.