I'm in a tree

HomeProjectsWritingScienceTools

MusicGamesEphemeraResume

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:

  1. Begin with a gaslighting strategy. Insist to everyone that the list is already in order, even if it is not. If they give up arguing with you, terminate the program. If they insist that you actually sort the list, proceed to the next step.
  2. 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).
  3. Produce N blockbuster action films, each with an advertising budget proportional to a number in the list. For consistency, ensure each film is released in the same theaters at the same time of year. (Practically, this means the list cannot exceed a dozen or so items. If N>12, simply delete all but twelve items from the list). Read off the box office earnings for each film in order, 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.