创建字母歌曲


55

您的目标是按照以下格式(按顺序)将字母歌曲创建为文本:

A is for <word starting with A>
B is for <word starting with B>
C is for <word starting with C>
...
Z is for <word starting with Z>

输出示例:

A is for Apple
B is for Banana
C is for Carrot
D is for Door
E is for Elephant
F is for Frog
G is for Goat
H is for Hat
I is for Icicle
J is for Jelly
K is for Kangaroo
L is for Lovely
M is for Mom
N is for Never
O is for Open
P is for Paste
Q is for Queen
R is for Rice
S is for Star
T is for Test
U is for Underneath
V is for Very
W is for Water
X is for X-ray
Y is for Yellow
Z is for Zipper

规则:

  • 歌曲的每个“字母”都有其自己的行,因此共有26行,并可能有结尾的换行。

  • 输出区分大小写:

    • 每行开头的字母必须大写。
    • is for 是小写的。
    • 所选单词不必大写,但可以大写。所有行应保持一致。
  • 每行选择的单词取决于您,但必须是一个有效的英文单词,至少包含3个字母,并且不能是连词(如andbut),感叹号/感叹号(如heyyay),缩写(如XLS)或名称(如Jon)。

  • 尽管我怀疑有人会发现它短一些,但我发现使用短语而不是单个单词是可以接受的。因此,如果由于某种原因S is for Something smells fishy...而缩短,那就去吧。

  • 将程序的输出放入您的答案中,或者至少输入您使用的单词的列表(如果有一个链接可以在线运行您的代码,则无需查看整个输出)。

  • 最短代码胜出


这个挑战受到了这个视频的启发。


我猜测即使在适当的词典中列出了语也是不允许的?(例如““当她意识到自己再次朝内陆前进时,她只是拉了一个家伙!”)
乔纳森·艾伦

1
有了一些答案,Barenaked Ladies的这首歌似乎很有意义。
AdmBorkBork

1
@JonathanAllan没有No语。词典包含很多从技术上来说不是单词的东西。缩写是一个,语是另一个。
mbomb007'2

4
不幸的是,这导致无法找到以同一字母结尾的3个字母单词。
17Me21年

1
使用外部字典有两个答案。他们不应该将文件的大小添加到代码中吗?

Answers:


3

SOGL 0.8.160 32 个字节

χ3½⌠↓-ζ⁄∞Nη6′⁵‘Z{t",t5~r‘ooKo to

说明:

χ3½⌠↓-ζ⁄∞Nη6′⁵‘                   push "niooaaoasoioaiaaaoiineeaei"
               Z{                 for each letter of the uppercase alphabet
                 t                output the letter in a newline (and disable implicit output)
                  ",t5~r‘o        append " is for "
                          o       append the letter
                           Ko     append the 1st letter of the 1st string (the 2nd letters) and remove it
                              to  append "t"

这几乎是乔纳森·艾伦的回答,但已移植到这种语言。

旧版本:(SOGL 0.8.2)

Z"sηΒ…@Ν┘$JP6*š∙╬F▓÷Σ⁷4⌠    ⁹{Tīο⁾α⅝½Χ<▼½Ξμ‚‘θ’»∫wGKO",t5~r‘P≥o


Z                                                             push the uppercase alphabet
 "sηΒ…@Ν┘$JP6*š∙╬F▓÷Σ⁷4⌠    ⁹{Tīο⁾α⅝½Χ<▼½Ξμ‚‘                  push the 27 words separated by spaces using the languages english compression (BCD...XYZA)
                                          θ                   split on spaces
                                           ’»∫                repeat 27 times (push 0-based pointer)
                                              w               get the 1-indexed item of the array (so 0 = last, 1 = first, 2 = 2nd,...)
                                               G              put the 1st thing on stack ontop (the alphabet)
                                                K             get the 1st letter and remove it
                                                 O            output it
                                                  ",t5~r‘     push compressed " is for "
                                                         P    append that (and disable last auto-output)
                                                          ≥   put the 1st thing on the stack below everything
                                                           o  append the last thing (the word from the word list)

输出:

A is for against
B is for being
C is for could
D is for down
E is for even
F is for first
G is for good
H is for had
I is for into
J is for just
K is for know
L is for little
M is for much
N is for nothing
O is for other
P is for project
Q is for quite
R is for right
S is for said
T is for their
U is for under
V is for very
W is for with
X is for xavier
Y is for you
Z is for zoo

这不是该语言可以做到的最短,但对于硬编码的单词应该是最好的。


57

Bash(+ coreutils), 818782,78字节

使用X的手册页作为单词源。

打高尔夫球

man xyst\  x|&grep -Po '\b[a-z]{4,} '|sed 's/\(.\)/\u\1 is for &/'|sort -uk1,1

编辑

  • 使用了不存在的“ xyst”手册页+ |&保存5个字节;
  • 通过交换sedsort,又节省了4个字节。

测试

%man xyst\  x|&grep -Po '\b[a-z]{4,} '|sed 's/\(.\)/\u\1 is for &/'|sort -uk1,1

A is for also 
B is for build 
C is for computing 
D is for distribution 
E is for entry 
F is for following 
G is for graphics 
H is for hierarchical 
I is for implementations 
J is for just 
K is for keyboard 
L is for listing 
M is for manual 
N is for network 
O is for output 
P is for programs 
Q is for quite 
R is for runs 
S is for system 
T is for transparent 
U is for used 
V is for various 
W is for window 
X is for xyst 
Y is for your 
Z is for zeros 

3
lsof和xregs是单词吗?:)
OldBunny2800

1
@ OldBunny2800应该立即修复
zeppelin

2
我查了一下,是的,xyst是一个真实的词。:)
OldBunny2800

3
看起来孩子们将要学习一些大字眼。:D
mbomb007

1
@JonathanAllan不幸的是,“ x”的手册页在TIO上不可用,但是这里有一个链接 tio.run/nexus/…,它代替了“ man man”。xyst的诀窍是,男人xyst会抱怨stderr没有“ xyst的手动输入”,然后将stderr与合并为stdout |&,因此可以将其grepped。
齐柏林飞艇

33

Python 2中88 77个字节

得益于xnor,它的-11个字节(通过遍历字符串并c从65开始计数来避免zip )

c=65
for x in'niooaauusoioaiuaaoiineeaei':print'%c is for %c%st'%(c,c,x);c+=1

在线尝试!

(我的果冻答案的端口,当时是56个字节。)

A is for Ant
B is for Bit
C is for Cot
D is for Dot
E is for Eat
F is for Fat
G is for Gut
H is for Hut
I is for Ist
J is for Jot
K is for Kit
L is for Lot
M is for Mat
N is for Nit
O is for Out
P is for Pat
Q is for Qat
R is for Rot
S is for Sit
T is for Tit
U is for Unt
V is for Vet
W is for Wet
X is for Xat
Y is for Yet
Z is for Zit

4
我喜欢以t结尾的单词方法。可以通过并行更新x来缩短迭代。
xnor

一如既往地非常聪明;谢谢!
乔纳森·艾伦

1
什么Unt啊 找不到任何地方
Albert Renshaw

我不认为这Unt是一个字,但是Ut您可以用n字面量替换中的,\0以使其有效并仅添加一个字节。编辑没关系的规则说它必须是3个字母长...嗯
艾伯特·伦肖

4
@AlbertRenshaw根据Merriam-Webster的说法,叔叔是欧洲a鼠。根据Wiktionary的说法,替代品将是ult,而不仅仅是缩写(以句号列出,例如ult)。
乔纳森·艾伦,

31

重击 78,69字节

土豚,Babushkas和神风敢死队!

打高尔夫球

sed -nr '/^[a-z]{9}$/s/(.)/\u\1 is for &/p'</u*/*/*/words|sort -uk1,1

编辑

  • 摆脱了grep,-9个字节

测试

%sed -nr '/^[a-z]{9}$/s/(.)/\u\1 is for &/p'</u*/*/*/words|sort -uk1,1

A is for aardvarks
B is for babushkas
C is for cablecast
D is for dachshund
E is for eagerness
F is for fabricate
G is for gabardine
H is for habitable
I is for ibuprofen
J is for jabberers
K is for kamikazes
L is for labelling
M is for macaronis
N is for nailbrush
O is for obedience
P is for pacemaker
Q is for quadrants
R is for rabbinate
S is for sabotaged
T is for tableland
U is for ulcerated
V is for vacancies
W is for wackiness
X is for xylophone
Y is for yachtsman
Z is for zealously

利用/ usr / share / dict / words

word是所有Unix和类似Unix的操作系统上的标准文件,并且只是字典单词的换行符分隔列表。例如,它可用于拼写检查程序。


14

PowerShell中150个 141 117 75字节

65..90|%{$i=[char]$_;"$i is for $i$('niooaauusoioaiuaaoiineeaei'[$_-65])t"}

在线尝试!

从循环6590(即ASCII AZ)。每次迭代时,我们都将整数转换为适当的整数char(即ASCII 65A),将其保存以$i备后用,将其与字符串连接,is for $i然后将其固定在适当单词的中间。这是通过索引一个长字符串(从Jonathan Allan的答案中借用)来完成的。完成字母t以使三个字母成为单词。

结果字符串将全部留在管道上,Write-Output最后的隐式字符串将在它们之间插入换行符。

多亏了乔纳森·艾伦(Jonathan Allan)的Rod Rodrowed单词表,节省了很多字节


您可以删除每个单词(首都之一)的第一个字母,并打印[char]$ 例子
罗德

@Rod谢谢。我将其与我刚要进行的工作结合起来,以更改循环的计算方式以及索引的计算方式和保存方式等等。
AdmBorkBork '17

13

果冻,39 个字节

;“ẉbẊWS»,⁸K;;”t
“¤ṁp}œḊṄæ®’b6ị“ʠȷ»ØAç"Y

TryItOnline!

基于56字节版本(以下两个),但更改了单词以删除所有中间字母"u"s,以便可以将其索引到词典单词"anisole"*中,这具有将我们需要的所有字母的索引都小于6的便利:(1:a, 2:n 3:i, 4:s, 5:o (6:l), 0:e请注意,"e"右边的索引为零[也为7和-7以及与0 mod 7相符的任何其他数字])。它在字典中也很早,因此只有两个而不是更常见的三字节查找索引("anisogamete"也适用于2)。

*芳香醚甲氧基苯的旧名称,通常用于香水中。

A is for Ant
B is for Bit
C is for Cot
D is for Dot
E is for Eat
F is for Fat
G is for Got
H is for Hat
I is for Ist
J is for Jot
K is for Kit
L is for Lot
M is for Mat
N is for Nit
O is for Oat
P is for Pat
Q is for Qat
R is for Rot
S is for Sit
T is for Tit
U is for Unt
V is for Vet
W is for Wet
X is for Xat
Y is for Yet
Z is for Zit

怎么样?

“¤ṁp}œḊṄæ®’b6ị“ʠȷ»ØAç"Y - Main link: no arguments
“¤ṁp}œḊṄæ®’             - base 250 compressed number -> 75711304811637630759
           b6           - convert to base 6 list -----------> [   2,    3,    5,    5,    1,    1,    5,    1,    4,    5,    3,    5,    1,    3,    1,    1,    1,    5,    3,    3,    2,    0,    0,    1,    0,    3]
              “ʠȷ»      -     word from Jelly's dictionary, "anisole" 
             ị          - index into that ------------------> [ "n" , "i" , "o" , "o" , "a" , "a" , "o" , "a" , "s" , "o" , "i" , "o" , "a" , "i" , "a" , "a" , "a" , "o" , "i" , "i" , "n" , "e" , "e" , "a" , "e" , "i"]
                  ØA    - get the uppercase alphabet
                    ç"  - zip with last link (1) as a dyad -> ["Ant","Bit","Cot","Dot","Eat","Fat","Got","Hat","Ist","Jot","Kit","Lot","Mat","Nit","Oat","Pat","Qat","Rot","Sit","Tit","Unt","Vet","Wet","Xat","Yet","Zit"]
                      Y - join with line feeds
                        - implicit print

;“ẉbẊWS»,⁸K;;”t - Link 1, join up the parts: Character, Two-Character-Word-Ending
;               - concatenate Character (e.g. "A") with
 “ẉbẊWS»        - the compressed string " is for" --->  "A is for"
        ,       - pair that with
         ⁸      - the left argument (Character) -----> ["A is for","A"]
          K     - join with spaces ------------------>  "A is for A"
           ;    - concatenate with right argument --->  "A is for An"
            ;   - concatenate with
             ”t -     "t" --------------------------->  "A is for Ant"

以前的46

“¤ṪŻIð^ƥ’b4ị⁾sap⁾pt¤ØAż,@K¥€“ẉbẊWS»ØAżYF”e272¦

在“ sa”和“ pt”的笛卡尔乘积中,所有单词的第二个字母“ s”或“ a”,最后一个字母“ p”或“ t”使用四进制查找。除了 “ U”字以外,代码将其更改为“ Use”(最后使用相对较大F”e272¦的字)-如果我可以找到这样的单词列表,且没有此类异常,我们将查看39个字节

单词表:

Asp, Bat, Cat, Dap, Eat, Fat, Gap, Hat, Ist, Jat, Kat, Lap, Mat, Nap, Oat, Pat, Qat, Rat, Sat, Tap, Use, Vat, Wat, Xat, Yap, Zap

试试这个


前56个字节

”tṁØA⁺,j“niooaauusoioaiuaaoiineeaei”œs3Z,@K¥€“ẉbẊWS»ØAżY

单词表:

Ant, Bit, Cot, Dot, Eat, Fat, Gut, Hut, Ist, Jot, Kit, Lot, Mat, Nit, Out, Pat, Qat, Rot, Sit, Tit, Unt, Vet, Wet, Xat, Yet, Zit

它已格式化,请尝试一下


前一个83字节

“ẉbẊWS»WṁØA⁺żż“¦ịfe$ɲVPġþ¹Øt@ƑƊŀqṁŒƑOɦ⁴ḍẊḤṁr}Ƭ¢b⁻?q&øIụNẎ9eƲi⁸'ıB.;%V,¦İ⁷ẓk½»s5¤K€Y

...让我们玩“发现字母没有动物的地方!” 只有一个,只有一个-注意红色鲱鱼 (一个谎言,红色鲱鱼是氙,这是一种元素,显然不是动物),这里有两个五个字母的单词,它们不是动物(氙是一个) :

Aphid, Bison, Camel, Dingo, Eagle, Finch, Gecko, Heron, Indri, Jabot, Koala, Lemur, Mouse, Nyala, Otter, Panda, Quail, Raven, Sloth, Tapir, Urial, Viper, Whale, Xenon, Yapok, Zebra

(当然,此文件格式正确,请尝试一下 -我只是想节省空间)


Xenon不是动物。我确定您是在开玩笑H is for Herring,但我想不是。
mbomb007'2

嘿,这是个谎言。氙气很明显:)
乔纳森·艾伦

我认为他们正在考虑xenop,这不在Jelly的词典中。
乔纳森·艾伦

好主意!但是Uut
格雷格·马丁

@GregMartin我同意,我认为您开始将您的单词讲成音节的咕unt声。
魔术章鱼缸

10

视网膜89 87字节

感谢Martin Ender,节省了2个字节


ApBaCaDoEaFaGeHaIkaJeKiLeMeNeOpPeQaRaSaTiUniVaWeXysYurZi
[A-Z]
¶$& is for $&
^¶

m`$
t

在线尝试!

我为每个以结尾结尾的字母选择一个单词t(有些字母晦涩难懂)。

说明


ApBaCaDoEaFaGeHaIkaJeKiLeMeNeOpPeQaRaSaTiUniVaWeXysYurZi

用上面的文本替换不存在的(空)输入。

[A-Z]
¶$& is for $&

将每个大写字母替换为(newline)(itself) is for (itself)。这导致上面的文本被分成几行,例如

A is for Ap
B is for Ba
C is for Ca

... 等等

^¶
​

但是,由于换行符位于每个大写字母之前,因此必须删除一个领先的换行符。在此阶段将其删除。

m`$
t

t在每行末尾加上a ,因为歌曲中使用的每个单词都以结尾t


您无需捕获大写字母。只需使用$&$0代替$1。实际上,这也可能在我的拆分阶段节省了字节。
Martin Ender

@MartinEnder谢谢。到底是$&做什么的?我在GitHub Wiki上没有看到它。
Business Cat

这是它的别名$0(它只是.NET风格以及大多数其他风格的一部分)。
马丁·恩德

使用一些简短的单词将其降到83,然后在线尝试
Jonathan Allan

8

视网膜92 88字节

通过从Business Cat的答案中借用一个想法节省了4个字节。

字节数假定为ISO 8859-1编码。


AddBCDEelFGHItsJetKitLMNetOilPQatRSTUrnVatWXisYesZit
[A-Z]
¶$& is for $&
m` .$
$&ad
G`.

在线尝试!

基于AdmBorkBork的单词列表,但我将其他几个单词更改为结尾的单词,ad以在公共后缀中节省更多字节。

说明


AddBCDEelFGHItsJetKitLMNetOilPQatRSTUrnVatWXisYesZit

将空输入(不存在)输入此字符串。它包含所有字母以及不以结尾的其余单词ad

[A-Z]
¶$& is for $&

在每个大写字母之前插入换行符,然后将其变成X is for X

m` .$
$&ad

匹配现在单独出现的字母并追加ad以完成缩短的单词。

G`.

丢弃通过在之前插入换行符而创建的空行A


8

PHP,122个 124 127 120 115 101字节

遵循“标准” <letter><filler>t结构。
我试图提出任何人都没有使用过的单词。
如果您看到一个要替换的单词,请告诉我。

foreach(range(A,Z)as$k=>$c)echo"$c is for $c",ceaoaaei0eieeouoaaei0eeaei[$k]?:[I=>ka,U=>ni][$c],"t\n";

换行符表示为,\n但计为1个字节。


输出:

A is for Act
B is for Bet
C is for Cat
D is for Dot
E is for Eat
F is for Fat
G is for Get
H is for Hit
I is for Ikat
J is for Jet
K is for Kit
L is for Let
M is for Met
N is for Not
O is for Out
P is for Pot
Q is for Qat
R is for Rat
S is for Set
T is for Tit
U is for Unit
V is for Vet
W is for Wet
X is for Xat
Y is for Yet
Z is for Zit

奇怪的话:

  • ikat

    Ikat(或ikkat)是一种用于对纺织品进行图案化的染色技术,该技术在对织物进行染色和编织之前,先对纱线进行抗蚀剂染色。

  • xat

    北美西部的一些印第安人竖立着一根雕刻的杆子,以纪念死者

  • 即时通讯

    青春痘 皮肤瑕疵。

  • qat

    Catha edulis(khat,qat)是非洲之角和阿拉伯半岛的一种开花植物。


聪明的解决方案,我打算做类似的事情,很高兴看到这个!+1
艾伯特·伦肖

1
这些都不是英语单词....
康纳尔奥布莱恩

@ ConorO'Brien您确定吗?据我所知,PHP都是用英语编写的。
Ismael Miguel

5
@IsmaelMiguel之类的东西vprintfzend_version肯定不是英语单词。这些实体中很少有实际上是单词。
Conor O'Brien

1
zit至少我不会说一个奇怪的词,我认为每个人都应该已经知道它的意思了。
mbomb007 '17

6

Pyke,55 51 48字节

26.f[1R].C".d"R+E)DGjt@.^.Il 6>( F['h .dRdJl5

在这里尝试!

链接的长度为3,不符合条件,因为单词包含结语。

    [1R].C".d"R+E)                            - def function [i):
     1R]                                      -     [1, i]
        .C                                    -    chr(^)
          ".d"R+                              -   ".d"+ ^
                E                             -  eval(^) (dictionary lookup of length 1)
                                              -    gets the `i`th word in the dictionary

26.f[             DGjt@.^.Il 6>(              -  first_26():
    [                                         -     function(i)
                       .^                     -    ^.startswith(v)
                   Gjt@                       -     alphabet[current_iter-1]
                         .Il 6>               -   if ^:
                           l 6>               -    len(function(i)) > 6
                                 F['h .dRdJl5 - for i in ^:
                                  ['h         -     function(i)[0], function(i)
                                      .d      -    "is for" (unprintables 0x02, 0x07, 0x06)
                                        R     -    rotate(^, ^^)
                                         dJ   -   " ".join(^)
                                           l5 -  ^.capitalize()

输出:

A is for available
B is for because
C is for community
D is for download
E is for english
F is for features
G is for getting
H is for hardware
I is for increase
J is for jewelry
K is for kitchen
L is for locations
M is for manufacturer
N is for northern
O is for outdoor
P is for protein
Q is for quickly
R is for religion
S is for surgery
T is for thousands
U is for universal
V is for vehicles
W is for weekend
X is for xenical
Y is for youngest
Z is for zoofilia

您可以使用相同的算法在Pyke之外进行测试。需要dictionary.json

import json, string

with open("dictionary.json") as f_obj:
    words=json.load(f_obj)

rtn=[]
i=0
while len(rtn) != 26:
    cur_word=words[i]
    if cur_word[0]==string.lowercase[len(rtn)]:
        if len(cur_word) > 6:
            rtn.append(cur_word)
    i += 1

for i in rtn:
    print("{} is for {}".format(i[0].upper(), i))

否。此外,我在运行您的代码时遇到错误。
mbomb007'2

Timeout running code. BAD EVAL确保更新“在线试用”链接。
mbomb007 '17

2
Z is for zoofilia在让我的孩子唱歌之前,我会认真考虑。
齐柏林飞艇


对于像我一样做双重练习的人:英语并不总是大写。;)
DLosc

6

Japt52 50字节

与@ETHproductions合作

;B£[R`  f `Od"¥¥º"gY]qXÃx

包含许多不可打印的内容。在线测试!

单词列表是:

All Bar Can Dan Ear Fan Gas Has Ill Jar Kit Led Man Nit Oar Pan Qat Rat Sat Tan Udo Vat War Xis Yes Zit

Japt使用shoco字符串压缩库,该将小写字母的普通行减少了一个字节。这是压缩为一个字节的所有两个字母的运行的完整列表:

an,ar,as,at,be,bl,bo,bu,ca,ce,ch,co,da,de,di,do,ed,en,er,es,ha,he,hi,ho,im,in,is,it,le,li,ll,ly,ma,me,mi,mo,nd,ne,ng,nt,of,on,or,ou,ra,re,ri,ro,se,sh,si,st,te,th,ti,to,ul,ur,us,ut,wa,we,wh,wi

因此,想法是为字母表中的每个字母用这些对之一构成一个单词。

;B£   [R`  f `    Od"string"gY]qXÃ x
;BmXY{[R" is for "Od"string"gY]qX} x

;                                      // Among other things, set B to "ABC...XYZ".
 B                                     // Split B into chars.
    mXY{                           }   // Map each item X and index Y to the following:
                      "string"gY       //   Take the char at index Y in the compressed str.
                    Od                 //   Decompress.
        [R" is for "            ]      //   Put this in an array with a newline and " is for ".
                                 qX    //   Join on X, giving "\n{X} is for {word}".
                                    x  // Trim. This removes the leading newline.
                                       // Implicit: output result of last expression

需要注意的一件有趣的事是,尽管Japt可以隐式解压缩用反引号括起来的字符串,但实际上这里要长一个字节,因为您必须在解压缩的字符串中抓取两个字符,而不是一个。


6

05AB1E45 42 39 38 37 36字节

Au'Æå•à¡P°€kš¦zᮕSè)øvy¬“ÿ€ˆ€‡ ÿt“,

在线尝试!

说明

Au按下大写字母。
'Æå推单词scenario
•à¡P°€kš¦zᮕ按10底数36774474076746444766322426
使用这些数字索引到scenario
将这些字符串压缩到列表中[An, Bi, Co, ..., Zi]

v                  # for each element in the list
 y                 # push it
  ¬                # push it's first letter
   “ÿ€ˆ€‡ ÿt“      # push the string "ÿ is for ÿt" 
                   # replacing ÿ with with the top element of the stack
             ,     # print with newline

使用的词: ['Ant', 'Bit', 'Cot', 'Dot', 'Eat', 'Fat', 'Got', 'Hat', 'Ist', 'Jot', 'Kit', 'Lot', 'Mat', 'Nit', 'Oat', 'Pat', 'Qat', 'Rot', 'Sit', 'Tit', 'Unt', 'Vet', 'Wet', 'Xat', 'Yet', 'Zit']

33字节版本,我不确定

Au'†Ž•4Ãðzòç•3BSè)øvy¬“ÿ€ˆ€‡ ÿt“,

话: ['Ant', 'Bat', 'Cat', 'Dat', 'Eat', 'Fat', 'Gat', 'Hat', 'Ist', 'Jat', 'Kat', 'Lat', 'Mat', 'Nat', 'Oat', 'Pat', 'Qat', 'Rat', 'Sat', 'Tat', 'Ust', 'Vat', 'Wat', 'Xat', 'Yat', 'Zat']


6

Ruby,93 84 69 63 58 62字节

?A.upto(?Z){|l|puts l+" is for #{"AnDoIsUn"[/#{l}./]||l+?a}t"}

输出:

A is for Ant
B is for Bat
C is for Cat
D is for Dot
E is for Eat
F is for Fat
G is for Gat
H is for Hat
I is for Ist
J is for Jat
K is for Kat
L is for Lat
M is for Mat
N is for Nat
O is for Oat
P is for Pat
Q is for Qat
R is for Rat
S is for Sat
T is for Tat
U is for Unt
V is for Vat
W is for Wat
X is for Xat
Y is for Yat
Z is for Zat

所有3个字母的单词都以't'结尾,其中大多数以'at'结尾。

使用有争议的字词(iat,dat,amp。ump)-55个字节:

?A.upto(?Z){|l|puts l+" is for "+l+("AU"[l]?"mp":"at")}

仍在尝试寻找模式,我认为可以仅使用2个不同的结尾并简化所有操作。

感谢@Value Ink和@Business cat的帮助。


1
Qat和Xis(复数为Xi)是单词,因此您可以使用它们,并将查找正则表达式减少为/#{l}../
Value Ink

谢谢,我在想类似的事情,但是现在我不在电脑上了,我一定会检查一下。
GB

实际上,我正在尝试为缺少的字母找到5个字母的单词:数组,论文,嵌体...但是我坚持这样做。:-(
GB

1
Kat是有效字词,因此您可以删除的特殊情况kit
Business Cat

1
我想到了“ dat”和“ zat”,但是它们都是相同的连词(that)和语,这两种词都被禁止。“ amp”和“ ump”似乎是“安培” /“放大”和“公断”的缩写。“ IAT”是首字母缩写词,因此也不好。
乔纳森·艾伦,

6

///,163个字节

/2/ad//1/ is for /A1Add
B1B2
C1C2
D1D2
E1Eat
F1F2
G1Goo
H1H2
I1Irk
J1Job
K1Kob
L1L2
M1M2
N1Nob
O1Owl
P1P2
Q1Qat
R1R2
S1S2
T1T2
U1Use
V1Vat
W1W2
X1X-ray
Y1Yob
Z1Zoo

在线尝试

优步-n。-残酷残酷的家伙

嗯,今天学到了一些东西...


2
在英国,洋洋娃娃是暴徒,暴徒或bo子。比残酷和残酷更残酷,粗暴。
乔纳森·艾伦,

1
在俄语中,“ Yob”是淫秽动词的一种简化形式,基本上相当于英语中的“ f * ck”。您知道的越多...
Scapegrace先生17年

5

05AB1E72 68字节

码:

”–³æéÁéî¹àæÑå꧵™Ä‚æ†Í„΢׆™ƒÛÌ´ŸÄ«©‡¯†‚IJ‚Ò„©É€ŠÛì„”#vy¬…ÿ€ˆ€‡ð«ì,

使用CP-1252编码。在线尝试!

说明

如下代码:

”–³æéÁéî¹àæÑå꧵™Ä‚æ†Í„΢׆™ƒÛÌ´ŸÄ«©‡¯†‚IJ‚Ò„©É€ŠÛì„”#

推送此数组:

['Apple', 'Banana', 'Carol', 'Door', 'Elephant', 'Frog', 'Goat', 'Hat', 'Ice', 'January', 'Key', 'Love', 'Mom', 'Never', 'Open', 'Paste', 'Queen', 'Rice', 'Star', 'Test', 'Underwear', 'Very', 'Water', 'Xanax', 'Yellow', 'Zoloft']

并使用以下代码进行处理:

vy¬…ÿ€ˆ€‡ð«ì,

vy              # For each string in the array
  ¬             # Get the first letter of that string
   …ÿ€ˆ€‡       # Push the string "ÿ is for" where 'ÿ' is the first letter of the string
         ð«     # Append a space character
           ì    # Prepend this string to the current string from the array
            ,   # Print with a newline

您能解释一下为什么要推那个数组吗?
魔术章鱼缸

我认为05AB1E具有一些内置的单词,可以用字符串中的2个字节表示。
17Me21年

@ 12Me21太酷了!”–³”=Appleint(–³,214)=23891,但我仍然没有看到这里的相关性。
魔术章鱼缸


2
@carusocomputing 是压缩和解压缩工作方式的更详细说明。
阿德南

5

Clojure,159232字节

好吧,现在这肯定是非竞争性的解决方案,因为对使用的单词进行硬编码会容易得多。将其放在此处只是为了获得正确答案(而不使用他人的单词表)。

(mapv #(println(str(char %)" is for"(first(re-seq(re-pattern(str" "(char(+ % 32))"+\\w{3,} "))
    (reduce(fn[a b](str a(with-out-str(load-string(str "(doc "b")")))))" xyst "(map str(keys(ns-publics 'clojure.core))))))))(range 65 91))

基本上仍然可以获取clojure.core命名空间中定义的所有函数,但是在此之后求值doc <function name>并将其放入字符串中。之后,将其连接成一个巨大的字符串(带有单词xyst),并从那里找到合适的单词。应该在Clojure REPL中运行。

输出:

A is for arbitrary
B is for being
C is for changes
D is for determined
E is for exception
F is for failed
G is for given
H is for held
I is for items
J is for java
K is for keys
L is for lazy
M is for must
N is for notified
O is for option
P is for performed
Q is for queued
R is for returns
S is for state
T is for true
U is for uses
V is for validator
W is for were
X is for xyst
Y is for yields
Z is for zero

旧解决方案:

(mapv #(println(str(char %)" is for "(some(fn[a](and(=(.charAt a 0)(char(+ % 32)))a))(conj(map str(keys(ns-publics 'clojure.core)))"orb""yes"))))(range 65 91))

or,而不是orb1个字节。
wizzwizz4

1
最小长度为3个字母
21Me21

@ mbomb007已更新。
悬崖根

4

JavaScript(ES6),82个字节

_=>btoa`pb
è¡Záî"Âh*"è1£b:ãÚA¤hJ$âRu^YåÚaæb`.replace(/(.)./g,`$1 is for $&t
`)

返回字符串的匿名函数。包含不可打印的内容;这是一个没有的版本:

_=>btoa`\x02pb
\x80è\x11¡Z\x18áî"Âh*"è1£b:ãÚA¤hJ$âRu^YåÚaæb`.replace(/(.)./g,`$1 is for $&t
`)

这使用@JonathanAllen的技术,仅使用以结尾的三个字母的单词t。字符串解压缩为AnBiCoDoEaFaGOHuIsJoKiLoMaNiOuPaQaRoSiTiUnVeWeXaYeZi

我尝试像这样链接两个字母对:

Ace
 Bee
  Cee
   Dew
    Ewe
     ...

我现在一直都X坚持下去Y; 据我所知,唯一可获得的三个字母的X单词是Xis,并且没有以开头的三个字母的单词Ys

为了记录,完整的字符串是ceeeweeereueaebiueeiziais...


据维基词典,你可以使用uzitiz...
DLosc

@DLosc好主意。然后,你需要做的seiski或者sri,它留给你reeroeruerye,它留给你......只有三个字母q-words我能看到的是qatqisqua。维基词典页面上是否包含更多三个字母的单词?
ETHproductions'2

有一个包含三个字母的单词的类别,但它不是一个完整的列表。例如,它不包含que(我只知道这是因为这里的另一个答案使用了它)。(不过,不确定是否有以p结尾的-word u。)
DLosc

@DLosc我已经在使用了piu,所以这根本不是问题:P谢谢!
ETHproductions's

piu似乎边界很近-维基词典没有英语,而dictionary.com却是più(不知道我们如何考虑此挑战的重音符号)。但是,是的,ys_这将是一个问题。
DLosc

3

Mathematica,97个字节

a@c_:={ToUpperCase@c," is for ",Select[WordList[],#~StringTake~1==c&][[3]],"
"};a/@Alphabet[]<>""

在Mathematica中WordList寻找每个字母开头的第三个单词;这避免了一个字母和单词的插入。有尾随换行符。

A is for aardvark
B is for babble
C is for cabala
D is for dabbled
E is for eagerly
F is for fable
G is for gabble
H is for haberdashery
I is for iambus
J is for jabberer
K is for kaleidoscope
L is for label
M is for mac
N is for nacelle
O is for oak
P is for pabulum
Q is for quackery
R is for rabbinate
S is for sable
T is for tabbouleh
U is for udder
V is for vacant
W is for wad
X is for xenophobic
Y is for yachting
Z is for zapper

eep,完全忘了,谢谢
Greg Martin

3

Groovy,76 73字节

(从76字节修改为73字节,谢谢猫)

受红宝石解决方案启发:

('A'..'Z').any{i->println"$i is for ${'AntIvyUse'.find(/$i../)?:i+'at'}"}

我们使用它any代替每个,因为它更短,并且所有println语句都返回false。对于字符串中的特殊情况,我们使用String.find,它在groovy中返回match或null。在null上,我们使用elvis运算符?:返回以结尾的单词at

打印输出:

A is for Ant
B is for Bat
C is for Cat
D is for Dat
E is for Eat
F is for Fat
G is for Gat
H is for Hat
I is for Ivy
J is for Jat
K is for Kat
L is for Lat
M is for Mat
N is for Nat
O is for Oat
P is for Pat
Q is for Qat
R is for Rat
S is for Sat
T is for Tat
U is for Use
V is for Vat
W is for Wat
X is for Xat
Y is for Yat
Z is for Zat

Groovy,递归,74字节

{i->println"$i is for ${'AntIvyUse'.find(/$i../)?:i+'at'}";call(++i)}('A')

从第一个答案中打印出文本,然后引发PatternFormatException。我们以'A'递归地调用闭包,并递增,++char直到之后的字符Z引发错误为止。

Groovy,通过作弊,77个字节

有被私刑的风险:

print 'http://codegolf.stackexchange.com/q/109502'.toURL().text[21796..22189]

即读取此页面中的数据,并在开始时打印出有效答案的定义。为了我的辩护...它确实会打印出所需的答案...现在没有人编辑页面...

Groovy,使用“时间”,81个字节

使用三个字母词模式在python答案上构建:

26.times{i,c=i+65->printf"%c is for %c${'niooaauusoioaiuaaoiineeaei'[i]}t\n",c,c}

印刷品:

A is for Ant
B is for Bit
C is for Cot
D is for Dot
E is for Eat
F is for Fat
G is for Gut
H is for Hut
I is for Ist
J is for Jot
K is for Kit
L is for Lot
M is for Mat
N is for Nit
O is for Out
P is for Pat
Q is for Qat
R is for Rot
S is for Sit
T is for Tit
U is for Unt
V is for Vet
W is for Wet
X is for Xat
Y is for Yet
Z is for Zit

Groovy,通过递归main(...),83个字节

假设我们将换行符视为一个字符。

i=args?args[0]:'A'
println"$i is for ${'AntIvyUse'.find(/$i../)?:i+'at'}"
main(++i)

从第一个答案中打印出文本,然后抛出PatternSyntaxException。

Groovy,使用eachWithIndex,88个字节

'niooaauusoioaiuaaoiineeaei'.eachWithIndex{c,i->char x=i+65;println "$x is for $x${c}t"}

Groovy,使用转置,102字节

['A'..'Z','niooaauusoioaiuaaoiineeaei'as List].transpose().each{println it[0]+" is for ${it.join()}t"}

Kat是有效字词,因此您可以删除的特殊情况kit
Business Cat

编辑,谢谢。为我节省了3个字节
:)

2

05AB1E,77个字节

•‹T1qA‹rËöf#ùqÈ$>M©ÈñM£r°§°Ü]€¡3¸/©#bÍ'ò7DÉø½D—¹û©˜Òו36B3ôvy™¬"ÿ is for ÿ"}»

在线尝试!

使用以下字符串压缩:

ASSBINCATOTEATFATGOTHATILLJOTKITLOTMETNOTOATPATQUEROTSETTITUSEVATWETXISYIPZAP

转换为Base-214:

‹T1qA‹rËöf#ùqÈ$>M©ÈñM£r°§°Ü]€¡3¸/©#bÍ'ò7DÉø½D—¹û©˜Ò×

使用了3个字母的拼字游戏清单:http ://wordfinder.yourdictionary.com/letter-words/3

输出如下:

A is for Ass
B is for Bin
C is for Cat
D is for Dot
E is for Eat
F is for Fat
G is for Got
H is for Hat
I is for Ill
J is for Jot
K is for Kit
L is for Lot
M is for Met
N is for Not
O is for Oat
P is for Pat
Q is for Que
R is for Rot
S is for Set
T is for Tit
U is for Use
V is for Vat
W is for Wet
X is for Xis
Y is for Yip
Z is for Zap

版本为70字节,但不允许使用2个字母的单词。


解释:

•‹T1qA‹rËöf#ùqÈ$>M©ÈñM£r°§°Ü]€¡3¸/©#bÍ'ò7DÉø½D—¹û©˜Òו # Compressed String

36B3ô                   # Decompress, split into 3s.
     v               }  # For each word...
      y™¬"ÿ is for ÿ"   # Take first letter of word, interpolate.
                      » # Print with newlines.

qui不是英文单词。查找此内容仅显示一个拉丁词。
mbomb007'2

@ mbomb007应该是Que我知道有3个字母的拼字游戏单词,拼写错误。
魔术章鱼缸

好话:) 可以用代替,
Emigna'2


2

Lithp136个 125 117字节

((import lists)(each(split "niooaauusoioaiuaaoiineeaei" "")
#X,C::((print(chr(+ 65 C))"is for"(+(chr(+ 65 C))X "t"))))

(为便于阅读而拆分)

在线尝试!

这几乎是Python答案的一部分

  • 使用each的索引节省了11个字节
  • 通过删除无用的调用节省了8个字节 (scope #)

输出:

A is for Ant
B is for Bit
C is for Cot
D is for Dot
E is for Eat
F is for Fat
G is for Gut
H is for Hut
I is for Ist
J is for Jot
K is for Kit
L is for Lot
M is for Mat
N is for Nit
O is for Out
P is for Pat
Q is for Qat
R is for Rot
S is for Sit
T is for Tit
U is for Unt
V is for Vet
W is for Wet
X is for Xat
Y is for Yet
Z is for Zit

2
好名字!(我不是,虽然语无伦次,但是这种语言是否有这样的话?)
乔纳森·艾伦

1
谢谢!不会,语言可以发音。更重要的是它是Lisp的混蛋版本。我只是发现Lisp太难缠住我的头了,Lithp是我的接受方式,对我来说很有意义。它应该比大多数Lisp代码更具可读性。
Andrakis

1

批处理,250字节

@set s=ABCDEFGHIJKLMNOPQRSTUVWXYZ
@for %%w in (eon dellium zar jinn lbow hon nat our rk unta not lama nemonic domo uija sycho uay ye ee sunami rn ex rap enophobe ou ugzwang)do @call:c %%w
@exit/b
:c
@echo %s:~0,1% is for %s:~0,1%%1
@set s=%s:~1%

由于我永远都不会得到像样的成绩,因此我选择了最短的幽默词:

A is for Aeon
B is for Bdellium
C is for Czar
D is for Djinn
E is for Elbow
F is for Fhon
G is for Gnat
H is for Hour
I is for Irk
J is for Junta
K is for Knot
L is for Llama
M is for Mnemonic
N is for Ndomo
O is for Ouija
P is for Psycho
Q is for Quay
R is for Rye
S is for See
T is for Tsunami
U is for Urn
V is for Vex
W is for Wrap
X is for Xenophobe
Y is for You
Z is for Zugzwang

1

堆叠,72字节

72个字节有两个

65@i$'niooaauusoioaiuaaoiineeaei'{!i#::' is for '+\n+'t'+ +out i 1+@i}"!
{!n#::' is for '+\'niooaauusoioaiuaaoiineeaei'n 65-#+'t'+ +out}65 90 for

在线尝试!使用那种很棒的模式。(在您询问之前,++它将是单个令牌,因此将其+ +代替。)

两者都通过从迭代6590正确的字符序列来工作。笔记:

  • #: 是的别名 chr
  • # 是的别名 get
  • {!...}{ n : ... }(带有n参数的lambda )相同

对于73个字节:

'niooaauusoioaiuaaoiineeaei'toarr{e i:65 i+#::' is for '+\e+'t'+ +out}map

1

Mathematica 93字节

ToUpperCase@#<>" is for "<>Cases[WordList[],s_/; s~StringPart~1==#][[9]]&/@Alphabet[]//Column

产量

A is for abandoned
B is for babushka
C is for cabin
D is for dactylic
E is for eardrum
F is for fabricator
G is for gadabout
H is for habitation
I is for ice
J is for jackal
K is for kappa
L is for laboratory
M is for macaroni
N is for nagger
O is for oarsman
P is for pachysandra
Q is for quadratic
R is for rabidness
S is for saccharin
T is for tableland
U is for ulcer
V is for vacationist
W is for wadi
X is for xylene
Y is for yammer
Z is for zebra

1

Groovy,72个字节

c=65;"niooaauusoioaiuaaoiineeaei".any{printf"%c is for %<c%st\n",c++,it}

输出量

A is for Ant
B is for Bit
C is for Cot
D is for Dot
E is for Eat
F is for Fat
G is for Gut
H is for Hut
I is for Ist
J is for Jot
K is for Kit
L is for Lot
M is for Mat
N is for Nit
O is for Out
P is for Pat
Q is for Qat
R is for Rot
S is for Sit
T is for Tit
U is for Unt
V is for Vet
W is for Wet
X is for Xat
Y is for Yet
Z is for Zit

1

Python 3中,145个 137 135字节

我牺牲了一些字节,以便在每次运行时对输出进行伪随机化。想法是在其中查找至少3个字符的小写单词,/usr/share/dict/words然后使用来从该列表中选择一个id([x])%99

import re
for x in range(65,91):print("%c is for "%x+re.findall("\n(%c.{3,})"%(x+32),open('/usr/share/dict/words').read())[id([x])%99])

编辑

  • 删除,title()因为不必大写单词。
  • 将正则表达式更改为"\n(%c.{3,})"(+ 3字节)以允许删除,re.M(-5字节)。

输出示例:

A is for abacinate
B is for bacchantic
C is for caback
D is for dactylosternal
E is for eagless
F is for factful
G is for gabbroic
H is for hackneyed
I is for iambize
J is for jacutinga
K is for kadaya
L is for labra
M is for macaco
N is for nailwort
O is for oakenshaw
P is for pachysomia
Q is for quachil
R is for racer
S is for sabbath
T is for tabulable
U is for ubication
V is for vagabondism
W is for wabe
X is for xenobiosis
Y is for yacca
Z is for zeed

不确定它们是否全部有效。例如Qohele,尽管搜索发现它是一本书或大量神圣文本,但我找不到的定义。
Andrakis

1
只是注意到我的正则表达式在每个单词的末尾才匹配-会修复。
PidgeyUsedGust

修复。现在只寻找小写字母,完整的单词在那里没有名字。
PidgeyUsedGust

1

GNU sed,81 + 1(r标志)= 82字节

这是乔纳森·艾伦(Jonathan Allan)的答案中单词列表的sed实现。

s:$:AnBiCoDoEaFaGuHuIsJoKiLoMaNiOuPaQaRoSiTiUnVeWeXaYeZi:
s:(.).:\1 is for &t\n:g

除共享的结束字母外,这些单词t在第1行以串联形式给出,然后在第2行以请求的格式打印。尾随换行符出现。

运行

sed -rf alphabet_song.sed <<< ""

1

Java 7中,124个 121字节

String c(){String r="";for(char c=65;c<91;r+=c+" is for "+c+"baaonaiineioaeaoaaeileeaoi".charAt(c++-65)+"t\n");return r;}

基于@JonathanAllen的答案,因为Java没有精美的内置字典。;)我试图为整个字母表(如sor ny)或中间字母(如aor e)找到另一个结尾字母,但是大多数字母都缺少一个或两个单词,所以我也使用t了。单词是从wordhippo.com中手动选择的。

取消高尔夫:

在这里尝试。

class M{
  static String c(){String r="";for(char c=65;c<91;r+=c+" is for "+c+"baaonaiineioaeaoaaeileeaoi".charAt(c++-65)+"t\n");return r;}

  public static void main(String[] a){
    System.out.println(c());
  }
}

输出:

A is for Abt
B is for Bat
C is for Cat
D is for Dot
E is for Ent
F is for Fat
G is for Git
H is for Hit
I is for Int
J is for Jet
K is for Kit
L is for Lot
M is for Mat
N is for Net
O is for Oat
P is for Pot
Q is for Qat
R is for Rat
S is for Set
T is for Tit
U is for Ult
V is for Vet
W is for Wet
X is for Xat
Y is for Yot
Z is for Zit

1
为+1 +a+++。我喜欢写那些:P
Poke

1

PHP,91 87 86 76字节

根据乔纳森·艾伦的词汇表

for($a=A;$i<26;)echo"$a is for ",$a++,neaoaaeiseioeuuoaaiineiaei[$i++],"t
";

较旧的版本,86字节:

for($a=A;a&$c=reaoaaei0eioeuuoaaii0eiaei[$i++];)echo"$a is for ",$a++,$c?$c.t:nto,"
";

要么

for($a=A;$c=reaoaaeiHeioeuuoaaiiHeiaei[$i++];)echo"$a is for ",$a++,$c^x?$c.t:nto,"
";

用运行-nr

输出

A is for Art
B is for Bet
C is for Cat
D is for Dot
E is for Eat
F is for Fat
G is for Get
H is for Hit
I is for Into
J is for Jet
K is for Kit
L is for Lot
M is for Met
N is for Nut
O is for Out
P is for Pot
Q is for Qat
R is for Rat
S is for Sit
T is for Tit
U is for Unto
V is for Vet
W is for Wit
X is for Xat
Y is for Yet
Z is for Zit

有关怪异的字眼,请参见Ismael的答案

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.