答:
 C++14, 156 chars

I thought it was a pretty cool solution though obviously can not beat most other entries here.

#define f for(i=0;i++<n;c<<t);
[](string t){auto&c=cout;int n=stoi(t),i;f c<<'\n';for(i=0;++i<n-1;c<<t,c.width(~-n*size(t)+1),c.fill(0),c<<t+'\n');if(n-1)f}
```

<p>Ungolfed:</p>

<pre class="lang-c++ prettyprint-override"><code>#define f for ( i = 0; i++ < n; c << t ); // print top/bot row
[](string t) {
  auto& c = cout;
  int n = stoi(t), i;
  f // print first row
  c << '\n'; // kind of annoying but no way to get rid of (yes I tried
             // c << '\n'+t instead of c << t+'\n')
  for ( i = 0; ++i < n - 1; ) {
    c << t; // output the number
    // then we we get the width of necessary spaces
    c.width(~-n*size(t)+1); // Equivalent to (n-1)*size(t) + 1, but we save
                            // two bytes since ~- takes precedence over
                            // multiplication
    c.fill(0); // fill with spaces, ' ' == 0
    c << t+'\n';
   }
   if ( n-1 ) f // This if statement is dissapointing
}
</code>```

And like always, to call the function use [](string t) { ... }("10");

Title: Print N Squared

Body:
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!

Body:
 C++14, 156 chars

I thought it was a pretty cool solution though obviously can not beat most other entries here.

#define f for(i=0;i++<n;c<<t);
[](string t){auto&c=cout;int n=stoi(t),i;f c<<'\n';for(i=0;++i<n-1;c<<t,c.width(~-n*size(t)+1),c.fill(0),c<<t+'\n');if(n-1)f}

Ungolfed:

#define f for ( i = 0; i++ < n; c << t ); // print top/bot row
[](string t) {
  auto& c = cout;
  int n = stoi(t), i;
  f // print first row
  c << '\n'; // kind of annoying but no way to get rid of (yes I tried
             // c << '\n'+t instead of c << t+'\n')
  for ( i = 0; ++i < n - 1; ) {
    c << t; // output the number
    // then we we get the width of necessary spaces
    c.width(~-n*size(t)+1); // Equivalent to (n-1)*size(t) + 1, but we save
                            // two bytes since ~- takes precedence over
                            // multiplication
    c.fill(0); // fill with spaces, ' ' == 0
    c << t+'\n';
   }
   if ( n-1 ) f // This if statement is dissapointing
}

And like always, to call the function use [](string t) { ... }("10");


问:
Highest score on the field

Introduction

Let a field be a rectangle filled with only the characters - and [0-9]. An example of a field is:

```<code>11-011123
111-010--
0010---01
111-01234
</code>```

You see that this field has been separated into three smaller areas:

To calculate the score of a smaller area, we just add all numbers up. For example:

```<code>11
111
0010
111

1 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 1 + 1 + 1 = 9
</code>```

The total score for this area is 9. We now do the same thing for the second area:

```<code>   011123
    010

0 + 1 + 1 + 1 + 2 + 3 + 0 + 1 + 0 = 9
</code>```

The total score is also 9. Now we have to examine the last area:

```<code>       01
    01234

0 + 1 + 0 + 1 + 2 + 3 + 4 = 11
</code>```

This has a total score of 11. The highest score on the field is 11, so this is what we need to output.

The Task

Given a field (in the form of a 2D string, an array, etc.), output the highest score on the field. You may assume that the given fields will always contain at least 1 digit. This is code-golf, so the submission with the least amount of bytes wins!

Test cases

Test case 1:

```<code>Input:
1

Output:
1
</code>```

Test case 2:

```<code>Input:
1-1-1-1
-1-1-1-
2-1-1-1
-1-1-1-

Output:
2
</code>```

Test case 3:

```<code>Input:
12-45-
4-65-9
87-654
12-487
45----
684764

Output:
69
</code>```

Test case 4:

```<code>Input:
111-12
------
21--10

Output:
3
</code>```

答:
JavaScript (ES6), 157 bytes

s=>[...o=s].map((n,i)=>o=n<'.'|(a=[...s]).map(_=>a.map((c,j)=>c>'-'&c<10&(a[j+1]|a[j-1]|a[j+l]|a[j-l])>90?a[n-=-c,j]=99:0),a[i]=99)|o>n?o:n,l=~s.search`
`)|o
```

<h2>Explanation</h2>

<p>Takes an input field as a string. For each number in the field, sums all numbers in the area. It does this by iterating over each number in the field multiple times, adding the number to the score if an adjacent cell contains a previously counted number. Counted numbers that are part of the area are represented by setting them to 99 so that they are not counted again. Outputs the highest score as a number.</p>

<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 =

s=>
  [...o=s].map((n,i)=>o=n<'.'|             // for each number on the field
                                           // n = area score
      (a=[...s])                           // a = array of each field character
      .map(_=>                             // loop to ensure whole area is found
        a.map((c,j)=>                      // for each cell c at index j
          c>'-'&c<10&                      // if the current cell is a number
          (a[j+1]|a[j-1]|a[j+l]|a[j-l])>90 // and an adjacent cells is in the area
          ?a[n-=-c,j]=99:0                 // add the cell to the area
        ),                                 // and the number to the score
        a[i]=99                            // mark the starting cell as counted
      )
      |o>n?o:n,                            // o = output (max of o and n)
    l=~s.search`
`                                          // l = line length of field
  )
  |o                                       // return o</code>```

<textarea id="input" rows="6" cols="40">12-45-
4-65-9
87-654
12-487
45----
684764</textarea>

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

```</code>```

ContentLicense: CC BY-SA 3.0

Title: Highest score on the field

Body:
JavaScript (ES6), 157 bytes

s=>[...o=s].map((n,i)=>o=n<'.'|(a=[...s]).map(_=>a.map((c,j)=>c>'-'&c<10&(a[j+1]|a[j-1]|a[j+l]|a[j-l])>90?a[n-=-c,j]=99:0),a[i]=99)|o>n?o:n,l=~s.search`
`)|o

Explanation

Takes an input field as a string. For each number in the field, sums all numbers in the area. It does this by iterating over each number in the field multiple times, adding the number to the score if an adjacent cell contains a previously counted number. Counted numbers that are part of the area are represented by setting them to 99 so that they are not counted again. Outputs the highest score as a number.

var solution =

s=>
  [...o=s].map((n,i)=>o=n<'.'|             // for each number on the field
                                           // n = area score
      (a=[...s])                           // a = array of each field character
      .map(_=>                             // loop to ensure whole area is found
        a.map((c,j)=>                      // for each cell c at index j
          c>'-'&c<10&                      // if the current cell is a number
          (a[j+1]|a[j-1]|a[j+l]|a[j-l])>90 // and an adjacent cells is in the area
          ?a[n-=-c,j]=99:0                 // add the cell to the area
        ),                                 // and the number to the score
        a[i]=99                            // mark the starting cell as counted
      )
      |o>n?o:n,                            // o = output (max of o and n)
    l=~s.search`
`                                          // l = line length of field
  )
  |o                                       // return o

<textarea id="input" rows="6" cols="40">12-45-
4-65-9
87-654
12-487
45----
684764</textarea><br />
<button onclick="result.textContent=solution(input.value)">Go</button>
<pre id="result"></pre>


答:
Pyth, 93 bytes

```<code>A,hlh.zjJ\-.zKsm?qdJd\#HD'b=KXKbJR+i@HbTsm?&&gd0<dlKq@Kd\#'d0[tbhb-bG+bG;Wh=NxK\#=+Y'N)h.MZY
</code>```

Try it online!

How it works

First step: read the input

