# Can somone please explain the error in my code for COKE?

Here is the link to my submission…
https://www.codechef.com/viewsolution/25996305
Please someone explain me the error in it…
Give me some testcase where my code fails.

2 Likes

i think, on line 24;
if(temp>l and temp<=r)
should be changed to
if(temp>=l and temp<=r)
as question says inclusive in range. Also i don’t know much python, but i think this should work.

WrongSolution

1 Like

in loop of 0 to m;
you forget to add one more else if condition.
else if(temp>=k-1 && temp<=k+1) temp = k;

1 Like

By mistake i posted wrong link to my solution,
I have changed it now…

1 Like

Thanks man, It worked.
feeling silly, how can I make such mistakes :\

1 Like

We are humans, it happens.

1 Like

Pls see my new link and tell me where it fails

I submitted my code with inclusive only in first attempt…

Sorry but i don’t know much python. I hope someone else might help you.

1 Like

in line 20 --> temp -=1

1 Like

Yup Thanks…I made a mistake in shorthand operator

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

Can anyone please tell why my code is giving wrong answer ? Please provide the test case it is failing

It’s possible that the final output takes the value 10^6. Consider the case when n = 1, m = 1, k = 1, l = 1, r = 1, temperature of coke can = 1, price of coke can = 1000000. Your program will output -1 where it should be outputting 1000000.

1 Like

Thank you so much ! It worked

1 Like