# [Community Puzzle] Rock-Paper-Scissors War

https://www.codingame.com/training/medium/rock-paper-scissors-war

Created by @java_coffee_cup,validated by @Deltaspace,@selenae and @CyberLemonade.
If you have any issues, feel free to ping them.

Very fun !

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.

1 Like

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

[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â€¦

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.

2 Likes