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

Pages: 1-4041-

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 3:00

Bogosort.

Name: Anonymous 2011-06-02 3:07

7/10

Name: Anonymous 2011-06-02 3:15

fuck off/10

Name: Anonymous 2011-06-02 3:21

back to /[spoiler]g[spoiler]/

Name: Anonymous 2011-06-02 3:51

>>3-4
Learn to sage retard.

Name: Anonymous 2011-06-02 3:55

>>6
wut

Name: Anonymous 2011-06-02 3:57

>>7
WHAT DOES NOKO STAND FOR I MUST NO

Name: Anonymous 2011-06-02 4:01

Name: Anonymous 2011-06-02 4:03

のこがかわいいいいいいい ^_^

Name: Anonymous 2011-06-02 4:07

>>10
くたばれ。さげ。

Name: Anonymous 2011-06-02 5:05

>>7
You added a space after the sage.

I wonder how the hell they detect it. It doesn't show up when I mouse over the link. You have to view the page's source.

A while back I added a space and someone detected it right away. This board is strange.

Name: Anonymous 2011-06-02 5:33

>>12
The thread got bumped, that's how I knew.

Name: Anonymous 2011-06-02 5:44

Is anyone else having problems reading the rest of OPs post?

Name: Anonymous 2011-06-02 5:56

being autistic gives you the power to detect space sageing

Name: Anonymous 2011-06-02 5:59

>>12
A while back I added a space and someone detected it right away. This board is strange.
Some java-loving moron probably made a firefox-scripts to detect this. BTW, browser java script is as ugly as enterprise java, only morons would touch such a language.

Name: Anonymous 2011-06-02 6:02

>>16
Use BROWSER COMMON LISP instead!

Name: Anonymous 2011-06-02 6:05

>>17
fuck you and your senseless jokes, java-lover.

Name: Anonymous 2011-06-02 6:08

>>12
>>13 is the only correct answer.

Name: Anonymous 2011-06-02 6:09

Vote for Python as the new web scripting standard!

Imagine a world in which web pages are built upon Python! No more horrid and malignant JavaScript!

Name: Anonymous 2011-06-02 6:10

>>18
Go stuff Sussmans cock in your LISPhole and prepare to feel the pleasure of being cummed inside whilst I cash my enterprize Java paycheck and effortlessly detect space sageing. Oh, and be sure to check my anus on the way out.

Name: Anonymous 2011-06-02 6:12

dubz

Name: Anonymous 2011-06-02 6:14

Post ending in 00 tells me what do to.

Name: Anonymous 2011-06-02 6:17

>>20
Python interpreter written in JavaScript: http://www.skulpt.org/static/skulpt.js

Name: Anonymous 2011-06-02 6:27

>>20,24
ONE WORD: THE FORCED INDENTATION OF CODE. THREAD OVER

Name: Anonymous 2011-06-02 6:33

>>25
Who the fuck writes unindented code?

Name: Anonymous 2011-06-02 6:39

>>24

a = 3

def foo():
    a = 2

foo()    # foo should set the outer a to 2
print a  # so this should print '2'

This prints 3, due to a naive mistake that Guido made early on, one that has permanent and far-reaching implications to the usability of the language. For what it's worth, Larry Wall made the same mistake with Perl, Matz made it with Ruby, and Strachan appears to be making it all over again in Groovy. It's a common blunder.

Name: Anonymous 2011-06-02 6:40

>>26

Lisp:

Grammar -> split '| '(sentence    -> (noun_phrase verb_phrase)
                     |noun_phrase -> (Article Noun)
                     |verb_phrase -> (Verb noun_phrase)
                     |Article     -> the a
                     |Noun        -> man ball woman table
                     |Verb        -> hit took saw liked)

