16
1
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
sandbox – Luis felipe De jesus Munoz – 2019-02-05T14:53:39.743
May we take two inputs; a list of coordinates and a list of values? (This would also help for languages that don't allow mixed types.) – Adám – 2019-02-05T15:50:03.080
Should
[[2,0,"a"],[-2,0,"b"],[0,8,"HI"],[0,-1,"c"]]
display "HI" as having 7 empty rows between itself and origin? If so, can we add it as a test? – Destroigo – 2019-02-05T17:31:51.770Can strings consist of only spaces and/or only digits? My answer need some serious reworking if the answer is yes due to implicit conversion between strings and integers.. (And if the answer is yes, could you add some test cases for this, especially where the number in the string is smaller/larger than the smallest/largest coordinate.) – Kevin Cruijssen – 2019-02-05T17:42:05.320
1@KevinCruijssen You can assume there wont be any number or empty spaces only in the input. There can be something like
a a
but never1
oror
1a
or1 1
– Luis felipe De jesus Munoz – 2019-02-05T17:52:26.347Can output be an array of lines? – Shaggy – 2019-02-05T17:58:47.000
@Shaggy No.
output the result as a text.
Hope it is not a problem :c – Luis felipe De jesus Munoz – 2019-02-05T18:01:01.9201@LuisfelipeDejesusMunoz Thanks. Oh, and one more question I'm sure more people here would want to know: who is Marie? ;p – Kevin Cruijssen – 2019-02-05T18:02:03.007
2@KevinCruijssen My crush 5 years ago :c – Luis felipe De jesus Munoz – 2019-02-05T18:02:54.343
1Can we take input as a list of named tuples? Something like this:
(int a,int b,string c)
? – Embodiment of Ignorance – 2019-02-05T19:23:14.013