Every Turkish citizen has an identity number whose validity can be checked by these set of rules:

- It is an 11 digit number
- First digit can't be zero
- Take the sum of 1st, 3rd, 5th, 7th and 9th digit and multiply it by 7.
Then subtract the sum of 2nd, 4th, 6th and 8th digits from this value.
Modulus 10 of the result should be equal to 10th digit.
- Sum of first ten digits' modulus 10 should be equal to eleventh digit.

Example:

    10167994524
    //  1+1+7+9+5= 23   // "Take the sum of 1st, 3rd, 5th, 7th and 9th digit..."
    //    23 * 7= 161   //  "...and multiply it by 7"
    //   0+6+9+4 = 19   // "Take the sum of 2nd, 4th, 6th and 8th digits..."
    // 161 - 19 = 142   // "...and subtract from first value"
    // "Modulus 10 of the result should be equal to 10th digit"
    10167994524
             ^ = 2 = 142 % 10
    // 1+0+1+6+7+9+9+4+5+2 = 44
    // "Sum of first ten digits' modulus 10 should be equal to eleventh digit"
    10167994524
              ^ = 4 = 44 % 10

Your task is to write a function to check the validity of a given number.
Return `true` or `false` accordingly.

Note: The input can be a string in some cases.

Difficulty: EASY
Starter code: def check_valid_tr_number(number):
	

Solutions:
def check_valid_tr_number(n):
	return type(n) == int and len(str(n)) == 11 and (8 * sum(map(int, str(n)[:-1:2])) % 10 == sum(map(int, str(n)[:-1])) % 10 == n % 10)


import re

def check_valid_tr_number(n):
	lst = list(map(int, str(n) if isinstance(n, int) else '0'))
	return isinstance(n, int) and len(lst) == 11 and (sum(lst[:10]) % 10 == lst[-1]) and ((sum(lst[0:9:2]) * 7 - sum(lst[1:8:2])) % 10 == lst[-2])


def check_valid_tr_number(number):
	s = str(number)
	return len(s) == 11 and s.isdigit() and (not s.startswith('0')) and ((sum(map(int, s[:9:2])) * 7 - sum(map(int, s[1:8:2]))) % 10 == int(s) // 10 % 10) and (sum(map(int, s[:10])) % 10 == int(s) % 10)


def check_valid_tr_number(n):
	if not isinstance(n, int) or not 9999999999 < n < 100000000000:
		return False
	dig = [int(d) for d in str(n)]
	return (sum(dig[:9:2]) * 7 - sum(dig[1:9:2])) % 10 == dig[9] and sum(dig[:10]) % 10 == dig[10]


def check_valid_tr_number(number):
	print(number)
	if not len(str(number)) == 11 or not isinstance(number, int):
		return False
	number = str(number)
	odd = int(number[0]) + int(number[2]) + int(number[4]) + int(number[6]) + int(number[8])
	even = int(number[1]) + int(number[3]) + int(number[5]) + int(number[7])
	sub = (odd * 7 - even) % 10
	if str(sub) == number[9] and (odd + even + int(number[9])) % 10 == int(number[10]):
		return True
	else:
		return False


def check_valid_tr_number(number):
	if not isinstance(number, int):
		return False
	s = str(number)
	if len(s) != 11:
		return False
	if sum(map(int, s[:-1])) % 10 != int(s[-1]):
		return False
	if (7 * sum(map(int, s[:-1:2])) - sum(map(int, s[1:-2:2]))) % 10 != int(s[-2]):
		return False
	return True


def check_valid_tr_number(number):
	n = str(number)
	return isinstance(number, int) and len(n) == 11 and (str((sum((int(n[i]) for i in range(0, 10, 2))) * 7 - sum((int(n[i]) for i in range(1, 8, 2)))) % 10) == n[9]) and (str(sum((int(n[i]) for i in range(10))) % 10) == n[10])