问:
"Hello, World!"
So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most interesting code golf in the common languages, finding the shortest solution in certain esolangs can be a serious challenge. For instance, to my knowledge it is not known whether the shortest possible Brainfuck solution has been found yet.

Furthermore, while all of <s>Wikipedia</s> (the Wikipedia entry has been deleted but there is a copy at archive.org
), esolangs and Rosetta Code have lists of "Hello, World!" programs, none of these are interested in having the shortest for each language (there is also this GitHub repository). If we want to be a significant site in the code golf community, I think we should try and create the ultimate catalogue of shortest "Hello, World!" programs (similar to how our basic quine challenge contains some of the shortest known quines in various languages). So let's do this!

The Rules

Each submission must be a full program.

The program must take no input, and print Hello, World! to STDOUT (this exact byte stream, including capitalization and punctuation) plus an optional trailing newline, and nothing else.

The program must not write anything to STDERR.

If anyone wants to abuse this by creating a language where the empty program prints Hello, World!, then congrats, they just paved the way for a very boring answer.

Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language.

Submissions are scored in bytes, in an appropriate (pre-existing) encoding, usually (but not necessarily) UTF-8. Some languages, like Folders, are a bit tricky to score - if in doubt, please ask on Meta.

This is not about finding the language with the shortest "Hello, World!" program. This is about finding the shortest "Hello, World!" program in every language. Therefore, I will not mark any answer as "accepted".

If your language of choice is a trivial variant of another (potentially more popular) language which already has an answer (think BASIC or SQL dialects, Unix shells or trivial Brainfuck-derivatives like Alphuck), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

As a side note, please don't downvote boring (but valid) answers in languages where there is not much to golf - these are still useful to this question as it tries to compile a catalogue as complete as possible. However, do primarily upvote answers in languages where the authors actually had to put effort into golfing the code.

For inspiration, check the Hello World Collection.

The Catalogue

The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

```<code>## Language Name, N bytes
</code>```

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

```<code>## Ruby, <s>104</s> <s>101</s> 96 bytes
</code>```

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

```<code>## Perl, 43 + 2 (-p flag) = 45 bytes
</code>```

You can also make the language name a link which will then show up in the snippet:

```<code>## [><>](https://esolangs.org/wiki/Fish), 121 bytes
</code>```

/* Configuration */

var QUESTION_ID = 55422; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 8478; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });
    else console.log(body);
  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    lang = jQuery(''+lang+'').text();

    languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;
    if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
  text-align: left !important;
  display: block !important;
}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 500px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}</code>```

<link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/all.css?v=ffb5d0584c5f">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

答:
Constant, 115 bytes

```<code>ppp*eee-pP;_fao*R;_fo+pp;_coo+p;_fo;eec*ppc+ef;_o-ppppf;_oZ+eeeepc;_o+eeef*pf;_o+pf;_o-pec;_o
-eeef;_ozeeef*pc+lf;_o
</code>```

(the newline is unnecessary) Ungolfed:

```<code>ppp * eee-pP;
_fao * R;
_fo + pp;
_coo + p;
_fo;
eec * ppc + ef;
_o-ppppf;
_oZ + eeeepc;
_o + eeef * pf;
_o + pf;
_o-pec;
_o-eeef;
_ozeeef * pc + lf;
_o;
</code>```

Try it out here!

This is a very natural program, except that numbers are not composed of the conventional digits, but rather constants such as p (pi) and e (euler's number). _ is the last expression, f is floor, c is ceil, and o is character output.

Title: "Hello, World!"

Body:
Constant, 115 bytes

ppp*eee-pP;_fao*R;_fo+pp;_coo+p;_fo;eec*ppc+ef;_o-ppppf;_oZ+eeeepc;_o+eeef*pf;_o+pf;_o-pec;_o
-eeef;_ozeeef*pc+lf;_o

(the newline is unnecessary) Ungolfed:

ppp * eee-pP;
_fao * R;
_fo + pp;
_coo + p;
_fo;
eec * ppc + ef;
_o-ppppf;
_oZ + eeeepc;
_o + eeef * pf;
_o + pf;
_o-pec;
_o-eeef;
_ozeeef * pc + lf;
_o;

Try it out here!

This is a very natural program, except that numbers are not composed of the conventional digits, but rather constants such as p (pi) and e (euler's number). _ is the last expression, f is floor, c is ceil, and o is character output.


答:
Reng v.3.2, 36 bytes

```<code>1i#x:xe!Ø;$:1+)å(Eh
å'11µ1nran! ¡n~
</code>```

Try it here!

This pushes 1 to the stack, then stores the input i into x (i#x). Then, a range of all the necessary numbers is created using :xe!Ø;$:1+)å(Eh, being ended by Ø, which goes the first i.e. next line. å takes every number and pushes the digits of that number.

On the next line, å breaks the last number into its digits, ' sorts the stack, and 11µ removes 1 1 from the stack. A 1 is then printed, and the numbers are reversed then outputted through the loop an! ¡n. The program is terminated with ~.

ContentLicense: CC BY-SA 3.0

Title: The Rien Number

Body:
The Champernowne constant is a number that is constructed by concatenating the first n numbers, with n tending to infinity. It looks something like this:

```<code>0.123456789101112131415161718192021222324252627282930...
</code>```

Now, I will describe to you the Rien number. It can be thought of as a minimization of the Champernowne constant as an integer. I will refer to the Rien number with the first n digits as Ri(n). This is how to formulate it:

The first n natural numbers (the sequence {1,2,3,...}) are concatenated.

This result is then sorted, according to the digit value. So 1..12 would look like 011111223456789.

Since the Rien number cannot have leading zeroes, we move all 0s so that they are significant, whilst keeping the number minimized, resulting in, say, 101111223456789. This is Ri(n), in this case, Ri(12).

Here are some results for Ri(n):

```<i>n</i>    Ri(<i>n</i>)
1    1
2    12
3    123
7    1234567
9    123456789
10   10123456789
15   101111111223344556789
34   10001111111111111222222222222223333333334444555666777888999
42   100001111111111111122222222222222233333333333333444444455556666777788889999
45   100001111111111111122222222222222233333333333333344444444444555556666777788889999
55   10000011111111111111122222222222222223333333333333333444444444444444455555555555566666777778888899999
100  100000000000111111111111111111112222222222222222222233333333333333333333444444444444444444445555555555555555555566666666666666666666777777777777777777778888888888888888888899999999999999999999
999  100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
```

Objective Given a number 1 ≤ n < 10000 as input (via arguments, STDIN, or hardcoding if your language does not support conventional input), output/return Ri(n).

This is a code-golf, so the shortest code in bytes wins. You may use a language that was made after this contest, as long as it was not made for answering this challenge. (Of course, you can use it, if it provides an interesting solution, but mark your answer as non-competing.)

Reference implementation

I tested this in IE, so there really shouldn't be a problem. If there is a problem, there's an easy solution: get a sane browser.

function min(n) {
  var seq = [];
  for(var i = 1; i <= n; i++) seq.push(i);
  seq = seq.join("").split("").map(Number);
  var to;
  if(seq.indexOf(1) >= 0) to = seq.splice(seq.indexOf(1), 1);
  seq.sort(function(a, b) {
    return a - b;
  });
  if(to) seq = to.concat(seq);
  return seq.join("");
}
t.onchange = t.onkeyup = function() {
  h.innerHTML = min(this.value)
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>* {
  font-family: Consolas, monospace;
}
input {
  border: 2px dotted #aaaaaa;
  border-radius: 5px;
  margin: 10px;
}</code>```

<input id="t" type="number">

```
</div>
</div>
</p>

<hr>

<h2>Leaderboard</h2>

<p>The Stack Snippet at the bottom of this post generates the catalog from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.</p>

<p>To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:</p>

```## Language Name, N bytes
```

<p>where <code>N</code> is the size of your submission. If you improve your score, you <em>can</em> keep old scores in the headline, by striking them through. For instance:</p>

```## Ruby, <s>104</s> <s>101</s> 96 bytes
```

<p>If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the <em>last</em> number in the header:</p>

```## Perl, 43 + 2 (-p flag) = 45 bytes
```

<p>You can also make the language name a link which will then show up in the snippet:</p>

```## [><>](http://esolangs.org/wiki/Fish), 121 bytes
```

<p><div class="snippet" data-lang="js" data-hide="true">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var QUESTION_ID=68685,OVERRIDE_USER=44713;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;</code>```

body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td>Link</td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td>Link</td></tr></tbody> </table></code>```

Body:
Reng v.3.2, 36 bytes

1i#x:xe!Ø;$:1+)å(Eh
å'11µ1nran! ¡n~

Try it here!

This pushes 1 to the stack, then stores the input i into x (i#x). Then, a range of all the necessary numbers is created using :xe!Ø;$:1+)å(Eh, being ended by Ø, which goes the first i.e. next line. å takes every number and pushes the digits of that number.

On the next line, å breaks the last number into its digits, ' sorts the stack, and 11µ removes 1 1 from the stack. A 1 is then printed, and the numbers are reversed then outputted through the loop an! ¡n. The program is terminated with ~.


问:
The plus-minus sequence

The plus-minus sequence

The plus-minus sequence is one that starts with two seeds, a(0) and b(0). Each iteration of this sequence is the addition and subtraction of the previous two members of the sequence. That is, a(N) = a(N-1) + b(N-1) and b(N) = a(N-1) - b(N-1).

Objective Produce the plus-minus sequence, in infinitude or the first K steps given K. You may do this using an infinite output program, a generator, or a function/program that gives the first K steps. The output order does not matter, so long as it is consistent. (I.e., b(K) a(K) or a(K) b(K), with some non-numeric, non-newline separator in between.) The output must start with the input.

Test cases

For inputs 10 2 (of a(0) b(0), this is a possible output for the first K approach (or a subsection of the infinite approach):

```<code>10     2
12     8
20     4
24     16
40     8
48     32
80     16
96     64
160    32
192    128
320    64
384    256
640    128
768    512
1280   256
1536   1024
2560   512
3072   2048
5120   1024
6144   4096
10240  2048
12288  8192
20480  4096
24576  16384
40960  8192
49152  32768
81920  16384
98304  65536
</code>```

For inputs 2 20 10 (a(0) b(0) k):

```<code>2     20
22   -18
4     40
44   -36
8     80
88   -72
16    160
176  -144
32    320
352  -288
</code>```

This is a code-golf, so the shortest program in bytes wins.

Catalog

The Stack Snippet at the bottom of this post generates the catalog from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

```<code>## Language Name, N bytes
</code>```

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

```<code>## Ruby, <s>104</s> <s>101</s> 96 bytes
</code>```

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

```<code>## Perl, 43 + 2 (-p flag) = 45 bytes
</code>```

You can also make the language name a link which will then show up in the snippet:

```<code>## [><>](http://esolangs.org/wiki/Fish), 121 bytes
</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

答:
Jelly, 5 bytes

```<code>ṄI;Sß
</code>```

This is a recursive approach. Due to tail call optimization, the only limit is the ability to fit both integers into memory. Output is one list per line.

Try it online!

How it works

```<code>ṄI;Sß  Main link. Argument: [b[n], a[n]] (n = 0 for original input)

Ṅ      Print [b[n], a[n]] to STDOUT.
 I     Compute the increments of the list, i.e., [a[n] - [b[n]].
   S   Compute the sum of the list, i.e., b[n] + a[n].
  ;    Concatenate the results to the left and to the right.
    ß  Recursively call the main link.
</code>```

ContentLicense: CC BY-SA 4.0

Title: The plus-minus sequence

Body:
Jelly, 5 bytes

ṄI;Sß

This is a recursive approach. Due to tail call optimization, the only limit is the ability to fit both integers into memory. Output is one list per line.

Try it online!

How it works

ṄI;Sß  Main link. Argument: [b[n], a[n]] (n = 0 for original input)

