[Community Puzzle] Kids blocks

https://www.codingame.com/training/medium/kids-blocks

Send your feedback or ask for help here!

Created by @MNada,validated by @Konstant,@Smelty and @Tony380.
If you have any issues, feel free to ping them.

Are the followings valid solutions?

061
0 6 1

516
5 1 6

No it’s not valid, keep them horizontal.

Think LEGO : you need to clip the studs.

Thanks for the reply. I read the statement a few more times but cannot find any specification about “horizontal only” or “Lego bricks which have studs”.

I know that it’s not said clearly in the statement but I assumed that the " chars were studs in the ascii representation and it was indeed that, I only considered horizontal blocks and my solution finds exactly the expected output.

I implemented extra rules for the vertical placement of blocks. As I am prioritizing horizontal placements, all test cases except the two were just fine to pass.

Had I known the “horizontal only” requirement I should have finished it with half the effort.

A bit of ascii drawing is far from clear enough. The author should make a remedy to the statement to make it more accurate to reflect the intent of the puzzle.

The validation tests are softer then test cases.
The stupid check (if the total area is a not prime numbers) works perfectly to pass validation.

I must be missing the obvious “trick” about this puzzle but I’m struggling to see what condition I should be checking for test case 6 to display “NOT POSSIBLE” instead of “POSSIBLE”.

My approach is to check the divisors of the total area of all pieces combined and if there are no two numbers that multiplied together give the total area it means that it’s not possible to build a rectangle/square.

Obviously this is not the case for test case 6 since my simple criterion doesn’t realise that you don’t have enough pieces, however, I’m struggling to see what check I should be implementing (of course this should also apply to any test condition).

Any help is much appreciated, thanks.

Hi, i’m passing all validators except “validator 2”, can u please share the test (or a “similar” to ) to check and correct my code ? Thanks ! :slight_smile: @MNada

Try testing your code with custom cases where one or two of the three inputs are 0.

Hi ! I (think) i’m covering all possible “0-combinations” , so my error (i believe) is not in cases of zeros problems :frowning:
Briefely my conditions are : if 2 out of 3 are 0 and the other one is == 1 OR all 3 of them are 0 OR the product of them is a prime number (product = 1* x1 + 2* x2 + 3* x3) → NOT POSSIBLE . Am i missing out some other cases ? Thank you very much
EDIT: thx to @5DN1L for help. My error was assuming that prime factorization of the area are always be made of 2 number (i tought the puzzle was made like this on purpose)

1 Like

You forgot to check these cases in validators:

1
0
0

or

0
1
0

or

0
0
1

I suppose all should result the 'POSSIBLE' output.