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
  unable to remove all elements from list based on a condition sg_python 3 371 Jan-27-2024, 04:03 PM
Last Post: deanhystad
Question mypy unable to analyse types of tuple elements in a list comprehension tomciodev 1 426 Oct-17-2023, 09:46 AM
Last Post: tomciodev
  Understanding and debugging memory error crashes with python3.10.10 Arkaik 5 1,976 Apr-18-2023, 03:22 AM
Last Post: Larz60+
  Checking if a string contains all or any elements of a list k1llcod3 1 1,022 Jan-29-2023, 04:34 AM
Last Post: deanhystad
  python list out top 10 Memory utilisation mg24 0 785 Nov-20-2022, 10:51 PM
Last Post: mg24
  Memory Error While generating cheksum no mg24 2 981 Sep-25-2022, 10:33 PM
Last Post: mg24
  How to change the datatype of list elements? mHosseinDS86 9 1,896 Aug-24-2022, 05:26 PM
Last Post: deanhystad
  ValueError: Length mismatch: Expected axis has 8 elements, new values have 1 elements ilknurg 1 5,011 May-17-2022, 11:38 AM
Last Post: Larz60+
Question How to print each possible permutation in a dictionary that has arrays as values? noahverner1995 2 1,695 Dec-27-2021, 03:43 AM
Last Post: noahverner1995
  Why am I getting list elements < 0 ? Mark17 8 3,026 Aug-26-2021, 09:31 AM
Last Post: naughtyCat

Forum Jump:

User Panel Messages

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