r/learnprogramming • u/Ok_Calligrapher9862 • Oct 07 '26
Building sets with matrices? There are 8 possible sequences. There are exact quantities.
I don’t know code but I know code could solve my problem. If this isn’t the right sub to ask in, please let me know where would be best :)
Possible sequences:
{OpenO MidDoubleC MidOhCee CloseO }
{OpenO MidCeeOh MidDoubleC CloseO }
{OpenO MidDoubleC MidDoubleO CloseC }
{OpenO MidCeeOh MidCeeOh CloseC }
{OpenC MidDoubleO MidCeeOh CloseC }
{OpenC MidOhCee MidDoubleO CloseC }
{OpenC MidDoubleO MidDoubleC CloseO }
{OpenC MidOhCee MidOhCee CloseO }
Exact Quantities:
Open0 = 3
OpenC = 5
CloseO = 3
CloseC = 5
MidDoubleC = 2
MidDoubleO = 4
MidCeeOh = 4
MidOhCee = 6
What are various sets of 8 I could build?
1
u/SharkSymphony Oct 07 '26
Cranking out permutations of a list is a one-liner in Python. See itertools.permutations.
1
u/POGtastic Oct 07 '26
Assuming Python: Consider
collections.Counteranditertools.product. We want the 2-product of our sequences such that aCounterof each element in the product does not have a higher count of anything than aCounterof our quantities.In the REPL, putting your sequences into
SEQSand aCounterof your quantities intoQUANTITIES: