MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / compare_string

Function compare_string

boolean_algebra/quine_mc_cluskey.py:7–25  ·  view source on GitHub ↗

>>> compare_string('0010','0110') '0_10' >>> compare_string('0110','1101') False

(string1: str, string2: str)

Source from the content-addressed store, hash-verified

5
6
7def compare_string(string1: str, string2: str) -> str | Literal[False]:
8 """
9 >>> compare_string('0010','0110')
10 '0_10'
11
12 >>> compare_string('0110','1101')
13 False
14 """
15 list1 = list(string1)
16 list2 = list(string2)
17 count = 0
18 for i in range(len(list1)):
19 if list1[i] != list2[i]:
20 count += 1
21 list1[i] = "_"
22 if count > 1:
23 return False
24 else:
25 return "".join(list1)
26
27
28def check(binary: list[str]) -> list[str]:

Callers 1

checkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected