1<html> 2 <head> 3 <meta charset="UTF-8"><title>quines, and brainfuck - writing @ coral.shoes</title><meta name="iloinlxlvi" content="https://coral.shoes/iloinlxlvi.json"><link rel="stylesheet" href="../resources/main.css"> 4 <link href="../resources/blog.css" rel="stylesheet"> 5 </head> 6 7 <body> 8 <div class="navbar"><a href="../index.html">coral.shoes</a></div> 9 <main> 10 <div class="img-container"><img src="../splash/fire-waffle.jpg"><a class="overlay" href="../splash/fire-waffle.png" title="view full quality photo"></a></div> 11 12 <h1> quines, and brainfuck </h1> 13 <p> written 2023-04-27 </p> 14 15 <hr> 16 <h2> introduction </h2> 17 <p> 18 a quine is a program which without taking any input, outputs it's own source code â a fixed point of the programming language in question. quines are unwieldy beings because they mix what is often considered two distinct levels of abstractions: source code, and the programs the code represent. 19 </p> 20 <p> 21 brainfuck is a minimalistic programming language consisting of only 8 simple commands in the source and a pointer into a big array of integers as the only runtime storage medium. the language was designed to be implementable with as small of a compiler as possible, sacrificing usability for implementation simplicity. 22 </p> 23 <p> 24 in this blog, we'll explore how to combine these two, writing a quine in brainfuck. is there any practical use for this, or any important lesson to take away from the exercise? i'm not sure, but i'm leaning towards a "definitely not". 25 </p> 26 27 <h2> quines, and not brainfuck </h2> 28 29 <p> 30 before we develop a quine in the brainfuck language, we'll start with something a bit more managable â a quine in the Python programming language. we'll be putting a lot of valid code inside string literals, which can make it slightly difficult to identify what parts of the code are expressions and what are strings. use the code highlighting to your advantage! 31 </p> 32 <p> 33 starting off, we know we'll be needing to print something. let's start off with a print statement: 34 </p> 35 <pre style="background-color:#2b303b;" style="background: #2b303b;"> 36<span style="color:#96b5b4;">print</span><span style="color:#c0c5ce;">("</span><span style="color:#a3be8c;">...</span><span style="color:#c0c5ce;">")</span></pre> 37 <p> 38 what to print? we must make sure the print itself is included: 39 </p> 40 <pre style="background-color:#2b303b;" style="background: #2b303b;"> 41<span style="color:#96b5b4;">print</span><span style="color:#c0c5ce;">("</span><span style="color:#a3be8c;">print(</span><span style="color:#96b5b4;">\"</span><span style="color:#a3be8c;">...</span><span style="color:#96b5b4;">\"</span><span style="color:#a3be8c;">)</span><span style="color:#c0c5ce;">")</span></pre> 42 <p> 43 and then: 44 </p> 45 <pre style="background-color:#2b303b;" style="background: #2b303b;"> 46<span style="color:#96b5b4;">print</span><span style="color:#c0c5ce;">("</span><span style="color:#a3be8c;">print(</span><span style="color:#96b5b4;">\"</span><span style="color:#a3be8c;">print(</span><span style="color:#96b5b4;">\\</span><span style="color:#c0c5ce;">"...\</span><span style="background-color:#bf616a;color:#2b303b;">\")\")")</span></pre> 47 <p> 48 and at this point we might as well conclude this quine will need to be infinitely long. 49 </p> 50 51 <div class="infobox"> 52 <p>in some programming languages, there exist some rather trivial examples of quines.</p> 53 <p>in PHP, any text not surrounded by <code style="background-color:#2b303b;" style="background: #2b303b;"> 54<span style="color:#ab7967;"><?php</span><span style="color:#c0c5ce;">></span></code>-tags is output verbatim, giving a lot of boring quines.</p> 55 <p>another way to "cheat" in a quine is by reading the source code from the current file, such as the sh program <code style="background-color:#2b303b;" style="background: #2b303b;"> 56<span style="color:#8fa1b3;">cat </span><span style="color:#c0c5ce;">$</span><span style="color:#bf616a;">0</span></code>.</p> 57 </div> 58 59 <p> 60 giving up on printing the source directly, we can instead try assigning the source code to a variable, and then printing the variable 61 </p> 62 <pre style="background-color:#2b303b;" style="background: #2b303b;"> 63<span style="color:#c0c5ce;">source = "</span><span style="color:#a3be8c;">print(source)</span><span style="color:#c0c5ce;">" 64</span><span style="color:#96b5b4;">print</span><span style="color:#c0c5ce;">(source)</span></pre> 65 <p> 66 however this doesn't print the variable assignment itself on the first row. if we add the variable assignment to the print statement and adjust the variable accordingly, we get 67 </p> 68 <pre style="background-color:#2b303b;" style="background: #2b303b;"> 69<span style="color:#c0c5ce;">source = "</span><span style="color:#a3be8c;">print(</span><span style="color:#96b5b4;">\"</span><span style="color:#a3be8c;">source = </span><span style="color:#96b5b4;">\"</span><span style="color:#a3be8c;"> + source + </span><span style="color:#96b5b4;">\"\\</span><span style="color:#a3be8c;">n</span><span style="color:#96b5b4;">\"</span><span style="color:#a3be8c;"> + source)</span><span style="color:#c0c5ce;">" 70</span><span style="color:#96b5b4;">print</span><span style="color:#c0c5ce;">("</span><span style="color:#a3be8c;">source = </span><span style="color:#c0c5ce;">" + source + "</span><span style="color:#96b5b4;">\n</span><span style="color:#c0c5ce;">" + source)</span></pre> 71 <p> 72 which is very close, but the first time <code>source</code> is printed, the quote escapes are included. while some languages do include functions for "unescaping" strings (such as the <code lang="py">repr()</code> function in Python), we can instead try storing the variable in a way which is easier to print a representation of. let's pick a format where the source is stored as a list of codepoints: 73 </p> 74 <pre style="background-color:#2b303b;" style="background: #2b303b;"> 75<span style="color:#c0c5ce;">source = [</span><span style="color:#d08770;">112</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">114</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">105</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">110</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">116</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">40</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">34</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">115</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">111</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">117</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">114</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">99</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">101</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">32</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">61</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">32</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">91</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">34</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">32</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">43</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">32</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">34</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">44</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">32</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">34</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">46</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">106</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">111</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">105</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">110</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">40</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">115</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">116</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">114</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">40</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">120</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">41</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">32</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">102</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">111</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">114</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">32</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">120</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">32</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">105</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">110</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">32</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">115</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">111</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">117</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">114</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">99</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">101</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">41</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">32</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">43</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">32</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">34</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">93</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">10</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">34</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">32</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">43</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">32</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">34</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">34</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">46</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">106</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">111</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">105</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">110</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">40</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">99</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">104</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">114</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">40</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">120</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">41</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">32</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">102</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">111</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">114</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">32</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">120</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">32</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">105</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">110</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">32</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">115</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">111</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">117</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">114</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">99</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">101</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">41</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">41</span><span style="color:#c0c5ce;">] 76</span><span style="color:#96b5b4;">print</span><span style="color:#c0c5ce;">("</span><span style="color:#a3be8c;">source = [</span><span style="color:#c0c5ce;">" + "</span><span style="color:#a3be8c;">, </span><span style="color:#c0c5ce;">".</span><span style="color:#8fa1b3;">join</span><span style="color:#c0c5ce;">
76(str(x) </span><span style="color:#b48ead;">for </span><span style="color:#c0c5ce;">x </span><span style="color:#b48ead;">in </span><span style="color:#c0c5ce;">source) + "</span><span style="color:#a3be8c;">]</span><span style="color:#96b5b4;">\n</span><span style="color:#c0c5ce;">" + "".</span><span style="color:#8fa1b3;">join</span><span style="color:#c0c5ce;">(</span><span style="color:#96b5b4;">chr</span><span style="color:#c0c5ce;">(x) </span><span style="color:#b48ead;">for </span><span style="color:#c0c5ce;">x </span><span style="color:#b48ead;">in </span><span style="color:#c0c5ce;">source))</span></pre> 77 <p> 78 here, the number is each code point in the following line. the expression <code style="background-color:#2b303b;" style="background: #2b303b;"> 79<span style="color:#c0c5ce;">"</span><span style="color:#a3be8c;">, </span><span style="color:#c0c5ce;">".</span><span style="color:#8fa1b3;">join</span><span style="color:#c0c5ce;">(str(x) </span><span style="color:#b48ead;">for </span><span style="color:#c0c5ce;">x </span><span style="color:#b48ead;">in </span><span style="color:#c0c5ce;">source)</span></code> evaluates to a comma-separated string of all the numbers in source (resulting in the list on the first line), while the expression <code style="background-color:#2b303b;" style="background: #2b303b;"> 80<span style="color:#c0c5ce;">"".</span><span style="color:#8fa1b3;">join</span><span style="color:#c0c5ce;">(</span><span style="color:#96b5b4;">chr</span><span style="color:#c0c5ce;">(x) </span><span style="color:#b48ead;">for </span><span style="color:#c0c5ce;">x </span><span style="color:#b48ead;">in </span><span style="color:#c0c5ce;">source)</span></code> results in the string produced by concatenating all the code points in the list (resulting in the second line). together, these two expressions combined results in a proper quine! 81 </p> 82 <hr> 83 <p> 84 in the program above, we can identify three parts which are common to a lot of quines. the program consists of three parts: 85 86 <ol> 87 <li> representing the source of part 2 and 3 in some storage (in our case, assigning the source to a list of codepoints) </li> 88 <li> printing the assignment in part 1 by using the stored variable </li> 89 <li> printing the code represented by part 1 using the same variable </li> 90 </ol> 91 </p> 92 93 <h2> introduction to brainfuck </h2> 94 95 <p> 96 as mentioned in the introduction, brainfuck is quite an unusual programming language unless you've worked with <a href="https://esolangs.org">esolangs</a> before. in brainfuck, the only form of storage is an array of bytes, often referred to as the 'tape', which stretches out as far as the runtime of the language allows. accessing the tape is done through a pointer often referred to as the 'pointer'. if you've read about <a href="https://en.wikipedia.org/wiki/Turing_machine">turing machines</a> before, you might see some similarities here (note however, that brainfuck does not have the concept of states from turing machines). 97 </p> 98 99 <p> 100 the eight commands in brainfuck are as follows: 101 <ul> 102 <li> <code>+</code>: increase the value which the 'pointer' points to by one </li> 103 <li> <code>-</code>: decrease the value which the 'pointer' points to by one </li> 104 <li> <code>></code>: move the pointer one step to the right </li> 105 <li> <code><</code>: move the pointer one step to the left </li> 106 <li> <code>.</code>: print the value to which the 'pointer' points as an ASCII codepoint </li> 107 <li> <code>,</code>: read an ASCII codepoint from the user, storing it in the pointed to value </li> 108 <li> <code>[</code>: if the value pointed to is zero, jump forward to the matching <code>]</code> </li> 109 <li> <code>]</code>: if the value pointed to is nonzero, jump backward to the matching <code>[</code> </li> 110 </ul> 111 112 as we can see, <code>+-</code> is used for changing the values in the tape, <code>><</code> is used for moving the pointer around, <code>.,</code> do I/O with the user and <code>[]</code>
112 is used for control flow, both giving us a conditional jump and a loop operation. 113 </p> 114 115 <h2> writing a quine in brainfuck </h2> 116 117 <p> 118 applying the three-part technique described earlier, we first need to choose a way to represent brainfuck source code. the absolute simplest way to store the source code would be to store each command as a code point in memory. however, as we need to loop over the text, and the loop iterations are probably going to need some temporary memory, we put a zero cell between each adjacent character in memory to be used as auxilliary storage. 119 </p> 120 <p> 121 for example, the code <code style="background-color:#2b303b;" style="background: #2b303b;"> 122<span style="color:#c0c5ce;">,[-]</span></code> would be 123 represented in memory as 124 </p> 125 <pre style="background-color:#2b303b;" style="background: #2b303b;"> 126<span style="color:#d08770;">44 0 91 0 45 0 93 0 0 0 0 0 </span><span style="color:#c0c5ce;">... 127</span><span style="color:#c0c5ce;">^</span></pre> 128 129 <p> 130 which would be generated by the program 131 </p> 132 <pre style="background-color:#2b303b;" style="background: #2b303b;"> 133<span style="color:#c0c5ce;">++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<<<<<<</span></pre> 134 135 <p> 136 the second part has the job of printing this program. to do this, we'll loop through all the characters until a we find a zero marking the end of the data, print the respective number of <code>+</code>'s, print two <code>></code>'s, go to the next character and repeat. at the end, we'll need to go back through the code and print two <code>></code>'s for each character on the way back. 137 </p> 138 <p> 139 to do the first part: 140 </p> 141 <pre style="background-color:#2b303b;" style="background: #2b303b;"> 142<span style="color:#c0c5ce;">[ </span><span style="color:#65737e;"># loop through the chars until we reach a zero 143</span><span style="color:#c0c5ce;"> </span><span style="color:#65737e;"># we have three cells, A, B and C 144</span><span style="color:#c0c5ce;"> </span><span style="color:#65737e;"># cell A and C are auxilliary zero-cells, and cell B contains the current char 145</span><span style="color:#c0c5ce;"> > </span><span style="color:#65737e;"># go to cell C (temporary value to the right of the current char) 146</span><span style="color:#c0c5ce;"> +++++++++++++++++++++++++++++++++++++++++++ </span><span style="color:#65737e;"># set it to 43 (the ascii code for plus) 147</span><span style="color:#c0c5ce;"> < </span><span style="color:#65737e;"># go to cell B (the current char) 148</span><span style="color:#c0c5ce;"> [ - </span><span style="color:#65737e;"># loop until B is zero 149</span><span style="color:#c0c5ce;"> < + </span><span style="color:#65737e;"># increase A (the temporary cell to the left) 150</span><span style="color:#c0c5ce;"> >> . </span><span style="color:#65737e;"># to go C and print it (the ascii plus) 151</span><span style="color:#c0c5ce;"> < </span><span style="color:#65737e;"># go back to B 152</span><span style="color:#c0c5ce;"> ] 153</span><span style="color:#c0c5ce;"> </span><span style="color:#65737e;"># now B is zero, A conatins the value of the current char, and C is still an ascii plus 154</span><span style="color:#c0c5ce;"> < </span><span style="color:#65737e;"># go to A 155</span><span style="color:#c0c5ce;"> [ - </span><span style="color:#65737e;"># loop until it's zero 156</span><span style="color:#c0c5ce;"> > + </span><span style="color:#65737e;"># increase B 157</span><span style="color:#c0c5ce;"> < </span><span style="color:#65737e;"># go back to A 158</span><span style="color:#c0c5ce;"> ] 159</span><span style="color:#c0c5ce;"> </span><span style="color:#65737e;"># now B contains the current char again, and A is zero 160</span><span style="color:#c0c5ce;"> >> </span><span style="color:#65737e;"># go to C 161</span><span style="color:#c0c5ce;"> +++++++++++++++++++ </span><span style="color:#65737e;"># increase it by 19 (it now contains 43+19=62, the ascii value for > 162</span><span style="color:#c0c5ce;"> .. </span><span style="color:#65737e;"># print it twice 163</span><span style="color:#c0c5ce;"> [-] </span><span style="color:#65737e;"># set it to zero 164</span><span style="color:#c0c5ce;"> > </span><span style="color:#65737e;"># go to the next char to be printed 165</span><span style="color:#c0c5ce;">] 166</span><span style="color:#c0c5ce;"><< </span><span style="color:#65737e;"># go back to the last non-zero char</span></pre> 167 <p>
168 stripping the comments and whitespace, 169 </p> 170 <pre style="background-color:#2b303b;" style="background: #2b303b;"> 171<span style="color:#c0c5ce;">[>+++++++++++++++++++++++++++++++++++++++++++<[-<+>>.<]<[->+<]>>+++++++++++++++++++..[-]>]<<</span></pre> 172 <p> 173 we then want to go back to the start, printing a <code><<</code> for each char 174 </p> 175 <pre style="background-color:#2b303b;" style="background: #2b303b;"> 176<span style="color:#c0c5ce;">[ </span><span style="color:#65737e;"># loop until zero 177</span><span style="color:#c0c5ce;"> </span><span style="color:#65737e;"># we again have A, B and C 178</span><span style="color:#c0c5ce;"> < ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ </span><span style="color:#65737e;"># set A to 60, ascii value for < 179</span><span style="color:#c0c5ce;"> .. </span><span style="color:#65737e;"># print it twice 180</span><span style="color:#c0c5ce;"> [-] </span><span style="color:#65737e;"># set it back to zero 181</span><span style="color:#c0c5ce;"> < </span><span style="color:#65737e;"># go to the previous char 182</span><span style="color:#c0c5ce;">] 183</span><span style="color:#c0c5ce;">>> </span><span style="color:#65737e;"># go to the first non-zero char</span></pre> 184 <p> 185 again, stripping: 186 </p> 187 <pre style="background-color:#2b303b;" style="background: #2b303b;"> 188<span style="color:#c0c5ce;">[<++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..[-]<]>></span></pre> 189 <p> 190 for the third part, we want to print out the code being represented itself. this is quite a bit lot simpler, 191 </p> 192 <pre style="background-color:#2b303b;" style="background: #2b303b;"> 193<span style="color:#c0c5ce;">[ </span><span style="color:#65737e;"># loop until zero 194</span><span style="color:#c0c5ce;"> . </span><span style="color:#65737e;"># print the current char 195</span><span style="color:#c0c5ce;"> >> </span><span style="color:#65737e;"># go to the next char 196</span><span style="color:#c0c5ce;">]</span></pre> 197 <p> 198 stripped being 199 </p> 200 <pre style="background-color:#2b303b;" style="background: #2b303b;"> 201<span style="color:#c0c5ce;">[.>>]</span></pre> 202 203 <p> 204 part 2 and 3 together form the source which part 1 will encode. combined, they are (with added newlines between the parts) 205 </p> 206 <pre style="background-color:#2b303b;" style="background: #2b303b;"> 207<span style="color:#c0c5ce;">[>+++++++++++++++++++++++++++++++++++++++++++<[-<+>>.<]<[->+<]>>+++++++++++++++++++..[-]>]<<[<++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..[-]<]>>[.>>]</span></pre> 208 <p> 209 i don't want to encode all of this into brainfuck by hand, so let's use a short python script to generate the program: 210 </p> 211 <pre style="background-color:#2b303b;" style="background: #2b303b;"> 212<span style="color:#c0c5ce;">source = "</span><span style="color:#a3be8c;">[>+++++++++++++++++++++++++++++++++++++++++++<[-<+>>.<]<[->+<</span><span style="color:#c0c5ce;">" \ 213</span><span style="color:#c0c5ce;"> "</span><span style="color:#a3be8c;">]>>+++++++++++++++++++..[-]>]<<[<++++++++++++++++++++++++++++</span><span style="color:#c0c5ce;">" \ 214</span><span style="color:#c0c5ce;"> "</span><span style="color:#a3be8c;">++++++++++++++++++++++++++++++++..[-]<]>>[.>>]</span><span style="color:#c0c5ce;">" 215</span><span style="color:#96b5b4;">print</span><span style="color:#c0c5ce;">("".</span><span style="color:#8fa1b3;">join</span><span style="color:#c0c5ce;">("</span><span style="color:#a3be8c;">+</span><span style="color:#c0c5ce;">" * </span><span style="color:#96b5b4;">ord</span><span style="color:#c0c5ce;">(c) + "</span><span style="color:#a3be8c;">>></span><span style="color:#c0c5ce;">" </span><span style="color:#b48ead;">for </span><span style="color:#c0c5ce;">c </span><span style="color:#b48ead;">in </span><span style="color:#c0c5ce;">source) + "</span><span style="color:#a3be8c;"><<</span><span style="color:#c0c5ce;">" * </span><span style="color:#96b5b4;">len</span><span style="color:#c0c5ce;">(source) + source)</span></pre> 216 <p> 217 resulting in the final quine 218 </p> 219 <pre style="background-color:#2b303b;" style="background: #2b303b;"> 220<span style="color:#c0c5ce;">+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[>+++++++++++++++++++++++++++++++++++++++++++<[-<+>>.<]<[->+<]>>+++++++++++++++++++..[-]>]<<[<++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..[-]<]>>[.>>]</span></pre> 221 <p> 222 isn't it beautiful :3 223 </p> 224 </main> 225 </body> 226</html>
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.