Advertisement
vladislav_larionov

squares

Dec 11th, 2021
1,748
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. # http://sovietov.com/txt/triangle/triangle.html
  2.  
  3. def triangles(g):
  4.     n = len(g)
  5.     for a in range(0, n):
  6.         for b in range(a + 1, n):
  7.             if not g[a][b]:
  8.                 continue
  9.             for c in range(b + 1, n):
  10.                 if g[b][c] and g[a][c]:
  11.                     print(a + 1, b + 1, c + 1)
  12.  
  13.  
  14. def squares(g):
  15.     n = len(g)
  16.     for a in range(0, n):
  17.         for b in range(a + 1, n):
  18.             for c in range(b + 1, n):
  19.                 for d in range(c + 1, n):
  20.                     if g[a][b] and g[a][c] and g[c][d] and g[b][d]:
  21.                         print(a + 1, b + 1, c + 1, d + 1)
  22.  
  23.  
  24. if __name__ == "__main__":
  25.     matrix = [[0, 1, 1, 1, 1, 1],
  26.               [1, 0, 1, 1, 1, 1],
  27.               [1, 1, 0, 1, 1, 1],
  28.               [1, 1, 1, 0, 1, 1],
  29.               [1, 1, 1, 1, 0, 1],
  30.               [1, 1, 1, 1, 1, 0]]
  31.     # triangles(matrix)
  32.     squares(matrix)
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement