[Community Puzzle] Winning Parabola

https://www.codingame.com/training/easy/winning-parabola

Send your feedback or ask for help here!

Created by @Magicien-d-oz,validated by @R2B2,@Alain-Delpuch and @IAmNoob.
If you have any issues, feel free to ping them.

I do not get the optimization principe. For example, how the result (14.6,52.1) is derived in the first example with only one target (50,10) ? Why not for example (45,24.2) insted of (14.6,52.1) ? Both will have distance 0 at this target.

The principle is to ensure that when the arrow has the same abscissa as the target the distance between the two is the smallest. With the solution you propose me at a distance of 50m the arrow has an ordinate of 9.9227… while with my solution at the same distance the arrow has an ordinate of 9.9999… closer to 10 the ordinate of the target.

1 Like

my solution on test 1 is 17,1 24,4 gives a y =9.99997914932769
I think there are more solutons because of the accuracy of the language and implementatiation of the java run time.

Hi, I think you might have miscalculated. Because I checked the solution you submitted to the calculator (independent of my program) and for an abscissa of 50 I get -5. This seems relatively logical because you use a low angle and a low speed. I don’t see how the arrow could reach 50m.

I think there is a problem of precision or something. I pass all the IDE tests but fail at validator far away and vertical shot. I work in Python3 and I tried changing the precision, using math or numpy… no change.
Can you help me ?

Indeed it is quite strange that you pass all the tests but not the validators. You talk about the precisions : did you express your result well at 0.1° and 0.1m/s?

I did yes :slight_smile:

Try to send me your code so I can see where it’s coming from.

Ok I found the problem, I was stuck in a local minima when calculating a rough solution (every degree and every 1m.s-1). So now I check around several local minima with a higher precision to find the solution. All validators passed !
Just a bit strange that I was lucky (or not) to not fall into a wrong local minimum on the IDE tests…

Anyway thanks a lot @Magicien-d-oz for your availability :slight_smile:

1 Like

Congratulations :+1:

9,999951584 vs
9,922737518

14.6,52.1 is half a bee knee closer

Even if indeed the two are close since it may have only one solution is taken the most accurate

1 Like

I am able to get the right results, but not able to beat the time. I am looping through all angles and speed (720000 combinations) and computing y for each x and summing them up for each combination and finding the minimum. I am able to pass the single target tests, but cannot pass the ones with more than one targets. Can you help?

silly mistake Math.pow(a,2) is not the same as Math,sqrt(a) forgot the meaning of t

@Magicien-d-oz could you check out my submission? I don’t understand why would it give correct for 1 and not for multiple enemies

Hello @davidbilla , it’s quite normal that you can’t do this with a code that tests all the possibilities.It’s much too long (when I created the puzzle I had to do this kind of code myself, some solutions could take up to 2 minutes!) You have to find a way to optimize the code speed. To do this reduce the number of combinations to test

1 Like

@StabijJack Haha Good :+1:

@rectifier Is the solution incorrect or is the turnaround time too long?

I am trying to think of a logic to reduce the number of combinations - if I just use the whole numbers combinations for the angles and speeds, it does not come near to the actual results. If it does I can then drill into that angle and speed. Need to focus a bit harder.