You are given a secret message you need to decipher. Here are the things you need to know to decipher it:

For each word:
- the second and the last letter is switched (e.g. `Hello` becomes `Holle`)
- the first letter is replaced by its character code (e.g. `H` becomes `72`)

Note: there are no special characters used, only letters and spaces

Examples
```
decipherThis('72olle 103doo 100ya'); // 'Hello good day'
decipherThis('82yade 115te 103o'); // 'Ready set go'
```

Difficulty: EASY
Tags: String algorithms

Fundamentals

Data structures
Skill types: Data structures

Starter code:
def decipher_this(string):
	

Solutions:
def decipher_word(word):
	i = sum(map(str.isdigit, word))
	decoded = chr(int(word[:i]))
	if len(word) > i + 1:
		decoded += word[-1]
	if len(word) > i:
		decoded += word[i + 1:-1] + word[i:i + 1]
	return decoded

def decipher_this(string):
	return ' '.join(map(decipher_word, string.split()))


def decipher_this(string):
	words = string.split()
	res = []
	for x in words:
		if x.isdigit():
			res.append(chr(int(x)))
		elif len(x) >= 3:
			sum = ''
			new_str = ''
			for i in x:
				if i.isdigit():
					sum += i
				else:
					new_str += i
			sum = chr(int(sum)) + new_str
			if len(sum) > 2:
				x = sum[0::len(sum) - 1] + sum[2:len(sum) - 1] + sum[1]
				res.append(x)
			else:
				res.append(sum)
	return ' '.join(res)


def decipher_this(string):
	words = []
	for word in string.split():
		code = ''.join((char for char in word if char.isdigit()))
		new_word = chr(int(code)) + ''.join((char for char in word if not char.isdigit()))
		words.append(new_word[:1] + new_word[-1] + new_word[2:-1] + new_word[1] if len(new_word) > 2 else new_word)
	return ' '.join(words)


import re

def decipher_this(stg):
	return re.sub('(\\d+)(\\w?)(\\w*)', decipher_word, stg)

def decipher_word(match):
	(o, cl, cr) = match.groups()
	return f'{chr(int(o))}{cr[-1:]}{cr[:-1]}{cl}'


def decipher_this(string):
	translated = []
	for word in string.split():
		digits = ''
		for c in word:
			if c.isdigit():
				digits += c
		word = word.replace(digits, chr(int(digits)))
		if len(word) > 2:
			translated.append(''.join([word[0], word[-1], word[2:-1], word[1]]))
		else:
			translated.append(word)
	return ' '.join(translated)


import string as Str

def decipher_this(string):
	allLetters = Str.ascii_letters
	allNumbers = Str.digits
	sentence = string.split(' ')
	decodedSentence = ''
	for word in sentence:
		ascii_code = word.strip(allLetters)
		ascii_letters = word.strip(allNumbers)
		first_letter = chr(int(ascii_code))
		if len(ascii_letters) > 1:
			ascii_letters = ascii_letters[-1:] + ascii_letters[1:-1] + ascii_letters[:1]
		decodedSentence = decodedSentence + first_letter + ascii_letters + ' '
	return decodedSentence[:-1]


import re

def decipher_this(string):
	decrypted = []
	for word in string.split():
		re_ord = re.match('\\d+', word).group()
		new_word = list(re.sub(re_ord, chr(int(re_ord)), word))
		if len(new_word) > 2:
			(new_word[1], new_word[-1]) = (new_word[-1], new_word[1])
		decrypted.append(''.join(new_word))
	return ' '.join(decrypted)


import re

def decipher_this(text):
	return re.sub('\\b(\\d{2,3})(\\w?)(\\w*?)(\\w?)\\b', lambda m: '{}'.format(chr(int(m.group(1))) + m.group(4) + m.group(3) + m.group(2)), text)


import re
REGEX = re.compile('(\\d+)([a-zA-Z]*)$')

def decipher_this(s):
	result = []
	for word in s.split():
		m = REGEX.match(word)
		(digits, chars) = m.groups()
		tmp = [chr(int(digits))]
		if len(chars) < 2:
			tmp.append(chars)
		else:
			tmp.append('{}{}{}'.format(chars[-1], chars[1:-1], chars[0]))
		result.append(''.join(tmp))
	return ' '.join(result)


import re

def decipher_this(str):
	return re.sub('(\\d+)(\\w*)', lambda m: chr(int(m.group(1))) + (m.group(2)[-1] + m.group(2)[1:-1] + m.group(2)[0] if len(m.group(2)) > 1 else m.group(2)), str)