您正在为朋友组织寻宝活动。为了更轻松地进行操作,您想要绘制隐藏贵重物品的所有位置的地图。
输入值
0 0
允许使用任何形式的输入来表示由(负)x和y坐标组成的点列表,即左上角(注意:您也可以在答案中使用基于1的索引,请对此进行评论)。例:
1 2
3 0
0 1
挑战
您的函数或程序应该能够构造一个映射,该映射表示每个给定位置,x
并在输出的y + 1行和x + 1列中找到标记。未标记的位置以表示。该地图还包含一个框架,其中的角为
+
s,垂直线为|
s,水平线为-
s。您的解决方案应该输出最小的帧。上面给出的输入示例的映射:
+----+
| x|
|x |
| x |
+----+
可能的测试案例
"0 0"
=>
+-+
|x|
+-+
"0 10
5 5
10 0"
=>
+-----------+
| x|
| |
| |
| |
| |
| x |
| |
| |
| |
| |
|x |
+-----------+
""
=>
++
++
"0 0
0 2
2 0"
=>
+---+
|x x|
| |
|x |
+---+
当然,这是code-golf,这意味着字节数最少的解决方案将获胜!鼓励您对解决方案进行说明。
the input is a list of locations (e.g. nested list, list of tuples, space & newline separated, separate inputs, ect.)