Magritte - Golconda
Description:
** INTRO **
It's now time for art class in CodeWars.
Golconda (French: Golconde) is an oil painting on canvas by Belgian surrealist René Magritte, painted in 1953. It is usually housed at the Menil Collection in Houston, Texas. (Wikipedia link)
Perhaps Magritte was into programming.
** Le Painting **
** Le Kata **
Your goal is to represent the men of the painting on screen.
As you can see there are 3 levels of men in perspective, let's call 1st level the closest, 2nd the middle and 3rd the farthest. Within a level they are regularly distanced to form a sort of rhombus (or an X with 4 at the 4 corners and 1 in the middle).
The 1st level man will be represented with O
for the man's head and A
for the man's body; it's the only one with 2 characters.
The 2nd and 3rd level men will be represented with !
and .
respectively.
Check the example at the end.
** INPUT **
Provided to you is a dictionary with all the main parameters.
What you need to be aware of is that for representing a level of men you just need the coordinates of one (close to the top-left) and how distant (often) you want it to repeat. For better abstraction, try to handle negative numbers as well. You will need to deal with perspective too.
A parameters dictionary will be something like:
d = {
"1_men_x": 2, # the X coordinate for men in first level
"1_men_y": 2, # the Y coordinate for men in first level
"1_men_often": 8, # distance from next of first level men
"2_men_x": 3, # the X coordinate for men in second level (middle)
"2_men_y": 1, # the Y coordinate for men in second level
"2_men_often": 6, # distance from next of second level men
"3_men_x": 0, # the X coordinate for men in third level
"3_men_y": 0, # the Y coordinate for men in third level
"3_men_often": 4, # distance from next of third level men
"width": 50, # painting width in characters
"height": 19 # painting height in characters
}
Coordinates for 1st men refer to the head coordinates', not the body!
** OFTEN PARAMETER **
About the 3 often
parameters - this distance is expressed with this example, let's suppose it equals 6:
- the next man will be 6 lines distant vertically,
- distant 6 * 2 (the double of
often
) characters horizontally, - and the men in the middle of the X-shape will have an offset of half of both vertical and horizontal distances, therefore 3 lines vertically (6 / 2) and 6 characters horizontally ( 6 * 2 / 2);
- the halves are approximated always as integer divisions.
- [this is difficult to explain] given the fact you have an
often
parameter, the coordinates might not represent exactly the left-most or top-most man, or perhaps the man can just be out of the picture, this parameter is what count the most and use the remainder operation to keep track of them on all sides. Example: if a man is at(20,20)
and will repeat with anoften
of 5, it's clearly not the top-left-most.
** OUTPUT **
With the parameters shown in the previous dictionary (suppose (0,0)
is the top-left corner, (1,0
its right, (0,1)
its down)), we have to get something like this:
. . . . . . .
! ! ! !
O . . O . . O . .
A A A
. .! . ! . .! . ! .
. O . . O . . O .
! A ! A! ! A
. . . . . . .
O . ! . O .! . !O . .!
A A A
. . . . . . .
! ! ! !
. O . . O . . O .
A A A
. .! . ! . .! . ! .
O . . O . . O . .
3rd level man is at (0,0) and repeats every 4 vertically and 4*2 horizontally.
** EXAMPLES **
Result: ``` . . . .d = {"1_men_x": 3, "1_men_y": 2, "1_men_often": 10, "2_men_x": 4, "2_men_y": 1, "2_men_often": 7, "3_men_x": 2, "3_men_y": 0, "3_men_often": 5, "width" : 40, "height": 19}
! ! !
O . . O . .
A A
! ! ! . . . .
! A ! !A . . . .. O . . O .
! ! ! O . . O . .
A A . ! . ! . !. O . . O . ! A ! A !
2.
d2 = { "1_men_x": 0, "1_men_y": 0, "1_men_often": 7, "2_men_x": 1, "2_men_y": 1, "2_men_often": 5, "3_men_x": 2, "3_men_y": 3, "3_men_often": 3, "width" : 20, "height": 15}
Result:
O . . O
A! . ! A .
. !O. . !
. A . .
!. . ! .
O . . O .
A ! A !
. . .
. O . .
! A !
. . .
.! . !.
O O
```
** HINTS **
- Use a monospace font terminal to help you solving, it's going to be a coordinates-and-if nightmare.
- remember there is no
\n
at the end.
Stats:
Created | Jan 5, 2017 |
Published | Jan 12, 2017 |
Warriors Trained | 481 |
Total Skips | 147 |
Total Code Submissions | 77 |
Total Times Completed | 12 |
Python Completions | 12 |
Total Stars | 8 |
% of votes with a positive feedback rating | 80% of 5 |
Total "Very Satisfied" Votes | 3 |
Total "Somewhat Satisfied" Votes | 2 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 4 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 6 kyu |