描述
如果将三部分中的每一部分中的数字总和为相同的数字,我们认为该整数具有至少三位数的三重平衡。我们按如下方式拆分数字:
abcdefghi - Standard case: the number of digits is divisable through 3:
abc def ghi
abcdefgh - Number % 3 == 2: The outer groups are both assigned another digit
abc de fgh (the inner group will have one digit less than both outer groups)
abcdefghij - Number % 3 == 1: The inner group is assigned the extra digit
abc defg hij (the inner group will have one digit more than the outer groups)
挑战
您的任务是编写一个程序,给定一个至少包含3个数字的整数,该程序确定给定的数字是否是三重平衡的,并根据其结果输出真值或假值。
测试用例
333 -> True
343 -> False
3123 -> True
34725 -> True
456456 -> False
123222321 -> True
这是代码错误,因此存在标准漏洞,并且可能以字节为单位的最短答案胜出!
1
据我了解,如果可以将其平均分配,则应该这样做。
—
totallyhuman
@ Mr.Xcoder将其分为三部分(按照@MagicOctopusUnr的评论,它仍然不起作用:
—
Stephen
when split in three parts,
哎呀!对于测试用例的困惑,我感到很抱歉,显然我头脑有些扭曲。现在,他们已得到纠正,希望您投票重新提出我的挑战。
—
racer290
默认情况下,允许将输入作为字符串。可以将其视为数字数组吗?
—
路易斯·门多