Designer Door Mat - Python HackerRank Solution
Hello Friends, How are you? Today I am going to solve the HackerRank Designer Door Mat Problem in Python with a very easy explanation. In this article, you will get one or more approaches to solving this problem. So let's start-
{tocify} $title={Table of Contents}
HackerRank Python Designer Door Mat Solution - Problem Statement
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 N X M. (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------------- ---.|..|..|..|..|..|..|..|..|.--- ------.|..|..|..|..|..|..|.------ ---------.|..|..|..|..|.--------- ------------.|..|..|.------------ ---------------.|.--------------- {codeBox}
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 {codeBox}
Sample Output
------------.|.------------ ---------.|..|..|.--------- ------.|..|..|..|..|.------ ---.|..|..|..|..|..|..|.--- ----------WELCOME---------- ---.|..|..|..|..|..|..|.--- ------.|..|..|..|..|.------ ---------.|..|..|.--------- ------------.|.------------ {codeBox}
Python Designer Door Mat - Hacker Rank Solution
Approach I: Designer Door Mat HackerRank Python Solution
# ========================
# Information
# ========================
# Name: Designer Door Mat in Python HackerRank
# Direct Link: https://www.hackerrank.com/challenges/designer-door-mat/problem
# Difficulty: Easy
# Max Score: 10
# Language: Pypy 3
# ========================
# Solution Start
# ========================
#Designer Door Mat in Python - Hacker Rank Solution
# Enter your code here. Read input from STDIN. Print output to STDOUT
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, -1, -2):
print((i * ".|.").center(M, "-"))
#Designer Door Mat in Python - Hacker Rank Solution END
# MyEduWaves
Disclaimer: The above Problem ( Python Designer Door Mat ) is generated by Hackerrank but the Solution is Provided by MyEduWaves. This tutorial is only for Educational and Learning purposes. Authority if any queries regarding this post or website fill out the contact form.
I hope you have understood the solution to this HackerRank Problem. All these three solutions will pass all the test cases. Now visit Python Designer Door Mat Hackerrank Problem and try to solve it again.
All the Best!
Tags:
HackerRank Python