Ṅ      Print [b[n], a[n]] to STDOUT.
 I     Compute the increments of the list, i.e., [a[n] - [b[n]].
   S   Compute the sum of the list, i.e., b[n] + a[n].
  ;    Concatenate the results to the left and to the right.
    ß  Recursively call the main link.


答:
Factor, 62 bytes

```<code>:: f ( a b -- x ) a b "%s %s" printf a b + a b - f ; recursive
</code>```

recursive, or else the callstack runs out too quickly.

Title: The plus-minus sequence

Body:
The plus-minus sequence

The plus-minus sequence is one that starts with two seeds, a(0) and b(0). Each iteration of this sequence is the addition and subtraction of the previous two members of the sequence. That is, a(N) = a(N-1) + b(N-1) and b(N) = a(N-1) - b(N-1).

Objective Produce the plus-minus sequence, in infinitude or the first K steps given K. You may do this using an infinite output program, a generator, or a function/program that gives the first K steps. The output order does not matter, so long as it is consistent. (I.e., b(K) a(K) or a(K) b(K), with some non-numeric, non-newline separator in between.) The output must start with the input.

Test cases

For inputs 10 2 (of a(0) b(0), this is a possible output for the first K approach (or a subsection of the infinite approach):

```<code>10     2
12     8
20     4
24     16
40     8
48     32
80     16
96     64
160    32
192    128
320    64
384    256
640    128
768    512
1280   256
1536   1024
2560   512
3072   2048
5120   1024
6144   4096
10240  2048
12288  8192
20480  4096
24576  16384
40960  8192
49152  32768
81920  16384
98304  65536
</code>```

For inputs 2 20 10 (a(0) b(0) k):

```<code>2     20
22   -18
4     40
44   -36
8     80
88   -72
16    160
176  -144
32    320
352  -288
</code>```

This is a code-golf, so the shortest program in bytes wins.

Catalog

The Stack Snippet at the bottom of this post generates the catalog from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

```<code>## Language Name, N bytes
</code>```

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

```<code>## Ruby, <s>104</s> <s>101</s> 96 bytes
</code>```

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

```<code>## Perl, 43 + 2 (-p flag) = 45 bytes
</code>```

You can also make the language name a link which will then show up in the snippet:

```<code>## [><>](http://esolangs.org/wiki/Fish), 121 bytes
</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

Body:
Factor, 62 bytes

:: f ( a b -- x ) a b "%s %s" printf a b + a b - f ; recursive

recursive, or else the callstack runs out too quickly.


答:
Ruby, 25 bytes

Based on xnor's Python solution. Perhaps I'll make a generator in another answer, but this will print a, then b, then the new a, then the new b, ad infinitum.

f=->a,b{p a,b;f[a+b,a-b]}
```

Title: The plus-minus sequence


问:
Reimplementing square root
Define a function, s, which takes a number and returns the square root.

No use of library functions, such as Java's Math.sqrt() or PHP's built in sqrt(), allowed.

答:
```<code>return 1.f/InvSqrt(x);
</code>```

InvSqrt of course courtesy of Quake.

What, you mean you wanted an accurate result?

ContentLicense: CC BY-SA 2.5

Title: Reimplementing square root

Body:
return 1.f/InvSqrt(x);

InvSqrt of course courtesy of Quake.

What, you mean you wanted an accurate result?


问:
Drawing a gradient in ASCII art
Task description:

Write a program as short as possible to draw a radial gradient in ASCII art. The size of the output grid is predefined. The center point and the characters to be used for the gradient are provided as input to the program.

The gradient will be 70×25 character cells in size with the following specifications

The upper-left corner of the grid has the coordinates (0, 0).

The gradient, consisting of the characters provided, is mapped into 35 length units. A length unit is one character tall and two characters wide (since monospaced fonts usually have characters twice as high as they are wide).

Within those 35 LU the current distance from the center point is multiplied by number of gradient characters/35 to get the index of the character to draw at that point. Fractional numbers for the index are rounded towards zero here. The length units are to be left as a real number. (Of course, if the results are the same, the implementation doesn't matter.)

Beyond those 35 LU only the last gradient character appears. However, since the last gradient »band« already starts within the 35 LU, the last character starts appearing short of 35 LU already.

Input:

The input is given on standard input and consists of three lines, each terminated by a line break:

The x coordinate of the gradient center point

The y coordinate of the gradient center point

The characters to use for drawing the gradient. Those may include spaces.

Output:

Output is the gradient as defined by the rules above on standard output. The standard error stream is ignored. Each line of the gradient is terminated by a line break. No other characters except those defined by the input may occur.

Sample input 1:

```<code>58
14
 .:;+=xX$&
</code>```

Sample output 1:

```<code>&&$$$$$$$$XXXXXXXXxxxxxxxxx===========++++++++++++++++++++++++++++++++
&$$$$$$$$XXXXXXXXxxxxxxxxx=========+++++++++++++;;;;;;;;;;;;;;;;;;;;;+
$$$$$$$$XXXXXXXXxxxxxxxx=========+++++++++++;;;;;;;;;;;;;;;;;;;;;;;;;;
$$$$$$$XXXXXXXXxxxxxxxx========++++++++++;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$$$$$$XXXXXXXXxxxxxxxx========+++++++++;;;;;;;;;;;;;:::::::::::::;;;;;
$$$$$XXXXXXXXxxxxxxxx=======+++++++++;;;;;;;;;;;:::::::::::::::::::::;
$$$$$XXXXXXXxxxxxxxx=======+++++++++;;;;;;;;;:::::::::::::::::::::::::
$$$$XXXXXXXXxxxxxxx=======++++++++;;;;;;;;;:::::::::::::::::::::::::::
$$$$XXXXXXXxxxxxxx========+++++++;;;;;;;;::::::::::...............::::
$$$XXXXXXXXxxxxxxx=======+++++++;;;;;;;;:::::::::...................::
$$$XXXXXXXxxxxxxx=======++++++++;;;;;;;::::::::.......................
$$$XXXXXXXxxxxxxx=======+++++++;;;;;;;::::::::.........       ........
$$$XXXXXXXxxxxxxx=======+++++++;;;;;;;:::::::........           ......
$$$XXXXXXXxxxxxxx=======+++++++;;;;;;;:::::::.......             .....
$$$XXXXXXXxxxxxxx=======+++++++;;;;;;;:::::::.......             .....
$$$XXXXXXXxxxxxxx=======+++++++;;;;;;;:::::::.......             .....
$$$XXXXXXXxxxxxxx=======+++++++;;;;;;;:::::::........           ......
$$$XXXXXXXxxxxxxx=======+++++++;;;;;;;::::::::.........       ........
$$$XXXXXXXxxxxxxx=======++++++++;;;;;;;::::::::.......................
$$$XXXXXXXXxxxxxxx=======+++++++;;;;;;;;:::::::::...................::
$$$$XXXXXXXxxxxxxx========+++++++;;;;;;;;::::::::::...............::::
$$$$XXXXXXXXxxxxxxx=======++++++++;;;;;;;;;:::::::::::::::::::::::::::
$$$$$XXXXXXXxxxxxxxx=======+++++++++;;;;;;;;;:::::::::::::::::::::::::
$$$$$XXXXXXXXxxxxxxxx=======+++++++++;;;;;;;;;;;:::::::::::::::::::::;
$$$$$$XXXXXXXXxxxxxxxx========+++++++++;;;;;;;;;;;;;:::::::::::::;;;;;
</code>```

Sample input 2:

```<code>0
0
X.X.X.X
</code>```

Sample output 2:

```<code>XXXXXXXXXX..........XXXXXXXXXX..........XXXXXXXXXX..........XXXXXXXXXX
XXXXXXXXXX..........XXXXXXXXXX..........XXXXXXXXXX..........XXXXXXXXXX
XXXXXXXXXX..........XXXXXXXXXX..........XXXXXXXXXX..........XXXXXXXXXX
XXXXXXXX............XXXXXXXXXX..........XXXXXXXXXX..........XXXXXXXXXX
XXXXXX.............XXXXXXXXXX...........XXXXXXXXXX..........XXXXXXXXXX
..................XXXXXXXXXXX..........XXXXXXXXXX...........XXXXXXXXXX
................XXXXXXXXXXXX...........XXXXXXXXXX..........XXXXXXXXXXX
...............XXXXXXXXXXXX...........XXXXXXXXXX...........XXXXXXXXXXX
............XXXXXXXXXXXXXX...........XXXXXXXXXXX..........XXXXXXXXXXXX
.........XXXXXXXXXXXXXXX............XXXXXXXXXXX...........XXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXX............XXXXXXXXXXX...........XXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXX.............XXXXXXXXXXX...........XXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXX..............XXXXXXXXXXXX...........XXXXXXXXXXXXXXX
XXXXXXXXXXXXXXX................XXXXXXXXXXXX............XXXXXXXXXXXXXXX
XXXXXXXXXXX..................XXXXXXXXXXXXX............XXXXXXXXXXXXXXXX
...........................XXXXXXXXXXXXX............XXXXXXXXXXXXXXXXXX
........................XXXXXXXXXXXXXXX............XXXXXXXXXXXXXXXXXXX
......................XXXXXXXXXXXXXXX.............XXXXXXXXXXXXXXXXXXXX
..................XXXXXXXXXXXXXXXXX.............XXXXXXXXXXXXXXXXXXXXXX
.............XXXXXXXXXXXXXXXXXXXX..............XXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...............XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXX...............XXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXX.................XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX...................XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXX......................XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
</code>```

Sample input 3:

```<code>70
25
.:+#
</code>```

Sample output 3:

```<code>######################################################++++++++++++++++
#################################################+++++++++++++++++++++
#############################################+++++++++++++++++++++++++
##########################################++++++++++++++++++++++++++++
#######################################+++++++++++++++++++++++++++++++
####################################++++++++++++++++++++++++++++++++++
##################################++++++++++++++++++++++++++++++++++++
################################++++++++++++++++++++++++++++++++++++++
##############################++++++++++++++++++++++++++++++++::::::::
#############################+++++++++++++++++++++++++++::::::::::::::
###########################+++++++++++++++++++++++++::::::::::::::::::
##########################++++++++++++++++++++++++::::::::::::::::::::
#########################++++++++++++++++++++++:::::::::::::::::::::::
########################+++++++++++++++++++++:::::::::::::::::::::::::
#######################++++++++++++++++++++:::::::::::::::::::::::::::
######################++++++++++++++++++++::::::::::::::::::::::::::::
#####################+++++++++++++++++++::::::::::::::::::::::::::::::
####################+++++++++++++++++++::::::::::::::::::::::::.......
####################++++++++++++++++++::::::::::::::::::::::..........
###################+++++++++++++++++++::::::::::::::::::::............
###################++++++++++++++++++:::::::::::::::::::..............
###################+++++++++++++++++:::::::::::::::::::...............
##################++++++++++++++++++::::::::::::::::::................
##################++++++++++++++++++:::::::::::::::::.................
##################++++++++++++++++++:::::::::::::::::.................
</code>```

Sample input 4

```<code>59
1
 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<>|,.-#+!$%&/()=?*'_:;
</code>```

Sample output 4

```<code>!+#-,|><87654210ZYWVUTRQPONLKJIHFEDCBzyxwutsrqonmlkjhgfedcbbbcdefghjkl
!+#-,|><87654210ZYWVUTRQPONLKJIHFEDCAzyxwutsrqonmljihgfdcba abcdfghijl
!+#-,|><87654210ZYWVUTRQPONLKJIHFEDCBzyxwutsrqonmlkjhgfedcbbbcdefghjkl
!+#-,|><97654310ZYXVUTSQPONMKJIHGEDCBAyxwvutrqponmkjihgffeedeeffghijkm
$+#-.|><98654320ZYXWUTSRQONMLKIHGFEDBAzyxwutsrqponmlkjihhggggghhijklmn
$!#-.,|<987643210YXWVUSRQPONLKJIHGEDCBAzywvutsrqponmllkjjjiiijjjkllmno
$!+#.,|><87654210ZYXVUTSRQONMLKJHGFEDCBAzywvutsrrqponnmmlllllllmmnnopq
%!+#-.|><987543210YXWVUTRQPONMLJIHGFEDCBAzyxwvutsrrqppooonnnnnoooppqrr
%$!+-.,|><87654310ZYXWVTSRQPONMLJIHGFEDCBAzyxxwvuttssrrqqqqqqqqqrrsstt
&%!+#-.,><987643210ZYXVUTSRQPONMLKJIHGFEDCBAzyyxwvvuutttssssssstttuuvv
&%$!+#.,|><986543210ZYWVUTSRQPONMLKJIHGFEDDCBAzzyyxwwwvvvuuuuuvvvwwwxy
/&%$!#-.,|><976543210ZYXVUTSRQPONMLKKJIHGFEEDCBBAAzzyyyxxxxxxxxxyyyzzA
(/&%!+#-.,|><876543210ZYXWVUTSRQPONMLKJJIHGGFEEDCCBBBAAAzzzzzzzAAABBBC
)(/%$!+#-.,|><876543210ZYXWVUTSRQPPONMLKKJIIHGGFFEEDDDCCCCCCCCCCCDDDEE
=)(&%$!+#-.,|><986543210ZYYXWVUTSRQPPONMMLKKJIIHHGGGFFFEEEEEEEEEFFFGGG
?=)(&%$!+#-.,|><9876543210ZYXWVVUTSRRQPOONMMLLKJJJIIIHHHHHHHHHHHHHIIIJ
*?=)(/%$!+#-.,|><98765432210ZYXWWVUTSSRQQPOONNMMLLLKKKJJJJJJJJJJJKKKLL
'*?=)(/&%$!+#-.,|><98765432110ZYXXWVUUTSSRRQPPOOONNNMMMMMLLLLLMMMMMNNN
_'*?=)(/&%$!+#-.,|><988765432210ZYYXWWVUUTTSSRRQQQPPPOOOOOOOOOOOOOPPPQ
:_'*?=)(/&%$!+##-.,|><9877654332100ZYYXXWVVUUTTTSSSRRRRQQQQQQQQQRRRRSS
;;:_'*?=)(/&%$!+#-.,,|><98876554322100ZZYYXXWWVVVUUUTTTTTTTTTTTTTTTUUU
;;;:_'*?=)(/&&%$!+#-.,,|><9987665443321100ZZYYYXXXWWWWVVVVVVVVVVVWWWWX
;;;;;:_'*?=)(/&%$$!+#-..,|>><9887665544322211000ZZZYYYYYYYYYYYYYYYYYZZ
;;;;;;:_'*??=)(/&%%$!+##-.,,|><<99877665544333222111100000000000001111
;;;;;;;;:_'*?==)(/&&%$!++#--.,,|>><<9887766655544433333322222223333334
</code>```

A week has passed. It is time to unveil the solution lengths from our university's contest:

167 – Python

  189 – Haskell

  203 – C

  210 – VB.NET

  219 – C

And our own solutions:

  91 – GolfScript

  125 – Ruby

  157 – PowerShell

Title: Drawing a gradient in ASCII art

Body:
Windows PowerShell, 157

Nothing noteworthy. Beaten to death already:

$x,$y,$c=@($input)
$l=$c.Length
$c+=(""+$c[-1])*90
0..24|%{$r=$_
-join(0..69|%{$c[[math]::truncate([math]::sqrt(($x-$_)*($x-$_)+4*($y-$r)*($y-$r))*$l/70)]})}


问:
Quack the Angry Duck
No one is quite certain what the emoticon >:U is intended to represent, but many scholars believe it looks like an angry duck. Let's assume that's the case.

Task

Given an integer n between 0 and 3 inclusive, print or return

```<code>quack
</code>```

if n = 0,

```<code>>:U
</code>```

if n = 1,

```<code>     U   U
>  : U   U
 >   U   U
>  : U   U
      UUU
</code>```

if n = 2, or

```<code>                  >:U         >:U
>:U               >:U         >:U
   >:U       >:U  >:U         >:U
      >:U         >:U         >:U
         >:U      >:U         >:U
      >:U         >:U         >:U
   >:U       >:U  >:U         >:U
>:U               >:U         >:U
                     >:U>:U>:U
</code>```

if n = 3.

You can assume the input will always be valid. There should be no leading space in the output, but any amount of trailing space is fine. Ducks (with the possible exception of @cobaltduck) have no tolerance for loopholes. Shortest code in bytes wins.

答:
Cinnamon Gum, 76 bytes

```<code>0000000: 6c33 502b 2c4d 4cce b636 54b3 b30a b536  l3P+,ML..6T....6
0000010: 5253 0081 5010 e6b2 5350 b082 3215 ecb0  RS..P...SP..2...
0000020: 8a42 1487 865a 1bab 2960 00a0 79c8 6c2e  .B...Z..)`..y.l.
0000030: 2026 a002 4221 0430 55c0 5938 cd40 9720   &..B!.0U.Y8.@.
0000040: 6c06 6177 90e9 17ac 4102 4100            l.aw....A.A.
</code>```

Non-competing since Cinnamon Gum was created after this challenge.

Try it online.

Explanation

The first byte l specifies the mode: in this case it tells Cinnamon Gum to enter lookup table mode. Cinnamon Gum then decompresses the rest of the string (which has been compressed with zopfli --deflate) into this:

```<code>0&quack;1&>:U;2&     U   U
>  : U   U
 >   U   U
>  : U   U
      UUU;3&                  >:U         >:U
>:U               >:U         >:U
   >:U       >:U  >:U         >:U
      >:U         >:U         >:U
         >:U      >:U         >:U
      >:U         >:U         >:U
   >:U       >:U  >:U         >:U
>:U               >:U         >:U
                     >:U>:U>:U
</code>```

It then splits by ;, puts each key-value pair (with & as delimiter) in a dictionary, and outputs dictionary[input].

Title: Quack the Angry Duck

Body:
Cinnamon Gum, 76 bytes

0000000: 6c33 502b 2c4d 4cce b636 54b3 b30a b536  l3P+,ML..6T....6
0000010: 5253 0081 5010 e6b2 5350 b082 3215 ecb0  RS..P...SP..2...
0000020: 8a42 1487 865a 1bab 2960 00a0 79c8 6c2e  .B...Z..)`..y.l.
0000030: 2026 a002 4221 0430 55c0 5938 cd40 9720   &..B!.0U.Y8.@.
0000040: 6c06 6177 90e9 17ac 4102 4100            l.aw....A.A.

Non-competing since Cinnamon Gum was created after this challenge.

<a href="http://cinnamon-gum.tryitonline.net/#code=MDAwMDAwMDogNmMzMyA1MDJiIDJjNGQgNGNjZSBiNjM2IDU0YjMgYjMwYSBiNTM2ICBsM1ArLE1MLi42VC4uLi42CjAwMDAwMTA6IDUyNTMgMDA4MSA1MDEwIGU2YjIgNTM1MCBiMDgyIDMyMTUgZWNiMCAgUlMuLlAuLi5TUC4uMi4uLgowMDAwMDIwOiA4YTQyIDE0ODcgODY1YSAxYmFiIDI5NjAgMDBhMCA3OWM4IDZjMmUgIC5CLi4uWi4uKWAuLnkubC4KMDAwMDAzMDogMjAyNiBhMDAyIDQyMjEgMDQzMCA1NWMwIDU5MzggY2Q0MCA5NzIwICAgJi4uQiEuMFUuWTguQC4gCjAwMDAwNDA6IDZjMDYgNjE3NyA5MGU5IDE3YWMgNDEwMiA0MTAwICAgICAgICAgICAgbC5hdy4uLi5BLkEuCg&input=Mw" rel="nofollow noreferrer">Try it online.

Explanation

The first byte l specifies the mode: in this case it tells Cinnamon Gum to enter lookup table mode. Cinnamon Gum then decompresses the rest of the string (which has been compressed with zopfli --deflate) into this:

0&quack;1&>:U;2&     U   U
>  : U   U
 >   U   U
>  : U   U
      UUU;3&                  >:U         >:U
>:U               >:U         >:U
   >:U       >:U  >:U         >:U
      >:U         >:U         >:U
         >:U      >:U         >:U
      >:U         >:U         >:U
   >:U       >:U  >:U         >:U
>:U               >:U         >:U
                     >:U>:U>:U

It then splits by ;, puts each key-value pair (with & as delimiter) in a dictionary, and outputs dictionary[input].


问:
Write an interpreter for my new programming language
I have a new programming language called Brussels-Sprout. Brussels-Sprout functions in an array of 256 boolean values, all initialized to zero, has one instruction pointer, and one "bit index".

After each (non-branching) instruction is executed, the instruction pointer is incremented by one. If the instruction pointer goes off the right side of the instruction array, the program terminates. Going off the left side is undefined behavior.

If the bit index is outside the bounds of the array, it should be reset to 0.

Brussels-Sprout uses the following keywords, which are always lowercase:

chew - Invert the value in the array at the bit index. (flip the bit at the bit index)

swallow - Increment the bit index.

vomit - Decrement the bit index.

complain - Output the bit at the bit index to stdout, or equivalent output log.

feedtodog - If the bit at the bit index is 0, skip the next instruction. Otherwise, increment instruction pointer by 1.

playwithfood - If the bit at the bit index is 1, jump backwards 2 instructions. Otherwise, increment instruction pointer by 1.

If an instruction not on this list is executed, undefined behavior occurs.

I'm sure that this sounds like a very certain other turing-tarpit programming language. But since this programming language operates in boolean values and not bytes, I think it is different.

Test cases:

```<code>chew complain -> 1
swallow chew swallow chew swallow vomit complain playwithfood -> 11
chew complain swallow chew complain swallow chew complain swallow complain -> 1110
chew feedtodog undefinedbehaviour complain -> 1
</code>```

Your challenge is to write an interpreter for Brussels-Sprout. This is code golf, so shortest program wins!

答:
SpecBAS (modern Sinclair BASIC interpreter) 202 Bytes

```<code>1 INPUT a$:DIM b(256)BASE 0,i$(),a$(SPLIT a$," "):DO 6:READ b,i$(b):LOOP:b=0,i=1:DO:c=b(b):EXECUTE i$(CODE a$(i,4)-99):b&=255,i+=1:LOOP:DATA 20,"b(b)=1-c",9,"b+=1",6,"b-=1",13,"?c;",1,"i+=c",22,"i-=3*c"
</code>```

Or to make it a little clearer:

```<code>1 INPUT a$:
  DIM b(256) BASE 0,i$(),a$(SPLIT a$," "):
  DO 6:
    READ b,i$(b):
  LOOP:
  b=0,i=1:
  DO:
    c=b(b):
    EXECUTE i$(CODE a$(i,4)-99):
    b&=255,i+=1:
  LOOP:
  DATA 20,"b(b)=1-c",9,"b+=1",6,"b-=1",13,"?c;",1,"i+=c",22,"i-=3*c"
</code>```

Uses some features that weren't available in the 80s, so there's that. Also shameless rips off some of the techniques in other entries. Sorry about that!

Input is from the user at runtime. Execution ends with an error "Subscript wrong".

Body:
SpecBAS (modern Sinclair BASIC interpreter) 202 Bytes

1 INPUT a$:DIM b(256)BASE 0,i$(),a$(SPLIT a$," "):DO 6:READ b,i$(b):LOOP:b=0,i=1:DO:c=b(b):EXECUTE i$(CODE a$(i,4)-99):b&=255,i+=1:LOOP:DATA 20,"b(b)=1-c",9,"b+=1",6,"b-=1",13,"?c;",1,"i+=c",22,"i-=3*c"

Or to make it a little clearer:

1 INPUT a$:
  DIM b(256) BASE 0,i$(),a$(SPLIT a$," "):
  DO 6:
    READ b,i$(b):
  LOOP:
  b=0,i=1:
  DO:
    c=b(b):
    EXECUTE i$(CODE a$(i,4)-99):
    b&=255,i+=1:
  LOOP:
  DATA 20,"b(b)=1-c",9,"b+=1",6,"b-=1",13,"?c;",1,"i+=c",22,"i-=3*c"

Uses some features that weren't available in the 80s, so there's that. Also shameless rips off some of the techniques in other entries. Sorry about that!

Input is from the user at runtime. Execution ends with an error "Subscript wrong".


答:
Python 3.5, 55 43 bytes:

```<code>def q(a,b):
 while 1:print(a,b);a,b=a+b,a-b
</code>```

Prints out the correct sequence seemingly forever. I have been able to let this go on for about 30 minutes without any error being raised, and the program had printed out 2301 digits for the first number, and 1150 digits for the second! Based on this, I guessing that, being provided sufficient hardware to run on, this can go on for WAY longer and print out WAY more digits, and also has theoretically no recursion limit, courtesy of the while loop!

Title: The plus-minus sequence

Body:
Python 3.5, 55 43 bytes:

def q(a,b):
 while 1:print(a,b);a,b=a+b,a-b

Prints out the correct sequence seemingly forever. I have been able to let this go on for about 30 minutes without any error being raised, and the program had printed out 2301 digits for the first number, and 1150 digits for the second! Based on this, I guessing that, being provided sufficient hardware to run on, this can go on for WAY longer and print out WAY more digits, and also has theoretically no recursion limit, courtesy of the while loop!


问:
The Arithmetic Derivative
The derivative of a function is a cornerstone of mathematics, engineering, physics, biology, chemistry, and a large number of other sciences as well. Today we're going to be calculating something only tangentially related: the arithmetic derivative.

Definition

The arithmetic derivative a(n) or n' is defined here (A003415) by a number of properties that are similar to the derivative of a function.

a(0) = a(1) = 0,

a(p) = 1, where p is any prime, and

a(mn) = m*a(n) + n*a(m).

The third rule is based on the product rule for differentiation of functions: for functions f(x) and g(x), (fg)' = f'g + fg'. So with numbers, (ab)' = a'b + ab'.

Also of note, since the arithmetic derivative can be extended to the negative numbers via this simple relation, a(-n) = -a(n), the input may be negative.

Rules

Write a program or function that, given any integer n, returns the arithmetic derivative of n.

Inputs will be -230 < n < 230, to avoid problems with integer sizes and numbers too large to factor in a reasonable amount of time. Your algorithm should still be able to theoretically calculate the arithmetic derivative of numbers outside this range.

Built-ins for symbolic math, prime factorization and differentiation are allowed.

Examples

```<code>> a(1)
0
> a(7)
1
> a(14)   # a(7)*2 + a(2)*7 = 1*2 + 1*7 = 9
9
> a(-5)   # a(-5) = -a(5) = -1
-1
> a(8)    # a(8) = a(2**3) = 3*2**2 = 12
12
> a(225)  # a(225) = a(9)*25 + a(25)*9 = 6*25 + 10*9 = 150 + 90 = 240
240
> a(299792458)  # a(299792458) = a(2)*149896229 + a(7)*42827494 + a(73)*4106746 + a(293339)*1022 = 1*149896229 + 1*42827494 + 1*4106746 + 1*1022 = 149896229 + 42827494 + 4106746 + 1022 = 196831491
196831491
</code>```

As always, if the problem is unclear, please let me know. Good luck and good golfing!

答:
Seriously, <s>17</s> <s>14</s> <s>11</s> 12 bytes

My first ever Seriously answer. This answer is based on Luis Mendo's MATL answer and the idea that the arithmetic derivative of a number m is equal to m·(1/p1 + 1/p2 + ... + 1/pn) where p1...pn is every prime factor of n to multiplicity. My addition is to note that, if m = p1e1·p2e2·...·pnen, then a(m) = m·(e1/p1 + e2/p2 + ... + en/pn). Thanks to Mego for golfing and bug fixing help. Try it online!

```<code>,;w`i@/`MΣ*l
</code>```

Ungolfing:

```<code>,             get a single input
 ;w           duplicate input and get prime factorization, p_f
               for input [-1..1], this returns [] and is dealt with at the end
   `   `M     map the function inside `` to p_f
    i         pop all elements of p_f[i], the prime and the exponent, to the stack
     @        rotate so that the exponent is at the top of the stack
      /       divide the exponent by the prime
         Σ    sum it all together
          *   multiply this sum with the input
           l  map and multiply do not affect an empty list, so we just take the length, 0
               l is a no-op for a number, so the result is unchanged for all other inputs
</code>```

Title: The Arithmetic Derivative

Body:
Seriously, <s>17</s> <s>14</s> <s>11</s> 12 bytes

My first ever Seriously answer. This answer is based on Luis Mendo's MATL answer and the idea that the arithmetic derivative of a number m is equal to m·(1/p1 + 1/p2 + ... + 1/pn) where p1...pn is every prime factor of n to multiplicity. My addition is to note that, if m = p1e1·p2e2·...·pnen, then a(m) = m·(e1/p1 + e2/p2 + ... + en/pn). Thanks to Mego for golfing and bug fixing help. Try it online!

,;w`i@/`MΣ*l

Ungolfing:

,             get a single input
 ;w           duplicate input and get prime factorization, p_f
               for input [-1..1], this returns [] and is dealt with at the end
   `   `M     map the function inside `` to p_f
    i         pop all elements of p_f[i], the prime and the exponent, to the stack
     @        rotate so that the exponent is at the top of the stack
      /       divide the exponent by the prime
         Σ    sum it all together
          *   multiply this sum with the input
           l  map and multiply do not affect an empty list, so we just take the length, 0
               l is a no-op for a number, so the result is unchanged for all other inputs


答:
Python 2.7, <s>56</s>, 42 bytes:

```<code>a,b=input()
while 1:print a,b;a,b=a+b,a-b
</code>```

Simple loop that either prints forever(ish).

Title: The plus-minus sequence

Body:
Python 2.7, <s>56</s>, 42 bytes:

a,b=input()
while 1:print a,b;a,b=a+b,a-b

Simple loop that either prints forever(ish).


问:
Double-duty quine: quine!dlroW ,olleH
Write a program that will output its own source code when run, and nothing else. Seems easy, right?

The catch is that when the source code is reversed, your program must output "Hello, World!" exactly, without the quotes.

This is code-golf, so lowest byte count wins.

Edit: Your quine must be a proper quine.

答:
JavaScript (ES6), 71 bytes

```<code>trela=a=>alert("trela="+trela+"\ntrela\n``")//
`!dlroW ,olleH`
trela
``
</code>```

How it Works:

Line 1 defines function trela that when run outputs the program's source code. Line 2 is an unassigned string, does nothing. Lines 3 and 4 call trela abusing the template string syntax.

Reversed:

```<code>``
alert
`Hello, World!`
//)"``n\alertn\"+alert+"=alert"(trela>=a=alert
</code>```

How it Works:

Line 1 is an unassigned string, does nothing. Lines 2 and 3 abuse the template string syntax to print Hello, World!. Line 4 is a comment.

Title: Double-duty quine: quine!dlroW ,olleH

Body:
JavaScript (ES6), 71 bytes

trela=a=>alert("trela="+trela+"\ntrela\n``")//
`!dlroW ,olleH`
trela
``

How it Works:

Line 1 defines function trela that when run outputs the program's source code. Line 2 is an unassigned string, does nothing. Lines 3 and 4 call trela abusing the template string syntax.

Reversed:

``
alert
`Hello, World!`
//)"``n\alertn\"+alert+"=alert"(trela>=a=alert

How it Works:

Line 1 is an unassigned string, does nothing. Lines 2 and 3 abuse the template string syntax to print Hello, World!. Line 4 is a comment.


答:
GolfScript, 33 bytes

Forwards

```<code>{`".;1$~]"}"!dlroW ,olleH".;1$~]

</code>```

Try it online!

Backwards

```<code>
]~$1;."Hello, World!"}"]~$1;."`{
</code>```

