It's possible that there is something wrong with this level.
When running it from the IDE (shift+return), it's possible for your character to pick up a coin after reaching 25 coins. When you return to the X to tell the archer how much gold you have, the character will have 26 coins, but say he has 25. Then you fail the level.
When submitting the solution, which randomizes the coin placements, the character may pick up exactly 25, then go to the archer and say "25" and pass the level.
This is a bit confusing for the user as the IDE-ran solution fails but the submitted solution can actually be correct. I only found this out after hardcoding hero.say(totalGold +1) to see if I could pass by cheating.