One randomly-generated sorting algorithm, please!
Do you have an unsorted list of N natural numbers? Do you just hate it when programs are guaranteed to terminate? Do you get angry when algorithms do better than factorial time? Then you're in luck! The following algorithm has been generated just for you:
- Feed your list into a black hole, permanently destroying the information. The list is as good as sorted now! If people shake their heads and insist you actually sort the list, just generate a new one and proceed to the next step.
- Uh oh! You've triggered a penalty step. Before you proceed, you must perform a task. Andrew Wiles's proof of Fermat's Last Theorem is 109 pages long. Assuming each page contains roughly 2000 characters, the text can be encoded in order 1,000,000 bits. Generate this number of bits and check to see if they prove Fermat's Last Theorem. If they do not, repeat this step. If they do, proceed! You've paid the penalty. (This step was defined in collaboration with Mirac Suzgun).
- You turn to mathematical ecology for inspiration. For each number in your list, generate a population of rabbits proportional to the number and a population of wolves inversely proportional to the number. Wait for each system to equilibrate. Read off the equilibrium population of rabbits in order of population size, printing the number corresponding to each.
Congratulations! Your list is now sorted. Click here to return to the front page, where more randomly-generated algorithms await.