Complete the function which converts hex number (given as a string) to a decimal number.

Difficulty: EASY
Starter code: def hex_to_dec(s):
	

Solutions:
def hex_to_dec(s):
	return int(s, 16)


from functools import partial
hex_to_dec = partial(int, base=16)


def hex_to_dec(s):
	key = '0123456789abcdef'
	n = 0
	res = 0
	for l in s[::-1]:
		res += key.index(l) * 16.0 ** n
		n += 1
	return int(res)


hex_to_dec = lambda s: int(s, 16)


def hex_to_dec(s):
	hxdict = {'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	count = 0
	total = 0
	for num in reversed(s):
		if num.isalpha():
			hxnum = hxdict.get(num)
			total = total + hxnum * 16 ** count
			count += 1
		else:
			total = int(num) * 16 ** count + total
			count += 1
	return total


def hex_to_dec(string):
	return int(string, 16)


def hex_to_dec(s):
	return int(eval('0x' + s))


def hex_to_dec(s):
	hex = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	sum = 0
	leng = len(s) - 1
	for i in s:
		sum += hex[i] * 16 ** leng
		leng -= 1
	return sum


d = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'A': 10, 'B': 11, 'C': 12, 'D': 13, 'E': 14, 'F': 15}

def hex_to_dec(s):
	x = list(str(s.upper()))
	y = [d[i] for i in x][::-1]
	z = [16 ** i for i in range(len(y))]
	w = []
	for i in range(len(y)):
		w.append(y[i] * z[i])
	return sum(w)


hex_to_dec = lambda s: eval('0x' + s)


def hex_to_dec(s):
	m = '0123456789ABCDEF'
	result = 0
	for i in range(0, len(s)):
		result += m.index(s[i].upper()) * 16 ** (len(s) - 1 - i)
	return result


def to_bin(value):
	res = ''
	while value > 0:
		res += str(value % 2)
		value //= 2
	return '{:0>4}'.format(res[::-1]) if res != '' else '0000'

def to_dec(value):
	res = 0
	value = value[::-1]
	for ix in range(len(value)):
		res += int(value[ix]) * 2 ** ix
	return res

def hex_to_dec(s):
	convert = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	res = list(map(lambda x: convert[x], list(s)))
	res = list(map(to_bin, res))
	res = ''.join(res)
	return to_dec(res)


import binascii

def hex_to_dec(s):
	return int.from_bytes(binascii.unhexlify('0' * (len(s) % 2) + s), byteorder='big')


def hex_to_dec(s):
	ords = [ord(x) for x in s]
	ints = [x - 48 if x < 90 else x - 87 for x in ords]
	res = 0
	for i in range(len(s)):
		curr_power = len(s) - 1 - i
		res += ints[i] * 16 ** curr_power
	return res


