The basic idea is this: write your own sorting method without using indices (square bracket notation [ ])
For example, in a normal sorting method you might want to swap positions i and j. Code like this:
n[i], n[j] = n[j], n[i]
This is not allowed. As a further restriction, I am not allowing any square brackets in your code, even if they aren't indexing anything. Time to think outside the box a bit.
For example, when you have written your function use a random number generator to test it:
import random for i in range(5): sortedIntegers = mySortingMethod(list(random.randint(0, 100) for x in range(20))) print sortedIntegers .... [1, 2, 2, 11, 11, 15, 16, 18, 23, 27, 35, 38, 39, 57, 57, 57, 64, 81, 81, 97] [0, 5, 6, 6, 15, 21, 21, 35, 46, 49, 62, 62, 65, 67, 70, 73, 78, 80, 89, 90] [0, 0, 6, 14, 14, 27, 31, 33, 49, 52, 53, 57, 58, 60, 69, 86, 90, 93, 95, 100] [2, 8, 8, 15, 20, 20, 22, 22, 33, 35, 37, 41, 44, 44, 45, 70, 79, 84, 88, 96] [2, 8, 12, 15, 19, 19, 30, 37, 40, 41, 46, 51, 60, 63, 65, 75, 79, 79, 92, 99]
A few rules:
* It must be a single top-level function (nested helper functions are fine) that sorts a random LIST of integers into ascending order
* Built-in sorting functions are not allowed, nor functions from another module not packaged with Python
* There are allowed to be repeats in the random sequence of integers, it must deal with this
* Right now, only Python entries will be accepted, I may open it up to other languages in the future, implementations in other languages are fine but will not be judged in the challenge.
* Python 2 or 3 is fine
* The winner will be the person who enters the fastest sorting method timed by me, there is also an award for the most creative submission.
After a few entries or a bit of interest I'll release my solution I've already written for you all to have a peek at
Happy Challenging! Let's see what you can do.
EDIT: I should really set a deadline, 2 weeks from today should be good to be get plenty of entries so Sunday 16th September 2012 will be the cut off.
This post has been edited by Simown: 12 September 2012 - 11:51 AM

New Topic/Question
Reply




MultiQuote





|