断弦金字塔
给定字符串n,创建一个字符串金字塔,相对于当前行,该金字塔分为几部分。 第一行包含未修改的字符串。 第二行包含被管道分成两半的字符串。 第三行将其分隔三分之二... 等等。每个子字符串的长度,其中l是字符串n的长度等于 地板(l / n) 剩下的字符将放在其自己的子字符串中。使用的最后一行是第一行,其中子字符串的长度为2。 测试用例: 输入:您好,世界。 输出: Hello, world. Hello,| world|. Hell|o, w|orld|. Hel|lo,| wo|rld|. He|ll|o,| w|or|ld|. 输入:abcdefghij 输出: abcdefghij abcde|fghij abc|def|ghi|j ab|cd|ef|gh|ij 输入:01234567890abcdef 输出: 01234567890abcdef 01234567|890abcde|f 01234|56789|0abcd|ef 0123|4567|890a|bcde|f 012|345|678|90a|bcd|ef 01|23|45|67|89|0a|bc|de|f 额外规则: 您可以编写完整的程序或函数,而使用较少的代码。 输入内容的长度至少应为4个字符。 如果您的语言支持,则必须使用换行符。如果不可能,将换行符替换为: 输入将始终是可打印的ASCII。 如果您的程序解决了P对NP,请减负100%。 排行榜: 显示代码段 var QUESTION_ID=104297,OVERRIDE_USER=62384;function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"http://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function …