我们房子外面有一个10x10米的正方形花园。我们想种草,做一个露台。我们已经决定了如何划分花园,但是我们还没有确定草量与露台之间的比例。
我们需要可视化帮助,而ASCII艺术显然是实现此目的的最佳方法。
挑战:
取一个整数,范围为[0,100](或可选的十进制[0,1]),代表应该露台花园的百分比。
一平方米的露台用破折号-
或条形表示|
。一平方米的草用井号表示#
。
- 如果露台的数量小于或等于50%,则应在花园的左下角开始用条形遮盖,然后垂直然后水平填充。
- 如果梯田的数量超过50%,则我们希望以另一种方式(用虚线代替条形)进行装饰,并从左下角开始,然后水平填充,然后垂直填充。
例子:
N = 25%
||########
||########
||########
||########
||########
|||#######
|||#######
|||#######
|||#######
|||#######
N = 75%
##########
##########
-----#####
----------
----------
----------
----------
----------
----------
----------
N = 47%
||||######
||||######
||||######
|||||#####
|||||#####
|||||#####
|||||#####
|||||#####
|||||#####
|||||#####
N = 50%
|||||#####
|||||#####
|||||#####
|||||#####
|||||#####
|||||#####
|||||#####
|||||#####
|||||#####
|||||#####
N = 51%
##########
##########
##########
##########
-#########
----------
----------
----------
----------
----------
N = 0%
##########
##########
##########
##########
##########
##########
##########
##########
##########
##########
N = 100%
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
这是代码高尔夫球,因此以字节为单位的最短代码获胜。有关I / O的标准规则。这是ASCII技术,因此输出应类似于上面的示例。即输出["|", "|" ...]
不正确。
一如既往地鼓励解释:)