Live data from Hacker News

Show HN: XKCD-inspired StackSort

gkoberger.github.com

91–100 of 210 posts

Re: Show HN: XKCD-inspired StackSort

#91
post #5

If you give it about 30 seconds it works eventually, this is beautiful. I had a good laugh. Edit: It makes me want to do something crazy like setup a tool chain that cobbles whole programs together with trial and error like this. Throw enough resources at it maybe it will be faster and cheaper than your avg. developer. It will be an unmaintainable mess as if you used Brainfuck or Perl. But it will run, by god, it wil…

I tried a basic version of that 1.5 weeks ago. At first it was generating random characters, then I tried some Markov chains trained on valid code. After running it overnight (it was attempting 40+ programs per second), the very best program looked something like this: package main; func main() { i := 0 // wae64309i Next step I wanna try is to use tokens of the language instead of series of random characters. Edit: H…

Hah, fun idea.

Modified it a bit to run in parallel. I guess I'll leave it on for couple hours and see if it gets anywhere.

current output:

    1363637914 2013-03-18 22:18:34.118051 +0200 EET Stats: 0/53659699 (0%) good/tries, 223559.91320127275 ops/sec

Re: Show HN: XKCD-inspired StackSort

#92
post #45

has nobody else noticed that the default list always sorts with the same algorithm? http://stackoverflow.com/questions/14761032/infinite-recursi...

That's because it always tried answers in the same order. If you tell it to keep going, it'll succesfully sort with http://stackoverflow.com/questions/4833651/javascript-array-... and http://stackoverflow.com/questions/12137690/javascript-sort-... as well.

Those two don't work in the general case.

The first only leaves the unique members of the list, so you get a sorted set. The second sorts lexicographically, because javascript's .sort() method on arrays sorts lexicographically. This means that if you have a list of numbers like [1, 2, 10], it will get sorted as [1, 10, 2]. Unless you pass your own comparator in.

What this page really demonstrates is that there is precisely one answer on stackoverflow containing a complete generic sort function in javascript (quicksort in fact).

Re: Show HN: XKCD-inspired StackSort

#93
post #63

This was inspired by the alt-text from last week's "Ineffective Sorts" xkcd ( http://xkcd.com/1185/ ). It tries to sort a list or JSON by fetching code from StackOverflow until it properly sorts the input.

Nicely done. I enjoyed looking at the code. For those of you who want to jump straight to the meat of it, go here: https://github.com/gkoberger/stacksort/blob/master/js/script... Search down for "run_snippet_go"

FYI, you can link to a specific line on GitHub by appending #L to the URL. In this case: https://github.com/gkoberger/stacksort/blob/master/js/script...

GitHub even adds the anchor for you if you click on the line number in the gutter. (shift-click to select a range of lines.)

Re: Show HN: XKCD-inspired StackSort

#94
If a site like StackOverflow/Github had a more powerful search, better semantic data, etc. maybe people would be able to create things primarily by searching through it?

In this example, one would type "sort array" and it would auto-find a function that sorts an array, but perhaps more advanced things can also be done? I guess it depends somewhat on how re-usable code really is, besides on the ability of a computer to find the right code.

At the very least, there should be better search/help when one is coding. SO's current search isn't good at returning the best results.

Re: Show HN: XKCD-inspired StackSort

#97
post #74
post #5

If you give it about 30 seconds it works eventually, this is beautiful. I had a good laugh. Edit: It makes me want to do something crazy like setup a tool chain that cobbles whole programs together with trial and error like this. Throw enough resources at it maybe it will be faster and cheaper than your avg. developer. It will be an unmaintainable mess as if you used Brainfuck or Perl. But it will run, by god, it wil…

I've created a weekend hack that allows you to specify a minimal grammar and then generates text (which can be code) using it. It's called Choice Words ( https://github.com/fdb/choicewords ) It can generate poems but also generative designs (see the README).

That generated drawing in the README.md looks like something i'd hang in my kitchen. You should try selling these ;)

Re: Show HN: XKCD-inspired StackSort

#98
post #88

Earlier quoted context omitted.

I tried a basic version of that 1.5 weeks ago. At first it was generating random characters, then I tried some Markov chains trained on valid code. After running it overnight (it was attempting 40+ programs per second), the very best program looked something like this: package main; func main() { i := 0 // wae64309i Next step I wanna try is to use tokens of the language instead of series of random characters. Edit: H…

If you actually want to go down this path then you want a language with as little redundancy as possible. Comments may be useful to humans but they needlessly complicate the search space. Abstractly you want to think about the how your language is parsed so you don't for example try different variable names. Though if you spend enough time your probably going to be reimplementing some type of http://en.wikipedia.org/…

Like maybe Brainfuck?

Re: Show HN: XKCD-inspired StackSort

#100

For the numbers it eventually ends up here : http://stackoverflow.com/questions/14761032/infinite-recursi... but by and large this is a great hack. I worry however if someone meta-exploits this by creating a javascript XSS in a stack exchange answer waiting patiently ...

Would they even be able to do much damage? The site is hosted on a subdomain of Github, so I presume they wouldn't be able to do much. Right?

I mean I hope sites hosted on *.github.com can't compromise my Github account...

Post reply on HN