https://www.codingame.com/training/easy/the-frog-jump-1

Send your feedback or ask for help here!

Created by @Pyoroalb,validated by @tarapitha,@dbdr and @anon72424297.

If you have any issues, feel free to ping them.

https://www.codingame.com/training/easy/the-frog-jump-1

Send your feedback or ask for help here!

Created by @Pyoroalb,validated by @tarapitha,@dbdr and @anon72424297.

If you have any issues, feel free to ping them.

Sorry but Wikipediaâ€™s solution wonâ€™t work when x,yâ‰ 0,0.

For me x,yâ‰ 0,0 work in ide but not in the validation

The same here.

Why mass m is in the input but not used in the given formula?

Besides, typo should be further fixed - there is now two â€śStep 3â€ť

1 Like

@nicola1 & @baddger: The other frogs â€śdistancesâ€ť are to be considered as landing x positions. @tarapitha & I have tried to fix that and improve the statement.

So why does only the validator fail?

Purely coincidental I guess. Iâ€™m not in the authorâ€™s mind and his official solution is kinda ambiguous: Either itâ€™s wrong as he has forgotten to subtract x0 from the calculated landing position, or we have to interpret the given distances as positions. The second interpretation does not require to modify the testcases.

Please, how to calculate distance ?

This does not work but itâ€™s just like description :

```
double speed_x = Math.cos(alpha)*speed;
double speed_y = Math.sin(alpha)*speed;
double delta = speed_y*speed_y - 4.0*(b*0.5)*y;
double time = (-speed_y - Math.sqrt(delta))/(2.0*b*0.5);
double distance = a*0.5*time*time+speed_x*time;
```

Thanks in advance.

java?

Be aware that Math.cos() accepts an angle in radian.

3 Likes

unless you changed the wording in the puzzle statement, the given values for the other frogs are *not* related to x0. There is no information about where they started their jumps from, only the distance that they achieved. So thereâ€™s really no reason to even consider subtracting x0 from the values.

Sorry, i misinterpreted your statement about subtracting x0. Your comment is completely correct.

@Cx1 Ok but thanks for you comment anyway, the problem is that obviously distances have to be interpreted as positions, but somebody kinda reverted my modification (without mentioning it in the comments):

Input Line 2 was initially â€ś*The distance in meters of each frog separated by spaces.*â€ť

I replaced it by â€ś*The landing x coordinate in meters of each frog separated by spaces.*â€ť which provides a correct interpretation to solve the problem.

And now itâ€™s â€ś*Frogs jump lengths in meters of each frog separated by spaces.*â€ť which is wrong againâ€¦

Indeed your phrasing was best, since it fits neatly with that 1st rule of ranking: â€śThe further the frog lands, the better the frogâ€™s place.â€ť â€“ itâ€™s not the jump length that is scored, but the landing position!

@Cx1 Actually that ranking rule initially was about the longest jump but was modified by @tarapitha to fit in with the testcases. As I said, there is a tradeoff between modifying the statement to fit in with the testcases and the other way round. The second alternative would have the serious disadvantage of making all currently validated solutions wrong.

1 Like

Thanks, that was the problem with Java

Iâ€™m encountering the same problem as @yoles:

when I do the calculations, I get 0 for distance whereas I should get (according to the test case 1) 0.09 or 0.08.

Iâ€™m quite sure Iâ€™m missing something, but I dunno what.

Thanks in advance.

This same problem has the same solution - feed radian to your cos function.

I got the same problem, did you manage to fix it?

Using the provided calculations, my code fails only for both **On Jupiter** and **A strongest frog** tests (and only in **On Jupiter** validator when submitting my code)â€¦

On Jupiter: My code computes a 0.0363m long jump. With 6 higher jumps, my frog is 7th but expected is 5.

speed_x:0.8833, speed_y:0.5100, delta:0.2601, time:0.0411, jump:0.0363

A strongest frog: I get a 0.077m long jump which is the third best jump but expected is 2.

speed_x:1.1881, speed_y:0.3183, delta:0.1013, time:0.0649, jump:0.0771

Could anyone tell me which intermediate value is wrong ?

Thanks