allperms function

All permutations with given characteristics