Solution to tug_of_war problem by backtracking( problem statement inside)