Skip to content

Instantly share code, notes, and snippets.

@ashleighbasil
Created May 31, 2021 17:57
Show Gist options
  • Save ashleighbasil/33be1be9298b0ced1786795aa837c414 to your computer and use it in GitHub Desktop.
Save ashleighbasil/33be1be9298b0ced1786795aa837c414 to your computer and use it in GitHub Desktop.
Python version of Haskell's inits function (for cassidoo newsletter puzzle)
def inits(lst): return [lst[:i] for i in range(len(lst)+1)]
def inits(lst):
perms = []
for i in range(len(lst)+1):
perms.append(lst[:i])
return perms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment