i don't know how many coders we got on the forums but i wrote a pretty efficient sorting algorithm that i think is the best out there due to the sheer versatility and usability it has.
in the code block you'll see it's algorithm then an example, you could copy and paste it into an online python 3 interpreter and it'll work for ya and it'll tell you the run time
show me your efficient code guys, doesn't have to be sorting but just anything you're really really proud of that you wrote well
import random
import time
#only brainlets write inefficient sorting algorithms
# this sorting algorithm has an efficiency of O(log(n)) prove me wrong
# >>>protip: you can't
# ,+@;
# .@@@@@@@#
# .@@@@@@@#
# `@@@@@@@@@;
# .@@@@@@@@@@'#
# ;@@@@@@;:@#`,;;
# ``+ @@@@: ''+',
# + @'+#`; :,:@
# , +,`` .' ';
# .. .# ` , `
# :@ :,: ,
# ,@ ` . +
# .@ :; ` , @@@@+`
# # ` ,# ,@@@@@@@@'
# @@ .` #@@@@@@@++@
# @@@' ,@@@@@@+@;#'@
# `@@@@@ :@@@@@@:@@@@':
# @#'@@@' @@@@@@@@@@;@@@
# @#,@@@@@@@@@@@@@@@#@@@:
# @,.@@@@@@@@@@@@@@@@@@@@
# ,@@:@@@@@@@@@@@@@@@@@@@@
# @@@+@@@@@@@@@@@@@@@@@@@@.
# @@@#@@@@@@@@@@@@@@@@@@@@@
# `# @@@#@@@@@@@@@@@@@@@@@@@@@
# ;: , @@@@@@@@@@@@@@@@@@@@@@@@@
# : + @@@@@@@@@@@@@@@@@@@@@@@@@
# ' `;@@@@@@@@@@@@@@@@@@@@@@@@
# .. ' @@@@@@@@@@@@#'+@@@@@@
# + , #@@@@@@@@@@@@@@@@@@@
# `.#, :@';:'@@@@;@'@@@@@@
# , `@@@:@@@@@#@:@@@@@
start_time = time.time()
def efficientSort(sort):
temp = sort
sortedbool = False
while not sortedbool:
print(temp)
var1 = random.randint(0, len(temp)-1)
while True:
var2 = random.randint(0, len(temp)-1)
if var1 != var2:
break
temp1 = temp[var1]
temp[var1] = temp[var2]
temp[var2] = temp1
sortedbool = True
for i in range(0, len(temp)-1):
if temp[i] > temp[i+1]:
sortedbool = False
sort = [7,6,5,4,3,2,1,0]
efficientSort(sort)
print("Runtime: ", time.time() - start_time)
