```
def judgeSquareSum(self, c):
def is_square(N):
return int(N**.5)**2 == N
return any(is_square(c - a*a)
for a in xrange(int(c**.5) + 1))
```

Without loss of generality, let's consider only `a, b >= 0`

. This is because if say, `a < 0`

, then we may also find a solution using `abs(a)`

.

Now, `a*a = c - b*b <= c`

, because `b*b >= 0`

, and `0 <= a <= sqrt(c)`

is a necessary condition for a solution.

Let's try each `0 <= a <= sqrt(c)`

. For each choice of `a`

, we must have `b*b = c - a*a`

. There will be a solution if and only if the right-hand-side is a perfect square.