human
Write me a code to find the time which is palindromic and comes after the given time and the other steps required given the following:
Find the time which is palindromic and comes after the given time | Function to return the required time.
To store the resultant time.
Hours are stored in h as integer.
Minutes are stored in m as integer.
Reverse of h.
Reverse of h as a string.
If MM < reverse of ( HH ).
0 is added if HH < 10.
0 is added if rev_h < 10.
Increment hours.
Reverse of the hour after incrementing 1.
0 is added if HH < 10.
0 is added if rev_h < 10.
Driver code"
Solution in Python:
assistant
#Here is code to find the time which is palindromic and comes after the given time and the other steps required.
 def getTime ( s , n ) :
	res = " "
	h = int ( s [ 0 : 2 ] ) ;
	m = int ( s [ 3 : 5 ] ) ;
	rev_h = ( h % 10 ) * 10 + ( ( h % 100 ) - ( h % 10 ) ) // 10 ;
	rev_hs = str ( rev_h )
	temp = " "
	if ( h == 23 and m >= 32 ) :
		res = " - 1" ;
	elif ( m < rev_h ) :
		if ( h < 10 ) :
			temp = "0" ;
		temp = temp + str ( h ) ;
		if ( rev_h < 10 ) :
			res = res + temp + " : 0" + rev_hs ;
		else :
			res = res + temp + " : " + rev_hs ;
	else :
		h += 1
		rev_h = ( h % 10 ) * 10 + ( ( h % 100 ) - ( h % 10 ) ) // 10 ;
		rev_hs = str ( rev_h ) ;
		if ( h < 10 ) :
			temp = "0" ;
		temp = temp + str ( h ) ;
		if ( rev_h < 10 ) :
			res = res + temp + " : 0" + rev_hs ;
		else :
			res = res + temp + " : " + rev_hs ;
	return res ;
if __name__ == " _ _ main _ _ " :
	s = "21:12" ;
	n = len ( s ) ;
	print ( getTime ( s , n ) ) ;