划船划船


26

每个人都可能熟悉以下歌曲,这是一场音乐比赛

这首歌。

背景

更少的人可能会想起尝试和几个朋友一起唱这首4人版本的歌,但失败了。抵消具有不同音调的歌曲的歌词被称为唱“回合”,这就是我们今天要使用静态输出来模拟的内容。这是某人实际表演作品的示例(链接到音频/视频,将有声音)

挑战

面临的挑战是要完全按照以下内容输出文本:

Row, row, row your boat,           |-----------------------------------|-----------------------------------|-----------------------------------
Gently down the stream.            |Row, row, row your boat,           |-----------------------------------|-----------------------------------
Merrily, merrily, merrily, merrily,|Gently down the stream.            |Row, row, row your boat,           |-----------------------------------
Life is but a dream.               |Merrily, merrily, merrily, merrily,|Gently down the stream.            |Row, row, row your boat,           
-----------------------------------|Life is but a dream.               |Merrily, merrily, merrily, merrily,|Gently down the stream.            
-----------------------------------|-----------------------------------|Life is but a dream.               |Merrily, merrily, merrily, merrily,
-----------------------------------|-----------------------------------|-----------------------------------|Life is but a dream.               

规则

  • 尾随空格是可以接受的,但不是必需的,这包括换行符。
  • 连字符和竖线是必需输出的一部分,是的。
  • 需要逗号,句号,大写字母以及与语法相关的所有句法元素。

这是,不使用标准漏洞的最低字节数代码就是赢家。


2
我只想说,我非常喜欢您的大量kolmogorov复杂性ascii艺术挑战!编写这样的解决方案,这个键盘如此真实的键盘都非常有趣。:)
DJMcMayhem

2
@DJMcMayhem自从找到这个网站以来,我在日常生活中随机遇到挑战,并为自己的想法留一个小记事本,我将继续努力使自己变得有趣!
Magic Octopus Urn

Answers:


12

05AB1E80 77字节

“¢ã,¢ã,¢ã€žžÄ,““èî„‹€€šæ.“"merrily, "4ר“‚쀈€³€…žâ.“'-35×Ð)€ª.B3FDÁ})øvy'|ý,

在线尝试!

工作正在进行中。


顺便说一句,我对字典中没有“ 05AB1E”的字典印象深刻。几乎无法有效地演唱05AB1E生日快乐。不过很酷的答案,是希望看到基于字典的05AB1E答案哈哈。同样,DJMcMayhem是正确的。
Magic Octopus Urn

等等,是什么ª?没关系,判例,精彩。
魔术章鱼缸

@carusocomputing:是的,我最近才注意到它的存在。过去曾多次需要它:P
Emigna'Apr 21'17

vy可以ʒ保存一个字节。
凯文·克鲁伊森

10

V139,128字节

iLife is but a dream ±µ |4amerrily, x7b~A|Gently down the stream.±² |3arow, X5b~Ayour boat,±± |3I³µ-|3AòÄó.û-}|ò5DÎ4f|C|

一线!(sortof:P)

在线尝试!

十六进制转储:

00000000: 694c 6966 6520 6973 2062 7574 2061 2064  iLife is but a d
00000010: 7265 616d 20b1 b520 7c1b 3461 6d65 7272  ream .. |.4amerr
00000020: 696c 792c 201b 7837 627e 417c 4765 6e74  ily, .x7b~A|Gent
00000030: 6c79 2064 6f77 6e20 7468 6520 7374 7265  ly down the stre
00000040: 616d 2eb1 b220 7c1b 3361 726f 772c 201b  am... |.3arow, .
00000050: 5835 627e 4179 6f75 7220 626f 6174 2cb1  X5b~Ayour boat,.
00000060: b120 7c1b 3349 b3b5 2d7c 1b33 4101 1bf2  . |.3I..-|.3A...
00000070: c4f3 2efb 2d7d 7cf2 3544 ce34 667c 437c  ....-}|.5D.4f|C|

我是否能获得准确降落的奖励积分2^7

这花了一段时间才能弄清楚。我希望我可以像键盘ASCII艺术字一样快速击球,但是我不确定。我们拭目以待。它们是非常相似的挑战(而且都很有趣:D)

本来我尝试过(180):

3irow, ch your boat,±± ||"rCLife is but a dream.±µ ||"lD4imerrily, r||"mCGently down the stream.±² ||"gC³µ-|B"dCR³D
GRDD
MGRD
LMGR
DLMG
DDLM
³DLÍR/r
ÍG/g
ÍM/m
ÍL/l
ÍD/d

在线尝试!

哪个插入:

RDDD
GRDD
MGRD
LMGR
DLMG
DDLM
DDDL

然后进行替换以将其扩展。但是,以风格进行构建要短得多(并且更有趣)


您获得0^(2^7)降落在2^7哈哈的奖励积分。有趣的首先想到的是180版本。
魔术章鱼缸

1
@carusocomputing Aww,为什么不给他(2 ^ 7)/ 0奖励积分?
马修·罗

6

批,292个 288 275字节

@set d=-------
@set "d=%d%%d%%d%%d%%d%^|
@set "m=M_ m_ m_ m_^|
@set "s=           ^|
@set "s=Life is but a dream.    %s%%m:_=errily,%Gently down the stream. %s%Row, row, row your boat,%s%%d%%d%%d%"
@for /l %%i in (1,1,6)do @call:c
:c
@echo %s:~111,146%
@set "s=%d%%s%

编辑:通过重写代码以使用我在Retina答案中使用的子字符串技巧的版本,节省了13个字节。方便地,我可以循环六次,然后进入循环正文的第七次迭代,这意味着输出|s 所需的引用不会太繁琐,但是^在选择子字符串时,我必须小心考虑s 。


6

Python 3中,252个 235 208 206 205字节

好吧好吧。这是一个比较无聊的答案:

w=' '*11
t=["Row, row, row your boat,"+w,"Gently down the stream. "+w,"Merrily,"+" merrily,"*3,"Life is but a dream.    "+w,*['-'*35]*3]
for a in zip(*[t[z:]+t[:z]for z in range(7,3,-1)]):print(*a,sep='|')

旧答案,252个字节:

无聊的答案,另一个Python答案更短,但是我想如果这种方法更短我会尝试。尽管节省了字节/字符串2-3的差异,但Python 3仍然存在,因为gzipbase64都在Python 2中更加糟糕。

from base64 import*
from gzip import*
print(decompress(b85decode('ABzY8Fgf~I0{;ujFV|5hf)Waq`K3h)N%@H-ItmC-qe~c2OAVKMYF<fBr9w)6d7eT^Myf(_Nl|KIuATz2dxGfaW-i~<qN2>4N*#q<oQxVex|z!-Gc8pivsfXiv_v6MAqB%CkU6w=GZ!&|OJj#}Q7chW$(>wu%p_Rd3;?AKH=M}>000')).decode())

原始长度的25%,令人印象深刻,但是您可以更加聪明,只压缩第一次迭代,在换行符上分割并执行4个移位。这可能会击败python的其他实现。要考虑的想法。我不是一对一的人,不知道是谁做的。
魔术章鱼缸

@carusocomputing正确。我真的只是很感兴趣,如何在如此高度冗余的固定输出任务上正常运行压缩。不过,我的回答却变短了,但没那么笨。
L3viathan '17

您还可以在压缩版本中进行编辑吗?我个人认为该方法也很有趣。即通过简单的gzip获得的字节数有多低。无论付出什么努力,它都必须使用Huffman或其他东西+1。
魔术八达通Ur

1
@carusocomputing我会在底部添加它。而且,我认为并不是使放气变得相对较大的deflate的Huffman部分,而是LZ部分。
L3viathan '17

1
@JonathanAllan确实,我很想念。已修复,丢失了一个字节。
L3viathan '17

5

PowerShell中224个 207 202字节

