mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-23 08:51:31 -04:00
Change the dir structure slightly
This commit is contained in:
parent
6b6fe21db3
commit
2f4a9638c0
184 changed files with 0 additions and 21 deletions
|
@ -1,36 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
__author__ = "bt3"
|
||||
|
||||
|
||||
def find_substr(s1, s2):
|
||||
|
||||
if len(s1) < len(s2):
|
||||
bs = s2
|
||||
ss = s1
|
||||
else:
|
||||
bs = s1
|
||||
ss = s2
|
||||
|
||||
ps = 0
|
||||
|
||||
for c in bs:
|
||||
|
||||
if ss[ps] == c:
|
||||
ps += 1
|
||||
else:
|
||||
ps = 0
|
||||
|
||||
if ps == len(ss)-1:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
s1 = 'buffy is a vampire slayer'
|
||||
s2 = 'vampire'
|
||||
s3 = 'angel'
|
||||
assert(find_substr(s2, s1) == True)
|
||||
assert(find_substr(s3, s1) == False)
|
Loading…
Add table
Add a link
Reference in a new issue