I didn't want to try to analyze this problem, because the question will
arise of when to stop protecting yourself and go for the kill (also the
question of what part 2 will bring). I just coded a solution that
checks all the possibilities. I can have high confidence that it will
give the right answer.
It's pretty long & I will post it later, maybe.
Henry Rich
On 12/22/2015 4:45 PM, 'Pascal Jasmin' via Programming wrote:
instead of solving this I made tools to interactively test the choice of
spells. These are hard coded to my boss damage of 8 and boss hp of 55.
mana =: +/@:{~
turnskill =: (6 %~ 55 - 4 2 0 +/@:{~ 3 4 -.~ ]) turnsdie =: 9 %~ 50 - 0 _2
0 _21 0 +/@:{~ ] turnsdie1 =: 8 %~ 50 - 0 _2 0 _21 0 +/@:{~ ] NB. part 1
The algorithm assumes that poison is always cast, and regenmana cast when needed
as well. (based on threshold of costs). Poison has to be cast every 3 turns, and
the total spells cast has to be fewer <: than the turnsdie result rounded up.
53 73 173 113 229 (mana , turnskill , turnsdie1) 5 0 2 1 1 # i.5
for example, not casting shield
53 73 173 113 229 (mana , turnskill , turnsdie1) 5 0 2 0 1 # i.5
840 5.83333 6.25
costs less mana, but there is no time to cast 8 spells bc you die in 7 turns.
for part 2.
53 73 173 113 229 (mana , turnskill , turnsdie) 1 2 3 1 2 # i.5
1289 7.83333 8.33333
53 73 173 113 229 (mana , turnskill , turnsdie) 2 1 3 1 2 # i.5
1269 7.5 8.11111
Not really sure why this solution fails, but possibly related to 1 damage at
begining of turn, that is not modelled here. .1111 is 1/9 which signals that I
have 1 hp at beginging of 9th turn, and so die before finishing.
I don't know why these 2 solutions fail though:
53 73 173 113 229 (mana , turnskill , turnsdie) 1 0 3 2 2 # i.5
1256 8.5 10.2222
53 73 173 113 229 (mana , turnskill , turnsdie) 0 1 3 2 2 # i.5
1276 8.83333 10.4444
Though I had bugs and wrong assumptions when building these tools, this
approach did get the answer faster than 80% of the leaderboard.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm