Backtracking Algorithm Python Example Code