电脑永远不会品尝到令人耳目一新的Cookie


11

github.com/JackToaster/Reassuring-Parable-Generator的启发,又受xkcd.com/1263的启发。可能的话是从派生reassuring.cfg该资源库的。

建议查看reassuring.cfg (使用第12次提交)以查看输出匹配的语法(输出是与语法匹配的所有字符串的列表)。

任务:您的程序必须输出pastebin pastebin.com/2SNAJ1VH中包含的所有7968个区分大小写的精确文本行。pastebin的副本保存在Wayback Machine中

这是来自pastebin的33条激励线的示例:

Computers can't enjoy a salad.
Computers can't enjoy a cake.
Computers can't enjoy a ice cream cone.
Computers can't enjoy a meal.
Computers can't enjoy a drink.
Computers can't enjoy a steak.
Computers can't enjoy a chicken dinner.
Computers can't enjoy a piece of cake.
Computers can't enjoy a piece of pie.
Computers can't enjoy a cookie.
Computers can't enjoy a sandwich.
Computers can't taste a salad.
Computers can't taste a cake.
Computers can't taste a ice cream cone.
Computers can't taste a meal.
Computers can't taste a drink.
Computers can't taste a steak.
Computers can't taste a chicken dinner.
Computers can't taste a piece of cake.
Computers can't taste a piece of pie.
Computers can't taste a cookie.
Computers can't taste a sandwich.
Computers can't experience eating a salad.
Computers can't experience eating a cake.
Computers can't experience eating a ice cream cone.
Computers can't experience eating a meal.
Computers can't experience eating a drink.
Computers can't experience eating a steak.
Computers can't experience eating a chicken dinner.
Computers can't experience eating a piece of cake.
Computers can't experience eating a piece of pie.
Computers can't experience eating a cookie.
Computers can't experience eating a sandwich.

挑战规则:

  • 可以根据需要以任何方式订购行输出,但是必须包括所有7968。
  • 输出应为单个平面字符串,而不是字符串列表。
  • 您的程序应不接受任何输入或不使用的输入为空。
  • 您的程序可能无法从任何在线来源获取数据。
  • 一条尾随的换行符是可选的。

这是,因此最短的代码获胜。



4
No computer {can} {action}.重复两次,并Computers {cannot_present}产生诸如“计算机无能为力”之类的短语。故意的?
darrylyeo

所有程序的输出中都必须包含pastebin中任何明显的错误(我们无法更改过去程序的规范)。reassuring.cfg只是一个示例语法,至少非常准确。
fireflame241

要在此ID中竞争,必须为输入编写一个解析器,以便列出唯一性哈哈。
魔术章鱼缸

作为参考,到Bubblegum解决方案的TIO 链接太长,无法给出答案。源代码为23270字节。
musicman523

Answers:


7

Zsh,765字节

这可能是我用zsh编写的第一本书,但是它具有令人难以置信的便利功能,即能够将数组转换为大括号扩展(尽管不如应有的便利……)。与一起运行zsh -P(计数为+1字节),这将打开RC_EXPAND_PARAM

