挑战
给定两个字符串,每个字符串的长度最多为30个,由可打印的ASCII字符(代码)组成,以最小的代码字节数将它们放在天平上!这包括以下步骤:
- 计算并比较琴弦的重量
- 选择适当倾斜的ASCII艺术比例
- 将两根弦放在秤上
字符串可以作为数组,两个参数或任何其他合理的方法传递。
的一个字符串的重量被定义为的该字符串的字符,其中权重的总和:
- 空格的权重为0(
)
- 小写字母的权重为2(
abcdefghijklmnopqrstuvwxyz
) - 大写字母的权重为4(
ABCDEFGHIJKLMNOPQRSTUVWXYZ
) - 所有其他符号的权重为3(
!"#$%&'()*+,-./0123456789:;<=>?@[\]^_`{|}~
)
秤看起来像这样:
。_ | _- * / \ |-* / \ _- * | / \ _- * | / \ / \ | * ------ * / \ | / \ | / \ | * ------ * | ______ | ______
_。 / \ * -_ | / \ *-| / \ | * -_ / \ | * -_ * ------ * | / \ | / \ | / \ | / \ | * ------ * ______ | ______
。 | ______ | ______ / \ | / \ / \ | / \ / \ | / \ / \ | / \ * ------ * | * ------ * | | ______ | ______
如果第一个字符串较重,请使用第一个图形作为输出的基础;如果第二根弦较重,则使用第二根图纸;如果琴弦的重量相等,请使用第三个。允许尾随空格。
我将使用第三幅图的一部分作为以下所有示例的基础。
第一个字符串应该放在左声像上,第二个字符串应该在右声像上。
将字符串的非空格字符放在破折号上方的6x5区域内,将其放在平底锅上,如此处#
s所示(您可能最终会覆盖部分天平的秤-很好):
###### _ ###### ###### ###### / ###### \ * ------ *
所有这些字符都应“结算”,即。-
在字符串的一个字符或另一个字符上方:
错误错误正确 ____ ____ ____ F /\ /\ /\ l \ / \ / \ / \ / hov \ / s \ / oating \ / ering \ / ettled \ * ------ * * ------ * * ------ *
此外,整个堆栈应尽可能平整,这意味着六个1宽的列中,最高的高度和最短的高度之差不得超过1:
错误错误正确正确 [最高:5] [最高:4] [最高:5] [最高:2] [最短:0] [最短:2] [最短:4] [最短:2] 5__5_ ____ 5_5__ ____ 45445&/ \ 445454 / \ 45445 $%&$ @ 445454 / \ / 45445&%@%$&445454%&$ @%& / 45445 \ / && $ @ $&%\ / 445454 \ / $ @ $%$$ \ * ------ * * ------ * * ------ * * ------ *
字符的确切顺序/排列无关紧要。以下是字符串“称重您的话!”的所有有效安排:
____ ____ ____ ____ / \ / \ / \ / \ ds!\ /欠费\ u! Ourwor Wihuos yoiwgr eghioo / Weighy \ / egyrr!\ / Wrhd!s \ / rrsuwy \ * ------ * * ------ * * ------ * * ------ *
测试用例
输入:“ CODE GOLF”,“编码挑战” 权重:32,32 示例输出: 。 | ______ | ______ / \ | / \ / \ | 恩格斯 / OO \ | 沙勒 / CFGLED \ | /编码\ * ------ * | * ------ * | | ______ | ______
输入:“”,“ $” 权重:0,3 示例输出: _。 / \ * -_ | / \ *-| / \ | * -_ / \ | * -_ * ------ * | / \ | / \ | / \ | / $ \ | * ------ * ______ | ______
输入:“您知道他们说什么!”,“ thes'always_a_relevant_xkcd” 体重:75,65 示例输出: 。tr_a_s | _hekx_y |-* elcdta _- * | 复仇 _- * | / e's_al \ T / \ | * ------ * AUYOHY | A!HWYK | / OTSMEW \ | * ------ * | ______ | ______
+1
。首先:如果空间不“称量”任何东西并且不包含在艺术品中,那么为什么还要包含它们呢?首先过滤掉它们只是不必要的开销。其次:这对我来说就像是“二合一” /变色龙的挑战-挑战1:确定哪个字符串“更重”,挑战2:生成一些ASCII艺术。