Thanks for letting me know, looks like I will have to give up on this one then!
I ended up solving it, i will try to figure out how i had higher numbers, itās possible i was killing aliens before they damaged me, at an incorrect turn ratio. I was getting 2800 on the second practice task. Instead of the expected 1700, but getting 3200 (correct) on the first one. So it may have been bad math. possibly not including armor or something. I apologize.
@Skwerl23 If you have counter-examples to say the puzzle is incorrect, prove it.
No need to show how you arrived at it. Just show details of your fighting plan in an example.
@java_coffee_cup i think it was entirely my fault, and realized a few micro flaws. I now have a working solution, which BTW confuses the heck out of me. Division is the least i would expect to be correct.
If you read the whole thread carefully it pretty much demonstrates how this division is not only a good heuristic but actually the optimal solution to this problem.
Itās funny that among people who solved this problem, thereās a non negligible proportion who had an intuition of the formula, like āI want to favor low T and high D so letās try to minimize T/D and see if it worksā, and itā¦ worked.
Somehow they might have felt like they hacked the problem without fully understanding it.
So yeah if you can relate to this, and wonder if your solution was pure luck or not, and if it woud have worked with other validators, actually yes, it is the optimal solution.
@pardouin would you mind sending me a private message as to why? Maybe an article somewhere that explains it or something.
Hello everyone,
Iām having issues with the last test scenario āTickle Warsā. I currently pass it in the IDE but not when I submit.
I feel stuck since I have no clue why itās not correct. Any tips?
Thanks
do you validate all other IDE tests? Itās the āsameā test (ships with damage = 1) but with 8 ships.
Yes, I do validate all IDE tests. Thanks for the details, Iāll look into it
I am stuck. In the IDE the only task i do not pass is the swarm, but I dont pass the swarm or close call when i submit the task. currently i am using the metric of damage done to me per turn divided by turns to kill at initiation to sort the targets as priority. i dont want to have to recalculate that metric and resort after every shot is fired but that is the only way i can see to improve my code if that even makes it better at all. any tips would be greatly appreciated
That metric is correct and does not change with time, meaning recalculating it every turn would not change anything. Your problem is likely elsewhere.
Make sure your calculations are done with floats/doubles to avoid automatic integer rounding. Other than that, just print your values to the console to check if somethingās wrong. You fail an IDE test, thatās great, you can debug much more easily than if you simply failed a validator.
Maybe youāre using a floor instead of a ceil when you calculate the number of turns to kill a target.
Or maybe itās the āyou cannot deal less than 1 damageā that is not implemented as it should be in your formula.
i had a round hiding where a ceil shoulc have been got it finally. thanks for the tips
Rust start code has an issue as type variable is a reserved keyword.
nope. I am having a similar situation.
Thank you for this comment. It was enough to get me past the final validator (I put this in the custom IDE).
This is rough, Iām a pretty beginner coder just doing these puzzles as a means to learn. I started this thinking this was ridiculously hard for my level, but have progressed so much and even surprised myself at what i can accomplish with no help, but alasā¦ iām stuck.
My issue is that I pass everything, except āThe swarmā and āClose Callā. Both of which I get shield values alot less than I should. The Swarm should be 212, I get -1013. Close call should be 0, I get -866 (I know both should be FLEE if less than 0 but just printed the values to troubleshoot). Every other test case I ace. I really donāt want to give up. I also donāt want to start typing pseudo code or anything in case it spoils it for anyone else too.
Has anyone encountered problems with taking way too much damage on these two specifically but being fine in every other encounter? The only similarities between the two are both having 20 or more ships.
edit: just to add as iāve seen numerous comments in here about division being the right solution. My own priority system consists of calculating how many turns it takes to kill a ship. this number is taken away from the total amount of turns an encounter will take (turns to kill all ships) which is then multiplied by how much damage this ship takes. ((Total turns - Turns to kill ship) * damage the ship does). The higher this number, the higher the priority it is to kill the ship therefore the highest number of the ships gets targeted first (dead ships get their damage set to 0 so this priority number is also set to 0). This seems foolproof to me and am not convinced yet if this is my issue.
My guess is the difference (as you yourself acknowledge) has to do with how you prioritize the ships. Iām curious, given your choice of heuristic
(Total turns - Turns to kill ship) * damage the ship does,
what does the order of attack on The Swarm test look like? Does your code tend to attack all the FIGHTERS first, then CRUISERs? Do you attack the ones that do the most damage first, in descending order?
I tried to use DFS to solve the problem but it seemed to have a timeout for The Swarm and Close Call cases. Is there a better algorithm?
Yeah, all you need to do is find the good metric to sort the target.
To get the right comparison function, try to imagine two targets and consider two things:
- the damage dealt each turn by a target
- the number of turns it will take to destroy the target
Based on these two, which target would you chose ?