[Community Puzzle] Rock-Paper-Scissors War

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 ! :slight_smile:

1 Like

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.

1 Like

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 :wink:

[spoiler]
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.
[/spoiler]

Silly mistake. Today I just looked at it again and I have found it instaneously. Do these spoiler tags work?

apparently not…