human
What is a code to find k 'th character of decrypted string and the other steps required given the following:
Find k 'th character of decrypted string | Set 1 | Function to find K 'th character in Encoded String.
expand string variable is used to store final string after decompressing string str.
Current substring freq = 0 Count of current substring.
read characters until you find a number or end of string.
push character in temp.
read number for how many times string temp will be repeated in decompressed string.
generating frequency of temp.
now append string temp into expand equal to its frequency.
this condition is to handle the case when string str is ended with alphabets not with numeric value.
Driver Code"
Solution in Python:
assistant
#Here is code to find k 'th character of decrypted string and the other steps required.
 def encodedChar ( str , k ) :
	expand = " "
	i = 0
	while ( i < len ( str ) ) :
		while ( i < len ( str ) and ord ( str [ i ] ) >= ord ( ' a ' ) and ord ( str [ i ] ) <= ord ( ' z ' ) ) :
			temp += str [ i ]
			i += 1
		while ( i < len ( str ) and ord ( str [ i ] ) >= ord ( '1' ) and ord ( str [ i ] ) <= ord ( '9' ) ) :
			freq = freq * 10 + ord ( str [ i ] ) - ord ( '0' )
			i += 1
		for j in range ( 1 , freq + 1 , 1 ) :
			expand += temp
	if ( freq == 0 ) :
		expand += temp
	return expand [ k - 1 ]
if __name__ == ' _ _ main _ _ ' :
	str = " ab4c12ed3"
	k = 21
	print ( encodedChar ( str , k ) )