Created
May 31, 2021 17:57
-
-
Save ashleighbasil/33be1be9298b0ced1786795aa837c414 to your computer and use it in GitHub Desktop.
Python version of Haskell's inits function (for cassidoo newsletter puzzle)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def inits(lst): return [lst[:i] for i in range(len(lst)+1)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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