Thanks for the help. But somehow, I did it ultimately.
But I would also like to mention, that there is some mistake here in the solution:
1. All different: 1068 (fine)
2. One double: 378 (incorrect)
3. Two doubles: 18 (fine)
Now coming to second bit:
What you did there is, you didn't allow...