Could u please tell me why is this code not working?

Point Of Impact

Problem Code: BILLRD

I think my approach should work well… but it isnt working.

https://www.codechef.com/viewsolution/42919464

1 Like

I think you are missing on some important base conditions here (Corner points: eg: if x == y && (x != 0) then N and N should be final answer and not x and y, otherwise it’s 0, 0). Plus your the coordinates should change for every impact as in if (k % 4 is equal to 3) then it the coordinates X and Y should change 3 times as the point will be hitting 3 times unless it hits a corner then that will the answer. So improve your wall hitting conditions (thought : maybe use a loop from 1 to k (modulus value) or maybe just change values of points manually, what that loop was going to for each iteration, eg: if k == 1: then possible change in coordinates , for k == 3: changes from k == 2 + k == 1, etc, i.e Use of if… if … if , instead of if … else if …else if) and also think of other base conditions.
Hope that helps !

3 Likes