Skip to content

Instantly share code, notes, and snippets.

@bpicolo
Last active November 30, 2015 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bpicolo/32a7fc775ce1810c88a0 to your computer and use it in GitHub Desktop.
Save bpicolo/32a7fc775ce1810c88a0 to your computer and use it in GitHub Desktop.
andrescusort
Dirty code:
import heapq
stuff = ["A Hard Day's Night", 'All About Eve', 'Boyhood', 'Citizen Kane', 'Das Cabinet des Dr. Caligari. (The Cabinet of Dr. Caligari)', 'E.T. The Extra-Terrestrial', 'Inside Out', 'It Happened One Night', 'King Kong', 'Laura', 'Metropolis', 'Modern Times', 'North by Northwest', 'Repulsion', "Singin' in the Rain", 'Snow White and the Seven Dwarfs', 'The Adventures of Robin Hood', 'The Godfather', 'The Third Man', 'The Wizard of Oz']
start = 1
end = []
while(stuff):
end.append([])
for i in range(start * start):
if not stuff:
break
end[-1].append(stuff.pop(0))
heapq._heapify_max(end[-1])
start = start + 1
# end dirty code
[
["A Hard Day's Night"],
['Das Cabinet des Dr. Caligari. (The Cabinet of Dr. Caligari)', 'Boyhood', 'Citizen Kane', 'All About Eve'],
['Repulsion', 'North by Northwest', 'Modern Times', 'King Kong', 'Laura', 'Metropolis', 'It Happened One Night', 'Inside Out', 'E.T. The Extra-Terrestrial'],
['The Wizard of Oz', 'The Third Man', 'The Adventures of Robin Hood', 'The Godfather', 'Snow White and the Seven Dwarfs', "Singin' in the Rain"]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment