Generate a string with maximum possible alphabets with odd frequencies | Function to generate a string of length n with maximum possible alphabets each occuring odd number of times . ; If n is odd ; Add all characters from b - y ; Append a to fill the remaining length ; If n is even ; Add all characters from b - z ; Append a to fill the remaining length ; Driver code
def generateTheString ( n ) : NEW_LINE INDENT ans = " " NEW_LINE if ( n % 2 ) : NEW_LINE INDENT for i in range ( min ( n , 24 ) ) : NEW_LINE INDENT ans += chr ( ord ( ' b ' ) + i ) NEW_LINE DEDENT if ( n > 24 ) : NEW_LINE INDENT for i in range ( ( n - 24 ) ) : NEW_LINE INDENT ans += ' a ' NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT for i in range ( min ( n , 25 ) ) : NEW_LINE INDENT ans += chr ( ord ( ' b ' ) + i ) NEW_LINE DEDENT if ( n > 25 ) : NEW_LINE INDENT for i in range ( ( n - 25 ) ) : NEW_LINE INDENT ans += ' a ' NEW_LINE DEDENT DEDENT DEDENT return ans NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT n = 34 NEW_LINE print ( generateTheString ( n ) ) NEW_LINE DEDENT