At HRT we are trying to saturate the hypercube

Question:

 

Answer:

Please find the attached python code:  
def getSquares(X,Y): 	
  s = set() 	
  for i in range(len(X)): 		
   s.add((int(X[i]),int(Y[i]))) 	
  count = 0  	
  a = list(s) 	
  for i in range(len(X)-1): 		
     for j in range(i+1,len(X)): 			
       x1,y1 = a[i][0],a[i][1] 			
       x2,y2 = a[j][0],a[j][1] 			
       if (x1 > x2): 				
         tmp = x1 				
         x1 = x2 				
         x2 = tmp 				
         tmp = y1 				
         y1 = y2 				
         y2 = tmp 			
       x3,y3 = x2+(y1-y2),y2+(x2-x1) 			
       x4,y4 = x1+(y1-y2),y1+(x2-x1) 			
       if ((x3,y3) in s and (x4,y4) in s): 				
           count += 1 			
       x3,y3 = x2-(y1-y2),y2-(x2-x1) 			
       x4,y4 = x1-(y1-y2),y1-(x2-x1) 			
       if ((x3,y3) in s and (x4,y4) in s): 			    
         count += 1 	
return (int(count/4))      
X = [0,0,1,1,1,2,2] 
Y = [0,1,0,1,2,1,2] 
print(getSquares(X,Y))

Leave a Comment