Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def forbidden(n):
- # returns a list of all "forbidden" pairs; i.e., (i,j) such that
- # 1 ≤ i ≤ n-1, 1 ≤ j ≤ n-1, i ≠ j, i ≡ j (mod 2)
- def is_subseq(x,y):
- # returns True if x is a subsequence of y, else returns False
- def is_folding(x):
- # returns True if sequence x is a folding, else returns False
- # cyc_perms is a list of all cyclic permutations of sequence x
- for cyc_perm in cyc_perms:
- for (i,j) in forbidden(len(x)):
- if is_subseq([i,j,i+1,j+1],cyc_perm): return False
- return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement