Your colleagues have been good enough(?) to buy you a birthday gift. Even though it is your birthday and not theirs, they have decided to play pass the parcel with it so that everyone has an even chance of winning. There are multiple presents, and you will receive one, but not all are nice... One even explodes and covers you in soil... strange office. To make up for this one present is a dog! Happy days! (do not buy dogs as presents, and if you do, never wrap them).

Depending on the number of passes in the game (y), and the present you unwrap (x), return as follows:

x == goodpresent --> return x with num of passes added to each charCode (turn to charCode, add y to each, turn back)
x == crap || x == empty --> return string sorted alphabetically
x == bang --> return string turned to char codes, each code reduced by number of passes and summed to a single figure
x == badpresent --> return 'Take this back!'
x == dog, return 'pass out from excitement y times' (where y is the value given for y).

Difficulty: EASY
Tags: Fundamentals

Data structures
Skill types: Data structures

Starter code:
def present(x,y):
	

Solutions:
_RESULTS = {'goodpresent': lambda y: ''.join((chr(ord(c) + y) for c in 'goodpresent')), 'crap': lambda y: 'acpr', 'empty': lambda y: 'empty', 'bang': lambda y: str(sum((ord(c) - y for c in 'bang'))), 'badpresent': lambda y: 'Take this back!', 'dog': lambda y: 'pass out from excitement {} times'.format(y)}
present = lambda x, y: _RESULTS[x](y)


def present(x, y):
	if x == 'badpresent':
		return 'Take this back!'
	if x == 'goodpresent':
		return ''.join((chr(ord(i) + y) for i in x))
	if x == 'crap' or x == 'empty':
		return ''.join(sorted(x))
	if x == 'bang':
		return str(sum([ord(i) - y for i in x]))
	if x == 'dog':
		return 'pass out from excitement {} times'.format(y)


present = lambda x, y: ['Take this back!', ''.join((chr(ord(e) + y) for e in x)), 'acpr', str(sum((ord(e) - y for e in x))), 'pass out from excitement {} times'.format(y), x]['doangp'.index(x[2])]


def present(x, y):
	if x == 'goodpresent':
		return ''.join((chr(ord(c) + y) for c in x))
	elif x in {'crap', 'empty'}:
		return ''.join(sorted(x))
	elif x == 'bang':
		return str(sum((ord(c) - y for c in x)))
	elif x == 'badpresent':
		return 'Take this back!'
	elif x == 'dog':
		return f'pass out from excitement {y} times'


def present(x, y):
	if x == 'badpresent':
		return 'Take this back!'
	if x == 'goodpresent':
		return ''.join((chr(ord(i) + y) for i in x))
	if x == 'crap':
		return 'acpr'
	if x == 'bang':
		return str(sum((ord(i) - y for i in x)))
	if x == 'dog':
		return f'pass out from excitement {y} times'
	if x == 'empty':
		return x


def present(x, y):
	if x == '' or x == 'empty':
		return 'empty'
	elif x == 'crap':
		return 'acpr'
	elif x == 'badpresent':
		return 'Take this back!'
	elif x == 'dog':
		return 'pass out from excitement ' + str(y) + ' times'
	elif x == 'bang':
		output = 0
		for char in list(x):
			output += ord(char) - y
		return str(output)
	elif x == 'goodpresent':
		output = ''
		for char in list(x):
			output += chr(ord(char) + y)
		return output
	else:
		return 'lol'


def present(present, passes):
	if present == 'goodpresent':
		return ''.join((chr(ord(c) + passes) for c in present))
	elif present == 'crap' or present == '':
		return ''.join(sorted(present))
	elif present == 'bang':
		return str(sum(map(ord, present)) - passes * len(present))
	elif present == 'badpresent':
		return 'Take this back!'
	elif present == 'dog':
		return f'pass out from excitement {passes} times'
	else:
		return 'empty'


def present(x, y):
	if x == 'badpresent':
		return 'Take this back!'
	elif x == 'dog':
		return f'pass out from excitement {y} times'
	elif x in ['crap', 'empty']:
		return ''.join(sorted(x))
	elif x == 'goodpresent':
		return ''.join(map(lambda a: chr(ord(a) + y), x))
	else:
		return str(sum(map(lambda a: ord(a) - y, x)))