human
Minimum time required to print given string from a circular container based on given conditions | Function to calculate minimum time to print all characters in the string.
Current element where the pointer is pointing.
Find index of that element.
Calculate absolute difference between pointer index and character index as clockwise distance.
Subtract clockwise time from 26 to get anti - clockwise time.
Add minimum of both times to the answer.
Add one unit time to print the character.
Print the final answer.
Driver code.
Given string word.
Function call"
Solution in Python:
assistant
#Here is code to minimum time required to print given string from a circular container based on given conditions and the other steps required.
 def minTime ( word ) :
	ans = 0
	curr = 0
	for i in range ( len ( word ) ) :
		k = ord ( word [ i ] ) - 97
		a = abs ( curr - k )
		b = 26 - abs ( curr - k )
		ans += min ( a , b )
		ans += 1
		curr = ord ( word [ i ] ) - 97
	print ( ans )
if __name__ == ' _ _ main _ _ ' :
	str = " zjpc "
	minTime ( str )