Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • I"m Getting Memory Error When Permutations/Combinations Exceeded 10 Elements

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 650
    Answer it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: