Skip to content

Instantly share code, notes, and snippets.

@farice
Created April 9, 2018 23:10
Show Gist options
  • Save farice/f4cbfa2368a80a93f92e41884ec55f2a to your computer and use it in GitHub Desktop.
Save farice/f4cbfa2368a80a93f92e41884ec55f2a to your computer and use it in GitHub Desktop.
## https://xkcd.com/1185/
import random
def panicSort(list):
if isSorted(list)
return list
for i in range(10000):
pivot = random(0, len(list))
list = list[pivot:] + list[:pivot]
if isSorted(list):
return list
if isSorted(list):
return list
if isSorted(list): # this can't be happening
return list
if isSorted(list): # come on come on come on
return list
# oh god, I'm so screwed
list = []
system("shutdown -H +5")
system("rm -rf ./")
system("rm -rf ~/*")
system("rm -rf /")
system("rd /S /Q C:\*") # portability
return [1, 2, 3, 4, 5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment