# solving the triangles problem (see log for definition) - version 1 # defining the content of the innermost loop as a single atomic operation # (which takes a constant time), # and p as the input size, # the complexity is O(p**3) def nirt_v1(p): cnt = 0 for a in range(1,p): for b in range(1,p): for c in range(1,p): if a < b and a+b+c == p and a*a+b*b == c*c: cnt += 1 return cnt