Assume that each dog gets the same amount of food.

Thus, each dog will eat 2 bags of food every 18 days (from the given information at the start of the problem).

But that means the dog eats 2/18=1/9 bag per day.

Now, we have to consider feeding the 9 dogs with 12 bags of food. Since each dog eats 1/9 bag per day, that means the 9 dogs eat 1 bag per day. Now, since there are 12 bags available, how many days will it take the 9 dogs to eat them?