human
Largest number divisible by 50 that can be formed from a given set of N digits consisting of 0 s and 7 s only | Print the largest number divisible by 50.
Counting number of 0 s and 7 s.
If count of 7 is divisible by 50.
If count of 7 is less than 5.
If count of 7 is not divisible by 50.
Count of groups of 5 in which count of 7 s can be grouped.
Driver Code.
Given array.
Size of the array"
How can the above be solved in Python?
 ... Write me a code to largest number divisible by 50 that can be formed from a given set of N digits consisting of 0 s and 7 s only and the other steps required?
assistant
#Here is code to largest number divisible by 50 that can be formed from a given set of N digits consisting of 0 s and 7 s only and the other steps required.
 def printLargestDivisible ( arr , N ) :
	count0 = 0 ; count7 = 0 ;
	for i in range ( N ) :
		if ( arr [ i ] == 0 ) :
			count0 += 1 ;
		else :
			count7 += 1 ;
	if ( count7 % 50 == 0 ) :
		while ( count7 ) :
			count7 -= 1 ;
			print ( 7 , end = " " ) ;
		while ( count0 ) :
			count0 -= 1 ;
			print ( count0 , end = " " ) ;
	elif ( count7 < 5 ) :
		if ( count0 == 0 ) :
			print ( " No " , end = " " ) ;
		else :
			print ( "0" , end = " " ) ;
	else :
		count7 = count7 - count7 % 5 ;
		while ( count7 ) :
			count7 -= 1 ;
			print ( 7 , end = " " ) ;
		while ( count0 ) :
			count0 -= 1 ;
			print ( 0 , end = " " ) ;
if __name__ == " _ _ main _ _ " :
	arr = [ 0 , 7 , 0 , 7 , 7 , 7 , 7 , 0 , 0 , 0 , 0 , 0 , 0 , 7 , 7 , 7 ] ;
	N = len ( arr ) ;
	printLargestDivisible ( arr , N ) ;