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-16 23:09

Name: Anonymous 2009-08-16 23:11

Name: Anonymous 2009-08-16 23:14

>>1
U MENA BINARY DICKS TREE?

Name: Anonymous 2009-08-16 23:18

>>4
Dijkstra?

Name: Anonymous 2009-08-16 23:39

<3

Name: Anonymous 2009-08-16 23:42

What does (binary_dicks_tree)<(fibonacci_butt_sort) evaluate to?

Name: Anonymous 2009-08-17 0:15

>>7
Sorted Anuses.

Name: Anonymous 2009-08-17 2:33


a,b = 0,1
while 1:
    print b,
    a,b = b,a+b

Name: Anonymous 2009-08-17 11:03

>>8
In what order?

Name: Anonymous 2009-08-17 15:26

>>10
ANUSES[10] = {ANUS, ANUS, ANUS, ANUS, ANUS, ANUS, ANUS, ANUS, ANUS, ANUS, } ;

Name: Anonymous 2009-08-17 15:42

From this point forward, if anyone on /prog/ asks about data structures, I'm going to reply FIBONACCI BUTT SORT

Name: Anonymous 2009-08-17 15:43

>>1,12
Will you GPL your BBCode?

Name: Anonymous 2009-08-17 15:43

>>12
Don't you mean Haskell?

Name: Anonymous 2009-08-17 15:44

[b][i][u]F[/u][o]I[/o][u]B[/u][o]O[/o][u]N[/u][o]A[/o][u]C[/u][o]C[/o][u]I[/u] [o]B[/o][u]U[/u][o]T[/o][u]T[/u] [o]S[/o][u]O[/u][o]R[/o][u]T[/u][/i][/b]

Name: Anonymous 2009-08-17 15:48

Im writing a 'butt sorter' in JAVA to output the FBSorted BBCode for any text.

Name: Anonymous 2009-08-17 15:50

>>16
BUTT SORT FAILURE

JAVA

Name: Anonymous 2009-08-17 15:52

>>16
I hope you are going to use Fibonacci tail recursion to do it...

Name: Anonymous 2009-08-17 16:14



    FIBONACCI BUTT SORT

Name: Anonymous 2009-08-17 16:25

>>15
Thank you.

Name: Anonymous 2009-08-17 16:47

>>15
Did you mean: FIBONACCIBUTTSORT

Hint: BBCode tags don't work inside the [code] tag.

Name: Anonymous 2009-08-17 16:49

>>21
Your implementation needs work. Try skipping spaces

Name: Anonymous 2009-08-17 16:57

>>21
Did you mean to read the fucking thread?

Name: Anonymous 2009-08-17 17:05

>>21
lol no, that was just the source code.

Name: Anonymous 2009-08-17 17:11

>>1
WTF is this shit? And how do I implement it to my advantage?

Name: Anonymous 2009-08-17 17:32



(defun write-tag (tag string)
(if (null tag)
""
(format nil "[~a]~a[/~a]" tag string tag)))
(defun bb-buttsort (s)
"FIBONACCI BUTTSORT"
(write-tag "i"
(write-tag "b"
(apply #'concatenate 'string
    (loop for c across s
    and parity = nil then (not parity)
    collect (write-tag (if parity "o" "u") c))))))




(defun write-tag (tag string)
  (if (null tag)
      ""
      (format nil "[~a]~a[/~a]" tag string tag)))
(defun bb-buttsort (s)
  (write-tag "i"
   (write-tag "b"
    (apply #'concatenate 'string
       (loop for c across s
          and parity = nil then (not parity)
          collect (write-tag (if parity "o" "u") c))))))

Name: Anonymous 2009-08-17 17:33

FIBONACCI BUTT SORT

Name: >>26 2009-08-17 17:34

