C# 5.0, 715 bytes
I know, this is huge. Just wanted to add a C# solution.
/*^()_*/using System.CodeDom;namespace System{class P{static void Main(){var b="/*^()_*/using System.CodeDom;namespace System{{class P{{static void Main(){{var b={0};var f=new string(new[]{{b[3],b[2],b[5],b[2],b[4]}});var w=new IO.StringWriter();CodeDom.Compiler.CodeDomProvider.CreateProvider(\"CSharp\").GenerateCodeFromExpression(new CodePrimitiveExpression(b),w,null);Console.WriteLine(b.Replace(\"[4]}}}}}}}}\",f),w);Console.ReadKey();}}}}}}";var f=new string(new[]{b[3],b[2],b[5],b[2],b[4]});var w=new IO.StringWriter();CodeDom.Compiler.CodeDomProvider.CreateProvider("CSharp").GenerateCodeFromExpression(new CodePrimitiveExpression(b),w,null);Console.WriteLine(b.Replace("[4]}}}}",f),w);Console.ReadKey();}}}
The output is:
/*^()_*/using System.CodeDom;namespace System{class P{static void Main(){var b="/*^()_*/using System.CodeDom;namespace System{{class P{{static void Main(){{var b={0};var f=new string(new[]{{b[3],b[2],b[5],b[2],b[4]}});var w=new IO.StringWriter();CodeDom.Compiler.CodeDomProvider.CreateProvider(\"CSharp\").GenerateCodeFromExpression(new CodePrimitiveExpression(b),w,null);Console.WriteLine(b.Replace(\"[4]}}}}}}}}\",f),w);Console.ReadKey();}}}}}}";var f=new string(new[]{b[3],b[2],b[5],b[2],b[4]});var w=new IO.StringWriter();CodeDom.Compiler.CodeDomProvider.CreateProvider("CSharp").GenerateCodeFromExpression(new CodePrimitiveExpression(b),w,null);Console.WriteLine(b.Replace("(^_^)}}",f),w);Console.ReadKey();}}}
Available at Ideone.com
5
Not to be overly negative, but this is a generalised quine and a do x without y problem. In a language with a general quining method, this is rather dull. You also haven't specified what should happen if your source code is 5 bytes or fewer.
– FryAmTheEggman – 2016-09-13T02:55:22.123@Fry I don't think it's possible to display the 5 characters
(^_^)
with a source code with less than 5 characters ? maybe with specific encoding... – Arnaud – 2016-09-13T03:04:26.373@SuperChafouin no, but it's possible in 5 characters. – Rɪᴋᴇʀ – 2016-09-13T03:07:11.037
3While I'm not certain that it is possible in this case, it is rather trivial to create a program that prints more bytes than it contains. For example, the Pyth program
G
produces the outputabcdefghijklmnopqrstuvwxyz
. – FryAmTheEggman – 2016-09-13T03:07:38.6573
I'd recommend that programs should be at least 6 characters, just so nobody tries, say, Bubblegum.
– Sp3000 – 2016-09-13T03:54:46.6072@FryAmTheEggman The line between a dull and an interesting generalised quine is rather fine. My meta answer is mostly referring to quines where the only viable solution is to obtain a string representing the entire source code and then processing that string. If there are solutions that can get away without constructing the full source code at some point, I think that usually already allows for interesting solutions (e.g. the currently leading CJam answer). As for the do X without Y, the restriction on substrings seems necessary to avoid trivial (quine) solutions. – Martin Ender – 2016-09-13T06:57:33.083
@Sp3000 I don't think it would work, since
(^_^)
is alerady explicitly forbidden. – Erik the Outgolfer – 2016-09-13T12:11:38.283@EriktheGolfer
\x30\xeb\x97\xaa
(4 bytes) outputs(^_^)
in Bubblegum – Sp3000 – 2016-09-13T12:51:16.557@Sp3000 Is it valid DEFLATE or LZMA 2? – Erik the Outgolfer – 2016-09-13T12:53:12.647
@EriktheGolfer Neither - if it's not a valid compression scheme Bubblegum defaults to base 96 encoding – Sp3000 – 2016-09-13T12:53:44.607
@Sp3000 I let you post it as an answer, although I don't think it's valid at all. You would need a filler byte, because the 5 bytes will be modified, not modified or added or both. Maybe a trailing newline would help here. – Erik the Outgolfer – 2016-09-13T12:59:55.720
@EriktheGolfer I wasn't intending on posting it, I'm just demonstrating that Fry's initial question needs an answer. – Sp3000 – 2016-09-13T13:04:51.577
@all added minimum source code size requirement. – Arnaud – 2016-09-13T13:47:55.487
@MartinEnder You're right, I spoke a bit too harshly in my comment. I think my second sentence could have been better ended with "this can be done easily". I more meant it as a warning that posts may devolve into generalised quines with basic restricted source workarounds. – FryAmTheEggman – 2016-09-13T14:21:25.160