[Community Puzzle] The Frog Jump 1

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

@Niako

---

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. :slight_smile:

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 :slight_smile:

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.

Thx @java_coffee_cup.

I also had to feed radian to the sin 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