def hex_to_dec(s):
	ans = 0
	dict = {'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	i = len(s)
	if i == 1:
		if s.isnumeric():
			ans += int(s)
		elif s.isalpha():
			for (x, y) in dict.items():
				if s == x:
					ans += y
	else:
		for s in s:
			if s.isnumeric():
				ans += int(s) * pow(16, i - 1)
				i -= 1
			else:
				for (x, y) in dict.items():
					if s == x:
						ans += y * pow(16, i - 1)
						i -= 1
	return ans


def hex_to_dec(s):
	return int(str(s), base=16)


def hex_to_dec(s):
	(result, count) = (0, 0)
	hexes = '0123456789ABCDEF'
	s_r = s.upper()[::-1]
	for i in s_r:
		result += hexes.find(i) * 16 ** count
		count += 1
	return result


def hex_to_dec(number):
	return int(number, 16)


def hex_to_dec(s):
	convert = ''
	dec = 0
	for i in range(len(s)):
		if s[len(s) - 1 - i] == '0':
			convert = 0
		if s[len(s) - 1 - i] == '1':
			convert = 1
		if s[len(s) - 1 - i] == '2':
			convert = 2
		if s[len(s) - 1 - i] == '3':
			convert = 3
		if s[len(s) - 1 - i] == '4':
			convert = 4
		if s[len(s) - 1 - i] == '5':
			convert = 5
		if s[len(s) - 1 - i] == '6':
			convert = 6
		if s[len(s) - 1 - i] == '7':
			convert = 7
		if s[len(s) - 1 - i] == '8':
			convert = 8
		if s[len(s) - 1 - i] == '9':
			convert = 9
		if s[len(s) - 1 - i] == 'a':
			convert = 10
		if s[len(s) - 1 - i] == 'b':
			convert = 11
		if s[len(s) - 1 - i] == 'c':
			convert = 12
		if s[len(s) - 1 - i] == 'd':
			convert = 13
		if s[len(s) - 1 - i] == 'e':
			convert = 14
		if s[len(s) - 1 - i] == 'f':
			convert = 15
		dec += convert * 16 ** i
	return dec


def hex_to_dec(s):
	print(int(s, 20))
	return int(s, 16)


def hex_to_dec(hex: str) -> int:
	return int(hex, 16)


def hex_to_dec(y):
	(x, y, z) = (16, list(y[::-1]), {'a': '10', 'b': '11', 'c': '12', 'd': '13', 'e': '14', 'f': '15'})
	return sum([int(z[y[i]]) * x ** i if y[i] in z else int(y[i]) * x ** i for i in range(len(y))])


def hex_to_dec(s):
	return eval('0x{}'.format(s))


def hex_to_dec(s):
	dic = {'0123456789abcdef'[x]: x for x in range(16)}
	a = 0
	b = len(s) - 1
	c = 0
	while b >= 0:
		a += dic[s[c]] * 16 ** b
		b -= 1
		c += 1
	return a


import sys

def hex_to_dec(s):
	hex = {'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	res = 0
	weight = 16 ** (len(s) - 1)
	for ch in s:
		if ch in hex:
			res += hex.get(ch) * weight
		else:
			res += int(ch) * weight
		weight /= 16
	return res


def hex_to_dec(s):
	inv = list(s)[::-1]
	arr = []
	for i in range(len(inv)):
		for j in range(10):
			if inv[i] == str(j):
				arr.append(j * 16 ** i)
		if inv[i] == 'a':
			arr.append(10 * 16 ** i)
		elif inv[i] == 'b':
			arr.append(11 * 16 ** i)
		elif inv[i] == 'c':
			arr.append(12 * 16 ** i)
		elif inv[i] == 'd':
			arr.append(13 * 16 ** i)
		elif inv[i] == 'e':
			arr.append(14 * 16 ** i)
		elif inv[i] == 'f':
			arr.append(15 * 16 ** i)
	res = 0
	for i in arr:
		res += i
	return res


def hex_to_dec(s):
	i = int(s, 16)
	return int(str(i))


def hex_to_dec(s):
	t = 0
	x = len(s) - 1
	for i in s:
		if i == 'a':
			t += 10 * 16 ** x
		elif i == 'b':
			t += 11 * 16 ** x
		elif i == 'c':
			t += 12 * 16 ** x
		elif i == 'd':
			t += 13 * 16 ** x
		elif i == 'e':
			t += 14 * 16 ** x
		elif i == 'f':
			t += 15 * 16 ** x
		else:
			t += int(i) * 16 ** x
		x -= 1
	print(t)
	return t


def hex_to_dec(s):
	return int(f'0x{s}', 16)


def hex_to_dec(s):
	s = s[::-1]
	dec = 0
	a = [0] * len(s)
	for i in range(len(s)):
		a[i] = 10 if s[i] == 'a' or s[i] == 'A' else 11 if s[i] == 'b' or s[i] == 'B' else 12 if s[i] == 'c' or s[i] == 'C' else 13 if s[i] == 'd' or s[i] == 'D' else 14 if s[i] == 'e' or s[i] == 'E' else 15 if s[i] == 'f' or s[i] == 'F' else int(s[i])
		dec = dec + a[i] * 16 ** i
	return dec


def hex_to_dec(s):
	key = '0123456789abcdef'
	return sum([key.index(v) * 16 ** (len(list(s)) - 1 - i) for (i, v) in enumerate(list(s))])


def hex_to_dec(s):
	dict = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	return sum([dict[v] * 16 ** (len(list(s)) - 1 - i) for (i, v) in enumerate(list(s))])


def hex_to_dec(s):
	hexn = {'A': 10, 'B': 11, 'C': 12, 'D': 13, 'E': 14, 'F': 15}
	sum = 0
	n = 0
	for i in s[::-1]:
		if i.upper() in hexn:
			sum += hexn[i.upper()] * 16 ** n
		else:
			sum += int(i) * 16 ** n
		n += 1
	return sum


list_with_keys = list(map(chr, range(ord('a'), ord('f') + 1)))
my_list = []
for item in list(range(10)):
	my_list.append(str(item))
list_with_keys = my_list + list_with_keys
list_with_values = list(range(16))
hex_dict = dict(zip(list_with_keys, list_with_values))

def hex_to_dec(s):
	hex_convert = []
	for char in list(s):
		for (key, value) in hex_dict.items():
			if char == key:
				hex_convert.append(value)
	hex_num = 0
	for (index, number) in zip(range(len(hex_convert)), reversed(hex_convert)):
		hex_num = hex_num + number * 16 ** index
	return hex_num


List = ['a', 'b', 'c', 'd', 'e', 'f', 'g']

def hex_to_dec(s):
	return int(s, 16)


def hex_to_dec(s):
	r_number = 0
	for (idx, letter) in enumerate(s.upper()[::-1]):
		if ord(letter) >= 65 and ord(letter) <= 70:
			r_number += (ord(letter) - 55) * 16 ** idx
		elif ord(letter) >= 48 and ord(letter) <= 57:
			r_number += (ord(letter) - 48) * 16 ** idx
		else:
			print('not a proper hex number :', letter)
			return
	return r_number


def hex_digit_to_dec(s):
	if s.isdigit():
		return int(s)
	return ord(s) - ord('a') + 10

def hex_to_dec(s):
	res = 0
	max_i = len(s) - 1
	for (i, x_16) in enumerate(s):
		res += hex_digit_to_dec(x_16) * 16 ** (max_i - i)
	return res


def hex_to_dec(s):
	d = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'A': 10, 'B': 11, 'C': 12, 'D': 13, 'E': 14, 'F': 15}
	return sum([d[x.upper()] * 16 ** index for (index, x) in enumerate(s[::-1])])


def hex_to_dec(s):
	case = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	s = list(s)
	s.reverse()
	(sum_, j) = (0, 0)
	for i in range(len(s)):
		sum_ += case.get(s[i]) * pow(16, j)
		j += 1
	return sum_


def hex_to_dec(s):
	dec = 0
	rev_s = s[::-1]
	count = 0
	for i in rev_s:
		if i == '0':
			dec += 0 * 16 ** count
			count += 1
		elif i == '1':
			dec += 1 * 16 ** count
			count += 1
		elif i == '2':
			dec += 2 * 16 ** count
			count += 1
		elif i == '3':
			dec += 3 * 16 ** count
			count += 1
		elif i == '4':
			dec += 4 * 16 ** count
			count += 1
		elif i == '5':
			dec += 5 * 16 ** count
			count += 1
		elif i == '6':
			dec += 6 * 16 ** count
			count += 1
		elif i == '7':
			dec += 7 * 16 ** count
			count += 1
		elif i == '8':
			dec += 8 * 16 ** count
			count += 1
		elif i == '9':
			dec += 9 * 16 ** count
			count += 1
		elif i.lower() == 'a':
			dec += 10 * 16 ** count
			count += 1
		elif i.lower() == 'b':
			dec += 11 * 16 ** count
			count += 1
		elif i.lower() == 'c':
			dec += 12 * 16 ** count
			count += 1
		elif i.lower() == 'd':
			dec += 13 * 16 ** count
			count += 1
		elif i.lower() == 'e':
			dec += 14 * 16 ** count
			count += 1
		elif i.lower() == 'f':
			dec += 15 * 16 ** count
			count += 1
	return dec


def hex_to_dec(s):
	hex_dict = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']
	temp = list(map(hex_dict.index, s))
	pow = range(len(s) - 1, -1, -1)
	return sum((temp[i] * 16 ** pow[i] for i in range(len(s))))


def hex_to_dec(he_x):
	return int(he_x, 16)


hex_vals = {'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}

def hex_to_dec(s):
	accum = 0
	for (pos, num) in enumerate(reversed(s)):
		if num in '0123456789':
			accum += int(num) * 16 ** pos
		else:
			accum += hex_vals[num] * 16 ** pos
	return accum


hex_to_dec = lambda n: int(n, 16)


def hex_to_dec(s):
	return int(s, base=16)
hex_to_dec('10')


def hex_to_dec(s):
	hex_dic = {}
	for i in range(10):
		hex_dic[str(i)] = i
	next_letter = 10
	for i in ['a', 'b', 'c', 'd', 'e', 'f']:
		hex_dic[i] = next_letter
		next_letter += 1
	base = 16
	num_digits = len(s) - 1
	dec_val = 0
	pos = 0
	for i in range(num_digits, -1, -1):
		dec_val += hex_dic[s[pos]] * base ** i
		pos += 1
	return dec_val


def hex_to_dec(n):
	a = n
	res = int(a, 16)
	return res


def hex_to_dec(s):
	a = 0
	dic_hex = {'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	for i in range(0, len(s)):
		print(s[-(i + 1)], i)
		a += int(dic_hex.get(s[-(i + 1)], s[-(i + 1)])) * 16 ** i
	return a


def hex_to_dec(s):
	sd = int(s, 16)
	print(sd)
	return sd


def hex_to_dec(s):
	d = {'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	res = 0
	for i in s:
		res *= 16
		if i.isdigit():
			res += int(i)
		else:
			res += d.get(i)
	return res


def hex_to_dec(s):
	print(s)
	v = 0
	step = 0
	for i in range(len(s) - 1, -1, -1):
		if s[i] == 'a':
			v = v + 10 * 16 ** step
		elif s[i] == 'b':
			v += 11 * 16 ** step
		elif s[i] == 'c':
			v += 12 * 16 ** step
		elif s[i] == 'd':
			v += 13 * 16 ** step
		elif s[i] == 'e':
			v += 14 * 16 ** step
		elif s[i] == 'f':
			v += 15 * 16 ** step
		else:
			v += int(s[i]) * 16 ** step
		step += 1
	return v


def hex_to_dec(s):
	x = {c: n for (n, c) in enumerate('ABCDEF', 10)}
	y = [x[c] if c in x.keys() else int(c) for c in s.upper()]
	return sum((n * 16 ** i for (n, i) in zip(y, range(len(y))[::-1])))


def hex_to_dec(s):
	hex_num = '0123456789abcdef'
	count = 0
	decimal_num = 0
	for i in s[::-1]:
		decimal_num += hex_num.index(i) * 16 ** count
		count += 1
	return decimal_num


def hex_to_dec(s):
	index = []
	for n in range(len(s)):
		index.append(s[n:n + 1])
	i_len = len(index)
	index = [10 if x == 'a' else x for x in index]
	index = [11 if x == 'b' else x for x in index]
	index = [12 if x == 'c' else x for x in index]
	index = [13 if x == 'd' else x for x in index]
	index = [14 if x == 'e' else x for x in index]
	index = [15 if x == 'f' else x for x in index]
	o = len(index)
	sum_dec = 0
	for i in range(i_len):
		sum_dec += int(index[i]) * 16 ** (o - 1)
		o -= 1
	return sum_dec
hex_to_dec('a1b2')


def hex_to_dec(s):
	a = len(s)
	b = {'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	c = {str(x): x for x in range(10)}
	for x in b:
		c[x] = b[x]
	d = 0
	f = s[::-1]
	for x in range(len(s) - 1, -1, -1):
		d += 16 ** x * c[f[x]]
	return d


def hex_to_dec(s):
	exp = result = 0
	for i in s[::-1]:
		result += '0123456789abcdef'.index(i) * 16 ** exp
		exp += 1
	return result


def hex_to_dec(s):
	D = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	ans = 0
	for c in s:
		ans = 16 * ans + D[c]
	return ans


def hex_to_dec(s):
	hexa = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	patahBalik = list(s)
	patahBalik.reverse()
	sum = 0
	power = 0
	for i in patahBalik:
		for (j, k) in hexa.items():
			if i == j:
				sum = sum + k * 16 ** power
				power = power + 1
	return sum


def hex_to_dec(s):
	a = range(16)
	b = '0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F'.split(',')
	d = {j: i for (i, j) in zip(a, b)}
	v = sum((d[j.upper()] * 16 ** i for (i, j) in enumerate(s[::-1])))
	return v


def hex_to_dec(s):
	hex_dict = {'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	hex_list = [i for i in s]
	pot_list = [i for i in range(0, len(hex_list))][::-1]
	res = 0
	for i in hex_list:
		if i in hex_dict:
			hex_list = [j.replace(i, str(hex_dict[i])) for j in hex_list]
	return sum([int(a) * 16 ** int(b) for (a, b) in zip(hex_list, pot_list)])


def hex_to_dec(s):
	letter_conversions = {'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	result = 0
	for (index, digit) in enumerate(s[::-1]):
		if digit.isnumeric():
			result += int(digit) * 16 ** index
		else:
			for (key, value) in letter_conversions.items():
				if digit == key:
					result += value * 16 ** index
	return result


def hex_to_dec(s):
	hex = '0123456789abcdef'
	deci = 0
	place = 0
	for x in reversed(s):
		if place == 0:
			deci += hex.index(x)
		else:
			deci += hex.index(x) * 16 ** place
		place += 1
	return deci


def hex_to_dec(n):
	n = list(n.lower())
	n = [10 if x == 'a' else 11 if x == 'b' else 12 if x == 'c' else 13 if x == 'd' else 14 if x == 'e' else 15 if x == 'f' else int(x) for x in n]
	Tsum = 0
	p = 0
	for (p, i) in enumerate(reversed(n), p):
		Tsum = Tsum + i * 16 ** p
	return Tsum


def hex_to_dec(s):
	dict = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	j = 0
	decimal = 0
	for i in s:
		decimal = decimal + dict[s[j]] * 16 ** (len(s) - j - 1)
		j += 1
	return decimal


def hex_to_dec(h):
	return int(h, 16)


def hex_to_dec(s):
	su = 0
	l = ['a', 'b', 'c', 'd', 'e', 'f']
	n = len(s)
	n1 = n - 1
	for i in range(0, n):
		if '0' <= s[i] <= '9':
			su = su + int(s[i]) * 16 ** n1
			n1 = n1 - 1
		else:
			su = su + (10 + l.index(s[i].lower())) * 16 ** n1
			n1 = n1 - 1
	return su


def hex_to_dec(s):
	number = 0
	lst = list(s)
	lst.reverse()
	for n in range(len(lst)):
		lst[n] = ord(lst[n]) - 87 if ord(lst[n]) > 96 else lst[n]
		number += int(lst[n]) * 16 ** n
	return number


def hex_to_dec(s):
	s = s.lower()
	t = 0
	j = len(s) - 1
	A = ['a', 'b', 'c', 'd', 'e', 'f']
	for i in range(len(s)):
		r = s[i]
		if type(s[i]) == str and 97 <= ord(s[i]) <= 102:
			r = ord(s[i]) - 87
		t += int(r) * 16 ** j
		j -= 1
	return t


def hex_to_dec(s):
	h2s = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	dec = 0
	exponent = 0
	for i in range(len(s), 0, -1):
		digit = h2s[s[i - 1].lower()]
		dec = dec + digit * 16 ** exponent
		exponent = exponent + 1
	return dec


def hex_to_dec(s):
	h = '0123456789abcdef'
	y = len(s) - 1
	x = 0
	for i in s:
		print(i)
		x += h.index(i) * 16 ** y
		y -= 1
	return x


def hex_to_dec(s):
	hexkey = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	out = 0
	for (power, char) in enumerate(reversed(s.lower())):
		out += hexkey[char] * 16 ** power
	return out


def hex_to_dec(s):
	switch = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	total = 0
	for char in s:
		total = total * 16 + switch.get(char)
	return total


def hex_to_dec(s):
	hex = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	result = 0
	rev = s[::-1]
	for idx in range(len(rev)):
		result += hex[rev[idx]] * 16 ** idx
	return result


def hex_to_dec(s):
	exponent = 0
	value = 0
	decimal = 0
	l = len(s)
	for i in range(l):
		exp = 16 ** i
		if s[l - i - 1] == 'a' or s[l - i - 1] == 'A':
			value = exp * 10
		elif s[l - i - 1] == 'b' or s[l - i - 1] == 'B':
			value = exp * 11
		elif s[l - i - 1] == 'c' or s[l - i - 1] == 'C':
			value = exp * 12
		elif s[l - i - 1] == 'd' or s[l - i - 1] == 'D':
			value = exp * 13
		elif s[l - i - 1] == 'e' or s[l - i - 1] == 'E':
			value = exp * 14
		elif s[l - i - 1] == 'f' or s[l - i - 1] == 'F':
			value = exp * 15
		else:
			value = exp * int(s[l - i - 1])
		decimal += value
	return decimal


def hex_to_dec(s):
	heshion = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	tal = 0
	for x in range(0, len(s)):
		tal += heshion[s[x]] * 16 ** (len(s) - 1 - x)
	return tal


def hex_to_dec(s):
	return sum(((ord(x) - 87 if x.isalpha() else int(x)) * 16 ** i for (i, x) in enumerate(s[::-1])))


def hex_to_dec(s):
	try:
		return int(s, 16)
	except ValueError:
		return int(s, 16)


def hex_to_dec(s):
	d = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	return sum(map(lambda x, y: d[x] * pow(16, y), s, range(len(s) - 1, -1, -1)))


from functools import reduce

def hex_to_dec(s):
	d = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15}
	return reduce(lambda x, y: x * 16 + d[y], s, 0)


def hex_to_dec(s):
	n = 0
	p = 1
	for x in s[::-1]:
		if x == 'a':
			n += 10 * p
		elif x == 'b':
			n += 11 * p
		elif x == 'c':
			n += 12 * p
		elif x == 'd':
			n += 13 * p
		elif x == 'e':
			n += 14 * p
		elif x == 'f':
			n += 15 * p
		else:
			n += int(x) * p
		p *= 16
	return n