Write a function ```convert_temp(temp, from_scale, to_scale)``` converting temperature from one scale to another. 
Return converted temp value. 

Round converted temp value to an integer(!).

Reading: http://en.wikipedia.org/wiki/Conversion_of_units_of_temperature

```
possible scale inputs:
    "C"  for Celsius
    "F"  for Fahrenheit
    "K"  for Kelvin
    "R"  for Rankine
    "De" for Delisle
    "N"  for Newton
    "Re" for Réaumur
    "Ro" for Rømer
```

```temp``` is a number, ```from_scale``` and ```to_scale``` are strings. 

```python
convert_temp(   100, "C",  "F") # => 212
convert_temp(    40, "Re", "C") # => 50
convert_temp(    60, "De", "F") # => 140
convert_temp(373.15, "K",  "N") # => 33
convert_temp(   666, "K",  "K") # => 666
```

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Data structures

Mathematics

Starter code: def convert_temp(temp, from_scale, to_scale):
	

Solutions:
TO_KELVIN = {'C': (1, 273.15), 'F': (5.0 / 9, 459.67 * 5.0 / 9), 'R': (5.0 / 9, 0), 'De': (-2.0 / 3, 373.15), 'N': (100.0 / 33, 273.15), 'Re': (5.0 / 4, 273.15), 'Ro': (40.0 / 21, -7.5 * 40 / 21 + 273.15)}

def convert_temp(temp, from_scale, to_scale):
	if from_scale == to_scale:
		return temp
	if from_scale != 'K':
		(a, b) = TO_KELVIN[from_scale]
		temp = a * temp + b
		if to_scale == 'K':
			return int(round(temp))
	(a, b) = TO_KELVIN[to_scale]
	return int(round((temp - b) / a))


int2 = lambda x: int(round(x, 0))

def other2c(temp, from_scale):
	func_dict = {'C': lambda x: x, 'K': lambda x: int2(x - 273.15), 'F': lambda x: int2((x - 32) * 5 / 9), 'R': lambda x: int2((x - 491.67) * 5 / 9), 'De': lambda x: int2(100 - x * 2 / 3), 'N': lambda x: int2(x * 100 / 33), 'Re': lambda x: int2(x * 5 / 4), 'Ro': lambda x: int2((x - 7.5) * 40 / 21)}
	return func_dict[from_scale](temp)

def c2other(temp, to_scale):
	func_dict = {'C': lambda x: x, 'K': lambda x: int2(x + 273.15), 'F': lambda x: int2(x * 9 / 5 + 32), 'R': lambda x: int2((x + 273.15) * 9 / 5), 'De': lambda x: int2((100 - x) * 3 / 2), 'N': lambda x: int2(x * 33 / 100), 'Re': lambda x: int2(x * 4 / 5), 'Ro': lambda x: int2(x * 21 / 40 + 7.5)}
	return func_dict[to_scale](temp)

def convert_temp(temp, from_scale, to_scale):
	if from_scale == to_scale:
		return temp
	nowc = other2c(temp, from_scale)
	c2res = c2other(nowc, to_scale)
	return c2res


convertToC = {'C': lambda t: t, 'F': lambda t: (t - 32) * 5 / 9, 'K': lambda t: t - 273.15, 'R': lambda t: (t - 491.67) * 5 / 9, 'De': lambda t: 100 - t * 2 / 3, 'N': lambda t: t * 100 / 33, 'Re': lambda t: t * 5 / 4, 'Ro': lambda t: (t - 7.5) * 40 / 21}
convertFromC = {'C': lambda t: t, 'F': lambda t: t * 9 / 5 + 32, 'K': lambda t: t + 273.15, 'R': lambda t: (t + 273.15) * 9 / 5, 'De': lambda t: (100 - t) * 3 / 2, 'N': lambda t: t * 33 / 100, 'Re': lambda t: t * 4 / 5, 'Ro': lambda t: t * 21 / 40 + 7.5}

def convert_temp(temp, from_scale, to_scale):
	return round(convertFromC[to_scale](convertToC[from_scale](temp)))


def convert_temp(temp, from_scale, to_scale):
	input_lookup = {'C': lambda x: x + 273.15, 'F': lambda x: (x + 359.67) * 5 / 9, 'K': lambda x: x, 'R': lambda x: x * 5 / 9, 'De': lambda x: 373.15 - x * 2 / 3, 'N': lambda x: x * 100 / 33 + 273.15, 'Re': lambda x: x * 5 / 4 + 273.15, 'Ro': lambda x: (x - 7.5) * 40 / 21 + 273.15}
	output_lookup = {'C': lambda x: x - 273.15, 'F': lambda x: x * 9 / 5 - 459.67, 'K': lambda x: x, 'R': lambda x: x * 9 / 5, 'De': lambda x: (373.15 - x) * 3 / 2, 'N': lambda x: (x - 273.15) * 33 / 100, 'Re': lambda x: (x - 273.15) * 4 / 5, 'Ro': lambda x: (x - 273.15) * 21 / 40 + 7.5}
	return round(output_lookup[to_scale](input_lookup[from_scale](temp)))


convert_temp = lambda z, s, d: int(round({'C': lambda z: z - 273.15, 'F': lambda z: z * 9 / 5 - 459.67, 'K': lambda z: z, 'R': lambda z: z * 9 / 5, 'De': lambda z: (373.15 - z) * 3 / 2, 'N': lambda z: (z - 273.15) * 33 / 100, 'Re': lambda z: (z - 273.15) * 4 / 5, 'Ro': lambda z: (z - 273.15) * 21 / 40 + 7.5}[d]({'C': lambda z: z + 273.15, 'F': lambda z: (z + 459.67) * 5 / 9, 'K': lambda z: z, 'R': lambda z: z * 5 / 9, 'De': lambda z: 373.15 - z * 2 / 3, 'N': lambda z: z * 100 / 33 + 273.15, 'Re': lambda z: z * 5 / 4 + 273.15, 'Ro': lambda z: (z - 7.5) * 40 / 21 + 273.15}[s](z))))


FUNCS = {'C': (lambda t: t, lambda t: t), 'F': (lambda t: (t - 32) * 5 / 9, lambda t: t * 9 / 5 + 32), 'K': (lambda t: t - 273.15, lambda t: t + 273.15), 'R': (lambda t: (t - 491.67) * 5 / 9, lambda t: (t + 273.15) * 9 / 5), 'De': (lambda t: 100 - t * 2 / 3, lambda t: (100 - t) * 3 / 2), 'N': (lambda t: t * 100 / 33, lambda t: t * 33 / 100), 'Re': (lambda t: t * 5 / 4, lambda t: t * 4 / 5), 'Ro': (lambda t: (t - 7.5) * 40 / 21, lambda t: t * 21 / 40 + 7.5)}

def convert_temp(t, org, to):
	return round(FUNCS[to][1](FUNCS[org][0](t)))


d = {'C': 't', 'F': 't-32*5/9', 'K': 't-273.15', 'R': '(t-491.67)*5/9', 'De': '100-t*2/3', 'N': 't*100/33', 'Re': 't*5/4', 'Ro': '(t-7.5)*40/21'}
d_ = {'C': 'c', 'F': 'c*9/5+32', 'K': 'c+273.15', 'R': '(c+273.15)*9/5', 'De': '(100-c)*3/2', 'N': 'c*33/100', 'Re': 'c*4/5', 'Ro': 'c*21/40+7.5'}

def convert_temp(t, fr, to):
	c = eval(d[fr])
	return round(eval(d_[to]))


converters = {('C', 'F'): lambda c: c * 9 / 5 + 32, ('C', 'K'): lambda c: c + 273.15, ('C', 'R'): lambda c: (c + 273.15) * 9 / 5, ('C', 'De'): lambda c: (100 - c) * 3 / 2, ('C', 'N'): lambda c: c * 33 / 100, ('C', 'Re'): lambda c: c * 4 / 5, ('C', 'Ro'): lambda c: c * 21 / 40 + 7.5, ('F', 'C'): lambda f: (f - 32) * 5 / 9, ('K', 'C'): lambda k: k - 273.15, ('R', 'C'): lambda r: (r - 491.67) * 5 / 9, ('De', 'C'): lambda de: 100 - de * 2 / 3, ('N', 'C'): lambda n: n * 100 / 33, ('Re', 'C'): lambda re: re * 5 / 4, ('Ro', 'C'): lambda ro: (ro - 7.5) * 40 / 21}

def convert_temp(temp, from_scale, to_scale):
	f = converters.get((from_scale, to_scale))
	x = f(temp) if f else convert_temp(convert_temp(temp, from_scale, 'C'), 'C', to_scale)
	return round(x)


def convert_temp(tt, f, t):
	if f == 'C':
		x = tt
	if f == 'F':
		x = (tt - 32) * 5.0 / 9
	if f == 'K':
		x = tt - 273.15
	if f == 'R':
		x = (tt - 491.67) * 5.0 / 9
	if f == 'De':
		x = 100 - tt * 2.0 / 3
	if f == 'N':
		x = tt * 100.0 / 33
	if f == 'Re':
		x = tt * 5.0 / 4
	if f == 'Ro':
		x = (tt - 7.5) * 40.0 / 21
	if t == 'C':
		y = x
	if t == 'F':
		y = x * 9.0 / 5 + 32
	if t == 'K':
		y = x + 273.15
	if t == 'R':
		y = (x + 273.15) * 9.0 / 5
	if t == 'De':
		y = (100 - x) * 3.0 / 3
	if t == 'N':
		y = x * 33.0 / 100
	if t == 'Re':
		y = x * 4.0 / 5
	if t == 'Ro':
		y = x * 21.0 / 40 + 7.5
	return round(y)


CELSIUS = {'C': (1.0, 0.0), 'F': (5 / 9.0, -32 * 5 / 9.0), 'K': (1.0, -273.15), 'R': (5 / 9.0, -273.15), 'De': (-2 / 3.0, 100.0), 'N': (100 / 33.0, 0.0), 'Re': (1.25, 0.0), 'Ro': (40 / 21.0, -40 * 7.5 / 21)}

def convert_temp(temp, from_scale, to_scale):
	(fa, fb) = CELSIUS[from_scale]
	(ta, tb) = CELSIUS[to_scale]
	cels = fa * temp + fb
	return round((cels - tb) / ta)