# Source code GO!

Let's use augmented reality to hunt small creatures hidden in source-code. Write a quine program that outputs its own code source, except for 5 consecutive characters that will be modified and that will display a PCG-mon : (^_^)

The 5 consecutive characters can be positioned anywhere in the source code (from position 0 to n-5, n being the source code length). The source code must have a minimum length of 5 characters. The string (^_^) or any of its substring of length >=2 must not appear in initial source code, only in output.

Example of valid submission:

• source code my source code, output my (^_^)e code

Invalid:

• source code (^_^) copy;, output (^_^) (^_^)

## Winning criteria

The shortest code in bytes wins.

• 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 Sep 13 '16 at 2:55
• @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 Sep 13 '16 at 3:04
• While 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 output abcdefghijklmnopqrstuvwxyz. – FryAmTheEggman Sep 13 '16 at 3:07
• I'd recommend that programs should be at least 6 characters, just so nobody tries, say, Bubblegum. – Sp3000 Sep 13 '16 at 3:54
• @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 Sep 13 '16 at 6:57

# Javascript ES6, 44 bytes

$=_=>$=(\^\_\^\)${($+'').slice(5)};$();$()


Output:

$=(^_^)=(\^\_\^\)${($+'').slice(5)};$();$()  Still working on golfing, but it works for now. • +1 for having another face: =_= – Cyoce Sep 13 '16 at 4:56 • Can't you do $=_=>(\^\_\^\)${($+'').slice(3)};$();$() (it actually looks even nicer because now it looks like you're waking up a sleeping face). :) – Martin Ender Sep 13 '16 at 15:14

# Vim, 33, 27 keystrokes

qqqqqS(<C-v>94_<C-v>94)q@q<esc>hh"qPq@q


Note that <C-v> means ctrl+v, and is byte 0x16 and <esc> is the escape character, and is byte 0x1B.

This just uses a slightly modified version of my Golf you a quine for great good! answer.

Outputs:

(^_^)S(^V94_^V94)q@q^[hh"qPq@q


This is valid since ^V is the way vim represents <C-v> and ^[ is the way vim represents <esc>.

The basic idea, is just to input the text (^_^) by its code points so we can avoid putting those characters in the source code. In insert mode, <C-v>number will insert the ASCII character of "number". However, since the challenge says:

The string (^_^) or any of its substring of length >=2 must not appear in initial source code, only in output.

This answer abuses the "substring" rule by only entering the codepoints of the ^ characters, and entering (, _, and ) directly.

Here's a gif that lets you see this solution in action, and puts the source code and output side by side for comparison:

• pretty sneaky, using the ^ control char... +1 – Rɪᴋᴇʀ Sep 13 '16 at 2:50

## CJam, 13 11 bytes

"(_)"
_p'^*


Online interpreter (-2 bytes thanks to @MartinEnder).

"(_)"             Push string
_p          Duplicate and print repr with newline
'^*       Join string with '^'


# Python, 115111 107 bytes

def f():s='def f():s=%r;print s%%s.replace(s[:5],"^".join("(_)"))';print s%s.replace(s[:5],"^".join("(_)"))


Call f() and the output is:

def f():s='(^_^)():s=%r;print s%%s.replace(s[:5],"^".join("(_)"))';print s%s.replace(s[:5],"^".join("(_)"))


Inspired in part by this answer to a similar question.

• Welcome to the site! – DJMcMayhem Sep 13 '16 at 7:13

## CJAM, 16 15 bytes

Try it here.

{"^(_)"(*}_~sss


# JavaScript (ES6), 91 bytes

a="a=%s;co%s.log(a,uneval(a),(${'^'}_${'^'}))";console.log(a,uneval(a),(${'^'}_${'^'}))


This is based on my non-source-reading answer to Golf you a quine for great good!. Outputs

a="a=%s;co%s.log(a,uneval(a),(${'^'}_${'^'}))";co(^_^).log(a,uneval(a),(${'^'}_${'^'}))


This can easily be modified by moving around the second %s in the string. For example,

a="a=%s;console.log(a,uneval(a),($%s_${'^'}))";console.log(a,uneval(a),(${'^'}_${'^'}))


outputs

a="a=%s;console.log(a,uneval(a),($%s_${'^'}))";console.log(a,uneval(a),($(^_^)_${'^'}))


# Jelly, 22 bytes

“4094959441b³ỌØV”ṘVabc


Available at TryItOnline

Uses the built-in payload capable quine “ØV”ṘV
The abc on the end is just filler to be replaced
b³ converts the integer into base 100, resulting in [40,94,95,94,41]
Ọ casts to characters, resulting in (^_^)
So the whole result is “4094959441b³ỌØV”(^_^)

# Go (golang), 131 bytes

This challenge must have an answer in Go!

package main;import"fmt";func main(){a:="package main;import\"fmt\";func(%c_%[1]c)(){a:=%q;fmt.Printf(a,94,a)}";fmt.Printf(a,94,a)}


Try it online!

# 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

# MATL, 14 bytes

')__*i't&Dwqh


Produces the output ')__*i'(^_^)h.

Try it online!

### Explanation

')__*i'  % Push this string
t&D       % Duplicate and get string representation (i.e. enclose with quotes)
w         % Swap
q         % Subtract 1. Transforms ')__*i' into the code points of '(^_^)h'
h         % Concatenate. Automatically casts code points to chars. Implicitly display

• My first attempt at a quine! – Luis Mendo Sep 14 '16 at 17:10

# Bash, 178 bytes

Q='#(8_8)
printf "Q=\47"
echo -n "$Q"|sed -r "s~(_|\()8~\1^~g" echo -e "\x27" tail<<<"$Q" -n4'
printf "Q=\47"
echo -n "$Q"|sed -r "s~(_|\()8~\1^~g" echo -e "\x27" tail<<<"$Q" -n4
`

Pfff, I am not good at quines :/ Any suggestion to golf it more is more than welcome! :-)