cours_progra/bac1/q1/15dec/fonctions.py

28 lines
674 B
Python
Raw Normal View History

2023-02-15 13:40:50 +01:00
def plus_grand_bord(w):
for k, v in enumerate(w[1:]):
if v == w[0]:
if w[k+1:] == w[:len(w[k+1:])]:
return w[k+1:]
return None
def intersection(v, w):
max_inter = ''
for (k, v) in enumerate(v):
if v in w:
i = 1
while v[k:k+i] in w:
i += 1
if i >= len(w):
break
if len(v[k:k+i]) > len(max_inter):
max_inter = v[k:k+i]
return max_inter
def palyndrome(mot):
inv = [mot[len(mot)-1-i] for i in range(len(mot))]
return inv
if __name__ == "__main__":
print(palyndrome('anticonstitutionnelement'))