parity.py is possibly duplicated
Closed this issue · 2 comments
cs-shadow commented
At first glance, it seems like pkg/parity.py
and pkg/library/parity.py
are very similar except for some minor differences. I'm guessing this is not by design, right?
$ git diff --no-index pkg/parity.py pkg/library/parity.py
diff --git a/parity.py b/library/parity.py
index e2370fe..ce1cae8 100755
--- a/parity.py
+++ b/library/parity.py
@@ -30,23 +30,23 @@ Examples
"""
- if len(A) != len(B): raise ValueError("B is not a permutation of A")
+if len(A) != len(B): raise ValueError("B is not a permutation of A")
- # represent each element in B with its index in A and run permutation_parity()
- A_indices = dict(zip(A,range(len(A))))
+# represent each element in B with its index in A and run permutation_parity()
+A_indices = dict(zip(A,range(len(A))))
- if len(A_indices) != len(A): raise ValueError("A contains duplicate values")
+if len(A_indices) != len(A): raise ValueError("A contains duplicate values")
- try:
- perm = [A_indices[x] for x in B]
- except KeyError:
- raise ValueError("B is not a permutation of A")
+try:
+ perm = [A_indices[x] for x in B]
+except KeyError:
+ raise ValueError("B is not a permutation of A")
- return permutation_parity(perm, check_input=False)
+return permutation_parity(perm, check_input=False)
-def permutation_parity(perm, check_input=True):
+permutation_parity(perm, check_input=True):
"""Parity of a permutation of the integers
Parameters
aasthan4 commented
Yes thats true. It is being used using both locations I think. Let me fix that.
aasthan4 commented
Yup parity sorted out. file storage structure is changed.