问:
Shortest code to print ':)' random times
You have to create a code which prints

```<code>:)
</code>```

a random number of times from 1 to 255 inclusive. Your output may not contain any whitespace.

Your score :

The count in bytes

EDIT : Also show 3 outputs of your code

Body:
Hoon, 34 bytes

(runt (~(rad og eny) 256)^':)' "")

++runt prepends b a times. Giving it just an empty tape, pulling a random number from ++rad:og with the entropy variable eny.

Really, the only interesting thing in this is the syntax a^b - it's sugar for [a b] which saves two bytes, since runt really needs to be called like (runt [a b] c)

> (runt (~(rad og eny) 256)^':)' "")
":):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):)"
> (runt (~(rad og eny) 256)^':)' "")
":):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):)"
> (runt (~(rad og eny) 256)^':)' "")
":):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):):)"


问:
Smallest integers after N divisible by 2, 3, and 4
Give credit to whom credit is due.

Objective Given an integer N > 0, out the smallest integers A, B, and C so that:

All of A, B, and C are strictly greater than N;

2 divides A;

3 divides B;

and 4 divides C.

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

Test cases

```<code>N => A, B, C
1 => 2, 3, 4
4 => 6, 6, 8
43 => 44, 45, 44
123 => 124, 126, 124
420 => 422, 423, 424
31415 => 31416, 31416, 31416
1081177 => 1081178, 1081179, 1081180
</code>```

答:
Jelly, 8 bytes

```<code>~%2r4¤+‘
</code>```

Try it online! or verify all test cases.

How it works

```<code>~%2r4¤+‘  Main link. Argument: n (integer)

~         Bitwise NOT; yield ~n = -(n + 1).
     ¤    Combine the three links to the left into a niladic chain:
  2         Yield 2.
   r4       Yield the range from 2 to 4, i.e., [2, 3, 4].
 %        Yield the remainder of the division of ~n by 2, 3 and 4.
          In Python/Jelly, -(n + 1) % k = k - (n + 1) % k if n, k > 0.
       ‘  Yield n + 1.
      +   Add each modulus to n + 1.
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Jelly, 8 bytes

~%2r4¤+‘

Try it online! or verify all test cases.

How it works

~%2r4¤+‘  Main link. Argument: n (integer)

~         Bitwise NOT; yield ~n = -(n + 1).
     ¤    Combine the three links to the left into a niladic chain:
  2         Yield 2.
   r4       Yield the range from 2 to 4, i.e., [2, 3, 4].
 %        Yield the remainder of the division of ~n by 2, 3 and 4.
          In Python/Jelly, -(n + 1) % k = k - (n + 1) % k if n, k > 0.
       ‘  Yield n + 1.
      +   Add each modulus to n + 1.

ContentLicense: CC BY-SA 3.0


答:
Julia, 16 bytes

```<code>n->n-n%(r=2:4)+r
</code>```

Try it online!

Title: Smallest integers after N divisible by 2, 3, and 4

Body:
Give credit to whom credit is due.

Objective Given an integer N > 0, out the smallest integers A, B, and C so that:

All of A, B, and C are strictly greater than N;

2 divides A;

3 divides B;

and 4 divides C.

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

Test cases

```<code>N => A, B, C
1 => 2, 3, 4
4 => 6, 6, 8
43 => 44, 45, 44
123 => 124, 126, 124
420 => 422, 423, 424
31415 => 31416, 31416, 31416
1081177 => 1081178, 1081179, 1081180
</code>```

Body:
Julia, 16 bytes

n->n-n%(r=2:4)+r

Try it online!


答:
Minkolang 0.15, 17 bytes

```<code>n$z3[zi2+$d%-+N].
</code>```

Try it here!

Explanation

```<code>n$z                  Take number from input and store in register
   3[                Open for loop that repeats 3 times
     z               Push value in register on stack
      i2+            Loop counter plus 2
         $d          Duplicate stack
           %-+       Mod, subtract, add
              N      Output as number
               ].    Close for loop and stop.
</code>```

Body:
Minkolang 0.15, 17 bytes

n$z3[zi2+$d%-+N].

Try it here!

Explanation

n$z                  Take number from input and store in register
   3[                Open for loop that repeats 3 times
     z               Push value in register on stack
      i2+            Loop counter plus 2
         $d          Duplicate stack
           %-+       Mod, subtract, add
              N      Output as number
               ].    Close for loop and stop.


答:
Pyth, <s>11</s> 10 bytes

```<code>m*dh/QdtS4
</code>```

Test suite.

```<code>       tS4  generate range [2, 3, 4]
m           for d in range...
 *dh/Qd       d*(1+input/d)
</code>```

Thanks to Dennis for a byte!

Body:
Pyth, <s>11</s> 10 bytes

m*dh/QdtS4

Test suite.

       tS4  generate range [2, 3, 4]
m           for d in range...
 *dh/Qd       d*(1+input/d)

Thanks to Dennis for a byte!


答:
CJam, 15 bytes

```<code>5,2>rif{1$/)*N}
</code>```

Try it online! or verify all test cases.

Body:
CJam, 15 bytes

5,2>rif{1$/)*N}

Try it online! or verify all test cases.


答:
Python 2, 32 bytes

lambda n:[n+2&-2,n/3*3+3,n+4&-4]
```
<p>Bit arithmetic for 2 and 4, modular arithmetic for 3.</p>
<p>I found four 7-byte expressions for the next multiple of <code>k</code> above <code>n</code> but none shorter:</p>
<pre class="lang-python prettyprint-override"><code>n-n%k+k
~n%k-~n
n/k*k+k
~n/k*-k
</code>```

Any gives 34 bytes when copies for k=2,3,4, and 33 bytes if combined:

[n/2*2+2,n/3*3+3,n/4*4+4]
[n/k*k+k for k in 2,3,4]
```
<p>But, 2 and 4 are powers of 2 that allow bit tricks to zero out the last 1 or 2 bytes.</p>
<pre class="lang-python prettyprint-override"><code>n+2&-2
n+4&-4
</code>```

This gives 6 bytes (instead of 7) for getting the next multiple, for 32 bytes overall, beating the for k in 2,3,4.

Unfortunately, the promising-looking n|1+1 and n|3+1 have the addition done first, so incrementing the output takes parentheses.

Body:
Python 2, 32 bytes

lambda n:[n+2&-2,n/3*3+3,n+4&-4]

Bit arithmetic for 2 and 4, modular arithmetic for 3.

I found four 7-byte expressions for the next multiple of k above n but none shorter:

n-n%k+k
~n%k-~n
n/k*k+k
~n/k*-k

Any gives 34 bytes when copies for k=2,3,4, and 33 bytes if combined:

[n/2*2+2,n/3*3+3,n/4*4+4]
[n/k*k+k for k in 2,3,4]

But, 2 and 4 are powers of 2 that allow bit tricks to zero out the last 1 or 2 bytes.

n+2&-2
n+4&-4

This gives 6 bytes (instead of 7) for getting the next multiple, for 32 bytes overall, beating the for k in 2,3,4.

Unfortunately, the promising-looking n|1+1 and n|3+1 have the addition done first, so incrementing the output takes parentheses.


答:
Matlab, 50 bytes

```<code>@(a)arrayfun(@(k)find(~rem(a+1:a+k,k))+a,[2 3 4])
</code>```

Body:
Matlab, 50 bytes

@(a)arrayfun(@(k)find(~rem(a+1:a+k,k))+a,[2 3 4])


答:
MATL, <s>15 10</s> 9 bytes

```<code>2:4+t5M\-
</code>```

Try it online!

Explanation:

```<code>2:4          #The array [2, 3, 4]
   +         #Add the input to each element, giving us [12, 13, 14]
    t        #Duplicate this array
     5M      #[2, 3, 4] again
       \     #Modulus on each element, giving us [0, 1, 2]
        -    #Subtract each element, giving us [12, 12, 12]
</code>```

Body:
MATL, <s>15 10</s> 9 bytes

2:4+t5M\-

Try it online!

Explanation:

2:4          #The array [2, 3, 4]
   +         #Add the input to each element, giving us [12, 13, 14]
    t        #Duplicate this array
     5M      #[2, 3, 4] again
       \     #Modulus on each element, giving us [0, 1, 2]
        -    #Subtract each element, giving us [12, 12, 12]


问:
Contaminated Squares

Introduction

Let's observe the following square, consisting only of the digits 0 - 9:

```<code>1034
4167
8414
3542
</code>```

The outer shell of this square is:

```<code>1034
4  7
8  4
3542
</code>```

It contains zeros, so we need to peel off the outer shell, leaving:

```<code>16
41
</code>```

The outer shell of this square is:

```<code>16
41
</code>```

It does not contain any zeros and is therefore a non-contaminated square. So basically, the definition of a non-contaminated square is when the outer shell of the square contains no zeros.

The Task

Given a square of digits (containing only non-negative integers) in any reasonable format, output the largest non-contaminated square by constantly peeling off the outer shell, in any reasonable format.

Test cases

Test case 1:

```<code>Input         Output

1234          1234
2345          2345
3456          3456
4567          4567
</code>```

Test case 2:

```<code>Input         Output

123           123
204           204
346           346
</code>```

Test case 3:

```<code>Input         Output

101           1
010
101
</code>```

Test case 4:

```<code>Input         Output

000           (none)
000
000
</code>```

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

答:
Pyth, 19 bytes

```<code>.W}\0.-`H`JutCPG2HJ
</code>```

Test suite

```<code>.W}\0.-`H`JutCPG2HJ
.W                     While the first function returns true, apply the second
                       function, starting with the input.
           u    2H     Apply the following twice to the input:
              PG       Remove the last row
             C         Transpose
            t          Remove the first row
                       This removes the outermost shell.
          J            Save it to J
         `             Stringify the matrix
       `H              Stringify the input
     .-                Multiset difference
  }\0                  Check if there is a '0' in the resulting string.
                  J    If that succeeds, update the current value to J.
                       When it fails, return the current value.
</code>```

Title: Contaminated Squares

Body:
Pyth, 19 bytes

.W}\0.-`H`JutCPG2HJ

Test suite

.W}\0.-`H`JutCPG2HJ
.W                     While the first function returns true, apply the second
                       function, starting with the input.
           u    2H     Apply the following twice to the input:
              PG       Remove the last row
             C         Transpose
            t          Remove the first row
                       This removes the outermost shell.
          J            Save it to J
         `             Stringify the matrix
       `H              Stringify the input
     .-                Multiset difference
  }\0                  Check if there is a '0' in the resulting string.
                  J    If that succeeds, update the current value to J.
                       When it fails, return the current value.


答:
Matlab, 33 bytes

Another slightly different approach

```<code>@(a)feval(@(x)a+1+mod(-a-1,x),2:4)
</code>```

Body:
Matlab, 33 bytes

Another slightly different approach

@(a)feval(@(x)a+1+mod(-a-1,x),2:4)


答:
Ruby, 27 bytes

Maps 2, 3, and 4 to the next multiple above n.

```<code>->n{(2..4).map{|e|n+e-n%e}}
</code>```

Body:
Ruby, 27 bytes

Maps 2, 3, and 4 to the next multiple above n.

->n{(2..4).map{|e|n+e-n%e}}


答:
MATL, 8 bytes

```<code>Qt_2:4\+
</code>```

Uses Denis' Jelly algorithm, I'm surprised it's the same length!

Try it online, or, verify all test cases.

```<code>Q    % takes implicit input and increments by one
t_   % duplicate, and negate top of stack (so it's -(n+1))
2:4  % push vector [2 3 4]
\    % mod(-(n+1),[2 3 4])
+    % add result to input+1
     % implicit display
</code>```

Body:
MATL, 8 bytes

Qt_2:4\+

Uses Denis' Jelly algorithm, I'm surprised it's the same length!

Try it online, or, verify all test cases.

Q    % takes implicit input and increments by one
t_   % duplicate, and negate top of stack (so it's -(n+1))
2:4  % push vector [2 3 4]
\    % mod(-(n+1),[2 3 4])
+    % add result to input+1
     % implicit display


答:
C, <s>50</s> 46 bytes

```<code>i;f(int*a,int n){for(i=1;++i<5;*a++=n+i-n%i);}
</code>```

Thanks to Neil and  nwellnhof for saving 4 bytes!

Disappointingly long. I feel like there's some bit-shifting hack in here that I don't know about, but I can't find it yet. Returns a pointer to an array holding the three elements. Full program:

```<code>i;f(int*a,int n){for(i=1;++i<5;*a++=n+i-n%i);}

int main()
{
    int array[3];
    int n=10;
    f(array, n);
    printf("A:%d\tB:%d\tC:%d\n",array[0],array[1],array[2]);
    return 0;
}
</code>```

Body:
C, <s>50</s> 46 bytes

i;f(int*a,int n){for(i=1;++i<5;*a++=n+i-n%i);}

Thanks to Neil and  nwellnhof for saving 4 bytes!

Disappointingly long. I feel like there's some bit-shifting hack in here that I don't know about, but I can't find it yet. Returns a pointer to an array holding the three elements. Full program:

i;f(int*a,int n){for(i=1;++i<5;*a++=n+i-n%i);}

int main()
{
    int array[3];
    int n=10;
    f(array, n);
    printf("A:%d\tB:%d\tC:%d\n",array[0],array[1],array[2]);
    return 0;
}


答:
Pyke, <s>11 9</s> 8 bytes

```<code>3FODQRc+
</code>```

Try it here!

```<code>3FODQRc+
         - Q = input()
3F       - for i in range(3): # for i in [0,1,2]
  O      -  i += 2
    Q c  -   Q-(Q%i)
       + -  i+^
</code>```

Body:
Pyke, <s>11 9</s> 8 bytes

3FODQRc+

Try it here!

3FODQRc+
         - Q = input()
3F       - for i in range(3): # for i in [0,1,2]
  O      -  i += 2
    Q c  -   Q-(Q%i)
       + -  i+^


问:
Zeroes at the end of a factorial
Write a program or function that finds the number of zeroes at the end of n! in base 10, where n is an input number (in any desired format).

It can be assumed that n is a positive integer, meaning that n! is also an integer. There are no zeroes after a decimal point in n!. Also, it can be assumed that your programming language can handle the value of n and n!.

Test cases

```<code>1
==> 0

5
==> 1

100
==> 24

666
==> 165

2016
==> 502

1234567891011121314151617181920
==> 308641972752780328537904295461
</code>```

This is code golf. Standard rules apply. The shortest code in bytes wins.

答:
GNU coreutils, 34 bytes

```<code>seq $1|factor|tr \  \\n|grep -cx 5
</code>```

The set of prime factors of the factorial n! is the union of the sets of prime factors of 1..n.  We just need to count the number of fives, as this will always be less than the number of twos, and it takes one five and one two to produce each trailing zero.  Happily, n==0 correctly produces 0, even though the question doesn't require that.

The output of factor is not quite what we want (in fact, in every golf I do, the reprinting of input is a nuisance):

```<code>$ seq 6|factor
1:
2: 2
3: 3
4: 2 2
5: 5
6: 2 3
</code>```

By replacing each space with a newline, we can match lines that are exactly 5 (this handily eliminates the 5: prefix for that line), and count the total.

You will probably run out of memory and/or time trying the last of the example inputs, but there's nothing in the program itself that wouldn't work.

Title: Zeroes at the end of a factorial

Body:
GNU coreutils, 34 bytes

seq $1|factor|tr \  \\n|grep -cx 5

The set of prime factors of the factorial n! is the union of the sets of prime factors of 1..n.  We just need to count the number of fives, as this will always be less than the number of twos, and it takes one five and one two to produce each trailing zero.  Happily, n==0 correctly produces 0, even though the question doesn't require that.

The output of factor is not quite what we want (in fact, in every golf I do, the reprinting of input is a nuisance):

$ seq 6|factor
1:
2: 2
3: 3
4: 2 2
5: 5
6: 2 3

By replacing each space with a newline, we can match lines that are exactly 5 (this handily eliminates the 5: prefix for that line), and count the total.

You will probably run out of memory and/or time trying the last of the example inputs, but there's nothing in the program itself that wouldn't work.


答:
05AB1E, 8 bytes

Code:

```<code>>D(3L>%+
</code>```

Try it online!.

Body:
05AB1E, 8 bytes

Code:

>D(3L>%+

Try it online!.


答:
C, 28 bytes

f(n){return(n/=5)?n+f(n):n;}
```

<h2>Explanation</h2>

<p>The number of trailing zeros is equal to the number of fives that make up the factorial.  Of all the <code>1..n</code>, one-fifth of them contribute a five, so we start with <code>n/5</code>.  Of these <code>n/5</code>, a fifth are multiples of 25, so contribute an extra five, and so on.  We end up with <code>f(n) = n/5 + n/25 + n/125 + ...</code>, which is <code>f(n) = n/5 + f(n/5)</code>.  We do need to terminate the recursion when <code>n</code> reaches zero; also we take advantage of the sequence point at <code>?:</code> to divide <code>n</code> before the addition.</p>

<p>As a bonus, this code is much faster than that which visits each <code>1..n</code> (and much, much faster than computing the factorial).</p>

<h2>Test program</h2>

<pre class="lang-c prettyprint-override"><code>#include<stdio.h>
#include<stdlib.h>
int main(int argc, char **argv) {
    while(*++argv) {
        int i = atoi(*argv);
        printf("%d: %d\n",i,f(i));
    }
}
</code>```

Test output

1: 0

  4: 0

  5: 1

  24: 4

  25: 6

  124: 28

  125: 31

  666: 165

  2016: 502

  2147483644: 536870901

  2147483647: 536870902

Title: Zeroes at the end of a factorial

Body:
Write a program or function that finds the number of zeroes at the end of n! in base 10, where n is an input number (in any desired format).

It can be assumed that n is a positive integer, meaning that n! is also an integer. There are no zeroes after a decimal point in n!. Also, it can be assumed that your programming language can handle the value of n and n!.

Test cases

```<code>1
==> 0

5
==> 1

100
==> 24

666
==> 165

2016
==> 502

1234567891011121314151617181920
==> 308641972752780328537904295461
</code>```

This is code golf. Standard rules apply. The shortest code in bytes wins.

Body:
C, 28 bytes

f(n){return(n/=5)?n+f(n):n;}

Explanation

The number of trailing zeros is equal to the number of fives that make up the factorial.  Of all the 1..n, one-fifth of them contribute a five, so we start with n/5.  Of these n/5, a fifth are multiples of 25, so contribute an extra five, and so on.  We end up with f(n) = n/5 + n/25 + n/125 + ..., which is f(n) = n/5 + f(n/5).  We do need to terminate the recursion when n reaches zero; also we take advantage of the sequence point at ?: to divide n before the addition.

As a bonus, this code is much faster than that which visits each 1..n (and much, much faster than computing the factorial).

Test program

#include<stdio.h>
#include<stdlib.h>
int main(int argc, char **argv) {
    while(*++argv) {
        int i = atoi(*argv);
        printf("%d: %d\n",i,f(i));
    }
}

Test output

1: 0

  4: 0

  5: 1

  24: 4

  25: 6

  124: 28

  125: 31

  666: 165

  2016: 502

  2147483644: 536870901

  2147483647: 536870902


答:
><>, 31 bytes

```<code>&2v
:&\&
?!\1+:{:}%
ao\n1+:5=?;
</code>```

Expects N to be present on the stack at program start. Try it online!

Body:
Give credit to whom credit is due.

Objective Given an integer N > 0, out the smallest integers A, B, and C so that:

All of A, B, and C are strictly greater than N;

2 divides A;

3 divides B;

and 4 divides C.

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

Test cases

```<code>N => A, B, C
1 => 2, 3, 4
4 => 6, 6, 8
43 => 44, 45, 44
123 => 124, 126, 124
420 => 422, 423, 424
31415 => 31416, 31416, 31416
1081177 => 1081178, 1081179, 1081180
</code>```

Body:
><>, 31 bytes

&2v
:&\&
?!\1+:{:}%
ao\n1+:5=?;

Expects N to be present on the stack at program start. Try it online!


问:
Golf you a quine for great good!
Using your language of choice, golf a quine.

A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output.

No cheating -- that means that you can't just read the source file and print it. Also, in many languages, an empty file is also a quine: that isn't considered a legit quine either.

No error quines -- there is already a separate challenge for error quines.

Points for:

Smallest code (in bytes)

Most obfuscated/obscure solution

Using esoteric/obscure languages

Successfully using languages that are difficult to golf in

The following Stack Snippet can be used to get a quick view of the current score in each language, and thus to know which languages have existing answers and what sort of target you have to beat:

var QUESTION_ID=69;
var OVERRIDE_USER=98;

var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk";var answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;function answersUrl(index){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+index+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}
function commentUrl(index,answers){return"https://api.stackexchange.com/2.2/answers/"+answers.join(';')+"/comments?page="+index+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}
function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,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=!1;comment_page=1;getComments()}})}
function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,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=(function(){var headerTag=String.raw `h\d`
var score=String.raw `\-?\d+\.?\d*`
var normalText=String.raw `[^\n<>]*`
var strikethrough=String.raw `<s>${normalText}</s>|<strike>${normalText}</strike>|<del>${normalText}</del>`
var noDigitText=String.raw `[^\n\d<>]*`
var htmlTag=String.raw `<[^\n<>]+>`
return new RegExp(String.raw `<${headerTag}>`+String.raw `\s*([^\n,]*[^\s,]),.*?`+String.raw `(${score})`+String.raw `(?=`+String.raw `${noDigitText}`+String.raw `(?:(?:${strikethrough}|${htmlTag})${noDigitText})*`+String.raw `</${headerTag}>`+String.raw `)`)})();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,})});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(''+a.language+'').text().toLowerCase();languages[lang]=languages[lang]||{lang:a.language,user:a.user,size:a.size,link:a.link,uniq:lang}});var langs=[];for(var lang in languages)
if(languages.hasOwnProperty(lang))
langs.push(languages[lang]);langs.sort(function(a,b){if(a.uniq>b.uniq)return 1;if(a.uniq<b.uniq)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;float:left}#language-list{padding:10px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

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

Winners by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

 ```

答:
These are the two shortest Ruby quines from SO:

```<code>_="_=%p;puts _%%_";puts _%_
</code>```

and

```<code>puts <<2*2,2
puts <<2*2,2
2
</code>```

Don't ask me how the second works...

Title: Golf you a quine for great good!

Body:
These are the two shortest Ruby quines from SO:

_="_=%p;puts _%%_";puts _%_

and

puts <<2*2,2
puts <<2*2,2
2

Don't ask me how the second works...


问:
Crossword numbering
Produce a program to correctly number a crossword grid.

Input

The input will be the name of a file representing the crossword
grid. The input filename may be passed as an argument, on the
standard input, or by other conventional means other than
hardcoding.

Grid file format: A text file. The first line consists of two white-space
separated integer constants M and N. Following that line are M
lines each consisting of N characters (plus a new line) selected
from [#A-Z ]. These characters are interpreted such that '#'
indicates a blocked square, ' ' a open square in the puzzle
with no known contents and any letter an open square whose
containing that letter.

Output

The output will be a numbering file, and may be sent to the
standard output, to a file whose name is derived from the
input filename, to a user specified file, or to some other
conventional destination.

Numbering file format A text file. Lines starting with '#' are ignored and
may be used for comments. All other lines contain a tab separated
triplet i, m, n where i represents a number to be printed
on the grid, and m and n represent the row and column of the
square where it should be printed. The number of both rows and
columns starts at 1.

Numbering scheme

A correctly numbered grid has the following properties:

Numbering begins at 1.

No column or span of open squares is unnumbered. (You may assume
that no single character answer will exist in the problem.)

Numbers will be encountered in counting order by scanning from
top row to the bottom taking each row from left to right. (So,
every horizontal span is numbered at its leftmost square, and
every column is numbered at its topmost square.)

Test input and expected output

Input:

```<code>5   5
#  ##
#
  #
    #
##  #
</code>```

Output (neglecting comment lines):

```<code>1       1       2
2       1       3
3       2       2
4       2       4
5       2       5
6       3       1
7       3       4
8       4       1
9       4       3
10      5       3
</code>```

Aside

This is the first of what will hopefully be several crossword
related challenges. I plan to use a consistent set of
file-formats throughout and to build up a respectable suite of
crossword related utilities in the process. For instance a
subsequent puzzle will call for printing a ASCII version of the
crossword based on the input and output of this puzzle.

答:
SHELL SCRIPT

```<code>#!/bin/sh
crossWordFile=$1

totLines=`head -1 $crossWordFile | cut -d" " -f1`
totChars=`head -1 $crossWordFile | awk -F' ' '{printf $2}'`

NEXT_NUM=1
for ((ROW=2; ROW<=(${totLines}+1); ROW++))
do
   LINE=`sed -n ${ROW}p $crossWordFile`
   for ((COUNT=0; COUNT<${totChars}; COUNT++))
   do
      lineNumber=`expr $ROW - 1`
      columnNumber=`expr $COUNT + 1`
      TOKEN=${LINE:$COUNT:1}
      if [ "${TOKEN}" != "#" ]; then
      if [ ${lineNumber} -eq 1 ] || [ ${columnNumber} -eq 1 ]; then
          printf "${NEXT_NUM}\t${lineNumber}\t${columnNumber}\n"
          NEXT_NUM=`expr $NEXT_NUM + 1`
      elif [ "${TOKEN}" != "#" ] ; then
          upGrid=`sed -n ${lineNumber}p $crossWordFile | cut -c"${columnNumber}"`
          leftGrid=`sed -n ${ROW}p $crossWordFile | cut -c${COUNT}`
          if [ "${leftGrid}" = "#" ] || [ "${upGrid}" = "#" ]; then
          printf "${NEXT_NUM}\t${lineNumber}\t${columnNumber}\n"
          NEXT_NUM=`expr $NEXT_NUM + 1`
          fi
      fi
      fi
   done
done
</code>```

sample I/O:

./numberCrossWord.sh crosswordGrid.txt

```<code>1       1       2
2       1       3
3       2       2
4       2       4
5       2       5
6       3       1
7       3       4
8       4       1
9       4       3
10      5       3
</code>```

ContentLicense: CC BY-SA 2.5

Title: Crossword numbering

Body:
SHELL SCRIPT

#!/bin/sh
crossWordFile=$1

totLines=`head -1 $crossWordFile | cut -d" " -f1`
totChars=`head -1 $crossWordFile | awk -F' ' '{printf $2}'`

NEXT_NUM=1
for ((ROW=2; ROW<=(${totLines}+1); ROW++))
do
   LINE=`sed -n ${ROW}p $crossWordFile`
   for ((COUNT=0; COUNT<${totChars}; COUNT++))
   do
      lineNumber=`expr $ROW - 1`
      columnNumber=`expr $COUNT + 1`
      TOKEN=${LINE:$COUNT:1}
      if [ "${TOKEN}" != "#" ]; then
      if [ ${lineNumber} -eq 1 ] || [ ${columnNumber} -eq 1 ]; then
          printf "${NEXT_NUM}\t${lineNumber}\t${columnNumber}\n"
          NEXT_NUM=`expr $NEXT_NUM + 1`
      elif [ "${TOKEN}" != "#" ] ; then
          upGrid=`sed -n ${lineNumber}p $crossWordFile | cut -c"${columnNumber}"`
          leftGrid=`sed -n ${ROW}p $crossWordFile | cut -c${COUNT}`
          if [ "${leftGrid}" = "#" ] || [ "${upGrid}" = "#" ]; then
          printf "${NEXT_NUM}\t${lineNumber}\t${columnNumber}\n"
          NEXT_NUM=`expr $NEXT_NUM + 1`
          fi
      fi
      fi
   done
done

sample I/O:

./numberCrossWord.sh crosswordGrid.txt

1       1       2
2       1       3
3       2       2
4       2       4
5       2       5
6       3       1
7       3       4
8       4       1
9       4       3
10      5       3


问:
Golf Text into DNA

Text to DNA golf

Challenge

Convert input into a DNA output.

Algorithm

Convert text into ASCII code points (e.g. codegolf -> [99, 111, 100, 101, 103, 111, 108, 102])

String the ASCII codes together (e.g. 99111100101103111108102)

Convert to binary (e.g. 10100111111001101001011010001000011001101011011110000110010111111011000000110)

Pad 0s onto the end to make an even number of characters (e.g. 101001111110011010010110100010000110011010110111100001100101111110110000001100)

Replace 00 with A, 01 with C, 10 with G, and 11 with T (e.g. GGCTTGCGGCCGGAGACGCGGTCTGACGCCTTGTAAATA)

Output

Test Cases

```<code>codegolf > GGCTTGCGGCCGGAGACGCGGTCTGACGCCTTGTAAATA
ppcg > GGCTAATTGTCGCACTT
} > TTGG (padding)
</code>```

Specifications

This is code-golf

Your program must accept spaces in input.

Your program must work for codegolf.

答:
MATL, 21 bytes

```<code>'CGTA'joV4Y2HZa2e!XB)
</code>```

Try it online!

Explanation

```<code>'CGTA'   % Push string to be indexed into
j        % Take input string
o        % Convert each char to its ASCII code
V        % Convert to string (*). Numbers are separated by spaces
4Y2      % Push the string '0123456789'
H        % Push number 2
Za       % Convert string (*) from base '0123456789' to base 2, ignoring spaces
2e       % Reshape into a 2-column matrix, padding with a trailing 0 if needed
!        % Transpose
XB       % Convert from binary to decimal
)        % Index into string with the DNA letters. Indexing is 1-based and modular
</code>```

Title: Golf Text into DNA

Body:
MATL, 21 bytes

'CGTA'joV4Y2HZa2e!XB)

Try it online!

Explanation

'CGTA'   % Push string to be indexed into
j        % Take input string
o        % Convert each char to its ASCII code
V        % Convert to string (*). Numbers are separated by spaces
4Y2      % Push the string '0123456789'
H        % Push number 2
Za       % Convert string (*) from base '0123456789' to base 2, ignoring spaces
2e       % Reshape into a 2-column matrix, padding with a trailing 0 if needed
!        % Transpose
XB       % Convert from binary to decimal
)        % Index into string with the DNA letters. Indexing is 1-based and modular


答:
dc, 12 bytes

[5/dd0<f+]sf
```

<p>This defines a function <code>f</code> which consumes its input from top of stack, and leaves its output at top of stack. See my C answer for the mathematical basis.  We repeatedly divide by 5, accumulating the values on the stack, then add all the results:</p>

<pre class="lang-dc prettyprint-override"><code>5/d   # divide by 5, and leave a copy behind
d0<   # still greater than zero?
f+    # if so, apply f to the new value and add
</code>```

Test program

# read input values
?
# print prefix
[  # for each value
    # print prefix
    [> ]ndn[ ==> ]n
    # call f(n)
    lfx
    # print suffix
    n[
]n
    # repeat for each value on stack
    z0<t
]
# define and run test function 't'
dstx
```

<h2>Test output</h2>

<pre class="lang-sh prettyprint-override"><code>./79762.dc <<<'1234567891011121314151617181920 2016 666 125 124 25 24 5 4 1'
</code>```

1 ==> 0
4 ==> 0
5 ==> 1
24 ==> 4
25 ==> 6
124 ==> 28
125 ==> 31
666 ==> 165
2016 ==> 502
1234567891011121314151617181920 ==> 308641972752780328537904295461
```

Title: Zeroes at the end of a factorial

Body:
dc, 12 bytes

[5/dd0<f+]sf

This defines a function f which consumes its input from top of stack, and leaves its output at top of stack. See my C answer for the mathematical basis.  We repeatedly divide by 5, accumulating the values on the stack, then add all the results:

5/d   # divide by 5, and leave a copy behind
d0<   # still greater than zero?
f+    # if so, apply f to the new value and add

Test program

# read input values
?
# print prefix
[  # for each value
    # print prefix
    [> ]ndn[ ==> ]n
    # call f(n)
    lfx
    # print suffix
    n[
]n
    # repeat for each value on stack
    z0<t
]
# define and run test function 't'
dstx

Test output

./79762.dc <<<'1234567891011121314151617181920 2016 666 125 124 25 24 5 4 1'

1 ==> 0
4 ==> 0
5 ==> 1
24 ==> 4
25 ==> 6
124 ==> 28
125 ==> 31
666 ==> 165
2016 ==> 502
1234567891011121314151617181920 ==> 308641972752780328537904295461


问:
Longest Common Prefix of 2 Strings
Write a program that takes 2 strings as input, and returns the longest common prefix. This is code-golf, so the answer with the shortest amount of bytes wins.</p>

```<code>Test Case 1:

"global" , "glossary"
"glo"

Test Case 2:

"department" , "depart"
"depart"

Test Case 3:

"glove", "dove"
""
</code>```

答:
Dyalog APL, 12 bytes

```<code>{⊥⍨⌽=⌿↑⍵}↑∊
</code>```

That's two bytes less than the previous APL solution!

The overall function is ↑, which takes n elements (characters) from the flattened (∊) argument, where n is the result of applying the function {⊥⍨⌽=⌿↑⍵} to the argument:

↑⍵ convert list of strings to table (padding with spaces to form rectangle)

=⌿ compare down (columns) giving boolean list

⌽ reverse

⊥⍨ count trailing trues*

*Literally it is a mixed-base to base-10 conversion, using the boolean list as both number and base:

⊥⍨0 1 0 1 1 is the same as 0 1 0 1 1⊥⍨0 1 0 1 1 which is  0×(0×1×0×1×1) 1×(1×0×1×1) 0×(0×1×1) 1×(1×1) + 1×(1) which again is two (the number of trailing 1s).

Title: Longest Common Prefix of 2 Strings

Body:
Dyalog APL, 12 bytes

{⊥⍨⌽=⌿↑⍵}↑∊

That's two bytes less than the previous APL solution!

The overall function is ↑, which takes n elements (characters) from the flattened (∊) argument, where n is the result of applying the function {⊥⍨⌽=⌿↑⍵} to the argument:

↑⍵ convert list of strings to table (padding with spaces to form rectangle)

=⌿ compare down (columns) giving boolean list

⌽ reverse

⊥⍨ count trailing trues*

*Literally it is a mixed-base to base-10 conversion, using the boolean list as both number and base:

⊥⍨0 1 0 1 1 is the same as 0 1 0 1 1⊥⍨0 1 0 1 1 which is  0×(0×1×0×1×1) 1×(1×0×1×1) 0×(0×1×1) 1×(1×1) + 1×(1) which again is two (the number of trailing 1s).


问:
Simple cat program
One of the most common standard tasks (especially when showcasing esoteric programming languages) is to implement a "cat program": read all of STDIN and print it to STDOUT. While this is named after the Unix shell utility cat it is of course much less powerful than the real thing, which is normally used to print (and concatenate) several files read from disc.

Task

You should write a full program which reads the contents of the standard input stream and writes them verbatim to the standard output stream. If and only if your language does not support standard input and/or output streams (as understood in most languages), you may instead take these terms to mean their closest equivalent in your language (e.g. JavaScript's prompt and alert). These are the only admissible forms of I/O, as any other interface would largely change the nature of the task and make answers much less comparable.

The output should contain exactly the input and nothing else. The only exception to this rule is constant output of your language's interpreter that cannot be suppressed, such as a greeting, ANSI color codes or indentation. This also applies to trailing newlines. If the input does not contain a trailing newline, the output shouldn't include one either! (The only exception being if your language absolutely always prints a trailing newline after execution.)

Output to the standard error stream is ignored, so long as the standard output stream contains the expected output. In particular, this means your program can terminate with an error upon hitting the end of the stream (EOF), provided that doesn't pollute the standard output stream. If you do this, I encourage you to add an error-free version to your answer as well (for reference).

As this is intended as a challenge within each language and not between languages, there are a few language specific rules:

If it is at all possible in your language to distinguish null bytes in the standard input stream from the EOF, your program must support null bytes like any other bytes (that is, they have to be written to the standard output stream as well).

If it is at all possible in your language to support an arbitrary infinite input stream (i.e. if you can start printing bytes to the output before you hit EOF in the input), your program has to work correctly in this case. As an example yes | tr -d \\n | ./my_cat should print an infinite stream of ys. It is up to you how often you print and flush the standard output stream, but it must be guaranteed to happen after a finite amount of time, regardless of the stream (this means, in particular, that you cannot wait for a specific character like a linefeed before printing).

Please add a note to your answer about the exact behaviour regarding null-bytes, infinite streams, and extraneous output.

Additional rules

This is not about finding the language with the shortest solution for this (there are some where the empty program does the trick) - this is about finding the shortest solution in every language. Therefore, no answer will be marked as accepted.

Submissions in most languages will be scored in bytes in an appropriate preexisting encoding, usually (but not necessarily) UTF-8.

Some languages, like Folders, are a bit tricky to score. If in doubt, please ask on Meta.

Feel free to use a language (or language version) even if it's newer than this challenge. Languages specifically written to submit a 0-byte answer to this challenge are fair game but not particularly interesting.

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

Also note that languages do have to fulfil our usual criteria for programming languages.

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

Unless they have been overruled earlier, all standard code-golf rules apply, including the http://meta.codegolf.stackexchange.com/q/1061.

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

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

 <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

```

答:
APL, 6 bytes

```<code>⎕←⍞
→1
</code>```

This has worked in all APLs since the beginning of time.

⍞ wait for input

⎕← Output that

→1 go to line 1

Title: Simple cat program

Body:
APL, 6 bytes

⎕←⍞
→1

This has worked in all APLs since the beginning of time.

⍞ wait for input

⎕← Output that

→1 go to line 1


问:
Find the Words on the Grid!
Write a program or function that extracts a word from a wordsearch using its start and end coordinates.

The Input

Your program or function should accept three parameters: the start coordinate, the end coordinate, and a wordsearch from which to extract the word.

The start coordinate can be taken in any format.

It will always be an integer

The bottom left of the grid is (0, 0)

You will not be provided with coordinates that go outside the bounds of the grid

You will not be provided with coordinates that are not vertical, horizontal, or perfectly diagonal to each other, such as (7, 0) and (0, 6).

The end coordinate will be taken in the same format as the start coordinate

The wordsearch will be a string, or your language's closest equivalent

It will be a grid of characters separated by a single space, with each row on a newline. It can have any height or width - which can be different - but it will always be a rectangle. For example:

```<code>A G O A T C A T
E A T M E N O W
W O R D S E A R
A K L L K J H G
N P L F G H F D
A S P L K J H G
O P I L F G H J
T F A S E J K L
</code>```

```<code>J H P B L D J L T
F J L N F N P W H
W P R D T F J R Q
J L L L L J H H W
N P L F H H F D S
J T P L L J H H K
P P J L F H H J N
L F J T F J L L O
</code>```

The Output

You should output a string, or your language's closest equivalent. As no wordsearches in real life ever ask to find a single letter, you may output nothing if the coordinates are the same.

Examples and Test Cases

```
First Grid Above:
(0, 4) and (4, 0) --> "APPLE"

(4, 0) and (0, 4) --> "ELPPA"

(1, 7) and (4, 7) --> "GOAT"

(0, 5) and (7, 5) --> "WORDSEAR"

(0, 6) and (5, 6) --> "EATMEN"

(0, 6) and (0, 7) --> "EA"

(7, 0) and (0, 7) --> "LHJGLRAA"

----------

Second Grid Above:
(1, 0) and (8, 7) --> "FJLHJJWT"

(1, 4) and (4, 4) --> "LLLL"

(1, 4) and (1, 4) --> "L" or ""```

答:
Python 3.5 using Numpy, 251 bytes:

```<code>def r(t,y,z):import numpy;l=numpy.array([[*i.split()]for i in z.split('\n')]);A,B,C,D=t[0],y[0],t[1],y[1];p=[1,-1];a=p[A>B];b=p[C>D];n=range(A,B+a,a);m=range(C,D+b,b);w=[l[:,i][::-1][p]for i,p in zip([[A]*len(m),n][A!=B],[[C]*len(n),m][C!=D])];return w
</code>```

Takes input in the following format:

```<code>print(''.join(r((start1,start2),(end1,end2),'''grid''')))
</code>```

Outputs in the format of a string (e.g. APPLE) as long as the function is called using the format above. Otherwise, a list
containing each letter (e.g. ['A','P','P','L','E']) is returned.

Will golf more over time where and when I can.

Try It Online! (Ideone) (Here, input is taken such that the grid is surrounded with double quotes ("") and input on one line, with \ns between each line of the grid. Then, the points are provided in a simple tuple form, with the starting on the second line, and the end on the third.)

Ungolfed code along with Explanation

```<code>def r(t,y,z):
    import numpy
    l=numpy.array([[*i.split()]for i in z.split('\n')])
    A,B,C,D=t[0],y[0],t[1],y[1]
    p=[1,-1]
    a=p[A>B]
    b=p[C>D]
    n=range(A,B+a,a)
    m=range(C,D+b,b)
    w=[l[:,i][::-1][p]for i,p in zip([[A]*len(m),n][A!=B],[[C]*len(n),m][C!=D])]
    return w
</code>```

For the purposes of this explanation, assume this program was run with the inputs ((0,4),(4,0)) and the first grid of the question. Here, I will go through the 2 main parts of the code:

l=numpy.array([[*i.split()]for i in z.split('\n')])

Here, l is a numpy array containing each line of the input in a separate "list". For instance, the first grid in the question, which is:

```<code>A G O A T C A T
E A T M E N O W
W O R D S E A R
A K L L K J H G
N P L F G H F D
A S P L K J H G
O P I L F G H J
T F A S E J K L
</code>```

returns this numpy array:

```<code>[['A' 'G' 'O' 'A' 'T' 'C' 'A' 'T']
 ['E' 'A' 'T' 'M' 'E' 'N' 'O' 'W']
 ['W' 'O' 'R' 'D' 'S' 'E' 'A' 'R']
 ['A' 'K' 'L' 'L' 'K' 'J' 'H' 'G']
 ['N' 'P' 'L' 'F' 'G' 'H' 'F' 'D']
 ['A' 'S' 'P' 'L' 'K' 'J' 'H' 'G']
 ['O' 'P' 'I' 'L' 'F' 'G' 'H' 'J']
 ['T' 'F' 'A' 'S' 'E' 'J' 'K' 'L']]
</code>```

w=[l[:,i][::-1][p]for i,p in zip([[A]*len(m),n][A!=B],[[C]*len(n),m][C!=D])]

This is the main list of the function in which all of the letters corresponding to each point on the grid is found. Here, i corresponds to either each integer in n, which is a range object containing every number in the range start1=>end1+1 in increments of +1 if start1<end1 or -1 if the opposite is true. However, i only corresponds to this as long as start1 does not equal end1. Otherwise start1 is returned as many times as the length of m, where m is a range object containing each integer in the range start2=>end2+1 with the same conditions as n, and p corresponds to every integer in m. That being said, let us now walk through this step by step:

l[:,i] basically returns a row vector for each column, i, in the array, l. for instance, l[:,0] would return:

```<code>['A' 'E' 'W' 'A' 'N' 'A' 'O' 'T']
</code>```

l[:,1] would return:

```<code>['G' 'A' 'O' 'K' 'P' 'S' 'P' 'F']
</code>```

so on and so forth. You can read more about different ways of indexing in numpy, including this method, here.

Then, after that, the function reverses each array returned, using l[:,i][::-1], since each array is indexed from left to right, but since the point 0,0 on the grid in on the lower left hand corner of the grid, reversing each array would return the index values as if they were being looked for from right to left. For instance, l[:,0][::-1] would return:

```<code>['T' 'O' 'A' 'N' 'A' 'W' 'E' 'A']
</code>```

After this, the function then indexes through that reversed array for the index value corresponding to p, which is your letter, and then adds that to the list being created. For instance, l[:,0][::-1][4], which corresponds to point (0,4), would return A.

This process keeps on repeating and adding new values to the list until  the range objects are exhausted.

After all that, the output, which is list w, is finally returned. In this case, that would be APPLE if called with print(''.join(r((0,4),(4,0),'''The Grid'''))) or ['A','P','P','L','E'] if it is called without ''.join(). Either way, it returns the correct answer, and we are done!

Title: Find the Words on the Grid!

Body:
Python 3.5 using Numpy, 251 bytes:

def r(t,y,z):import numpy;l=numpy.array([[*i.split()]for i in z.split('\n')]);A,B,C,D=t[0],y[0],t[1],y[1];p=[1,-1];a=p[A>B];b=p[C>D];n=range(A,B+a,a);m=range(C,D+b,b);w=[l[:,i][::-1][p]for i,p in zip([[A]*len(m),n][A!=B],[[C]*len(n),m][C!=D])];return w

Takes input in the following format:

print(''.join(r((start1,start2),(end1,end2),'''grid''')))

Outputs in the format of a string (e.g. APPLE) as long as the function is called using the format above. Otherwise, a list
containing each letter (e.g. ['A','P','P','L','E']) is returned.

Will golf more over time where and when I can.

Try It Online! (Ideone) (Here, input is taken such that the grid is surrounded with double quotes ("") and input on one line, with \ns between each line of the grid. Then, the points are provided in a simple tuple form, with the starting on the second line, and the end on the third.)

Ungolfed code along with Explanation

def r(t,y,z):
    import numpy
    l=numpy.array([[*i.split()]for i in z.split('\n')])
    A,B,C,D=t[0],y[0],t[1],y[1]
    p=[1,-1]
    a=p[A>B]
    b=p[C>D]
    n=range(A,B+a,a)
    m=range(C,D+b,b)
    w=[l[:,i][::-1][p]for i,p in zip([[A]*len(m),n][A!=B],[[C]*len(n),m][C!=D])]
    return w

For the purposes of this explanation, assume this program was run with the inputs ((0,4),(4,0)) and the first grid of the question. Here, I will go through the 2 main parts of the code:

l=numpy.array([[*i.split()]for i in z.split('\n')])

Here, l is a numpy array containing each line of the input in a separate "list". For instance, the first grid in the question, which is:

A G O A T C A T
E A T M E N O W
W O R D S E A R
A K L L K J H G
N P L F G H F D
A S P L K J H G
O P I L F G H J
T F A S E J K L

returns this numpy array:

[['A' 'G' 'O' 'A' 'T' 'C' 'A' 'T']
 ['E' 'A' 'T' 'M' 'E' 'N' 'O' 'W']
 ['W' 'O' 'R' 'D' 'S' 'E' 'A' 'R']
 ['A' 'K' 'L' 'L' 'K' 'J' 'H' 'G']
 ['N' 'P' 'L' 'F' 'G' 'H' 'F' 'D']
 ['A' 'S' 'P' 'L' 'K' 'J' 'H' 'G']
 ['O' 'P' 'I' 'L' 'F' 'G' 'H' 'J']
 ['T' 'F' 'A' 'S' 'E' 'J' 'K' 'L']]

w=[l[:,i][::-1][p]for i,p in zip([[A]*len(m),n][A!=B],[[C]*len(n),m][C!=D])]

This is the main list of the function in which all of the letters corresponding to each point on the grid is found. Here, i corresponds to either each integer in n, which is a range object containing every number in the range start1=>end1+1 in increments of +1 if start1<end1 or -1 if the opposite is true. However, i only corresponds to this as long as start1 does not equal end1. Otherwise start1 is returned as many times as the length of m, where m is a range object containing each integer in the range start2=>end2+1 with the same conditions as n, and p corresponds to every integer in m. That being said, let us now walk through this step by step:

l[:,i] basically returns a row vector for each column, i, in the array, l. for instance, l[:,0] would return:

['A' 'E' 'W' 'A' 'N' 'A' 'O' 'T']

l[:,1] would return:

['G' 'A' 'O' 'K' 'P' 'S' 'P' 'F']

so on and so forth. You can read more about different ways of indexing in numpy, including this method, here.

Then, after that, the function reverses each array returned, using l[:,i][::-1], since each array is indexed from left to right, but since the point 0,0 on the grid in on the lower left hand corner of the grid, reversing each array would return the index values as if they were being looked for from right to left. For instance, l[:,0][::-1] would return:

['T' 'O' 'A' 'N' 'A' 'W' 'E' 'A']

After this, the function then indexes through that reversed array for the index value corresponding to p, which is your letter, and then adds that to the list being created. For instance, l[:,0][::-1][4], which corresponds to point (0,4), would return A.

This process keeps on repeating and adding new values to the list until  the range objects are exhausted.

After all that, the output, which is list w, is finally returned. In this case, that would be APPLE if called with print(''.join(r((0,4),(4,0),'''The Grid'''))) or ['A','P','P','L','E'] if it is called without ''.join(). Either way, it returns the correct answer, and we are done!


答:
><>, 37 bytes

```<code>i:0( ?\
4*=?\$>1+{:8
+[r]\$1
?!;o>:{=
</code>```

Try it online!

Input is via STDIN, and is expected without quotes, separated by a space. For example, global glossary.

After the input is read, the characters up to and including the space are reversed and pushed back onto the stack. For example, if the input were global glossary, the stack would be glossary labolg. The stack is then rotated to the left one step at a time. If the top two chars are the same, output. Otherwise, end.

Title: Longest Common Prefix of 2 Strings

Body:
Write a program that takes 2 strings as input, and returns the longest common prefix. This is code-golf, so the answer with the shortest amount of bytes wins.</p>

```<code>Test Case 1:

"global" , "glossary"
"glo"

Test Case 2:

"department" , "depart"
"depart"

Test Case 3:

"glove", "dove"
""
</code>```

Body:
><>, 37 bytes

i:0( ?\
4*=?\$>1+{:8
+[r]\$1
?!;o>:{=

Try it online!

Input is via STDIN, and is expected without quotes, separated by a space. For example, global glossary.

After the input is read, the characters up to and including the space are reversed and pushed back onto the stack. For example, if the input were global glossary, the stack would be glossary labolg. The stack is then rotated to the left one step at a time. If the top two chars are the same, output. Otherwise, end.


答:
Retina, <s>62</s> <s>43</s> 26 bytes

17 bytes thanks to @Martin Büttner.

```
^
1111:
M!&`(11+):(\1*)
:

```

(Note the trailing newline.)

Try it online!

Input in unary in 1, output in unary in 1 separated by newlines.

Previous 43-byte version:

```<code>.+
11:$&;111:$&;1111:$&
\b(1+):(\1*)1*
$1$2
</code>```

Try it online!

Input in unary, output in unary separated by semi-colon (;).

Previous 62-byte version:

```<code>.+
$&11;$&111;$&1111
((11)+)1*;((111)+)1*;((1111)+)1*
$1;$3;$5
</code>```

Try it online!

Input in unary, output in unary separated by semi-colon (;).

Body:
Retina, <s>62</s> <s>43</s> 26 bytes

17 bytes thanks to @Martin Büttner.

^
1111:
M!&`(11+):(\1*)
:

(Note the trailing newline.)

Try it online!

Input in unary in 1, output in unary in 1 separated by newlines.

Previous 43-byte version:

.+
11:$&;111:$&;1111:$&
\b(1+):(\1*)1*
$1$2

Try it online!

Input in unary, output in unary separated by semi-colon (;).

Previous 62-byte version:

.+
$&11;$&111;$&1111
((11)+)1*;((111)+)1*;((1111)+)1*
$1;$3;$5

Try it online!

Input in unary, output in unary separated by semi-colon (;).


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

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

The Rules

Each submission must be a full program.

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

The program must not write anything to STDERR.

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

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

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

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

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

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

For inspiration, check the Hello World Collection.

The Catalogue

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

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

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

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

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

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

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

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

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

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

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

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

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
Pyke, 14 bytes

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

Try it here!

Title: "Hello, World!"

Body:
Pyke, 14 bytes

"Hello, World!

Try it here!


答:
Tellurium, 17 bytes

```<code>µHello, World!~^
</code>```

Well, this is pretty easy to explain.

µ starts reading the string

~ stops reading the string, and stores it in the selected cell.

^ outputs the selected cell's value, which is currently "Hello, world!"

Alternate version (5 bytes)

This one uses the preinitialized variable !o, which expands to "Hello, World!".

```<code>µ!o~^
</code>```

Title: "Hello, World!"

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

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

The Rules

Each submission must be a full program.

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

The program must not write anything to STDERR.

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

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

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

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

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

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

For inspiration, check the Hello World Collection.

The Catalogue

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

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

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

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

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

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

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

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

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

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

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

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

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

Body:
Tellurium, 17 bytes

µHello, World!~^

Well, this is pretty easy to explain.

µ starts reading the string

~ stops reading the string, and stores it in the selected cell.

^ outputs the selected cell's value, which is currently "Hello, world!"

Alternate version (5 bytes)

This one uses the preinitialized variable !o, which expands to "Hello, World!".

µ!o~^


答:
R, <s>30</s> 26 bytes

(Reduced 4 bytes thanks to @Neil)

```<code>N=scan();cat(N+2:4-N%%2:4)
</code>```

This (similarly to the rest of the answers I guess) adds 2:4 to the input and the reduces the remainder after running modulo on the same numbers.

Body:
R, <s>30</s> 26 bytes

(Reduced 4 bytes thanks to @Neil)

N=scan();cat(N+2:4-N%%2:4)

This (similarly to the rest of the answers I guess) adds 2:4 to the input and the reduces the remainder after running modulo on the same numbers.


答:
UGL, <s>51</s> <s>31</s> <s>25</s> 24 bytes

```<code>icu$l_u^^/%_u^*ocO$dddd:
</code>```

Try it online!

Previous 25-byte version:

```<code>iRcu$l_u$r^/%_u*ocO$dddd:
</code>```

Try it online!

Previous 31-byte version:

```<code>iRcuuulu$cuuuuuu%-r^/%_u*oddcO:
</code>```

Try it online!

Previous 51-byte version:

```<code>i$$cuuu/%_ucuuu*@cuuuu/%_ucuuuu*@cuu/%_ucuu*ocOocOo
</code>```

Try it online!

Body:
UGL, <s>51</s> <s>31</s> <s>25</s> 24 bytes

icu$l_u^^/%_u^*ocO$dddd:

Try it online!

Previous 25-byte version:

iRcu$l_u$r^/%_u*ocO$dddd:

Try it online!

Previous 31-byte version:

iRcuuulu$cuuuuuu%-r^/%_u*oddcO:

Try it online!

Previous 51-byte version:

i$$cuuu/%_ucuuu*@cuuuu/%_ucuuuu*@cuu/%_ucuu*ocOocOo

Try it online!


答:
JavaScript (ES6), 26 bytes

Interestingly porting either @KevinLau's Ruby answer or @xnor's Python answer results in the same length:

```<code>n=>[2,3,4].map(d=>n+d-n%d)
n=>[n+2&-2,n+3-n%3,n+4&-4]
</code>```

I have a slight preference for the port of the Ruby answer as it works up to 253-3 while the port of the Python answer only works up to 231-5.

Body:
Give credit to whom credit is due.

Objective Given an integer N > 0, out the smallest integers A, B, and C so that:

All of A, B, and C are strictly greater than N;

2 divides A;

3 divides B;

and 4 divides C.

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

Test cases

```<code>N => A, B, C
1 => 2, 3, 4
4 => 6, 6, 8
43 => 44, 45, 44
123 => 124, 126, 124
420 => 422, 423, 424
31415 => 31416, 31416, 31416
1081177 => 1081178, 1081179, 1081180
</code>```

Body:
JavaScript (ES6), 26 bytes

Interestingly porting either @KevinLau's Ruby answer or @xnor's Python answer results in the same length:

n=>[2,3,4].map(d=>n+d-n%d)
n=>[n+2&-2,n+3-n%3,n+4&-4]

I have a slight preference for the port of the Ruby answer as it works up to 253-3 while the port of the Python answer only works up to 231-5.


Body:
J, 18 bytes

2 3 4&([*>:@<.@%~)

Try it online!


问:
Count how many characters are in the program's source
Write a program that counts and prints the number of characters in it's own source code to standard output.

The number must be generated from counting the characters.

This Ruby solution would not be allowed:

```<code>puts 6
</code>```

because it is not calculated. Spaces, tabs, new lines, etc should be counted.

The program must be smallest possible in any programming language.

答:
Dyalog APL, 8 bytes

The niladic function f:

```<code>≢∊⎕NR'f'
</code>```

Notice that this prints 10 because APL counts (and stores) the function header (name + newline). However, PPCG practice is not to count this header. The entire program can be displayed with

```<code>      ↑⎕NR'f'
</code>```

Giving:

```<code>f
≢∊⎕NR'f'
</code>```

⎕NR'f' the Nested (i.e. a list of character lists) Representation of f

∊ ϵnlist (flatten)

≢ tally

Body:
Dyalog APL, 8 bytes

The niladic function f:

≢∊⎕NR'f'

Notice that this prints 10 because APL counts (and stores) the function header (name + newline). However, PPCG practice is not to count this header. The entire program can be displayed with

      ↑⎕NR'f'

Giving:

f
≢∊⎕NR'f'

⎕NR'f' the Nested (i.e. a list of character lists) Representation of f

∊ ϵnlist (flatten)

≢ tally


答:
Golfscript, 22 bytes

```<code>~..2/)2*@3/)3*@4/)4*]`
</code>```

Try it online!

Alternative 22-byte solution:

```<code>~..[4 2 3]{.@@/)*@}/]`
</code>```

Try it online!

Body:
Golfscript, 22 bytes

~..2/)2*@3/)3*@4/)4*]`

Try it online!

Alternative 22-byte solution:

~..[4 2 3]{.@@/)*@}/]`

Try it online!


Body:
Mathematica 28 bytes

f@n_:=n-n~Mod~#+#&/@{2,3,4}

f[1]
f[4]
f[43]
f[123]
f[420]
f[31415]
f[1081177]

{2, 3, 4}

{6, 6, 8}

{44, 45, 44}

{124, 126, 124}

{422, 423, 424}

{31416, 31416, 31416}

{1081178, 1081179, 1081180}

The general case produces a general answer:

f[r]

{2 + r - Mod[r, 2], 3 + r - Mod[r, 3], 4 + r - Mod[r, 4]}


答:
Mathematica, 21 bytes

```<code>Ceiling[#+1,{2,3,4}]&
</code>```

This is an unnamed function which takes a single integer as input and returns a list of the multiples.

The Ceiling function takes an optional second parameter which tells it to round up to the next multiple of the given number. Thankfully, it also automatically threads over its second argument such that we can give it a list of values and in turn we'll get rounded up multiples for all of those.

Body:
Mathematica, 21 bytes

Ceiling[#+1,{2,3,4}]&

This is an unnamed function which takes a single integer as input and returns a list of the multiples.

The Ceiling function takes an optional second parameter which tells it to round up to the next multiple of the given number. Thankfully, it also automatically threads over its second argument such that we can give it a list of values and in turn we'll get rounded up multiples for all of those.


答:
Octave, 20 bytes

```<code>@(n)n-mod(n,d=2:4)+d
</code>```

Examples:

```<code>octave:60> f(123)
ans =

   124   126   124

octave:61> f(1081177)
ans =

   1081178   1081179   1081180

octave:62> f(420)
ans =

   422   423   424
</code>```

Worth noting that we can do this up to 9 without adding any extra bytes:

```<code>@(n)n-mod(n,d=2:9)+d
</code>```

Output (2520 is the smallest positive integer evenly divisible by all the single digit numbers):

```<code>octave:83> f(2520)
ans =

   2522   2523   2524   2525   2526   2527   2528   2529
</code>```

Body:
Octave, 20 bytes

@(n)n-mod(n,d=2:4)+d

Examples:

octave:60> f(123)
ans =

   124   126   124

octave:61> f(1081177)
ans =

   1081178   1081179   1081180

octave:62> f(420)
ans =

   422   423   424

Worth noting that we can do this up to 9 without adding any extra bytes:

@(n)n-mod(n,d=2:9)+d

Output (2520 is the smallest positive integer evenly divisible by all the single digit numbers):

octave:83> f(2520)
ans =

   2522   2523   2524   2525   2526   2527   2528   2529


问:
Last non-zero digit of n!
Given an integer 1 ≤ N ≤ 1,000,000 as input, output the last non-zero digit of N!, where ! is the factorial (the product of all numbers from 1 to N, inclusive).  This is OEIS sequence A008904.

Your program needs finish within 10 seconds on a reasonable machine for any valid input.

Test Cases

```<code>1 => 1
2 => 2
3 => 6
4 => 4
5 => 2
6 => 2
7 => 4
8 => 2
9 => 8
10 => 8
100 => 4
1000 => 2
10000 => 8
100000 => 6
1000000 => 4
</code>```

This is a code-golf so the shortest code in bytes wins!

答:
C, <s>150</s> <s>140</s> 135 bytes

r,d;f(k,x){r=x<5?3:f(k+1,x/5);return(d=x%5)?r*"33436"[d]*(1<<d*k%4)%5:r;}main(int c,char**v){c=atoi(*++v);printf("%d",c<2?1:2*f(0,c));}
```
<p>This is the version for ASCII systems; replace the string <code>33436</code> with <code>11214</code> for an EBCDIC system, or with <code>\1\1\2\1\4</code> for a portable program.</p>
<p>C solutions are a bit hampered by the requirement to provide a full program; however, this does answer the question fully.</p>
<p>Try it online (requires Javascript):</p>
<ul>
<li>1000000 only</li>
<li>Loop with all testcases</li>
</ul>
<h2>Explanation</h2>
<p>It's based on the algorithm outlined in Least Significant Non-Zero Digit of n!, turned around so that we recurse in to find the highest power of five, and do the calculation on the way out.  The tables of constants were too big, so I reduced them by finding a relationship between the previous residue <code>r</code>, the current digit <code>d</code> and the recursion depth <code>k</code>:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: right;">r</th>
<th style="text-align: center;">d=0</th>
<th style="text-align: center;">d=1</th>
<th style="text-align: center;">d=2</th>
<th style="text-align: center;">d=3</th>
<th style="text-align: center;">d=4</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: right;">0</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">3×2^k</td>
<td style="text-align: center;">1×2^2k</td>
<td style="text-align: center;">3×2^3k</td>
<td style="text-align: center;">2</td>
</tr>
<tr>
<td style="text-align: right;">1</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">1×2^k</td>
<td style="text-align: center;">2×2^2k</td>
<td style="text-align: center;">1×2^3k</td>
<td style="text-align: center;">4</td>
</tr>
<tr>
<td style="text-align: right;">2</td>
<td style="text-align: center;">2</td>
<td style="text-align: center;">2×2^k</td>
<td style="text-align: center;">4×2^2k</td>
<td style="text-align: center;">2×2^3k</td>
<td style="text-align: center;">3</td>
</tr>
<tr>
<td style="text-align: right;">3</td>
<td style="text-align: center;">3</td>
<td style="text-align: center;">3×2^k</td>
<td style="text-align: center;">3×2^2k</td>
<td style="text-align: center;">3×2^3k</td>
<td style="text-align: center;">2</td>
</tr>
<tr>
<td style="text-align: right;">4</td>
<td style="text-align: center;">4</td>
<td style="text-align: center;">4×2^k</td>
<td style="text-align: center;">4×2^2k</td>
<td style="text-align: center;">4×2^3k</td>
<td style="text-align: center;">1</td>
</tr>
</tbody>
</table>
</div>
<p>For <code>r>0</code>, this resolves to a constant times <code>r</code> times <code>2^dk</code> (mod 5); the constants are in <code>a[]</code> below (inlined in the golfed code).  We also observe that <code>(2^4)%5</code> is 1, so we can reduce the exponent to avoid overflowing the range of <code>int</code>.</p>
<pre class="lang-c prettyprint-override"><code>const int a[] = { 1, 1, 2, 1, 4 };
int f(int k, int x)
{
    int r = x<5 ? 3 : f(k+1,x/5); /* residue - from recursing to higher-order quinary digits */
    int d = x%5;
    if (!d)
        return r;
    return r * a[d] * (1 << d*k%4) % 5;
}

int main(int c, char **v)
{
    c = atoi(*++v);
    printf("%d",
           c<2
           ? 1                  /* special-case 0 & 1 */
           : 2*f(0,c));         /* otherwise, it's 2 times r */
}
</code>```

Tests:

```<code>$ for i in 100 1000 10000 100000; do echo $i: `./694 $i`; done
100: 4
1000: 2
10000: 8
100000: 6
1000000: 4
</code>```

Performance is respectable, too.  Here's a maximum input for a system with 32-bit int:

```<code>$ time ./694 2147483647
8
real    0m0.001s
user    0m0.000s
sys     0m0.000s
</code>```

I got the same timings with a maximal 64-bit int, too.

Title: Last non-zero digit of n!

Body:
C, <s>150</s> <s>140</s> 135 bytes

r,d;f(k,x){r=x<5?3:f(k+1,x/5);return(d=x%5)?r*"33436"[d]*(1<<d*k%4)%5:r;}main(int c,char**v){c=atoi(*++v);printf("%d",c<2?1:2*f(0,c));}

This is the version for ASCII systems; replace the string 33436 with 11214 for an EBCDIC system, or with \1\1\2\1\4 for a portable program.

C solutions are a bit hampered by the requirement to provide a full program; however, this does answer the question fully.

Try it online (requires Javascript):

1000000 only

Loop with all testcases

Explanation

It's based on the algorithm outlined in Least Significant Non-Zero Digit of n!, turned around so that we recurse in to find the highest power of five, and do the calculation on the way out.  The tables of constants were too big, so I reduced them by finding a relationship between the previous residue r, the current digit d and the recursion depth k:

r
d=0
d=1
d=2
d=3
d=4

0
0
3×2^k
1×2^2k
3×2^3k
2

1
1
1×2^k
2×2^2k
1×2^3k
4

2
2
2×2^k
4×2^2k
2×2^3k
3

3
3
3×2^k
3×2^2k
3×2^3k
2

4
4
4×2^k
4×2^2k
4×2^3k
1

For r>0, this resolves to a constant times r times 2^dk (mod 5); the constants are in a[] below (inlined in the golfed code).  We also observe that (2^4)%5 is 1, so we can reduce the exponent to avoid overflowing the range of int.

const int a[] = { 1, 1, 2, 1, 4 };
int f(int k, int x)
{
    int r = x<5 ? 3 : f(k+1,x/5); /* residue - from recursing to higher-order quinary digits */
    int d = x%5;
    if (!d)
        return r;
    return r * a[d] * (1 << d*k%4) % 5;
}

int main(int c, char **v)
{
    c = atoi(*++v);
    printf("%d",
           c<2
           ? 1                  /* special-case 0 & 1 */
           : 2*f(0,c));         /* otherwise, it's 2 times r */
}

Tests:

$ for i in 100 1000 10000 100000; do echo $i: `./694 $i`; done
100: 4
1000: 2
10000: 8
100000: 6
1000000: 4

Performance is respectable, too.  Here's a maximum input for a system with 32-bit int:

$ time ./694 2147483647
8
real    0m0.001s
user    0m0.000s
sys     0m0.000s

I got the same timings with a maximal 64-bit int, too.


问:
Discrete Convolution or Polynomial Multiplication
Given two non empty lists of integers, your submission should calculate and return the discrete convolution of the two. Interestingly, if you consider the list elements as coefficients of polynomials, the convolution of the two lists represents the coefficients of the product of the two polynomials.

Definition

Given the lists A=[a(0),a(1),a(2),...,a(n)] and B=[b(0),b(1),b(2),...,b(m)] (setting a(k)=0 for k<0 and k>n and b(k)=0 for k<0 and k>m) then the convolution of the two is defined as A*B=[c(0),c(1),...,c(m+n)] where c(k) = sum [ a(x)*b(y) for all integers x y such that x+y=k]

Rules

Any convenient input and output formatting for your language is allowed.

Built-ins for convolution, creating convolution matrices, correlation and polynomial multiplication are not allowed.

Examples

```<code>[1,1]*[1] = [1,1]
[1,1]*[1,1] = [1,2,1]
[1,1]*[1,2,1] = [1,3,3,1]
[1,1]*[1,3,3,1] = [1,4,6,4,1]
[1,1]*[1,4,6,4,1] = [1,5,10,10,5,1]

[1,-1]*[1,1,1,1,1] = [1,0,0,0,0,-1]
[80085,1337]*[-24319,406] = [-1947587115,7,542822]
</code>```

答:
MATL, 19 bytes

```<code>PiYdt"TF2&YStpsw]xx
</code>```

Try it online!

Explanation

This builds a block-diagonal matrix with the two inputs, reversing the first. For example, with inputs [1 4 3 5], [1 3 2] the matrix is

```<code>[ 5 3 4 1 0 0 0
  0 0 0 0 1 3 2 ]
</code>```

Each entry of the convolution is obtained by shifting the first row one position to the right, computing the product of each column, and summing all results.

In principle, the shifting should be done padding with zeros from the left. Equivalently, circular shifting can be used, because the matrix contains zeros at the appropriate entries.

For example, the first result is obtained from the shifted matrix

```<code>[ 0 5 3 4 1 0 0
  0 0 0 0 1 3 2 ]
</code>```

and is thus 1*1 == 1. The second is obtained from

```<code>[ 0 0 5 3 4 1 0
  0 0 0 0 1 3 2 ]
</code>```

and is thus 4*1+1*3 == 7, etc. This must be done m+n-1 times, where m and n are the input lengths. The code uses a loop with m+n iterations (which saves some bytes) and discards the last result.

```<code>P          % Take first input (numeric vactor) implicitly and reverse it
i          % Take second input (numeric vactor)
Yd         % Build diagonal matrix with the two vectors
t          % Duplicate
"          % For each column of the matrix
  TF2&YS   %   Circularly shift first row 1 step to the right
  t        %   Duplicate
  p        %   Product of each column
  s        %   Sum all those products
  w        %   Swap top two elements in stack. The shifted matrix is left on top
]          % End for
xx         % Delete matrix and last result. Implicitly display
</code>```

Body:
MATL, 19 bytes

PiYdt"TF2&YStpsw]xx

Try it online!

Explanation

This builds a block-diagonal matrix with the two inputs, reversing the first. For example, with inputs [1 4 3 5], [1 3 2] the matrix is

[ 5 3 4 1 0 0 0
  0 0 0 0 1 3 2 ]

Each entry of the convolution is obtained by shifting the first row one position to the right, computing the product of each column, and summing all results.

In principle, the shifting should be done padding with zeros from the left. Equivalently, circular shifting can be used, because the matrix contains zeros at the appropriate entries.

For example, the first result is obtained from the shifted matrix

[ 0 5 3 4 1 0 0
  0 0 0 0 1 3 2 ]

and is thus 1*1 == 1. The second is obtained from

[ 0 0 5 3 4 1 0
  0 0 0 0 1 3 2 ]

and is thus 4*1+1*3 == 7, etc. This must be done m+n-1 times, where m and n are the input lengths. The code uses a loop with m+n iterations (which saves some bytes) and discards the last result.

P          % Take first input (numeric vactor) implicitly and reverse it
i          % Take second input (numeric vactor)
Yd         % Build diagonal matrix with the two vectors
t          % Duplicate
"          % For each column of the matrix
  TF2&YS   %   Circularly shift first row 1 step to the right
  t        %   Duplicate
  p        %   Product of each column
  s        %   Sum all those products
  w        %   Swap top two elements in stack. The shifted matrix is left on top
]          % End for
xx         % Delete matrix and last result. Implicitly display


