reduce complexity

refinement/refactoring of initial approach (brute force)
 - [x] extracted/refined methods and field names
 - [x] added javadoc
 - [x] added unit tests
 - [x] update for more intuitive algorithm
 - [x] removed unnecessary code