Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

on the wasting of time

Name: Anonymous 2012-11-02 8:38

An assignment is due tomorrow for my theoretical computer science class.

I have stayed up all night to work on it.

Rather than doing productive work I am spending my time writing a program in pic to format pretty trees.

Name: Anonymous 2012-11-02 10:42

>>7

Yay!


$ cat treegen.awk
{
    for(i=1; i<=NF; ++i){
        tree[(2^(NR-1)) + i - 1] = $i;
    }
}

END {
    for(i=1; i<(2^NR); ++i){
        printf("%d ", tree[i]);
    }
}
$ cat test.tree
         1
    2           3
 4    5     6     7
8 9 10 11 12 13 14 15
$ awk -f treegen.awk test.tree
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List