https://www.codingame.com/training/medium/rock-paper-scissors-war
Send your feedback or ask for help here!
Created by @java_coffee_cup,validated by @Deltaspace,@selenae and @CyberLemonade.
If you have any issues, feel free to ping them.
https://www.codingame.com/training/medium/rock-paper-scissors-war
Send your feedback or ask for help here!
Created by @java_coffee_cup,validated by @Deltaspace,@selenae and @CyberLemonade.
If you have any issues, feel free to ping them.
Very fun !
Very cool puzzle!
But I don’t know why I don’t pass the Random test case and the fourth and seventh validator after submitting. Foreach time step I create a new map based on the old map mapping each cell according to the rules. For each cell I collect the adjacent winner species and when there is more than one winner I put the winner in the cell that defeats the other winner. Don’t know what I have missed…
Hard to tell where the bug is by a description of approach. But as the Random test case caught you in red, you can make best use of it to find out the bug.
If you are in total deadlock, you can send me your day 1 to day 10 result of Random test case. I can tell you which one derails from the correct result.
I had the same problem and found the probelm description “When two different life forms are defeating the life form on the same location at the same time, the two winners will fight each other again to decide who is the final winner to occupy the location at the end of the day.” doesn’t quite cover every case.
…doesn’t quite cover every case
The description is accurate to cover all cases. Please quote a solid counter example if you disagree.
Each life form do have two different predators.There will never be more than 2 different life forms winning a war in the same location on the same day.
Same life form can fight into the same location from different directions but they do not fight against themselves.
To be fair, I’m refering to the fact that it is possible for more than two winners for each locations, thus it’s not just “two winners” who need to fight each other. In the test case my code originally failed, three additional fights were required, in order to find an overall winner.
There will be at most two unique winners after the first fight. The second fight will resolve the final result. If you need to program a third or fourth fight, it is not optimal approach. Warriors of the same life form will not fight each others.
Thank you. I have found out my problem
I have pushed all the winners in one list, so there were multiple winners of the same species in the list and when finding out the end winner I only used the first two winners in the list which can be the same then.
Used a set instead now. Maybe there should be a smaller test case covering this, but dunno the order could be different each time.
Silly mistake. Today I just looked at it again and I have found it instaneously. Do these spoiler tags work?
apparently not…
I think you’re assuming there are more than 2 winners because you might be counting the owner of the cell as one of them. But if there are others opponents, it means that he lost against them. Imagine this scenario :
Owner won against left & top neighbors.
But lost against right and bottom.
[owner, right, bottom]
won some fights. Thus, you might assume they’re all winners.
And yet, the owner is already out. He will not win against [right, bottom]
(already lost once)
Only [right, bottom]
have to fight for this location and you’ll have your winner.
Thank you for this spoiler. I had exactly the same problem (failing Random test case and fourth and seventh validator). I would not have known where to start to debug.
Very nice puzzle by the way!