Skip to main content
Commonmark migration
Source Link

#AWK and friends. ##Look mom! I've shaken the colors away!

AWK and friends.

Look mom! I've shaken the colors away!

The 'x' file:

BEGIN {
    N=5
    C=2^N
    print "P3\n"2^(3*N-int(3*N/2))" "2^int(3*N/2)"\n"C-1
    for(x=0;x<C;x++)
        for(y=0;y<C;y++)
            for(z=0;z<C;z++)
                print x^4+y^4+z^4"\t"x" "y" "z | "sort -n | cut -f2-" 
}

Run:

awk -f x > x.ppm

Output:

N=5:

N=5.png

N=6:

N=6.png

#AWK and friends. ##Look mom! I've shaken the colors away!

The 'x' file:

BEGIN {
    N=5
    C=2^N
    print "P3\n"2^(3*N-int(3*N/2))" "2^int(3*N/2)"\n"C-1
    for(x=0;x<C;x++)
        for(y=0;y<C;y++)
            for(z=0;z<C;z++)
                print x^4+y^4+z^4"\t"x" "y" "z | "sort -n | cut -f2-" 
}

Run:

awk -f x > x.ppm

Output:

N=5:

N=5.png

N=6:

N=6.png

AWK and friends.

Look mom! I've shaken the colors away!

The 'x' file:

BEGIN {
    N=5
    C=2^N
    print "P3\n"2^(3*N-int(3*N/2))" "2^int(3*N/2)"\n"C-1
    for(x=0;x<C;x++)
        for(y=0;y<C;y++)
            for(z=0;z<C;z++)
                print x^4+y^4+z^4"\t"x" "y" "z | "sort -n | cut -f2-" 
}

Run:

awk -f x > x.ppm

Output:

N=5:

N=5.png

N=6:

N=6.png

removen mentioning netpbm in the title cause this program omly uses the ppm file format but no netpbm program...
Source Link
user19214
user19214

#AWK, netpbm and friends. ##Look mom! I've shaken the colors away!

The 'x' file:

BEGIN {
    N=5
    C=2^N
    print "P3\n"2^(3*N-int(3*N/2))" "2^int(3*N/2)"\n"C-1
    for(x=0;x<C;x++)
        for(y=0;y<C;y++)
            for(z=0;z<C;z++)
                print x^4+y^4+z^4"\t"x" "y" "z | "sort -n | cut -f2-" 
}

Run:

awk -f x > x.ppm

Output:

N=5:

N=5.png

N=6:

N=6.png

#AWK, netpbm and friends. ##Look mom! I've shaken the colors away!

The 'x' file:

BEGIN {
    N=5
    C=2^N
    print "P3\n"2^(3*N-int(3*N/2))" "2^int(3*N/2)"\n"C-1
    for(x=0;x<C;x++)
        for(y=0;y<C;y++)
            for(z=0;z<C;z++)
                print x^4+y^4+z^4"\t"x" "y" "z | "sort -n | cut -f2-" 
}

Run:

awk -f x > x.ppm

Output:

N=5:

N=5.png

N=6:

N=6.png

#AWK and friends. ##Look mom! I've shaken the colors away!

The 'x' file:

BEGIN {
    N=5
    C=2^N
    print "P3\n"2^(3*N-int(3*N/2))" "2^int(3*N/2)"\n"C-1
    for(x=0;x<C;x++)
        for(y=0;y<C;y++)
            for(z=0;z<C;z++)
                print x^4+y^4+z^4"\t"x" "y" "z | "sort -n | cut -f2-" 
}

Run:

awk -f x > x.ppm

Output:

N=5:

N=5.png

N=6:

N=6.png

removed vars W and H
Source Link
user19214
user19214

#AWK, netpbm and friends. ##Look mom! I've shaken the colors away!

The 'x' file:

BEGIN {
    N=5
    C=2^N
    W=2^print "P3\n"2^(3*N-int(3*N/2))
   " H=2^int"2^int(3*N/2)
    print "P3\n"W" "H"\n"C"\n"C-1
    for(x=0;x<C;x++)
        for(y=0;y<C;y++)
            for(z=0;z<C;z++)
                print x^4+y^4+z^4"\t"x" "y" "z | "sort -n | cut -f2-" 
}

Run:

awk -f x > x.ppm

Output:

N=5:

N=5.png

N=6:

N=6.png

#AWK, netpbm and friends. ##Look mom! I've shaken the colors away!

The 'x' file:

BEGIN {
    N=5
    C=2^N
    W=2^(3*N-int(3*N/2))
    H=2^int(3*N/2)
    print "P3\n"W" "H"\n"C-1
    for(x=0;x<C;x++)
        for(y=0;y<C;y++)
            for(z=0;z<C;z++)
                print x^4+y^4+z^4"\t"x" "y" "z | "sort -n | cut -f2-" 
}

Run:

awk -f x > x.ppm

Output:

N=5:

N=5.png

N=6:

N=6.png

#AWK, netpbm and friends. ##Look mom! I've shaken the colors away!

The 'x' file:

BEGIN {
    N=5
    C=2^N
    print "P3\n"2^(3*N-int(3*N/2))" "2^int(3*N/2)"\n"C-1
    for(x=0;x<C;x++)
        for(y=0;y<C;y++)
            for(z=0;z<C;z++)
                print x^4+y^4+z^4"\t"x" "y" "z | "sort -n | cut -f2-" 
}

Run:

awk -f x > x.ppm

Output:

N=5:

N=5.png

N=6:

N=6.png

Source Link
user19214
user19214
Loading