General: permutation generator using backtracking solution