Number permutations function, creates a list of all possible arrangements. Worked on this code for a while, it works well and I'm trying to find a shorter an more efficient way of writing it.
a = [3,7,9]
perms = lambda a:list(sorted(z) for z in map(lambda p:dict.fromkeys([str(sum(v* (10**(len(p) -1 - i)) for i,v in enumerate(item))).zfill(len(a)) for item in itertools.permutations(p)]).keys(), [[int(x) for x in ''.join(str(i) for i in a)]]))[0]
The code returns:
['379', '397', '739', '793', '937', '973']
You can also input numeric string variable
a = '468'
perms(a)
['468', '486', '648', '684', '846', '864']
This is code is different, instead of returning tuples or list. It returns a list of results in string format. Also, you are allowed to input numeric strings, tuples or lists. Trust me I've checked any duplicates before posting.
The triple digits work pretty well
perms('000')
['000']
Other codes produces this
['000', '000', '000', '000', '000', '000']
Also, this code returns an ordered list.