Mandy and Diana baked some muffins. Mandy gave 4/7 of her muffins to Diana. Diana then gave 1/9 of her muffins to Mandy. As a result, Mandy had 1/2 as many muffins as Diana. If Mandy gave Diana 78 more muffins than what Diana gave to Mandy, how many muffins did Diana have at first?

to start, they have m and d muffins.

After the first swap, they have
Mandy: 3/7 m
Diana: d + 4/7 m
After the 2nd swap, they have
Mandy: 3/7 m + 1/9 (d + 4/7 m)
Diana : 8/9 (d + 4/7 m)
so at the end,
3/7 m + 1/9 (d + 4/7 m) = 1/2 * 8/9 (d + 4/7 m)
4/7 m = 78 + 1/9 (d + 4/7 m)
whew. Simplifying things a bit, we have
5m = 7d
32m = 7d + 4914
so
5m = 32m - 4914
m = 182
so d = 130
check:
Mandy had 182, and gave 104 to Diana, who then had 234
Diana then gave 26 to Mandy, who then had 104. Diana had 208.
Mandy then had 1/2 as many as Diana
Note that Mandy gave 104=78+26 to Diana.

Let's assume that Diana had x muffins at first.

According to the given information, Mandy gave 4/7 of her muffins to Diana. So, Mandy had (1 - 4/7) = 3/7 of her muffins left.
Also, Diana had (1 + 1/9) = 10/9 of her muffins left.

We are given that Mandy had 1/2 as many muffins as Diana after the exchange. So, we can set up the equation:
(3/7)M = (1/2)(10/9)D

Now, let's simplify the equation and solve for Mandy's muffins:
(3/7)M = (5/9)D
Multiply both sides by 7:
3M = (35/9)D
Divide both sides by 3:
M = (35/27)D

Given that Mandy gave 78 more muffins to Diana than Diana gave to Mandy, we can set up another equation:
M - Diana's Contribution = Diana's Contribution + 78

Substituting the value of M from the first equation:
(35/27)D - Diana's Contribution = Diana's Contribution + 78

Now, let's simplify the equation:
35D - 27(Diana's Contribution) = 27(Diana's Contribution) + 78(27)

Simplifying further:
35D - 27(Diana's Contribution) = 27Diana's Contribution + 2106

Combine like terms:
35D = 54(Diana's Contribution) + 2106

Rearranging the equation:
35D - 54(Diana's Contribution) = 2106

Given that Mandy gave 4/7 of her muffins to Diana:
4/7 * M = Diana's Contribution

Substituting the value of M:
4/7 * (35/27)D = Diana's Contribution

Multiplying both sides by 27:
4/7 * 35D = 27(Diana's Contribution)

Simplifying further:
20D = 27(Diana's Contribution)

Now, let's substitute this equation back into the previous equation:
35D - 54(20D/27) = 2106

Simplifying the equation:
35D - 1080D/27 = 2106

Now, let's multiply through by 27 to get rid of the denominators:
945D - 1080D = 56754

Combining like terms:
-135D = 56754

Dividing by -135:
D = -56754/135
D ≈ -420.4

Since the number of muffins cannot be negative, we will discard this negative solution.

Therefore, Diana had x = 0 muffins at first.