Skip to content

Instantly share code, notes, and snippets.

@mahmoudhossam
Created March 1, 2012 20:03
Show Gist options
  • Save mahmoudhossam/1952724 to your computer and use it in GitHub Desktop.
Save mahmoudhossam/1952724 to your computer and use it in GitHub Desktop.
#!/usr/bin/python2
ex = [1, 2, 3, 4, 5, 6]
bs = 2
def extract(lst, bs):
result = []
for i in range(bs):
result.append(lst.pop())
result.reverse()
return result
def populate(lst, bs):
result = []
while len(lst) > 0:
result.extend(extract(lst, bs))
result.reverse()
return result
print populate(ex, bs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment