Paste
Pasted as Python by PatrikGerber ( 13 years ago )
def subStringMatchExact(target,key):
x=0
start=()
while target.find(key,x,)>=0:
start=start+(target.find(key,x,),)
x=(target.find(key,x,))+1
return start
#firstMatch = subStringMatchExact(target,key1)
#secondMatch = subStringMatchExact(target, key2)
def constrainedMatchPair(firstMatch,secondMatch,lenght):
n=()
for x in range(0,len(firstMatch)):
for y in range(0,len(secondMatch)):
if int(firstMatch[x])+lenght+1==int(secondMatch[y]):
n=n+(int(firstMatch[x]),)
return n
def subStringMatchExactlyOne(target,key):
answer=()
x=()
y=()
for z in range(0,len(key)):
key1 = key[0:z]
key2 = key[z+1:]
lenght = z
firstMatch = subStringMatchExact(target,key1)
secondMatch = subStringMatchExact(target, key2)
y = y + constrainedMatchPair(firstMatch,secondMatch,lenght)
x = x + subStringMatchExact(target,key)
#print('might be',y)
# for q in range(0,len(x)):
# for r in range(0,len(y)):
# if x[q] == y[r]:
# print('not',y[r])
Revise this Paste
Parent: 65082