We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

- Prepare
- Python
- Strings
- Designer Door Mat
- Discussions

# Designer Door Mat

# Designer Door Mat

#### Sort by

recency

#### |

#### 1629 Discussions

#### |

Please Login in order to post a comment

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, "-"))

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, "-"))

This one took me a little while, but I appreciated the challenge! For those stuck: try breaking the output down into the upper, middle, and lower sections.

From there: what is the mathematical relationship between the total characters per line, dash ('-') characters, and design ('.|.') characters? I kept the middle section as one line of static output, and took this into account when looping through the output for the upper and lower sections. The lower section is the inverse of the upper section. Make sure to set your range limits properly, and increment/decrement accordingly!

N, M = [int(x) for x in input().split()]

a = 'WELCOME'

b = '.|.'

for i in range(N//2): pattern = (b * (2 * i + 1)).center(M, '-') print(pattern)

print(a.center(M, '-'))

for i in range(N//2-1, -1, -1): design = (b * (2 * i + 1)).center(M, '-') print(design)