Feb 18, 2023
I am quite dubious of the benefit of this.
It is the same number of lines of code, it is more complex, and it duplicates all the boundary values. 90, 80 etc appear twice so if you ever need to change a boundary you need to change it in two places. And the code might misbehave in an unexpected way if you forget to update both.
Sometime repetitive code is the best solution.
Also, I don't think dictionaries are more efficient in this scenario. You are looping over all the elements in order, so dictionary hashing doesn't really gain you very much.