Given 2 strings, `a` and `b`, return a string of the form: `shorter+reverse(longer)+shorter.`


In other words, the shortest string has to be put as prefix and as suffix of the reverse of the longest.

Strings `a` and `b` may be empty, but not null (In C# strings may also be null. Treat them as if they are empty.).  
If `a` and `b` have the same length treat `a` as the longer producing `b+reverse(a)+b`

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def shorter_reverse_longer(a,b):
	

Solutions:
def shorter_reverse_longer(a, b):
	if len(a) < len(b):
		(a, b) = (b, a)
	return b + a[::-1] + b


def shorter_reverse_longer(a, b):
	(short, long) = sorted((b, a), key=len)
	return short + long[::-1] + short


def shorter_reverse_longer(a, b):
	if len(a) >= len(b):
		(shorter, longer) = (b, a)
	else:
		(shorter, longer) = (a, b)
	return shorter + longer[::-1] + shorter


def shorter_reverse_longer(a, b):

	def s_r_l(s, l):
		return s + l[::-1] + s
	assert isinstance(a, str) and isinstance(b, str), 'Both arguments must be strings'
	if len(b) > len(a):
		return s_r_l(a, b)
	else:
		return s_r_l(b, a)


shorter_reverse_longer = lambda a, b: b + a[::-1] + b if len(a) >= len(b) else a + b[::-1] + a