Skip to content

Commit 0e9e2d5

Browse files
Merge pull request #745 from ask2sm/patch-15
naivestringmatching.py
2 parents dc8aa5b + 7afdd19 commit 0e9e2d5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

naivestringmatching.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def funtion(txt,pat):
2+
n=len(txt)
3+
m=len(pat)
4+
for i in range(n-m+1):
5+
for j in range(m):
6+
if(txt[i+j]!=pat[j]):
7+
break
8+
else:
9+
j+=1
10+
if(j==m):
11+
print("Found at:",i)
12+
13+
14+
if __name__ == '__main__':
15+
txt="SouravMondalSM"
16+
pat="SM"
17+
funtion(txt,pat)

0 commit comments

Comments
 (0)