generate =: {[@P]->mapc r P; P:!rewrites->P,rand,r; P->[P]}
rewrites Category -> Grammar,{[@_ [!Category '-> @RHS] @_]->RHS}


Python:

from random import choice

def Dict(**args): return args

grammar = Dict(
        S = [['NP','VP']],
        NP = [['Art', 'N']],
        VP = [['V', 'NP']],
        Art = ['the', 'a'],
        N = ['man', 'ball', 'woman', 'table'],
        V = ['hit', 'took', 'saw', 'liked']
        )

def generate(phrase):
    "Generate a random sentence or phrase"
    if isinstance(phrase, list):
        return mappend(generate, phrase)
    elif phrase in grammar:
        return generate(choice(grammar[phrase]))
    else: return [phrase]
   
def generate_tree(phrase):
    """Generate a random sentence or phrase,
     with a complete parse tree."""
    if isinstance(phrase, list):
        return map(generate_tree, phrase)
    elif phrase in grammar:
        return [phrase] + generate_tree(choice(grammar[phrase]))
    else: return [phrase]

def mappend(fn, list):
    "Append the results of calling fn on each element of list."
    return reduce(lambda x,y: x+y, map(fn, list))

>>> generate('S')
['the', 'man', 'saw', 'the', 'table']

>>> ' '.join(generate('S'))
'the man saw the table'

Name: Anonymous 2011-06-02 7:05

>>26
Who the fuck indents its code manually? Pythonistas, because they can't automatically indent it.

Name: >>29 2011-06-02 7:05

>>28
And you fuck off.

Name: Anonymous 2011-06-02 7:29

>>28
Now write a program to read and print a web page in Python and Lisp.

Name: Anonymous 2011-06-02 7:34

>>27

a = 3

def foo():
    global a
    a = 2

foo()    # foo should set the outer a to 2
print a  # so this should print '2'


This was intentional, faggot. Stop using global variables.

Name: Anonymous 2011-06-02 8:04

>>32
If your language a special global/non-local syntax, its scoping rules are probably broken. Python has both.
If your language has anonymous function, and its function-definition syntax function f(args ...) body ... is not an alias for/equivalent to f = function(args ...) body ..., its anonymous functions are probably broken.

Python promotes consistency[1], the asymmetry created by its crippled lambdas should be inacceptable.
As a workaround, they usually say ``use a nested[2] function'', which not only breaks the wonderful variable/function symmetry, but it's also impratical[3] in lambda-heavy code.

Python super is both complex[4] and complicated[5].

Thus, Python is broken both at pratical and philosophical level.

[1] Special cases aren't special enough to break the rules.
[2] Flat is better than nested.
[3] Although practicality beats purity.
[4] Simple is better than complex.
[5] Complex is better than complicated.

Name: Anonymous 2011-06-02 8:13

>>33
Faggot it was done intentionally. Python has no type declaration, so you can't tell at a glance whether a = 2 is declaring and initializing a variable or changing an already existent one. This will obviously lead to problems if you ever accidentally reuse the name of a global variable - forcing you to explicitly state you are using the global variable prevents this problem from occurring.

Name: Anonymous 2011-06-02 8:17

>>34
So it's forcing you to be explicit that you aren't making a mistake, and just lets you get on with it when you do make a mistake?

Name: Anonymous 2011-06-02 8:38

>>35
It prevents the mistake from occurring. I can reuse the name of a global variable unknowingly and the program will still work as expected.

If I wasn't forced to explicitly state I was using the global variable, I could unintentionally modify a global variable, which could lead to bugs that are difficult to trace.

Name: Anonymous 2011-06-02 8:48

>>34
Make variable declaration in a new scope explicit[1] with a let/var keyword, with no keyword be ``use the outer variable''. global should just be removed because global variables are a bad idea the 80% of times.

>>36
It's counterintuitive and ambiguous[2]. It works for languages with non-retarded scoping.

[1] Explicit is better than implicit.
[2] In the face of ambiguity, refuse the temptation to guess.

Name: Anonymous 2011-06-02 12:45

>>34
"Python has no type declaration"

This is because the *value* gets bound.

"so you can't tell at a glance whether a = 2 is declaring and initializing a variable or changing an already existent one.
"

Normally declaring and initializing a variable happens in languages that bind the *type* to the object. However, python bind the *value*.

"This will obviously lead to problems if you ever accidentally reuse the name of a global variable - forcing you to explicitly state you are using the global variable prevents this problem from occurring"

It depends. The variable, and not the value itself, is what bound to the namespace in python.


For more details, please refer to the python docs.

Name: Anonymous 2011-06-02 12:55

And apparently I can't form a coherent english sentence this morning.

Name: Anonymous 2011-06-02 15:47

>>38
BIND MY ANUS

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

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