peter bought a bag of candy. He gave away ten percent of the candy too his wife and the gave three pieces to meg. he gave one forth of what he had left to his friend joe and then ate half of the remaining 18 peaces of candy. How many pieces of candy were originally in the bag?

x = original # of pieces

w = gave to wife = 10x/100
m = gave to meg = 3
(x-w-m)/4 = j = gave to joe
18 = x - w - m - j
combine and solve for x

To determine the original number of pieces of candy in the bag, we need to work backwards and reverse the given actions.

1. Peter gave away 10% of the candy to his wife. To find the original quantity before giving it away, we can use the formula: Original quantity = (Given quantity * 100) / (100% - Given percentage)
- Given quantity = 100 (since it was 100% initially)
- Given percentage = 10
- Original quantity = (100 * 100) / (100% - 10%) = (100 * 100) / 90% = 10000 / 90 ≈ 111.11

2. Peter then gave three pieces to Meg. So subtract 3 from the original quantity: 111.11 - 3 ≈ 108.11

3. Next, Peter gave one-fourth of what he had left to his friend Joe. To find the amount Peter had before giving away a quarter, we can multiply what he had left by 4.
- (Amount he had left) * 4 = (108.11) * 4 = 432.44

4. Peter ate half of the remaining 18 pieces of candy. To find the original quantity before eating, we can multiply the remaining quantity by 2.
- (Remaining quantity) * 2 = 18 * 2 = 36

Therefore, the original number of pieces of candy in the bag was approximately 36.