Hi
Mary has 30 hats. She has 5 green, 7 blue, 12 red, and 6 brown.
selects two hats at random
P(they are different colors) = 1 - P(both are the same color)
P(both are the same color) = 5/30*4/29 + 7/30*6/29 + 12/30*11/29 + 6/30*5*29
= (20 + 42 + 132 + 30)/30*29 = 224/30*29 = .2575
P(they are different colors) = 1 -.2575 = .7425