implement the solve function without test-case checking.