Alphabet Rangoli

Sort by

recency

|

1357 Discussions

|

  • + 0 comments

    def print_rangoli(size): # your code goes here for x in range (96+size,96,-1): listcharsl = [chr(c) for c in range (96+size,x-1, -1)] listcharsr = [chr(c) for c in range (x+1,97+size)] print ("--"(x-97),"-".join(listcharsl), "-" if listcharsr else "", "-".join(listcharsr),"--"(x-97), sep="")

    for x in range (1,size):
        listcharsl.pop()
        listcharsr.pop(0)
        print ("--"*(x),"-".join(listcharsl), "-" if listcharsr else "", "-".join(listcharsr),"--"*(x), sep="")
    
  • + 2 comments
    z = "abcdefghijklmnopqrstuvwxyz"
    		
    b = "".join(z[:n][::-1])
    	
    c = [b[0:i]+b[0:i+1][::-1] for i in range(n)]
        
    d = ["-".join(i).center(n*4-3,"-") for i in c]
    
    print("\n".join(d), "\n".join(d[::-1][1:]), sep="\n")
    
  • + 1 comment
    def print_rangoli(size):
        # your code goes here
        asciiVal = size+96
        change = -1
        char = ""
        op = []
        def makeSymmetric(s):
            return s + s[:-1][::-1]
        for i in range(size):
            char = char + chr(asciiVal)
            asciiVal = asciiVal + change
            op.append(makeSymmetric("-".join(list(str(char)))).center(size * 4 - 3, "-" ))
        for i in op:
            print(i)
        for i in range(len(op)-2, -1, -1):
            print(op[i])
    
    if __name__ == '__main__':
        n = int(input())
        print_rangoli(n)
    
  • + 0 comments

    def print_rangoli(size): s,l='',[] if size==1: print('a') else: for i in range(96+size,96,-1): for j in range(96+size,i-1,-1): s=s+chr(j)+'-'

            if len(s)!=2:
                l.append((s+s[len(s)-4::-1]).center((size-1)*4+1,'-'))
            else:
                l.append(s.center((size-1)*4+1,'-'))
            s=''
        for h in l:
            print(h)
        for k in l[len(l)-2::-1]:
            print(k)
    
  • + 0 comments

    def print_rangoli(size): import string

    if not 0 < size < 27:
        return 
    
    alphabet = string.ascii_lowercase[:size][::-1]
    
    
    lines = []
    for i in range(size):
    
        pattern = "-".join(alphabet[:i + 1])
    
        lines.append((pattern + pattern[-2::-1]).center(4 * size - 3, "-"))
    
    print("\n".join(lines + lines[-2::-1]))