海底有个洞


48

在尝试(并失败)说服我的小儿子吃晚餐时,我尝试唱歌。在这首歌的中途,我意识到公式结构可能很适合打高尔夫球!

任务是编写一个不接受任何输入并产生以下文本的程序或函数:

There's a hole in the bottom of the sea
There's a hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a log in the hole in the bottom of the sea
There's a log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a bump on the log in the hole in the bottom of the sea
There's a bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a frog on the bump on the log in the hole in the bottom of the sea
There's a frog on the bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a flea on the fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a flea on the fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

There's a smile on the flea on the fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a smile on the flea on the fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea
There's a hole, there's a hole
There's a hole in the bottom of the sea

挑战规则:

  • 文本可以打印或作为函数输出返回
  • 每节经单行
  • 只要不改变布局,尾随空格就可以(这样就不会出现空格或单词之间有多余空格)
  • 尾随换行符也可以。
  • 没有领先的换行符。
  • 欢迎使用所有语言,这是,因此每种语言的最短答案以字节为单位!

6
类似于《有一位老太太》(其他类似的挑战,例如,已作为重复项关闭,尽管我认为它们不一定如此。)
乔纳森·艾伦

6
哦,ro,响尾蛇的沼泽,沼泽在山谷-o中。
fəˈnɛtɪk

4
为了进行比较(尽管不是编程语言),gzip -5将其压缩为186个字节(bzip2而且xz看起来更糟)。
Daniel Schepler

2
恭喜,来自另一个开发人员的父母:)
AJFaraday

1
我想把这首歌改编成05AB1E ...“哦,五只蜜蜂一个ee洞!”
魔术章鱼缸

Answers:


23

SOGL103 94 93 字节

Ψ ~Δ№Q‘离vζh‛←&M⁶╥7[P≈╔6≡⁸(φΔ\⅔Σ‚>≡ā⁷⁽○¹‘Ξ⁵K4s³‘⁽Bθ2n{@∑" the ”+Κ:bΚē‽:C}TPb"n@²‘+Tō, upcPøP

在这里尝试!

...‘                 push "bottom of the sea" - kept for the loop, here for 
    ...‘             push "hole in log in bump on frog on wart on hair on fly on flea on smile on"
        ...‘         push "there's a "
            ⁽        uppercase the 1st letter of that
             B       save "There's a " in B
              θ      split the long data string on spaces
               2n    split in arrays of length 2

{                     for each of those:
 @∑                   join the current array with spaces - e.g. "hole in"
   " the ”+           append " the " to it
           Κ          prepend that to "bottom of the sea" (or whatever it is now)
            :         create a copy
             bΚ       prepend B to it - finishes current line
               ē‽:C}  if (E++), save a copy of that in C (for the last line)

TP                   print the current line twice
  b"...‘+            B + "hole" - "There's a hole"
         T           output that, keeping item
          ō,         output ", "
             up      print the kept item lowercased
               cP    print the contents of C
                 øP  print an empty line

14
但是....但是如何?
SomeShinyObject

8
难以置信。甚至
奥斯汀·伯克

1
HNQ再次罢工!:\
毛茸茸的

4
您介意添加解释吗?好奇地看它如何工作。
凯文·克鲁伊森

@KevinCruijssen添加了
dzaima

19

Stax90 87 75 字节

¥▌▼h4█☻■Ω1gçΔ¶Zjµ│☺X▄)/╞▄╒)¥jêLqα╧ñu┌⌂½╧ûⁿ↕O◘╔╪kl<æàbπïfuσ♪╫qΓ╪ûQ├╘Te♥Æó♣ƒE

运行并调试

解压,解压并评论,它看起来像这样。

`;$w]i"50h1&V~OP>F$`            compressed literal for "There's a hole in the bottom of the sea"
X                               store in register X without popping
zG                              push an empty string and jump to the target (trailing }) 
`hfUiVx}.|j~vG12])Bxk?v zF`j    split "log bump frog wart hair fly flea smile" into array of words
F                               for each word, execute the following
  i. o. i?                      (i ? " o" : " i") where i is the 0-based iteration index
  +                             concatenate to the word
  `_o9!`+                       concatenate "n the "
  G                             jump to target below, resume next foreach iteration when finished
}                               this is the target of `G`, execution resumes when finished
  As|@                          insert substring at position 10
  QQ                            peek and print with newlines twice
  x14(                          trim string to leftmost 14 characters
  q                             peek and print without newlines
  ., p                          print ", " without newline
  vP                            lowercase 14 characters and print with newline
  xP                            push value of register X, then print with newline
  zP                            print blank line

运行这个


2
您介意添加解释吗?好奇地看它如何工作。
凯文·克鲁伊森

我会的,但我仍然感觉完全不同的方法会做得更好。成功或失败之后,我将解释剩下的一切。
递归

1
@KevinCruijssen:我感觉有更好的方法。果然,我完全重写了它,并节省了另外12个字节的膨胀。我也添加了一些解释。
递归


13

Python 2中202个 190 187 185 183 182 181字节

s="bottom of the sea\n"
a="There's a "
for w in'hole log bump frog wart hair fly flea smile'.split():s=w+" %sn the "%'io'['g'in s]+s;print(a+s)*2+a+"hole, t%shole\n"%a[1:]+a+s[-30:]

在线尝试!

旧的替代方法'io'['g'in s](13字节):

  • 14: 'oi'[s[5]<'n']
  • 15: ,'io'[len(s)>30]'ioo'[len(s)%3]'ooi'[len(s)%4]'io'[w[1]=='o']

已保存:

  • -1字节,感谢乔纳森·艾伦
  • -1字节,感谢Rod
  • -1字节,感谢Outgolfer的Erik

"hole, t%shole\n"%a[1:]保存一个字节
乔纳森·艾伦

您可以删除zip 来保存一个字节
Rod

@JonathanAllan谢谢:)
TF

@Rod谢谢,:-)
TF

'oi'[s[5]<'n']也将是一个旧的替代方法:具有'io'['g'in s]
暴民埃里克

13

C(GCC) 261个 246 236字节

#define X" on the "
char*a="smile"X"flea"X"fly"X"hair"X"wart"X"frog"X"bump"X"log in the hole in the bottom of the sea\n";f(i){for(i=0;i<9;)printf("T%s%sT%1$s%2$sT%1$shole, t%1$shole\nT%1$s%3$s\n","here's a ",a+"_TH<0$\31\r"[i++],a+95);}

-15个字节,感谢Daniel Schepler
-10个字节,感谢ceilingcat

在线尝试!


2
你能写,*b="_TH<0$\31\r"吗?
Daniel Schepler

是否会保存任何字节以在中定义“”?
OldBunny2800

@ OldBunny2800不,它会更长!在这种情况下,您至少需要发生6次才能有效...
Giacomo Garabello

12

05AB1E103 100 99 97 96 93 92字节

多亏了Kevin Cruijssen,节省了一个字节

“¥ÊˆŽ bumpÑå‡îtíÁ¤†îÌea¹²“#v’T€Î's a ’s„oiN2‹èy“ÿ ÿn€€ ÿ“©“—耂€€í™“JDN_iDU}X14£Dl‚„, ýXõ»,®

在线尝试!

说明

“¥ÊˆŽ bumpÑå‡îtíÁ¤†îÌea¹²“#v在列表上开始循环["hole", "log", "bump", "frog", "wart", "hair", "fly", "flea", "smile"]。使用05AB1E字典压缩单词。

我们每次都做:

’T€Î's a ’    # push the string "There's a "
s             # move the string from the previous iteration to the top of the stack
              # will be an empty string the first iteration since there is no input
„oiN2‹è       # push "i" for the first 2 iterations and "o" otherwise
y             # push the current word
“ÿ ÿn€€ ÿ“    # use interpolacing to create the meat of the current iteration string
              # meaning "hole in the ", "log in the hole in the " and so on
©             # store a copy in the register for the next iteration
“—耂€€í™“    # push the string "bottom of the sea"
JD            # join the whole line together and duplicate it
N_iDU}        # if this is the first iteration, store a copy of the line in X
X14£          # push the first 14 chars of X, which is "There's a hole"
Dl            # make a lower-case copy
‚„, ý         # join the original with the lowercase copy on ", ", forming line 3
X             # push X which is line 4
õ             # push and empty string, to create the line break between sections
»,            # join the whole section on newlines and print
®             # push the register for the next iteration

2
您可以删除开头õ,因为显然在使用swap且堆栈中没有任何内容时,默认情况下它会输出一个空字符串。我找不到别的东西去打高尔夫球。很好的答案!
凯文·克鲁伊森

