Contract Names

We wish to contract two given names, both composed of letters (at least one) but they do not necessarily have the same length. We define the string s to be the contraction of strings s1, s2 if and only if:

  1. s1 is a prefix of s

  2. s2 is a sufix of s

  3. it is the sortest (among those the fulfill the two previous conditions)

For instance, 'rosandra' is a contraction of 'rosa' and 'sandra'. But 'mymamamy' is not the contraction of 'myma', 'mamy' (yet it satisfies conditions #1 and #2) since 'mymamy' also does but it is shorter.

You are required to deliver the following function in the module contract (file contract.py):

contract(n1, n2)

such that

given n1, n2, non-empty str of lowercase letters.

returns a str with the contraction of n1 and n2 as as described above.

For example:


>>> n1, n2 = 'rosa', 'sandra'
>>> contract(n1, n2)
'rosandra'

>>> n1, n2 = 'myma', 'mamy' 
>>> contract(n1, n2)
'mymamy'

>>> n1, n2 = 'mymay', 'mamy' 
>>> contract(n1, n2)
'mymaymamy'

Doctests are available in the contract.test file.