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

Genious Algorithm: Factorial Tree Sort

Name: Anonymous 2011-06-02 2:57


 Factorial Tree Sort reads an array of integers and randomly arranges the order of those integers. It then checks to see if the array is sorted, if the array is sorted, Factorial Tree Sort has done its job. If the array is not sorted

(Post truncated.)

Name: Anonymous 2011-06-02 16:21

>>33
faggot don't use their own points against them. not fair.

Name: Anonymous 2011-06-02 16:30

>>40
Only if you wear your sister's pantyhose.

Name: Anonymous 2011-06-02 16:34

>>41
Faggot is not a person, not fair towards who?

Name: Anonymous 2011-06-03 3:49

I just did a coctothorpian implementation of this to prove that it will in fact not work. The pseudorandom numbers generated to select movement patterns eventually wrap in such a way that it will rarely, if ever, reach the state of being fully sorted.

Name: Anonymous 2011-06-03 7:04

Name: Anonymous 2011-06-03 14:39

>>44
Reinitialize your generator with a clock seed each iteration.

Name: Anonymous 2011-06-03 14:42

I figured out a better algorithm! Try all possible solutions once! That way the solution will be definitely found if it exists.
Where's my Nobel prize?

Name: Anonymous 2011-06-03 17:11

>>45
C octothorpe

Name: Anonymous 2011-06-03 19:11

>>47
in a lazy language, that's not too bad of an idea


insertEverywhere x xs = map (\(a,b) -> a ++ [x] ++ b) splits
    where splits = map (flip splitAt xs) [0..length xs]

permutate [] = []
permutate [x] = [[x]]
permutate (x:xs) = permutate xs >>= insertEverywhere x

isSorted [] = True
isSorted [x] = True
isSorted (x:y:xs) | x <= y    = isSorted (y:xs)
                  | otherwise = False

derpSort :: (Ord a) => [a] -> [a]
derpSort = head.filter isSorted.permutate

Works very quickly for already sorted or mostly sorted lists. However, insanely slow on completely unsorted lists

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