Mr. Vincent works in a door mat manufacturing company. One day, he designed a new door mat with the following specifications:
- Mat size must be NxM. (N is an odd natural number, and M is 3 times N.)
- The design should have ‘WELCOME’ written in the center.
- 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 N and M.
Constraints
- 5<N<101
- 15<M<303
Output Format
Output the design pattern.
Sample Input
9 27Sample Output
------------.|.------------
---------.|..|..|.---------
------.|..|..|..|..|.------
---.|..|..|..|..|..|..|.---
----------WELCOME----------
---.|..|..|..|..|..|..|.---
------.|..|..|..|..|.------
---------.|..|..|.---------
------------.|.------------Solution
I used the center function to center the string in the middle of the line. I used the for loop to print the top half of the door mat and then the welcome message and then the bottom half of the door mat.
n,m = list(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,-1,-2):
print((".|."*i).center(m,"-"))Happy Learning – If you require any further information, feel free to contact me.
![[Solved] Mr. Vincent works in a door mat manufacturing company [Solved] Mr. Vincent works in a door mat manufacturing company](https://realcoder.techss24.com/wp-content/uploads/2022/12/Solved-Mr.-Vincent-works-in-a-door-mat-manufacturing-company.png)
![[Solved] Write a function HackerRank Problem](https://realcoder.techss24.com/wp-content/uploads/2022/09/Solved-Write-a-function-HackerRank-Problem-300x200.png)
![[Solved] You are in charge of the cake for a child's birthday Optimize Solution](https://realcoder.techss24.com/wp-content/uploads/2022/12/Solved-You-are-in-charge-of-the-cake-for-a-childs-birthday-Optimize-Solution-300x197.png)
![[Solved] Given a square matrix, calculate the absolute difference between the sums of its diagonals. Optimize Solution](https://realcoder.techss24.com/wp-content/uploads/2022/12/Solved-Given-a-square-matrix-calculate-the-absolute-difference-between-the-sums-of-its-diagonals.-Optimize-Solution-300x192.png)