PS3: Problem 1 » Solutions
May. 3rd, 2010 03:17 pmI'll be posting the remaining solutions over the next few days, as soon as I have time to finish reviewing them.
PS3: Problem 1 » Solutions
# Problem 1: countSubstringMatch, countSubstringMatchRecursive
def countSubStringMatch( target, key ):
count = 0
while target.find( key ) > -1:
count += 1
target = target[target.find( key ) + len( key ):]
return count
def countSubStringMatchRecursive( target, key ):
if target.find( key ) < 0:
return 0
else:
return 1 + countSubStringMatchRecursive( target[(target.find( key ) + len(key)):], key )