[Community Puzzle] Nonogram inversor

https://www.codingame.com/training/hard/nonogram-inversor

Send your feedback or ask for help here!

Created by @LaurentBouvier,validated by @bbb000bbbyyy and @Razovsky.
If you have any issues, feel free to ping them.

In Cat test seems an excess space at the end in input data.

I just removed a white space at the end of the 7th line (I think) in the Cat test.

What you mean logicaly? I had solwe all questions in some way. Every time I operate with 1 line only (wertical or horisontal). But tests say it is unlogical :( Even sinple test 5x5
    Here is it:
    // It is raw question:
    Tier: 1 remaining: 25
           1  3  2  5  1 
     1     .  .  .  .  . 
     1  3  .  .  .  .  . 
     3     .  .  .  .  . 
     1  1  .  .  .  .  . 
     1  1  .  .  .  .  . 

    //1. Lets  start from rows 1 by 1: (x = 1; o = 0)
           1  3  2  5  1 
     1     .  .  .  .  . 
     1  3  x  o  x  x  x 
     3     .  .  x  .  . 
     1  1  .  .  .  .  . 
     1  1  .  .  .  .  . 

    // 2.0 Lets now watch on colls 1 by 1:

           1  3  2  5  1 
     1     o  o  o  x  o 
     1  3  x  o  x  x  x 
     3     o  x  x  x  o 
     1  1  o  x  o  x  o 
     1  1  o  x  o  x  o 

    Tier: 2 remaining: 0
    Thats all. What is unlogical here?

cant do monowidth font here

Yes you can:

Here I can.
1 Like

Other 5 sample tests are ok, But validation only 2/5. If you give me any validation or other can print absolutely logical steps 1 by 1.

I removed another whitespace from validator 4 (which made my solution crash as well), so maybe you get 3/5 now.
Personally I think validator 4 is the hardest (at least for my solver), a bit like a chessboard pattern.

My mistake. In output format was nothing instead 0

The description could be confusing because ‘black’ is illustrated as white block in the graphics!

Yeah, Finally got it right :muscle:
Nice puzzle, I loved it :star_struck:

0
1
0
1

It takes a number of iterations to finish the deductions.
Validator 4 is the hardest due to the many little bits of elements. Still need to improve the deduction algorithm to avoid time out in v4.

Hello,

I have finally completed my solver :slight_smile: I have spent a lot of time on it, and I’m pretty satisfy of the result. I have mixed a deductions part for 95% of the cases and brute force the remaining 5%.
It’s work very well. I have tested it on very big nonogram.

However, the validator4 (dinosaur) is still reporting red. Could you please tell me why ? All the others tests I have made are working, and I’m blocked, because I don’t know what to look for.

This is a bit frustrating to be honest :slight_smile: Would it be possible to send me the input of the validator 4, so I can check in detail why it’s not working ?

Thanks in advance !
Ben

1 Like

it will be easier by giving it to you:

Input

20 15
2 1 2 1
3 3 4
1 2 5 1
1 3 1 1
2 3 3
4 2 1 1
2 2 3
2 1 1
3 3
2 4 2
2 3 1
2 1 2
1 5
1 3 2 2
2 4 1
1 2
2 4
2 3 1
3 2 1
6 2
4
2 2 5
3 1 3 3
2 1 2 2
1 2 1 2
2 3 1
2 1 1 1 2
2 2 1 1 1 1
4 2 1 2 1 1
1 1 4 1 1 2 1
1 1 3 3 2 1
2 1 3 1 3 1 2
1 1 1 1 1 1 1 1
1 3 1 1 1 1 1 1
4 3 3 2

Output

1 3 1 4
3 2
1 3 2
2 2 5
3 3 1
1 2 1 2 1
4 2 1 1
5 2 1 3
3 3 3
2 3 2
1 7 1
1 4 5
1 6 2
1 4 1 1
1 6 1
2 10
2 5 2
3 3 2 1
4 4 1
6 1
1 15
2 4 5
2 3 2 3
2 1 2 6 2
3 1 1 8 1
3 1 9 1
2 2 5 4
1 1 3 1 1 5
1 2 2 3 1
1 3 2 1 1 1
2 2 2 1 1 1
1 1 1 1 1 1 1
1 2 1 3 1 1 1 1 1
1 2 2 1 1 1 1 1
5 1 2

Thanks ! I will test it :slight_smile:

Well, my solver solve it without issue.

On my computer (I’m using visual studio to be more comfortable than the online IDE), it’s take 6s du resolve.
So maybe it’s the execution time which make the validator 4 to fail.

I will try to improve it.

Grille complete et résolue !
|0|0|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|1|1|2|
|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5|6|7|8|9|0|
----------------------------------------
|-|@|@|@|@|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|1
|@|@|-|-|@|@|-|-|-|-|@|@|@|@|@|-|-|-|-|-|2
|@|@|@|-|-|@|-|-|-|@|@|@|-|-|@|@|@|-|-|-|3
|-|-|@|@|-|@|-|-|@|@|-|-|-|-|-|-|@|@|-|-|4
|-|-|-|@|-|@|@|-|@|-|-|-|-|-|-|-|-|@|@|-|5
|-|-|-|@|@|-|@|@|@|-|-|-|-|-|-|-|-|-|@|-|6
|@|@|-|-|@|-|-|@|-|-|-|-|-|@|-|-|-|-|@|@|7
|-|@|@|-|@|@|-|-|-|@|-|@|-|@|-|-|-|-|-|@|8
|@|@|@|@|-|@|@|-|-|@|-|-|@|@|-|-|-|@|-|@|9
|@|-|@|-|-|-|@|@|@|@|-|-|@|-|@|-|@|@|-|@|10
|-|-|@|-|-|@|-|-|@|@|@|-|@|@|@|-|@|@|-|@|11
|-|@|@|-|@|-|@|@|@|-|@|-|@|@|@|-|@|-|@|@|12
|-|@|-|-|@|-|@|-|-|-|@|-|@|-|@|-|@|-|@|-|13
|-|@|-|-|@|@|@|-|-|@|-|@|-|@|-|@|-|@|-|@|14
|@|@|@|@|-|-|-|-|-|@|@|@|-|@|@|@|-|-|@|@|15


1 3 1 4
3 2
1 3 2
2 2 5
3 3 1
1 2 1 2 1
4 2 1 1
5 2 1 3
3 3 3
2 3 2
1 7 1
1 4 5
1 6 2
1 4 1 1
1 6 1
2 10
2 5 2
3 3 2 1
4 4 1
6 1
1 15
2 4 5
2 3 2 3
2 1 2 6 2
3 1 1 8 1
3 1 9 1
2 2 5 4
1 1 3 1 1 5
1 2 2 3 1
1 3 2 1 1 1
2 2 2 1 1 1
1 1 1 1 1 1 1
1 2 1 3 1 1 1 1 1
1 2 2 1 1 1 1 1
5 1 2
 ------ Execution Time : 6090 -------

Edit :

@TwoSteps, @LaurentBouvier, @bbb000bbbyyy, @Razovsky : poke ?

The validator 4 is bugged. Can someone correct it ?

Thanks !


Well, the validator 4 is bugged…

I have updated my code to reach 1.8s de resolve the dinosaure, submit it again, and fail…

So I have hardcoded the result for this by detecting when the dinosaure is sent as an input, and harcoded the answer --> still an error.

So the validator is wrong. Maybe a blank or something somewhere. Could you please correct the validator ?

Preformatted text`Thanks !
The grid solved :

The grid solved :
|0|0|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|1|1|2|
|1|2|3|4|5|6|7|8|9|0|1|2|3|4|5|6|7|8|9|0|
----------------------------------------
|-|@|@|@|@|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|1
|@|@|-|-|@|@|-|-|-|-|@|@|@|@|@|-|-|-|-|-|2
|@|@|@|-|-|@|-|-|-|@|@|@|-|-|@|@|@|-|-|-|3
|-|-|@|@|-|@|-|-|@|@|-|-|-|-|-|-|@|@|-|-|4
|-|-|-|@|-|@|@|-|@|-|-|-|-|-|-|-|-|@|@|-|5
|-|-|-|@|@|-|@|@|@|-|-|-|-|-|-|-|-|-|@|-|6
|@|@|-|-|@|-|-|@|-|-|-|-|-|@|-|-|-|-|@|@|7
|-|@|@|-|@|@|-|-|-|@|-|@|-|@|-|-|-|-|-|@|8
|@|@|@|@|-|@|@|-|-|@|-|-|@|@|-|-|-|@|-|@|9
|@|-|@|-|-|-|@|@|@|@|-|-|@|-|@|-|@|@|-|@|10
|-|-|@|-|-|@|-|-|@|@|@|-|@|@|@|-|@|@|-|@|11
|-|@|@|-|@|-|@|@|@|-|@|-|@|@|@|-|@|-|@|@|12
|-|@|-|-|@|-|@|-|-|-|@|-|@|-|@|-|@|-|@|-|13
|-|@|-|-|@|@|@|-|-|@|-|@|-|@|-|@|-|@|-|@|14
|@|@|@|@|-|-|-|-|-|@|@|@|-|@|@|@|-|-|@|@|15
------ Execution Time : 1873 ms -------

My Output:

1 3 1 4
3 2
1 3 2
2 2 5
3 3 1
1 2 1 2 1
4 2 1 1
5 2 1 3
3 3 3
2 3 2
1 7 1
1 4 5
1 6 2
1 4 1 1
1 6 1
2 10
2 5 2
3 3 2 1
4 4 1
6 1
1 15
2 4 5
2 3 2 3
2 1 2 6 2
3 1 1 8 1
3 1 9 1
2 2 5 4
1 1 3 1 1 5
1 2 2 3 1
1 3 2 1 1 1
2 2 2 1 1 1
1 1 1 1 1 1 1
1 2 1 3 1 1 1 1 1
1 2 2 1 1 1 1 1
5 1 2

Did you try running the validator in the CodinGame IDE?

I did using your code and I got a bunch of 0 below your answer. Also this:
image

I’m not too familiar with the puzzle as I have not solved it but here it seems an issue with your code. Could you double-check?

Hello,

No, I was not aware it was possible ! I just made the test, and indeed, a lot of 0 are displayed.

I have found why : i forgot to remove the call to the standard solution output when the puzzle is really resolved.
For the blank at the end, I have tried some variation, just in case :slight_smile: but unsuccessfully.

Now the hook is working, at least it’s allow me to complete the puzzle, but I still don’t know why the validator 4 was failing. Maybe a timeout. A good improvement can be to display what is the reason of the failure in the validator section.

Anyway, thanks for you help :slight_smile:

3 Likes

Are single-line deduction rules enough for this CG puzzle? I am currently stuck at 80% (ide test 5 and validator 4 failing) using a bunch of such deductions repeatedly.
According to the wikipedia article, some puzzles might also need to tentatively color cells and to look for contradictions. Did anyone solve it without this, using only simple deductions?