Hello! Please tell me how in Python, by mind, do the finding whether ranges overlap. For example, a person is looking for people aged “from 9 to 14” and “from 15 to 21”, while he himself indicates that he is from “18 to 21”. The second person indicates that he is "from 8 to 11" and is looking for "from 21 to 40". It is necessary that everyone was happy. That is, firstly, the desired person must correspond to the desired intervals of age, secondly, if the one who searches does not satisfy the search parameters of the desired one, then the search must return false.
Clearly such arrays:
"search_users"{ "user_1" => { "my_age_from" => "18", "my_age_to" => "21", "wish_user_ages" => { {"from"=>"9", "to"=>"14"}, {"from"=>"15", "to"=>"21"} } }, "user_2" => { "my_age_from" => "8", "my_age_to" => "11", "wish_user_ages" => { {"from"=>"21", "to"=>"40"} } }, ....
How to find only overlapping users. So that they were to each other. There is a cycle option to go through all the conditions, but it is too difficult and somehow difficult to fit in my head, if my age would have been more than diapozon, there would be no problems. And it seems to me that there is some generally simpler method than conditional cycles. Please help, guru!))
OrderedDict
in Python (lists in Python do not have named keys, dictionaries in Python do not maintain order). If you intentionally used the python label for the question, then convert the input data into a format understood by Python (for example, json text). Label arrays most likely out of place 2- Specify what your question. Do you want at least some algorithm that finds for all users a list of suitable users by age? Or do you need an algorithm with a certain Big O behavior? - jfs