Try it online!

Title: Double-duty quine: quine!dlroW ,olleH

Body:
Write a program that will output its own source code when run, and nothing else. Seems easy, right?

The catch is that when the source code is reversed, your program must output "Hello, World!" exactly, without the quotes.

This is code-golf, so lowest byte count wins.

Edit: Your quine must be a proper quine.

Body:
GolfScript, 33 bytes

Forwards

{`".;1$~]"}"!dlroW ,olleH".;1$~]

Try it online!

Backwards

]~$1;."Hello, World!"}"]~$1;."`{

Try it online!


问:
Print N Squared
Write a program or function that takes in a non-negative integer N from stdin or as a function argument. It must print or return a string of a hollow ASCII-art square whose sides are each made with N copies of the number N.

Specifically:

If N is 0, no copies of N are used, so there should be no output (or only a single trailing newline).

If N is 1, the output is:

```<code>1
</code>```

If N is 2:

```<code>22
22
</code>```

If N is 3:

```<code>333
3 3
333
</code>```

If N is 4:

```<code>4444
4  4
4  4
4444
</code>```

If N is 5:

```<code>55555
5   5
5   5
5   5
55555
</code>```

The pattern continues for 6 through 9.

If N is 10, the output is:

```<code>10101010101010101010
10                10
10                10
10                10
10                10
10                10
10                10
10                10
10                10
10101010101010101010
</code>```

Notice that this is not actually square. It is 10 rows tall but 20 columns wide because 10 is two characters long. This is intended. The point is that each side of the "square" contains N copies of N. So all inputs beyond 9 will technically be ASCII rectangles.

For example, if N is 23, the output is:

```<code>2323232323232323232323232323232323232323232323
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
2323232323232323232323232323232323232323232323</code>```

Here are Pastebins of the required outputs for 99, 100, 111, and 123 (they may look wrong in a browser but in a text editor they'll look correct). The output for 1000 is to large for Pastebin but it would have 1000 rows and 4000 columns. Numbers with 4 or more digits must work just like smaller numbers.

Details:

N must be written in the usual decimal number representation, with no + sign or other non-digits.

The hollow area must only be filled with spaces.

No lines should have leading or trailing spaces.

A single newline after the squares' last line is optionally allowed.

Languages written after this challenge was made are welcome, they just aren't eligible to win.

The shortest code in bytes wins!

答:
Python 3.5, 101 135 bytes:

(+34 since apparently an input of 1 should just output 1 and an input of 0 should output nothing)

```<code>def y(g):g=str(g);i=len(g);[print(g*(int(g))+('\n'+g+' '*((int(g)*i)-(i*2))+g)*(int(g)-2)+'\n'+g*int(g))if int(g)>1 else print(g*int(g))]
</code>```

Prints out all the correct values for any integer input, whether in string form or not.

Sample Inputs and Outputs:

```<code>Input: y(10)

Output:

    10101010101010101010
    10                10
    10                10
    10                10
    10                10
    10                10
    10                10
    10                10
    10                10
    10101010101010101010

Input: y(1)

Output:

    1

Input: y(2)

Output:

    22
    22

Input: y(4)

Output:

    4444
    4  4
    4  4
    4444
</code>```

However, for triple digit numbers, it was just too big to fit on my monitor, so I hope that comes out correct if someone else tries it. I suspect it should since all 1 and 2 digit numbers come out correctly.

Title: Print N Squared

Body:
Python 3.5, 101 135 bytes:

(+34 since apparently an input of 1 should just output 1 and an input of 0 should output nothing)

def y(g):g=str(g);i=len(g);[print(g*(int(g))+('\n'+g+' '*((int(g)*i)-(i*2))+g)*(int(g)-2)+'\n'+g*int(g))if int(g)>1 else print(g*int(g))]

Prints out all the correct values for any integer input, whether in string form or not.

Sample Inputs and Outputs:

Input: y(10)

Output:

    10101010101010101010
    10                10
    10                10
    10                10
    10                10
    10                10
    10                10
    10                10
    10                10
    10101010101010101010

Input: y(1)

Output:

    1

Input: y(2)

Output:

    22
    22

Input: y(4)

Output:

    4444
    4  4
    4  4
    4444

However, for triple digit numbers, it was just too big to fit on my monitor, so I hope that comes out correct if someone else tries it. I suspect it should since all 1 and 2 digit numbers come out correctly.


问:
Reverse stdin and place on stdout
Requirements:

Take an input on stdin including new lines / carriage returns of unlimited length (only bounded by system memory; that is, there is no inherent limit in the program.)

Output the reverse of the input on stdout.

Example:

Input:

```<code>Quick brown fox
He jumped over the lazy dog
</code>```

Output:

```<code>god yzal eht revo depmuj eH
xof nworb kciuQ
</code>```

Shortest wins.

Leaderboard:

var QUESTION_ID=242,OVERRIDE_USER=61563;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

答:
Fuzzy Octo Guacamole, 2 bytes

(non-competing, FOG is newer than the challenge)

```<code>^z
</code>```

^ gets input, z reverses, and implicit output.

Title: Reverse stdin and place on stdout

Body:
Fuzzy Octo Guacamole, 2 bytes

(non-competing, FOG is newer than the challenge)

^z

^ gets input, z reverses, and implicit output.


问:
Open the browser to http://codegolf.stackexchange.com
Your job is to open a browser window of the default browser to http://codegolf.stackexchange.com.

Your code must open the browser itself, and cannot rely on an open one.

This is code-golf, so the shortest answer in bytes wins.

Moderator note: A large number of answers to this challenge use the URLs http://ppcg.lol or http://ppcg.ga. These URLs did direct to https://codegolf.stackexchange.com at the time, but have since expired. By this meta discussion, they have been allowed to stay, with the note that they are currently invalid.

答:
C++, 61 Bytes

#include <cstdlib>
main(){system("xdg-open http:ppcg.lol");}
```

Just a rip off of the bash solution using system, and it only works on systems using the freedesktop tools. Also shortened by using the short link some kindly provided, otherwise it would be much longer.

Body:
C++, 61 Bytes

#include <cstdlib>
main(){system("xdg-open http:ppcg.lol");}

Just a rip off of the bash solution using system, and it only works on systems using the freedesktop tools. Also shortened by using the short link some kindly provided, otherwise it would be much longer.


问:
Clean the muddy quartata-fish
This challenge is in honor of the Rookie of the Year category winners of Best of PPCG 2015: muddyfish (for I'm not the language you're looking for!) and quartata (for Implement a Truth-Machine).
Congratulations!

Background

In the deepest trenches of the ocean, there lives a rare and elusive square-shaped fish called the quartata-fish.
It looks like the glider from the Game of Life cellular automaton.
Here are two quartata-fish of different sizes:

```<code>-o-
--o
ooo

--oo--
--oo--
----oo
----oo
oooooo
oooooo
</code>```

You have managed to snap a photo of the quartata-fish, but the fish is rather hard to see since it's covered in mud.
Now you'll have to write a program to clean up the photo.

Input

Your input is a rectangular 2D grid of the characters .-o#, given as a newline-separated string.
If you want, you can use pipes | instead of newlines as the separators, and you may assume one trailing and/or preceding separator.

The input will contain exactly one quartata-fish of some side-length 3*n, where n ≥ 1 is a positive integer, surrounded by periods . that represent the ocean floor.
The fish will always be in the orientation depicted above.
Overlaid on this grid, there will be exactly one non-empty rectangular region of hashes #, which represents a blob of mud.
The blob may cover the quartata-fish partially or entirely.
An example input would be

```<code>............
..--oo--....
..--oo--....
..---#####..
..---#####..
..ooo#####..
..oooooo....
</code>```

Output

Your output shall be generated from the input by replacing all the hashes with the characters .-o, so that the grid contains exactly one quartata-fish.
There will always be a unique way to perform this replacement properly; in particular, the blob of mud will cover the fish entirely only if its size is 3×3.
The output shall use the same separator as the input.
For the above input, the correct output would be

```<code>............
..--oo--....
..--oo--....
..----oo....
..----oo....
..oooooo....
..oooooo....
</code>```

Rules and scoring

You can write a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.
There are no time bounds: if your submission would eventually halt given unlimited time and resources, you're fine.

Test cases

```<code>Input:
.......
...-o-.
...--o.
##.ooo.
##.....
Output:
.......
...-o-.
...--o.
...ooo.
.......

Input:
...-o-.
...-#o.
...ooo.
.......
Output:
...-o-.
...--o.
...ooo.
.......

Input:
.........
.###.....
.###.....
.ooo.....
Output:
.........
.-o-.....
.--o.....
.ooo.....

Input:
.....
.###.
.###.
.###.
Output:
.....
.-o-.
.--o.
.ooo.

Input:
......
......
......
...###
...###
...###
Output:
......
......
......
...-o-
...--o
...ooo

Input:
###o--....
###o--....
###-oo....
###-oo....
###ooo....
###ooo....
###.......
Output:
--oo--....
--oo--....
----oo....
----oo....
oooooo....
oooooo....
..........

Input:
............
..--oo--....
..--oo--....
..---#####..
..---#####..
..ooo#####..
..oooooo....
Output:
............
..--oo--....
..--oo--....
..----oo....
..----oo....
..oooooo....
..oooooo....

Input:
...--oo--....
.#########...
.#########...
.#########...
...oooooo....
...oooooo....
.............
.............
Output:
...--oo--....
...--oo--....
...----oo....
...----oo....
...oooooo....
...oooooo....
.............
.............

Input:
..............
..............
.########.....
.########.....
.########-....
.########-....
.########o....
.########o....
.########o....
.########o....
.########.....
..............
Output:
..............
..............
..............
..............
....--oo--....
....--oo--....
....----oo....
....----oo....
....oooooo....
....oooooo....
..............
..............

Input:
.................
.................
..---ooo---......
..--#########....
..--#########....
..--#########....
..--#########....
..--#########....
..oo#########....
..oo#########....
..oo#########....
....#########....
Output:
.................
.................
..---ooo---......
..---ooo---......
..---ooo---......
..------ooo......
..------ooo......
..------ooo......
..ooooooooo......
..ooooooooo......
..ooooooooo......
.................

Input:
.........................
.........................
....----oooo----.........
....----########.........
....----########.........
....----########.........
....----########.........
....----########.........
....----########.........
....----########.........
....oooo########.........
....oooo########.........
....oooooooooooo.........
....oooooooooooo.........
.........................
Output:
.........................
.........................
....----oooo----.........
....----oooo----.........
....----oooo----.........
....----oooo----.........
....--------oooo.........
....--------oooo.........
....--------oooo.........
....--------oooo.........
....oooooooooooo.........
....oooooooooooo.........
....oooooooooooo.........
....oooooooooooo.........
.........................
</code>```

答:
JavaScript (ES6), 291 bytes

g=>eval('w=g.search`\n`;h=g.length/w|0;for(n=(w<h?w:h)/3|0;s=n*3;n--)for(x=w+1-s;x--;)for(y=h+1-s;y--;[...g].every((c,i)=>c==o[i]|c=="#")?z=p:0)for(p="",i=h;i--;)p=(l=[,"-o-","--o","ooo"][(i-y)/n+1|0],l?"."[t="repeat"](x)+l.replace(/./g,c=>c[t](n))+"."[t](w-x-s):"."[t](w))+(p?`\n`:"")+p;z')
```

<h2>Explanation</h2>

<p>Takes input grid as a newline separated string. Not completely golfed, will do more when I get time.</p>

<p>It works by:</p>

<ul>
<li>Getting every possible position and size of a fish in the bounds of the input grid.</li>
<li>For each position/size, it builds a grid string with a fish in that position.</li>
<li>Checks if this is the correct output by iterating over every character. If each character either matches or is a hash, it outputs the built string.</li>
</ul>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var solution =

g=>
  eval(`

    // Get size of input grid
    w=g.search\`\n\`;
    h=g.length/w|0;

    // Check every possible size (n) and position (x and y) of fish
    for(n=(w<h?w:h)/3|0;s=n*3;n--)
      for(x=w+1-s;x--;)
        for(y=h+1-s;y--;

          // Check if possible solution matches input grid
          [...g].every((c,i)=>c==p[i]|c=="#")?z=p:0
        )

          // Create possible solution grid
          for(p="",i=h;i--;)
            p=(
              l=[,"-o-","--o","ooo"][(i-y)/n+1|0],
              l?
                "."[t="repeat"](x)+
                l.replace(/./g,c=>c[t](n))+
                "."[t](w-x-s)
              :"."[t](w)
            )+(p?\`\n\`:"")+p;
    z
  `)</code>```

<textarea id="input" rows="6" cols="40">..............
..............
.########.....
.########.....
.########-....
.########-....
.########o....
.########o....
.########o....
.########o....
.########.....
..............</textarea>

<button onclick="result.textContent=solution(input.value)">Go</button>

```</code>```

Title: Clean the muddy quartata-fish

Body:
JavaScript (ES6), 291 bytes

g=>eval('w=g.search`\n`;h=g.length/w|0;for(n=(w<h?w:h)/3|0;s=n*3;n--)for(x=w+1-s;x--;)for(y=h+1-s;y--;[...g].every((c,i)=>c==o[i]|c=="#")?z=p:0)for(p="",i=h;i--;)p=(l=[,"-o-","--o","ooo"][(i-y)/n+1|0],l?"."[t="repeat"](x)+l.replace(/./g,c=>c[t](n))+"."[t](w-x-s):"."[t](w))+(p?`\n`:"")+p;z')

Explanation

Takes input grid as a newline separated string. Not completely golfed, will do more when I get time.

It works by:

Getting every possible position and size of a fish in the bounds of the input grid.

For each position/size, it builds a grid string with a fish in that position.

Checks if this is the correct output by iterating over every character. If each character either matches or is a hash, it outputs the built string.

var solution =

g=>
  eval(`

    // Get size of input grid
    w=g.search\`\n\`;
    h=g.length/w|0;

    // Check every possible size (n) and position (x and y) of fish
    for(n=(w<h?w:h)/3|0;s=n*3;n--)
      for(x=w+1-s;x--;)
        for(y=h+1-s;y--;

          // Check if possible solution matches input grid
          [...g].every((c,i)=>c==p[i]|c=="#")?z=p:0
        )

          // Create possible solution grid
          for(p="",i=h;i--;)
            p=(
              l=[,"-o-","--o","ooo"][(i-y)/n+1|0],
              l?
                "."[t="repeat"](x)+
                l.replace(/./g,c=>c[t](n))+
                "."[t](w-x-s)
              :"."[t](w)
            )+(p?\`\n\`:"")+p;
    z
  `)

<textarea id="input" rows="6" cols="40">..............
..............
.########.....
.########.....
.########-....
.########-....
.########o....
.########o....
.########o....
.########o....
.########.....
..............</textarea><br />
<button onclick="result.textContent=solution(input.value)">Go</button>
<pre id="result"></pre>


答:
Seriously, 2 bytes (non-competitive)

```<code>R
</code>```

There is a formfeed character (ASCII 0x0C) as the first byte. Hexdump (reversible with xxd -r):

```<code>00000000: 0c52                                     .R
</code>```

Try it online! (note that the formfeed shows up as the dingbat ♀ on TIO - one of the nice features Dennis has added is the parsing of CP437 dingbats into ASCII control codes).

Title: Reverse stdin and place on stdout

Body:
Requirements:

Take an input on stdin including new lines / carriage returns of unlimited length (only bounded by system memory; that is, there is no inherent limit in the program.)

Output the reverse of the input on stdout.

Example:

Input:

```<code>Quick brown fox
He jumped over the lazy dog
</code>```

Output:

```<code>god yzal eht revo depmuj eH
xof nworb kciuQ
</code>```

Shortest wins.

Leaderboard:

var QUESTION_ID=242,OVERRIDE_USER=61563;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

```

Body:
Seriously, 2 bytes (non-competitive)

R

There is a formfeed character (ASCII 0x0C) as the first byte. Hexdump (reversible with xxd -r):

00000000: 0c52                                     .R

Try it online! (note that the formfeed shows up as the dingbat ♀ on TIO - one of the nice features Dennis has added is the parsing of CP437 dingbats into ASCII control codes).


答:
Seriously, 10 bytes

```<code>,Rp@εjS@$+
</code>```

Try it online!

Explanation:

```<code>,Rp@εjS@$+
,Rp@        push range(1, input()+1), pop first element (1), swap
    εjS     join list on empty string, sort
       @$+  prepend the 1
</code>```

Title: The Rien Number

Body:
The Champernowne constant is a number that is constructed by concatenating the first n numbers, with n tending to infinity. It looks something like this:

```<code>0.123456789101112131415161718192021222324252627282930...
</code>```

Now, I will describe to you the Rien number. It can be thought of as a minimization of the Champernowne constant as an integer. I will refer to the Rien number with the first n digits as Ri(n). This is how to formulate it:

The first n natural numbers (the sequence {1,2,3,...}) are concatenated.

This result is then sorted, according to the digit value. So 1..12 would look like 011111223456789.

Since the Rien number cannot have leading zeroes, we move all 0s so that they are significant, whilst keeping the number minimized, resulting in, say, 101111223456789. This is Ri(n), in this case, Ri(12).

Here are some results for Ri(n):

```<i>n</i>    Ri(<i>n</i>)
1    1
2    12
3    123
7    1234567
9    123456789
10   10123456789
15   101111111223344556789
34   10001111111111111222222222222223333333334444555666777888999
42   100001111111111111122222222222222233333333333333444444455556666777788889999
45   100001111111111111122222222222222233333333333333344444444444555556666777788889999
55   10000011111111111111122222222222222223333333333333333444444444444444455555555555566666777778888899999
100  100000000000111111111111111111112222222222222222222233333333333333333333444444444444444444445555555555555555555566666666666666666666777777777777777777778888888888888888888899999999999999999999
999  100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
```

Objective Given a number 1 ≤ n < 10000 as input (via arguments, STDIN, or hardcoding if your language does not support conventional input), output/return Ri(n).

This is a code-golf, so the shortest code in bytes wins. You may use a language that was made after this contest, as long as it was not made for answering this challenge. (Of course, you can use it, if it provides an interesting solution, but mark your answer as non-competing.)

Reference implementation

I tested this in IE, so there really shouldn't be a problem. If there is a problem, there's an easy solution: get a sane browser.

function min(n) {
  var seq = [];
  for(var i = 1; i <= n; i++) seq.push(i);
  seq = seq.join("").split("").map(Number);
  var to;
  if(seq.indexOf(1) >= 0) to = seq.splice(seq.indexOf(1), 1);
  seq.sort(function(a, b) {
    return a - b;
  });
  if(to) seq = to.concat(seq);
  return seq.join("");
}
t.onchange = t.onkeyup = function() {
  h.innerHTML = min(this.value)
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>* {
  font-family: Consolas, monospace;
}
input {
  border: 2px dotted #aaaaaa;
  border-radius: 5px;
  margin: 10px;
}</code>```

<input id="t" type="number">

```
</div>
</div>
</p>

<hr>

<h2>Leaderboard</h2>

<p>The Stack Snippet at the bottom of this post generates the catalog from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.</p>

<p>To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:</p>

```## Language Name, N bytes
```

<p>where <code>N</code> is the size of your submission. If you improve your score, you <em>can</em> keep old scores in the headline, by striking them through. For instance:</p>

```## Ruby, <s>104</s> <s>101</s> 96 bytes
```

<p>If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the <em>last</em> number in the header:</p>

```## Perl, 43 + 2 (-p flag) = 45 bytes
```

<p>You can also make the language name a link which will then show up in the snippet:</p>

```## [><>](http://esolangs.org/wiki/Fish), 121 bytes
```

<p><div class="snippet" data-lang="js" data-hide="true">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var QUESTION_ID=68685,OVERRIDE_USER=44713;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;</code>```

body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td>Link</td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td>Link</td></tr></tbody> </table></code>```

Body:
Seriously, 10 bytes

,Rp@εjS@$+

Try it online!

Explanation:

,Rp@εjS@$+
,Rp@        push range(1, input()+1), pop first element (1), swap
    εjS     join list on empty string, sort
       @$+  prepend the 1


答:
Python 2, 131 bytes

Forward:

```<code>print(lambda x:x+repr(x)+")#'!dlroW ,olleH' tnirp")('print(lambda x:x+repr(x)+")#\'!dlroW ,olleH\' tnirp")(')#'!dlroW ,olleH' tnirp
</code>```

Reverse:

```<code>print 'Hello, World!'#)'()"print '\Hello, World!'\#)"+)x(rper+x:x adbmal(tnirp'()"print 'Hello, World!'#)"+)x(rper+x:x adbmal(tnirp
</code>```

The first half is a one-line quine, followed by a # to form a comment separating the first half from the simpler second half.

Title: Double-duty quine: quine!dlroW ,olleH

Body:
Python 2, 131 bytes

Forward:

print(lambda x:x+repr(x)+")#'!dlroW ,olleH' tnirp")('print(lambda x:x+repr(x)+")#\'!dlroW ,olleH\' tnirp")(')#'!dlroW ,olleH' tnirp

Reverse:

print 'Hello, World!'#)'()"print '\Hello, World!'\#)"+)x(rper+x:x adbmal(tnirp'()"print 'Hello, World!'#)"+)x(rper+x:x adbmal(tnirp

The first half is a one-line quine, followed by a # to form a comment separating the first half from the simpler second half.


答:
JavaScript (ES6), <s>42</s> 38 bytes

f=_=>/\//g&&"f="+f||"!dlroW ,olleH">=_
```

<h2>Reversed</h2>

<pre class="lang-js prettyprint-override"><code>_=>"Hello, World!"||f+"=f"&&g//\/>=_=f
</code>```

Explanation

When reversed, it becomes an anonymous function that returns the string Hello, World!.

The regex /\//g becomes a comment when it is reversed, which allows the syntactically invalid >=_=f to be commented out in the reversed code.

Title: Double-duty quine: quine!dlroW ,olleH

Body:
JavaScript (ES6), <s>42</s> 38 bytes

f=_=>/\//g&&"f="+f||"!dlroW ,olleH">=_

Reversed

_=>"Hello, World!"||f+"=f"&&g//\/>=_=f

Explanation

When reversed, it becomes an anonymous function that returns the string Hello, World!.

The regex /\//g becomes a comment when it is reversed, which allows the syntactically invalid >=_=f to be commented out in the reversed code.


答:
Python 2, 325 bytes

def f(s):
 s=map(list,s.split());R=range;L=len(s);M=len(s[0])
 for h in R(L/3*3,0,-3):
  for x in R(M-h+1):
   for y in R(L-h+1):
    if all(s[v%L][v/L]in".-#o #"[0<=v%L-y<h>v/L-x>=0::2]for v in R(L*M)):
     for k in R(h*h):s[y+k/h][x+k%h]="-o"[482>>k/h*3/h*3+k%h*3/h&1]
     return'\n'.join(map(''.join,s)).replace('#','.')
```

A badly golfed solution for now – the for .. in range(...)s are an utter train wreck. Inputs/outputs newline separated strings.

The byte count currently assumes space indents only – I'll switch to mixed tabs/spaces later when I'm done golfing, if necessary.

Title: Clean the muddy quartata-fish

Body:
This challenge is in honor of the Rookie of the Year category winners of Best of PPCG 2015: muddyfish (for I'm not the language you're looking for!) and quartata (for Implement a Truth-Machine).
Congratulations!

Background

In the deepest trenches of the ocean, there lives a rare and elusive square-shaped fish called the quartata-fish.
It looks like the glider from the Game of Life cellular automaton.
Here are two quartata-fish of different sizes:

```<code>-o-
--o
ooo

--oo--
--oo--
----oo
----oo
oooooo
oooooo
</code>```

You have managed to snap a photo of the quartata-fish, but the fish is rather hard to see since it's covered in mud.
Now you'll have to write a program to clean up the photo.

Input

Your input is a rectangular 2D grid of the characters .-o#, given as a newline-separated string.
If you want, you can use pipes | instead of newlines as the separators, and you may assume one trailing and/or preceding separator.

The input will contain exactly one quartata-fish of some side-length 3*n, where n ≥ 1 is a positive integer, surrounded by periods . that represent the ocean floor.
The fish will always be in the orientation depicted above.
Overlaid on this grid, there will be exactly one non-empty rectangular region of hashes #, which represents a blob of mud.
The blob may cover the quartata-fish partially or entirely.
An example input would be

```<code>............
..--oo--....
..--oo--....
..---#####..
..---#####..
..ooo#####..
..oooooo....
</code>```

Output

Your output shall be generated from the input by replacing all the hashes with the characters .-o, so that the grid contains exactly one quartata-fish.
There will always be a unique way to perform this replacement properly; in particular, the blob of mud will cover the fish entirely only if its size is 3×3.
The output shall use the same separator as the input.
For the above input, the correct output would be

```<code>............
..--oo--....
..--oo--....
..----oo....
..----oo....
..oooooo....
..oooooo....
</code>```

Rules and scoring

You can write a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.
There are no time bounds: if your submission would eventually halt given unlimited time and resources, you're fine.

Test cases

```<code>Input:
.......
...-o-.
...--o.
##.ooo.
##.....
Output:
.......
...-o-.
...--o.
...ooo.
.......

Input:
...-o-.
...-#o.
...ooo.
.......
Output:
...-o-.
...--o.
...ooo.
.......

Input:
.........
.###.....
.###.....
.ooo.....
Output:
.........
.-o-.....
.--o.....
.ooo.....

Input:
.....
.###.
.###.
.###.
Output:
.....
.-o-.
.--o.
.ooo.

Input:
......
......
......
...###
...###
...###
Output:
......
......
......
...-o-
...--o
...ooo

Input:
###o--....
###o--....
###-oo....
###-oo....
###ooo....
###ooo....
###.......
Output:
--oo--....
--oo--....
----oo....
----oo....
oooooo....
oooooo....
..........

Input:
............
..--oo--....
..--oo--....
..---#####..
..---#####..
..ooo#####..
..oooooo....
Output:
............
..--oo--....
..--oo--....
..----oo....
..----oo....
..oooooo....
..oooooo....

Input:
...--oo--....
.#########...
.#########...
.#########...
...oooooo....
...oooooo....
.............
.............
Output:
...--oo--....
...--oo--....
...----oo....
...----oo....
...oooooo....
...oooooo....
.............
.............

Input:
..............
..............
.########.....
.########.....
.########-....
.########-....
.########o....
.########o....
.########o....
.########o....
.########.....
..............
Output:
..............
..............
..............
..............
....--oo--....
....--oo--....
....----oo....
....----oo....
....oooooo....
....oooooo....
..............
..............

Input:
.................
.................
..---ooo---......
..--#########....
..--#########....
..--#########....
..--#########....
..--#########....
..oo#########....
..oo#########....
..oo#########....
....#########....
Output:
.................
.................
..---ooo---......
..---ooo---......
..---ooo---......
..------ooo......
..------ooo......
..------ooo......
..ooooooooo......
..ooooooooo......
..ooooooooo......
.................

Input:
.........................
.........................
....----oooo----.........
....----########.........
....----########.........
....----########.........
....----########.........
....----########.........
....----########.........
....----########.........
....oooo########.........
....oooo########.........
....oooooooooooo.........
....oooooooooooo.........
.........................
Output:
.........................
.........................
....----oooo----.........
....----oooo----.........
....----oooo----.........
....----oooo----.........
....--------oooo.........
....--------oooo.........
....--------oooo.........
....--------oooo.........
....oooooooooooo.........
....oooooooooooo.........
....oooooooooooo.........
....oooooooooooo.........
.........................
</code>```

Body:
Python 2, 325 bytes

def f(s):
 s=map(list,s.split());R=range;L=len(s);M=len(s[0])
 for h in R(L/3*3,0,-3):
  for x in R(M-h+1):
   for y in R(L-h+1):
    if all(s[v%L][v/L]in".-#o #"[0<=v%L-y<h>v/L-x>=0::2]for v in R(L*M)):
     for k in R(h*h):s[y+k/h][x+k%h]="-o"[482>>k/h*3/h*3+k%h*3/h&1]
     return'\n'.join(map(''.join,s)).replace('#','.')

A badly golfed solution for now – the for .. in range(...)s are an utter train wreck. Inputs/outputs newline separated strings.

The byte count currently assumes space indents only – I'll switch to mixed tabs/spaces later when I'm done golfing, if necessary.