We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
importmathdefget_char_seq(j,n):str1=''foriinrange(1,j+1):str1+=chr(97+n-i)str1='-'.join(str1)returnstr1defget_string(i,size,columns):str1=get_char_seq(i,size)str2=str1[:-2]str2=''.join(reversed(str2))left_dash=((math.floor(columns/2)+1)-len(str1))*'-'right_dash=((math.floor(columns/2)-1)-len(str2))*'-'full_string=left_dash+str1+'-'+str2+right_dashreturnfull_stringdefprint_rangoli(size):# your code goes herecolumns=4*size-3ifsize==1:print('a')else:foriinrange(1,size+1):full_string=get_string(i,size,columns)print(full_string)foriinrange(size-1,0,-1):full_string=get_string(i,size,columns)print(full_string)if__name__=='__main__':n=int(input())print_rangoli(n)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Alphabet Rangoli
You are viewing a single comment's thread. Return to all comments →