I am looking for Python ideas for the following problem.
Given a list of lists...
[[20, 21, 22], [17, 18, 19, 20], [10, 11, 12, 13]]
If there is a duplicate element that is common between any or all the lists, return True. If all of the elements are unique, return False.
In the example above, 20 is common and would return True. The example below would return False because all the numbers are unique between the lists.
[[20, 21, 22], [17, 18, 19], [10, 11, 12, 13]]
Lastly, testing for duplicates in an individual list is not needed because the numbers are always sequential.
FYI - this problem will be used to optimize an airline crew members monthly schedule. Each list represents a 3, 4, or 5 day airline trips that can't overlap.
BTW - this problem is not an assignment but a personal quest to work less and get paid more :) Sorry it was unclear. I tried a brute force method which works but was hoping for a more elegant Pythonic method. I appreciate all the responses as they are leading me into new areas of Python programming.
Aucun commentaire:
Enregistrer un commentaire