Is there a way of doing the above without using loops and list comprehension - Just recursion?
This is my solution with for loops:
def permutations(s):
if(len(s)==1):
return [s]
combs = []
for i in range(len(s)):
for perm in permutations(s[:i]+s[i+1:]):
combs += [s[i]+perm]
return combs
example:
input :"bca"
output: ["abc", "acb", "bca", "bac", "cab", "cba"]