Com Python ,
#! /usr/bin/env python3
import sys
from itertools import chain, permutations
# from the docs https://docs.python.org/3/library/itertools.html#itertools-recipes
# modified for permutations instead of combinations
def powerset_perm(iterable):
s = list(iterable)
return chain.from_iterable(permutations(s, r) for r in range(1, len(s) + 1))
for w in powerset_perm(sys.argv[1:]):
print("".join(w))
Exemplo:
~ ./foo.py foo フー bar1™
foo
フー
bar1™
fooフー
foobar1™
フーfoo
フーbar1™
bar1™foo
bar1™フー
fooフーbar1™
foobar1™フー
フーfoobar1™
フーbar1™foo
bar1™fooフー
bar1™フーfoo