问:
Fibonacci products
You can decompose a number greater than 0 as a unique sum of positive Fibonacci numbers. In this question we do this by repeatedly subtracting the largest possible positive Fibonacci number. E.g.:

```<code>1 = 1
2 = 2
3 = 3
4 = 3 + 1
12 = 8 + 3 + 1
13 = 13
100 = 89 + 8 + 3
</code>```

Now, I call a Fibonacci product the same lists as above, but with the addition replaced by multiplication. For example, \$f(100) = 89 \times 8 \times 3 = 2136\$.

Write a program or function that given a positive integer n returns the Fibonacci product of that number.

Testcases:

```<code>1: 1
2: 2
3: 3
4: 3
5: 5
6: 5
7: 10
8: 8
9: 8
42: 272
1000: 12831
12345: 138481852236
</code>```

答:
PHP, 119 bytes

The code (wrapped on two lines for readability):

```<code>for($o=$c=1;$c<=$n=$argv[1];$f[++$k]=$c,$a=$b,$b=$c,$c+=$a);
for($i=$k;$i;$i--)for(;$n>=$d=$f[$i];$n-=$d,$o*=$d);echo$o;
</code>```

The first line computes in $f the Fibonacci numbers smaller than $n (the argument provided in the command line). The second line computes the Fibonacci factors (by subtraction) and multiplies them to compute the product in $o.

