Live data from Hacker News

Show HN: XKCD-inspired StackSort

gkoberger.github.com

31–40 of 210 posts

Re: Show HN: XKCD-inspired StackSort

#31

Noticed that there was a lot of "Potentially bad code" answers. I read you are avoiding scripts with "cookie" or written after the comic was written, but are there other restrictions? For example, this was banned: http://stackoverflow.com/questions/14800987/javascript-sorti... Just curious about it.

I attempt to block anything that does DOM manipulation, uses Backbone or underscore, uses "Date()" (since it's probably a benchmark and those are slow), and a few others.

Re: Show HN: XKCD-inspired StackSort

#32
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…

Could be a new declarative language.

Re: Show HN: XKCD-inspired StackSort

#37

Wow.. beautiful! I know this is only for fun, but it can start something bigger. Basically, given an input and output we could search for an algorithm that works. It reminds me a talk that PG gave in which he states people making bots to optimize code and then an intelligent compiler could be done. It sounded very futuristic, but maybe it is not that futuristic after all...

This is called TDD.

Re: Show HN: XKCD-inspired StackSort

#38

Wow.. beautiful! I know this is only for fun, but it can start something bigger. Basically, given an input and output we could search for an algorithm that works. It reminds me a talk that PG gave in which he states people making bots to optimize code and then an intelligent compiler could be done. It sounded very futuristic, but maybe it is not that futuristic after all...

[deleted]

Re: Show HN: XKCD-inspired StackSort

#39
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: Here's the code. https://gist.github.com/shurcooL/df2c8339ada1997606b3 It should run out of the box if your Go is installed in /usr/local/go. I just changed it to generate a temp dir in the working dir (prefixed with "Gen-"), so you can delete it afterwards (previously it relied on a "Gen" folder to already exist). Right now it's configured to have quite difficult verification conditions, so it generates valid programs quite infrequently (despite trying 5000+ programs per second on my machine).

Re: Show HN: XKCD-inspired StackSort

#40

Earlier quoted context omitted.

Dammit, just as I was about to write a function sortArray(a) { alert('Hello StackSort!') } Question/Answer. =( Good foresight!

I also don't allow alerts :)

This is a really cool script you've written and made me laugh out loud.

It would be a shame though if someone edited / republished / whatever an old script and used it to steal people's github cookies (your code wouldn't be able to filter someone calling a remote script which then ran its own code for instance or a script that evaled a new script based on a string / unicode etc.)

It might be best to just run the code in a frame that's not hosted on Github then you're safe.

Post reply on HN