There is no single treatment that works for every phobia, but some people cure it by being gradually exposed to the phobic situation or object. In this kata we will try curing arachnophobia by drawing primitive spiders.
 
Our spiders will have legs, body, eyes and a mouth. Here are some examples:
```
/\((OOwOO))/\

/╲(((0000w0000)))╱\

^(oWo)^
```
You will be given four values:  
1) `leg size` where each value stands for its own leg type: `1 for "^ ^", 2 for "/\ /\", 3 for "/╲ ╱\", 4 for "╱╲ ╱╲"`  
2) `body size` where each value stands for its own body type: `1 for "( )", 2 for "(( ))", 3 for "((( )))"`  
3) `mouth` representing the spider's mouth  
4) `eye` representing the spider's eye

**Note:** the eyes are symmetric, and their total amount is `2 to the power of body size`.
  
You will also be given only valid data. That's it for the instructions, you can start coding!

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def draw_spider(leg_size, body_size, mouth, eye):
	

Solutions:
def draw_spider(leg_size, body_size, mouth, eye):
	lleg = ['', '^', '/\\', '/╲', '╱╲'][leg_size]
	rleg = ['', '^', '/\\', '╱\\', '╱╲'][leg_size]
	lbody = '(' * body_size
	rbody = ')' * body_size
	eye *= 2 ** (body_size - 1)
	return f'{lleg}{lbody}{eye}{mouth}{eye}{rbody}{rleg}'


def draw_spider(leg_size, body_size, mouth, eye):
	LEG = {1: ['^', '^'], 2: ['/\\', '/\\'], 3: ['/╲', '╱\\'], 4: ['╱╲', '╱╲']}
	left_legs = LEG[leg_size][0]
	right_legs = LEG[leg_size][1]
	left_body = '(' * body_size
	right_body = ')' * body_size
	eyes = eye * 2 ** (body_size - 1)
	return ''.join([left_legs, left_body, eyes, mouth, eyes, right_body, right_legs])


L = {1: '^', 2: '/\\', 3: '/╲', 4: '╱╲'}
R = {1: '^', 2: '/\\', 3: '╱\\', 4: '╱╲'}

def draw_spider(leg, body, mouth, eye):
	return L[leg] + '(' * body + eye * (2 ** body // 2) + mouth + eye * (2 ** body // 2) + ')' * body + R[leg]


def draw_spider(leg_size, body_size, mouth, eye):
	leg = {1: '^', 2: '/\\', 3: '/╲', 4: '╱╲'}
	r_leg = {1: '^', 2: '/\\', 3: '╱\\', 4: '╱╲'}
	body = {1: '(', 2: '((', 3: '((('}
	r_body = {1: ')', 2: '))', 3: ')))'}
	time = body_size + 1 if body_size == 3 else body_size
	spi = leg[leg_size] + body[body_size] + eye * time + mouth + eye * time + r_body[body_size] + r_leg[leg_size]
	return spi


L_LEGS = ['', '^', '/\\', '/╲', '╱╲']
R_LEGS = ['', '^', '/\\', '╱\\', '╱╲']

def draw_spider(legs, body, mouth, eye):
	eyes = eye * (1 << body - 1)
	return f"{L_LEGS[legs]}{'(' * body}{eyes}{mouth}{eyes}{')' * body}{R_LEGS[legs]}"


exoskeletons = ["Ce n'est pas un insecte...", '^%s%s%c%s%s^', '/\\%s%s%c%s%s/\\', '/╲%s%s%c%s%s╱\\', '╱╲%s%s%c%s%s╱╲', "...and it's also not a bug."]

def draw_spider(leg_size, body_size, mouth, eye):
	(left, right) = [eye * (2 ** body_size // 2)] * 2
	return exoskeletons[leg_size] % ('(' * body_size, left, mouth, right, body_size * ')')


def draw_spider(a, b, c, d):
	l = '_ ^ /\\ /╲ ╱╲ ╱╲ ╱\\ /\\ ^'.split()
	return '{}{}{}{}{}{}{}'.format(l[a], '(' * b, d * 2 ** (b - 1), c, d * 2 ** (b - 1), ')' * b, l[-a])


draw_spider = lambda L, B, M, E: '^%s^ /\\%s/\\ /╲%s╱\\ ╱╲%s╱╲'.split()[L - 1] % ('(' * B + E * 2 ** (B - 1) + M + E * 2 ** (B - 1) + ')' * B)


def draw_spider(leg, body, mouth, eye):
	legs = ['^ ^', '/\\ /\\', '/╲ ╱\\', '╱╲ ╱╲'][leg - 1].split()
	return legs[0] + '(' * body + eye * 2 ** (body - 1) + mouth + eye * 2 ** (body - 1) + ')' * body + legs[1]


def draw_spider(leg_size, body_size, mouth, eye):
	if leg_size == 1:
		leg1 = '^'
		leg2 = '^'
	elif leg_size == 2:
		leg1 = '/\\'
		leg2 = '/\\'
	elif leg_size == 3:
		leg1 = '/╲'
		leg2 = '╱\\'
	else:
		leg1 = '╱╲'
		leg2 = '╱╲'
	return leg1 + body_size * '(' + int(2 ** body_size / 2) * eye + mouth + int(2 ** body_size / 2) * eye + body_size * ')' + leg2