You're hanging out with your friends in a bar, when suddenly one of them is so drunk, that he can't speak, and when he wants to say something, he writes it down on a paper. However, none of the words he writes make sense to you. He wants to help you, so he points at a beer and writes "yvvi". You start to understand what he's trying to say, and you write a script, that decodes his words.

Keep in mind that numbers, as well as other characters, can be part of the input, and you should keep them like they are. You should also test if the input is a string. If it is not, return "Input is not a string".

Source: codewars | Difficulty: EASY
Tags: Ad-hoc

Starter code: def decode(string_):
	

Solutions:
def parse_character(char):
	if 65 <= ord(char) <= 90:
		return chr(155 - ord(char))
	elif 97 <= ord(char) <= 122:
		return chr(219 - ord(char))
	else:
		return char

def decode(string_):
	if not isinstance(string_, str):
		return 'Input is not a string'
	return ''.join(map(parse_character, string_))


def decode(string_):
	if not isinstance(string_, str):
		return 'Input is not a string'
	return string_.translate(str.maketrans('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA'))


lower = 'abcdefghijklmnopqrstuvwxyz'
table = str.maketrans(lower + lower.upper(), lower[::-1] + lower.upper()[::-1])

def decode(stg):
	if not isinstance(stg, str):
		return 'Input is not a string'
	return stg.translate(table)


def transform(c):
	d = chr(219 - ord(c.lower()))
	return d if c.islower() else d.upper()

def decode(s):
	return 'Input is not a string' if not isinstance(s, str) else ''.join((transform(c) if c.isalpha() else c for c in s))


abc = 'abcdefghijklmnopqrstuvwxyz'
trans = dict(zip(abc + abc.upper(), reversed(abc.upper() + abc)))

def decode(s):
	return ''.join((trans.get(c, c) for c in s)) if type(s) == str else 'Input is not a string'


decode = lambda s: 'Input is not a string' if not isinstance(s, str) else ''.join((chr(155 + 64 * (96 < ord(c) < 123) - ord(c)) if c.isalpha() else c for c in s))


def decode(s):
	if type(s) != str:
		return 'Input is not a string'
	st = {}
	it = 0
	for i in 'abcdefghijklmnopqrstuvwxyz':
		st[i] = 'abcdefghijklmnopqrstuvwxyz'[::-1][it % 26]
		st[i.upper()] = st[i].upper()
		it += 1
	m = ''
	for im in s:
		if im.isalpha():
			try:
				m += st[im]
			except:
				pass
		else:
			m += im
	return m


low = 'zyxwvutsrqponmlkjihgfedcba'
up = 'ZYXWVUTSRQPONMLKJIHGFEDCBA'

def decode(s):
	if not isinstance(s, str):
		return 'Input is not a string'
	return ''.join(((low[ord(x) - 97] if x.islower() else up[ord(x) - 65]) if x.isalpha() else x for x in s))


def decode(string_):
	if not isinstance(string_, str):
		return 'Input is not a string'
	input = list(string_)
	output = []
	dic1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
	dic2 = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
	for i in range(len(input)):
		alph = ''
		for j in range(len(input[i])):
			if input[i][j].isupper():
				alph += dic2[25 - dic2.index(input[i][j])]
			elif input[i][j].islower():
				alph += dic1[25 - dic1.index(input[i][j])]
			else:
				alph += ''.join(input[i][j])
		output.append(alph)
	return ''.join(output)


def decode(string_):
	if not isinstance(string_, str):
		return 'Input is not a string'
	alph = 'abcdefghijklmnopqrstuvwxyz'
	print(string_)
	out = ''
	for x in string_:
		if x.lower() in alph:
			n = 25 - alph.index(x.lower())
			if x.isupper():
				out += alph[n].upper()
			else:
				out += alph[n]
		else:
			out += x
	return out


from string import ascii_lowercase as lower, ascii_uppercase as upper
trans = str.maketrans(lower + upper, lower[::-1] + upper[::-1])

def decode(string_):
	try:
		return string_.translate(trans)
	except AttributeError:
		return 'Input is not a string'


def decode(string):
	if type(string) != str:
		return 'Input is not a string'
	alph = 'abcdefghijklmnopqrstuvwxyz'
	s = ''
	for el in string:
		if el.lower() in alph:
			if el.islower():
				s += alph[25 - alph.index(el.lower())]
			else:
				s += alph[25 - alph.index(el.lower())].upper()
		else:
			s += el
	return s


s_ = 'abcdefghijklmnopqrstuvwxyz'

def decode(string_):
	if not isinstance(string_, str):
		return 'Input is not a string'
	s = ''
	for i in string_:
		if not i.isalpha():
			s += i
		elif i.islower():
			s += s_[-s_.index(i) - 1]
		elif i.isupper():
			s += s_[-s_.index(i.lower()) - 1].upper()
	return s