[Community Puzzle] Object insertion

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @irmo322,validated by @fungi_star,@Esadruhn and @Rouge_dragon.
If you have any issues, feel free to ping them.

Hi, i have problem with validator 5.
All is green in ide, nothing is hardcoded but i can’t pass this validator and i’m stuck at 85%

Process

1- putting stars from object in array of pair to keep the coordinates
2- scanning grid for point character
3- if point found then loop on stars array to see if grid coordinates + stars coordinates match with another point character
4- save solution in array
5- if solution is superior to 1, then loop to place object in grid

1 Like

Validator 5 is very similar to test case 5 - there is only one way to insert the object and the source and target areas have the same dimensions.

Try something like this:

3 5
.*.*.
*.*.*
.*.*.
3 5
.....
.....
.....

Answer should be:

1
.*.*.
*.*.*
.*.*.
2 Likes

Just found out that my previous code can reach an out of scope for this case.
Thx for putting me on the right way. 100% now thanks to you.

Hi, I try this puzzle for 2h and i didn’t found solution. Any tip can help.
Should i use 2D loop inside a 2D loop?

That is a possible approach, but what you do inside the loops matters more.

2 Likes

Hello @irmo322 ,
I think it’s a very nice puzzle and I thank you for it, nonetheless I would like to make a suggestion in order to avoid discrepancies between the 5th ide test and the 5th validator test:
It might be nice to provide another ide test after (or maybe before) the fifth one with the same conditions (that is to say having an object’s matrice with a similar size as the grid’s matrice) but with an object starting with a ‘.’ instead of a ‘*’ (as it seems to be the condition in the 5th the validator).

Hi @olifasan ,
Thank you for your feedback.
When I created this puzzle, I did my best to respect to the following principles (from codingame documentation):

  • Test cases should cover all specifications
  • Each validator must differ from the corresponding test
  • Each validator should check the same case as the corresponding test

The main idea is that if the solution is not hardcoded and pass all tests, then it should pass all validators.
From @Tyrano 's feedback, it seems that’s not the case.

Can you explain me how a solution can work on all test cases but not on validator 5?
Why starting with a ‘.’ instead of a ‘*’ in validator 5 makes it significantly different than test 5?

Hi @irmo322,
In my case I think it was a way to avoid issues with out of range array elements that made me start comparing the object with the grid from the horizontal index where there is actually a part of the object: * and not void: .
That generated an error for not considering the case where the object has the grid size and doesn’t start with a * . But this error only appeared in validator 5, not in ide test 5 as it starts with a * (neither in the rest of ide tests).