human
String with k distinct characters and no same characters adjacent | Function to find a string of length n with k distinct characters ..
Initialize result with first k Latin letters.
Fill remaining n - k letters by repeating k letters again and again ..
Driver code"
How can the above be solved in Python?
assistant
#Here is code to string with k distinct characters and no same characters adjacent and the other steps required.
 def findString ( n , k ) :
	res = " "
	for i in range ( k ) :
		res = res + chr ( ord ( ' a ' ) + i )
	count = 0
	for i in range ( n - k ) :
		res = res + chr ( ord ( ' a ' ) + count )
		count += 1
		if ( count == k ) :
			count = 0 ;
	return res
if __name__ == " _ _ main _ _ " :
	n = 5
	k = 2
	print ( findString ( n , k ) )