Chef and Inequality | PYTHON | codechef showing wrong answer

i was doing a problem Chef and Inequality i wrote a code and it is working fine for examples but when i submit that it showing result= ‘wrong answer’. HERE IS MY CODE CODE1 but when i changed my code a little bit i just added a min(0,d-c+1/d-i) function in line 12 and 14 and Now it is working and showing result=accepted. here is my that CODE2. i want to know what is wrong in my CODE1 why i have to add that min(0,d-c+1/d-i) function to my code 1 because

1)if d-c+1 is negative it means c>d+1 i have already added an if statement in my code for that case

2)how d-i can be negative because i varys from [a,b]

1)You can remove the max in the case j < c and add (d-c+1),
2)you need to add max(0,d-j) in the else case because although j > c it might be greater than d also. j varies from a to b but it is not written that d > a or d > b. So d-j can be negative
code -CodeChef: Practical coding for everyone

Thanks Bro i got that , You really helped a lot

Welcome :slight_smile: