Search Results

Results tagged with
Search options not deleted user 4372
16 results

This challenge is intended to be solved by sorting, ordering, or otherwise organizing some set of data.

Shortest Program to Sort a List of numbers into Odd and Even Category

dc 3 (35 - 32) Using arrays, as suggested by @Tomas. This saves some of characters because I can calculate the parity of each number and use it as an index, instead of tweaking the with parity as a m …
• 18.4k

Shortest Program to Sort a List of numbers into Odd and Even Category

Ruby, 55 - 46 = 9 f=->a{h=[0,0];a.map{|v|h[v%2]+=v};e,o=h;(e*e+o*o)**0.5} Test: f[[20, 9, 4, 5, 5, 5, 15, 17, 20, 9]] => 78.49203781276162
• 18.4k
1 vote

Sort this, quick!

Ruby, 87 60 bytes q=->a,p=a.sample{a[1]?(l,r=a.partition{|e|e<p};q[l]+q[r]):a} Ungolfed: def quicksort(a, pivot=a.sample) if a.size > 1 l,r = a.partition { |e| e < pivot} quicksort(l) + …
• 18.4k

Sort a list of numbers

Generic, multithreaded bogosort in Java 46 seconds to sort 4 numbers I thought it would be elegant with support for generics. Also, multithreading is always nice, so I use that instead of randomizat …
• 18.4k

• 18.4k