The mass needed is not as precise as implied by the instructions. I was able to use a mass quite a bit lower than the actual sum.
M = minimum health of all enemies
S = sum health of all enemies
return S-M
This still wins.
Of course doing this requires more work than just adding up their healths, but it might make room for someone that doesn’t code, but just guesses a number and gets lucky with the random seed.
The only thing I didn’t understand is that if the findFriends() method returns the peasants, then why the findEnemies() doesn’t return the ogres? Although you can still solve it with a one-liner, it’s just uglier
I think he meant the health of the enemy with the least health.
The problem in the ref code was that it would subtract the last victim’s entire health even when poisonMass was less than health (resulting in negative poisonMass at the end).
I submitted a patch for this and a few other things:
Fixed poisonAttack calculation
set hero.seeThroughWalls = false (makes it harder to use attacks like chain-lightning, which can kill any remaining ogres)
set ignoreItemGold to true (no income from boss stars => no summoning, although it might not make much of a difference)
replaced munchkins with scouts (for a larger health range and so that health does not need to go above their natural maxHealth)
changed a few words in the sample code (but this could mess with translations)
edit: noticed a typo in the comments: “require mass” should be “required mass”. (was not changed in the above commit)