包含-排除使您可以在知道其他一些值的情况下计算集合之间的某些并集和相交的大小。我不会确切解释,但是您的挑战是在维恩图上可视化包含-排除。
因为我很好,所以您将使用矩形,而不是圆形。
您将获得一个以任何合理格式(由4元组组成的列表,成对的列表,成对的列表等)表示的矩形列表,这些矩形由左上角和右下角的坐标表示。您可以假定所有坐标都是非负数,并且在您的语言的(合理的)数字范围内(请指定小于128的坐标)。您可以选择是左包含或左包含以及右包含或右包含。无论选择哪种格式,都可以假定所有矩形至少为1x1。
然后,您将使用一个非空白字符绘制屏幕上的每个矩形(ASCII画布)k
,这是您可以选择的。
但是,每当两个矩形重叠时,重叠区域应使用另一个非空白字符绘制l != k
,您也可以选择。
每当3个矩形重叠时,重叠区域应与被绘制k
,以及用于奇数矩形的覆盖,k
以及偶数,l
。
背景应为单个空格(0x20
)。
测试用例(k = "#", l = "."
)
0 0 9 9
1 1 10 10
2 2 11 11
#########
#........#
#.#######.#
#.#######.#
#.#######.#
#.#######.#
#.#######.#
#.#######.#
#.#######.#
#........#
#########
1 1 3 3
2 2 4 4
##
#.#
##
1 1 9 9
2 2 8 8
3 3 7 7
########
#......#
#.####.#
#.####.#
#.####.#
#.####.#
#......#
########
笔记
0, 0
必须存在前导空格和换行符(如果没有最小坐标,则会出现换行符)- 任何尾随空格和换行符都被允许在合理范围内(即不要像100000000换行符那样尾随,这很烦人)
- x轴和y轴可以面对任何一个方向,但您必须保持一致并指定哪个(默认值为x右和y向下)
- 坐标可以是0、1,或2的索引。
这是代码高尔夫球,因此目标是拥有最短的代码。打高尔夫球快乐!