I have been trying to implement tabular method for simplification of boolean expressions in python. For that I need to check whether two given strings differ at only one index for example, the function should return the following for the following examples:
0011
and0111
- true as the two differ only at position 10-001
and0-101
- true as differ at only 20-011
and0-101
- false as differ at 2,3
right now I am using the following function:
def match(s1,s2):
l=[False,-1]##returns false when they cant be combined
for i in range(len(s1)):
if s1[:i]==s2[:i] and s1[i]!=s2[i] and s1[i+1:]==s2[i+1:]:
l= [True,i]
break
return l
I want to implement it in a very fast manner (low complexity). Is there a way to do so in python?