Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Sowing Fire - kept blowing up

I had a difficult time understanding these directions and finally had to search the forum for an explanation. I would build my first trap and get blown up by it. I identified which line of code that was causing me problems. The comments didn’t quite provide enough detail to help me get through on my own. I show the original code and then the acceptable code (hidden).

def buildNextTrapInColumn(columnX,numTraps):
    # Change newY to use % to wrap around and only build trapsInColumn (9) traps per column
    newY = 7 * numTraps + 10 # ∆ Change this to use % 9!
Spoiler - code changed to % 9 that is acceptable
 newY = 7 * (numTraps % trapsInColumn) + 10 

I initially changed the + 10 to the % 9. The post below included the details not to change the current code, just add the % 9 (trapsInColumn) into it. Thanks @Deadpool198 Then I also missed the () to create the proper order of operations.
To summarize, a simple suggestion that the comments for this line of code may need an upgrade to give a few more clear hints.

Another post with same problem

Thanks for point it out @brooksy125. What changes do you think should be made? I can submit a patch to fix it afterwards.

I went back to SteelClaw Gap to see how it was worded there. Since numTraps wasn’t identified for the modulo wrap, I didn’t realize that it was the variable that needed to be wrapped around trapsInColumn. Also, could add the () to the original code or add another comment for order of operation.

# Change newY to use % to wrap around trapsInColumn (9) based on numTraps to only build 9 traps
newY = 7 * (numTraps  ) + 10 # ∆ Don't remove code, but insert % 9 into existing code