 # [Solved] Problem in Python code for LOC172 - "How many Pizzas"

I solved the above problem in C++ (C++14), but my Python (PYTH 3.4) solution is getting WA.

My Approach :-

• Store the end-points of Y - Coordinates of the range each robot in an array - “Coord”.
• Sort the array - “Coord”.
• Generate the new end-points using coordinate compression, so that the new coordinates lie in the range [0, 2*N], where N = Number of robots.
• Now, the max number of overlapping intervals is the required answer.

I’m unable to find the error in the Python code.

C++ (C++14) Code (AC) - https://www.codechef.com/viewsolution/13888744

Python (PYTH 3.4) Code (WA) - https://www.codechef.com/viewsolution/13888800

```a = lower_bound(Coord, r[i]-r[i])
b = lower_bound(Coord, r[i]-r[i])```

Pretty sure that will be

```a = lower_bound(Coord, r[i]-r[i])
b = lower_bound(Coord, r[i]+r[i])```

Also, this doesn’t affect the algorithm, but `r=[0,0,0]*n` actually makes a list of size 3n filled with zeroes, which I don’t think you intended.

2 Likes

Thanks @meooow, that was the problem. Maybe I just copied the above line and forgot to change the minus ‘-’ sign.

Yeah, that happens 1 Like
//