Given a string `s` of uppercase letters, your task is to determine how many strings `t` (also uppercase) with length equal to that of `s` satisfy the followng conditions:

* `t` is lexicographical larger than `s`, and
* when you write both `s` and `t` in reverse order, `t` is still lexicographical larger than `s`.


```Haskell
For example:
solve('XYZ') = 5. They are: YYZ, ZYZ, XZZ, YZZ, ZZZ
```
String lengths are less than `5000`. Return you answer `modulo 10^9+7 (= 1000000007)`.

More examples in test cases. Good luck!

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def solve(s):
	

Solutions:
def solve(s):
	(r, l) = (0, 0)
	for c in s:
		m = ord('Z') - ord(c)
		(r, l) = (r + m + l * m, m + l * 26)
	return r % 1000000007


def solve(s, z=ord('Z')):
	a = r = 0
	for i in (z - ord(c) for c in s):
		r += (a + 1) * i
		a = a * 26 + i
		r %= 1000000007
		a %= 1000000007
	return r


def solve(s):
	M = 10 ** 9 + 7
	z = ord('Z')
	base = z - ord('A') + 1
	(left, total) = (0, 0)
	for c_num in [z - ord(c) for c in s]:
		(l, t) = (left, total)
		left = (l * base + c_num) % M
		total = ((l + 1) * c_num + t) % M
	return total


def solve(s):
	M = 10 ** 9 + 7
	base = ord('Z') - ord('A') + 1
	num_cs = map(lambda c: 90 - ord(c), [c for c in s])
	acc = (0, 0)
	for num_c in num_cs:
		(ups_left, ups_tot) = acc
		ups_left_ = (ups_left * base + num_c) % M
		ups_tot_ = ((ups_left + 1) * num_c + ups_tot) % M
		acc = (ups_left_, ups_tot_)
	return acc[1]


M = 10 ** 9 + 7
from functools import reduce

def solve(s):
	return reduce(lambda p, n: ((p[0] * 26 + (90 - n)) % M, ((p[0] + 1) * (90 - n) + p[1]) % M), map(ord, s), (0, 0))[1]


def solve(s):
	(a, pa) = (0, 0)
	for c in s:
		diff = ord('Z') - ord(c)
		a = a + diff + pa * diff
		pa = diff + pa * 26
		(a, pa) = (a % 1000000007, pa % 1000000007)
	return a


def solve(s):
	(sum_value, tmp) = (0, 0)
	for value in map(lambda x: 90 - ord(x), s):
		sum_value += value * (1 + tmp)
		tmp = (26 * tmp + value) % 1000000007
	return sum_value % 1000000007


from functools import lru_cache
from itertools import combinations

@lru_cache(5000)
def get_26_power(i):
	return 26 ** i

def solve(s):
	greater_letters = list(map(lambda x: 90 - ord(x), s))
	tmp = 1 + sum((greater * get_26_power(i) for (i, greater) in enumerate(greater_letters[1:])))
	sum_value = 0
	for value in greater_letters:
		sum_value += tmp * value
		tmp = (tmp + 25) // 26
	return sum_value % 1000000007


def solve(s):
	val = [90 - ord(c) for c in reversed(s)]
	(tmp, res) = ([0], val[0])
	for (v1, v2) in zip(val, val[1:]):
		tmp.append(tmp[-1] * 26 + v1)
		res += v2 * (tmp[-1] + 1)
	return res % (10 ** 9 + 7)


MOD = pow(10, 9) + 7

def solve(s):
	n = len(s)
	a = [25 - (ord(x) - 65) for x in s]
	(r, s) = (0, 0)
	for i in range(n):
		r = (r + a[i] + s * a[i]) % MOD
		s = (a[i] + s * 26) % MOD
	return r


def solve(s):
	n = len(s)
	(dp, mod, sum) = ([0] * n, 1000000007, 0)
	for i in range(n - 2, -1, -1):
		dp[i] = (dp[i + 1] * 26 % mod + (ord('Z') - ord(s[i + 1])) % mod) % mod
	for i in range(0, n):
		sum += (dp[i] + 1) * (ord('Z') - ord(s[i])) % mod
		sum %= mod
	return sum