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.
# your code goes herea=0foriinrange(1,n*2):mid=(n*4-2)//2ifi<n:k=(n*4-3)-(i*2-1)asc=97+(n-1)forjinrange(1,k+1):if(j>=mid-aandj<=(k+2)/2):print(chr(asc)+"-",end="")temp=ascasc-=1elif(j>(k+2)/2andj<=mid):temp+=1print(chr(temp)+"-",end="")else:print("-",end="")a+=2print()elifi==n:asc=97+(n-1)forjinrange(1,(n*4-2)):ifj<=mid:ifj%2==0:print("-",end="")else:print(chr(asc),end="")temp=ascasc-=1else:ifj%2==0:print("-",end="")else:temp+=1print(chr(temp),end="")print()else:a-=2asc=97+(n-1)k2=(i*2)-2forjinrange(1,k2+1):if(j>=mid-aandj<=(k2+2)/2):print(chr(asc)+"-",end="")temp=ascasc-=1elif(j>(k2+2)/2andj<=mid):temp+=1print(chr(temp)+"-",end="")else:print("-",end="")print()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 →