sarawutc wrote:I have a question... the question says "with replacement". Doesn't it mean that you can have 3Ps, 3Es, and 3Rs. I'm so confused.
Yeah, I didn't like that phrase, so I just ignored it

I have no idea what the author of the question intended, but you can be certain that an official GMAT question would never contain such ambiguity.
The question,
as I read it, is asking asking us to choose 3 letters from PEPPER. So, for example, we can't have three R's.
If the question intended us to be able to use up to 3Ps, 3Es, and 3Rs, then it doesn't make any sense to mention "PEPPER." The question should have just asked, "If duplication is permitted, how many 3-letter codes can be formed using only P's, R's and E's?"
Of course, that still may have been the author's intention. We can't be sure.
Let's answer the question, "
If duplication is permitted, how many 3-letter codes can be formed using only P's, R's and E's?"
Take the task of building 3-letter codes and break it into stages.
Stage 1: Select the first letter
We have 3 letters to choose from (P, E, or R), so we can accomplish stage 1 in
3 ways.
Stage 2: Select the second letter
We have 3 letters to choose from (P, E, or R), so we can accomplish stage 2 in
3 ways.
Stage 3: Select the third letter
We have 3 letters to choose from (P, E, or R), so we can accomplish stage 3 in
3 ways.
By the Fundamental Counting Principle (FCP) we can complete all 3 stages (and thus create a 3-letter code) in
(3)(3)(3) ways ([spoiler]= 27 ways[/spoiler])
Cheers,
Brent
Aside: For more information about the FCP, we have a free video on the subject:
https://www.gmatprepnow.com/module/gmat-counting?id=775