```<code>A,hlh.zjJ\-.zKsm?qdJd\#H
A,                           Assign the following to G and H:
  hlh.z                          G = increment(length(first(all_input())))
       jJ\-.z                    H = join(J="-",all_input())
                m       H    for d in H:
                 ?qdJ            if equal(d,J):
                     d               add d to the list
                                 else:
                      \#             add "#" to the list
                             end
               s             sum the list
              K              assign to K

Sample input:
11-011123
111-010--
0010---01
111-01234

G = 10
H = "11-011123-111-010---0010---01-111-01234" (note the extra dashes connecting each line)
J = "-"
K = "##-######-###-###---####---##-###-#####"
</code>```

Second step: define a function to evaluate one area

```<code>D'b=KXKbJR+i@HbTsm?&&gd0<dlKq@Kd\#'d0[tbhb-bG+bG;
D'b                                             ;  def quote(b):
   =KXKbJ                                              K[b] = J
         R+                                            return the sum of A and B, where:
           i@HbT                                         A = to_integer(H[b],10)

                 m                   [tbhb-bG+bG         for d in {dec(b), inc(b), minus(b,G), add(b,G)}:
                  ?&&                                      if .... and ........ and ............... :
                     gd0                                      d>=0
                        <dlK                                           d<len(K)
                            q@Kd\#                                                  equal(K[d],"#")
                                  'd                           add quote(d) to temp_list
                                                           else:
                                    0                          add 0 to temp_list
                s                                        B = sum(temp_list)

Basically, this function (quote) is given a starting
point (b), and then recursively find its neighbour and
add their values to the output.
</code>```

Third step: read all the areas and find the rqeuired maximum

```<code>Wh=NxK\#=+Y'N)h.MZY
Wh=NxK\#     )         while inc(N=find(K,"#")):   --while K still has "#"
        =+Y'N              Y+= quote(N)
               .MZY    find the maximum of Y,
              h        then print the first.
</code>```

Title: Highest score on the field

Body:
Introduction

Let a field be a rectangle filled with only the characters - and [0-9]. An example of a field is:

```<code>11-011123
111-010--
0010---01
111-01234
</code>```

You see that this field has been separated into three smaller areas:

To calculate the score of a smaller area, we just add all numbers up. For example:

```<code>11
111
0010
111

1 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 1 + 1 + 1 = 9
</code>```

The total score for this area is 9. We now do the same thing for the second area:

```<code>   011123
    010

0 + 1 + 1 + 1 + 2 + 3 + 0 + 1 + 0 = 9
</code>```

The total score is also 9. Now we have to examine the last area:

```<code>       01
    01234

0 + 1 + 0 + 1 + 2 + 3 + 4 = 11
</code>```

This has a total score of 11. The highest score on the field is 11, so this is what we need to output.

The Task

Given a field (in the form of a 2D string, an array, etc.), output the highest score on the field. You may assume that the given fields will always contain at least 1 digit. This is code-golf, so the submission with the least amount of bytes wins!

Test cases

Test case 1:

```<code>Input:
1

Output:
1
</code>```

Test case 2:

```<code>Input:
1-1-1-1
-1-1-1-
2-1-1-1
-1-1-1-

Output:
2
</code>```

Test case 3:

```<code>Input:
12-45-
4-65-9
87-654
12-487
45----
684764

Output:
69
</code>```

Test case 4:

```<code>Input:
111-12
------
21--10

Output:
3
</code>```

Body:
Pyth, 93 bytes

A,hlh.zjJ\-.zKsm?qdJd\#HD'b=KXKbJR+i@HbTsm?&&gd0<dlKq@Kd\#'d0[tbhb-bG+bG;Wh=NxK\#=+Y'N)h.MZY

Try it online!

How it works

First step: read the input

A,hlh.zjJ\-.zKsm?qdJd\#H
A,                           Assign the following to G and H:
  hlh.z                          G = increment(length(first(all_input())))
       jJ\-.z                    H = join(J="-",all_input())
                m       H    for d in H:
                 ?qdJ            if equal(d,J):
                     d               add d to the list
                                 else:
                      \#             add "#" to the list
                             end
               s             sum the list
              K              assign to K

Sample input:
11-011123
111-010--
0010---01
111-01234

G = 10
H = "11-011123-111-010---0010---01-111-01234" (note the extra dashes connecting each line)
J = "-"
K = "##-######-###-###---####---##-###-#####"

Second step: define a function to evaluate one area

