Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # http://sovietov.com/txt/triangle/triangle.html
- def triangles(g):
- n = len(g)
- for a in range(0, n):
- for b in range(a + 1, n):
- if not g[a][b]:
- continue
- for c in range(b + 1, n):
- if g[b][c] and g[a][c]:
- print(a + 1, b + 1, c + 1)
- def squares(g):
- n = len(g)
- for a in range(0, n):
- for b in range(a + 1, n):
- for c in range(b + 1, n):
- for d in range(c + 1, n):
- if g[a][b] and g[a][c] and g[c][d] and g[b][d]:
- print(a + 1, b + 1, c + 1, d + 1)
- if __name__ == "__main__":
- matrix = [[0, 1, 1, 1, 1, 1],
- [1, 0, 1, 1, 1, 1],
- [1, 1, 0, 1, 1, 1],
- [1, 1, 1, 0, 1, 1],
- [1, 1, 1, 1, 0, 1],
- [1, 1, 1, 1, 1, 0]]
- # triangles(matrix)
- squares(matrix)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement