Given a large positive number N having x digits, the task is to count all rotations of the given number which are divisible by 4.
Example 1:
Input: N = 8
Output: 1
Explaination: The number 8 is divisible by 4.
Example 2:
Input: N = 20
Output: 1
Explaination: The number 20 is divisible by 4. 
But after rotation 02 is not divisible by 4.
Your Task:
You do not need to read input or print anything. Your task is to complete the function countRotations() which takes N as input parameter and returns the number of rotations divisible by 4.
Expected Time Complexity: O(x)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ x ≤ 10^{5}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3

class Solution:
    def countRotations(self, N):
        # code here

Solutions:
class Solution:

	def countRotations(self, N):
		s = str(N)
		c = 0
		for i in range(len(s)):
			j = s[i:] + s[:i]
			j = int(j)
			if j % 4 == 0:
				c = c + 1
		return c


class Solution:

	def countRotations(self, N):
		if len(N) == 1:
			if int(N) % 4 == 0:
				return 1
			return 0
		c = 0
		n = len(N)
		for i in range(n - 1):
			d = N[i] + N[i + 1]
			if int(d) % 4 == 0:
				c += 1
		if int(N[n - 1] + N[0]) % 4 == 0:
			c += 1
		return c


class Solution:

	def countRotations(self, N):
		a = str(N)
		c = 0
		for i in range(len(a)):
			b = a[i:] + a[:i]
			if int(b) % 4 == 0:
				c += 1
		return c
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = input()
		ob = Solution()
		print(ob.countRotations(N))


class Solution:

	def countRotations(self, N):
		a = str(N)
		c = 0
		for i in range(len(a)):
			b = a[i:] + a[:i]
			if int(b) % 4 == 0:
				c += 1
		return c