D'b=KXKbJR+i@HbTsm?&&gd0<dlKq@Kd\#'d0[tbhb-bG+bG;
D'b                                             ;  def quote(b):
   =KXKbJ                                              K[b] = J
         R+                                            return the sum of A and B, where:
           i@HbT                                         A = to_integer(H[b],10)

                 m                   [tbhb-bG+bG         for d in {dec(b), inc(b), minus(b,G), add(b,G)}:
                  ?&&                                      if .... and ........ and ............... :
                     gd0                                      d>=0
                        <dlK                                           d<len(K)
                            q@Kd\#                                                  equal(K[d],"#")
                                  'd                           add quote(d) to temp_list
                                                           else:
                                    0                          add 0 to temp_list
                s                                        B = sum(temp_list)

Basically, this function (quote) is given a starting
point (b), and then recursively find its neighbour and
add their values to the output.

Third step: read all the areas and find the rqeuired maximum

Wh=NxK\#=+Y'N)h.MZY
Wh=NxK\#     )         while inc(N=find(K,"#")):   --while K still has "#"
        =+Y'N              Y+= quote(N)
               .MZY    find the maximum of Y,
              h        then print the first.


问:
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!

答:
Oracle SQL 11.2, <s>106</s> <s>105</s> 115 bytes

```<code>SELECT RPAD(:1,(:1-1)*LENGTH(:1),DECODE(LEVEL,1,:1||'',:1,:1||'',' '))||:1 FROM DUAL WHERE:1>0 CONNECT BY:1>=LEVEL;
</code>```

10 bytes added to manage 0

Title: Print N Squared

Body:
Oracle SQL 11.2, <s>106</s> <s>105</s> 115 bytes

SELECT RPAD(:1,(:1-1)*LENGTH(:1),DECODE(LEVEL,1,:1||'',:1,:1||'',' '))||:1 FROM DUAL WHERE:1>0 CONNECT BY:1>=LEVEL;

10 bytes added to manage 0


问:
Read a crossword
Inspired by this question about packing into this format.

Occasionally I see a completed crossword and being as I am, I can't be bothered to find out what the solutions to the clues actually were.

Input:

A 2D string (any format, newline separated, 2d list etc.)

Blank squares will be represented with a  (space character)

Every other square will be in the lower case alphabet.

You may assume that the input will be padded with spaces to form a rectangle

Output:

Each word found

You must search for words along and down

Words will be at least two letters long

If there are duplicate words, you have to output them for each time they appear

You don't have to do any validation

Words may be outputted in any order

No strict formatting rules

Test cases:

```<code>word
e e
step
t d

word, step, west, reed
---
pies
 not
  no
wasp

pies, not, no, wasp, in, eons, stop
---
igloo
    n
word

igloo, word, on
</code>```

答:
 C++14, <s>209</s><s>207</s>201 bytes

Ridiculously high amount of bytes... but oh well. Transpose matrix, split string. Easy. Too bad no native function for transposing

```<code>[](vector<string>; m){auto t=m;int C=size(m[0]),j=0;for(;++j<C*C;)t[j%C][j/C]=m[j/C][j%C];for(j=0;++j<C+C;){stringstream Z(j<C?m[j]:t[j-C]);string s;while(getline(Z,s,' '))cout<<(size(s)>1?s+' ':"");}}
</code>```

Ungolfed:

```<code>using S=vector<string>;
[](S m){
  S t=m;
  int C=size(m[0]),j=0;
  for(;j<C*C;++j)t[j%C][j/C]=m[j/C][j%C]; // Transpose
  for(j=0;j<C+C;++j){ // since rectangle matrix, we can iterate like so
    stringstream Z(j<C?m[j]:t[j-C]); // Get string from m or t
    string s;
    while(getline(Z,s,' '))
      cout<<(size(s)>1?s+' ':"");
  }
}
</code>```

How to use it (note you must enforce padding as the question states):

```<code>using S = vector<string>;[](S m) { ... }({"pies", " not", "  no", "wasp"});
</code>```

Title: Read a crossword

Body:
 C++14, <s>209</s><s>207</s>201 bytes

Ridiculously high amount of bytes... but oh well. Transpose matrix, split string. Easy. Too bad no native function for transposing

[](vector<string>; m){auto t=m;int C=size(m[0]),j=0;for(;++j<C*C;)t[j%C][j/C]=m[j/C][j%C];for(j=0;++j<C+C;){stringstream Z(j<C?m[j]:t[j-C]);string s;while(getline(Z,s,' '))cout<<(size(s)>1?s+' ':"");}}

Ungolfed:

using S=vector<string>;
[](S m){
  S t=m;
  int C=size(m[0]),j=0;
  for(;j<C*C;++j)t[j%C][j/C]=m[j/C][j%C]; // Transpose
  for(j=0;j<C+C;++j){ // since rectangle matrix, we can iterate like so
    stringstream Z(j<C?m[j]:t[j-C]); // Get string from m or t
    string s;
    while(getline(Z,s,' '))
      cout<<(size(s)>1?s+' ':"");
  }
}

How to use it (note you must enforce padding as the question states):

using S = vector<string>;[](S m) { ... }({"pies", " not", "  no", "wasp"});


问:
Print the British Flag!
Inspired by Print the American Flag! this is a direct copy but with the British flag as it has some symmetries but is still quite complex!

Your challenge is to produce the following ASCII-Art in as few bytes as possible! Turn your head/screen (not both!) by 90 degrees to view it properly.

```<code> __________________________________________
|\  \XXXXXXXXXXXX  000000  XXXXXXXXXXXX//0/|
|0\  \XXXXXXXXXXX  000000  XXXXXXXXXXX//0/ |
|\0\  \XXXXXXXXXX  000000  XXXXXXXXXX//0/  |
|\\0\  \XXXXXXXXX  000000  XXXXXXXXX//0/  /|
|X\\0\  \XXXXXXXX  000000  XXXXXXXX//0/  /X|
|XX\\0\  \XXXXXXX  000000  XXXXXXX//0/  /XX|
|XXX\\0\  \XXXXXX  000000  XXXXXX//0/  /XXX|
|XXXX\\0\  \XXXXX  000000  XXXXX//0/  /XXXX|
|XXXXX\\0\  \XXXX  000000  XXXX//0/  /XXXXX|
|XXXXXX\\0\  \XXX  000000  XXX//0/  /XXXXXX|
|XXXXXXX\\0\  \XX  000000  XX//0/  /XXXXXXX|
|XXXXXXXX\\0\  \X  000000  X//0/  /XXXXXXXX|
|XXXXXXXXX\\0\  \  000000  //0/  /XXXXXXXXX|
|XXXXXXXXXX\\0\    000000  /0/  /XXXXXXXXXX|
|XXXXXXXXXXX\\0\   000000  0/  /XXXXXXXXXXX|
|XXXXXXXXXXXX\\0\  000000  /  /XXXXXXXXXXXX|
|XXXXXXXXXXXXX\\0  000000    /XXXXXXXXXXXXX|
|XXXXXXXXXXXXXX\\  000000   /XXXXXXXXXXXXXX|
|                  000000                  |
|000000000000000000000000000000000000000000|
|000000000000000000000000000000000000000000|
|000000000000000000000000000000000000000000|
|                  000000                  |
|XXXXXXXXXXXXXX/   000000  \\XXXXXXXXXXXXXX|
|XXXXXXXXXXXXX/    000000  0\\XXXXXXXXXXXXX|
|XXXXXXXXXXXX/  /  000000  \0\\XXXXXXXXXXXX|
|XXXXXXXXXXX/  /0  000000   \0\\XXXXXXXXXXX|
|XXXXXXXXXX/  /0/  000000    \0\\XXXXXXXXXX|
|XXXXXXXXX/  /0//  000000  \  \0\\XXXXXXXXX|
|XXXXXXXX/  /0//X  000000  X\  \0\\XXXXXXXX|
|XXXXXXX/  /0//XX  000000  XX\  \0\\XXXXXXX|
|XXXXXX/  /0//XXX  000000  XXX\  \0\\XXXXXX|
|XXXXX/  /0//XXXX  000000  XXXX\  \0\\XXXXX|
|XXXX/  /0//XXXXX  000000  XXXXX\  \0\\XXXX|
|XXX/  /0//XXXXXX  000000  XXXXXX\  \0\\XXX|
|XX/  /0//XXXXXXX  000000  XXXXXXX\  \0\\XX|
|X/  /0//XXXXXXXX  000000  XXXXXXXX\  \0\\X|
|/  /0//XXXXXXXXX  000000  XXXXXXXXX\  \0\\|
|  /0//XXXXXXXXXX  000000  XXXXXXXXXX\  \0\|
| /0//XXXXXXXXXXX  000000  XXXXXXXXXXX\  \0|
|/0//XXXXXXXXXXXX__000000__XXXXXXXXXXXX\__\|
</code>```

The block is 44 x 42 characters. Note that the first line ends with a single space! No other trailing spaces are allowed but a trailing new line is allowed on the last line.

I'm not aware of any date significance for the UK at the moment!

Title: Print the British Flag!

Body:
SpecBAS again - 507 Bytes

Here's a similar version to Brian's above (I don't have enough reputation to comment yet) but without the colour. It uses a very different method to generate the display.

10 DEF FN rr$(r$)=r$(2 TO)+r$(1): DEF FN rl$(r$)=r$(LEN r$)+r$( TO LEN r$-1)
20 a$="\  \"+"x"*14+"\\0",b$="x"*12+"//0/  /xx",c$="x"*14+"/  /0//",d$="\\"+"x"*14+"\  \0",e$="  000000  ": ?" ";"_"*42: DO 18: ?"|";a$( TO 16);e$;b$( TO 16);"|": a$=FN rl$(a$),b$=FN rr$(b$): LOOP: ?"|";TAB 17;e$;TAB 43;"|"'("|"+("0"*42)+"|"+#13)*3;"|";TAB 17;e$;TAB 43;"|": DO 18: ?"|";c$( TO 16);e$;d$( TO 16);"|": c$=FN rr$(c$),d$=FN rl$(d$): LOOP: ?#11;TAB 17;"__";TAB 25;"__";TAB 40;"__"


问:
Shortest code for infinite disk I/O
(Just open 50 tabs in Google Chrome :D (just kidding, no you can't))

Shortest code for infinite disk I/O any language, C# example:

using System.IO;

namespace FileApp {
    static class Program {
        public static void Main() {
            do {
                File.WriteAllText("a", "a");
                File.Delete("a");
            } while (true);
        }
    }
}
```

You can't just fill the entire disk though, as then it would halt in the end and would be finite.

And you can't do reading only, infinite writing has to happen. (It has to kill my SSD after enough runtime.)

Get cracking! :)

答:
CBM BASIC 7.0, 9 bytes

```<code>0dS"a":rU
</code>```

This program, when run, repeatedly saves itself to disk.  Here's a more readable version which doesn't use BASIC keyword abbreviations:

```<code>0 dsave "a" : run
</code>```

Title: Shortest code for infinite disk I/O

Body:
CBM BASIC 7.0, 9 bytes

0dS"a":rU

This program, when run, repeatedly saves itself to disk.  Here's a more readable version which doesn't use BASIC keyword abbreviations:

0 dsave "a" : run


问:
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

```

答:
Python 3, 42 bytes

I wanted to write a generator for this function, and so I did.

def f(a,b):
 while 1:yield a,b;a,b=a+b,a-b
```

<p>In Python 3, the sequence is generated in this way:</p>

<pre class="lang-python prettyprint-override"><code>>>> gen = f(2, 20)
>>> next(gen)
(2, 20)
>>> next(gen)
(22, -18)
>>> next(gen)
(4, 40)
>>> next(gen)
(44, -36)
>>> next(gen)
(8, 80)
</code>```

ContentLicense: CC BY-SA 4.0

Title: The plus-minus sequence

Body:
Python 3, 42 bytes

I wanted to write a generator for this function, and so I did.

def f(a,b):
 while 1:yield a,b;a,b=a+b,a-b

In Python 3, the sequence is generated in this way:

>>> gen = f(2, 20)
>>> next(gen)
(2, 20)
>>> next(gen)
(22, -18)
>>> next(gen)
(4, 40)
>>> next(gen)
(44, -36)
>>> next(gen)
(8, 80)


答:
Common Lisp, 57

```<code>(lambda(a b)(loop(print`(,a,b))(psetf a(+ a b)b(- a b))))
</code>```

Uses psetf, which affects values to variables in parallel, and the simple loop syntax.

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:
Common Lisp, 57

(lambda(a b)(loop(print`(,a,b))(psetf a(+ a b)b(- a b))))

Uses psetf, which affects values to variables in parallel, and the simple loop syntax.


答:
Pyke, 9 bytes, noncompetitive

```<code>Stm`sS1R+
</code>```

Explanation:

```<code>S         -      range(1,inp+1)
 t        -     ^[1:]
  m`      -    map(str,^)
    s     -   sum(^)
     S    -  sort(^)
      1R+ - 1+^
</code>```

Try it here!

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:
Pyke, 9 bytes, noncompetitive

Stm`sS1R+

Explanation:

S         -      range(1,inp+1)
 t        -     ^[1:]
  m`      -    map(str,^)
    s     -   sum(^)
     S    -  sort(^)
      1R+ - 1+^

Try it here!


答:
bash + GNU coreutils, 75 bytes

```<code>a=$1
b=$2
for i in `seq $3`;{ echo -e "$a\t$b";c=$a;a=$((c+b));b=$((c-b));}
</code>```

Invocation:

```<code>./codegolf.sh 2 10 5
</code>```

Title: The plus-minus sequence

Body:
bash + GNU coreutils, 75 bytes

a=$1
b=$2
for i in `seq $3`;{ echo -e "$a\t$b";c=$a;a=$((c+b));b=$((c-b));}

Invocation:

./codegolf.sh 2 10 5


答:
Oracle SQL 11.2, <s>222</s> 211 bytes

```<code>SELECT 1||TRIM(xmlagg(xmlelement(e,c)).EXTRACT('//text()'))FROM(SELECT SUBSTR(s,LEVEL+2,1)c FROM(SELECT MAX(sys_connect_by_path(LEVEL,' '))s FROM DUAL CONNECT BY LEVEL<=:1)CONNECT BY LEVEL<=LENGTH(s)ORDER BY 1);
</code>```

Un-golfed

```<code>SELECT 1||TRIM(xmlagg(xmlelement(e,c)).EXTRACT('//text()'))  -- add leading 1, concatenate each char and remove spaces
FROM   (
         SELECT SUBSTR(s,LEVEL+2,1)c                          -- split the string in characters, omiting the first number (1)
         FROM   (
                  SELECT MAX(sys_connect_by_path(LEVEL,' '))s -- create a string by concatenating numbers
                  FROM   DUAL
                  CONNECT BY LEVEL<=:1
                )
         CONNECT BY LEVEL<=LENGTH(s)ORDER BY 1
       )
</code>```

Title: The Rien Number

Body:
Oracle SQL 11.2, <s>222</s> 211 bytes

SELECT 1||TRIM(xmlagg(xmlelement(e,c)).EXTRACT('//text()'))FROM(SELECT SUBSTR(s,LEVEL+2,1)c FROM(SELECT MAX(sys_connect_by_path(LEVEL,' '))s FROM DUAL CONNECT BY LEVEL<=:1)CONNECT BY LEVEL<=LENGTH(s)ORDER BY 1);

Un-golfed

SELECT 1||TRIM(xmlagg(xmlelement(e,c)).EXTRACT('//text()'))  -- add leading 1, concatenate each char and remove spaces
FROM   (
         SELECT SUBSTR(s,LEVEL+2,1)c                          -- split the string in characters, omiting the first number (1)
         FROM   (
                  SELECT MAX(sys_connect_by_path(LEVEL,' '))s -- create a string by concatenating numbers
                  FROM   DUAL
                  CONNECT BY LEVEL<=:1
                )
         CONNECT BY LEVEL<=LENGTH(s)ORDER BY 1
       )


问:
Stretch the word
The input is a word of lowercase letters not separated by whitespace. A newline at the end is optional.

The same word must be output in a modified version: For each character, double it the second time it appears in the original word, triple it the third time etc.

Example input:

```<code>bonobo
</code>```

Example output:

```<code>bonoobbooo
</code>```

Standard I/O rules apply. The shortest code in bytes wins.

Tests provided by @Neil :

```<code>tutu -> tuttuu
queue -> queuuee
bookkeeper -> boookkkeeepeeer
repetitive -> repeetittiiveee
uncopyrightables -> uncopyrightables
abracadabra -> abraacaaadaaaabbrraaaaa
mississippi -> misssiisssssssiiipppiiii
</code>```

答:
JavaScript (ES6), <s>48</s> 45 bytes

```<code>s=>s.replace(n=/./g,c=>c.repeat(n[c]=-~n[c]))
</code>```

Edit: Saved 3 bytes thanks to @user81655.

Title: Stretch the word

Body:
JavaScript (ES6), <s>48</s> 45 bytes

s=>s.replace(n=/./g,c=>c.repeat(n[c]=-~n[c]))

Edit: Saved 3 bytes thanks to @user81655.


Title: Stretch the word

Body:
The input is a word of lowercase letters not separated by whitespace. A newline at the end is optional.

The same word must be output in a modified version: For each character, double it the second time it appears in the original word, triple it the third time etc.

Example input:

```<code>bonobo
</code>```

Example output:

```<code>bonoobbooo
</code>```

Standard I/O rules apply. The shortest code in bytes wins.

Tests provided by @Neil :

```<code>tutu -> tuttuu
queue -> queuuee
bookkeeper -> boookkkeeepeeer
repetitive -> repeetittiiveee
uncopyrightables -> uncopyrightables
abracadabra -> abraacaaadaaaabbrraaaaa
mississippi -> misssiisssssssiiipppiiii
</code>```

Body:
Perl, 17

(16 bytes code, +1 for -p)

s/./${$&}.=$&/ge

Usage:

perl -pe 's/./${$&}.=$&/ge' <<< 'bonobo'
bonoobbooo


问:
Find the treasure in a 2D dungeon
You are in a one-floor dungeon. There is a treasure which is protected by locked doors. Doors can be opened by finding the corresponding keys. Your goal is to find the shortest path to the treasure.

Input

Input will be a two-dimensional grid representing the initial layout of the dungeon.

```<code>###########
#$   #   g#
#    # ####
###G##    #
#    ####C#
#c  @     #
###########
</code>```

This is you: @

These are walls: #

This is the treasure: $

Locked doors are capital letters: A...Z

