Python Forum
memory error using permutation list of 11 elements
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
memory error using permutation list of 11 elements
#1
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,9,9,15,15,15,15,6,9,3] #track lengths
result = list(itertools.permutations(inputdata))
outputArrays = np.array_split(result,len(result))

pprint(outputArrays)
Reply
#2
Run it in a loop rather than loading it all into a list. Then it's not all in memory at one time.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Why am I getting list elements < 0 ? Mark17 8 433 Aug-26-2021, 09:31 AM
Last Post: naughtyCat
  Looping through nested elements and updating the original list Alex_James 3 228 Aug-19-2021, 12:05 PM
Last Post: Alex_James
  Extracting Elements From A Website List knight2000 2 368 Jul-20-2021, 10:38 AM
Last Post: knight2000
  Make Groups with the List Elements quest 2 363 Jul-11-2021, 09:58 AM
Last Post: perfringo
  I cannot delete and the elements from the list quest 4 779 May-11-2021, 12:01 PM
Last Post: perfringo
  List of lists - merge sublists with common elements medatib531 1 751 May-09-2021, 07:49 AM
Last Post: Gribouillis
  Find Common Elements in 2 list quest 4 745 Apr-14-2021, 03:57 PM
Last Post: quest
  Sorting Elements via parameters pointing to those elements. rpalmer 3 748 Feb-10-2021, 04:53 PM
Last Post: rpalmer
  Group List Elements according to the Input with the order of binary combination quest_ 19 1,660 Jan-28-2021, 03:36 AM
Last Post: bowlofred
  Even/Odd permutation braankoo 9 7,911 Jan-10-2021, 01:19 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020