您应该编写一个程序或函数,该程序或函数接收一个碗的容积和其中的水作为输入,然后输出或返回一个带有所需容积的碗的ASCII表示形式。
碗具有以下结构:
\ /
\___/
碗至少有一个_
字符。的计数\
的和/
的,也正和他们是平等的对称因。
碗的容积的总数量_
和space
所述字符之间\
的和/
的加一,每对\
和/
。这表示上述碗的容量为10
:
\ / => xxxxx x (the last one is for the \/ pair)
\___/ xxx x (the last one is for the \/ pair)
请注意,两个不同的碗可能具有相同的体积。例如,以下两个碗的容积均为18:
\ /
\ / \ /
\___/ \_______/
我们可以往碗里倒些水。水被表示为一行~
字符,而不是碗中的空格。最下面一行没有空格,因此不能包含~
。这意味着我们的示例只能以一种方式充满水:
\~~~~~/
\___/
其他碗可以通过多种方式填充:
\~~~~~/ \ /
\ / \~~~/
\_/ \_/
碗中的水量是字符下方的碗行的量~
。上面的例子4, 6 and 2
分别有水量。
输入项
- 两个正整数,碗的体积和水的体积。
- 您可以选择两个数字的顺序。
- 可以以任何常见列表格式(列表,元组,数组等)或两个单独的整数输入两个整数。
- 对于输入值,至少要保证一种有效的碗水配置。
输出量
- 装有水的碗的ASCII表示,其中碗和水的体积与输入相匹配。
- 如果您选择返回结果而不是打印结果,则应将其作为单个字符串(或您的语言最接近的替代品)返回。
- 允许任何尾随空格。
- 不允许使用不必要的前导空格。
- 如果有多个正确的配置,则可以自由选择要输出的配置,但是只能输出其中之一。
例子
每个输入整数对后跟一个或多个可能的输出。
6 2
\~~~/
\_/
10 4
\~~~~~/
\___/
24 8
\ /
\~~~~~~/
\ /
\__/
42 12 //either of the two output is correct
\ /
\ /
\~~~~~~~/
\ /
\ /
\_/
\ /
\~~~~~~~~~~~~~/
\___________/
90 68
\~~~~~~~~~~~~~~~~~~~~~/
\ /
\ /
\ /
\_____________/
102 42
\ /
\ /
\~~~~~~~~~~~~~~~~~/
\ /
\ /
\___________/
这是代码高尔夫球,因此最短的入场券获胜。