# We shift our origin such that the hunter is at the origin.

The rabbit's original coordinate was x. ( Note that x can be positive , negative or zero ).

The basic observation is that once we reach to the original position of the rabbit, we can kill the
rabbit in atmost 3 steps:
By hitting at x (rabbit is killed if it was stationary)
2By hitting at x+d1 ( where d is a distance calculated by the algorithm explained below ) ( the
rabbit gets killed if it had moved right )
3By hitting at x-d2 ( where d2 is a distance calculated by the algorithm explained below ) ( the
rabbit gets killed if it had moved left )

Now, we have to devise an algorithm to find x.

We assume different initial locations for the rabbit until we kill the rabbit.

First, we assume that x=0.
We shoot at 0.
Case Ìf the rabbit was stationary, it gets killed.
eIse we shoot at 2.
Case 2 Ìf the rabbit was moving right, this time it gets killed.
eIse we shoot at -3
Case 3 Ìf the rabbit was moving left, this time it gets killed.

If the rabbit stiII doesn't die, we assume x=+1.
We shoot at 1.
Case Ìf the rabbit was stationary, it gets killed.
eIse we shoot at 6.( aIready 5 minutes have eIapsed. )
Case 2 Ìf the rabbit was moving right, this time it gets killed.
eIse we shoot at -5.( aIready 6 minutes have eIapsed. )
Case 3 Ìf the rabbit was moving left, this time it gets killed.

If the rabbit stiII doesn't die, we assume x=-1.
We shoot at -1.
Case Ìf the rabbit was stationary, it gets killed.
eIse we shoot at 7.( aIready 8 minutes have eIapsed. )
Case 2 Ìf the rabbit was moving right, this time it gets killed.
eIse we shoot at -10.( aIready 9 minutes have eIapsed. )
Case 3 Ìf the rabbit was moving left, this time it gets killed.

We continue the above process for x=+2 and x=-2 ,x=+3 and x=-3,...and so
on until we reach the actual x0.

e get the following table for the first few values of x:

Assumption for x Shooting points Time elapsed

0 0,2,-3 1,2,3
1 1,6,-5 4,5,6
-1 -1,7,-10 7,8,9
2 2,13,-10 10,11,12

-2 -2,12,-17 13,14,15
3 3,20,-15 16,17,18
-3 -3,17,-24 19,20,21
4 4,27,-19 22,23,24
-4 -4,22,-31 25,26,27
.....
.....

e observe that for a given x0, the time to reach x0 is :
Case 1: x0 is positive:
e need to go though 0,1,-1,2,-2,3,-3,...,x0-1,1-x0, before reaching x0.
Each of the checkpoints require 3 minutes. So, a total of [1+2*(x0-1)]*3 minutes
are required to reach x0. Thereafter, atmost 3 minutes are required to finish the
game. So, the total time is atmost [1+2*(x0-1)]*3+3=x = O(x).

Case 2: x0 is negative:
e need to go though 0,1,-1,2,-2,3,-3,...,-x0-1,1+x0,-x0 before reaching
x0. Each of the checkpoints require 3 minutes. So, a total of [1+2*(x0-1)]*3+3
minutes are required to reach x0. Thereafter, atmost 3 minutes are required to
finish the game. So, the total time is atmost [1+2*(x0-1)]*3+3+3=x+3 = O(x).

Case 3: x0 is zero:
This is a trivial case. It takes atmost 3 steps to finish the game.

ence, the rabbit is finished in O(x) time.

.97..20      03.9208.3  .9.54398706:7023:908 \$4 .70706:70/94 13890.54398706:7023:908 \$4 .70706:70/9470.9208.80   85489.09.80   830.20 \$4 90949.08.41    ( 23:908 .0 907.1907 .9248923:908.                                                               04-807..70706:70/9413890 . %070.41     (   23:908.20 \$4 90949. %070.0.0    0300/94494:              -0147070..4190..0.4190.0    0300/94494:           -0147070..9248923:908.949.1907 .9147..92489    (       ..3  .949.--981380/3  920          ..80 99.03 909209470...80   8074  %88.92489890589413890. 8 .70706:70/9470.92489    (        .