Skip to content

Commit 7afdd19

Browse files
naivestringmatching.py
ADD naivestringmatching.py.
1 parent dc8aa5b commit 7afdd19

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

naivestringmatching.py

+17
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)