a=able\ to
b=" be $a"
d=wonderful
i=ing\ a
o=omputer
n="No c$o "
r=ever
p=capable\ of
u=will
w=$u\ n$r
x=experienc
e=(\ {{{enjoy,tast,$x'ing eat'}$i,tast$i\ {delicious,fresh,tasty,refreshing,$d}}\ {salad,cake,'ice cream cone',meal,drink,steak,chicken\ dinner,'piece of '{cake,pie},cookie,sandwich},{understand$i,{enjoy,$x}$i{,\ {beautiful,$d,{inspir,amaz}ing,superb}}}\ {son{net,g},poem,story,play,'piece of music'}}.)
f=(${e:s/cing/ce/:s/sting/ste/:s/ding/d/:s/ying/y})
l=($w won\'t$b {$w,n$r\ $u}{$b,' have the ability to'})
v=($l "won't $r$b")
k=({ca,wo}n\'t $l is{"n't ",\ un}$a)
c=(C$o\s A\ c$o)
printf %s\\n $c\ $k$f C$o's '$v$f $n{can,is\ $a,$u\ $r$b,"is $r going to",{can,$u}\ $r}$f{,} $c\ {is{\ in,"n't "}$p,"cannot $x"e}$e $n{{is,$u\ be}\ $p,"can $x"e}$e

在线尝试!


4

JavaScript(ES6),1234 1091字节

这是一个不错的字节数开始!是时候打高尔夫球了。

f=

_=>(G=`beautiful|wonderful|inspiring|amazing|superb
sonnet|poem|story|play|song${p=`|piece of `}music
cake${p}cake${p}pie|salad|ice cream cone|meal|drink|steak|chicken dinner|cookie|sandwich
delicious|fresh|tasty|refreshing|wonderful
can|is ${a=`able to`}|is ever going to|can ever|will ever${b=` be `+a}|will ever
is ${C=`capable of`}|will be ${C}|can${E=` ${e=`experience`}
${w=`will never`}${b}|${w}${h=` have the ability to|never will`}${h}${b}|won't${b}|${w}|won't`} ever${b}
isn't ${C}|is in${C}|cannot${E}|can't|isn't ${a}|is un${a}`.split`
`.map(l=>l.split`|`),F=S=>[].concat(...S.split`|`.map(s=>eval(s.match(/\d/g).map(n=>`for(f[${n}]of G[${n}])`).join``+`A.push(s.replace(/\\d/g,n=>' '+f[n]));A`,A=[]))),G[9]=F(p=`enjoy a2|taste a2|${e} eating a2|taste a32|enjoy a1|${e} a1|enjoy a01|understand a1|${e} a01`),G[9]=F(p=`${e=`enjoy`} a2|taste a2|${e} eating a2|taste a32|enjoy a1|${e} a1|enjoy a01|understand a1|${e} a01`),G[0]=F(p.replace(/([^g])e? (a|e)/g,'$1ing $2')),F(`C${o=`omputer`}s89.|A c${o}89.|C${o}s69.|No c${o}49.|C${o}s70.|A c${o}70.|No c${o}50.|No c${o}49.`).join`
`)

document.write('<pre>'+f())

少打高尔夫球:

f=

_=>(

G=`beautiful|wonderful|inspiring|amazing|superb
sonnet|poem|story|play|song${p=`|piece of `}music
cake${p}cake${p}pie|salad|ice cream cone|meal|drink|steak|chicken dinner|cookie|sandwich
delicious|fresh|tasty|refreshing|wonderful
can|is ${a=`able to`}|is ever going to|can ever|will ever${b=` be `+a}|will ever
is ${C=`capable of`}|will be ${C}|can${E=` ${e=`experience`}
${w=`will never`}${b}|${w}${h=` have the ability to|never will`}${h}${b}|won't${b}|${w}|won't`} ever${b}
isn't ${C}|is in${C}|cannot${E}|can't|isn't ${a}|is un${a}`.split`
`.map(l=>l.split`|`),

F=S=>[].concat(...S.split`|`.map(s=>eval(s.match(/\d/g).map(n=>`for(f[${n}]of G[${n}])`).join``+`A.push(s.replace(/\\d/g,n=>' '+f[n]));A`,A=[]))),

G[9]=F(p=`enjoy a2|taste a2|${e} eating a2|taste a32|enjoy a1|${e} a1|enjoy a01|understand a1|${e} a01`),
G[9]=F(p=`${e=`enjoy`} a2|taste a2|${e} eating a2|taste a32|enjoy a1|${e} a1|enjoy a01|understand a1|${e} a01`),

G[0]=F(p.replace(/([^g])e? (a|e)/g,'$1ing $2')),

F(`C${o=`omputer`}s89.|A c${o}89.|C${o}s69.|No c${o}49.|C${o}s70.|A c${o}70.|No c${o}50.|No c${o}49.`).join`
`

)

document.write('<pre>'+f())


怎么样?

(这是迄今为止我最喜欢的高尔夫之一!)

语法存储在array中G,其结果为:

[["beautiful","wonderful","inspiring","amazing","superb"],
 ["sonnet","poem","story","play","song","piece of music"],
 ["salad","cake","ice cream cone","meal","drink","steak","chicken dinner","piece of cake","piece of pie","cookie","sandwich"],
 ["delicious","fresh","tasty","refreshing","wonderful"],
 ["is capable of","can experience","will be capable of"],
 ["can","is able to","is ever going to","can ever","will ever be able to","will ever"],
 ["will never be able to","will never have the ability to","never will have the ability to","never will be able to","won't ever be able to","will never","won't be able to"],
 ["is incapable of","isn't capable of","cannot experience"],
 ["can't","won't","will never","won't be able to","will never be able to","will never have the ability to","never will have the ability to","never will be able to","isn't able to","is unable to"]]

F是一个通过定界符分割字符串|并对其进行迭代的函数。到目前为止,一切都很好。

F=S=>[].concat(...S.split`|`.map( ... )),

现在这个内部函数怎么了?

s=>eval(
    s.match(/\d/g).map(n=>`for(F[${n}]of G[${n}])`).join``+
    `A.push(s.replace(/\\d/g,n=>F[n]));A`,
    A=[]
)

首先我们初始化一个数组A。然后,我们在传递的字符串中找到所有数字s并构建一个子程序:使用每个数字n,我们生成一个for- of循环,该循环遍历其中的条目G[n](存储为的属性F,因为JavaScript中的函数也是对象)。然后将这些循环一个接一个地附加。

例如,为这样生成的子程序s="1 2 3"启动如下:

for(F[1]of G[1])for(F[2]of G[2])for(F[3]of G[3])

在每次迭代中,子程序都会s用存储在中的对应替换替换其中的每个数字F[n],并将结果压入A。子程序被evaled并A隐式返回。

for(F[1]of G[1])for(F[2]of G[2])for(F[3]of G[3])A.push(s.replace(/\d/g,n=>F[n]));A

使用F,程序的其余部分仅根据已经存在的生产规则来构建语法的其余部分。替换仅由中的个位数索引定义G


好东西!但是,如果未调用该函数,这似乎会崩溃f。因此,f=应将其添加到字节数中。
Arnauld

(我认为可以通过重新使用F代替来解决f。)
Arnauld

@Arnauld很好。
darrylyeo

4

PHP,877字节

啊,真有趣!

for($p="piece of ";$c="AEIMQUY]aeBFJNRVZ^bfQUY]iIMCGKOSWmqunrvoswCGKOSW"[$m++];)foreach([409,T19,"71 eat59",T19delicious,T1916,T19Ty,T19re165,T1914,409,719,40912,40914,409105,409115,40913,understand09,71912,71914,719105,719115,71913]as$i=>$v)foreach($i<8?[salad,cake,"ice cream cone",meal,drink,steak,"chicken dinner",$p.cake,$p.pie,cookie,sandwich]:[sonnet,poem,story,play,song,$p.music]as$u)echo trim(strtr([C17s,"A c17","No c17"][$o=3&$d=ord($c)-65]." ".($o&2?[6,is3,"is 8 go5 to","6 8","2 8 be3","2 8",11=>"is 15","6 7e","2 be 15"]:["6't",$t="won't",$w="2 n8","$t be3","2 n8 be3",$w.$z=" have the ability to","n8 2$z","n8 2 be3","isn't3","is unable to","$t 8 be3","is in15","isn't 15","6not 7e"])[$d/4]." $v",($c>l?[ing,ing]:["",e])+[2=>will," able to",enjoy,ing,can,experienc,ever," a ",inspir,amaz,beautiful,superb,wonderful,"capable of",fresh,omputer,T=>tast]))," $u.
";

如果可以,请尝试尝试再挖掘一个字节。

不打高尔夫球

while($c="AEIMQUY]aeBFJNRVZ^bfQUY]iIMCGKOSWmqunrvoswCGKOSW"[$p++])
    foreach(["enjoy0 a","tast1 a","experienc1 eating a","tast1 a delicious","tast1 a fresh","tast1 a tasty","tast1 a refreshing","tast1 a wonderful",
    "enjoy0 a","experienc1 a","enjoy0 a beautiful","enjoy0 a wonderful","enjoy0 a inspiring","enjoy0 a amazing","enjoy0 a superb",
    "understand0 a","experienc1 a beautiful","experienc1 a wonderful","experienc1 a inspiring","experienc1 a amazing","experienc1 a superb"]as$i=>$v)
        foreach($i<8
            ?[salad,cake,"ice cream cone",meal,drink,steak,"chicken dinner","piece of cake","piece of pie",cookie,sandwich]
            :[sonnet,poem,story,play,song,"piece of music"]
        as$u)
            echo[Computers,"A computer","No computer"][$o=3&$d=ord($c)-65]," ",
                ($o&2
                    ?[can,"is able to","is ever going to","can ever","will ever be able to","will ever",11=>"is capable of","can experience","will be capable of"]
                    :["can't","won't","will never","won't be able to","will never be able to","will never have the ability to","never will have the ability to","never will be able to","isn't able to","is unable to","won't ever be able to","is incapable of","isn't capable of","cannot experience"]
                )[$d/4]," ",
                strtr($v,$c>l?[ing,ing]:["",e]),
                " $u.\n"
            ;

说明

输出可分为48个块,每个块166行。在每个块内,每行以Computers|A computer|No computer14个负数(for ComputersA computer)或9个正数(for No computer)功能之一开始。
我将这些块分别编码为6位(3个不同的主题->低2位;正和负大写字母共享键->高4位),并且(很明显)添加了65个以将值用作ASCII代码。

在这些块中,用于11种不同食物的8种动词/形容词组合和用于6种不同艺术的13种不同的组合,总是以相同的顺序进行;因此,只需使用动词/形容词键来确定它们是否在下一个循环中列出食物或饮料,就可以轻松地将它们循环浏览。

剩下的一个棘手的部分:一些大写字母要求动词为动名词。并且某些动词e在转换中丢失了。上限索引告诉我们是否必要。
(并且由于编码中的位顺序,我可以简单地使用ASCII字符进行比较)。
但是如何?用正则表达式了一段时间后杂耍,我只是把1其中e已被替换ing并且0其中ing有要追加,让strtr做的工作。

这就是上面非高尔夫球版本的故事。(打包的1199字节)


高尔夫主要包括3个步骤:

  1. 最常用的字符序列存储在变量中。
  2. strtr扩展到除了主题以外的所有东西,以便将变量移至strtr
  3. 大多数序列从变量移到strtr

第19个单词tast用大写字母代替,以消除几个引号。


我想知道如果我也对动词/形容词组合进行编码会发生什么。
也许我可以击败Zsh;但我不确定是否想尝试一下。


1

视网膜,1249 1192字节


CFs 1 5.¶A cF 1 5.¶C O nG beH 5.¶C O nGKtheJto 5.¶C nG OKtheJto 5.¶C nG O beH 5.¶C won't G beH 5.¶C O nG 5.¶C won't beH 5.¶nNo cF 3 5.¶C 2 6.¶A cF 2 6.¶nNo cF 4 6.¶nNo cF 3 5.
1
can't$%'¶$%`won't$%'¶$%`O nG$%'¶$%`won't beH$%'¶$%`O nG beH$%'¶$%`O nGKtheJto$%'¶$%`nG OKtheJto$%'¶$%`nG O beH$%'¶$%`isn'tH$%'¶$%`is unIto
2
is incapIof$%'¶$%`isn't capIof$%'¶$%`cannot De
3
can$%'¶$%`isH$%'¶$%`is G goQ to$%'¶$%`can G$%'¶$%`O G beH$%'¶$%`O G
4
is capIof$%'¶$%`can De$%'¶$%`O be capIof
5
E a 8$%'¶$%`Le a 8$%'¶$%`De eatQ a 8$%'¶$%`Le a 7 8$%'¶$%`E a 9$%'¶$%`De a 9$%'¶$%`E a B 9$%'¶$%`P a 9$%'¶$%`De a B 9
6
EQ a 8$%'¶$%`LQ a 8$%'¶$%`DQ eatQ a 8$%'¶$%`LQ a 7 8$%'¶$%`EQ a 9$%'¶$%`DQ a 9$%'¶$%`EQ a B 9$%'¶$%`PQ a 9$%'¶$%`DQ a B 9
7
delicious$%'¶$%`fresh$%'¶$%`Ly$%'¶$%`refreshQ$%'¶$%`wonderful
8
salad$%'¶$%`cake$%'¶$%`ice cream cone$%'¶$%`meal$%'¶$%`drink$%'¶$%`steak$%'¶$%`chicken dinner$%'¶$%`Mof cake$%'¶$%`Mof pie$%'¶$%`cookie$%'¶$%`sandwich
9
sonnet$%'¶$%`poem$%'¶$%`story$%'¶$%`play$%'¶$%`song$%'¶$%`Mof music
B
beautiful$%'¶$%`wonderful$%'¶$%`inspirQ$%'¶$%`amazQ$%'¶$%`superb
D
experienc
E
enjoy
F
omputer
G
ever
H
 Ito
I
able 
J
 ability 
K
 have 
L
tast
M
piece 
O
will
P
understand
Q
ing

输出超出TIO限制。我想使用%`阶段来避免所有这些,$%'¶$%`但是出于某种原因却不能满足我的要求。编辑:由于@ fireflame241,节省了57个字节。


还有一些压缩空间:ing和“ Ito”分别使用了几次。每次对1,,2和的调用5 都在空格之前和之后,因此可以将它们放在替换中。同样,6并且7始终跟随一个句点。3似乎只能使用一次。
fireflame241

@ fireflame241我无法修改数字,因为它们需要重复几次替换,但感谢其他想法!
尼尔

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.