Designer Door Mat

Sort by

recency

|

1815 Discussions

|

  • + 0 comments
    n = int(a)
    m = int(b)
    mid = (n // 2) + 1  
    d = '-'
    l = '.|.'
    
    for i in range(1, n + 1):
        if i < mid:
            num_blocks = (2 * (i - 1)) + 1
            print((l * num_blocks).center(m, d))
        elif i == mid:
            print("WELCOME".center(m, d))
        else:  
            num_blocks = (2 * (n - i)) + 1
            print((l * num_blocks).center(m, d))
    
  • + 0 comments
    h, w = map(int, input().split())
    for i in range(1,h,2):
        print((".|."*i).center(w,"-"))
    print("WELCOME".center(w,"-"))
    for i in range(h-2,0,-2):
        print((".|."*i).center(w,"-"))
    
  • + 0 comments
    def is_valid_input(height: int, width: int) -> bool:
        return (
            isinstance(height, int)
            and isinstance(width, int)
            and height % 2 == 1
            and width == height * 3
            and 5 < height < 101
        )
    
    
    def design_doormat(height: int, width: int) -> list[str]:
        if not is_valid_input(height, width):
            raise ValueError("Invalid input: N must be odd, M must be 3*N")
    
        lines = []
    
        # Top
        for i in range(1, height, 2):
            pattern = ".|." * i
            lines.append(pattern.center(width, "-"))
    
        # Center
        lines.append("WELCOME".center(width, "-"))
    
        # Bottom
        for i in range(height - 2, 0, -2):
            pattern = ".|." * i
            lines.append(pattern.center(width, "-"))
    
        return lines
    
    
    if __name__ == "__main__":
        n, m = map(int, input().split())
        for line in design_doormat(n, m):
            print(line)
    
  • + 1 comment

    n, m = map(int, input().split())

    for i in range(1, n, 2): print((".|." * i).center(m, "-"))

    print("WELCOME".center(m, "-"))

    for i in range(n-2, 0, -2): print((".|." * i).center(m, "-"))

  • + 0 comments
    import math
    N , M = map(int, input().split())
    # M = 3*N  #because it will be done implicitly by hackerank, no need to ovrwrite
    
    ro = math.floor(N/2)
    for i in range(0 ,ro):
        print(('.|.'*(i*2+1)).center(M,'-'))
        
    print('WELCOME'.center(M,'-'))
    
    for i in range(ro-1,-1,-1):
        print(('.|.'*(i*2+1)).center(M,'-'))