solved 2684: Polygonal Line Search, accepted but bad code (too large, too complex)