Hi
I am new to python coding but would like to use it to generate all the permutations and combinations of a slot car track layout given a list of pieces of track. I figure each piece of track is a block that connects at each end. Curved pieces are just curved blocks. The blocks have to line up one after another in line and make a loop, if it does not make a loop then the layout is discarded. I got as high as 10 pieces of track before I ran out of memory. I have 75 pieces of track made up of straight and curved pieces. This does not take into account each curved piece of track can face up or down.
Lastly I want to save each completed loop layout so I can use it as an input data list to generate a graphical picture of the slot car track layout.
Any help on how to code this would be deeply appreciated. Thank you.
the code...
import itertools
from pprint import pprint
import numpy as np
#inputdata = [[9,0],[10,45],[10,45],[9,0],[10,45],[10,45]]
#inputdata = [9,9,9,9,9,9,9,9,9,9,9,9,9,9,15,15,15,15,15,15,15,15,15,15,15,6,6,6,6,6,6,6]
inputdata = [9,9,9,15,15,15,15,6,9,3]
result = list(itertools.permutations(inputdata))
outputArrays = np.array_split(result,len(result))
#print(outputArrays[100]) #to print a single list element.
pprint(outputArrays)
0 Answer(s)