1
@KevinCruijssen:哦,是的,我不认为这是通常输入的内容。谢谢:)
艾米娜

11

PowerShell中194个 188 185 180 174字节

$z=$a="in the bottom of the sea"
$b="here's a"
$h="$b hole"
echo hole log bump frog wart hair fly flea smile|%{,"T$b $_ $a"*2
$a='oi'[!$j++]+"n the $_ $a"
"T$h, t$h
T$h $z
"}

在线尝试!

似乎无法完全抓住Python ...

基本上,设置了几个常见字符串$h$a$z,和$b,然后经过一个循环遍历每个项目的(holelog,... fleasmile),每次迭代输出相应的诗句。!$j++中间有一点逻辑来说明发生的in/ on开关。否则,所有字符串都将留在管道中,并且默认值Write-Output免费为我们提供换行符。

-6个字节感谢Arnauld。
-3个字节,感谢mazzy。
-5个字节感谢Veskah。
-6个字节,感谢mazzy。


-3个字节:) 在线尝试!
mazzy

@mazzy这是一个聪明的把戏。我需要牢记这一点,因为我花了-split很多时间来说单词。
AdmBorkBork




9

的JavaScript(ES6), 201个194 189 188  187字节

@Shaggy节省了1个字节

_=>`14log4bump5frog5wart5hair5fly5flea5smile5`.replace(/.+?\d/g,w=>`T0${(p=w+3+p)+p}1, t01
T01432
`.replace(/\d/g,n=>`here's a |hole|bottom of the sea
|n the | i| o`.split`|`[n]),p=`2T0`)

在线尝试!


JavaScript(ES6),235个字节

只需RegPack'ed即可

_=>[..."Z[]^_$cdjkqvxz{}~"].reduce((p,c)=>(l=p.split(c)).join(l.pop()),`Tj{{}qq}$$}~~}dd}__}xx}cc}[[v~ frogz$}v
Z{kZz on^x flyz_v], tj]Zkq log in^{k] in^ bottom of^ seajhere's ad wartz~c fleazx$ bumpzq_ hairzd^ the] hole[ smilezcZ
Tj`)

在线尝试!



7

Japt -Rx126个 116 113 112 111 109 107字节

事实证明,在手机上按下酒杯时打高尔夫球要挑战弦压挑战是非常困难的-谁想过?

`T's»dâ ÈÞ­omºfdÈ a`rdS
tE8
¯E
`logn¿mpnfgnØnirnf§nf¤Úè`qÍË2ÆiAV¯E©8 iF¯E ÔqVri'oÃpW+v iSi,)UPÃc

测试一下

                                              :The first 3 lines get assigned to variables U, V & W, respectively
`...`                                         :The compressed string "There'sdadholedindthedbottomdofdthedsea"
     rdS                                      :Replace all "d"s with spaces
tE8                                           :Substring of U from 0-based index 14 (E), of length 8 (="  in the ")
¯E                                            :Slice U to index 14 (="There's a hole")
`...`                                         :The compressed string "lognbumpnfrognwartnhairnflynfleasmilent"
     qÍ                                       :Split on "n" (note that the last element is irrelevant)
       Ë                                      :Map each element at 0-based index E in array F
        2Æ                                    :  Map the range [0,2)
          iA                                  :    Insert the following in U at index 10
            V¯                                :      V sliced to index
              E©8                             :        Logical AND of E and 8 (=0 on first iteration, 8 on all others)
                  i                           :      Prepend
                   F¯E                        :        Slice F to index E
                       Ô                      :        Reverse
                        q                     :        Join with
                         Vri'o                :          Replace "i" with "o" in V
                              Ã               :  End map
                               p              :  Push
                                W+            :    W appended with
                                  v           :      W lowercased
                                    iSi,      :      Prepended with a space prepended with a comma
                                        )     :    End append
                                         UP   :    U and an empty string
                                           Ã  :End map
                                            c :Flatten
                                              :Implicitly join with newlines, trim & output

7

XML,719个 673 603 514 493 486字节

