Designer Door Mat in Python - HackerRank Solution

Problem Statement :

Mr. Vincent works in a door mat manufacturing company. One day, he designed a new door mat with the following specifications:

     1. Mat size must be MXN. (N is an odd natural number, and M is 3 times N.)

     2. The design should have 'WELCOME' written in the center. 

     3. The design pattern should only use |, . and - characters.


Sample Designs:

    Size: 7 x 21 
    ---------.|.---------
    ------.|..|..|.------
    ---.|..|..|..|..|.---
    -------WELCOME-------
    ---.|..|..|..|..|.---
    ------.|..|..|.------
    ---------.|.---------
    
    Size: 11 x 33
    ---------------.|.---------------
    ------------.|..|..|.------------
    ---------.|..|..|..|..|.---------
    ------.|..|..|..|..|..|..|.------
    ---.|..|..|..|..|..|..|..|..|.---
    -------------WELCOME-------------
    ---.|..|..|..|..|..|..|..|..|.---
    ------.|..|..|..|..|..|..|.------
    ---------.|..|..|..|..|.---------
    ------------.|..|..|.------------
    ---------------.|.---------------

Input Format:

A single line containing the space separated values of M and N.


Constraints:

3<N<101

15<M<303


Output Format:

Output the design pattern.


Solution:

n,m=input().split()
c='|'
v='.'

n=int(n)
m=int(m)
j=n//2-1
for i in range(n):
    if i==n//2:
        print('WELCOME'.center(m,'-'))
    else:
        if i<n/2:    
            print(((v+c+v)*(2*i+1)).center(m,'-'))
        else:
            print(((v+c+v)*(2*j+1)).center(m,'-'))
            j=j-1



Disclaimer:- 

The above hole problem statement is given by hackerrank.com but the solution is generated by the Hackerranksolution.site authority if any of the queries regarding this post or website fill the following contact form thank you.
Next Post Previous Post
No Comment
Add Comment
comment url