Fibonacci Butt Sort
1
Name:
Anonymous
2009-08-16 23:08
Let us discuss the various implementations of theF I B O N A C C I B U T T S O R T .
41
Name:
Anonymous
2009-08-17 19:55
>>40
DICK TOWER is superior
42
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).
43
Name:
Anonymous
2009-08-17 20:23
Hello, /prog/, How are you this fine, fin e evening? I'll just leave th is 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());
}
}
44
Name:
Anonymous
2009-08-17 20:29
>>43
Finally, something useful written in Java
It's still too verbose
45
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.
46
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]
47
Name:
Anonymous
2009-08-17 21:15
Gentlemen, have you heard of the magical spirit conjuring technology called a M E T A C I R C U L A R B O O B U L A T O R ?
48
Name:
Anonymous
2009-08-17 22:07
>>47
The Pleasure of being Metacircularly Boobulated inside.
49
Name:
Anonymous
2009-08-18 0:11
50
Name:
Anonymous
2009-08-18 0:11
51
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]
52
Name:
Anonymous
2009-08-18 4:51
GENTLEMEN
53
Name:
Anonymous
2009-08-18 13:01
>>1
Is it Butt Sort or Buttsort?
54
Name:
Anonymous
2009-08-18 13:04
BUTTSORT
55
Name:
Anonymous
2009-08-18 15:31
F I B O N A C C I B U T T S O R T
56
Name:
Anonymous
2009-08-18 17:24
>>53
You're confusing it with a buttburst.
57
Name:
Anonymous
2009-08-19 3:56
58
Name:
Anonymous
2009-08-19 4:32
>>56
You're confusing sage with age.
59
Name:
Anonymous
2009-08-19 4:47
60
Name:
Anonymous
2009-08-23 22:23
jjjj
61
Name:
Anonymous
2009-08-24 12:12
Anybody have the source code for a buttsorter yet?
62
Name:
Anonymous
2009-08-24 12:32
63
Name:
/prog/ announcer
2009-08-24 12:46
>>61
Please read the threads before contributing, thank you.
64
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.
66
Name:
Anonymous
2009-08-24 18:30
67
Name:
Anonymous
2009-08-25 3:48
Guize I have written an implementation in C with UNICODE support.
[m] [b] [i] # i n c l u d e < s t d i o . h >
# i n c l u d e < w c h a r . h >
# i n c l u d e < s t r i n g . h >
# i n c l u d e < l o c a l e . h >
# i n c l u d e < e r r n o . h >
F I L E * f f f f f f f i b o n a c c i _ b u t t _ s o r t ( F I L E * s , s i z e _ t n )
{
s i z e _ t i = 0 ;
w i n t _ t t a g s [ ] = { L ' u ' , L ' o ' } ;
w i n t _ t c = W E O F ;
f o r ( i = 0 ; i < n ; + + i )
{
i f ( ( c = f g e t w c ( s ) ) = = L ' [u][/u]n ' )
{
f p u t w c ( L ' [u][/u]n ' , s t d o u t ) ;
r e t u r n s ;
}
e l s e i f ( i s w s p a c e ( c ) )
{
f p u t w c ( c , s t d o u t ) ;
}
e l s e i f ( c ! = W E O F )
{
w p r i n t f ( L " [ % l c ] % l c [ / % l c ] " , t a g s [ ( i % 2 ) ] , c , t a g s [ ( i % 2 ) ] ) ;
}
e l s e
{
r e t u r n N U L L ;
}
}
r e t u r n s ;
}
i n t m a i n ( )
{
i f ( ! s e t l o c a l e ( L C _ C T Y P E , N U L L ) )
{
f w p r i n t f ( s t d e r r , L " W a r n i n g : L o c a l e n o t s p e c i f i e d . [o] [/o]n " ) ;
}
c o n s t s i z e _ t B U F F A _ S I Z E = 4 0 9 6 ;
w i n t _ t c = W E O F ;
f p u t w s ( L " [ b ] [ i ] " , s t d o u t ) ;
w h i l e ( ( c = f g e t w c ( s t d i n ) ) ! = W E O F )
{
i f ( u n g e t w c ( c , s t d i n ) = = W E O F )
{
f p u t w s ( L " F a i l e d t o u n g e t w c <span class="o">. [u][/u]n " , s t d e r r ) ;
b r e a k ;
}
i f ( ! f f f f f f f i b o n a c c i _ b u t t _ s o r t ( s t d i n , B U F F A _ S I Z E ) )
{
b r e a k ;
}
}
f p u t w s ( L " [ / i ] [ / b <span class="o">] [u][/u]n " , s t d o u t ) ;
i f ( f e r r o r ( s t d i n ) )
{
p e r r o r ( s t r e r r o r ( e r r n o ) ) ;
f p u t w s ( L " I n p u t e r r o r o c c u r e d . O u t p u t p r o b a b l y c o r r u p t e d . "
" S h i t f u c k i n g s u c k s . [u] [/u]n " , s t d e r r ) ;
}
r e t u r n 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]
68
Name:
Anonymous
2009-08-25 3:52
69
Name:
Anonymous
2009-08-25 4:15
>>67
BBCode corruption? Lesse why did it fail.
F I B O N A C C I B U T T S O R T
70
Name:
Anonymous
2009-08-25 4:17
>>69
Looks like Shii-chan doesn't like Standard See in BBCode as in
>>67 . :(
71
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]
72
Name:
Anonymous
2009-08-30 3:12
What would the Sussman think about FBS?
73
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.
74
Name:
Anonymous
2009-08-30 6:27
I am 12 Sussmans old and what is this
75
Name:
Anonymous
2009-08-30 6:42
>>74
[u][o][i]Back to /b/, please.[/i][/o][/u]
76
Name:
Anonymous
2009-08-30 10:10
F I B O N A C C I B U T T S O R T
77
Name:
Anonymous
2009-08-30 12:10
>>76
My
F I B O N A C C I B U T T hurts :(
78
Name:
Anonymous
2009-08-30 13:15
79
Name:
Anonymous
2009-08-30 13:50
>>78
T h e o f f i c i a l S I u n i t f o r F I B O N A C C I B U T T S O R T
80
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.
Newer Posts