human
What is a code to number of digits to be removed to make a number divisible by 3 and the other steps required given the following:
Number of digits to be removed to make a number divisible by 3 | function to count the no of removal of digits to make a very large number divisible by 3.
add up all the digits of num.
if num is already is divisible by 3 then no digits are to be removed.
if there is single digit , then it is not possible to remove one digit ..
traverse through the number and find out if any number on removal makes the sum divisible by 3.
if there are two numbers then it is not possible to remove two digits ..
Otherwise we can always make a number multiple of 2 by removing 2 digits ..
Driver Code"
Solution in Python:
assistant
#Here is code to number of digits to be removed to make a number divisible by 3 and the other steps required.
 def divisible ( num ) :
	n = len ( num )
	sum_ = 0
	for i in range ( n ) :
		sum_ += int ( num [ i ] )
	if ( sum_ % 3 == 0 ) :
		return 0
	if ( n == 1 ) :
		return - 1
	for i in range ( n ) :
		if ( sum_ % 3 == int ( num [ i ] ) % 3 ) :
			return 1
	if ( n == 2 ) :
		return - 1
	return 2
if __name__ == ' _ _ main _ _ ' :
	num = "1234"
	print ( divisible ( num ) )