Live data from Hacker News

Trolling homework questions - sorting

codegolf.stackexchange.com

31–40 of 51 posts

Re: Trolling homework questions - sorting

#31

I considered considering this ridiculously over-complicated approximate solution. Train a neural network to sort with a bunch of examples of sorted arrays.

I would be interested if you could expand on how you would alter the NN architecture for different sized lists

Re: Trolling homework questions - sorting

#33
post #8

Wow. http://codegolf.stackexchange.com/a/16274

yeah, that's why i don't code in perl

Your everyday Perl is much nicer:

perl -e 'my $vals = ".003, .002, .005"; my @sorted = sort { $a > $b } map { $_ =~ s/ +//g; $_ } split(",",$vals); print "$_ " foreach @sorted;'

You can alias the topic variable ($_) if you're not a fan.

Re: Trolling homework questions - sorting

#34

I considered considering this ridiculously over-complicated approximate solution. Train a neural network to sort with a bunch of examples of sorted arrays.

I would be interested if you could expand on how you would alter the NN architecture for different sized lists

You would have to deal with a maximum size limit, or sort only sections of it at a time.

I mean it might technically be possible if you did some kind of recurrent neural network and gave the inputs through time rather than through space. And you would also have to let it interact with some kind of external memory or workspace.

Perhaps you could train it to just perform operations on the list itself (compare two elements, swap two elements, etc.) That would be the simplest way.

Re: Trolling homework questions - sorting

#39
post #6

The ultimate answer is to ask your young siblings to sort them for you. The price is a little time and some candy. Or since so many people are unemployed, ask them to crowdsource and work for something in return! Or just ask wolframalpha.

Set up a job through the Amazon mechanical Turk API and that might actually be possible to do programmatically.

That was my first thought - use a call to the MT api to get the sort done, and then "wait for response". Meets the requirements of the competition perfectly.

Re: Trolling homework questions - sorting

#40

Sigh, don't have an SO account but if I did, I would suggest this code which I call randsort -- #include #include #include int main(int argc, char *argv[]) { int i, ndx; double my_numbers[10]; double sorted_numbers[10]; uint16_t picked; for (i = 1; i = 0; i--) { if (( i == -1) || (sorted_numbers[i] > sorted_numbers[i+1])) { break; } } if (i == -1) { printf(" Sorted: \n"); for (i = 0; i

And since `srand(time(NULL))` isn't ever called, it's deterministic, too!
Post reply on HN