This Python program is designed to create a pattern that resembles a designer door mat. The user inputs two integers, N and M, which represent the dimensions of the mat. The pattern is then generated based on these dimensions, with the word 'WELCOME' in the center and '.|.' patterns filling the rest of the space.
CodeRankGPT is a tool powered by GPT-4 that quietly assists you during your coding interview, providing the solutions you need.
In real-time and absolutely undetectable 🥷
The solution works by first taking two integers as input, N and M, which represent the dimensions of the mat. It then uses a for loop to generate the '.|.' patterns for the first half of the mat. The 'WELCOME' string is then printed in the center of the mat. Another for loop is used to generate the '.|.' patterns for the second half of the mat. The '.|.' patterns and 'WELCOME' string are surrounded by '-' characters to fill the remaining space on each line. The number of '-' characters and '.|.' patterns on each line is calculated based on the dimensions of the mat.
N, M = map(int, input().split())
for i in range(1, N, 2):
print(int((M - 3 * i) / 2) * "-" + (i * ".|.") + int((M - 3 * i) / 2) * "-")
print(int((M - 7) / 2) * "-" + "WELCOME" + int((M - 7) / 2) * "-")
for i in range(N - 2, -1, -2):
print(int((M - 3 * i) / 2) * "-" + (i * ".|.") + int((M - 3 * i) / 2) * "-")
If you have a HackerRank coding test coming up, you can use CodeRankGPT to your advantage. It will assist you during your interview and help ensure you get the job.
AI is here now, and other candidates might be using it to get ahead and win the job. 🧐
The form has been successfully submitted.