[Community Puzzle] [Advanced] Graffiti on the fence

I can’t validate 5th after submission… But I pass all 13 tests.
It’s really frustrating !
What’s so special in 5th ? Can you reproduce this particularity in a test case ?
Thanks.

100
10
0 2
2 3
3 20
20 30
30 40
41 60
60 70
70 88
88 99
40 41

Highly likely there is a bug in your code. Not sure what has activated it to cause failure. May be you can try this test.

1 Like

I assume it’s in my code. The problem is when you can’t debug it :wink:
My output for this : 99 100

We turn around, I just need to put 5th validator in tests cases (copy/paste)…

Hi
can you give me an example for the 9th validator?
Every validatior an test passes but the 9th

Thank you!

Validator 9 is very similar to its corresponding test case, Long fence 4. Or, it is a simpler version of Long fence 4.
There is a cluster of ranges in one end, and a few ranges on the other extreme end.

To debug errors in the black box is difficult. One practical method is:

  • write a sure correct but slower solution, and
  • write a puzzle generation engine, to produce similar puzzles but in a shorter range, to allow the slower solution to pass easily, and
  • automate puzzle_generation + sure_correct_puzzle_solving + fast_buggy_solution_running + crosscheck_two_solutions.

The bug should reveal itself under this massive sampling and cross-checking.

Hi,

Can someone give me a clue on tests 8,10 and 11, i passe all the other tests.
For the 8th test i got this output :
0 2
9979 56143
1896211701 2000000000
993349 36086098

failed

Found :
9979 56143
Expected :
993349 36086098

is there an order to respect ?

As it is stated in the output requirement :

A list of unpainted sections, one section on each line, by format st ed,
sorted by st in ascending order.

Here, you have another problem, your first output line should not be printed, there is a bug in your code.
Do you use a data type large enough to handle the fence size ?

Hey, I can’t get validator 10, even tho every other test is passed…
Any clue / test case so I could figure it out ?

Thanks

Validator 10 is very similar to its corresponding test case “Long fence 5”.
It has ranges scattering along the full length of the fence, most of them are in DEC order in the style of the test case.
As the norm, watch out for the edges (0 and the max length), for all kinds of overlapping, for duplication, for correct order of output.

if still at lost…
As suggested above, if you have a sure correct but stupid algorithm to find solution for a much shorter length, use it to cross-check your clever and bug-hidden solution. This approach is often used in the work place in acceptance tests, to check validity of new system replacing old system.

This was a fun challenge! Especially since I’ve got stubborn and wanted to completed it by myself without any hints. Took me a while but I did it!

At first I proved myself to be a dumbass with zero reading comprehension skills as I’ve tried masks. Soon it became apparent that declaring list is strictly against keyword “array forbidden” and I had to rethink my approach.

Second attempt was formally correct but inefficient. I was basically looking for section edges by iterating through each meter of the fence and comparing it with previous section. I was basically only detecting edges of painted/unpainted sections which didn’t explicite state whether it is painted or un[painted section but that was simply fixed just by checking if the first meter is painted or not.

Finally I reached the only possible conclusion: to make efficient algorithm I will have to operate on input array of painted sections, without iterating through fence. With that I found my solution: merge all painted sections that can be merged, sort them by starting position and now the problem of basically finding their “negative” is much simpler.

2 Likes

Use Linked List to avoid memory wastage.

Maybe I am late, but I was also having diffculties with Long Fence 5. My problem was in function boolean isCollide(Range r1, Range r2). The logic was broken when r1 element was in range of r2 element that started from zero. I guess because of lucky number combination, this test sometimes can trigger some logic holes that other test cant.

Hi guys,

I just solved this one using Python3.
I have recorded all the reports in a list and then sorted the list…

Has any of you solved this without sorting the list? Could you share?
What about doing it “on the fly” with out saving the reports?

Cheers