r/dailyprogrammer • u/rya11111 3 1 • Mar 31 '12
[3/31/2012] Challenge #34 [intermediate]
Your task today is show the implementation of two sorting algorithms Stooge sort and Bogosort in anyway you like!
11
Upvotes
1
u/JerMenKoO 0 0 Mar 31 '12
I don't know what I'm doing wrong, but I got maximum recursion depth reached in python.
1
u/DanielJohnBenton 0 0 Mar 31 '12 edited Mar 31 '12
My bogosort appears to work. C++.
Output:
Edit: Seeded randomisation.
Edit #2: I'm guessing those conditions should be
<=in case of duplicates.Edit #3: Actually no, I'm just getting mixed up.
1
u/ixid 0 0 Mar 31 '12 edited Mar 31 '12
My StoogeSort is a carbon copy of the wikipedia one. Here's Bogosort (amusing to use another sort to make a sort work):
1
u/tanzoniteblack Mar 31 '12
My Python code. As expected, the bogosort takes a really really really really long time for arrays larger than size 4.
1
u/lawlrng_prog Mar 31 '12
Both algorithms blatantly stolen from Wikipedia. Really amusing sorts tho. =)
1
u/Steve132 0 1 Mar 31 '12
C++ bogosort:
C++ stoogesort
1
u/lullabysinger Apr 01 '12
Perl bogosort, with gross misuse of the Perl sort operator :)
1
u/[deleted] Apr 01 '12
My Stooge sort in C++:
1
u/thatrandomusername Apr 01 '12
Javascript:
1
u/huck_cussler 0 0 Apr 01 '12
Both are working so far. In Java:
0
u/Cyph3r90 Apr 02 '12
In C#: