jeudi 27 mai 2010

Check is string a is prefix of string b


def prefix (a, b):
i=0
while a[i] <> 0
if b[i] == 0:
return false
if a[i]<>b[i]:
return false
return true

prefix ('' , 'f') = 1
prefix ('f', '') = 1
perfix ('f','fg') = 1

Aucun commentaire:

Enregistrer un commentaire