Prepend the code with <?php  (technically not part of the program), put it in a file (fibonacci-factors.php) then run it as:

```<code>$ php -d error_reporting=0 fibonacci-factors.php 100
# The output:
2136
</code>```

Or run it using php -d error_reporting=0 -r '... code here ...' 100.

The ungolfed code and the test suite can be found on Github.

Title: Fibonacci products

Body:
PHP, 119 bytes

The code (wrapped on two lines for readability):

for($o=$c=1;$c<=$n=$argv[1];$f[++$k]=$c,$a=$b,$b=$c,$c+=$a);
for($i=$k;$i;$i--)for(;$n>=$d=$f[$i];$n-=$d,$o*=$d);echo$o;

The first line computes in $f the Fibonacci numbers smaller than $n (the argument provided in the command line). The second line computes the Fibonacci factors (by subtraction) and multiplies them to compute the product in $o.

Prepend the code with <?php  (technically not part of the program), put it in a file (fibonacci-factors.php) then run it as:

$ php -d error_reporting=0 fibonacci-factors.php 100
# The output:
2136

Or run it using php -d error_reporting=0 -r '... code here ...' 100.

The ungolfed code and the test suite can be found on Github.


答:
Ruby, 83 bytes

Almost directly pulled out of an answer I did earlier regarding expanding roots into a polynomial.

