So I'm currently generating a sequence of characters as a string using:
def nth(lists, num):
res = []
for a in lists:
res.insert(0, a[num % len(a)])
num //= len(a)
return res
def generate_page(chars, length, iteration):
result = nth([chars] * length, iteration)
return "".join(result)
length = 15
seed = 16
number = generate_page('0123456789ABC', length, seed)
But what I can't wrap my head around is how would I generate a sequence of characters if I know how much of each character I want.
For example, let's say I want to generate a sequence that had 1 "A", 3 "B"'s, and 1 "C" how could I get to any arrangement of "ABBBC"?
I'm thinking I would just concatenate a list of the amounts I know I want and then scramble them up like:
A = 1
B = 3
C = 1
listOfCharacters = ["A"]*A + ["B"]*B + ["C"]*C
>>> ['A', 'B', 'B', 'B', 'C']
random.seed(1)
listOfCharacters = random.shuffle(listOfCharacters)
>>> None
listOfCharacters = ''.join(listOfCharacters)
>>> TypeError
But am obviously getting a TypeError at the moment, and am not even sure if this is the best route to retrieve all of the permutations without repeats with a seed.