-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathPERMUT2.py
More file actions
36 lines (31 loc) · 686 Bytes
/
PERMUT2.py
File metadata and controls
36 lines (31 loc) · 686 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
def getIt():
allCases=[]
while True:
lenght=int(raw_input())
if lenght==0:
break
else:
case=(raw_input().split())
i=0
while i<len(case):
case[i]=int(case[i])
i+=1
allCases.append(case)
return allCases
def inverseTest(case):
ambi=True
i=0
while i<len(case):
i+=1
if case[case[i-1]-1]==i:
continue
else:
ambi=False
break
if ambi==True:
print'ambiguous'
else:
print'not ambiguous'
Tcases=getIt()
for case in Tcases:
inverseTest(case)