# Task
 Define crossover operation over two equal-length strings A and B as follows:

 the result of that operation is a string of the same length as the input strings result[i] is chosen at random between A[i] and B[i]. 
 
 Given array of strings `arr` and a string result, find for how many pairs of strings from `arr` the result of the crossover operation over them may be equal to result.

 Note that (A, B) and (B, A) are the same pair. Also note that the pair cannot include the same element of the array twice (however, if there are two equal elements in the array, they can form a pair).

# Example

 For `arr = ["abc", "aaa", "aba", "bab"]` and `result = "bbb"`, the output should be `2`.

 ```
"abc" and "bab" can crossover to "bbb"
"aba" and "bab" can crossover to "bbb"
```
# Input/Output


 - `[input]` string array `arr`

   A non-empty array of equal-length strings.

   Constraints: `2 ≤ arr.length ≤ 10, 1 ≤ arr[i].length ≤ 10.`


 - `[input]` string `result`

   A string of the same length as each of the arr elements.

   Constraints: `result.length = arr[i].length.`


 - `[output]` an integer

Source: codewars | Difficulty: EASY
Tags: Ad-hoc

Starter code: def strings_crossover(arr, result):
	

Solutions:
from itertools import combinations

def strings_crossover(arr, result):
	return sum((1 for (s1, s2) in combinations(arr, 2) if all((r in (x, y) for (x, y, r) in zip(s1, s2, result)))))


from collections import Counter

def strings_crossover(arr, result):
	lstBit = [int(''.join(['01'[x == y] for (x, y) in zip(result, w)]), 2) for w in arr]
	target = 2 ** len(result) - 1
	c = Counter(lstBit)
	v1 = sum((v * w for (k, v) in list(c.items()) for (l, w) in list(c.items()) if k | l == target and k != target and (l != target))) // 2
	v2 = 0 if target not in c else (sum(c.values()) - c[target]) * c[target]
	v3 = 0 if c[target] < 2 else c[target] * (c[target] - 1) // 2
	return v1 + v2 + v3


from itertools import combinations as comb
strings_crossover = lambda li, r: sum((all((r[k] in [i[0][k], i[1][k]] for k in range(len(i[0])))) for i in comb(li, 2)))


from itertools import combinations

def strings_crossover(arr, result):
	return sum((all((a == b or a == c for (a, b, c) in zip(result, *xs))) for xs in combinations(arr, 2)))


import itertools

def strings_crossover(arr, result):
	lista = list(itertools.combinations(arr, 2))
	crossovers = 0
	for element in lista:
		flag = True
		for (i, e) in enumerate(result):
			if element[0][i] != e and element[1][i] != e:
				flag = False
		if flag:
			crossovers += 1
	return crossovers


from itertools import combinations

def strings_crossover(arr, result):
	return sum((all((x == z or y == z for (x, y, z) in zip(a, b, result))) for (a, b) in combinations(arr, 2)))


from itertools import combinations

def strings_crossover(arr, result):
	r = 0
	for (s1, s2) in combinations(arr, 2):
		flag = True
		for i in range(len(result)):
			if s1[i] != result[i] and s2[i] != result[i]:
				flag = False
				break
		if flag:
			r += 1
	return r


from itertools import combinations

def strings_crossover(arr, result):
	combs = [*combinations(arr, 2)]
	t = 0
	for k in range(len(combs)):
		(x, y, z) = (set(enumerate(result)), set(enumerate(combs[k][0])), set(enumerate(combs[k][1])))
		t += not x - (y | z)
	return t


from itertools import combinations

def strings_crossover(arr, result):
	return sum((1 for (a, b) in combinations(arr, 2) if all((r in (x, y) for (r, x, y) in zip(result, a, b)))))