```<code>->a,b{q=a.map{|c|r=b.map{|e|e*c};b=[0]+b;r}
q.pop.zip(*q).map{|e|(e-[p]).reduce:+}}
</code>```

Title: Discrete Convolution or Polynomial Multiplication

Body:
Given two non empty lists of integers, your submission should calculate and return the discrete convolution of the two. Interestingly, if you consider the list elements as coefficients of polynomials, the convolution of the two lists represents the coefficients of the product of the two polynomials.

Definition

Given the lists A=[a(0),a(1),a(2),...,a(n)] and B=[b(0),b(1),b(2),...,b(m)] (setting a(k)=0 for k<0 and k>n and b(k)=0 for k<0 and k>m) then the convolution of the two is defined as A*B=[c(0),c(1),...,c(m+n)] where c(k) = sum [ a(x)*b(y) for all integers x y such that x+y=k]

Rules

Any convenient input and output formatting for your language is allowed.

Built-ins for convolution, creating convolution matrices, correlation and polynomial multiplication are not allowed.

Examples

```<code>[1,1]*[1] = [1,1]
[1,1]*[1,1] = [1,2,1]
[1,1]*[1,2,1] = [1,3,3,1]
[1,1]*[1,3,3,1] = [1,4,6,4,1]
[1,1]*[1,4,6,4,1] = [1,5,10,10,5,1]

[1,-1]*[1,1,1,1,1] = [1,0,0,0,0,-1]
[80085,1337]*[-24319,406] = [-1947587115,7,542822]
</code>```

