from itertools import permutations
string="SOFT"
a=permutations(string)
for i in list(a):
# join all the letters of the list to make a string
print("".join(i))
def permutations(s):
if len(s) <= 1:
yield s
else:
for i in range(len(s)):
for p in permutations(s[:i] + s[i+1:]):
yield s[i] + p
input = 'ABCD'
for permutation in enumerate(permutations(input)):
print repr(permutation[1]),
print
from itertools import permutations
from itertools import combinations
p = permutations([1,2,4]) # or permutations([1, 2, 3], 2)
for i in p:
print(i)
c = combinations([1,2,3],2)
for j in c:
print(j)
/**
* Return an array of arrays of size *returnSize.
* The sizes of the arrays are returned as *returnColumnSizes array.
* Note: Both returned array and *columnSizes array must be malloced, assume caller calls free().
*/
int** permute(int* nums, int numsSize, int* returnSize, int** returnColumnSizes){
}