Skip to content

Instantly share code, notes, and snippets.

@soedar
Last active December 28, 2015 07:08
Show Gist options
  • Save soedar/7461749 to your computer and use it in GitHub Desktop.
Save soedar/7461749 to your computer and use it in GitHub Desktop.
is_word = lambda word: word in ['hot', 'el', 'fate', 'elf', 'ate', 'hotel', 'fate']
def str_set(input_str):
if input_str == "":
return [[]]
result = []
for i in range(1, len(input_str)+1):
s = input_str[:i]
if is_word(s):
res = str_set(input_str[i:])
for r in res:
r.insert(0, s)
result.extend(res)
return result
print(str_set('hotelfate'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment