-1

Okay, so I have a list

input: [0,1,2,3,4,5]

output: [0000,0001,0010,0100,1000,0002...]

I came up with a really stupid way of doing that but I'm looking for something more efficient.

def makeMoves():
    combList = []
    moves = ['0','1','2','3','4','5']
    while len(combList) < 1296:
        move = ''
        for i in range(4):
            move += random.choice(moves)
        if not move in combList:
            combList.append(move)
    return combList

Thanks in advance!

1 Answers1

-1
from itertools import permutations

inp = [0,1,2,3,4,5]
result = [''.join([str(x) for x in element]) for  element in permutations(inp, 5)]
wuerfelfreak
  • 2,363
  • 1
  • 14
  • 29