Last active
March 24, 2016 06:11
-
-
Save rishi93/24d8073258400a244dbe to your computer and use it in GitHub Desktop.
Ambiguous Permutations - PERMUT2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def ifAmbiguous(arr,length): | |
| for i in range(0,length): | |
| num = i + 1 | |
| pos = arr[i] - 1 | |
| if arr[pos] != num: | |
| return False | |
| return True | |
| while True: | |
| length = int(input()) | |
| if length == 0: | |
| break | |
| arr = [int(x) for x in input().split()] | |
| if(ifAmbiguous(arr,length)): | |
| print("ambiguous") | |
| else: | |
| print("not ambiguous") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment