In this challenge you are going to place letters from the alphabet in a Cartesian plane and output the result as a text.
Your input will consist in a list of list with 3 parameters:
- X coordinate
- Y coordinate
- String
How?
We know that a Cartesian plane contain 2 axes \$(X, Y)\$ and 4 quadrants where the signs of the \$(X,Y)\$ coordinates are \$(+,+)\$, \$(−,+)\$, \$(−,−)\$, and \$(+,−)\$. For example
Consider the following 3 by 3 matrix as a Cartesian plane
\begin{matrix} (-1,1) & (0,1) & (1,1) \\ (-1,0) & (0,0) & (1,0) \\ (-1,-1) & (0,-1) & (1,-1) \end{matrix}
If we are given in the input something like [[-1,1,L],[0,1,F]]
our matrix will look something similar to
\begin{matrix} L & F & (1,1) \\ (-1,0) & (0,0) & (1,0) \\ (-1,-1) & (0,-1) & (1,-1) \end{matrix}
And the final output LF
In addition to that there are some points we need to follow in order to get the correct output:
- When a X,Y coord is repeated, you will need to concatenate the strings. Example: assume in (-1,1) the string
F
is placed and you need to place the stringa
in the same point. You concatenate both strings resulting inFa
and that is the value that will go in (-1,1). - Your output need to be consistent to the matrix. Example imagine this as your final result:
\begin{matrix} Ma & r & ie \\ i & s & (1,0) \\ cute & (0,-1) & (1,-1) \end{matrix}
You must output
Ma rie
i s
cute
Why?
You can view this as a table where the columns are the values of the x-axis and the rows the y-axis.
Column 1 | Column 2 | Column 3
----------------------------------------
Row 1 | "Ma" | "r" | "ie"
Row 2 | "i" | "s" |
Row 3 | "cute" | |
All columns values must have the same length
Column 1 | Column 2 | Column 3
----------------------------------------
Row 1 | "Ma " | "r" | "ie"
Row 2 | "i " | "s" |
Row 3 | "cute" | |
Finnaly we output the result
Ma rie
i s
cute
Test Cases
Input
------------
[[3, 3, "c"]
[4, 1, "un"]
[5, 3, "e"]
[4, 3, "od"]
[4, 2, "lf"]
[1, 2, "go"]
[2, 1, "i"]
[2, 1, "s f"]]
Output
--------------
code
go lf
is f un
Input
--------------
[[0, 0, 's'],
[-1,1, 'M'],
[0, 1, 'r'],
[-1,1, 'a'],
[1, 1, 'i'],
[-1, 0, 'i'],
[1, 1, 'e'],
[-1,- 1, 'c'],
[-1,- 1, 'u'],
[-1, -1, 'te']]
Output.
----------------
Ma rie
i s
cute
Notes
- This is supposed to be code-golf
- You can wrap the coordinates in a single list e.g
[[3, 3], "c"]
- You can take the input in any reasonable format
- You can assume there wont be any number or empty spaces only in the input. e.g. There can be something like
a a
but never1
or" "
or1a
or1 1
a a
but never1
or ` ` or1a
or1 1
\$\endgroup\$(int a,int b,string c)
? \$\endgroup\$