<!DOCTYPE a[<!ENTITY T "There's a"><!ENTITY O " on the"><!ENTITY a " hole in the bottom of the sea
"><!ENTITY b " log in the&a;"><!ENTITY c " bump&O;&b;"><!ENTITY d " frog&O;&c;"><!ENTITY e " wart&O;&d;"><!ENTITY f " hair&O;&e;"><!ENTITY g " fly&O;&f;"><!ENTITY i " flea&O;&g;"><!ENTITY z "&T; hole, there's a hole
&T;&a;
">]><a>&T;&a;&T;&a;&z;&T;&b;&T;&b;&z;&T;&c;&T;&c;&z;&T;&d;&T;&d;&z;&T;&e;&T;&e;&z;&T;&f;&T;&f;&z;&T;&g;&T;&g;&z;&T;&i;&T;&i;&z;&T; smile&O;&i;&T; smile&O;&i;&z;</a>

您可以使用来“执行”它xmlstarlet sel -t -m '//a' -v . -n <xml_file_here>

如果XML不那么冗长,这将容易得多,但是从好的方面来说,这小于原始文本的25%。


5

视网膜0.8.2,150字节


THsmile oNflea oNfly oNhair oNwart oNfrog oNbump oNlog iNE
N
$&$'¶TH
O^$`

.+
$&¶$&¶THW, tHW¶THE¶
H
here's a 
E
W iNbottom of the sea
W
hole
N
n the 

在线尝试!说明:


THsmile oNflea oNfly oNhair oNwart oNfrog oNbump oNlog iNE

插入最后一节经文。

N
$&$'¶TH

计算所有经文。

O^$`

按正确的顺序排列经文。

.+
$&¶$&¶THW, tHW¶THE¶

完成每节经文并添加合唱。

H
here's a 
E
W iNbottom of the sea
W
hole
N
n the 

扩展一些占位符。


5

R237231字节

i=" in the "
for(j in 0:8)cat(f<-c(t<-"There's a ",paste(c("log","bump","frog","wart","hair","fly","flea","smile")[j:0],collapse=" on the "),if(j)i,h<-"hole",i,b<-"bottom of the sea
"),f,t,h,", there's a ",h,"
",t,h,i,b,"
",sep="")

在线尝试!


5

PHP,180个 178字节

foreach([hole,log,bump,frog,wart,hair,fly,flea,smile]as$w)echo$a=T.($b="here's a ").($s="$w ".io[++$i>2]."n the $s").$c="bottom of the sea
",$a,T,$b.=hole,", t$b
T$b in the $c
";

运行-nr在线尝试

在PHP 7.2中产生警告;要修复,请将引号放在
数组元素周围iohole然后将两个独立T


4

C(GCC) 334个 328 307 299字节

char*s="here's a \0smile on the flea on the fly on the hair on the wart on the frog on the bump on the log in the hole in the bottom of the sea\n";i;k=105;a[]={0,1,1,1,1,0,1,2,2};main(j){for(;i<9;k-=11+a[i++])do{printf("T%s%s",s,s+k);}while(j++&1||!printf("T%shole, t%shole\nT%s%s\n",s,s,s,s+105));}

在线尝试!



4

Perl 6、166字节

($/=@(($!="There's a")X [\R,](<hole log bump frog wart hair fly flea smile>Z(<i o>[$++>1]~"n the")xx*)X"bottom of the sea
")).map:{say "$_$_$! hole, {$!.lc} hole
$0"}

在线尝试!


4

Japt -R,142字节

`—¤clogc¿mpcfžgcØÖŽrcf§cf¤acsÚè`qc
`ˆ e Þ­om  e  a`
`T”œ's a `
£W+U¯YÄ ÔËE?"io"gE<Y +`n e `:P +Dø+` {V}
` ²+W+`—¤, t”œ's a —¤
{W}—¤ {V+R

在线尝试!


4

批处理,267字节

@echo off
set r=i
set t= There's a hole
set s=bottom of the sea
for %%w in (hole log bump frog wart hair fly flea smile)do call:c %%w
exit/b
:c
set s=%1 %r%n the %s%
echo%t:~,11%%s%
echo%t:~,11%%s%
echo%t%,%t:T=t%
echo%t%%s:~-25%
echo(
if %1==log set r=o

t包含在合唱中重复的字符串,s包含大部分经文行,而rin the和之间选择on the。在经文中,仅需要的前11个字符t,而在第一个合唱行中,的第二个副本将tT小写,而第二个合唱行重用的后25个字符s


4

红宝石173170字节

a="T#{["here's a hole"]*3*"%s"%[", t","
T"]+c=" in the "}bottom of the sea

"
b=a[31,39]
%w{log bump frog wart hair fly flea smile x}.map{|i|puts b,b,a;b[9]+=i+c;c[1]=?o}

在线尝试!


4

Haskell中243个 215字节

在nimi的大力帮助下减少到215个字节

c[[l n,l n,'T'#h++", "++'t'#h,l 8,""]|n<-[8,7..0]]
t#u=t:"here's a "++u
h="hole"
c=concat
l n='T'#c(drop n$map(++" on the ")(words"smile flea fly hair wart frog bump")++["log in the ",h," in the bottom of the sea"])

在线尝试!

(旧的243字节版本在这里)。

一个非常简单的解决方案。

-- main function producing a list of lines
v = concat [[
    l n,
    l n, -- second line of each verse equals to its first line
    'T' # h ++ ", " ++ 't' # h,
    l 8, -- last line of each verse is the same in all verses
    ""
  ] | n <- [8,7..0]]

-- a small helper to construct similar strings 
t # u = t : "here's a " ++ u

h = "hole"

-- construct a first line of n-th verse (with n = 8 is the first and n = 0 is the last one)
-- Every such line begins with a constant prefix followed by expanding list of nested entities
l n = 'T' # concat (
      drop n $
         map (++ " on the ") (words "smile flea fly hair wart frog bump")
         ++ ["log in the ", h, " in the bottom of the sea"]
    )

1
一些提示:a)您s只使用一次,因此可以内联它。b)您总是在前面加上一些东西t,因此可以使其成为一个(中缀)函数:t#u=t:"here's a "++u。C)构造函数的大名单lmap(++" on the ")(words"smile flea ..."较短。另外:将附加到该列表的所有内容移到列表本身。d)现在要删除的数字列表从8下降到0(单数字!)e)现在内联i还节省了一些字节。f)无需命名您的主要功能。根据我们的元数据,Haskell值被视为适当的函数,因此请删除v=
nimi

...全部215字节在线尝试!
nimi

1
另外需要保存3个字节:您可以使用>>=list monad中的(concatMap)和inline concatin function 来代替列表理解l在线尝试!
nimi


3

Python 3中213个206 198 193字节

k='n the ';o=e='bottom of the sea\n';b="There's a ";h='hole'
for j in[h]+'log bump frog wart hair fly smile'.split():o=j+' '+'io'['g'in o]+k+o;print(b+o+b+o+b+h+', t'+b[1:]+h+'\n'+b+h+' i'+k+e)

在线尝试!


-15字节归功于@Sara
-5字节归功于@ ASCII-only

可能更适合打高尔夫球,但不多。



@SaraJ谢谢。我是(显然是错误的)印象下o=e=将使双方oe指向同一个对象。我还认为拆分会更长。
Artemis Fowl

@ArtemisFowl oe 确实引用了相同的对象...只是字符串在Python中是不可变的,因此诸如此类的事情+=将创建一个新副本,而不是对现有副本进行更改
纯ASCII码


我只知道@ASCII,但是我认为python以某种方式确保了它们继续引用同一对象。
Artemis Fowl

2

干净,267字节

import StdEnv,Text,Data.List
t="here's a "
h="hole"
b=" in the bottom of the sea"
f=foldr((+)o\s#p="T"+t+join" on the "(reverse s)+" in the "+h+b
=join"\n"[p,p,"T"+t+h+", t"+t+h+"\nT"+t+h+b+"\n\n"])""(tl(inits["log","bump","frog","wart","hair","fly","flea","smile"]))

在线尝试!


2

cQuents238个 219字节

|@
#36::"T"~c1)~j\rbk));@ )~c2,Z,"T"~c1)~"hole, t"~c1)~"hole","T"~c1)~c2)~@

::"","log in the","bump"~c3,"frog"~c3,"wart"~c3,"hair"~c3,"fly"~c3,"flea"~c3,"smile"~c3
:"here's a ","hole in the bottom of the sea"," on the"

在线尝试!

这个挑战使我最终用我的语言实现了列表和字符串。该语言是为整数序列构建的,因此效果很好!

说明

:"here's a ","hole in the bottom of the sea"," on the"

    helper line: c1), c2), and c3) access the three terms in this list

::"","log in the","bump"~c3,"frog"~c3,"wart"~c3,"hair"~c3,"fly"~c3,"flea"~c3,"smile"~c3

    helper line: yields a list containing the first n terms in it, accessed with bx)
    for example, the first three terms are:

"","log in the","bump"~c3

    so b3) would yield ["","log in the","bump on the"] (~ is concatenation and c3 is " on the")


|@
#36::"T"~c1)~j\rbk));@ )~c2,Z,"T"~c1)~"hole, t"~c1)~"hole","T"~c1)~c2)~@


|@
                              join sequence on literal newline
#36::                         output first 36 terms in sequence joined together
                              following are the 4 terms in the sequence, which will cycle through 9 times (for a total of 36 terms)
"T"~c1)~j\rbk));@ )~c2,       first term
"T"~c1)~                      "T" concat "here's a " concat
        j\rbk));@ )           the first k terms of b, reversed, and joined on " "
                   ~c2,       concat "hole in the bottom of the sea"
Z,                            second term - same as previous
"T"~c1)~"hole, t"~c1)~"hole", third term
"T"~c1)~                      "T" concat "here's a " concat
        "hole, t"~c1)~"hole", "hole, t" concat "here's a " concat "hole"
"T"~c1)~c2)~@
                              fourth term - "T" concat "here's a " concat "hole on the bottom of the sea" concat newline

2

Perl 5,194个字节

@ ASCII-only用文字换行符削减了6个字节,\l我忘了一个技巧

$"=" on the ";say+($b=($e="There's a ").hole,$c=" in the bottom of the sea",$/)x2,$.="$b, \l$b
$b$c
";say"$e@a[-$_..-1] in the hole$c
"x2,$.for 1..(@a=qw/smile flea fly hair wart frog bump log/)

在线尝试!



对。辛苦了 我应该一定记得换行符。我以前看过\l,但是从来没有理由使用它,所以从没想过。
Xcali




2

木炭115106字节

≔There's a holeθEE⁹⁺…θχ⪫⮌…⪪”↶±∧⟲!↶⁼,(_⎇RB↧ω⪪zθⅉQθ`✳&⬤⸿◧σ⁻y▷»ΣK▶↙⁻υX`SξQ6 /ι⁹Wq”x⁺²ιn the ⟦ιι⁺⁺θ, ↧θ⁺θ✂ι±²⁵

在线尝试!链接是详细版本的代码。编辑:通过复制我的批处理代码为合唱的最后一行节省了9个字节。说明:

≔There's a holeθ

保存字符串There's a hole,该字符串按原样使用两次,小写字母第三次,第四次但仅前10个字符使用。

⪪”↶±∧⟲!↶⁼,(_⎇RB↧ω⪪zθⅉQθ`✳&⬤⸿◧σ⁻y▷»ΣK▶↙⁻υX`SξQ6 /ι⁹Wq”x

bottom of the seaxhole ixlog ixbump oxfrog oxwart oxhair oxfly oxflea oxsmile oxs 上分割字符串。

E⁹⁺…θχ⪫⮌…...⁺²ιn the 

循环遍历9个经文,获取i+2数组的第一个元素,将它们反转,将它们与n the相连,并There's a以结果为前缀。

E...⟦ιι⁺⁺θ, ↧θ⁺θ✂ι±²⁵

通过复制每行并构造合唱,将每行扩展为一节。然后,每节经文隐式地打印在每行上,并且每行经空白行隐式分隔。


2

V184170字节

4iThere's a hole in the bottom of the sea
kky5w5eá,lpD5brtHj4yyGp4w8ion the 2briilog 3bibump 3bifrog 3biwart 3bihair 3bifly 3biflea 3bismile 7ñ4yykp4wd3wñ8ñÄ5jñ

在线尝试!

说明:

  • 4iThere's a hole in the bottom of the sea<\n><esc> 插入“在海底有一个洞” 4次。
  • kk 移至第三行
  • y5w 复制“有一个洞”
  • 5eá, 在“有洞”之后插入逗号
  • lp 逗号后粘贴
  • D 删除该行的其余部分
  • 5brt 小写第二个T
  • Hj4yy 从第二行复制4行
  • Gp 在第一行之后粘贴所有内容
  • 4w8ion the <esc>(在第一节的末尾)移至第二节的第一个“洞”,并在“
  • 2briilog <esc> 向后移动到最后一个“ on”,将o替换为i,然后插入“ log”
  • 3bibump <esc>3bifrog <esc>3biwart <esc>3bihair <esc>3bifly <esc>3biflea <esc>3bismile <esc> 向后移动,在每个“上”之间插入适当的词
  • 7ñ4yykp4wd3wñ执行4yykp4wd3w7次
    • 4yykp 在这一节之前重复这节经文
    • 4wd3w 移至“有洞”之后的第一个单词,并删除3个单词
  • 8ñÄ5jñ 在每节经文的第一行之后复制第一行(其中有8行要做)

2

///,216字节

/V/\/\///U/\/ VS/TCVR/iBVQUtheVPUoBVOUholeVN/RASVM/ASO, tCO
SA
VL/RMSVKUlog VJUbumpPKVIUfrogPJVHUwartPIVGUhairPHVFUflyPGVEUfleaPFVDUsmilePEVC/here's aVB/nQVA/O R bottom ofQ sea
/SASMSKNKLJNJLINILHNHLGNGLFNFLENELDNDRM

在线尝试!

这种任务是///相当擅长的一件事。:D嘿,结果比C,C#或Java短!

该程序的输出以两个尾随的换行符结尾;希望这不是一个破坏交易的行为。

无论如何,这里没有真正的聪明之处。我只是简单地确定了重复的字符串,并为它们定义了一个字符的快捷方式,然后重复进行直到我看不到任何重复的字符串为止。我以一种或多或少的幼稚和贪婪的方式做到了这一点。但是,我确实有意定义了“在……海上跳蚤微笑”的快捷方式,然后定义“在……海上跳蚤的微笑”,依此类推,以形成一条捷径链。结果是新名词的整个序列在代码中清晰可见,我觉得这很令人愉快。:)

替换V和U之后,我们将获得以下更具可读性的代码:

/S/TC//R/iB//Q/ the//P/ oB//O/ hole//N/RAS//M/ASO, tCO
SA
//L/RMS//K/ log //J/ bumpPK//I/ frogPJ//H/ wartPI//G/ hairPH//F/ flyPG//E/ fleaPF//D/ smilePE//C/here's a//B/nQ//A/O R bottom ofQ sea
/SASMSKNKLJNJLINILHNHLGNGLFNFLENELDNDRM

2

LaTeX,265268个字符

\documentclass{book}\input{pgffor}\def\i{bottom of the sea}\let~\i\def\b{here's a }\def\h{hole}\def\s#1{ in}\begin{document}\foreach\x in{\h\s,log\s,bump,frog,wart,hair,fly,flea,smile}{\xdef~{\x{ on} the ~}T\b~\\T\b~\\T\b\h, t\b\h\\T\b\h\,in the \i\par}\enddocument

编译成带有段落缩进和所有内容的漂亮PDF。

取消评论并评论:

\documentclass{book}
\input{pgffor}
\def\i{bottom of the sea}   %for re-use in the last two verses 
\let~\i                     %here I keep attaching words
\def\b{here's a }               
\def\h{hole}
\def\s#1{ in}               %this replaces the next token with "in", useful for log and hole where "in" is used instead of"on"
\begin{document}
\foreach\x in{\h\s,log\s,bump,frog,wart,hair,fly,flea,smile}{
    \xdef~{\x{ on} the ~}   %keep attaching words and on/on to ~
    T\b~\\                  %verse 1
    T\b~\\                  %verse 2
    T\b\h, t\b\h\\          %verse 3
    T\b\h\,in the \i\par    %verse 4
}
\enddocument

输出:

在此处输入图片说明


2

C#(Visual C#交互式编译器),220字节

string b="There's a ",d="hole in the bottom of the sea\n",e,f;" log bump frog wart hair fly flea smile".Split().Any(s=>Write((e=b+(f=s!=""?s+(f!=""?" o":" i")+"n the "+f:s)+d)+e+b+$@"hole, there's a hole
{b+d}
")is int);

在线尝试!

@ASCIIOnly -5个字节,@ someone -2个字节!

我有一个小孩,可以向您保证,这首歌既吸引人又令人讨厌。


1
很抱歉提醒您它存在:o)
Sok

.Any()-> !=""
分仅使用ASCII码


并且您inforeach> _>
纯ASCII:

@ASCIIOnly-感谢您的提示:)
dana
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.