>>26
Seems it needs some more work :( But at least FIBONACCI BUTTSORT works

Name: Anonymous 2009-08-17 17:58

Here's my implementation:

buttSort = b . i . unwords . map concat $ map xmap fbf `xmap` fbs
  where fbf = cycle [u, o] : cycle [cycle [o, u]]
        fbs = map tacnoc . words $ "FIBONACCI BUTT SORT"

xmap = zipWith ($)
tacnoc = map (:[])

A bit of a kludge, to be honest. What I ought to have done is written a custom iterator function instead of juggling map and xmap, so it would be intrinsically aware of the space-skipping requirement and I wouldn't have to fuck with fbf.

FIBONACCI BUTT SORT

Name: Anonymous 2009-08-17 18:16

>>29
Like this?

buttSort = b . i . go (cycle [u, o])
  where go fs (' ':xs) = " " ++ go fs xs
        go (f:fs) (x:xs) = f [x] ++ go fs xs
        go _ [] = []

Name: Anonymous 2009-08-17 18:18

>>30
I THINK THE OUTPUT OF THIS VERSION IS ABSOLUTELY PERFECT

Name: Anonymous 2009-08-17 18:37

>>30
buttSort = b . i . go (cycle [u, o])  where go fs (' ':xs) = " " ++ go fs xs        go (f:fs) (x:xs) = f [x] ++ go fs xs        go _ [] = []

Name: Anonymous 2009-08-17 19:00

Testing my kludgy scheme buttsort

Name: Anonymous 2009-08-17 19:01

>>33
Whoops, used [sup]/[sub] instead of [o]/[u]
Testing my kludgy scheme buttsort

Name: Anonymous 2009-08-17 19:06

This works in PLT scheme. It's not the best solution, but I wanted to use unfold.
[code](require srfi/1)
(define (make-cycle x)
  (let ((clist (apply circular-list x)))
    (lambda ()
      (begin0
        (car clist)
        (set! clist (cdr clist))))))
(define bbcode-select
  (let ((c (make-cycle (list o u))))
    (lambda (x)
      (if (string=? x " ")
          " "
          ((c) x)))))
(define (buttsort x)
    (b (i (apply string-append (unfold null? (lambda (y) (bbcode-select (car y))) cdr (regexp-split #rx"" x))))))[code]

Name: Anonymous 2009-08-17 19:16

>>35
EXPERT BBCODE FAILURE

Name: Anonymous 2009-08-17 19:20

>>36
AmIforgiven?AmIforgiven?
AmIforgiven?AmIforgiven?
How about now?

Name: Anonymous 2009-08-17 19:29

>>37
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;No.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

Name: Anonymous 2009-08-17 19:30

>>38
EXPERT HTML FAILURE

Name: Anonymous 2009-08-17 19:53


                dicks
               /     \
              /       \
           dicks     dicks
           /   \     /   \
          /     *   /     \
       dicks      dicks  dicks
       /   \     /    \  /   \
      *   dicks *     * *    dicks

Name: Anonymous 2009-08-17 19:55

>>40
DICK TOWER is superior

Name: Anonymous 2009-08-17 20:21

>>41
NO ITS NOT!

A Dick Tower has a growth complexity of N, whereas a Binary Dicks Tree has an average growth complexity of only log(N).

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

Name: Anonymous 2009-08-17 20:29

>>43
Finally, something useful written in Java It's still too verbose

Name: Xarn 2009-08-17 20:29

>>42
If I enter 100 into my ENTERPRISE DICKS MACHINE I want 100 delicious dicks to come out, not 2.

Name: Anonymous 2009-08-17 20:32

>>43
Ne[i]w and imp[u]roved[o] [code]wit[o]h more[spoiler] tags![m]
[/m][/spoiler][/o][/code][/o][/u][/i]

diff
[m]
9a10
        new Tag("spoiler"), new Tag("m"), new Tag("code")
[/m]

Name: Anonymous 2009-08-17 21:15

Gentlemen, have you heard of the magical spirit conjuring technology called a METACIRCULAR BOOBULATOR ?

Name: Anonymous 2009-08-17 22:07

>>47
The Pleasure of being Metacircularly Boobulated inside.

Name: Anonymous 2009-08-18 0:11

>>48
i came

Name: Anonymous 2009-08-18 0:11

>>48
i came

Name: Anonymous 2009-08-18 4:34

Ne[i]w and imp[u]roved[o] [code]wit[o]h more[spoiler] tags![m]
[/m][/spoiler][/o][/code][/o][/u][/i]

Name: Anonymous 2009-08-18 4:51

GENTLEMEN

Name: Anonymous 2009-08-18 13:01

>>1
Is it Butt Sort or Buttsort?

Name: Anonymous 2009-08-18 13:04

BUTTSORT

Name: Anonymous 2009-08-18 15:31

FIBONACCI BUTT SORT

Name: Anonymous 2009-08-18 17:24

>>53
You're confusing it with a buttburst.

Name: Anonymous 2009-08-19 3:56

?>>56

Name: Anonymous 2009-08-19 4:32

>>56
You're confusing sage with age.

Name: Anonymous 2009-08-19 4:47

>>58
Fuck you, dipshit.

Name: Anonymous 2009-08-23 22:23

jjjj

Name: Anonymous 2009-08-24 12:12

Anybody have the source code for a buttsorter yet?

Name: Anonymous 2009-08-24 12:32

Name: /prog/ announcer 2009-08-24 12:46

>>61
Please read the threads before contributing, thank you.

Name: Anonymous 2009-08-24 14:24

>>63
Sorry about that, I finally found the "Read entire thread" link. I thought the old posts were gone or something.

Name: Haxus the Buttsorter 2009-08-24 14:37

Haxus the Buttsorter

Name: Anonymous 2009-08-24 18:30

>>65
i approve

Name: Anonymous 2009-08-25 3:48

Guize I have written an implementation in C with UNICODE support.
[m][b][i]#include <stdio.h>
#include <wchar.h>
#include <string.h>
#include <locale.h>
#include <errno.h>

FILE* fffffffibonacci_butt_sort(FILE *s, size_t n)
{
    size_t i = 0;
    wint_t tags[] = {L'u', L'o'};
    wint_t c = WEOF;
   
    for(i = 0; i < n; ++i)
    {
        if((c = fgetwc(s)) == L'[u][/u]n')
        {
            fputwc(L'[u][/u]n', stdout);
            return s;
        }
        else if(iswspace(c))
        {
            fputwc(c, stdout);
        }
        else if(c != WEOF)
        {
            wprintf(L"[%lc]%lc[/%lc]", tags[(i%2)], c, tags[(i%2)]);
        }
        else
        {
            return NULL;
        }
    }
    return s;
}

int main()
{
    if(!setlocale(LC_CTYPE, NULL))
    {
        fwprintf(stderr, L"Warning: Locale not specified.[o][/o]n");
    }

    const size_t BUFFA_SIZE = 4096;
    wint_t c = WEOF;

    fputws(L"[b][i]", stdout);

    while((c = fgetwc(stdin)) != WEOF)
    {
        if(ungetwc(c, stdin) == WEOF)
        {
            fputws(L"Failed to ungetwc<span class="o">.[u][/u]n", stderr);
            break;
        }

        if(!fffffffibonacci_butt_sort(stdin, BUFFA_SIZE))
        {
            break;
        }
    }

    fputws(L"[/i][/b<span class="o">][u][/u]n", stdout);

    if(ferror(stdin))
    {
        perror(strerror(errno));
        fputws(L"Input error occured. Output probably corrupted."
                "Shit fucking sucks.[u][/u]n", stderr);
    }

    return 0;
}
[/i][/b][/m]


[code]#include <stdio.h>
#include <wchar.h>
#include <string.h>
#include <locale.h>
#include <errno.h>

FILE* fffffffibonacci_butt_sort(FILE *s, size_t n)
{
    size_t i = 0;
    wint_t tags[] = {L'u', L'o'};
    wint_t c = WEOF;
   
    for(i = 0; i < n; ++i)
    {
        if((c = fgetwc(s)) == L'\n')
        {
            fputwc(L'\n', stdout);
            return s;
        }
        else if(iswspace(c))
        {
            fputwc(c, stdout);
        }
        else if(c != WEOF)
        {
            wprintf(L"[%lc]%lc[/%lc]", tags[(i%2)], c, tags[(i%2)]);
        }
        else
        {
            return NULL;
        }
    }
    return s;
}

int main()
{
    if(!setlocale(LC_CTYPE, NULL))
    {
        fwprintf(stderr, L"Warning: Locale not specified.\n");
    }

    const size_t BUFFA_SIZE = 4096;
    wint_t c = WEOF;

    fputws(L"[b][i]", stdout);

    while((c = fgetwc(stdin)) != WEOF)
    {
        if(ungetwc(c, stdin) == WEOF)
        {
            fputws(L"Failed to ungetwc.\n", stderr);
            break;
        }

        if(!fffffffibonacci_butt_sort(stdin, BUFFA_SIZE))
        {
            break;
        }
    }

    fputws(L"[/i][/b]\n", stdout);

    if(ferror(stdin))
    {
        perror(strerror(errno));
        fputws(L"Input error occured. Output probably corrupted."
                "Shit fucking sucks.\n", stderr);
    }

    return 0;
}[/code]

Here's an example for UTF-8 input:
[spoiler]Invalid or incomplete multibyte or wide character: Invalid or incomplete multibyte or wide character[/spoiler]

Name: Anonymous 2009-08-25 3:52

>>67
buttsort win

Name: Anonymous 2009-08-25 4:15

>>67
BBCode corruption? Lesse why did it fail.

FIBONACCI BUTT SORT

Name: Anonymous 2009-08-25 4:17

>>69
Looks like Shii-chan doesn't like Standard See in BBCode as in >>67 . :(

Name: Anonymous 2009-08-30 2:59

Bootstrapping my Directed Acyclic Buttsorter.

Here we go!

[b][i] import java.util.StringTokenizer; import javax.swing.JOptionPane; public class starter { public static void main(String args[]) { StringTokenizer st = new StringTokenizer(" "); String input = ""; String output = [u]"[b][i]";[/u] String next; int i = 1; input = JOptionPane.showInputDialog("Enter Text"); try { st = new StringTokenizer(input); } catch(Exception e) { } while(st.hasMoreTokens()) { i = i * -1; next = st.nextToken(); if(i > 0) { next = "" + next + ""; } else { next = [u]"[o]"[/u] + next + "[/o]"; } output = output + " " + next; } output = output + "[/i][/b]"; System.out.println(output); JOptionPane.showInputDialog( null, "Enjoy your buttsort", "Buttsorter", JOptionPane.PLAIN_MESSAGE, null, null, output); } }[/i][/b]

Name: Anonymous 2009-08-30 3:12

What would the Sussman think about FBS?

Name: Anonymous 2009-08-30 4:57

Sometimes I wonder if The Sussman is actually tsundere for /prog/ and whenever I read a weird thread, I imagine him reading it and wincing and wondering what the fuck is this.

Name: Anonymous 2009-08-30 6:27

I am 12 Sussmans old and what is this

Name: Anonymous 2009-08-30 6:42

>>74

[u][o][i]Back to /b/, please.[/i][/o][/u]

Name: Anonymous 2009-08-30 10:10



    FIBONACCI BUTT SORT

Name: Anonymous 2009-08-30 12:10

>>76
My FIBONACCI BUTT hurts :(

Name: Anonymous 2009-08-30 13:15

>>77
FIBONACCI BUTTHERTZ

Name: Anonymous 2009-08-30 13:50

>>78
The official SI unit for FIBONACCI BUTTSORT

Name: Anonymous 2009-08-30 14:44

>>79

The background level is 50Hz. This value must be subtracted from all readings to estimate the real one.

Name: Anonymous 2009-08-30 14:54

>>80
So that means that I am being buttsorted at a minimum of 50Hz right now at this very moment?

Name: Anonymous 2009-08-30 15:07

>>81
Without a shadow of a doubt yes. Don't worry it's entirely normal.

Name: Anonymous 2009-08-30 17:02

>>82
Unless of course, a second buttsort was being propagated in his proximity at 50Hz with an identical amplitude and 90 degree phase offset from the backround nose. Thus canceling out all active buttsorting.

Name: Anonymous 2009-08-30 17:04

>>83
EE major detected.

Name: Anonymous 2009-08-30 17:10

>>84
Wave polarisation was a high school physics topic

Name: Anonymous 2009-08-30 18:21

>>85
I just realised that I misread >>83, he is talking about interference not polarisation I'm a retard :(

Name: Anonymous 2009-08-30 21:48

>>85
Interference was also a high school physics topic.

Name: Anonymous 2009-08-31 4:37

>>86
Don't be too hard on yourself. Buttsort is hard at first.

Name: Anonymous 2009-09-02 22:53

I AM AFRAID THAT I ACCIDENTLY MADE A BUTTSORTER

Name: Anonymous 2009-09-02 22:56

>>89
OH MY, OH MY
void buttsort(char* out,char* in){
    strcpy(out,"[b][i]");
    out += 6;
    int i,c=0;
    for(i=0;i<strlen(in);++i){
        if(c%2){
            strcpy(out,"[u]?[/u]");
        }else{
            strcpy(out,"[o]?[/o]");
        }
        out[3] = toupper(in[i]);
        out += 8;
        if(!isspace(in[i])) ++c;
    }
    strcpy(out,"[/i][/b]");
}

Name: Anonymous 2009-09-03 1:32

>>90
Now rewrite it in OCaml

Name: Anonymous 2009-09-03 1:38

>>91
Why not HASKELL ?

Name: Anonymous 2009-09-03 1:50

I thought we already had HASKAL and Common Lisp implementations?

Name: Anonymous 2009-09-03 1:56

>>90
BUTT-UGLY

Testing: testing buttsort

Name: Anonymous 2009-09-03 2:01

>>94
Providing a mIRC implementation.
Usage: /bs testing buttsort
Can be used as an identifier, e.g. $buttsort(testing buttsort)
Caveat: Will not function well at all if the output ends up being > 900 characters. This means that you can only do roughly 90 characters worth of input text.

alias bs { say $buttsort($$1-) }
alias bbcode { return $+($chr(91), $1, $chr(93)) }
alias endbbcode { return $bbcode($+($chr(47), $1)) }
alias buttsort {
  var %text = $$1-
  var %output = $bbcode(b) $+ $bbcode(i)
  var %i = 1
  var %ctr = 1
  var %t = $len(%text)
  while (%i <= %t) {
    var %g = $mid(%text, %i, 1)
    var %spacequantity = 0
    while (%i <= %t && %g == $chr(32)) {
      inc %i
      inc %spacequantity
      var %g = $mid(%text, %i, 1)
    }
    if (%i > %t && %spacequantity > 0) { break }
    if (%ctr == 1) {
      var %output = %output $+ $str($chr(32), %spacequantity) $+ $bbcode(u) $+ %g $+ $endbbcode(u)
      var %ctr = 0
    }
    else {
      var %output = %output $+ $str($chr(32), %spacequantity) $+ $bbcode(o) $+ %g $+ $endbbcode(o)
      var %ctr = 1
    }
    inc %i
  }
  var %output = %output $+ $endbbcode(i) $+ $endbbcode(b)
  return %output
}

Name: Anonymous 2009-09-03 2:23

>>95
Thank you sir.  I will be using this often.

Name: Anonymous 2009-09-03 2:26

Testing three words

Name: Anonymous 2009-09-03 2:39

Testing Polynomial Buttsort

Name: Anonymous 2009-09-03 2:42

PBS = Polynomial Buttsort (TEST 2)

Name: Anonymous 2009-09-03 2:44

Now featuring SPOILERS!

Name: Anonymous 2009-09-03 2:48

>>98
Kinda cool
>>99
Getting retarded
>>100
Diarrhea Buttsort

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