-
Notifications
You must be signed in to change notification settings - Fork 0
/
7 strings_designer_mat.py
79 lines (58 loc) · 1.96 KB
/
7 strings_designer_mat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
https://www.hackerrank.com/challenges/designer-door-mat/problem?isFullScreen=true
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 X. ( is an odd natural number, and is times .)
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 and .
Constraints
Output Format
Output the design pattern.
Sample Input
9 27
Sample Output
------------.|.------------
---------.|..|..|.---------
------.|..|..|..|..|.------
---.|..|..|..|..|..|..|.---
----------WELCOME----------
---.|..|..|..|..|..|..|.---
------.|..|..|..|..|.------
---------.|..|..|.---------
------------.|.------------
#%%
# Enter your code here. Read input from STDIN. Print output to STDOUT
N, M = map(int, input().split())
pat = ".|."
for i in range (1, N//2 + 1):
pat_stack = pat * (2*i - 1)
dashes_and_pat_stack = pat_stack.center(M,"-")
print(dashes_and_pat_stack)
if i == N//2:
welcome_text = "WELCOME".center(M,"-")
print(welcome_text)
for i in reversed(range(1, N//2 + 1)):
pat_stack = pat * (2*i - 1)
dashes_and_pat_stack = pat_stack.center(M,"-")
print(dashes_and_pat_stack)