human
Write me a code to smallest multiple of 3 which consists of three given non and the other steps required given the following:
Smallest multiple of 3 which consists of three given non | Function to return the minimum number divisible by 3 formed by the given digits.
Sort the given array in ascending.
Check if any single digit is divisible by 3.
Check if any two digit number formed by the given digits is divisible by 3 starting from the minimum.
Generate the two digit number.
If none of the above is true , we can form three digit number by taking a [ 0 ] three times ..
Driver code"
How can the above be solved in Python?
assistant
#Here is code to smallest multiple of 3 which consists of three given non and the other steps required.
 def printSmallest ( a , n ) :
	sum0 , sum1 = 0 , 0
	a = sorted ( a )
	for i in range ( n ) :
		if ( a [ i ] % 3 == 0 ) :
			return a [ i ]
	for i in range ( n ) :
		for j in range ( n ) :
			num = ( a [ i ] * 10 ) + a [ j ]
			if ( num % 3 == 0 ) :
				return num
	return a [ 0 ] * 100 + a [ 0 ] * 10 + a [ 0 ]
arr = [ 7 , 7 , 1 ]
n = len ( arr )
print ( printSmallest ( arr , n ) )