|
|
@ -88,20 +88,17 @@ class Diagnostics: |
|
|
|
|
|
|
|
@staticmethod |
|
|
|
def commonality(report: List[int]) -> List[Dict[str, int]]: |
|
|
|
common_counts = [] |
|
|
|
num_1 = defaultdict(int) |
|
|
|
for binary in report: |
|
|
|
for column, bit in enumerate(binary): |
|
|
|
try: |
|
|
|
common_counts[column][bit] += 1 |
|
|
|
except IndexError: |
|
|
|
common_counts.append(defaultdict(int)) |
|
|
|
common_counts[column][bit] = 1 |
|
|
|
num_1[column] += int(bit) |
|
|
|
|
|
|
|
common = [] |
|
|
|
half_total = len(report)/2 |
|
|
|
for count in common_counts: |
|
|
|
if count["1"] == half_total: |
|
|
|
for count in num_1.values(): |
|
|
|
if count == half_total: |
|
|
|
common.append(2) # Indicating equally common |
|
|
|
elif count["1"] > half_total: |
|
|
|
elif count > half_total: |
|
|
|
common.append(1) |
|
|
|
else: |
|
|
|
common.append(0) |
|
|
|