The issue is already discussed here and I am attaching the code from the post
def is_bijection(seq1, seq2):
distinct1 = set(seq1)
distinct2 = set(seq2)
distinctMappings = set(zip(seq1, seq2))
return len(distinct1) == len(distinctMappings) and len(distinct2) == len(distinctMappings)
The above snippet checks if two sequnces is bijective or not. I want to extend it more. I want pull out a sublist containing the pairs that cause it not to be bijective. Lets take the following example:
seq1 = ['India','Bangladesh','Nordic','Bangladesh']
seq2 = [12,10,10,11]
If we send the above sequences to attached functions, it will return false. I also want to get a list/subject as follows:
'Bangladesh' - 10
'Bangladesh' - 11
that shows the reason for NOT being bijective. Any hint on this ?
EDIT:
The sequences(X,Y) are bijective if they follwing the following rules:
- each element of X must be paired with at least one element of Y,
- no element of X may be paired with more than one element of Y,
- each element of Y must be paired with at least one element of X, and
- no element of Y may be paired with more than one element of X.
Any 2 sequences that do not follows the above rules are non-bijective. I want to get the sublist of (X,Y) pair from the 2 sequences that makes it non-bijective.