Body:
Ruby, 83 bytes

Almost directly pulled out of an answer I did earlier regarding expanding roots into a polynomial.

->a,b{q=a.map{|c|r=b.map{|e|e*c};b=[0]+b;r}
q.pop.zip(*q).map{|e|(e-[p]).reduce:+}}


Title: Golf Text into DNA

Body:
Text to DNA golf

Challenge

Convert input into a DNA output.

Algorithm

Convert text into ASCII code points (e.g. codegolf -> [99, 111, 100, 101, 103, 111, 108, 102])

String the ASCII codes together (e.g. 99111100101103111108102)

Convert to binary (e.g. 10100111111001101001011010001000011001101011011110000110010111111011000000110)

Pad 0s onto the end to make an even number of characters (e.g. 101001111110011010010110100010000110011010110111100001100101111110110000001100)

Replace 00 with A, 01 with C, 10 with G, and 11 with T (e.g. GGCTTGCGGCCGGAGACGCGGTCTGACGCCTTGTAAATA)

Output

Test Cases

```<code>codegolf > GGCTTGCGGCCGGAGACGCGGTCTGACGCCTTGTAAATA
ppcg > GGCTAATTGTCGCACTT
} > TTGG (padding)
</code>```

Specifications

This is code-golf

Your program must accept spaces in input.

