human
Check if it is possible to serve customer queue with different notes | Function that returns true is selling of the tickets is possible.
Nothing to return to the customer.
Check if 25 can be returned to customer ..
Try returning one 50 and one 25.
Try returning three 25.
If the loop did not break , all the tickets were sold.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to check if it is possible to serve customer queue with different notes and the other steps required.
 def isSellingPossible ( n , a ) :
	c25 = 0 ;
	c50 = 0 ;
	i = 0 ;
	while ( i < n ) :
		if ( a [ i ] == 25 ) :
			c25 += 1 ;
		elif ( a [ i ] == 50 ) :
			c50 += 1 ;
			if ( c25 == 0 ) :
				break ;
			c25 -= 1 ;
		else :
			if ( c50 > 0 and c25 > 0 ) :
				c50 -= 1 ;
				c25 -= 1 ;
			elif ( c25 >= 3 ) :
				c25 -= 3 ;
			else :
				break ;
		i += 1 ;
	if ( i == n ) :
		return True ;
	else :
		return False ;
a = [ 25 , 25 , 50 , 100 ] ;
n = len ( a ) ;
if ( isSellingPossible ( n , a ) ) :
	print ( " YES " ) ;
else :
	print ( " NO " ) ;