$a=' '*11;0..6|%{((0..4+4+4)[($_,($_+=6),--$_,--$_|%{$_%7})]|%{("Row, row, row your boat,$a","Gently down the stream.$a ","Merrily,$(' merrily,'*3)","Life is but a dream.$a    ",('-'*35))[$_]})-join'|'}

在线尝试! (如果屏幕不够宽,则输出将自动换行)

令人遗憾的是,这种数组生成方式很难看,但是节省了17个字节,所以...

0..6|%{((0..4+4+4)[($_,($_+=6),--$_,--$_|%{$_%7})]

我们从循环06。每次迭代,我们都将索引到array中(0,1,2,3,4,4,4)。索引是基于目前的数字,目前的数字+6,即-1,然后那个 -1。然后,将它们中的每一个馈入一个循环,在该循环中我们用进行模运算%7。例如,如果我们在0外部0..6循环中,则这些将是0,6,5,4,然后是each %7,所以0,6,5,4。该索引已索引到(0,1,2,3,4,4,4)数组中,因此输出为0,4,4,4。对于输入1我们得到1,7,6,5那么1,0,6,5其收益率1,0,4,4。等等。(如果有一个.clamp功能,事情会容易得多)

那些一次吐进一个循环|%{}。每次迭代时,我们都会在song-lyrics-array中的适当位置建立索引,并将该字符串保留在管道中。然后将这些字符串-join一起编辑|以格式化输出行。这些字符串留在管道上,输出是隐式的。

借助Value Ink,节省了一些字节。


考虑到您已经$a保存了11个空格,可以将第四行更改为以$a4个空格结尾,而不是$(' '*15)-3个字节,是吗?
价值墨水

4

的JavaScript(ES8),285 256 240 231 229 217 214 213 211 210字节

_=>"0444104421043210432144324443".replace(/./g,(x,y)=>a[x].padEnd(35)+`
|||`[++y&3],a=["Row, row, row your boat,","Gently down the stream.","Merrily,"+(m=" merrily,")+m+m,"Life is but a dream.","-".repeat(35)])

通过借用Arnauld的答案来节省一些字节


试试吧

f=

_=>"0444104421043210432144324443".replace(/./g,(x,y)=>a[x].padEnd(35)+`
|||`[++y&3],a=["Row, row, row your boat,","Gently down the stream.","Merrily,"+(m=" merrily,")+m+m,"Life is but a dream.","-".repeat(35)])

o.innerText=f()
<pre id=o>


1
'0444,1044,2104,3210,4321,4432,4443'.split,可.map节省10个字节。另外,padEnd它也不是ES6甚至ES7的一部分。
尼尔

糟糕,打算将其更新为ES8-感谢@Neil。并且感谢您的提示,但是我正在研究另一个解决方案,最终为我节省了12个字节。
Shaggy

4

PHP,191字节

for(;$n<7;$n++)for($m=0;$m<4;)echo $m?"|":"\n",str_pad($i=["Row, row, row your boat,","Gently down the stream.",M.($t="errily,")." m$t m$t m$t","Life is but a dream."][$n-$m++],35," -"[!$i]);

在线尝试!

展开式

for(;$n<7;$n++)
  for($m=0;$m<4;)
    echo $m?"|":"\n"
     ,str_pad($i=["Row, row, row your boat,","Gently down the stream."
       ,M.($t="errily,")." m$t m$t m$t","Life is but a dream."][$n-$m++]
       ,35," -"[!$i]);

您可以通过从回声中删除括号来保存字符(这不是功能)
Robbie Averill

我@RobbieAverill知道,但括号包括三元运营商,我可以删除它,只有它,我通过一个逗号代替点
约尔格Hülsermann

3

Python 2,199字节

w=' '
s=['-'*35]
t=['Row, row, row your boat,'+w*11,'Gently down the stream.'+w*12,'Merrily,'+' merrily,'*3,'Life is but a dream.'+w*15]
print'\n'.join(map('|'.join,zip(t+s*3,s+t+s+s,s+s+t+s,s*3+t)))

在线尝试!


感谢@mathjunkie节省了14个字节


'Merrily, merrily, merrily, merrily,'可能是('merrily, '*4).capitalize()对的吗?还是不是Python?
魔术章

2
甚至更短,'Merrily,'+' merrily,'*3
数学迷

2

CJam128个 122字节

"Row, row, row your boat,""gently down the stream."'M" merrily,"4*2>+"Life is but a dream."'-35*__]{35Se]}%a4*4,.m>z'|f*N*

在线尝试!

说明

"Row, row, row your boat,"  e# Push this string.
"gently down the stream."   e# Push this string.
'M                          e# Push the character 'M'.
" merrily,"4*               e# Push the string " merrily, merrily, merrily, merrily,".
2>+                         e# Remove the first two letters of it, and append it to 'M',
                            e#   fixing the capitalization.
"Life is but a dream."      e# Push this string.
'-35*__                     e# Push a string containing 35 hyphens and make two copies of it.
]                           e# Collect all these strings in an array.
{35Se]}%                    e# Pad each of them to length 35 by adding spaces to the right.
a4*                         e# Repeat the array 4 times.
4,                          e# The range [0 1 2 3].
.m>                         e# Rotate each subarray of strings rightward by the corresponding
                            e#   number in the range.
z                           e# Transpose the array.
'|f*                        e# Join the strings on each row with '|' characters.
N*                          e# Join the rows together with newlines.

2

SOGL,83 字节

┌׀0ρMVxDrž|⁷ΨB≈π93|↑D~Νķ‰¤t╤▼ΣΗ⁶⅔¾№⁷Ζ÷│²╥Ν9°‘-”)0ΔH«‘4*jŗ"ΣΨ¬¹‘4*;+7{’⁄{»}⁽:’∞n1wpX

第一部分┌׀0ρMVxDrž|⁷ΨB≈π93|↑D~Νķ‰¤t╤▼ΣΗ⁶⅔¾№⁷Ζ÷│²╥Ν9°‘是压缩字符串,导致

`life is but a dream.               |-|gently down the stream.            |row, row, row your boat,           |`

这些是颠倒的行(因为这是逐行打印的),并且剪切了“愉快”的部分以在程序中进行替换。
该程序的其余部分:

...‘                                        Push the compressed string
      )0ΔH«‘                                push "merrily, "
            4*                              repeat it 4 times
              j                             take the last letter off
    -”         ŗ                            replace "-" with the merrily line
                "ΣΨ¬¹‘                      push 35 dashes with an appending "|"
                      4*                    repeat it 4 times
                        ;+                  add inverted ("---|---..."+"Life is but a dream  ...")
                                            The resulting string of above is "-----------------------------------|-----------------------------------|-----------------------------------|-----------------------------------|life is but a dream.               |merrily, merrily, merrily, merrily,|gently down the stream.            |row, row, row your boat,           |"
                          7{                repeat 7 times
                            ’⁄{»}            rotate right 35 times
                                 ⁽           uppercase the 1st letter
                                  :          duplicate
                                   ’∞n       split into parts of length 135
                                      1w     get the 1st one
                                        p    output that
                                         X   delete the splat array

2

///,200字节

/_/     //&/errily,//*/ m&//+/-------//@/Row, row, row your boat, __//#/Gently down the stream.  __//$/M&***//%/Life is but a dream.___//~/+++++/@|~|~|~
#|@|~|~
$|#|@|~
%|$|#|@
~|%|$|#
~|~|%|$
~|~|~|%

在线尝试!

很简单,使用常见事件代替。


2

PHP,179个字节:

for($m="errily,";$i<28;)echo str_pad($s=["Row, row, row your boat,","Gently down the stream.","M$m m$m m$m m$m","Life is but a dream."][($i>>2)-$i%4],35," -"[!$s]),"
|||"[++$i%4];

不打高尔夫球

for($i=0;$i<28;$i++)
{
    $x=$i%4;
    $y=$i>>2;

    $s=["Row, row, row your boat,",
        "Gently down the stream.",
        M.($m="errily,")." m$m m$m m$m",
        "Life is but a dream."
    ][$y-$x];

    $pad_string = $s ? " ":"-";
    $postfix = $x<3 ? "|" : "\n";
    echo str_pad($s,35,$pad_string),$postfix;
}

2

的JavaScript(ECMAScript的2017),191个 187 182字节

感谢Shaggy节省了3个字节

f=(i=27,s=['Life is but a dream.','Merrily,'+(m=' merrily,')+m+m,'Gently down the stream.','Row, row, row your boat,'][(i>>2)-i%4]||'')=>i?s.padEnd(35,' -'[+!s])+`
|||`[i&3]+f(i-1):s

o.innerHTML = f();
<pre id=o style="font-size:10px"></pre>


我认为'Merrily,'+' merrily,'.repeat(3)可以节省一个字节。
尼尔

哦,我忘了提到padEndES7中没有的内容,更不用说ES6了。
尼尔

1
M${s='errily, '}m${s}m${s}m而不是M${s='errily,'} m${s} m${s} m节省2个字节
路加福音

1
您可以使用保存3个字节"Merrily,"+(s=" merrily,")+s+s
毛茸茸的

1
@Shaggy啊,是的。那似乎是最好的选择。谢谢!
Arnauld

2

Microsoft Sql Server,421字节

with v as(select left(s+space(35),35)s,n from(values('Row, row, row your boat,',1),('Gently down the stream.',2),('Merrily, merrily, merrily, merrily,',3),('Life is but a dream.',4))t(s,n))select isnull(v.s,s.s)+'|'+isnull(b.s,s.s)+'|'+isnull(c.s,s.s)+'|'+isnull(d.s,s.s)from v full join v b on v.n=b.n+1 full join v c on b.n=c.n+1 full join v d on c.n=d.n+1 cross apply(select replicate('-',35)s)s order by isnull(v.n,9)

在线检查


我喜欢它。数据库是我的信息!
Zahiro Mor

2

C(GCC),231 230字节

-1个字节,感谢ceilingcat!

#define m"errily, "
char s[7][35]={"Life is but a dream.","M"m"m"m"m"m"m"m,"Gently down the stream.","Row, row, row your boat,"};f(l,c){memset(s[4],45,'k');for(l=7;l--;)for(c=0;c<4;)printf("%-35.35s%c",s[(4+l+c++)%7],"|||\n"[c]);}

非常简单。首先,它构建一个7行的字符串数组,并通过一个宏部分分解出“快乐”部分,然后用填充虚线行memset。然后,以足够的偏移量和分隔符打印行。

在线尝试!


@ceilingcat谢谢!
昆汀

1

MATLAB,280字节

a='errily,';
z={'Row, row, row your boat,';'Gently down the stream.';['M',a,' m',a,' m',a,' m',a];'Life is but a dream.'};
z{5}(1:35)='-';
y=5*ones(7,4);
for j=1:4;z{j}(end+1:35)=' ';y(j:j+3,j)=(1:4)';end
x=z(y);
for j=1:7;fprintf('%s|%s|%s|%s\n',x{j,1},x{j,2},x{j,3},x{j,4});end

单元数组索引非常昂贵,这似乎是丢弃某些字节(如果可能)的最简单位置。


欢迎光临本站!
DJMcMayhem

1

视网膜153150字节


<-|>Life is but a dream.15|M!< m!>|Gently down the stream.12|Row, row, row your boat,11<|->
<(.*?)>
$1$1$1
!
errily,
-
35$*-
\d+
$* 
r!&`.{71}\|.{71}

在线尝试!

我尝试了任意游程长度编码,但$1$*$2没有做到我想要的,重复字符串被证明太棘手。编辑:通过编码保存2个errily,字节,通过删除不必要的保存1个字节^


1

Python 2,225字节

w=[["-"*35]*7for _ in[0]*4]
for i in [0]*4:w[i][i:i+4]=[a.ljust(35)for a in["Row, row, row your boat,","Gently down the stream.","Merrily,"+" merrily,"*3,"Life is but a dream."]]
print "\n".join(["|".join(i)for i in zip(*w)])

在线尝试!


1

Perl 5,215个字节

$m='merrily,';$s=' 'x11;$l='-'x35;
@t=@s=("Row, row, row your boat,$s","Gently down the stream. $s",
       "\u$m $m $m $m","Life is but a dream.    $s",$l,$l,$l);
map{$i--;map$t[$_].="|".$s[$i++%7],0..6}1..3;print"$_\n"for@t

在线尝试!


1

迅速416个 406 405 380 372 307字节

var f=String.init(repeating:count:);_={[[0,4,4,4],[1,0,4,4],[2,1,0,4],[3,2,1,0],[4,3,2,1],[4,4,3,2],[4,4,4,3]].forEach{print($0.map{["Row, row, row your boat,"+f(" ",11),"Gently down the stream."+f(" ",12),"Merrily,"+f(" merrily,",3),"Life is but a dream."+f(" ",15),f("-",35)][$0]}.joined(separator:"|"))}}

您可以在这里尝试。

感谢@先生。Xcoder为我节省了65个字节!


1
很高兴看到一个迅速的答案!
硫磺

1
您可以通过将以下声明替换为f以下内容来使其更短:var f=String.init(repeating:count:),以节省大量字节:30
Xcoder先生17年

1
另外,在沙箱中print(o()),您不应调用,o()因为其中包含一条print语句,该调用才()在输出的末尾提供
Xcoder先生17年

1
另外,删除不必要的空格。它将节省大量字节。我将评论改进版本。
Xcoder先生17年

1
是一个改进的版本,309字节。我相信这会短63字节,并且可以打高尔夫球
Xcoder先生17年

1

T-SQL,296277276字节

PRINT REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE('1|0|0|0
2|1|0|0
3|2|1|0
4|3|2|1
0|4|3|2
0|0|4|3
0|0|0|4',0,REPLICATE('-',35))
        ,1,'Row, row, row your boat,6')
        ,2,'Gently down the stream. 6')
        ,3,'M5 m5 m5 m5')
        ,4,'Life is but a dream.    6')
        ,5,'errily,')
        ,6,SPACE(11))

开头的换行符是原始字符串的一部分,结尾处的换行符仅用于显示目的,不计入字节总数。

很大程度上受到Conrade SparklePony的回答的启发。与Andrei Odegov的SQL回答不同的技术。

相当简单的多重替换,但是有一些有助于节省字节的事情:

  • SQL允许在原始字符串中换行
  • 用数字代替字符使我消除了很多单引号
  • 嵌套替换(5和6),为我节省了更多的字节(感谢@ t-clausen.dk)

如果只有我能REPLACE所有的REPLACEs的东西短。嗯...


1
如果您使用自己的方法替换空间11,12,15,则可以保存1个字节
t-clausen.dk,

1

Japt -R99 95 94 92 90 89 87字节

R³i`Life  ¿t a Ým.
M{34î`Îk, m`}
Gt§ ܵ e Ðpam.
Row, w, w yr ¾,`ú)·ú-
£éY Ťq|

试试吧

R³i`L...{34î`...`}...,`ú)·ú-
R                                :Newline
 ³                               :Repeat 3 times
  i                              :Prepend
   `                             :  Decompress
    L...                         :    "Life is but a dream.\nM"
        {                        :    Interpolate
         34î                     :      Repeat & slice to length 34
            `...`                :        The compressed string "errily, m"
                 }               :    End interpolation
                  ...,           :    "\nGently down the stream.\nRow, row, row your boat,"
                      `          :  End decompression
                       ú         :  Right pad each line with spaces to the length of the longest
                        )        :End prepend
                         ·       :Split on newlines
                          ú-     :Right pad each element with "-" to the length of the longest
£éY Ťq|                         :Assign the above to U
£                                :Map each element at 0-based index Y
 éY                              :  Rotate U right Y times
    Å                            :  Slice off the first element
     ¤                           :  Slice off the first two elements
      q|                         :  Join with "|"
                                 :Implicit output, joined with newlines

0

Ruby,162个字节

7.times{|i|puts (~i..~i+3).map{|j|[*[?-*35]*3,"Life is but a dream.",?M+['errily,']*4*" m","Gently down the stream.","Row, row, row your boat,"][j].ljust(35)}*?|}

0

Java中,295个字节/ 272 259字节

每4列换行(295b)

void r(){String m=" merrily,",t="-------",s="     ",e=t+t+t+t+t;String[]v={"Gently down the stream.  "+s+s, "Merrily,"+m+m+m, "Life is but a dream."+s+s+s, e, e, e, "Row, row, row your boat, "+s+s};for(int i=0;i<7;i++){for(int j=6+i;j>2+i;j--)System.out.print(v[j%7]+'|');System.out.println();}}

在线尝试

没有换行版本(259b):

void r(){String m=" merrily,",t="-------",s="     ",e=t+t+t+t+t;String[]v={"Gently down the stream.  "+s+s, "Merrily,"+m+m+m, "Life is but a dream."+s+s+s, e, e, e, "Row, row, row your boat, "+s+s};for(int i=0;i<28;i++)System.out.print(v[(6-i%4+i/4)%7]+'|');}
  • 压缩2为循环成1

在线尝试


0

Japt158个 157字节

='|L=`Row, žw, žw yŒr ¾…,`+Sp11 +UV=`Gt§ ܵ e Ðpam.`+S³²²+UW=`M€Îk,`+` ´rÎk,`³+UJ=W+VX=`Life ‰ ¿t a Ý„m.`+Sp15 +UZ='-p35 +U[LZ³RVLZ²RJLZRXJLRZXJRZ²XWRZ³X]q

在线尝试!



0

Perl 5,163字节

say join'|',(('-'x26)x3,"Life is but a dream".$"x7,ucfirst(join$",("merrily,")x3),"Gently down the stream    ",ucfirst "row, "x3 ."your boat  ")[-$_..3-$_]for 1..7

在线尝试!


0

符文附魔,292字节

B͍"-"'#*"|"3s
"Row, row, row your boat,"b" "S*q"|"3sB͍>01B10B3*1-akr@>12B01B10B2*1-akr@>13B12B01B10B1-akr@>14B13B12B01B1-akr@>10B3*14B1-r0[10B2*14B13B1-akr0[10B14B13B12B1-akr]]@
B͍"Gently down the stream."c" "S*q"|"3s
B͍"Merrily,"3" merrily,"S*q"|"3s
B͍"Life is but a dream."f" "S*q"|"3s

在线尝试!

我通常不会进行挑战,但是布局是我可以应对的布局。符文没有很好的方法来压缩任意字符串,因此我们要做的只是重复的部分。

说明:

略微解压缩:

B͍"-"'#*"|"3s
B͍"Row, row, row your boat,"b" "S*q"|"3s
B͍"Gently down the stream."c" "S*q"|"3s
B͍"Merrily,"3" merrily,"S*q"|"3s
B͍"Life is but a dream."f" "S*q"|"3s
>11B10B3*1-akr@
>12B11B10B2*1-akr@
>13B12B11B10B1-akr@
>14B13B12B11B1-akr@
>10B3*14B1-r0[10B2*14B13B1-akr0[10B14B13B12B1-akr]]@

前5行用作构建歌曲的每个部分的功能(其中,第一行-使用的十进制值生成35 的间隔符,#以节省2个字节3X5+)。return指令位于该行的开头,以确保所有输入函数的IP也会在相同的循环数后离开该函数,以避免IP合并(导致输出缺少行),因为程序是矩形且为空单元格是隐式的。

接下来的四行负责打印输出的前四行

然后,第五行打印输出的最后3行。由于所有三行都必须以至少一个节间隔符开头,因此使用3个单独的IP是不可行的(因为它们需要延迟才能避免合并)。 >y@,和一个换行成本多个字节(4)比0[...](3个字节),其中...是任意的指令(即,输出的另一条线)。

相反,替换>@使用单个IP需要更多字节。

最后,将所有五个入口点行合并到第二行可节省5个字节的换行符。我们只需要确保ranch-return指令首先移至其行的末尾,即可保留该函数的功能。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.