Skip to content

Instantly share code, notes, and snippets.

@chrisedgemon
Created May 26, 2010 18:18
Show Gist options
  • Save chrisedgemon/414844 to your computer and use it in GitHub Desktop.
Save chrisedgemon/414844 to your computer and use it in GitHub Desktop.
>>> def x(lst, cols):
... if cols == 0: return []
... slice = len(lst) / cols
... if len(lst) % cols:
... slice += 1
... return [lst[:slice]] + x(lst[slice:], cols-1)
@chrisedgemon
Copy link
Author

def x(lst, cols):
... if cols == 1: return [[lst]]
... slice = len(lst) / cols
... if len(lst) % cols:
... slice += 1
... return [lst[:slice]] + x(lst[slice:], cols-1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment