In this HackerRank Designer Door Mat problem you are given the dimensions of the pattern. and you need to make a design of that size.


HackerRank Designer Door Mat in python problem solution

HackerRank Designer Door Mat in python problem solution

n, m = map(int, raw_input().split())
for i in xrange(1, (n - 1)/2 + 1):
    print ('---' * ((n - 1 - 2*i + 2) / 2)) + ('.|.' * (2 * (i - 1) + 1)) + ('---' * ((n - 1 - 2*i + 2) / 2))
print ('-' * ((n*3 - 1)/2 - 3)) + 'WELCOME' + ('-' * ((n*3 - 1)/2 - 3))
for i in xrange((n - 1)/2, 0, -1):
    print ('---' * ((n - 1 - 2*i + 2) / 2)) + ('.|.' * (2 * (i - 1) + 1)) + ('---' * ((n - 1 - 2*i + 2) / 2))

Second solution

N, M = map(int,input().split()) # More than 6 lines of code will result in 0 score. Blank lines are not counted.
for i in range(1,N,2): 
    print(('.|.' * i).center(N*3, '-'))
print('WELCOME'.center(N*3, '-'))
for i in range(N-2,-1,-2): 
    print(('.|.' * i).center(N*3, '-'))