[Tutor] another better way to do this ?

Emile van Sebille emile at fenx.com
Sun Jan 12 21:53:23 CET 2014


On 01/12/2014 12:21 PM, Peter Otten wrote:

>>>> test("axbxc", "abc")
> True
>>>> test("abbxc", "abc")
> False
>
> Is the second result desired?

No -- the second should match -- you found a test case I didn't...

def test(a,b):
   for ii in a:
     if ii not in b: a=a.replace(ii,"")
     while ii+ii in a: a=a.replace(ii+ii,ii)
   return b in a

Show me another.  :)

Emile






More information about the Tutor mailing list