I am relatively new to coding. I encountered a problem that I can't find a solution for.
I have multiple "clients" , and each client has a few valid ranges (noted with the start and end point - e.g. (5,10) where 5 is the start point and 10 is the end point). I need to find a code that finds the common ranges across all of the clients (and if such range doesn't exist, then find the common range between all of the clients but 1, and so on..)
I have considered the naive approach of just calculating all of the possible permutations, but I couldn't get it to work (besides being computationally inefficient).
Important notes - The number of clients and ranges per client is not pre-determined, but can be calculated in run-time.
Simple example - Suppose I have 7 clients, as follows:
- Client 1 - ranges are (17,30), (34,44)
- Client 2 - ranges are (17,30), (31,44)
- Client 3 - ranges are (25,30), (34,44)
- Client 4 - ranges are (18,30), (34,44)
- Client 5 - range is (19,44)
- Client 6 - ranges are (20, 37), (38,44)
- Client 7 - range is (20, 37)
The code should output (given this configuration) the following ranges - (25,30) and (34, 37)
I hope I described the problem properly, I'd be happy to clarify if necessary.
Thanks in advance!!