Problem
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 27
Sample Output
------------.|.---------------------.|..|..|.---------------.|..|..|..|..|.---------.|..|..|..|..|..|..|.-------------WELCOME-------------.|..|..|..|..|..|..|.---------.|..|..|..|..|.---------------.|..|..|.---------------------.|.------------
Solution to HackerRank Designer Door Mat In Python
row, col = list(map(int, input().split()))for i in range(1, (row//2)+1): print(((".|."*i)+(".|."*(i-1))).center(col, '-'))print("WELCOME".center(col, '-'))for i in reversed(range(1, (row//2)+1)): print(((".|."*i)+(".|."*(i-1))).center(col, '-'))
NOTE: The problem solved above, Designer Door Mat, was generated by HackerRank and the solution was brought by the admin of CodingSolutions for educational purpose. Got any issues with the code? Ask your questions in the comment box and I shall attend to it.
Comments
Post a Comment