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

Fibonacci Butt Sort

Name: Anonymous 2009-08-16 23:08

Let us discuss the various implementations of theFIBONACCI BUTT SORT.

Name: Anonymous 2009-08-17 20:23

Hello, /prog/, How are you this fine, fine evening? I'll just leave this here...



import java.io.IOException;
import java.util.*;

class Tag
{
    private static Random generator = new Random(new Date().getTime());
    private static Tag[] tags = new Tag[]
    {
        new Tag("b"), new Tag("i"), new Tag("u"), new Tag("o"),
    };

    private String name;

    static Tag getRandomTag()
    {
        return tags[generator.nextInt(tags.length)];
    }

    private Tag(String name)
    {
        this.name = name;
    }

    public String getOpenForm()
    {
        return "[" + name + "]";
    }

    public String getClosedForm()
    {
        return "[/" + name + "]";
    }
}

public class Progifier
{
    public static void main(String[] args) throws IOException
    {
        Stack<Tag> tags = new Stack<Tag>();
        Random generator = new Random(new Date().getTime());

        while(System.in.available() > 0)
        {
            int b = System.in.read();

            if(generator.nextInt(10) == 0)
                System.out.print(tags.push(Tag.getRandomTag()).getOpenForm());

            System.out.write(b);

            if(generator.nextInt(50) == 0 && !tags.empty())
                System.out.print(tags.pop().getClosedForm());
        }

        while(!tags.empty())
            System.out.print(tags.pop().getClosedForm());
    }
}

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