高尔夫英语–使用收缩


9

我对Stack Exchange内容的嘲笑程度不如对此。我想大家都会喜欢这个挑战,因为它受到了那里的启发。

您将编写一个代码高尔夫的函数或程序,即它必须尽可能地短。

给定文本,请返回(无论以何种方式)根据该表将要尽可能多地收缩的文本。

您不应从表中提取信息,而必须在代码中包含所有必需的信息。

所有违约规则都不应被打破,因为我们不会有任何不正当竞争。

你不需要考虑文本,如果它不大写,如表,所以你不能转换you all WOULD not haveYou all would not havey'all'dn't've

您可以只匹配旧的撇号(U + 0027)或任何不错的撇号;随便你

↑上方的示例输入,↓下方的相应输出

我对StackExchange内容的嘲笑远不及。我认为,所有人都会喜欢这个挑战,因为那里的事物启发了我们。

您将编写一个具有代码功能的函数或程序,即它必须尽可能地短。

给定一个文本,请(通过任何方式)返回该文本,该文本将根据该表尽可能多地收缩。

您不必从表中获取信息,而必须在代码中包含所有必需的信息。

所有违约规则都不应被打破,因为我们不会有任何不公平的竞争。

如果文本没有像表中那样大写,则无需考虑,因此您不必转换 you all WOULD not haveYou all would not havey'all'dn't've

您可以只匹配好撇号(U + 0027)或 任何好的;随便你


你的例子是错误的,对吧?
西蒙斯(Simmons)

@ N ^ BZ是的,就是那个!
西蒙斯(Simmons)

Answers:


4

Perl,3429 1095字节

压缩文本。

脚本的uuencoded版本

