[Community Puzzle] Asteroids

because of the inputs t1 t2 t3

in great delta A moves 4 steps and t2-t1 = 4
t3-t2 = 1 so it moves one step and stays in bounds

in out of bounds t2-t1 = 100 and t3-t2 = 100
the moves ares the sames

4 Likes

Thanks. I didnā€™t notice the ā€œtā€ variables had valuesā€¦ :face_with_hand_over_mouth:

3 Likes

Hello,
Iā€™m passing all tests from 1 to 9, but Iā€™m stuck on Armageddon ^^ It seems Iā€™m failing on K placement.
I found that the time ratio is 0.5 from T3Bis (imaginary linear T3, placed at 125) to T3. Considering that ratio, the initial move { x: +8, y: +7 } should become { x: +4, y: +3 (3.5 floored) }
But Iā€™m failingā€¦ So am I missing something ? :face_with_raised_eyebrow:
Thanks !

2 Likes

I think I know whatā€™s going on.
I have designed the puzzle with the origin at the top left corner and the y axis increasing as you go down (which I falsely assumed was the implied standard coordinate system for computer graphics) whereas I think you have the origin at the bottom left corner, with the y axis increasing as you go up.
Were it not for the flooring operation the sign would not matter, but it will be problematic when you start having fractional parts like in the last test cases.
I will edit the edit the statement to make it clearer, thank you.

2 Likes

Ohh I see, I would have never guessed thatā€¦
Thanks for the input, Iā€™ll use top as y = 0, should be fine with that.

1 Like

Hey, I passed all test cases, definitely didnā€™t hardcode and Iā€™m only getting 90% when submitting. Apparently I fail at validator 8. Any help would be appreciated, as it is driving me crazy!

Validator 8 is not much different from test case 8. Maybe you can design some custom cases to test your code.

1 Like

You should check your rounding method.
if the number is -0.5, should it be rounded to 0 or -1?

1 Like

I dont think thats the case, my rounding method looks like this
int x3 = (int) Math.floor(x2 + (tFactor * xd));
where tFactor is the ratio of change between t3, t2 and t2, t1 (a double) and xd=x2- x1;

Okay, seems like I solved the validator 8 issue. I always had the correct result, but it seems like the system wanted me to optimize the whole (its not moving in those two picturesā€¦) thing

It turns out the problem was that, given the visible test cases, one could assume asteroids are always given in consecutive order (E,F,G,Hā€¦).
This was not intentional and it was, in fact, not guaranteed in the statement but it turned out that Validator 8 was, unfortunately, the only exception.
Given the nature of Test Case/Validator 8 it is possible to overcome this by simply printing the original picture if both picture 1 and 2 are the same.
However I think it is better to make it clearer so, as usual, I have edited the contribution so that the corresponding test case will also feature a pair of asteroids which are not two consecutive letters.

2 Likes

Ohā€¦ Same here :smirk:

Hi

Can an asteroid disappear if they are all moving horizontally as it happens with asteroids E and J in the test case 9?

As long as an asteroid moves out of bound (whether moving horizontally, vertically or otherwise), it will disappear in the picture.

2 Likes

Thank you
I thought they moved around if they got out of bounds

I have the same issue with Validator number 10 (all my test in ide pass).

So i have tried to test the round of negative number like -0.5 => -1 and itā€™s ok.

The letter Z seems to be taken into account (last test Armagedon itā€™s ok).

So i donā€™t know where i can search. I will take any ideas :slight_smile:

What does your code do in case -1 is calculated?
Also, does the following help you?

If an asteroid position equal to -1, itā€™s not display in the result. (Like test ā€œOut of boundsā€)

I thinked had take care to verified all about this recommandations. The ide tests do not cover all of this ?
I will try to found the issue again and fix them .

Thanks for reply.

Donā€™t know if it will help you, but the five inputs (first line) of the 10th validator are the same than those of the 10th test.

1 Like

Nice puzzle, I understand it wrong at first because I thought that rounded to floor was meaning taking the closest value to the floor. And for me the floor was in the bottom, where Y coordonates are higher. :slight_smile:

1 Like