Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Randomize in tables
#3
Thank you!
But how to incorporate the restriction of sum? I do not know the number of names to choose (k's). I only know that the sum of these k's must be less than or equal to some value X.

Thanks to your advice I tried to choose random names by loop "while". The code stops when the total sum is less than value X. In the function it takes one name randomly by random.choice and then remembers the name and the sum of this name. However, there is a problem which I do not know how to get rid of. That is replacement. By doing so radom.choice may take a name that has been already in the list. I am thinking of decreasing the initial table by one value each time. What do you think?

Thank you!
Reply


Messages In This Thread
Randomize in tables - by mariavol - Aug-15-2022, 07:46 AM
RE: Randomize in tables - by Pedroski55 - Aug-15-2022, 10:29 AM
RE: Randomize in tables - by mariavol - Aug-15-2022, 02:36 PM
RE: Randomize in tables - by deanhystad - Aug-15-2022, 09:23 PM
RE: Randomize in tables - by Pedroski55 - Aug-15-2022, 11:30 PM

Forum Jump:

User Panel Messages

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