forked from keshavnandan/Topcoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTarget.txt
95 lines (54 loc) · 2.24 KB
/
Target.txt
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
PROBLEM STATEMENT
Here at [topcoder], we call a contestant a "target" if their rating is 3000 or more.
In the arena, the targets have a red icon with a small target on it.
Do you want to become a target as well?
Sure you do.
But before you get there, let's start with something easier: drawing a target.
The target you need to draw consists of nested squares.
The innermost square is just a single '#' character.
The larger squares use alternatingly the character ' ' (space) and the character '#'.
Here is an example in which the side of the largest square is n = 5:
#####
# #
# # #
# #
#####
And here is an example for n = 9:
#########
# #
# ##### #
# # # #
# # # # #
# # # #
# ##### #
# #
#########
You will be given an int n.
Your method must return a vector <string> which contains a drawing of the target with side n.
More precisely, each element of the returned vector <string> must be one row of the drawing, in order.
Therefore, the returned vector <string> will consist of n elements, each with n characters.
(See the examples below for clarification.)
The value of n will be such that a target like the ones above can be drawn: 5, 9, 13, and so on.
Formally, n will be of the form 4k+1, where k is a positive integer.
DEFINITION
Class:Target
Method:draw
Parameters:int
Returns:vector <string>
Method signature:vector <string> draw(int n)
CONSTRAINTS
-n will be between 5 and 49, inclusive.
-n mod 4 will be 1.
EXAMPLES
0)
5
Returns: {"#####", "# #", "# # #", "# #", "#####" }
1)
9
Returns: {"#########", "# #", "# ##### #", "# # # #", "# # # # #", "# # # #", "# ##### #", "# #", "#########" }
2)
13
Returns: {"#############", "# #", "# ######### #", "# # # #", "# # ##### # #", "# # # # # #", "# # # # # # #", "# # # # # #", "# # ##### # #", "# # # #", "# ######### #", "# #", "#############" }
3)
17
Returns: {"#################", "# #", "# ############# #", "# # # #", "# # ######### # #", "# # # # # #", "# # # ##### # # #", "# # # # # # # #", "# # # # # # # # #", "# # # # # # # #", "# # # ##### # # #", "# # # # # #", "# # ######### # #", "# # # #", "# ############# #", "# #", "#################" }