@a=split('!',uncompress(<DATA>.<DATA>));while(<>){chomp;$l=$_;for$d(@a){chomp $d;($x,$y)=split(/,/,$d);if($l=~m/$y/){$l=~s/$y/$x/g}}print "$l\n"}
__DATA__
x<9c>uVK<b2><a3>0^L<dc><e7>^Tdņ<8b>p^Lϋ'<b8>^FpUL<e2><e2><f6><a3><af>-<9b><bc>^Mv<b7>d<a9>%<c4><c7>m<fb>xLn^[<f6>x<dc><ee><ee><e5>      <be><<e3>^_<87>^P<ae>^B<e3>{}<8c>^_?<d1>fX<dc><c7>^K    n<95>^G<df><ce>V^M<b7><fb>#^P^C<8b><e0><e8>^S^Q<b0>*Ø<d1>3<9e>1<ec><cf>ሷ<fb><e2>4^[<ec>L.<e6><95>D<9c>^X'<c5>^_<cf><c4>G<aa>[<fc><f8><98>^V^O<e7>^_^L(<a8>^_<b2><a9>N}<88>#<b8><ae><88><d3><e2><d6><d5><e0>^\^DrR^L<9a>J<96>$D<e3>^P:{@s̘.<e6>^A<da>c<a1><a6>^G^B<f3>!<c3>      <81>H<84>9|<81><a1>A<d8><db><db>}<86>`3W;s<b1>sS+<db>%Ռ<89>f<ad>S^P'<9d><c7>^M<f6>n<c3>^]<f7>t^^jWg^N<cc>!^CU<ab><a5><86>^C2<84><83>% @W<c0>V<84><fa><88>^L<80><90>^Y<b0>^H)<98><a5>^@<e4>^LGm8rB4^N<aa>b<f5><e8>^@<d7><e1>^M^N<9b>^[<dd>6m<ee><81><f5>l<e1><b9>^\2]<b4>7<f3><a5><b6>j^P<ae>:<8b><e3>;<b1>^_<ac><e2>^F;<f2>B<86><9d>v<ef>i\qe<a7>8<fe><ac><f1><e7><df>^T<ff>^N^G<8c>^C^A`<d7>q<8a>؈<f8><96><f4><b4><e1>#<d0>^Sd<a8>5<ca><e0><bc>&^]<ea><a4>S<9d><ba><b1><ae>~<d2><e7>ē<9c><ea>h^[<86>{<9d>tx<93>^]ob<95><ea><9c><c2><c5>'<90><8b><be>FxW$<99>^W<89>Xj<f7><8b>՘<80><8d><9b><ff>^S^_'<d6>"[)<bc>^X(<9a>ښ^V|9<ab><cd>(&<95><d3>^F0<b2><d4>^S;<a5>N<da><c0>o6i<a5><9a><92>՝<be>^[<82><f0>q<f7><a2>^Uv<b5>L<a2>U$Z<fa>"<db>s<a6>D4<88>6<b4><18><a5><8a>FC2^Z<d2>7Z^E^_^K<bc><b3>%5<ed><ab>h1<a9>l<b6><f6>¯<e7><8d>x6<8a>H<b6><9a>^B<be>Xk^QlL<8d><ae><f4><9b>        <8b>9^VG<af>^]\%^NQ<89>^Y:m     ><e3>_<d8>wZ<b9>p<a1><b0>hfmm<bf>^T<ca><e4>K<fd>Ử\*<81>SOI▒%w^]g<a2><fb>Q.^^<9d>Y-<dd>A{<c8><f0>ƻ^KU<bf>^P<e4>A<ed><f4><e5>a^Q<ae>^Q^X<f8><ad>fS<ad>k^S^X=~<89><ab><b7> <a8><97>^D<d4><f6><9d>6Fw\<93>s<ce><f1>^H<89>?^]<b8>ώ@Ɩg<87>^?%p=<e8><a7>$<f3><cf>Fַb<c6>[<99><e5><be>#<90>²<bf><f4>=<cb>H<e4>v^^4<82>t5<fb>ڝ<ec><fb>ސUy<82>/r<a3><8a>^A<f1>!<f5><e5><9f><\E<ac><8c>7<ae>z?^ZN<a2>"<85>q<91><e2><c8><<f3><b9><^D<96>^H^]<e6>^?^Pb>^ϐ<a0>^E<f4><a0><93><df>5J%8?^Z<b4><f2><9f>Q<96><89><cf><f5>!h<a9>pa4?r$<80>O<b2><82>H<e1><a3><dc>/<84><ec>^S<db>{R<fc><f4><ae>^@AM<8a><b5>o<85>ѮEnZԞE<92>^TU<b5><c2> H<f2>jƓÝ%<dc><c9><e1>N^Mw<d2><f9>S<c3>)<a4>pQ'<a6>^[^W<fa><c1>V^R<b1>|<90><9b>b<cd><e7><f8>2<b3><fa>16o<89>s<84>^FLg|^O<d4>^H<82>e^L<bf>x]]<ac><99>^F<bf>ڋl<b5>6<a7><f5><95>И/<e7><eb>S<af>^<8d>^]<e8><f8><86>[<8d>^\<8d>^DA<cd><d3>(,~2^RHH4^Y      <c3><d4><d8>/<91><fc><f2><8a><8b>F},<91><ae>ҍb<e2>^K    <ff><92><91>z\<ba><fa>^_<bf><fc><b5><8f>

perl -MCompress::Zlib script.pl <sample.txt
You will write a function or program that's code-golf, i.e. it'd've to be as short as you can make it.
Given a text, return (both by any means) the text where you'll have contracted as many words as possible according this table.
You shan't pull information from the table, rather you must've all necessary information included in your code.
All default rules oughtn't to be broken as we'lln't've any unfair competition.
You needn't consider text if 'tisn't capitalized as in the table, so you mustn't convert y'all WOULD not've or You all wouldn't've to y'all'dn't've.
You may match just the good ol' apostrophe (U+0027) or any nice ones; whatever you wanna.

我想您可以perl -p0 s1-golfed.pl用来摆脱包装后的while循环:$/="\n";for$d(<DATA>){($x)=$d=~/(.*),(.*)\b/;s/$2/$x/g}
andlrc

并消除对以下内容的需求$xfor$d(<DATA>){$d=~s~(.*),(.*)\b~"s/$2/$1/g"~eeg}
andlrc
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.