solve() method is implemented.

The program runs but not perform well. It must be debugged!