In my application we have teams of users based on their location (zipcode) and then an encompassing radius of 100 miles (zipcodes within) to operate with.
My problem is: user one signs up and is designated a team based on his zipcode and the radius encompassing it. when user two signs up, and he has a zipcode that is let's say within the radius of the first users team, then we are supposed to assign him to that same team. However, the second user has a radius that exceeds the teams assigned radius because he is operating within his zipcode, not user A.
So, the problem becomes that right now we need to create a new team for each zipcode to ensure that every user in that team has the correct radius. This is not a solution though. We cannot have a new team for every zipcode.
My first thought was to create teams based on regions containing zipcodes and then just assign the user to that team since they're zipcode is in the region. I do not like this thought though.
Any help would be appreciated. This is a very difficult algorithm for me so please take the time to explain as simple as possible so I can clearly understand your solution.