Your program must work for codegolf.

Body:
Perl, <s>155</s> <s>148</s> 137 + 1 (-p flag) = 138 bytes

#!perl -p
s/./ord$&/sge;while($_){/.$/;$s=$&%2 .$s;$t=$v="";$t.=$v+$_/2|0,$v=$_%2*5
for/./g;s/^0// if$_=$t}$_=$s;s/(.)(.)?/([A,C],[G,T])[$1][$2]/ge

Test it on Ideone.


答:
Haskell, <s>55</s> 49 bytes

(a:b)#c=zipWith(+)(0:b#c)$map(a*)c++[]#b
_#c=0<$c
```

Defines an operator #.

Body:
Haskell, <s>55</s> 49 bytes

(a:b)#c=zipWith(+)(0:b#c)$map(a*)c++[]#b
_#c=0<$c

Defines an operator #.


答:
Haskell, 27 bytes

```<code>f n=[div n d*d+d|d<-[2..4]]
</code>```

Body:
Haskell, 27 bytes

f n=[div n d*d+d|d<-[2..4]]


答:
05AB1E, <s>18</s> 17 bytes

Code

```<code>0Ev²¹g<Å0«y*NFÁ}+
</code>```

Explanation

The theory behind:

To find the convolution, let's take the example [1, 2, 3], [3, 4, 5]. We position the values of the first array upside down and vertically, like this:

```<code>3
2
1
</code>```

Now, we place the second array like a ladder and multiply it by :

```<code>3 ×       [3  4  5]
2 ×    [3  4  5]
1 × [3  4  5]
</code>```

Resulting into:

```<code>        9   12   15
    6   8   10
3   4   5
</code>```

Then, we add them up, resulting into:

```<code>        9   12   15
    6   8   10
3   4   5

3   10  22  22   15
</code>```

So, the convolution is [3, 10, 22, 22, 15].

The code itself:

We are going to do this step by step using the [1, 2, 3], [3, 4, 5] as the test case.

```<code>0Ev²¹g<Å0«y*NFÁ}+
</code>```

We first push 0 and then we Evaluate the first input array. We map over each element using v.

So, for each element, we push the second array with ² and then the length of the first array using ¹g and decrease this by 1 (with <). We convert this into a list of zeros with (length 1st array - 1) zeros, using Å0 and append this to our list. Our stack now looks like this for the first item in the input list:

```<code>[3, 4, 5, 0, 0]
</code>```

We multiply this array with the current item, done with y*. After that, we push N, which indicates the index of the current item (zero-indexed) and rotate the array that many times to the right using FÁ}. Finally, we add this to our initial value (0). So, what basically is done is the following:

```<code>[0, 0, 9, 12, 15] +
[0, 6, 8, 10, 0] +
[3, 4, 5, 0, 0] =

[3, 10, 22, 22, 15]
</code>```

Which is then implicitly printed. Uses CP-1252 encoding. Try it online!.

Body:
05AB1E, <s>18</s> 17 bytes

Code

0Ev²¹g<Å0«y*NFÁ}+

Explanation

The theory behind:

To find the convolution, let's take the example [1, 2, 3], [3, 4, 5]. We position the values of the first array upside down and vertically, like this:

3
2
1

Now, we place the second array like a ladder and multiply it by :

3 ×       [3  4  5]
2 ×    [3  4  5]
1 × [3  4  5]

Resulting into:

        9   12   15
    6   8   10
3   4   5

Then, we add them up, resulting into:

        9   12   15
    6   8   10
3   4   5

3   10  22  22   15

So, the convolution is [3, 10, 22, 22, 15].

The code itself:

We are going to do this step by step using the [1, 2, 3], [3, 4, 5] as the test case.

0Ev²¹g<Å0«y*NFÁ}+

We first push 0 and then we Evaluate the first input array. We map over each element using v.

So, for each element, we push the second array with ² and then the length of the first array using ¹g and decrease this by 1 (with <). We convert this into a list of zeros with (length 1st array - 1) zeros, using Å0 and append this to our list. Our stack now looks like this for the first item in the input list:

[3, 4, 5, 0, 0]

We multiply this array with the current item, done with y*. After that, we push N, which indicates the index of the current item (zero-indexed) and rotate the array that many times to the right using FÁ}. Finally, we add this to our initial value (0). So, what basically is done is the following:

[0, 0, 9, 12, 15] +
[0, 6, 8, 10, 0] +
[3, 4, 5, 0, 0] =

[3, 10, 22, 22, 15]

Which is then implicitly printed. Uses CP-1252 encoding. Try it online!.