
Yahoo Logo ASCII Animation in 462 bytes of C (2011) - emartinelli
http://www.a1k0n.net/2011/06/26/obfuscated-c-yahoo-logo.html
======
a1k0n
Speaking of crazy ascii company logo animations, I never got a chance to golf
these down, but I made some with color and signed distance field ray marching:

[https://github.com/a1k0n/asciitracing](https://github.com/a1k0n/asciitracing)

~~~
userbinator
I think raymarching is an extremely elegant way to make complex scenes fit
into a tiny amount of space. These are my favourite articles on raymarching
because it shows just how compact they can be - a single mathematical
equation:

[http://iquilezles.org/www/articles/distfunctions/distfunctio...](http://iquilezles.org/www/articles/distfunctions/distfunctions.htm)

[http://iquilezles.org/www/articles/raymarchingdf/raymarching...](http://iquilezles.org/www/articles/raymarchingdf/raymarchingdf.htm)

Edit: The description for the "bridge" scene is interesting: "This is a sketch
really, but it never got completed, _due to the lack of artistic appealing of
the image_." I don't know if it's his extreme humility, but I think it
wouldn't be overexaggerating if I said it's one of the _best_ scenes on that
page.

~~~
anon4
One more crazy thing you can do with raymarching - smoothly twine any shape
into any other shape. Take any two signed distance fields, say they're defined
by the functions dist0(p) and dist1(p). Then you can do

    
    
        dist(p, t) = (1-t)*dist0(p) + t*dist1(p)
    

T doesn't have to be time-based, it can be space-based, so you have a shape
that's a cylinder on the bottom and a large sphere on top and here's a
mushroom
[https://www.shadertoy.com/view/lsSXWc](https://www.shadertoy.com/view/lsSXWc)

Edit: I have a very strong feeling that in most cases the resulting function
isn't a "proper" distance field, but you can still raymarch through it
normally.

------
cantrevealname
You can do super dense mathematical code in the ancient APL programming
language[1]. I wonder how even more tiny this program could get at the hands
of an APL expert if any still exist.

Here are some complete APL programs[2] to give a flavor of just how dense it
can get:

Sum integers from 1 to 100:

    
    
      +/ι100
    

Find all primes from 2 to a given number R:

    
    
      (∼R∈R◦.×R)/R←1↓ιR
    

Play Conway's Game of Life:

    
    
      life←{↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵}
    

[1]
[https://en.wikipedia.org/wiki/APL_%28programming_language%29](https://en.wikipedia.org/wiki/APL_%28programming_language%29)

[2]
[http://www.vaxman.de/publications/apl_slides.pdf](http://www.vaxman.de/publications/apl_slides.pdf)

~~~
robotmlg
I've always enjoyed this video of a guy showing how to write Conway's Game of
Life in APL, step by step:
[https://www.youtube.com/watch?v=a9xAKttWgP4](https://www.youtube.com/watch?v=a9xAKttWgP4)

------
inoop
My personal favorite is Viznut's classic signature:

    
    
        #include <math.h> /* outputs 8 kHz 8-bit unsigned pcm to stdout */
        main(v,i,z,n,u,t){for(v=-1;;)for(n=pow(/* gcc -lm sig.c;./a.out>/dev/dsp */
        1.06,"`cW`g[`cgcg[eYcb^bV^eW^be^bVecb^"[++v&31]+(v&64)/21),i=999;i;putchar(
        128+((8191&u)>i?0:i/8)-((8191&(z+=n))*i-->>16)))u+=v&1?t/2: (t=v&6?t:n/4);}
    

edit: fixed copy/paste error

~~~
a1k0n
I am a big fan of viznut also, and took the liberty of translating this into
Javascript so we can all hear it without trying to find a /dev/dsp analog (I
used ./viznut | sox -t raw -e unsigned -b 8 -r 8000 - -d):

[https://jsbin.com/tazeyoqoci/edit?html,output](https://jsbin.com/tazeyoqoci/edit?html,output)

Amazing work.

~~~
a1k0n
48kHz version, sounds slightly better:
[https://jsbin.com/zazifecaqe/1/edit?html,output](https://jsbin.com/zazifecaqe/1/edit?html,output)

------
onion2k
That's very cool.

You can do something similar using Chrome's console output. There used to be
an intro that worked by rendering a canvas as ascii but it's broken in newer
Chrome -
[http://sandbox.photonstorm.com/console.log/](http://sandbox.photonstorm.com/console.log/)
(it may work for other people). I figured out how it works and made a little
animation to explore the principle -
[http://ooer.com/console/i.html](http://ooer.com/console/i.html) (You'll need
to change the height of the console to fit 16 lines of output)

------
dheera
Wonder if someone can create a startup to do Obfuscated-C-Code-as-a-service.

~~~
cfarre
me too

------
hliyan
Perhaps we should consider replacing line count with something like "parameter
weighted statement count" as a measure of software size?

------
z3r0d4v3
if you have some time to kill...

[http://mnml.is/hn/jslinux.jpg](http://mnml.is/hn/jslinux.jpg)

------
cheeze
I always love these things. "X in Y lines of $language!"

Then you look at it and realize that a "line" is actually 20 different
statements minified.

I found jquery implemented in a single line![1]

[1] [https://jquery.com/download/](https://jquery.com/download/)

~~~
cryptoz
Yes, I don't see how this isn't

> Yahoo Logo ASCII Animation in one line of C (2011)

What's the difference between six lines of C and one line of C?

~~~
ghayes
Yeah, I think you have to count a semi-colon as a "line of C" for this to be
meaningful. It's still awesome none-the-less.

~~~
steckerbrett

        for(i=0;i<4;i++)
    

This is three lines?

~~~
eridal
Actually there are two types of ";", expression-separator (the one you
mentioned) and statement-separator (the one parent meant)

The problem with using those for code metrics is that many systems don't
require separators, like `if`, `for` and friends

~~~
a1k0n
FWIW, most of this code is actually contained inside for loop expressions,
since you can chain them together with commas and get away without using any
braces. Once that's done it's hard to even count "lines".

------
swiley
Maybe it would be better to just specify the length of the source file in
bytes, so we don't have these weird arguments about line length.

~~~
a1k0n
I went ahead and changed the title on my site, because I am also sick of that
comment.

~~~
dang
A little late, but we've followed suit above.

------
seyfulislam
Everything is six lines when you have semicolon.

