human
What is a code to count rotations divisible by 4 and the other steps required given the following:
Count rotations divisible by 4 | Returns count of all rotations divisible by 4.
For single digit number.
At - least 2 digit number ( considering all pairs ).
Considering the number formed by the pair of last digit and 1 st digit.
Driver program"
How can the above be solved in Python?
assistant
#Here is code to count rotations divisible by 4 and the other steps required.
 def countRotations ( n ) :
	l = len ( n )
	if ( l == 1 ) :
		oneDigit = ( int ) ( n [ 0 ] )
		if ( oneDigit % 4 == 0 ) :
			return 1
		return 0
	count = 0
	for i in range ( 0 , l - 1 ) :
		twoDigit = ( int ) ( n [ i ] ) * 10 + ( int ) ( n [ i + 1 ] )
		if ( twoDigit % 4 == 0 ) :
			count = count + 1
	twoDigit = ( int ) ( n [ l - 1 ] ) * 10 + ( int ) ( n [ 0 ] )
	if ( twoDigit % 4 == 0 ) :
		count = count + 1
	return count
n = "4834"
print ( " Rotations : ▁ " , countRotations ( n ) )