implement the problem with tests