Today I heard about this site called codility, where the user can conduct various programming tests to check the performance of their code.
When I started, they presented me with this sample test,
Description of the task A little frog wants to get to the other side of the road. Currently, the frog is in position X and wants to get into a position greater than or equal to Y. The little frog always jumps a fixed distance, D. Count the minimum number of jumps that the little frog must complete in order to reach its goal.
Write a function: class Solution { public int solution(int X, int Y, int D); } class Solution { public int solution(int X, int Y, int D); } class Solution { public int solution(int X, int Y, int D); } class Solution { public int solution(int X, int Y, int D); } that, given the three integers X , Y and D , returns the minimum number of jumps from position X to a position equal to or greater than Y
For example, given:
X = 10
Y = 85
D = 30 function should return 3 , because the frog will be located as follows:
after the first jump in position 10 + 30 = 40
after the second jump at position 10 + 30 + 30 = 70
after the third jump in position 10 + 30 + 30 + 30 = 100
Suppose: X, Y, and D are integers in the range
[1..1,000,000,000]; X ≤ Y. Difficulty: expected worst case time
complexity O (1); expected worst case complexity is O (1).
The question was pretty straightforward and it took me 2 minutes to write a solution, the following:
class Solution { public int solution(int X, int Y, int D) { int p = 0; while (X < Y){ p++; X = X + D; } return p; } }
However, the test results show that the performance of my code is only 20% and I scored only 55% ,

Here is the link to the result, https://codility.com/demo/results/demo66WP2H-K25/
It was so simple code where I just used one in a while loop, how could this be done much faster?