Most tweetable ASCII art 1-line converter in 140 bytes

maffiodo2 won the title “Most tweetable entry” in IOCCC 2014 (23rd), which certainly is the best title, you can’t find more suitable for it. Why? Because it only has 140 characters, if it isn’t a tweet, what could it be?


d=80,e,j;g(){j+=getchar();}main(a,b)char**b;{for(;;){j=0;g();if(j<0)break;g(g());putchar(b[1][j/3*strlen(b[1])>>8]);if(!(++e%d))puts("");}}

d=80 is the width of the ASCII, unfortunately, no setting for height. It reads a raw RGB image and a conversion ramp from command-line argument.

For example, using my Clip smile and the following ramp:


./prog ' .,:;!$#@' < cs.rgb

And I got this lengthy ASCII art, I don’t think the image aspect ratio is respected in generation:


,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,::::,::,,:,,,::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,:::::::::::::::,:,:,,,,:,:,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,::,,::,:,,:::::::::::,,:,,:,:,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,:,,,,::,,:,:;;::::::::::;;:,::,:::,:,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,:,,:,,:,::,;::::::::::::;,;:::::::::,::,::,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,::,,,:,,::,::::::::::::::::::;,::::::::::,:;;:,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,:;;:,,:::::::::;::;::::::::;;:;:::::::::::,::::,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,::::,::::::::::;:;;::::::::;;:;::::::::::::;,::,,,,:,,,,,,,,,,,,
,,,,,,,,,,,,,:,,:::;:::::::::::;::;::::::::;::;::::::::::::;:::::::,,,:,,,,,,,,,
,,,,,,,,,,,::::,:;,;:::::::::::;::;::::::::;::;:::::::::::;;,;:::::,:::,,,,,,,,,
,,,,,,,,,,,,,,:,:;,;;::::::::::;;:;::::::::!:;;:::::::::::;::;:::::::,,,,,,,,,,,
,,,,,,::,,,:::::,;::;::::::::::;;;;::::::::;;;::::::::::::;:;;:::::::::;:,,,,,,,
,,,,,::;:,::::::,:;:;::::::::::;;;;:::::;:;;:;;::::::::::;;:;::::::::::,::,,,,,,
,,,,,;:,;:,,::::::!:;;:::::::::;::;:::;:;;;;:;;::::::::::;;;;::::::::;:,:,,,,,,,
,,,,,:;,;;,:::::::;;;;::::::;;:;;;;:;;;;;;;;!;;;;::;:::::;:;;:::::::;;:::,,:,,,,
,,,,,,;::!::::::::;::;:::;::;;;;;;;;;;;;;;;;;;;;;;;:::;::;:;;:::::::;::;,:,:,,,,
,,,,,,;;,;;,:::::::;;;::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::::::;::;::::::,,,
,::::::!::!:::::::::;;::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:;:::::::;::;;::::::,,,
,:::::::!,;;:::::::::::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:;;;:::;;::;::::::::,,
,,::::::;;;;:::::::::::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::;;:;;:::::::::,,
,::::::::;::;:::::;;;:;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:;::;::::::::::::
:::::::::;::;:::;:;;;;;;;;;;;;;;;;;;;;;;;;;;;!;;;;;;;;;;;;;;;;;::;;;::::::::::::
::::::::::;;:::::;;;;;;;;;;;;;;;;;;!!!!!!;;;;!;;;;;;;;;;;;;;;;;;::;:::::::::::::
::::::::::::::::;;;;;;;;;;;;;;;;!!!!!!!!!!!;!;;!;!!!;;!;;;;;;;;;;;::::::::::::::
:::::::::::::::;;;;;;;;;;;;;;!!;!!!!!!!!!!!!!!!!!!!!!!!!;;;;;;;;;;;;::::::::::::
::::::::::::::;;;;;;;;;;;;!!!!!!!!!!!!!!!!!!!!!!!!;!!!!!;!!;;;;;;;;;;:::::::::::
::::::::::::;;;;;;;;;;;;;;;;;;;!!!!!!!!!!!!!!!;;;;!!!!!!!!;;;;;;;;;;;;::::::::::
:::::::::::;;;;;;;;;;;;;::::;;;;!!!!!!!!!!!!!;;;;::::;;;;!;;;;;;;;;;;;::::::::::
:::::::::;;;;;;;;;!;;;;:;;!!!!!:!!!!!!!!!!!!!;!!!!!;;:;;:;!;!!;;;;;;;;::::::::::
:::::::;::;;;;;;;;;;:!;;!;;;:;;;!!!!!!!!!!!!!!;;;:;;!;;!;;!;!!;;;;;;;;::::::::::
::::::::;;;;;;;;;;!;:;;::;;;!!!!!!!!!$!!!!!$!$!!!!;;;;;!;;!!!;;;;;;;;;;;;;::::::
::::::::;;;;;;;;;!;!!;;!!!!!$!!$!$$!$$$!!!$$$!$$$!!!!!!;!!!!!!;;;;;;;;;;;;::::::
::::::::;;;;;;;;!!!!!!!!!!!!$$$$$$!!$!$!!!$$$!$$$!!!!!!!!!!!!!;;;;;;;;;;;;;:::::
:::::::;;;;;;;;!!!!!!!!!!!!$!!$$$$$$$$$$!$$$$$$$$$!$$!!!!!!!!!;!!;;;;;;;;;::::::
::::::;;;;;;;;!!!!!!!!!!!!!$$$$$$$$$$$$$$$$$$$$$$$$$!!!!!!!!!;!!!!;;;;;;;;::::::
::::::;;;;;;;;;!!!!!!!!!!!!$$!!$$$$$$$$$$$$#$#$!$$$$!$!!!!!!!!!!!;;;;;;;;;;:::::
::::;;;;;;;;;!!!!!!!!!!!!$$$!!!!!!!$$$$$$$$$!!!!!$$$$$$!!!!!!!!!!;;;;;;;;;;;;:::
:::;;;;;;;;;!!!!!!!!!!$!!$$$!$$;$#!$$###$#$!$;!#!$$$$$$$$$$!!!!!!!;;;;;;;;;;::::
::::;;;;;;;;!!!!!!!!!!$$$$$$!$$;$$!########!#!!#!$$$$$$$$$$$!!!!!!;;;;;;;;;;;;:;
::;:;;;;;;;;;!!!!!!!!$$$$$$$;$!;!#;$######$!#!!$!!$$$$$$$$$$$!!!!!!;;;;;;;;;:;:;
::;;;;;;;;!!!!!!!!!!$$$$$$$$!$!;!#;#######$!#;;$!!#$$$$$$$$$!!!!!!!!!;;;;;;;;:::
::;;;;;;;;;!!!!!!!$$$$$$$$$$!$!;!#;########!#!;#$;#$$$$$$$$$$$$$!!!!!;;;;;;;;;;:
:;;;;;;;;;;!!!!!!!!$$$$$$$$$;#!;$#;########!@!:#$;#$$$$$$$$!$$!!!!!!!;;;;;;;;;;:
:;;;;;;;;;!!!!!!!!!$$$$$$$$!;#!;$$;########;@$:#$;##$$$$$$$$$$$!!!!!!!;;;;;;;;;;
::;;;;;;;;!!!!!!!!$$$$$$$$#$!$!;!!;@#####@#;#$:!!!##$$$$$$$$$$!!!!!!!!;;;;;;;;;:
:;;;;;;;;;!!!!!!!$$!$$$$$$#$$#!!$$!########$#$;$#$$$$$$$$$$$$$$$!!!!!;;;;;;;;;::
:;;;;;;;;;!!!!!!!!$!$$$$$##!$#!!##!@##@#@##$@#;##!$#$$$$$$$$$$$!!!!!!;;;;;;;;;;;
:;;;;;;;;;!!!!!!!!!$$$$$$$##!!$$!!#@#@#@@@@!#$$$!!#####$$$$$$$$!!!!!!!!;;;;;;;;:
:;;;;;;;;!!!!!!!!!!!$$$$$#########@###@#@@@#$$@########$$$$$$$$!!!!!!!!!;;;;;;::
;;;;;;;;;!!!!!!!!!!$$$$$$$######@@#@@@@@@@@#@@##@#####$$$$$$$$!!!!!!!!!;;;;;;;::
:;;;;;;;!!!!!!!!!!$$$$$$$$$######@@@@@@@@#@@@@@@##@###$$$$$$$!!!!!!!!;!;;;;;;;;:
::;;;;;;!!!!!!!!!!$$$$$$$$$######@@@@@@@@#@@@@#########$$$$$$!!!!!!!!;;;;;;;;;;;
::;;;;;;!!!!!!!!!!$$$$$$$$#####@@@@@@@@@@@@@@@@#@@###$$$$$$$$$$$!!!!;;;;;;;;;;::
::;;;;;;!!!!!!!!!$$$$$$$$$######@@@@@@@@@@@@@@@#@####$$$$$$$$$$!!!!;;;;;;;;;;;::
::;;;;;;!!!!!!!!!!$$$$$$$########@#@@@@@@@@@@@@@@@####$$$$$$$$$!!!!;;;;;;;;;;:::
::;;;;;;!!!!!!!!!$$$$$$$$#########@@@@@@@@@@@@@@@####$$$$$$$$$$!!!!!;;;;;;;:::::
::;;;;;!!!!!!!!!!$$$$$$$$#########@##@@@@@@@@@@@@####$$$$$$$$$!!!!!!;;;;;;;;;:::
:;;;;;;;!!!!!!!!;!$$$$$$###########@@@@@@@@@@@@@#####$$$$$$$$!!!!!!!;;;;;;;:::::
:;;;;;;;!!!!!!!;!;$$$$$$$###########@#@@@@###@@@######$$$$$$!!$;!!!!;;;;;::;::::
;;;;;;;;!!!!!!!;$!!$$$$################@@##############$$$$;!$!;!!!;;;;;;:::::::
:;;;;;;;;!!!!!!;;!;!$$$$$$#############@@############$$$$$!;!!;!!!!;;;;;;;::::::
::;;;;;;!!!!!!!!:!;;$$$$###############@###############$$$;!!;;!!!;;;;;;;;;;::::
::;;;;;;;;!!!!!!;;!;$$$$##############################$$$!;$!;!!!!;;;;;;;;::::::
:;;;;;;;;;!!!!!!;;$;!$$$$############################$$$$;!$;;!!!!!;;;;;;;;:::::
::;;;;;;;;;!!!!!!;!!;$$$$############################$$$!;!!;!!!!!;;;;;;;;::::::
::;;;;;;;;;;!!!!!;;!;!$$$$######################$##$$$$$!!!;;!!!!!!!;;;;;;::::::
:;;;;;;;;;;;!!!!!!;!!!$$$$$$####################$$$$$$$$;$!;!!!!!!!!;;;;;;;:::::
:;;;;;;;;;;;!!!!!!;$!!$$$$$$$###################$$$$$$$!;!;;!!!!!!!!!;;;;:;;::::
::;:;;;;;;;;!!!!!!!;;;!!!!!$#####################$$!;;!!;!!!!!!!!!!!;;;;;:::::::
:::;;;;;;;;;;!!!!!$!!;$$!!;;!$$################$$;;;!$$$;!!!!!!!!!!!;;;;;:::::::
::;;:;;;;;;;;!!!!!!!!!!!!$$$!;!!$#$##########$!!;!$$$;;;;!!!!!!!!!!;;;;;::::::::
:::;;;;;;;;;;!!!!!!!$$!!;;!$#$!$!!!!!!;!!!$$#!$$!$!;:;!!!!!!!!!!!!!;;;;;;:::::::
::::;:;;;;;;;;!!!!!!!!$$$!!;;!$#;;#$!$$$$$$!!!$#!;;!!$$!!!!!!!!!!!!!;;;;;:::::,,
:::::;;;;;;;;;;!!!!!!!!!$$$$$!!!!;$$!#$#####$!!!!!$$!!!!!!!!!!!!!;!!;;;;:::::::,
:::;;;;;;;;;;;;;;!!!!!!$$$$$$$$$$!!!;;;;;;!!!$$$$$$$!!!!!!!!!!!!!;;;;;;;;:::::::
:::::;;;;;;;;;;;!!!!!!!!$$$$$$$$$$#$$$$$$$$$$#$$$$$!!!!!!!!!!!!!!!!;;;;;::::::::
:::::;;;;;;;;;!!!;!!!!!!$$!$$$$$$$$$$$$$$$#$$$$$$$$!!!!!!!!!!!!!!;;;;;;;:::::::,
::::;;;;;;;;;;;;;;!!!!!!!!!$$$$$$$$$$$$$$$$$$$$$$$$!!!!!!!!!!!!!!;;;;;;::::::,,,
:::::;;;;;;;;;;;!!!!!!!!!!!!!$!$$$$$$$$$$$$$$$$$$$$!!!!!!!!!!!!!;;;;;;:::::::,,,

If 140 characters are still too long for you, the author also provided a 121-character version, which uses a fixed ramp:


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("");}}

maffiodo2 is written in C11, 2014-10-29, by Sandro Maffiodo, who also has another entry as homage to classic games.