[Community Puzzle] Go competition

https://www.codingame.com/training/medium/go-competition

Send your feedback or ask for help here!

Created by @OptiPanda,validated by @Alain-Delpuch,@Niako and @Stilgart.
If you have any issues, feel free to ping them.

Hi, I’ve not solved nor attempted to solve this puzzle, but just wanted to say that as a Go player, it looks very strange.

Just in the statement, to read:
“Every board is in a stable position”

and then to have:
Example (with only a 4x4 grid):

.BW.
..BW
BBBW
....

This example is not a stable board at all.
Or rather it is and actually all W stones are dead, the only real score here is B 16 (13 + 3 dead W stones) and W 6.5, so result is B+9.5
Very different from the expected result W wins…

Hi ! It’s just an example here to explain how to count ! We just consider here that nothing will be added and nothing must be removed.

The example is not the best (I give you that), but it’s just an example.
The first test is a good example but harder to apprehend at first sight than this one !

Might have been better with two eyes for both ?

.BW.
BBWW
.BW.
BBWW

After transformation we have:

bBWw
BBWW
bBWw
BBWW

6B + 2b = 8 for BLACK
6W + 2w + 6.5(komi) = 14.5 for WHITE

WHITE is the winner.

1 Like

Yeah this example is way better in my opinion :slight_smile:
Also I gave a quick look to the test cases, and Test - Basics 3 is not a stable / finished board either. Others look fine.

Hi, is it possible to know the last validator test. I don’t pass it and I have no clue why :confused:

Thanks !

Me too, last validator failed :confused: . Maybe there is a full empty line ? I have no idea.

@vecna & @PLSQL: Nothing unusual about the last validator.

I have the impression that all situations are already tested in Test - Medium 2, make sure that you not only get the right result, but also generate the right territories on this board.

1 Like

No there’s not ^^ !

And yes, lasts validators are just bigger boards

I passed all the test cases, but the last validator fails. Probably there is a particular scenario that is not covered by the test cases. It would help adding some more tests.

2 Likes

Hi, I really enjoyed the puzzle but it was not obvious to me that an empty cell has to be surrounded in just the 4 adjacent cells. I worked with all 8 surrounding cells and got stuck before I realized this. Anybody else have this problem?

me too, problem with the last validator!!

cc @QossMean

According to @Niako and @OptiPanda 's comments above, there is nothing specific about the last validators, they’re just bigger boards. You should then look to optimize your code.

1 Like

It would probably be best to invert the test with the validator. Because if there really is an optimization problem, we should know this during the execution of the test and not during the validation.

@QossMean Each validator is similar to the corresponding test: Same size, comparable content of the board, mostly the same particular cases are tested. There should be no optimization problem as this is solvable in linear time in the size of the board (at most 19²).
To determine whether you have a performance issue or not, simply measure the runtime of your code on the last testcase.

That said, CG should definitely mention the reason (WA, TLE, RE, etc) of each rejected validator.

@Niako I have 16 miliseconds on the last test, so this is obviously not a performance problem. It’s most likely I’m missing one simple rule that is present in the last validator, but is not in the other tests.

i’m having troubles with the Hard test case 1
the input is

19
.W.WW...WWWB...B.W.
WWWBWW..WWBB..BBWW.
BBBBBW.W.WWB.BBWW..
...BWW.W..WWBBW.WW.
...BBBW...WWBWW.W..
....BW.WWWBWW..W...
...BBWWWWBBBWWWW...
..BBWBBWBB.BW...WW.
.BWWWWBBBBBWWW...WW
..BBW.WB.BBBBW.....
..BW.W.WBBWWW......
..BWW..WBWWBWW.....
...BW.WWWBBBBWW....
...BW.WBWB.BWWWW...
..BWWWBBB.BBWBBWWW.
..BB.WW.BBBWWBBBBWW
...BBBWWB..BWWBWBBW
....BWWBB..BW.WWB.B
...BWWWWB..BBW.WBB.

and i end up with

wWwWWwwwWWWBbbbBwWw
WWWBWWwwWWBBbbBBWWw
BBBBBWwWwWWBbBBWWww
bbbBWWwWwwWWBBWwWWw
bbbBBBWwwwWWBWWwWww
bbbbBWwWWWBWWwwWwww
bbbBBWWWWBBBWWWWwww
bbBBWBBWBBbBWwwwWWw
bBWWWWBBBBBWWWwwwWW
bbBBWwWBbBBBBWwwwww
bbBWwWwWBBWWWwwwwww
bbBWWwwWBWWBWWwwwww
bbbBWwWWWBBBBWWwwww
bbbBWwWBWBbBWWWWwww
bbBWWWBBBbBBWBBWWWw
bbBB.WW.BBBWWBBBBWW
bbbBBBWWBbbBWWBWBBW
bbbbBWWBBbbBWwWWBbB
bbbBWWWWBbbBBWwWBBb

which give me 204.5=(198+6.5) whites instead of the 203.5 expected.

i can’t identify the issue, which is one is the bad cell ?

WoW
The problem can solved without recursion or flood-fill in O(n^2)

First row, 3rd character from the right, should remain ‘.’.

1 Like

I finally managed to get 100%. The problem is it’s not clear enough what we should do when there are cells disputed by both players on both horizontal and vertical lines. First I thought only the horizontal line counts, but it turns out also the vertical column counts. Also, it’s a draw if both players have at least 1 intersection, it doesn’t matter if a player has more intersections that the other. Hope this helps someone.

1 Like

I finish this puzzle
I have a question about a modified test 6 Test - Medium 2
what about if the test was

...WWWBB.....
..W.WBB.B....
...WB..B.....
WWWBB..B.B...
BWBB......B..
BB.B...BB....
..B...B.WBB..
BB.BBBBWWWBBB
BWB.BWB.W.WBW
WWWBBWBBW.WBW
..WWWWWW..WWW
.............
B...W........

only the last line changed
The result should be like this ?

wwwWWWBBbbbbb
wwWWWBBBBbbbb
wwwWBbbBbbbbb
WWWBBbbBbBbbb
BWBBbbbbbbBbb
BBBBbbbBBbbbb
bbBbbbB.WBBbb
BBBBBBBWWWBBB
BWBBBWB.W.WBW
WWWBBWBBW.WBW
..WWWWWW..WWW
.............
B...W........

Best regards
JM