Unless I'm missing something then I think more information is needed..?
How many types of hat are there? Post the ENTIRE question.
Maybe this is wrong but I think it's...
1-Probability(all hats are different)
So you get your first hat with prob 1.
The prob that the second one is different is 9/10
The prob that the third one is different is 8/10
The prob that the fourth one is different is 7/10
So 1-Probability(all hats are different) = 1-(9/10*8/10*7/10) = 0.496.