Continuing from How would you cross puzzle land? and How would you cross puzzle land? Part II, (which by the way still has a solution that hasn't been found).
You have crossed the river of lava with your cash and stroll into the city, and you find that the carnival has come to town, complete with carnival games. But before you get too engrossed in them, you notice a particularly cute person by the name of Sam (I'll let the reader choose whether that's short for Samuel or Samantha) observing one of the games. You walk up and ask "Have you tried this game out?" Sam replies "No, I'm a little suspicious of this one. I think I'll see how some other people do first." You're faced with a carny running a shell game. The carny hides a marble under one of three shells and shuffles them around at breathtaking speed. His challenge: "Care to guess which shell holds the marble? I'll even sweeten the deal: I'll turn over an empty shell after you pick, and you can change your choice if you like." You give him a short stare through squinted eyes as if you're sizing him up, and say "All right, but I'm gonna call forth some supernatural spirits to help me with this one." You then close your eyes and start chanting "Hum, baya baya baya", and start a strange dance that could easily be confused with a neurological disorder. After flailing and spinning around a bit, you say "sorry, the spirits couldn't help me out" and walk off without playing the game.
Sam seems a little put off, "What's the deal with all that 'channeling spirits' mumbo-jumbo?" You reply, "cover, for me to bump the table with my hips while I was doing that stupid looking dance. When I bumped it, I didn't hear a marble rattling under any of the shells, so I walked away." Important point: for those of you who haven't seen the first two in this series, these problems can often be attacked by both logic and, um, less sophisticated wit. Even more important point: your explanation drew a smile from Sam. "I saw some other games that seemed more legit earlier on if you want to try them out" Sam offers. "Sure thing, lead the way."
At the next stand, Sam notices a piece of onyx on the shelf of prizes and asks the carny "What would we need to do to win that?" "For that," the carny replies, "you'll need to get a perfect score on the whack-a-mole game." You take a look at the fair-goers who are currently taking a whack at it, and you're immediately struck by how fast the mole is. Unless you're a drummer, you won't be able to win this game with reflexes alone; you'll have to anticipate where the mole will be. "Let's win that game!" Sam urges, and you sure don't want to disappoint.
PUZZLE TIME: The machine has five holes that the mole can emerge from, numbered 1-5, and two mallets that you and Sam can use for mole whacking. There will only be one mole emerging from one hole at a time. From watching the previous players, you notice that the game starts with some music and a pseudo-random flashing light display that will actually give away the first hole the mole will emerge from. From that point on, the mole will appear from subsequent holes based on which holes were whacked with mallets on the previous turn.
If only one hole gets whacked on a turn, the machine will calculate 1) the number of the hole that was whacked minus one, and 2) the number of the hole that was whacked minus two. If either of those numbers is <1, it will add 5 to that number to bring it in the range of 1-5. The next mole with then jump out from either of those two holes.
If two holes are whacked at the same time, the machine will calculate both 1) the sum and 2) the product of the holes that are whacked. If either of those numbers is >5, it will keep subtracting 5 from that number until it falls in the range of 1-5. The next mole with then jump out from either of those two holes.
If the same set of holes is whacked twice in a row, the game will forego the above rules and the mole will jump out wherever it pleases.
Finally, since a carny is watching you play the game, you're not likely to win a prize if you resort to any obvious shenanigans. Each mallet can only take care of one mole-hole at a time. Remember that you need a perfect score, so no missing any moles. Have at it!