Half implementation of Manhattan method along with tests.