[Community Puzzle] The Frog Jump 1


#22

@6po
“Distances are in meters, rounded to the nearest centimeter. That is, distances are rounded to the nearest multiple of 0.01”

What do you get when you round your 0.0363 and 0.0771 jump distances? :wink:


#23

Thanks for making me feel so stupid ! :grinning:
I read this “rounded” statement but I didn’t measure it was useful in this context.

Thanks @Mercy38


#24

Still got this validator problem (using Python3) for the 6th case. Any idea ?


#25

Is it the 0,0 validator?


#26

Yep. I finally found the solution. It seems the problem was that I was looping through the list to find the position of my frog. I rather inserted my computed distance into the list, sorted / reversed the list and output the index+1 of my computed distance.
Thanks for your help.


#27

I am a bit confused, “The frog isn’t at 0 0” validation fails.
All test cases pass and all other validation tests pass.
I do use the frog’s starting position and cant think of the problem.
My frog in the same test case has a jump length of 3.94m if that helps compare with other peoples results.
Did anybody experience this and what was changed to get100%?


#28

What if your frog is the last one?


#29

I never considered that possibility!

100% achieved, thanks for the hint.


#30

@Pyoroalb

Hello, I have a problem with the resolution : all my tests pass.
But the test n°7 (“A different angle”) of the validator don’t pass.

I double check, the angle can be whatever the results seems to be the one expected (0 meter if angle == 90°, negative x if angle is between 91° and 179°, etc.).

Can someone tell me what’s wrong ? Thank you in advance :slight_smile:


#31

I did not use initialX, initialY, mass and a and still got 100%.
I think there’s something wrong with the Validator or my Solution is just lucky…


#32

Same as @Hodvidar. No clue why. On Submit this test fails


#33

Dear i also was unable to submit one test.
i found the solution.
My loop for checking the position was one to small.

for (int i = 0; i < frogNumber; i++)

changed to

for (int i = 0; i < frogNumber+1; i++)

and it was oke

Kind regards


#34

for (int i = 0; i <= frogNumber; i++)

will also work


#35

I don’t understand how this did not cause you an “out of range” exception @BartSw.
I didn’t pass validators 6 and 7 either, and for me the solution was different:

I had an array with the frog distances sorted in descending order, I was going through it and stopped when I found a value smaller than the value of my frog (meaning that it was the first frog that was less strong than mine).

Instead, I proceeded more simply: I added the value of my frog to my array, THEN I sorted it in descending order, and finally I just had to find the index of the value of my frog in this list (+ 1, because frog positions start at 1 while the index of my list starts at 0).

Good luck!


#36

Hi @tarapitha,@dbdr.

I passed all the test cases, but the validator indicates as follow even if I have no hard coded solution
“The following validators differ from the puzzle test cases to prevent hard coded solutions.”

So what should I do to get 100% ???

Thanks :wink:


#37

Hello! This information is too scarse :slight_smile: The validator should display the case numbers that result in nonmatching answers. Could you please include the problematic case numbers here? You could also check for rounding errors or exceptions generated by division by zero or square root from negative numbers.


#38

Hi,
Thanks for your answer.

I’ve checked for rounding errors and other exceptions, but did not get the point.

When I play the test cases, I get success for all of them, but when I try to submit the code, the case n°6 - The frog isn’t at 0 0 appears in red with the message :
The following validators differ from the puzzle test cases to prevent hard coded solutions. This is why you can have some fails here even if all of the tests provided in the IDE have been successfully passed.


#39

Hodvidar: I have a problem with the resolution : all my tests pass.
But the test n°7 (“A different angle”) of the validator don’t pass.

@Hodvidar,
Can you pass this custom test?
8
0.04 0.07 0.09 0.10 0.10 0.11 0.1 0.09
0 0
125
60
1.02
0 -9.81
Expected:
5

I found out that comparing float to double can give you unexpected results. So I would suggest not mix them up.