|
| 1 | +PROBLEM STATEMENT |
| 2 | +Here at [topcoder], we call a contestant a "target" if their rating is 3000 or more. |
| 3 | +In the arena, the targets have a red icon with a small target on it. |
| 4 | +Do you want to become a target as well? |
| 5 | +Sure you do. |
| 6 | +But before you get there, let's start with something easier: drawing a target. |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | +The target you need to draw consists of nested squares. |
| 11 | +The innermost square is just a single '#' character. |
| 12 | +The larger squares use alternatingly the character ' ' (space) and the character '#'. |
| 13 | +Here is an example in which the side of the largest square is n = 5: |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | +##### |
| 19 | +# # |
| 20 | +# # # |
| 21 | +# # |
| 22 | +##### |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | +And here is an example for n = 9: |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | +######### |
| 31 | +# # |
| 32 | +# ##### # |
| 33 | +# # # # |
| 34 | +# # # # # |
| 35 | +# # # # |
| 36 | +# ##### # |
| 37 | +# # |
| 38 | +######### |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | +You will be given an int n. |
| 44 | +Your method must return a vector <string> which contains a drawing of the target with side n. |
| 45 | +More precisely, each element of the returned vector <string> must be one row of the drawing, in order. |
| 46 | +Therefore, the returned vector <string> will consist of n elements, each with n characters. |
| 47 | +(See the examples below for clarification.) |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | +The value of n will be such that a target like the ones above can be drawn: 5, 9, 13, and so on. |
| 52 | +Formally, n will be of the form 4k+1, where k is a positive integer. |
| 53 | + |
| 54 | +DEFINITION |
| 55 | +Class:Target |
| 56 | +Method:draw |
| 57 | +Parameters:int |
| 58 | +Returns:vector <string> |
| 59 | +Method signature:vector <string> draw(int n) |
| 60 | + |
| 61 | + |
| 62 | +CONSTRAINTS |
| 63 | +-n will be between 5 and 49, inclusive. |
| 64 | +-n mod 4 will be 1. |
| 65 | + |
| 66 | + |
| 67 | +EXAMPLES |
| 68 | + |
| 69 | +0) |
| 70 | +5 |
| 71 | + |
| 72 | +Returns: {"#####", "# #", "# # #", "# #", "#####" } |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | +1) |
| 77 | +9 |
| 78 | + |
| 79 | +Returns: {"#########", "# #", "# ##### #", "# # # #", "# # # # #", "# # # #", "# ##### #", "# #", "#########" } |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | +2) |
| 84 | +13 |
| 85 | + |
| 86 | +Returns: {"#############", "# #", "# ######### #", "# # # #", "# # ##### # #", "# # # # # #", "# # # # # # #", "# # # # # #", "# # ##### # #", "# # # #", "# ######### #", "# #", "#############" } |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | +3) |
| 91 | +17 |
| 92 | + |
| 93 | +Returns: {"#################", "# #", "# ############# #", "# # # #", "# # ######### # #", "# # # # # #", "# # # ##### # # #", "# # # # # # # #", "# # # # # # # # #", "# # # # # # # #", "# # # ##### # # #", "# # # # # #", "# # ######### # #", "# # # #", "# ############# #", "# #", "#################" } |
| 94 | + |
| 95 | + |
0 commit comments