jeudi 8 avril 2021

Create a unique list of tuple in a series sorted by order and taken randomly in a range

I'm looking for a solution to find unique lists of tuple with 6 values in a serie sorted by order and taken randomly in a range. I need to test each possible combination possible knowing that the values in each tuples must be sorted. My final purpose is to find the best division of a score scale that goes from 0 to 100 for 6 risk classes

i.e: output search [(0,1,2,3,4,5),(0,1,2,3,4,6),....(95,96,97,98,99,100)]

And I got a memory issue: MemoryError.

if someone as a solution, please. Thanks in advance. Regards

Here is my code:

import random
import itertools
from itertools import combinations, permutations
from random import choice, sample
score_found = list(range(math.ceil(0), math.floor(101)) # the range between score should be found
score number_number = 6 # number of risk classes
list_of_random_score=[]
for i in combinations(score_found, score_number):
    list_of_random_score.append(i) 
list_of_random_score.sort()     #sort each tuple in the list
list_of_random_score2 = list(set(list_of_random_score))





Aucun commentaire:

Enregistrer un commentaire