Python Forum
Filter list respecting seniority & no more than 3 same number
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Filter list respecting seniority & no more than 3 same number
#1
General idea:

Number are 1 to 6
Each Person chooses 5 number.
Seniority is 1 the oldest & 5 the newest
If number repeat after 3 times, select next available from the chosen numbers

Person 1 chose 1,2,3,4,5
Person 2 chose 1,2,3,4,5
Person 3 chose 1,2,3,4,5
Person 4 chose 1,2,3,4,5
Person 5 chose 2,3,4,5,6

So basicly the list would be something like this right ? :

p1 = 1,2,3,4,5
p2 = 1,2,3,4,5
p3 = 1,2,3,4,5
p4 = 1,2,3,4,5
p5 = 2,3,4,5,6

I would like to have the final result filtered as such:

P1 = 1,2
P2 = 1,2
P3 = 1,2
P4 = 3,4
P5 = 3,4

I've read that "itertools" can be used to achieve such complex algorithm, but i need some help, anyone can give me some pointers?
Reply


Messages In This Thread
Filter list respecting seniority & no more than 3 same number - by Azerate - Aug-30-2017, 09:18 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Delete strings from a list to create a new only number list Dvdscot 8 1,676 May-01-2023, 09:06 PM
Last Post: deanhystad
  find random numbers that are = to the first 2 number of a list. Frankduc 23 3,455 Apr-05-2023, 07:36 PM
Last Post: Frankduc
  TypeError: float() argument must be a string or a number, not 'list' Anldra12 2 4,997 Jul-01-2022, 01:23 PM
Last Post: deanhystad
  Split a number to list and list sum must be number sunny9495 5 2,400 Apr-28-2022, 09:32 AM
Last Post: Dexty
  Divide a number by numbers in a list. Wallen 7 8,182 Feb-12-2022, 01:51 PM
Last Post: deanhystad
  When did the number got included in the list? Frankduc 14 3,267 Feb-03-2022, 03:47 PM
Last Post: Frankduc
  Count number of occurrences of list items in list of tuples t4keheart 1 2,423 Nov-03-2020, 05:37 AM
Last Post: deanhystad
  How do I add a number to every item in a list? john316 2 2,030 Oct-28-2020, 05:29 PM
Last Post: deanhystad
  Print the number of items in a list on ubuntu terminal buttercup 2 1,989 Jul-24-2020, 01:46 PM
Last Post: ndc85430
  Topic: “Filter numbers with a list comprehension” (PyBite #107) Drone4four 4 2,451 Jun-11-2020, 08:31 PM
Last Post: Drone4four

Forum Jump:

User Panel Messages

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