Corey had 1/9 as many hats as Derek. Derek gave 16 hats to Corey so that they would each have the same amount. How many hats did the two friends have altogether?

c = 1/9 d

then

d-16 = c+ 16 sub in the red equation

d-16 = 1/9d + 16

8/9 d = 32

d = 32 * 9/8 = 36 hats initially c = 1/9 d = 4 Total 36 +4 = 40 hats