jiehou commited on
Commit
d4da1e9
1 Parent(s): 57862f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -72,9 +72,13 @@ def search_pattern(fulltext, pattern, method):
72
  start = time.time()
73
  occurrence = 0
74
  for i in range(0,len(fulltext)-len(pattern)+1):
75
- if fulltext[i:i+len(pattern)] == pattern:
76
- print("Found ", fulltext[i:i+len(pattern)], ' locating at position ', i+1)
77
- occurrence += 1
 
 
 
 
78
 
79
  end = time.time()
80
  time_elapse = end - start
 
72
  start = time.time()
73
  occurrence = 0
74
  for i in range(0,len(fulltext)-len(pattern)+1):
75
+ found = 1
76
+ for l in range(len(pattern)):
77
+ if fulltext[i+l] != pattern[l]:
78
+ found = 0
79
+ if found:
80
+ occurrence += 1
81
+ print("Found ", fulltext[i:i+len(pattern)], ' locating at position ', i+1)
82
 
83
  end = time.time()
84
  time_elapse = end - start