I'm trying to create a item list with specific patterns, so far my design is like this,
patterns = [
'{column1}{column2}',
'{column1}@{column3}',
'{column2}#{column4}',
'{column3}!@#'
]
for c1 in possible_column1:
for c2 in possible_column2:
for c3 in possible_column3:
for c4 in possible_column4:
data = {
'column1': c1,
'column2': c2,
'column3': c3,
'column4': c4,
}
for pattern in patterns:
result.append(pattern.format(**data))
The design has many problems,
- It create duplicate values, and I have to do a
list(set(result))
to unique the list - It's slow
What's the common way of writing such algorithms?
The patterns
list varies and will be changed frequently, new type of columns maybe added as well
P.S
In my opinion, this differs from permutations.