Each door has a corresponding lower-case key: a...z

There will always be one @ and one $.

The dungeon will always be rectangular.

It is not guaranteed that the outside edge of the dungeon is a wall. This is a valid dungeon:

```<code>  $
A##
@ a
</code>```

It is not guaranteed that the treasure is reachable. Some dungeons may not be solvable.

There may be doors without a key, and there may be keys that do not open any doors.

There will never be duplicate doors or keys.

Output

Your program should print a sequence of R, L, U, D (or 4 other distinct symbols) to represent the shortest possible path to the treasure. Here, RLUD stands for right, left, up, and down, respectively. If there are multiple shortest paths, your program only needs to print one of them.

You cannot move onto a wall.

You cannot move outside of the dungeon boundaries.

You cannot move onto a door without picking up it's key.

Move onto a key to pick it up.

It is not necessary to open every single door.

If it is not possible to reach the treasure through a valid sequence of moves, then your program must terminate without printing anything. (A trailing newline is allowed.)

Scoring

This is code-golf so the answer with the lowest byte count wins.

Test Cases

Each test case will have the height and width of the dungeon on the first line, and one possible path, with the optimal number of moves, on the last line.

```<code>1 2
@$
R (1)

3 3
  $
#Z#
@ z
RRLUUR (6)

3 5
c#d#$
 #C#D
@
UUDDRRUUDDRRUU (14)

7 16
c   # b #  ###@
###     #
  A #####  ####
d #           e
  B    ## #####
###    C   ##
       # a DE $
RDDDDDDL (8)

16 37
#####################################
#    #ijk #a M   ##m##   #    #  R  #
#    #    #  #           #       ####
###J#### ############# ###    #  P b#
#e                       N  h #  ####
##########  ###########  ######     #
#        #  #    $    #  #    #  ####
#  D     H  #         #  #       Q f#
# EcF    #  #####A#####  ######  ####
#  G     #  #####B#####  #          #
#        K  #####C#####  ############
#        #                          #
########### #         #### ##### ####
#     # p   #         # n    #      #
# d         #    @    #     o#   r  #
#################Z###################
UUULLLLLLDDLLLDLLLLLLRRRRRRRRRUUURRRRRRRRRRRRRRRDDLLRRUULLUUUUUUURRRRRUURRRDRRRLLLLULLLLLDDLLLLUULLLUDLLLLLULLLRRRRRDRRRRRRDDLLLLLLLLLLLLDDDLLLLLLLDURRRRRRRRDDDDRRRRRRUUUUU (172)
</code>```

It is not possible to reach the treasure in the following dungeons. For these test cases, there should be no output.

```<code>1 3
@#$

7 11
#a#j#$#i#f#
# #E#F#c#H#
# #K#D#A#G#
#         #
#C#J# #I#B#
#h#d# #L#g#
#l#e#@#b#k#

10 25
#########################
   # fgh  #  # c B b #  #
 $ #      #  #   #   #  #
   ###### #  ##H###E##  #
   #                    #
   #     #########  ##e##
   Z @   D     y #  #   #
   #     #########  F  C#
   #     G          # Ad#
#########################
</code>```

The following snippet can be used to validate answers.

