exception handling - Simple Python program checking for intersection points -


the aim of program find points comes under intersection of @ least 2 circles.(space 1000x1000 matrix)

n=input() mat=[[0 in range(1005)] in range(1005)] circles=[]  in range(n):     circles.append(map(int,raw_input().split()))  ans=0  circle in circles:     minx=circle[0]-circle[2]     maxx=circle[0]+circle[2]     miny=circle[1]-circle[2]     maxy=circle[1]+circle[2]     in range(minx,maxx+1):         j in range(miny,maxy+1):             if mat[i][j]<=1:                 if ((i-circle[0])**2+(j-circle[1])**2)<=(circle[2]**2):                     mat[i][j]+=1                     if mat[i][j]>1:                         ans+=1 print ans 

n denoted number of circle circles contain circle center , radius in format [x,y,r] example let circles = [[3,2,4],[2,5,2]] contains 2 circles centered @ (3,2) , (2,5) radius 4 , 2 respectively.

is logic correct?...will trigger exceptions??


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -