# Task
 John loves encryption. He can encrypt any string by the following algorithm:
```
take the first and the last letters of the word;
replace the letters between them with their number;
replace this number with the sum of it digits 
          until a single digit is obtained.```
Given two strings(`s1` and `s2`), return `true` if their encryption is the same, or `false` otherwise.

# Example

 For `s1 = "EbnhGfjklmjhgz" and s2 = "Eabcz"`, the result should be `true`.
 ```
 "EbnhGfjklmjhgz" --> "E12z" --> "E3z"
 "Eabcz" --> "E3z"
 Their encryption is the same.```
 
# Input/Output


 - `[input]` string `s1`

  The first string to be encrypted.
  
  `s1.length >= 3`
 
 
 - `[input]` string `s2`

  The second string to be encrypted.

  `s2.length >= 3`
  
  
 - `[output]` a boolean value

 `true` if encryption is the same, `false` otherwise.

Source: codewars | Difficulty: EASY
Tags: Ad-hoc

Starter code: def same_encryption(s1, s2):
	

Solutions:
def same_encryption(s1, s2):
	return (s1[0], s1[-1], len(s1) % 9) == (s2[0], s2[-1], len(s2) % 9)


def same_encryption(s1, s2):
	encrypt = lambda s: f'{s[0]}{len(s[1:-1]) % 9}{s[-1]}'
	return encrypt(s1) == encrypt(s2)


def same_encryption(s1, s2):

	def single_digit(s):
		total = len(s) - 2
		while total > 9:
			total = sum((int(d) for d in str(total)))
		return '{}{}{}'.format(s[0], total, s[-1])
	return single_digit(s1) == single_digit(s2)


def same_encryption(s1, s2):
	(l1, l2) = (str(len(s1) - 2), str(len(s2) - 2))
	while int(l1) // 10 or int(l2) // 10:
		(l1, l2) = (str(sum(map(int, l1))), str(sum(map(int, l2))))
	return l1 == l2 and s1[0] == s2[0] and (s1[-1] == s2[-1])


def encrypt(s):
	n = len(s[1:-1])
	while n > 9:
		n = sum(map(int, str(n)))
	return f'{s[0]}{n}{s[-1]}'

def same_encryption(s1, s2):
	return encrypt(s1) == encrypt(s2)


from string import ascii_lowercase as alphabet

def same_encryption(s1, s2):
	sum_s1 = len(s1[1:-1])
	sum_s2 = len(s2[1:-1])
	while len(str(sum_s1)) > 1:
		sum_s1 = sum(map(int, str(sum_s1)))
	while len(str(sum_s2)) > 1:
		sum_s2 = sum(map(int, str(sum_s2)))
	return '{}{}{}'.format(s1[0], sum_s1, s1[-1]) == '{}{}{}'.format(s2[0], sum_s2, s2[-1])


def same_encryption(a, b):
	f = lambda s: f'{s[0]}{(len(s) - 2) % 9 or 9}{s[-1]}'
	return f(a) == f(b)


def same_encryption(s1, s2):
	return s1[0] == s2[0] and s1[-1] == s2[-1] and ((len(s1) - 2) % 9 == (len(s2) - 2) % 9)