Framework for solving problems using a backtracking approach