Given a  number N such that it may contain many continuous digits. Find the number of ways to spell the number.
For example, consider 8884441100, one can spell it simply as triple eight triple four double two and double zero. One can also spell as double eight, eight, four, double four, two, two, double zero.
 
Example 1:
Input:
N = 100
Output:
2
Explanation:
The number 100 has only 2 possibilities, 
1) one zero zero 
2) one double zero.
Example 2:
Input:
N = 11112
Output:
8
Explanation:
1 1 1 1 2, 11 1 1 2, 1 1 11 2, 1 11 1 2,
11 11 2, 1 111 2, 111 1 2, 1111 2
Example 3:
Input:
N = 12345
Output:
1
Explanation:
The number 12345 has only 1 possibility, 
one two three four five
 
Your Task:
You don't need to read input or print anything. Your task is to complete the function differentWaysToSpell() which takes a String N as input and returns the number of possible ways.
 
Expected Time Complexity: O(|N|)
Expected Auxiliary Space: O(1)
 
Constraints:
1 <= |N| <= 10^{50}

Difficulty: EASY
Tags: Combinatorics

Mathematics
Expected Time Complexity: O(|N|)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3



class Solution:

    def differentWaysToSpell(self, N):

        # code here

Solutions:
class Solution:

	def differentWaysToSpell(self, N):
		result = 1
		count = 1
		for i in range(1, len(N)):
			if N[i - 1] == N[i]:
				count += 1
			else:
				result *= 2 ** (count - 1)
				count = 1
		return result * 2 ** (count - 1)


class Solution:

	def differentWaysToSpell(self, N):
		r = 1
		c = 1
		for i in range(1, len(N)):
			if N[i - 1] == N[i]:
				c += 1
			else:
				r *= 2 ** (c - 1)
				c = 1
		return r * 2 ** (c - 1)


class Solution:

	def differentWaysToSpell(self, N):
		n = len(N)
		r = 1
		i = 0
		while i < n:
			count = 1
			while i < n - 1 and N[i + 1] == N[i]:
				count += 1
				i += 1
			r = r * int(pow(2, count - 1))
			i += 1
		return r


class Solution:

	def differentWaysToSpell(self, N):
		no_of_ways = 1
		prev = N[0]
		curr_count = 1
		for i in range(1, len(N)):
			curr = N[i]
			if curr == prev:
				curr_count += 1
			else:
				no_of_ways *= pow(2, curr_count - 1)
				prev = curr
				curr_count = 1
		no_of_ways *= pow(2, curr_count - 1)
		return no_of_ways


class Solution:

	def differentWaysToSpell(self, N):
		n = len(N)
		res = 1
		i = 0
		while i < n:
			c = 1
			while i < n - 1 and N[i] == N[i + 1]:
				c = c + 1
				i = i + 1
			res = res * int(pow(2, c - 1))
			i = i + 1
		return res


class Solution:

	def differentWaysToSpell(self, N):
		res = 1
		c = 1
		for i in range(1, len(N)):
			if N[i - 1] == N[i]:
				c += 1
			else:
				res *= 2 ** (c - 1)
				c = 1
		return res * 2 ** (c - 1)
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = input()
		ob = Solution()
		print(ob.differentWaysToSpell(N))


class Solution:

	def differentWaysToSpell(self, N):
		l = []
		d = len(N)
		c = 0
		for i in range(d - 1):
			if N[i] == N[i + 1]:
				c += 1
			else:
				l.append(c)
				c = 0
		l.append(c)
		p = 1
		for i in l:
			p = p * 2 ** i
		return p
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = input()
		ob = Solution()
		print(ob.differentWaysToSpell(N))


class Solution:

	def differentWaysToSpell(self, N):
		lst = list(N)
		result = 1
		count = 1
		for itr in range(1, len(lst)):
			if lst[itr - 1] == lst[itr]:
				count += 1
			else:
				result *= 2 ** (count - 1)
				count = 1
		return result * 2 ** (count - 1)
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = input()
		ob = Solution()
		print(ob.differentWaysToSpell(N))