以尽可能少的字节回显以下内容:
I'm Slim Shady. Yes, I'm the real Shady.
All you other Slim Shadys are just imitating.
So, won't the real Slim Shady please stand up?
Please stand up. Please stand up.
以下五个单词必须在您的代码中完全出现一次:
I'm
Slim
Shady
real
stand
以尽可能少的字节回显以下内容:
I'm Slim Shady. Yes, I'm the real Shady.
All you other Slim Shadys are just imitating.
So, won't the real Slim Shady please stand up?
Please stand up. Please stand up.
以下五个单词必须在您的代码中完全出现一次:
I'm
Slim
Shady
real
stand
Answers:
print"{0}{1}{2}. Yes, {0}{3}{2}.\nAll you other {1}{2}s are just imitating.\nSo, won't {3}{1}{2} p{4}?\nP{4}. P{4}.".format("I'm ","Slim ","Shady","the real ","lease stand up")
自然,与其他压缩解决方案具有相同的想法(尽管是独立获得的)。
print"{0}{1}{2}. Yes, {0}{3}{2}.\nAll you other{1}{2}s are just imitating.\nSo, won't{3}{1}{2} p{4}?\nP{4}. P{4}.".format("I'm"," Slim"," Shady"," the real","lease stand up")
Brainfuck 1923字节
请享用...
-[------->+<]>.+[-->+<]>++.---[->+++<]>+.
[->+++++<]>-.>-[--->+<]>--.--[--->++++<]
>.---.++++.[->+++++<]>-.>-[--->+<]>--.>+
[----->+++<]>+.-------.+++.+[--->+<]>++.
-----[++>---<]>.++[--->++<]>.--[->+++<]>-.
[->++++<]>+.[--->+<]>----.-[++>---<]>+.
------------.++++[->++<]>+.+[-->+<]>++.---
[->+++<]>+.[->+++++<]>-.---[->++++<]
>.------------.---.--[--->+<]>-.---[----->++<]
>.-------------.----.+++++++++++.[++>---<]
>--.>-[--->+<]>--.>+[----->+++<]>+.-------.
+++.+[--->+<]>++.-----[++>---<]>.>
++++++++++.+++[->+++++<]>.[--->+<]>+..
[++>---<]>--.--[->++++<]>+.----------.++++++.-
[---->+<]>+++.+++++[->+++<]
>.+++++.------------.---.+++++++++++++.
[-->+++++<]>+++.>-[--->+<]>--.--
[--->++++<]>.---.++++.[->+++++<]>-.>-
[--->+I'm<]>--.>+[----->+++<]>+.-------.+++.+
[--->+<]>++.------.+[---->+<]>+++.[->+++<]>+.--
[--->+<]>---.-------------.--[--->+<]>-.-
[--->++<]>.+++++++++++.--.+.
[---Slim->+<]>+++.-[--->++<]>-.++++.----.
+++++++++++.+[->+++<]>++.--[--->+<]
>-.-----------.+++++.-------.--[->+++<]>-.
>++++++++++.>-[--->+<]>--.[--->+<]>--.
[->+++++<]>+.------------.--[->++++<]>-.
--------.-.[++>---<]>++.[->+++<]>-.[---->+
<]>+++.---[->++++<]>.------------.---.--[---
>+<]>-.---[----->Shady++<]>.-------------.-
---.+++++++++++.[++>---<]>--.>-[--->+<]
>--.--[--->++++<]>.---.++++.[->+++++<]
>-.>-[--->+<]>--.>+[----->+++<]>+.-------.
+++.+[--->+<]>++.-[---->+<]>++.[-->+++++++<]
>.----.-------.----.--[--->+<]>--.++++[->+++<]
>.--[--->+<]>-.---[->++++<]>-.+.+[->+++<]
>++.+++++++++++++.----------.-[--->+<]
>-.---[->++++<]>+.-----.[--->++++<]>-.>
++++++++++.[->++++++++<]>.+[--->++++<]
>.---real----.----.--[--->+<]>--.++++[->+++<]
>.--[--->+<]>-.---[->++++<]>-.+.+[->+++<]
>++.+++++++++++++.----------.-[--->+<]>-.---
[->++++<]>+.-----.[->+++++<]>--.++[--->++<]
>.[-->stand+++++<]>.+[--->++++<]>
.-------.----.--[--->+<]>--.++++[->+++<]
>.--[--->+<]>-.---[->++++<]>-.+.+[->+++<]
>++.+++++++++++++.----------.-[--->+<]
>-.---[->++++<]>+.-----.[->+++++<]>--.
标准环孔
$_="01. Yes, 02X.
All you other1s are just imitating.
So, won't21 p3?
P3. P3.";s/\d/("I'm"," SlimX"," the real","lease stand up")[$&]/ge;s/X/ Shady/g;print
$><<"012. Yes, 032.
All you other12s are just imitating.
So, won't312 p4?
P4. P4.".gsub(/\d/){%W{I'm \ Slim \ Shady \ the\ real lease\ stand\ up}[$&.hex]}
在帮助了一些如何拆分填充字符串的人之后,我决定尝试一下他们的替代回调想法。;)
#{h+a}
短于"+h+a+"
,并且#{d+h+a}
短于"+d+h+a+"
。
#{h}#{a}
。
h=" Slim"+a=" Shady"
,而替换puts
为$><<
。
.gsub(/\d/){%W{I'm \ Slim \ Shady \ the\ real lease\ stand\ up}[$&.hex]}
另一种语言一样
alert("012. Yes, 05326All you other12s are just imitating6So, won't5312 p4?\nP4. P4."
.replace(/\d/g,x=>"I'm1 Slim1 Shady1real1lease stand up1 the 1.\n".split(1)[x]))
说明:将第一个字符串中的每个数字替换为数组中的相应字符串 ["I'm"," Slim"," Shady","real","lease stand up"," the ",".\n"]
在PPCG上使用新规则进行了修订(功能返回的输出,对功能的挑战没有任何限制,可以更新为158)。请参见代码段
F=
_=>`012. Yes, 0532.
All you other12s are just imitating.
So, won't5312 p4?
P4. P4.`.replace(/\d/g,x=>"I'm, Slim, Shady,real,lease stand up, the ".split`,`[x])
console.log(F())
replace
函数中使用模板文字并用\n
实际的换行符代替来保存字节。
"I'm| Slim| Shady| the real|lease stand up|432. Yes, 412.
All you other32s are just imitating.
So, won't132 p0?
P0. P0."'|/~5,{`/\*}/
我认为,如果您替换为'|
,它也可以在GolfScript中使用"|"
"I'm ":i"Slim ":|"Shady":y". Yes, "i"the real ":!y".
All you other "|y"s are just imitating.
So, won't "!|y" p""lease stand up":l"?
P"l". P"l"."
\n
,并n
与实际换行,并选择非字母数字变量名称(例如,&
),以消除他们周围的空白。
并用行分隔符混淆(只是为了好玩)。根据这个答案
Function p()
e = "Slim ": m = "Shady": i = "I'm ": n = "lease stand up": s = "real ": a = "."
p = i & e & m & ". Yes, " & i & "the " & s & m & a & Chr(10) & "All you other " & e & m & "s are just imitating." & Chr(10) & "So, won't the " & s & e & m & " p" & n & Chr(10) & "P" & n & ". P" & n & a
End Function
从的即时窗口调用?p
。
307包含?p
。
a = "."
掉,我认为您可以删除一些字节
<?="I'm Slim Shady".gzinflate("]Œ1
„0E{Á;üÎFr…ÅÒNHe9à°F&‰d&,Þ~Avmßûï;̬=Æ.ÂVFaø•–ÃµÍ ‚#WäÓx ñR
*Œª!Ä`d!½Ï¹Ï=>9uöót7Ø…Ij”ÔýÕ6Ó?qx‚/");@realstand;
十六进制转储:
0000000 3f3c 223d 2749 206d 6c53 6d69 5320 6168
0000010 7964 2e22 7a67 6e69 6c66 7461 2865 5d22
0000020 318c 840a 1030 7b45 3bc1 cefc 7246 c585
0000030 4ed2 6548 e039 46b0 8926 2664 de2c 057e
0000040 7641 df6d effb cc3b 3dac 2ec6 56c2 6146
0000050 f812 9695 b5c3 20cd 2382 e457 14d3 0978
0000060 52f1 2a0a ad8c 21aa 60c4 2164 cfbd cfb9
0000070 3e3d 7539 f3f6 3774 85d8 1949 946a d416
0000080 d5fd d336 713f 8278 222f 3b29 7240 6165
0000090 736c 6174 646e 003b
0000097
读取短裤(16位),提取3个5位整数作为查找表的索引。
<?$a=str_split(" .Yes,AlyouthrajimngSw'pP?
")+[27=>"I'm ",'Slim ',@Shady,'the real ','lease stand up'];$b=unpack(@v26,'o…~:tç (ƒ-4€t£9ê`0BË-SBT $2U`Y{ÿXg |ác');foreach($b as$c)echo$a[$c>>10],$a[$c>>5&31],$a[$c&31];
十六进制转储:
0000000 3f3c 6124 733d 7274 735f 6c70 7469 2228
0000010 2e20 6559 2c73 6c41 6f79 7475 7268 6a61
0000020 6d69 676e 7753 7027 3f50 220a 2b29 325b
0000030 3d37 223e 2749 206d 2c22 5327 696c 206d
0000040 2c27 5340 6168 7964 272c 6874 2065 6572
0000050 6c61 2720 272c 656c 7361 2065 7473 6e61
0000060 2064 7075 5d27 243b 3d62 6e75 6170 6b63
0000070 4028 3276 2c36 9d27 026f 8504 7e0c 3a03
0000080 e774 0918 0901 8328 1c2d 8034 a374 ea39
0000090 6001 3011 cb42 532d 5442 a007 3224 6055
00000a0 9d59 ff7b 5802 2067 e17c 2763 3b29 6f66
00000b0 6572 6361 2868 6224 6120 2473 2963 6365
00000c0 6f68 6124 245b 3e63 313e 5d30 242c 5b61
00000d0 6324 3e3e 2635 3133 2c5d 6124 245b 2663
00000e0 3133 3b5d
00000e4
通过移动内存
不是最短的,但是可以更快吗?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *s;
void m (int d, int f, int p)
{
memmove (s+p+f, s+p, strlen(s)-p+1); // Shift a part of the string to make room for our insertion
memcpy (s+p, s+d, f); // Copy the desired reference in place
}
int main ()
{
s = malloc (168);
strcpy (s,"I'm Slim Shady. Yes, the real.\nAll you others are just imitating.\nSo, won't the please stand up?\nP. ");
m (0, 4, 21);
m (8, 6, 33);
m (3, 11, 54);
m (28, 5, 100);
m (3, 11, 105);
m (118, 14, 135);
m (134, 16, 151);
puts (s);
}
缩小后的长度为374个字符。
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char*s;void m(int d,int f,int p){memmove(s+p+f,s+p,strlen(s)-p+1);memcpy(s+p,s+d,f);}int main(){s=malloc(168);strcpy(s,"I'm Slim Shady. Yes, the real.\nAll you others are just imitating.\nSo, won't the please stand up?\nP. ");m(0,4,21);m(8,6,33);m(3,11,54);m(28,5,100);m(3,11,105);m(118,14,135);m(134,16,151);puts(s);}
char s[168]="I'm Slim Shady. Yes, the real.\nAll you others are just imitating.\nSo, won't the please stand up?\nP. ";m(d,f,p){memmove(s+p+f,s+p,strlen(s)-p+1);memcpy(s+p,s+d,f);}main(){m(0,4,21);m(8,6,33);m(3,11,54);m(28,5,100);m(3,11,105);m(118,14,135);m(134,16,151);puts(s);}
我第一次学习高尔夫,同时学习Java。发布它是因为它击败了其他(功能齐全)的Java条目和Haskell条目。
class S{public static void main(String[]a){String s="I'm",t=" Slim",u=" Shady",v=" the real",w="lease stand up";System.out.print(s+t+u+". Yes, "+s+v+u+".\nAll you other"+t+u+"s are just imitating.\nSo, won't"+v+t+u+" p"+w+"?\nP"+w+". P"+w+".");}}
class P{static void Main(){System.Console.Write("{0}{1}{2}. Yes, {0}{3}{2}.\nAll you other {1}{2}s are just imitating.\nSo, won't {3}{1}{2} p{4}?\nP{4}. P{4}.", "I'm ","Slim ","Shady","the real ","lease stand up");}}
现在有了适当的大写字母和新行
WriteLine("{0}{1}","I'm ","Slim ")
。
.Write()
代替.WriteLine()
。即使需要,.Write()
带a \n
也较短。
我讨厌换行
Module M
Sub Main
Console.Write("{0}{1}{2}. Yes, {0}{3}{2}.{5}All you other {1}{2}s are just imitating.{5}So, won't {3}{1}{2} p{4}?{5}P{4}. P{4}.","I'm ","Slim ","Shady","the real ","lease stand up",vbCr)
End Sub
End Module
现在,输出中有适当的大小写和换行符,并且没有制表符 *
谢谢VB的帮助 vbCrLf
VBA 343字节
Sub EMINEM()
e = "Slim "
m = "Shady"
i = "I'm "
n = "lease stand up"
em = "real "
MsgBox i & e & m & ". Yes, " & i & "the " & em & m & "." & Chr(10) & "All you other " & e & m & "s are just imitating." & Chr(10) & "So, won't the " & em & e & m & " p" & n & Chr(10) & "P" & n & ". P" & n & "."
End Sub
?
吗?
"{0}{1}{2}. Yes, {0}{3}{2}.`nAll you other {1}{2}s are just imitating.`nSo, won't {3}{1}{2} p{4}?`nP{4}. P{4}."-f"I'm ","Slim ","Shady","the real ","lease stand up"
某种程度上,我的回答变得很像@nneonneo,尽管这并不是我的初衷...
h=" Shady"i="I'm"s=" Slim"..h r=" the real"u="lease stand up"io.write(i,s,". Yes, ",i,r,h,".\nAll you other",s,"s are just imitating.\nSo, won't",r,s," p",u,"?\nP",u,". P",u,".")
取消高尔夫并扩展一些
h=" Shady"
i="I'm"
s=" Slim"..h
r=" the real"
u="lease stand up"
io.write(i,s,". Yes, ",i,r,h,".\nAll you other",s,"s are just imitating.\nSo, won't",r,s," p",u,"?\nP",u,". P",u,".")
不像ososifrage的回答那么短,但是我想分享CamelCaseCompression,它没有人使用过,并允许删除许多空格和引号。
不过,确实需要更长的文字才能真正受益。
$_="0 1 2. Yes, 03 2.
AllYouOther 1 2sAreJustImitating.
So, won't3 1 24?
4. 4.";s/\d/qw(I'm Slim Shady TheReal PleaseStandUp)[$&]/ge;s/\B([A-Z])/ \L\2/g;print
编辑:按照Thaylon的建议,s/(\S)([A-Z])/\1 \L\2/g
替换已缩短了四个字符。但是,这在逗号大写字母上没有体现,因此必须在“不会”之前插入一个额外的空间。
PYTHON:198个 193字节
i,s,h,r,t="I'm ","Slim ","Shady","real ","lease stand up"
print i+s+h+". Yes, "+i+"the "+r+h+".\nAll you other "+s+h+"s are just imitating.\nSo, won't the "+r+s+h+" p"+t+"?\n"+"P"+t+'. P'+t+'.'
please
到变量保持stand up
和摆脱你的g
变量,并可能删除/n
你不需要他们
class P{static void Main(){System.Console.Write("{0}{1}{2}. Yes, {0} the{3} {2}.All you other{1}{2}s are just imitating.So, won't the{3}{1}{2} please{4}up?Please{4}up. Please{4}up.","I'm"," Slim ","Shady"," real"," stand ");}}
Java有点冗长,但这是我的尝试:
class P{public static void main(String[]c){String s=" Shady",t=" the real",l="lease stand up",i=" Slim",m="I'm";System.out.format("%s%s%s. Yes, %s%s%s.\nAll you other%s%ss are just imitating.\nSo, won't%s%s%s p%s?\nP%s. P%s.",m,i,s,m,t,s,i,s,t,i,s,l,l,l);}}
String
多次就可以在Java中声明多个字符串。这就是为什么我只有一个变量才拥有所有数组的原因。非常感谢您的提示。
MySQL的:273 267
set @i="I'm", @s="Slim", @h="Shady", @r="real", @t="stand", @p="lease stand up";select concat(@i," ",@s," ",@h,". Yes, ",@i," the ",@r," ",@h,".\r\nAll you other ",@s," ",@h,"s are just imitating.\r\nSo, won't the ",@r," ",@s," ",@h," p",@p,"?\r\nP",@p,". P",@p,".");
不太好,但不妨发布答案。
b=String.prototype,b.a=b.replace,alert("123. Yes, 16537All you other 23s are just imitating7So, won't 6523 p4?\nP4. P4.".a(/1/g,"I'm ").a(/2/g,"Slim ").a(/3/g,"Shady").a(/4/g,"lease stand up").a(/5/g,"real ").a(/6/g,"the ").a(/7/g,".\n"))
可读性更高的版本:
b=String.prototype
b.a=b.replace
alert("123. Yes, 16537All you other 23s are just imitating7So, won't 6523 p4?\nP4. P4."
.a(/1/g,"I'm ")
.a(/2/g,"Slim ")
.a(/3/g,"Shady")
.a(/4/g,"lease stand up")
.a(/5/g,"real ")
.a(/6/g,"the ")
.a(/7/g,".\n")
)
[1..21]|>List.iter((function|1|5->"I'm "|2|9|13->"Slim "|4->". Yes, "|6|12->"the real "|8->".\nAll you other "|11->"s are just imitating.\nSo won't "|15->" p"|16|18|20-> "lease stand up"|17->"?\nP"|19->". P"|21->"."|_->"Shady")>>printf "%s")
带有换行符的可读性更高的版本:
[1..21]|>List.iter((function
|1|5->"I'm "
|2|9|13->"Slim "
|4->". Yes, "
|6|12->"the real "
|8->".\nAll you other "
|11->"s are just imitating.\nSo won't "
|15->" p"
|16|18|20-> "lease stand up"
|17->"?\nP"
|19->". P"
|21->"."
|_->"Shady")>>printf "%s")
<?
$i="I'm";
$s=" Slim";
$h=" Shady";
$p="lease stand up";
$r=" the real";
echo"$i$s$h. Yes, $i$r$h.\nAll you other$s$h"."s are just imitating.\nSo, won't$r$s$h p$p?\nP$p. P$p.";
和打高尔夫球
<?$i="I'm";$s=" Slim";$h=" Shady";$p="lease stand up";$r=" the real";echo"$i$s$h. Yes, $i$r$h.\nAll you other$s$h"."s are just imitating.\nSo, won't$r$s$h p$p?\nP$p. P$p.";