function run() {var dungeonText = document.getElementById("dungeon").value;var dungeonLines = dungeonText.split("\n");var height = dungeonLines.length;var width = dungeonLines[0].length;var dungeon = new Array(height);for (i = 0; i < dungeon.length; i++) {var dungeonLine = dungeonLines[i];if (dungeonLine.length != width) {return error("The dungeon is not rectangular");} dungeon[i] = dungeonLines[i].split("");} var movesText = document.getElementById("moves").value;var moves = movesText.trim().split("");var moveCount = moves.length;var rowAt, colAt;for (r = 0; r < dungeon.length; r++) {for (c = 0; c < dungeon[r].length; c++) {if (dungeon[r][c] == '@') {rowAt = r;colAt = c;}}} var treasure = false;while (moves.length > 0) {var move = moves[0];var row = rowAt,col = colAt;switch (move) {case 'R':col++;break;case 'L':col--;break;case 'U':row--;break;case 'D':row++;break;default:return print(dungeon, moves, "Invalid move");} if (row < 0 || col < 0 || row >= height || col >= width) {return print(dungeon, moves, "Out of bounds");} var target = dungeon[row][col];if (target.match(/[A-Z#]/)) {return print(dungeon, moves, "Path blocked");} if (target.match(/[a-z]/)) {var door = target.toUpperCase();for (r = 0; r < dungeon.length; r++) {for (c = 0; c < dungeon[r].length; c++) {if (dungeon[r][c] == door) {dungeon[r][c] = ' ';}}}} if (target == '$') {treasure = true;} dungeon[row][col] = '@';dungeon[rowAt][colAt] = '.';rowAt = row;colAt = col;moves.shift();} if (treasure) {print(dungeon, moves, "Got the treasure in " + moveCount + " moves!");} else {print(dungeon, moves, "Failed to reach treasure");}} function error(message) {var result = document.getElementById("result");result.innerHTML = message;} function print(dungeon, moves, message) {var output = message + "\n";for (r = 0; r < dungeon.length; r++) {for (c = 0; c < dungeon[r].length; c++) {output += dungeon[r][c];} output += "\n";} for (i = 0; i < moves.length; i++) {output += moves[i];} var result = document.getElementById("result");result.innerHTML = output;}```
<pre class="snippet-code-html lang-html prettyprint-override"><code>Dungeon:<br/><textarea id="dungeon" name="dungeon" rows="20" cols="40"></textarea><br/>Moves:<br/><textarea id="moves" name="moves" cols="40"></textarea><br/><button id="run" name="run" onclick="run();">Start</button><br/><br/>Result:<br/><textarea id="result" name="result" rows="20" cols="40" disabled></textarea><br/></code>```

答:
Perl, <s>157</s> <s>152</s> 151 bytes

Includes +4 for -p0 (cannot be counted as just an extension of -e because it uses ' in several places)

Run with the maze on STDIN:

```<code>./keymaze.pl < maze.txt
</code>```

keymaze.pl:

```<code>#!/usr/bin/perl -p0
1until$n{map/\n/&&"L1R-1U@+D-@+"=~s%\pL%$t=$1{$_}.$&;pos=$^H=-$'+s'@' '*"@-",s/\G[a-z\$ ]/\@/+s/$&/ /i?/\$/?$1{$_}:$\||=$t:0for"$_"%reg,$_,%1}++.$\}{
</code>```

Replace \n and ^H by their literal versions for the claimed score. Needs about 1 hour and a bit less than 2 Gigabytes on my machine to solve the big maze.

Title: Find the treasure in a 2D dungeon

Body:
Perl, <s>157</s> <s>152</s> 151 bytes

Includes +4 for -p0 (cannot be counted as just an extension of -e because it uses ' in several places)

Run with the maze on STDIN:

./keymaze.pl < maze.txt

keymaze.pl:

#!/usr/bin/perl -p0
1until$n{map/\n/&&"L1R-1U@+D-@+"=~s%\pL%$t=$1{$_}.$&;pos=$^H=-$'+s'@' '*"@-",s/\G[a-z\$ ]/\@/+s/$&/ /i?/\$/?$1{$_}:$\||=$t:0for"$_"%reg,$_,%1}++.$\}{

Replace \n and ^H by their literal versions for the claimed score. Needs about 1 hour and a bit less than 2 Gigabytes on my machine to solve the big maze.


答:
Haskell, <s>50</s> <s>42</s> 41 bytes

Saved 8 bytes thanks to Lynn

f t=[c|(i,c)<-zip[1..]t,x<-take i t,c==x]
```

Title: Stretch the word


Title: Stretch the word

Body:
Perl 6, 37 bytes

{.split('').map({$_ x++%.{$_}}).join}


答:
Pyth, 11 bytes

```<code>s.e*b/<Qhkb
</code>```

Try it here!

Explanation

```
s.e*b/<Qhkb    # Q = input

 .e            # map over input with b as value and k as index (Q get appended at the end inplicitly)
      <Qhk     # take the first k+1 chars of Q
     /    b    # count occurences of b in there
   *b          # repeat b that many times
s              # join resulting list into one string
```

Title: Stretch the word

Body:
Pyth, 11 bytes

s.e*b/<Qhkb

Try it here!

Explanation

s.e*b/<Qhkb    # Q = input

 .e            # map over input with b as value and k as index (Q get appended at the end inplicitly)
      <Qhk     # take the first k+1 chars of Q
     /    b    # count occurences of b in there
   *b          # repeat b that many times
s              # join resulting list into one string


答:
PHP, <s>54</s> <s>51</s> <s>50</s> 47 bytes

```<code>for(;$C=$argn[$X++];)echo str_repeat($C,++$$C);
</code>```

Run like this:

```<code>echo abracadabra | php -nR 'for(;$C=$argn[$X++];)echo str_repeat($C,++$$C); echo"\n";'
</code>```

Tweaks

Saved 3 bytes by using variable variables. Changed used variables to uppercase to prevent collision

Saved a byte by removing type cast null to int for string offset, as string offset is cast to int anyway

Saved 3 bytes by using $argn instead of $argv (thx Titus)

Title: Stretch the word

Body:
PHP, <s>54</s> <s>51</s> <s>50</s> 47 bytes

for(;$C=$argn[$X++];)echo str_repeat($C,++$$C);

Run like this:

echo abracadabra | php -nR 'for(;$C=$argn[$X++];)echo str_repeat($C,++$$C); echo"\n";'

Tweaks

Saved 3 bytes by using variable variables. Changed used variables to uppercase to prevent collision

Saved a byte by removing type cast null to int for string offset, as string offset is cast to int anyway

Saved 3 bytes by using $argn instead of $argv (thx Titus)


答:
Python, 56 bytes

I seem to be stuck with two answers of the same length:

f=lambda x,*y:x and-~y.count(x[0])*x[0]+f(x[1:],x[0],*y)
f=lambda x,y=0:x[y:]and-~x[:y].count(x[y])*x[y]+f(x,y+1)
```

Edit: See @pacholik's answer for a shorter, alternative Python approach.

Title: Stretch the word

Body:
Python, 56 bytes

I seem to be stuck with two answers of the same length:

f=lambda x,*y:x and-~y.count(x[0])*x[0]+f(x[1:],x[0],*y)
f=lambda x,y=0:x[y:]and-~x[:y].count(x[y])*x[y]+f(x,y+1)

Edit: See @pacholik's answer for a shorter, alternative Python approach.


答:
><>, 52 bytes

```<code>i:0(?;&l:?!v1-$:&:&=?\}70.>
6f+0.00o:&~/         \:o
</code>```

It stacks every letter read, prints them once and once again for every similar letter in the stack.

It uses the & register, because having to handle 3 variables on the stack (current read letter, position in the stack, letter at this position) is a pain.

You can try it here!

Title: Stretch the word

Body:
><>, 52 bytes

i:0(?;&l:?!v1-$:&:&=?\}70.>
6f+0.00o:&~/         \:o

It stacks every letter read, prints them once and once again for every similar letter in the stack.

It uses the & register, because having to handle 3 variables on the stack (current read letter, position in the stack, letter at this position) is a pain.

You can try it here!


问:
Number of pieces on a checkers board

Introduction

A normal checkers board contains 8 x 8 = 64 squares:

You can see that in total, there are 12 white pieces. Black and white always have the same amount of pieces. If there are any more pieces on the board, the pieces would neighbouring, which is not allowed for this challenge. To clarify things, here are some examples:

The smallest board possible for this challenge is 3 x 3:

You can see that the maximum amount of pieces is equal to 2. So, when given N = 3, you need to output 2. If the input is N = 4, we get the following:

You can see that the maximum amount is also 2. So for N = 4, the output should be 2. For N = 5, the output should be equal to 5:

Examples

```<code>STDIN:  3
STDOUT: 2

STDIN:  4
STDOUT: 2

STDIN:  5
STDOUT: 5

STDIN:  6
STDOUT: 6

STDIN:  8
STDOUT: 12
</code>```

Rules

Your submission must be a program, or function etc.
that takes one integer and outputs or returns the number of pieces on the board

You can safely assume that the input is an non-negative integer > 2

This is code-golf, so the program with the least amount of bytes wins!

Note that the square in the lower left of the board is always dark. Pieces are only placed on dark squares

You have to occupy a full row with pieces

答:
Pyke, 8 bytes, noncompeting

```<code>Dt2f*h2f
</code>```

dup,dec,half,mult,inc,half

Try it here!

Title: Number of pieces on a checkers board

Body:
Pyke, 8 bytes, noncompeting

Dt2f*h2f

dup,dec,half,mult,inc,half

Try it here!


答:
Mathematica, 57 bytes

```<code>StringReplace[Clear@c;c@_=0;#,x_:>x~StringRepeat~++c[x]]&
</code>```

We use c[x] as a lookup table of how often character x has already occurred. This is incremented each time it's retrieved in x~StringRepeat~++c[x]. Unfortunately, to make the function reusable, we need to reset the lookup table each time with Clear@c;c@_=0;, which is quite expensive.

Title: Stretch the word

Body:
Mathematica, 57 bytes

StringReplace[Clear@c;c@_=0;#,x_:>x~StringRepeat~++c[x]]&

We use c[x] as a lookup table of how often character x has already occurred. This is incremented each time it's retrieved in x~StringRepeat~++c[x]. Unfortunately, to make the function reusable, we need to reset the lookup table each time with Clear@c;c@_=0;, which is quite expensive.


答:
Retina, <s>34</s> 19 bytes

Saved 15 bytes by taking some inspiration from isaacg's solution.

Byte count assumes ISO 8859-1 encoding.

```<code>
$`¶
(\D)(?!.*\1¶)

</code>```

The leading and trailing empty lines are significant.

Try it online!

Explanation

```<code>
$`¶
</code>```

This is a replace stage which matches the empty regex (i.e. every zero-width position in the string) and substitutes $`¶</code> for it, where <code>$` is the prefix of the match and ¶ inserts a linefeed. This basically computes all the prefixes and puts them on a separate line together with the last character of that prefix:

```<code>bb
obo
oboo
kbook
kbookk
ebookke
ebookkee
pbookkeep
ebookkeepe
rbookkeeper
</code>```

There will be some leading and trailing linefeeds, but we can ignore them.

From each of these prefixes we want to keep the characters that are equal to the last character. For that we use another replace stage:

```<code>(\D)(?!.*\1¶)

</code>```

This matches everything we don't want to keep and replaces it with a nothing. We match any character (using \D since we know there won't be digits in the input) and then make sure that there isn't another copy of that character at the end of the line.

Title: Stretch the word

Body:
Retina, <s>34</s> 19 bytes

Saved 15 bytes by taking some inspiration from isaacg's solution.

Byte count assumes ISO 8859-1 encoding.

$`¶
(\D)(?!.*\1¶)

The leading and trailing empty lines are significant.

Try it online!

Explanation

$`¶

This is a replace stage which matches the empty regex (i.e. every zero-width position in the string) and substitutes $`¶</code> for it, where <code>$` is the prefix of the match and ¶ inserts a linefeed. This basically computes all the prefixes and puts them on a separate line together with the last character of that prefix:

bb
obo
oboo
kbook
kbookk
ebookke
ebookkee
pbookkeep
ebookkeepe
rbookkeeper

There will be some leading and trailing linefeeds, but we can ignore them.

From each of these prefixes we want to keep the characters that are equal to the last character. For that we use another replace stage:

(\D)(?!.*\1¶)

This matches everything we don't want to keep and replaces it with a nothing. We match any character (using \D since we know there won't be digits in the input) and then make sure that there isn't another copy of that character at the end of the line.


答:
Python 3, 52

```<code>def f(s):*s,x=s;return s and f(s)+x+x*s.count(x)or x
</code>```

Title: Stretch the word

Body:
Python 3, 52

def f(s):*s,x=s;return s and f(s)+x+x*s.count(x)or x


答:
><>, 27 bytes

```<code>>i:0g1+:\
:{-1v!?:<}o
/p${/
</code>```

Requires the official interpreter which exits with an error when trying to print code point -1. Try it online!

The code reads input one char at a time and uses the first row of the codebox as a large array which stores the number of times each char has been seen so far (><> initialises non-program cells to 0). The second row is a loop for outputting a char multiple times.

Alternatively, here's a version which exits cleanly (37 bytes, not properly golfed):

```<code>>i:0(?;:0g1+:\
}o:{-1v!?:   <
v  p${<
</code>```

Title: Stretch the word

Body:
><>, 27 bytes

>i:0g1+:\
:{-1v!?:<}o
/p${/

Requires the official interpreter which exits with an error when trying to print code point -1. Try it online!

The code reads input one char at a time and uses the first row of the codebox as a large array which stores the number of times each char has been seen so far (><> initialises non-program cells to 0). The second row is a loop for outputting a char multiple times.

Alternatively, here's a version which exits cleanly (37 bytes, not properly golfed):

>i:0(?;:0g1+:\
}o:{-1v!?:   <
v  p${<


答:
PowerShell v2+, <s>52</s> 47 bytes

```<code>$b=@{};-join([char[]]$args[0]|%{"$_"*++$b[$_]})
</code>```

Constructs an empty hashtable, stores it in $b. This is our "counter" of what letters we've seen. We then take input $args[0], cast it as a char-array, and send it through a loop. Each iteration, we take the current character "$_" and multiply it by the pre-incremented counter at the given value, which will make the first occurrence be multiplied by 1, the second by 2 and so on. We encapsulate that with a -join so it's all one word being output.

Saved 5 bytes thanks to TessellatingHeckler by using a hashtable instead of an array, so we didn't need to decrement the ASCII character by 97 to reach the appropriate index. This works because pre-incrementing the hash index implicitly calls .Add() in the background if that index doesn't exist, since hashtables are mutable.

```<code>PS C:\Tools\Scripts\golfing> .\stretch-the-word.ps1 tessellatingheckler
tessseelllattingheeeckllleeeer
</code>```

Title: Stretch the word

Body:
PowerShell v2+, <s>52</s> 47 bytes

$b=@{};-join([char[]]$args[0]|%{"$_"*++$b[$_]})

Constructs an empty hashtable, stores it in $b. This is our "counter" of what letters we've seen. We then take input $args[0], cast it as a char-array, and send it through a loop. Each iteration, we take the current character "$_" and multiply it by the pre-incremented counter at the given value, which will make the first occurrence be multiplied by 1, the second by 2 and so on. We encapsulate that with a -join so it's all one word being output.

Saved 5 bytes thanks to TessellatingHeckler by using a hashtable instead of an array, so we didn't need to decrement the ASCII character by 97 to reach the appropriate index. This works because pre-incrementing the hash index implicitly calls .Add() in the background if that index doesn't exist, since hashtables are mutable.

PS C:\Tools\Scripts\golfing> .\stretch-the-word.ps1 tessellatingheckler
tessseelllattingheeeckllleeeer


答:
Pyth, 7 bytes

```<code>s@Led._
</code>```

Test suite

Test suite thanks to DenkerAffe

Explanation:

```<code>s@Led._
     ._    All prefixes, implicitly applied to the input.
 @L        Filter each prefix for characters equal to
   ed      the last character of the prefix
s          Concatenate and implicitly print.
</code>```

Title: Stretch the word

Body:
Pyth, 7 bytes

s@Led._

Test suite

Test suite thanks to DenkerAffe

Explanation:

s@Led._
     ._    All prefixes, implicitly applied to the input.
 @L        Filter each prefix for characters equal to
   ed      the last character of the prefix
s          Concatenate and implicitly print.


问:
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.

答:
Y, 19 bytes

```<code>Upxp"!dlroW ,olleH"
</code>```

U captures a string with U at the beginning until the next U is met, in this case, the source code. p prints the item, and x is a termination link. When reversed, this looks like:

```<code>"Hello, World!"pxpU
</code>```

This captures the string and prints it with p, again terminating the program with x.

Try it here!

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

Body:
Y, 19 bytes

Upxp"!dlroW ,olleH"

U captures a string with U at the beginning until the next U is met, in this case, the source code. p prints the item, and x is a termination link. When reversed, this looks like:

"Hello, World!"pxpU

This captures the string and prints it with p, again terminating the program with x.

Try it here!


答:
Pyth, 6 bytes

Thanks to @Doorknob for taking off 1 byte.

Thanks to @Maltysen for taking off 5 bytes.

```<code>s@VQ._
</code>```

Try it online!

How it works

For example, take the string "bonobo".

._ makes a list: ['b', 'bo', 'bon', 'bono', 'bonob', 'bonobo']

VQ._ means "the preceding function vectorized (applied in parallel) over Q and ._", which means Q (the input evaluated) will be treated as a list: ['b', 'o', 'n', 'o', 'b', 'o'], and then they will be paired by the @ like this:

```<code>     Q      ._         @ (intersect)
0:  'b'     'b'       'b'
1:  'o'     'bo'      'o'
2:  'n'     'bon'     'n'
3:  'o'     'bono'    'oo'
4:  'b'     'bonob'   'bb'
5:  'o'     'bonobo'  'ooo'
</code>```

Therefore, @VQ._ will produce ['b', 'o', 'n', 'oo', 'bb', 'ooo'].

The s then joins them all together, creating a string 'bonoobbooo', which is then implicitly printed out to become bonoobbooo.

Title: Stretch the word

Body:
Pyth, 6 bytes

Thanks to @Doorknob for taking off 1 byte.

Thanks to @Maltysen for taking off 5 bytes.

s@VQ._

Try it online!

How it works

For example, take the string "bonobo".

._ makes a list: ['b', 'bo', 'bon', 'bono', 'bonob', 'bonobo']

VQ._ means "the preceding function vectorized (applied in parallel) over Q and ._", which means Q (the input evaluated) will be treated as a list: ['b', 'o', 'n', 'o', 'b', 'o'], and then they will be paired by the @ like this:

     Q      ._         @ (intersect)
0:  'b'     'b'       'b'
1:  'o'     'bo'      'o'
2:  'n'     'bon'     'n'
3:  'o'     'bono'    'oo'
4:  'b'     'bonob'   'bb'
5:  'o'     'bonobo'  'ooo'

Therefore, @VQ._ will produce ['b', 'o', 'n', 'oo', 'bb', 'ooo'].

The s then joins them all together, creating a string 'bonoobbooo', which is then implicitly printed out to become bonoobbooo.


问:
CSV for fun and profit (mostly neither)
Similar to the Catalogue of hello world. I want to produce a catalogue of short ways to produce CSV.

CSV Definition

In this case CSV meaning the more literal interpretation of;
A string representation of a list or array separated by commas.

The input types should not be mixed i.e [1, "hello"] is NOT valid input

The output should not start with a comma or end with a comma.
The output should not contain newline (in any way shape or form).

see example;
"John,Henry,Carol,Carl"

Input

An array of variable length, containing only simple types.
The array representation is how your chosen language defines arrays or lists.

Output

A string representation of the array separated with commas.

Example

Input: ["John", "Henry", "Carol", "Mike"]

Output: "John,Henry,Carol,Mike"

How do I win?

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

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>## [><>](http://esolangs.org/wiki/Fish), 121 bytes
</code>```

/* Configuration */

var QUESTION_ID = 74557; // Obtain this from the url
// It will be like http://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 "http://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 "http://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}

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

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

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}</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

```

答:
Gogh, 1 byte

```<code>s
</code>```

Usage:

```<code>$ ./gogh noa "s" 'John Mike Henry'
</code>```

See the wiki to understand Gogh's array input.

Explanation

```<code>     “ Implicit input    ”
s    “ String conversion ”
     “ Implicit output   ”
</code>```

Title: CSV for fun and profit (mostly neither)

Body:
Gogh, 1 byte

s

Usage:

$ ./gogh noa "s" 'John Mike Henry'

See the wiki to understand Gogh's array input.

Explanation

     “ Implicit input    ”
s    “ String conversion ”
     “ Implicit output   ”


答:
Lua, 102 Bytes

How can lua be so long while all other entries are < 30 bytes... I'm sure even Java would be shorter!

t={}for i=2,...do(i..''):gsub(".",function(d)t[#t+1]=d end)end
table.sort(t)print(1 ..table.concat(t))
```

<h3>Ungolfed</h3>

<pre class="lang-lua prettyprint-override"><code>t={}                           -- initialise t as a table
for i=2,...                    -- iterate from 2 to n
do
  (i..''):gsub(".",function(d) -- iterate over each digits in i
    t[#t+1]=d                  -- insert the digit into t
  end)
end
table.sort(t)                 -- sort t
print(1 ..table.concat(t))    -- prepend a 1 to the content of t separated by ''
</code>```

I'm forced to put a space in print(1 .., else it would try to evaluate it to a decimal 1.<decimal part>, and throws an error because . isn't a valid decimal part.

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:
Lua, 102 Bytes

How can lua be so long while all other entries are < 30 bytes... I'm sure even Java would be shorter!

t={}for i=2,...do(i..''):gsub(".",function(d)t[#t+1]=d end)end
table.sort(t)print(1 ..table.concat(t))

Ungolfed

t={}                           -- initialise t as a table
for i=2,...                    -- iterate from 2 to n
do
  (i..''):gsub(".",function(d) -- iterate over each digits in i
    t[#t+1]=d                  -- insert the digit into t
  end)
end
table.sort(t)                 -- sort t
print(1 ..table.concat(t))    -- prepend a 1 to the content of t separated by ''

I'm forced to put a space in print(1 .., else it would try to evaluate it to a decimal 1.<decimal part>, and throws an error because . isn't a valid decimal part.


答:
C, 108 bytes

```<code>char*s="char*s=%c%s%c;main(){printf(s,34,s,34);}";main(){printf(s,34,s,34);}//};)"!dlroW ,olleH"(stup{)(niam
</code>```

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:
C, 108 bytes

char*s="char*s=%c%s%c;main(){printf(s,34,s,34);}";main(){printf(s,34,s,34);}//};)"!dlroW ,olleH"(stup{)(niam


答:
05AB1E, 7 bytes

Uses the first-k method. Input in the following for:

```<code>k
[a, b]
</code>```

Code:

```<code>FD=OsÆ‚
</code>```

Explanation:

```<code>F        # For N in range(0, k).
 D=      # Duplicate top of the stack and print without popping.
   O     # Sum up the array.
    sÆ   # Swap and perform a reduced subtraction.
      ‚  # Pair the top two elements. a, b --> [a, b]
</code>```

Uses the CP-1252 encoding. Try it online!

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:
05AB1E, 7 bytes

Uses the first-k method. Input in the following for:

k
[a, b]

Code:

FD=OsÆ‚

Explanation:

F        # For N in range(0, k).
 D=      # Duplicate top of the stack and print without popping.
   O     # Sum up the array.
    sÆ   # Swap and perform a reduced subtraction.
      ‚  # Pair the top two elements. a, b --> [a, b]

Uses the CP-1252 encoding. Try it online!


答:
05AB1E, 10 bytes

Code:

```<code>$vy«Dy¢y×?
</code>```

Explanation:

```<code>$           # Push the number 1 and input
 v          # Map over the input string
  y«        # Concat the letter to the previous string (initial 1)
    D       # Duplicate this string
     y¢     # Count the occurences of the current character in the string
       y×   # Multiply this number with the current character
         ?  # Pop and print without a newline
</code>```

Uses the CP-1252 encoding. Try it online!

Title: Stretch the word

Body:
The input is a word of lowercase letters not separated by whitespace. A newline at the end is optional.

The same word must be output in a modified version: For each character, double it the second time it appears in the original word, triple it the third time etc.

Example input:

```<code>bonobo
</code>```

Example output:

```<code>bonoobbooo
</code>```

Standard I/O rules apply. The shortest code in bytes wins.

Tests provided by @Neil :

```<code>tutu -> tuttuu
queue -> queuuee
bookkeeper -> boookkkeeepeeer
repetitive -> repeetittiiveee
uncopyrightables -> uncopyrightables
abracadabra -> abraacaaadaaaabbrraaaaa
mississippi -> misssiisssssssiiipppiiii
</code>```

Body:
05AB1E, 10 bytes

Code:

$vy«Dy¢y×?

Explanation:

$           # Push the number 1 and input
 v          # Map over the input string
  y«        # Concat the letter to the previous string (initial 1)
    D       # Duplicate this string
     y¢     # Count the occurences of the current character in the string
       y×   # Multiply this number with the current character
         ?  # Pop and print without a newline

Uses the CP-1252 encoding. Try it online!


答:
MATL, 8 bytes

```<code>tt!=RsY"
</code>```

Try it online! Or verify all test cases at once.

Explanation

```<code>t    % take input string implictly. Duplicate
t!   % duplicate and transpose into a column
=    % test for equality with broadcast. Gives an NxN array, where N is
     % input string length
R    % upper triangular part: set entries below the diagonal to 0
s    % sum of each column. For each postion in the input, gives how many
     % times that letter has appeared up to that position
Y"   % replicate elements (run-length decoding). Display implicitly
</code>```

Title: Stretch the word

Body:
MATL, 8 bytes

tt!=RsY"

Try it online! Or verify all test cases at once.

Explanation

t    % take input string implictly. Duplicate
t!   % duplicate and transpose into a column
=    % test for equality with broadcast. Gives an NxN array, where N is
     % input string length
R    % upper triangular part: set entries below the diagonal to 0
s    % sum of each column. For each postion in the input, gives how many
     % times that letter has appeared up to that position
Y"   % replicate elements (run-length decoding). Display implicitly


Title: The plus-minus sequence

Body:
C, 81 bytes

a,b;main(c){for(scanf("%d%d%d",&a,&b,&c);c--;a+=b,b=a-b-b)printf("%d %d\n",a,b);}


答:
Jelly, 4 bytes

```<code>;\f"
</code>```

Try it online!

How it works

```<code>;\f"  Main link. Argument: S (string)

;\    Cumulatively reduce by concatenation.
      This yields the array of all prefixes of S.
  f"  Vectorized filter.
      Keep only occurrences of the nth letter in the nth prefix.
</code>```

Title: Stretch the word

Body:
Jelly, 4 bytes

;\f"

Try it online!

How it works

;\f"  Main link. Argument: S (string)

;\    Cumulatively reduce by concatenation.
      This yields the array of all prefixes of S.
  f"  Vectorized filter.
      Keep only occurrences of the nth letter in the nth prefix.