-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsymetric.py
More file actions
41 lines (28 loc) · 944 Bytes
/
Copy pathsymetric.py
File metadata and controls
41 lines (28 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# A list is symmetric if the first row is the same as the first column,
# the second row is the same as the second column and so on. Write a
# procedure, symmetric, which takes a list as input, and returns the
# boolean True if the list is symmetric and False if it is not.
def symmetric(p):
# This is really really difficult
print symmetric([[1, 2, 3],
[2, 3, 4],
[3, 4, 1]])
#>>> True
#print symmetric([["cat", "dog", "fish"],
# ["dog", "dog", "fish"],
# ["fish", "fish", "cat"]])
#>>> True
#print symmetric([["cat", "dog", "fish"],
# ["dog", "dog", "dog"],
# ["fish","fish","cat"]])
#>>> False
#print symmetric([[1, 2],
# [2, 1]])
#>>> True
#print symmetric([[1, 2, 3, 4],
# [2, 3, 4, 5],
# [3, 4, 5, 6]])
#>>> False
#print symmetric([[1,2,3],
# [2,3,1]])
#>>> False