答:
Haskell, 36 bytes

f s|s==reverse s=s|h:t<-s=h:f t++[h]
```
<p>More readably:</p>
<pre class="lang-haskell prettyprint-override"><code>f s
 |s==reverse s = s
 |(h:t)<-s     = h:(f t)++[h]
</code>```

If the string is a palindrome, return it. Otherwise, sandwich the first letter around the recursive result for the tail of the string.

The string s is split into h:t in the second guard, obviating a filler 1>0 for this case. This is shorter than doing s@(h:t) for the input.

Title: Palindromizing the strings

Body:
Introduction

For the ones who don't know, a palindrome is when a string is equal to the string backwards (with exception to interpunction, spaces, etc.). An example of a palindrome is:

```<code>abcdcba
</code>```

If you reverse this, you will end up with:

```<code>abcdcba
</code>```

Which is the same. Therefore, we call this a palindrome. To palindromize things, let's take a look at an example of a string:

```<code>adbcb
</code>```

This is not a palindrome. To palindromize this, we need to merge the reversed string into the initial string at the right of the initial string, leaving both versions intact. The shorter, the better.

The first thing we can try is the following:

```<code>adbcb
bcbda
^^ ^^
</code>```

Not all characters match, so this is not the right position for the reversed string. We go one step to the right:

```<code>adbcb
 bcbda
 ^^^^
</code>```

This also doesn't match all characters. We go another step to the right:

```<code>adbcb
  bcbda
</code>```

This time, all characters match. We can merge both string leaving the intact. The final result is:

```<code>adbcbda
</code>```

This is the palindromized string.

The Task

Given a string (with at least one character) containing only lowercase letters (or uppercase, if that fits better), output the palindromized string.

Test cases

```<code>Input     Output

abcb      abcba
hello     hellolleh
bonobo    bonobonob
radar     radar
hex       hexeh
</code>```

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

Body:
Haskell, 36 bytes

f s|s==reverse s=s|h:t<-s=h:f t++[h]

More readably:

f s
 |s==reverse s = s
 |(h:t)<-s     = h:(f t)++[h]

If the string is a palindrome, return it. Otherwise, sandwich the first letter around the recursive result for the tail of the string.

The string s is split into h:t in the second guard, obviating a filler 1>0 for this case. This is shorter than doing s@(h:t) for the input.


问:
Palindromizing the strings

Introduction

For the ones who don't know, a palindrome is when a string is equal to the string backwards (with exception to interpunction, spaces, etc.). An example of a palindrome is:

```<code>abcdcba
</code>```

If you reverse this, you will end up with:

```<code>abcdcba
</code>```

Which is the same. Therefore, we call this a palindrome. To palindromize things, let's take a look at an example of a string:

```<code>adbcb
</code>```

This is not a palindrome. To palindromize this, we need to merge the reversed string into the initial string at the right of the initial string, leaving both versions intact. The shorter, the better.

The first thing we can try is the following:

```<code>adbcb
bcbda
^^ ^^
</code>```

Not all characters match, so this is not the right position for the reversed string. We go one step to the right:

```<code>adbcb
 bcbda
 ^^^^
</code>```

This also doesn't match all characters. We go another step to the right:

```<code>adbcb
  bcbda
</code>```

This time, all characters match. We can merge both string leaving the intact. The final result is:

```<code>adbcbda
</code>```

This is the palindromized string.

The Task

Given a string (with at least one character) containing only lowercase letters (or uppercase, if that fits better), output the palindromized string.

Test cases

```<code>Input     Output

abcb      abcba
hello     hellolleh
bonobo    bonobonob
radar     radar
hex       hexeh
</code>```

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

答:
Octave, <s>78</s> 75 bytes

Saved 3 bytes thanks to Eʀɪᴋ ᴛʜᴇ Gᴏʟғᴇʀ!

```<code>function p=L(s)d=0;while~all(diag(s==rot90(s),d++))p=[s fliplr(s(1:d))];end
</code>```

ideone still fails for named functions, but here is a test run of the code as a program.

ContentLicense: CC BY-SA 3.0

Title: Palindromizing the strings

Body:
Octave, <s>78</s> 75 bytes

Saved 3 bytes thanks to Eʀɪᴋ ᴛʜᴇ Gᴏʟғᴇʀ!

function p=L(s)d=0;while~all(diag(s==rot90(s),d++))p=[s fliplr(s(1:d))];end

ideone still fails for named functions, but here is a test run of the code as a program.


问:
Draw A Sierpinski Triangle
The Sierpinsky Triangle is a fractal created by taking a triangle, decreasing the height and width by 1/2, creating 3 copies of the resulting triangle, and place them such each triangle touches the other two on a corner.  This process is repeated over and over again with the resulting triangles to produce the Sierpinski triangle, as illustrated below.

Write a program to generate a Sierpinski triangle.  You can use any method you want to generate the pattern, either by drawing the actual triangles, or by using a random algorithm to generate the picture.  You can draw in pixels, ascii art, or whatever you want, so long as the output looks similar to the last picture shown above.  Fewest characters wins.

Title: Draw A Sierpinski Triangle

Body:
J (18 characters)

' *'{~(,,.~)^:9 ,1

Result

*
**
* *
****
*   *
**  **
* * * *
********
*       *
**      **
* *     * *
****    ****
*   *   *   *
**  **  **  **
* * * * * * * *
****************
*               *
**              **
* *             * *
****            ****
*   *           *   *
**  **          **  **
* * * *         * * * *
********        ********
*       *       *       *
**      **      **      **
* *     * *     * *     * *
****    ****    ****    ****
*   *   *   *   *   *   *   *
**  **  **  **  **  **  **  **
* * * * * * * * * * * * * * * *
********************************


问:
Approximating a special case of the Riemann Theta function
This challenge is to write fast code that can perform a computationally difficult infinite sum.

Input

An n by n matrix P with integer entries that are smaller than 100 in absolute value. When testing I am happy to provide input to your code in any sensible format your code wants. The default will be one line per row of the matrix, space separated and provided on standard input.

P will be positive definite which implies it will always be symmetric.  Other than that you don't really need to know what positive definite means to answer the challenge.  It does however mean that there will actually be an answer to the sum defined below.

You do however need to know what a matrix-vector product is.

Output

Your code should compute the infinite sum:

to within plus or minus 0.0001 of the correct answer.  Here Z is the set of integers and so Z^n is all possible vectors with n integer elements and e is the famous mathematical constant that approximately equals 2.71828.  Note that the value in the exponent is simply a number. See below for an explicit example.

How does this relate to the Riemann Theta function?

In the notation of this paper on approximating the Riemann Theta function we are trying to compute .  Our problem is a special case for at least two reasons.

We set the initial parameter called z in the linked paper to 0.

We create the matrix P in such a way that the minimum size of an eigenvalue is 1. (See below for how the matrix is created.)

Examples

```<code>P = [[ 5.,  2.,  0.,  0.],
     [ 2.,  5.,  2., -2.],
     [ 0.,  2.,  5.,  0.],
     [ 0., -2.,  0.,  5.]]

Output: 1.07551411208
</code>```

In more detail, let us see just one term in the sum for this P.  Take for example just one term in the sum:

and  x^T P x = 30.  Notice thate^(-30) is about 10^(-14) and so is unlikely to be important for getting the correct answer up to the given tolerance. Recall that the infinite sum will actually use every possible vector of length 4 where the elements are integers.  I just picked one to give an explicit example.

```<code>P = [[ 5.,  2.,  2.,  2.],
     [ 2.,  5.,  4.,  4.],
     [ 2.,  4.,  5.,  4.],
     [ 2.,  4.,  4.,  5.]]

Output = 1.91841190706

P = [[ 6., -3.,  3., -3.,  3.],
     [-3.,  6., -5.,  5., -5.],
     [ 3., -5.,  6., -5.,  5.],
     [-3.,  5., -5.,  6., -5.],
     [ 3., -5.,  5., -5.,  6.]]

Output = 2.87091065342

P = [[6., -1., -3., 1., 3., -1., -3., 1., 3.],
     [-1., 6., -1., -5., 1., 5., -1., -5., 1.],
     [-3., -1., 6., 1., -5., -1., 5., 1., -5.],
     [1., -5., 1., 6., -1., -5., 1., 5., -1.],
     [3., 1., -5., -1., 6., 1., -5., -1., 5.],
     [-1., 5., -1., -5., 1., 6., -1., -5., 1.],
     [-3., -1., 5., 1., -5., -1., 6., 1., -5.],
     [1., -5., 1., 5., -1., -5., 1., 6., -1.],
     [3., 1., -5., -1., 5., 1., -5., -1., 6.]]

Output: 8.1443647932

P = [[ 7.,  2.,  0.,  0.,  6.,  2.,  0.,  0.,  6.],
     [ 2.,  7.,  0.,  0.,  2.,  6.,  0.,  0.,  2.],
     [ 0.,  0.,  7., -2.,  0.,  0.,  6., -2.,  0.],
     [ 0.,  0., -2.,  7.,  0.,  0., -2.,  6.,  0.],
     [ 6.,  2.,  0.,  0.,  7.,  2.,  0.,  0.,  6.],
     [ 2.,  6.,  0.,  0.,  2.,  7.,  0.,  0.,  2.],
     [ 0.,  0.,  6., -2.,  0.,  0.,  7., -2.,  0.],
     [ 0.,  0., -2.,  6.,  0.,  0., -2.,  7.,  0.],
     [ 6.,  2.,  0.,  0.,  6.,  2.,  0.,  0.,  7.]]

Output = 3.80639191181
</code>```

Score

I will test your code on randomly chosen matrices P of increasing size.

Your score is simply the largest n for which I get a correct answer in less than 30 seconds when averaged over 5 runs with randomly chosen matrices P of that size.

What about a tie?

If there is a tie, the winner will be the one whose code runs fastest averaged over 5 runs. In the event that those times are also equal, the winner is the first answer.

How will the random input be created?

Let M be a random m by n matrix with m<=n and entries which are -1 or 1.  In Python/numpy M = np.random.choice([0,1], size = (m,n))*2-1 . In practice I will set m to be about n/2.

Let P be the identity matrix + M^T M. In Python/numpy P =np.identity(n)+np.dot(M.T,M). We are now guaranteed that P is positive definite and the entries are in a suitable range.

Note that this means that all eigenvalues of P are at least 1, making the problem potentially easier than the general problem of approximating the Riemann Theta function.

Languages and libraries

You can use any language or library you like. However, for the purposes of scoring I will run your code on my machine so please provide clear instructions for how to run it on Ubuntu.

My Machine The timings will be run on my machine. This is a standard Ubuntu install on an 8GB AMD FX-8350 Eight-Core Processor.  This also means I need to be able to run your code.

Leading answers

n = 47 in C++ by Ton Hospel

n = 8 in Python by Maltysen

答:
Python 3

12 secs n=8 on my computer, ubuntu 4 core.

Really naive, have no clue what I'm doing.

from itertools import product
from math import e

P = [[ 6., -3.,  3., -3.,  3.],
     [-3.,  6., -5.,  5., -5.],
     [ 3., -5.,  6., -5.,  5.],
     [-3.,  5., -5.,  6., -5.],
     [ 3., -5.,  5., -5.,  6.]]

N = 2

n = [1]

while e** -n[-1] > 0.0001:
    n = []
    for x in product(list(range(-N, N+1)), repeat = len(P)):
        n.append(sum(k[0] * k[1] for k in zip([sum(j[0] * j[1] for j in zip(i, x)) for i in P], x)))
    N += 1

print(sum(e** -i for i in n))
```

This will keep on increasing the range of Z that it uses until it gets a good enough answer. I wrote my own matrix multiplication, prolly should use numpy.

ContentLicense: CC BY-SA 4.0

Body:
Python 3

12 secs n=8 on my computer, ubuntu 4 core.

Really naive, have no clue what I'm doing.

from itertools import product
from math import e

P = [[ 6., -3.,  3., -3.,  3.],
     [-3.,  6., -5.,  5., -5.],
     [ 3., -5.,  6., -5.,  5.],
     [-3.,  5., -5.,  6., -5.],
     [ 3., -5.,  5., -5.,  6.]]

N = 2

n = [1]

while e** -n[-1] > 0.0001:
    n = []
    for x in product(list(range(-N, N+1)), repeat = len(P)):
        n.append(sum(k[0] * k[1] for k in zip([sum(j[0] * j[1] for j in zip(i, x)) for i in P], x)))
    N += 1

print(sum(e** -i for i in n))

This will keep on increasing the range of Z that it uses until it gets a good enough answer. I wrote my own matrix multiplication, prolly should use numpy.


问:
Write a narcissist program!
A narcissist program is simple.  It is related to a quine.

If the input is equal to it's source code, it prints a truthy value, if not it prints a falsy one.  That is it.

Rules:

It can't read it's own file.

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

Hash functions are not allowed.  This trivializes it into just string matching.

The submission may be a function.

An example would be:

Code:

```<code>someprogramhere
</code>```

Input:

```<code>someprogramhere
</code>```

Output:

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

Or input:

```<code>a
</code>```

Output:

```<code>0
</code>```

Your code most certainly won't be someprogramhere, but you get the idea.

Go code.

答:
JavaScript ES6, 14 bytes

```<code>$=_=>_==`$=`+$
</code>```

Simple modification of the traditional "bling quine".

Title: Write a narcissist program!

Body:
JavaScript ES6, 14 bytes

$=_=>_==`$=`+$

Simple modification of the traditional "bling quine".


问:
Which is better - Emacs or Vim? (Google fight)
Greetings, noble code golfers. Today you will resolve the most ancient and distinguished of debates - Emacs or Vim?

Your challenge is to take two search terms as input, and output which of those terms has the most Google search results. (This is obviously completely fair. What do you mean, biased?)

Here are some example inputs and outputs:

Input: emacs and vim

Output: vim (totally not creating any flamewars in the comments)

Input: google and microsoft

Output: google

Input: code golf stack exchange and code review stack exchange

Output: code golf stack exchange (yeah!)

And here are some edge cases just for fun (and for testing your solutions):

Input: About 1,000,000 results and About 100,000 results

Output: About 100,000 results

Input: This will autocotrect and Another testcase

Output: Another testcase (if you don't consider autocorrecting, then the first one will win)

For the following test cases, you must remove the # signs in the search terms first, since they rely on the term having a specific amount of results and posting the term here would ruin that.

Input: Thissear#chter#mhasno#results and Another testcase

Output: Another testcase (just a test for zero results)

Input: "These exact wo#rds do#n't exi#st# on the Internet" and Another testcase

Output: Another testcase (testing "s)

Input: Abo#ut 1,65#2,85#3,2#86 re#sults and Another testcase

Output: Another testcase (this one is tricky - the above search term has one result)

Input: "Abo#ut 4#8,234,8#75,14#7 res#ults" and Another testcase

Output: Another testcase (also tricky - no results, so it displays the search term)

You don't need to handle the corner-case of "quoted" searches returning "No results, showing results without quotes instead" because that would just be too complicated. You don't need to handle inputs with the same number of results either.

This is code-golf, so the shortest code in bytes will win!

答:
Racket, <s>360</s> 337 bytes

```<code>#lang racket(require net/url net/uri-codec)(λ(t)(cddr(sort(map list t(map(lambda(a)(string->number(string-replace(list-ref(string-split(car(regexp-match#px"s\">About [\\d,]+ res"(call/input-url(string->url(string-append"http://google.com/search?nfpr=1&q="(uri-encode a)))(curry get-pure-port)port->string)))" ")1)",""")))))#:key cdr <)))
</code>```

0.o

There's a reason they call it Lost In a Sea of Parentheses.

Ungolfed:

```<code>#lang racket
(require net/url)
(require net/uri-codec)

(define (open-url term)
  (call/input-url
   (string->url (string-append "http://" term))
   (curry get-pure-port #:redirections 5)
   port->string))

(define (get-result term)
  (string->number
   (string-replace
    (list-ref
     (string-split
      (car (regexp-match #px"s\">About [\\d,]+ results" (open-url (string-append "google.com/search?nfpr=1&q=" (uri-encode term)))))
      " ")
     1)
    "," "")))

(define (zip a b) (map list a b))

(define (google-fite terms) (cddr (sort (zip terms (map get-result terms))) #:key cdr <))
</code>```

Body:
Racket, <s>360</s> 337 bytes

#lang racket(require net/url net/uri-codec)(λ(t)(cddr(sort(map list t(map(lambda(a)(string->number(string-replace(list-ref(string-split(car(regexp-match#px"s\">About [\\d,]+ res"(call/input-url(string->url(string-append"http://google.com/search?nfpr=1&q="(uri-encode a)))(curry get-pure-port)port->string)))" ")1)",""")))))#:key cdr <)))

0.o

There's a reason they call it Lost In a Sea of Parentheses.

Ungolfed:

#lang racket
(require net/url)
(require net/uri-codec)

(define (open-url term)
  (call/input-url
   (string->url (string-append "http://" term))
   (curry get-pure-port #:redirections 5)
   port->string))

(define (get-result term)
  (string->number
   (string-replace
    (list-ref
     (string-split
      (car (regexp-match #px"s\">About [\\d,]+ results" (open-url (string-append "google.com/search?nfpr=1&q=" (uri-encode term)))))
      " ")
     1)
    "," "")))

(define (zip a b) (map list a b))

(define (google-fite terms) (cddr (sort (zip terms (map get-result terms))) #:key cdr <))


问:
Highest score on the field

Introduction

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

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

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

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

```<code>11
111
0010
111

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

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

```<code>   011123
    010

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

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

```<code>       01
    01234

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

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

The Task

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

Test cases

Test case 1:

```<code>Input:
1

Output:
1
</code>```

Test case 2:

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

Output:
2
</code>```

Test case 3:

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

Output:
69
</code>```

Test case 4:

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

Output:
3
</code>```

答:
MATL, <s>54</s> <s>51</s> 49 bytes

```<code>n:"G~1@(2Y6Z+leG45>1e*5M@)*]vtz:"otY*g]G48-X:*sX>
</code>```

Input is a 2D char array in MATL(AB) format, with ; as row separator. The inputs in the example and in the test cases are respectively:

```<code>['11-011123';'111-010--';'0010---01';'111-01234']
['1']
['1-1-1-1';'-1-1-1-';'2-1-1-1';'-1-1-1-']
['12-45-';'4-65-9';'87-654';'12-487';'45----';'684764']
['111-12';'------';'21--10']
</code>```

Try it online!

Explanation

This works by building an adjacency matrix of the graph defined by the relation "being connected". As an example, consider the 3×4 field

```<code>52-4
15-8
3-72
</code>```

Entries in a 2D array are easily described in MATL using (column-major) linear indexing. In the 3×4 case, the linear index of each entry is given as

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

The adjacency matrix is built in steps using matrix multiplication. In the first step, immediate neighbours are considered. For example, the point indexed 3 is neighbour of itself and of that with index 2. It's not a neighbour of 6 because that point doesn't contain a number according to the field. In this example the adjacency matrix of the relation  "immediate-neighbour" is the 12×12 matrix L given as

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

(It can seen that column 3 has value 1 at rows 2 and 3.) This matrix is always symmetric and its diagonal has value 1 for points that don't contain -.

The next step would be the adjacency matrix of the relation "connected with at most one point in between". To obtain it, it suffices to multiply L by itself and set nonzero entries to 1. In general, the adjacency matrix of the relation "connected by some path", M, is obtained by raising L to an exponent (in matrix sense) that represents the maximum possible path length. An upper bound of the maximum path length is the number of nonzero entries in L.

Computing the matrix power directly may cause overflow, because large numbers quickly occur. So it's better to gradually multiply by the same matrix, converting nonzero entries into 1 after each step to prevent large numbers from building up.

Column i of M represents the points that are connected (by any path) with point i. Now, the level field can be reduced to a column vector c in linear order, where each entry contains the corresponding number or an undefined value for -. So in this case c would be

```<code>5
1
3
2
5
-
-
-
7
4
8
2
</code>```

Mutiplying each column of M by c element-wise and computing the sum of each column gives, for each point i, the total score of the area point i belongs to. An area is defined by all points that are mutually connected. Note that many columns will give the same result; namely, columns i and j will give the same sum if points i and j are connected (belong to the same area). The final result is the maximum of those sums.

```<code>        % Implicitly take input: 2D char array
n:      % Range [1,...,N], where N is number of entries in the input
"       % For loop. Each iteration builds a row of matrix L
  G     %   Push input again
  ~     %   Logical negate: transform into matrix of zeros
  1     %   Push 1, to be written into a matrix entry
  @     %   Iteration index. Ranges from 1 to N
  (     %   Write that 1 into the N-th entry (linear order)
  2Y6   %   Push array [0 1 0; 1 1 1; 0 1 0]: mask of immediate neighbours
  Z+    %   Convolve and keep same-size result
  le    %   Linearize into row array
  G45>  %   Array of same size as the input that contains 1 for numbers, 0 for '-'
  1e    %   Linearize into row array
  *     %   Multiply element-wise
  5M    %   Push last array again: 1 for numbers, 0 for '-'
  @)    %   Get 0 or 1 value of that array corresponding to current iteration
  *     %   Multiply. This is to give a row of zeros for non-numbers
]       % End. We have all rows of L in the stack
v       % Concatenate all rows into a matrix: L.
tz:     % Duplicate. Range [1,...,K], where K is the number of nonzeros in L
"       % For loop. Repear K times. This loop computes the 0/1 matrix power
  o     %   Convert matrix entries to double
  tY*   %   Duplicate and matrix-multiply
  g     %   Convert to logical values, that is, nonzero values become 1
]       % End. We have matrix M
G48-    % Convert input chars to the corresponding numbers by subtractig 48
X:      % Linearize into column array. This is vector c
*       % Element-wise multiplication with broadcast (implicit repetition)
s       % Sum of each column. Gives a row array
X>      % Maximum of that row array
        % Implicitly display
</code>```

Title: Highest score on the field

Body:
MATL, <s>54</s> <s>51</s> 49 bytes

n:"G~1@(2Y6Z+leG45>1e*5M@)*]vtz:"otY*g]G48-X:*sX>

Input is a 2D char array in MATL(AB) format, with ; as row separator. The inputs in the example and in the test cases are respectively:

['11-011123';'111-010--';'0010---01';'111-01234']
['1']
['1-1-1-1';'-1-1-1-';'2-1-1-1';'-1-1-1-']
['12-45-';'4-65-9';'87-654';'12-487';'45----';'684764']
['111-12';'------';'21--10']

Try it online!

Explanation

This works by building an adjacency matrix of the graph defined by the relation "being connected". As an example, consider the 3×4 field

52-4
15-8
3-72

Entries in a 2D array are easily described in MATL using (column-major) linear indexing. In the 3×4 case, the linear index of each entry is given as

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

The adjacency matrix is built in steps using matrix multiplication. In the first step, immediate neighbours are considered. For example, the point indexed 3 is neighbour of itself and of that with index 2. It's not a neighbour of 6 because that point doesn't contain a number according to the field. In this example the adjacency matrix of the relation  "immediate-neighbour" is the 12×12 matrix L given as

1 1 0 1 0 0 0 0 0 0 0 0
1 1 1 0 1 0 0 0 0 0 0 0
0 1 1 0 0 0 0 0 0 0 0 0
1 0 0 1 1 0 0 0 0 0 0 0
0 1 0 1 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 0 0 1
0 0 0 0 0 0 0 0 0 1 1 0
0 0 0 0 0 0 0 0 0 1 1 1
0 0 0 0 0 0 0 0 1 0 1 1

(It can seen that column 3 has value 1 at rows 2 and 3.) This matrix is always symmetric and its diagonal has value 1 for points that don't contain -.

The next step would be the adjacency matrix of the relation "connected with at most one point in between". To obtain it, it suffices to multiply L by itself and set nonzero entries to 1. In general, the adjacency matrix of the relation "connected by some path", M, is obtained by raising L to an exponent (in matrix sense) that represents the maximum possible path length. An upper bound of the maximum path length is the number of nonzero entries in L.

Computing the matrix power directly may cause overflow, because large numbers quickly occur. So it's better to gradually multiply by the same matrix, converting nonzero entries into 1 after each step to prevent large numbers from building up.

Column i of M represents the points that are connected (by any path) with point i. Now, the level field can be reduced to a column vector c in linear order, where each entry contains the corresponding number or an undefined value for -. So in this case c would be

5
1
3
2
5
-
-
-
7
4
8
2

Mutiplying each column of M by c element-wise and computing the sum of each column gives, for each point i, the total score of the area point i belongs to. An area is defined by all points that are mutually connected. Note that many columns will give the same result; namely, columns i and j will give the same sum if points i and j are connected (belong to the same area). The final result is the maximum of those sums.

        % Implicitly take input: 2D char array
n:      % Range [1,...,N], where N is number of entries in the input
"       % For loop. Each iteration builds a row of matrix L
  G     %   Push input again
  ~     %   Logical negate: transform into matrix of zeros
  1     %   Push 1, to be written into a matrix entry
  @     %   Iteration index. Ranges from 1 to N
  (     %   Write that 1 into the N-th entry (linear order)
  2Y6   %   Push array [0 1 0; 1 1 1; 0 1 0]: mask of immediate neighbours
  Z+    %   Convolve and keep same-size result
  le    %   Linearize into row array
  G45>  %   Array of same size as the input that contains 1 for numbers, 0 for '-'
  1e    %   Linearize into row array
  *     %   Multiply element-wise
  5M    %   Push last array again: 1 for numbers, 0 for '-'
  @)    %   Get 0 or 1 value of that array corresponding to current iteration
  *     %   Multiply. This is to give a row of zeros for non-numbers
]       % End. We have all rows of L in the stack
v       % Concatenate all rows into a matrix: L.
tz:     % Duplicate. Range [1,...,K], where K is the number of nonzeros in L
"       % For loop. Repear K times. This loop computes the 0/1 matrix power
  o     %   Convert matrix entries to double
  tY*   %   Duplicate and matrix-multiply
  g     %   Convert to logical values, that is, nonzero values become 1
]       % End. We have matrix M
G48-    % Convert input chars to the corresponding numbers by subtractig 48
X:      % Linearize into column array. This is vector c
*       % Element-wise multiplication with broadcast (implicit repetition)
s       % Sum of each column. Gives a row array
X>      % Maximum of that row array
        % Implicitly display


问:
Write the shortest self-identifying program (a quine variant)
Write a program that will generate a "true" output iff the input matches the source code of the program, and which generates a "false" output iff the input does not match the source code of the program.

This problem can be described as being related to quines, as the program must be able to somehow compute its own source code in the process.

This is code golf: standard rules apply.  Your program must not access any special files, such as the file of its own source code.

Edit: If you so choose, true/false can be replaced with True/False or 1/0.

Example

If the source code of your program is bhiofvewoibh46948732));:/)4, then here is what your program must do:

Input (Stdin)

```<code>bhiofvewoibh46948732));:/)4
</code>```

Output (Stdout)

```<code>true
</code>```

Input

```<code>(Anything other than your source code)
</code>```

Output

```<code>false
</code>```

答:
JavaScript ES6, <s>16</s> 14 bytes

```<code>$=_=>_==`$=`+$
</code>```

Minus two bytes thanks to Neil.

31 bytes if we must take input via prompt.

```<code>$=_=>prompt()==`$=${$};$()`;$()
</code>```

38 bytes if we must output via alert.

```<code>$=_=>alert(prompt()==`$=${$};$()`);$()
</code>```

This is the proper way to do it, as Optimizer's answer does not accept the entire source code.

Body:
JavaScript ES6, <s>16</s> 14 bytes

$=_=>_==`$=`+$

Minus two bytes thanks to Neil.

31 bytes if we must take input via prompt.

$=_=>prompt()==`$=${$};$()`;$()

38 bytes if we must output via alert.

$=_=>alert(prompt()==`$=${$};$()`);$()

This is the proper way to do it, as Optimizer's answer does not accept the entire source code.


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

```<code>ṫỤfU$Ḣœ^;U
</code>```

Try it online!

How it works

```<code>ṫỤfU$Ḣœ^;U  Main link. Argument: s (string)

 Ụ          Yield all indices of s, sorted by their corr. character values.
ṫ           Tail; for each index n, remove all characters before thr nth.
            This yields the list of suffixes of s, sorted by their first character,
            then (in descending order) by length.
    $       Combine the two links to the left into a chain:
   U        Upend; reverse all suffixes.
  f         Filter; only keep suffixes that are also reversed suffixes.
            This gives the list of all palindromic suffixes. Since all of them
            start with the same letter, they are sorted by length.
     Ḣ      Head; select the first, longest palindromic suffix.
      œ^    Multiset symmetric difference; chop the selected suffix from s.
         U  Upend; yield s, reversed.
        ;   Concatenate the results to the left and to the right.
</code>```

Title: Palindromizing the strings

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

ṫỤfU$Ḣœ^;U

Try it online!

How it works

ṫỤfU$Ḣœ^;U  Main link. Argument: s (string)

 Ụ          Yield all indices of s, sorted by their corr. character values.
ṫ           Tail; for each index n, remove all characters before thr nth.
            This yields the list of suffixes of s, sorted by their first character,
            then (in descending order) by length.
    $       Combine the two links to the left into a chain:
   U        Upend; reverse all suffixes.
  f         Filter; only keep suffixes that are also reversed suffixes.
            This gives the list of all palindromic suffixes. Since all of them
            start with the same letter, they are sorted by length.
     Ḣ      Head; select the first, longest palindromic suffix.
      œ^    Multiset symmetric difference; chop the selected suffix from s.
         U  Upend; yield s, reversed.
        ;   Concatenate the results to the left and to the right.


问:
Answer to life, the universe, and everything

Task

Given a String as input, your task is to output 42 only if the input String happens to be exactly the following :

```<code>abbcccddddeeeeeffffffggggggghhhhhhhhiiiiiiiiijjjjjjjjjjkkkkkkkkkkkllllllllllllmmmmmmmmmmmmmnnnnnnnnnnnnnnoooooooooooooooppppppppppppppppqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrrsssssssssssssssssssttttttttttttttttttttuuuuuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzzzzzzzzzz
</code>```

It may output any other value, produce an error or not output at all, if the input does not equal the aforementioned String.

Winning Criterion

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

答:
Reng v.3.2, 88 bytes

(Noncompeting, postdates question.)

```<code>2#y2#z"a"1Ø         Ø3r1\
:1+>y1-?!v$z1+:#y#zRzeq!^
   ^  :y#<
i sve(*?v)
?~n>$ 2.>076**
</code>```

This is one heckuvan answer.

Initial

```<code>2#y2#z"a"1Ø
</code>```

Stores 2 to y (the temporary counter) and z (the overall counter), and initiates the stack with "a" then goes to the next line.

Loop

```<code>:1+>y1-?!v$z1+:#y#zRzeq!^
   ^  :y#<
</code>```

First, :1+ duplicates the previously made run of characters and increments it to work with the next one. Then...

Generating N copies of a number

```<code>   >y1-?!v
   ^  :y#<
</code>```

This loops until y == 0. Once y is zero, we exit the loop. Otherwise, we put y - 1 back into y and duplicate the character being worked with it.

Breaking out of this loop

```          $z1+:#y#zRzeq!^

```

This drops y from the conditional and increments and duplicates z, which is then put into y and z. Then, if R (26 + 1) is z, we go to the next part. Otherwise, the loop continues again.

Transition

```                    Ø3r1\
                        ^
```

This goes out of the loop, pushes 1 (our equality counter), reverses the stack, and goes to the third line.

Final

```<code>i sve(*?v)
?~n>$ 2.>076**
</code>```

i sve(*?v) loops until (a) there is no input or (b) the equality counter is 0. In the first case, the first v is met, and we drop the -1 bit, skip over the >0 bit (2.), and output 42 (6*7*equality), skipping ~ with a conditional. Otherwise, the second v is encountered, and a zero is pushed before the 76**, so this makes it zero. The conditional activates the ~ (exit program) command because the TOS is falsey, and thus no output is given.

Body:
Reng v.3.2, 88 bytes

(Noncompeting, postdates question.)

2#y2#z"a"1Ø         Ø3r1\
:1+>y1-?!v$z1+:#y#zRzeq!^
   ^  :y#<
i sve(*?v)
?~n>$ 2.>076**

This is one heckuvan answer.

Initial

2#y2#z"a"1Ø

Stores 2 to y (the temporary counter) and z (the overall counter), and initiates the stack with "a" then goes to the next line.

Loop

:1+>y1-?!v$z1+:#y#zRzeq!^
   ^  :y#<

First, :1+ duplicates the previously made run of characters and increments it to work with the next one. Then...

Generating N copies of a number

   >y1-?!v
   ^  :y#<

This loops until y == 0. Once y is zero, we exit the loop. Otherwise, we put y - 1 back into y and duplicate the character being worked with it.

Breaking out of this loop

          $z1+:#y#zRzeq!^

This drops y from the conditional and increments and duplicates z, which is then put into y and z. Then, if R (26 + 1) is z, we go to the next part. Otherwise, the loop continues again.

Transition

                    Ø3r1\
                        ^

This goes out of the loop, pushes 1 (our equality counter), reverses the stack, and goes to the third line.

Final

i sve(*?v)
?~n>$ 2.>076**

i sve(*?v) loops until (a) there is no input or (b) the equality counter is 0. In the first case, the first v is met, and we drop the -1 bit, skip over the >0 bit (2.), and output 42 (6*7*equality), skipping ~ with a conditional. Otherwise, the second v is encountered, and a zero is pushed before the 76**, so this makes it zero. The conditional activates the ~ (exit program) command because the TOS is falsey, and thus no output is given.


问:
Tips for golfing in Racket / Scheme
What general tips do you have for golfing in Racket / Scheme? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Racket / Scheme (e.g. "remove comments" is not an answer).

I'm aware Scheme and Racket (formerly PLT Scheme) are technically different languages but are quite similar in many ways and much code (I suspect) will run mostly as intended in either. If your tip only applies to one of the aforementioned languages, note as such.

答:
In Racket, λ and lambda are synonymous keywords for constructing anonymous functions, but λ is 2 bytes where lambda is 6.

In Scheme, there's no such keyword λ and you're stuck with lambda.

Title: Tips for golfing in Racket / Scheme


问:
Unlocking the Secrets to a 1-Dimensional Labyrinth

Background

You awake to find yourself lost in a one dimensional labyrinth! A mystical genie (or something) appears and explains that the exit lies in front of you, but that between you and the exit is a series of challenges. As you wander forward you realize that all of the so-called challenges are merely locked doors. You first see a door with a tee-shaped key-hole, and having no such key yourself, retrace your steps, looking for a key with a T shape.

Frustrated, you find an alphabet soup of keys on the ground, none of which match the door you've come across. By some stroke of genius (or idiocy), you decide that the lower-case t-shaped key might be able to fit in the slot if you jam it in there hard enough. As you approach the door with the lower-case t key in hand, the T hole glows green and the door dissolves in front of you.

One down, many more to go...

Challenge

The goal of this challenge is to mark how many steps it takes you to exit the labyrinth.

The input of this challenge is the labyrinth: one string containing only  characters [A-Za-z^$ ].
Glossary:

^ -- The start space. The input will contain exactly one ^.

$ -- The exit (freedom!). The input will contain exactly one $.

[A-Z] -- Capital letters signify doors. You can only go through this door if you have already collected the requisite key.

[a-z] -- Lower case letters signify keys. You collect these keys by walking onto the space that contains the key.

There will be at most one of each capital letter in the input. This means the total number of doors will be between 0-26 inclusive.

Every locked door [A-Z] will have exactly one corresponding lower case key [a-z]. There may be any number of spaces ( ) in the input.

All of the doors will be to the right of the start, and to the left of the exit. Thus there will be no superfluous doors. All inputs will be solvable.

The output for this challenge will be a number, the number of steps it took to exit the labyrinth.

Algorithm

Your methodical approach to exiting this wretched place is as follows:

Start at the beginning (^) and move forward (right) collecting any keys you come across.

When you come across a door, if you have the correct key, you proceed forward onto the door. If you don't have the correct key, you walk backwards (left) collecting keys you come across until you find the key for the most recent door that you couldn't open.

Once you collect the key for the current troublesome door, you turn back to the right and proceed onward.

Repeat this process until you step on to the exit ($).

Experienced golfers will understand that your code doesn't have to implement this specific algorithm as long as it outputs the same result as if you had run this algorithm.

Counting

Each time you step from one square onto another square, that counts as one step. Turning 180º incurs no additional step. You cannot step forward onto a door without the requisite key. You must step onto a key to pick it up, and must step onto the exit to win. After your first move, the start space (^) behaves just like any other regular space.

Examples

In these examples I've left the spaces as underscores for human-readability.

Input is _a_^_A__$__. The output is 11. You take 1 step forward, notice that you have no key for the A door, and then about face. You walk backward until you occupy the space containing the a (3 steps backward, now 4 total). You then walk forward until you occupy the space containing the exit (7 steps forward, 11 total).

Input is b__j^__a_AJB_$. The output is 41 You make two separate trips to the back of the labyrinth, one to get the j key, and the next one to get the b key.

Input is __m__t_^__x_T_MX_$____. The output is 44. You won't make any extra trip to get the x key, as you picked it up on your way from the start to door T.

Input is g_t_^G_T$. The output is 12. You cannot move onto the G space without a key, and immediately about-face. You're lucky enough to pick up the t key on the way to the g key, and thus open both doors on your way to freedom.

Input is _^_____$. The output is 6. That was easy.

I/O Guidelines and Winning Criterion

Standard I/O rules apply. This is a code-golf challenge.

答:
C#, 309 bytes

```<code>class P{static void Main(string[]a){string m=Console.ReadLine(),k="";var f=true;char b,c=b=' ';int j=m.IndexOf('^'),t=0;for(;m[j]!='$';j+=f?1:-1){c=m[j];if(char.IsUpper(c)){if(k.IndexOf(char.ToLower(c))<0){f=!f;b=c;t--;}}if(char.IsLower(c)){k+=c;if(char.ToUpper(c)==b){f=!f;t--;}}t++;}Console.WriteLine(t);}}
</code>```

Ungolfed version:

```<code>    class P
{
    static void Main(string[] a)
    {
        string m = Console.ReadLine(), k = "";
        var f = true;
        char b, c = b = ' ';
        int j = m.IndexOf('^'), t = 0;
        for (; m[j] != '$'; j += f ? 1 : -1)
        {
            c = m[j];
            if (char.IsUpper(c))
            {
                if (k.IndexOf(char.ToLower(c)) < 0)
                {
                    f = !f; b = c; t--;
                }
            }

            if (char.IsLower(c))
            {
                k += c;
                if (char.ToUpper(c) == b) { f = !f; t--; }
            }

            t++;
        }
        Console.WriteLine(t);
        Console.ReadKey();

    }
}
</code>```

Nothing fancy here, just iterate through the string and change direction based on the character and whether the key is contained in a keys string.

m = the maze string

k = the keys string

f = the direction (true is forward in the maze)

b = the key to search for when backtracking

c = placeholder for m[j] to save some bytes due to frequent use

j = the char index of the string to look at

t = the count

Still relatively new to golfing so if you see somewhere I can slim it down, let me know!

Body:
C#, 309 bytes

class P{static void Main(string[]a){string m=Console.ReadLine(),k="";var f=true;char b,c=b=' ';int j=m.IndexOf('^'),t=0;for(;m[j]!='$';j+=f?1:-1){c=m[j];if(char.IsUpper(c)){if(k.IndexOf(char.ToLower(c))<0){f=!f;b=c;t--;}}if(char.IsLower(c)){k+=c;if(char.ToUpper(c)==b){f=!f;t--;}}t++;}Console.WriteLine(t);}}

Ungolfed version:

    class P
{
    static void Main(string[] a)
    {
        string m = Console.ReadLine(), k = "";
        var f = true;
        char b, c = b = ' ';
        int j = m.IndexOf('^'), t = 0;
        for (; m[j] != '$'; j += f ? 1 : -1)
        {
            c = m[j];
            if (char.IsUpper(c))
            {
                if (k.IndexOf(char.ToLower(c)) < 0)
                {
                    f = !f; b = c; t--;
                }
            }

            if (char.IsLower(c))
            {
                k += c;
                if (char.ToUpper(c) == b) { f = !f; t--; }
            }

            t++;
        }
        Console.WriteLine(t);
        Console.ReadKey();

    }
}

Nothing fancy here, just iterate through the string and change direction based on the character and whether the key is contained in a keys string.

m = the maze string

k = the keys string

f = the direction (true is forward in the maze)

b = the key to search for when backtracking

c = placeholder for m[j] to save some bytes due to frequent use

j = the char index of the string to look at

t = the count

Still relatively new to golfing so if you see somewhere I can slim it down, let me know!


答:
Haskell, <s>45</s> 51 bytes

```<code>f x|x==zip[1..]['a'..'z']>>=uncurry replicate->"42"
</code>```

zip [1..] ['a'..'z'] produces the list [(1,'a'), (2,'b'), ...].

uncurry replicate has the type (Int, a) -> [a], and uncurry replicate (n, v) produces a list of n copies of v.

>>= applies uncurry replicate to the zipped list, and concatenates the results.

Finally, that string compared to the argument and returns "42" if it is equal, or crashes.

(edited b/c I'm dumb and didn't notice the return requirement)

Title: Answer to life, the universe, and everything

Body:
Task

Given a String as input, your task is to output 42 only if the input String happens to be exactly the following :

```<code>abbcccddddeeeeeffffffggggggghhhhhhhhiiiiiiiiijjjjjjjjjjkkkkkkkkkkkllllllllllllmmmmmmmmmmmmmnnnnnnnnnnnnnnoooooooooooooooppppppppppppppppqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrrsssssssssssssssssssttttttttttttttttttttuuuuuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzzzzzzzzzz
</code>```

It may output any other value, produce an error or not output at all, if the input does not equal the aforementioned String.

Winning Criterion

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

Body:
Haskell, <s>45</s> 51 bytes

f x|x==zip[1..]['a'..'z']>>=uncurry replicate->"42"

zip [1..] ['a'..'z'] produces the list [(1,'a'), (2,'b'), ...].

uncurry replicate has the type (Int, a) -> [a], and uncurry replicate (n, v) produces a list of n copies of v.

>>= applies uncurry replicate to the zipped list, and concatenates the results.

Finally, that string compared to the argument and returns "42" if it is equal, or crashes.

(edited b/c I'm dumb and didn't notice the return requirement)


答:
Ruby, 44 bytes

This answer is based on xnor's Python and Haskell solutions.

```<code>f=->s{s.reverse==s ?s:s[0]+f[s[1..-1]]+s[0]}
</code>```

Title: Palindromizing the strings

Body:
Ruby, 44 bytes

This answer is based on xnor's Python and Haskell solutions.

f=->s{s.reverse==s ?s:s[0]+f[s[1..-1]]+s[0]}


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

Definition

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

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

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

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

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

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

Rules

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

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

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

Examples

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

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

答:
Jolf, 13 bytes

```<code>*jmauΜm)jd/1H
</code>```

Kudos to the MATL answer for the algorithm! Try it here, or test them all at once. (Outputs [key,out] in an array.)

Explanation

```<code>*jmauΜm)jd/1H
*j             input times
      m)j         p.f. of input
     Μ   d/1H      mapped to inverse
    u            sum of
  ma            abs of
</code>```

Title: The Arithmetic Derivative

Body:
Jolf, 13 bytes

*jmauΜm)jd/1H

Kudos to the MATL answer for the algorithm! Try it here, or test them all at once. (Outputs [key,out] in an array.)

Explanation

*jmauΜm)jd/1H
*j             input times
      m)j         p.f. of input
     Μ   d/1H      mapped to inverse
    u            sum of
  ma            abs of


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

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

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

Edit: Your quine must be a proper quine.

答:
RETURN, 94 bytes

```<code>"34¤¤,,,,,,,,,,,,,% 'H'e'l'l'o',' 'w'o'r'l'd'!'"34¤¤,,,,,,,,,,,,,% 'H'e'l'l'o',' 'w'o'r'l'd'!'
</code>```

Reversed:

```<code>'!'d'l'r'o'w' ','o'l'l'e'H' %,,,,,,,,,,,,,¤¤43"'!'d'l'r'o'w' ','o'l'l'e'H' %,,,,,,,,,,,,,¤¤43"
</code>```

Try it here.

Outputs to STDOUT. Until I find a better quine framework, this will have to do for now.

Explanation

```<code>"34¤¤,,,,,,,,,,,,,% 'H'e'l'l'o',' 'w'o'r'l'd'!'"
</code>```

This contains the quine string. In reverse, this is pushed to the stack but not outputted.

```<code>34¤¤,,,,,,,,,,,,,
</code>```

This pushes a quote char to the stack and outputs the result twice until there is nothing left to output. In reverse, this will print the charcodes already on the stack.

```<code>% 'H'e'l'l'o',' 'w'o'r'l'd'!'
</code>```

This one pops the top stack item (in reverse, this would pop a space char) and pushes a series of charcodes to the stack (in reverse, these charcodes would later be printed by the series of ,'s).

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

Body:
RETURN, 94 bytes

"34¤¤,,,,,,,,,,,,,% 'H'e'l'l'o',' 'w'o'r'l'd'!'"34¤¤,,,,,,,,,,,,,% 'H'e'l'l'o',' 'w'o'r'l'd'!'

Reversed:

'!'d'l'r'o'w' ','o'l'l'e'H' %,,,,,,,,,,,,,¤¤43"'!'d'l'r'o'w' ','o'l'l'e'H' %,,,,,,,,,,,,,¤¤43"

Try it here.

Outputs to STDOUT. Until I find a better quine framework, this will have to do for now.

Explanation

"34¤¤,,,,,,,,,,,,,% 'H'e'l'l'o',' 'w'o'r'l'd'!'"

This contains the quine string. In reverse, this is pushed to the stack but not outputted.

34¤¤,,,,,,,,,,,,,

This pushes a quote char to the stack and outputs the result twice until there is nothing left to output. In reverse, this will print the charcodes already on the stack.

% 'H'e'l'l'o',' 'w'o'r'l'd'!'

This one pops the top stack item (in reverse, this would pop a space char) and pushes a series of charcodes to the stack (in reverse, these charcodes would later be printed by the series of ,'s).


问:
Are the brackets fully matched?
You must write a program or function that takes a string of brackets and outputs whether or not that string is fully matched. Your program should print a truthy or falsy value, and IO can be in any reasonable format.

Rules and definitions:

For the purpose of this challenge, a "bracket" is any of these characters: ()[]{}<>.

A pair of brackets is considered "matched" if the opening and closing brackets are in the right order and have no characters inside of them, such as

```<code>()
[]{}
</code>```

Or if every subelement inside of it is also matched.

```<code>[()()()()]
{<[]>}
(()())
</code>```

Subelements can also be nested several layers deep.

```<code>[(){<><>[()]}<>()]
<[{((()))}]>
</code>```

A string is considered "Fully matched" if and only if:

Every single character is a bracket,

Each pair of brackets has the correct opening and closing bracket and in the right order, and

Each bracket is matched.

You may assume the input will only contain printable ASCII.

Test IO

Here are some inputs that should return a truthy value:

```<code>()
[](){}<>
(((())))
({[<>]})
[{()<>()}[]]
[([]{})<{[()<()>]}()>{}]
</code>```

And here are some outputs that should return a falsy value:

```<code>(               Has no closing ')'
}{              Wrong order
(<)>            Each pair contains only half of a matched element
(()()foobar)    Contains invalid characters
[({}<>)>        The last bracket should be ']' instead of '>'
(((()))         Has 4 opening brackets, but only 3 closing brackets.
</code>```

As usual, this is code-golf, so standard loopholes apply, and shortest answer in bytes wins.

Title: Are the brackets fully matched?

Body:
Retina, 20 bytes

+`\(\)|\[]|{}|<>

^$

Try it online


问:
Rectangle Detection
Write a program or function that takes in a multiline string of 0's and 1's. No other characters will be in the string and the string will always be rectangular (all lines will have same number of characters), with dimensions as small as 1×1, but otherwise the 0's and 1's may be arranged arbitrarily.

You may assume the string has an optional trailing newline, and if desired you may use any two distinct printable ASCII characters in place of 0 and 1.

Print or return a truthy value if all of the path connected regions of both 0's and 1's in the string are solid rectangles, else output a falsy value.

A path connected region of 0's means that from any one 0 in the region, all the other 0's can be reached by only moving up, down, left and right to other 0's (and not moving diagonally, not moving to any 1, and not moving outside the string bounds). The same idea applies to 1 path connected regions.

A solid rectangle of 0's means the entire area of the rectangle is filled with 0's and no 1's. The same idea applies to 1 solid rectangles.

The shortest code in bytes wins. Tiebreaker is earlier answer.

(Note that the string does not wrap around with toroidal boundary conditions.)

Examples

1) This input string has 3 path connected regions (2 for 0 and 1 for 1). Only the bottom right 00 region is a solid rectangle though, so the output would be falsy.

```<code>0011
0111
0100
</code>```

2) This input string has 4 path connected regions (2 for both 0 and 1). All of them are solid rectangles so the output would be truthy.

```<code>0011
0011
1100
</code>```

3) This input has 2 path connected regions, but only one of them is a solid rectangle, so the output would be falsy.

```<code>00000000
01111110
00000000
</code>```

4) This input has only 1 path connected region and is trivially a solid rectangle, so the output is truthy.

```<code>11111111
11111111
11111111
</code>```

Test Cases

A T just below the input string means truthy, F means falsy.

```<code>0
T

1
T

00
T

01
T

10
T

11
T

0000000
T

1111111
T

011100100100101100110100100100101010100011100101
T

00
11
T

01
10
T

01
11
F

00
01
F

11
11
T

110
100
F

111
000
T

111
101
111
F

101
010
101
T

1101
0010
1101
0010
T

1101
0010
1111
0010
F

0011
0111
0100
F

0011
0011
1100
T

00000000
01111110
00000000
F

11111111
11111111
11111111
T

0000001111
0000001111
T

0000001111
0000011111
F

0000001111
1000001111
F

1000001111
1000001111
T

1110100110101010110100010111011101000101111
1010100100101010100100010101010101100101000
1110100110010010110101010111010101010101011
1010100100101010010101010110010101001101001
1010110110101010110111110101011101000101111
F</code>```

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

```<code>ṣ⁷^2\⁺€FS¬
</code>```

Massive thanks to @Dennis for golfing this one down to half its original size (via undocumented features).

Try it online! Note that the triple quotes are for a multiline string.

Explanation

The basic algorithm is: return true iff every 2x2 subgrid has an even number of 1s (or, equivalently, 0s).

It's clear why an odd number of 1s can't work, since we would have one of the following:

```<code>10  01  00  00  01  10  11  11
00  00  01  10  11  11  10  01
</code>```

Note that the first 4 are rotations of the same thing, and ditto for the last 4. The reflex angle can't be part of a rectangle, hence why it would be invalid.

In other words, all 2x2 subgrids must be one of the following:

```<code>00  00  11  01  10  01  10  11
00  11  00  01  10  10  01  11
</code>```

which, if we look at the boundaries, can be imagined as the following "puzzle pieces":

```<code> ___    ___    ___    ___
|   |  | | |  |   |  | | |
|   |  | | |  |---|  |-|-|
|___|  |_|_|  |___|  |_|_|
</code>```

And try forming a non-rectangle with those puzzle pieces :) (whilst having the ends match up)

The actual implementation is thus:

```<code>ṣ⁷               Split input by newlines to give rows
  ^2\            Taking overlapping sets of 2 rows at a time: accumulate rows by XOR
                 Note that strings cast to integers automatically for bitwise operators
     ⁺€          Repeat the previous link (⁺), on each (€) element in the resulting array
       F         Flatten the array
        S        Sum (effectively reducing by OR)
         ¬       Logical negation of the result
</code>```

For example, for the input

```<code>100
010
000
101
</code>```

we have:

```<code>  ṣ⁷: ["100", "010", "000", "101"]
 ^2\: [[1, 1, 0], [0, 1, 0], [1, 0, 1]]    (e.g. first entry is "100" ^ "010")
^2\€: [[0, 1], [1, 1], [1, 1]]             (e.g. the first entry is [1^1, 1^0] - this
                                            gives the counts of 1s in each subgrid, mod 2)
   F: [0, 1, 1, 1, 1, 1]
   S: 5                                    (this gives the number of invalid 2x2 subgrids,
                                            which is indeed all but the top left)
   ¬: 0
</code>```

Title: Rectangle Detection

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

ṣ⁷^2\⁺€FS¬

Massive thanks to @Dennis for golfing this one down to half its original size (via undocumented features).

Try it online! Note that the triple quotes are for a multiline string.

Explanation

The basic algorithm is: return true iff every 2x2 subgrid has an even number of 1s (or, equivalently, 0s).

It's clear why an odd number of 1s can't work, since we would have one of the following:

10  01  00  00  01  10  11  11
00  00  01  10  11  11  10  01

Note that the first 4 are rotations of the same thing, and ditto for the last 4. The reflex angle can't be part of a rectangle, hence why it would be invalid.

In other words, all 2x2 subgrids must be one of the following:

00  00  11  01  10  01  10  11
00  11  00  01  10  10  01  11

which, if we look at the boundaries, can be imagined as the following "puzzle pieces":

 ___    ___    ___    ___
|   |  | | |  |   |  | | |
|   |  | | |  |---|  |-|-|
|___|  |_|_|  |___|  |_|_|

And try forming a non-rectangle with those puzzle pieces :) (whilst having the ends match up)

The actual implementation is thus:

ṣ⁷               Split input by newlines to give rows
  ^2\            Taking overlapping sets of 2 rows at a time: accumulate rows by XOR
                 Note that strings cast to integers automatically for bitwise operators
     ⁺€          Repeat the previous link (⁺), on each (€) element in the resulting array
       F         Flatten the array
        S        Sum (effectively reducing by OR)
         ¬       Logical negation of the result

For example, for the input

100
010
000
101

we have:

  ṣ⁷: ["100", "010", "000", "101"]
 ^2\: [[1, 1, 0], [0, 1, 0], [1, 0, 1]]    (e.g. first entry is "100" ^ "010")
^2\€: [[0, 1], [1, 1], [1, 1]]             (e.g. the first entry is [1^1, 1^0] - this
                                            gives the counts of 1s in each subgrid, mod 2)
   F: [0, 1, 1, 1, 1, 1]
   S: 5                                    (this gives the number of invalid 2x2 subgrids,
                                            which is indeed all but the top left)
   ¬: 0


答:
Javascript ES6, 54 bytes

```<code>f=_=>_.match(x=/\(\)|\[]|{}|<>/)?f(_.replace(x,'')):!_
</code>```

Uses a recursive replace implementation. Simple enough.

Title: Are the brackets fully matched?

Body:
You must write a program or function that takes a string of brackets and outputs whether or not that string is fully matched. Your program should print a truthy or falsy value, and IO can be in any reasonable format.

Rules and definitions:

For the purpose of this challenge, a "bracket" is any of these characters: ()[]{}<>.

A pair of brackets is considered "matched" if the opening and closing brackets are in the right order and have no characters inside of them, such as

```<code>()
[]{}
</code>```

Or if every subelement inside of it is also matched.

```<code>[()()()()]
{<[]>}
(()())
</code>```

Subelements can also be nested several layers deep.

```<code>[(){<><>[()]}<>()]
<[{((()))}]>
</code>```

A string is considered "Fully matched" if and only if:

Every single character is a bracket,

Each pair of brackets has the correct opening and closing bracket and in the right order, and

Each bracket is matched.

You may assume the input will only contain printable ASCII.

Test IO

Here are some inputs that should return a truthy value:

```<code>()
[](){}<>
(((())))
({[<>]})
[{()<>()}[]]
[([]{})<{[()<()>]}()>{}]
</code>```

And here are some outputs that should return a falsy value:

```<code>(               Has no closing ')'
}{              Wrong order
(<)>            Each pair contains only half of a matched element
(()()foobar)    Contains invalid characters
[({}<>)>        The last bracket should be ']' instead of '>'
(((()))         Has 4 opening brackets, but only 3 closing brackets.
</code>```

As usual, this is code-golf, so standard loopholes apply, and shortest answer in bytes wins.

Body:
Javascript ES6, 54 bytes

f=_=>_.match(x=/\(\)|\[]|{}|<>/)?f(_.replace(x,'')):!_

Uses a recursive replace implementation. Simple enough.


问:
Interpret your lang, but not yourself?
There are many challenges that say "interpret X", where X is a simple language. In my opinion, that is way too boring. To give all the procrastinating people on the internet something interesting to do, you can try to do this challenge:

Challenge

Choose a language $LANG. $LANG can be any turing complete programming language or a turing complete subset of a programming language. Beware that if you omit a feature of your language in $LANG for interpretation, you must not use it for your own program, too, since your submission must be written in $LANG, too.

Write a compiler / interpreter for $LANG written in $LANG. You may use all facilities (including eval and friends) of your language that are available to write this compiler. To make the task more challenging, there is one restriction: You program should be able to interpret / compile all valid programs of $LANG except your interpreter / compiler itself. If it occurs that the program to be interpreted / compiled is your interpreter or compiler itself (regardless of the filename), your program should do something completely unrelated to the functionality of an interpreter or compiler (such as barfing or printing Hello, world!).

To make this task even more complex, your program must not read its own source when compiling or interpreting.

Specifications

This task is code golf. The submission with the least characters that is correct wins. In case of a tie, the solution that was submitted first wins.

Your program / script should read the program to be interpreted from a file. You may hardcode its path and name. When the file is read, you may either compile the file to another file (That must be executable on your system) or run it directly. If $LANG lacks file-reading capabilities, you can choose another way to read in the code that fits $LANG. You may not choose $LANG as a subset of another language but with file-reading capabilites removed.

Usual code-golf rules apply. That is: your personal pet-language that you made up just to solve this challenge is forbidden, if the solution becomes trivial using it (Such as defining a single-char program that exactly implements the solution). Abuse of rules is encouraged.

答:
Javascript ES6, 45 bytes

```<code>$=(_=prompt())=>eval(_==`$=${$};$()`?0:_);$()
</code>```

Still competitive! (thx @Downgoat)

Title: Interpret your lang, but not yourself?

Body:
Javascript ES6, 45 bytes

$=(_=prompt())=>eval(_==`$=${$};$()`?0:_);$()

Still competitive! (thx @Downgoat)


答:
CJam, <s>25</s> <s>24</s> <s>23</s> 21 bytes

Thanks to Sp3000 for saving 2 bytes.

Thanks to jimmy23013 for saving 2 bytes.

```<code>q_,{()<>}a`$2/*{/s}/!
</code>```

Test suite.

Works essentially the same as the other answers: we repeatedly remove (), [], <> and {} from the string and check if we end up with the empty string. To avoid having to check when we're done, we remove the pairs N times where N is the length of the string, which is always sufficient (since each iteration will remove at least two characters, unless we're done). I'm glad to see that this doesn't beat Retina. :) (Although Pyth or Jelly might...)

There's one fun golfing trick here: to get the string ()<>[]{} we use the following:

```<code>{()<>}a`$
</code>```

The, {()<>} is just a block (i.e. a function), which contains the other brackets as code. With a we wrap the block in an array. The ` stringifies that array, which gives "[{()<>}]". Finally, we sort the string with $, which rearranges the brackets to ()<>[]{}.

Title: Are the brackets fully matched?

Body:
CJam, <s>25</s> <s>24</s> <s>23</s> 21 bytes

Thanks to Sp3000 for saving 2 bytes.

Thanks to jimmy23013 for saving 2 bytes.

q_,{()<>}a`$2/*{/s}/!

Test suite.

Works essentially the same as the other answers: we repeatedly remove (), [], <> and {} from the string and check if we end up with the empty string. To avoid having to check when we're done, we remove the pairs N times where N is the length of the string, which is always sufficient (since each iteration will remove at least two characters, unless we're done). I'm glad to see that this doesn't beat Retina. :) (Although Pyth or Jelly might...)

There's one fun golfing trick here: to get the string ()<>[]{} we use the following:

{()<>}a`$

The, {()<>} is just a block (i.e. a function), which contains the other brackets as code. With a we wrap the block in an array. The ` stringifies that array, which gives "[{()<>}]". Finally, we sort the string with $, which rearranges the brackets to ()<>[]{}.


问:
The plus-minus sequence

The plus-minus sequence

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

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

Test cases

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

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

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

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

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

Catalog

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
RETURN, 21 bytes

```<code>[¤.' ,$.'
,¤¤+2ª-F]=F
</code>```

Try it here.

Recursive operator-lambda. Usage:

```<code>[¤.' ,$.'
,¤¤+2ª-F]=F10 2F
</code>```

Explanation

```<code>[                 ]=F  declare function F for recursion
 ¤.' ,$.'␊,            output top 2 stack items along with trailing newline
           ¤¤+2ª-      get plus and minus of top 2 stack items
                 F     recurse!
</code>```

Title: The plus-minus sequence

Body:
RETURN, 21 bytes

[¤.' ,$.'
,¤¤+2ª-F]=F

Try it here.

Recursive operator-lambda. Usage:

[¤.' ,$.'
,¤¤+2ª-F]=F10 2F

Explanation

[                 ]=F  declare function F for recursion
 ¤.' ,$.'␊,            output top 2 stack items along with trailing newline
           ¤¤+2ª-      get plus and minus of top 2 stack items
                 F     recurse!


答:
Pylongolf2, 21 bytes

```<code>con1968701440=?42~¿
</code>```

Explanations:

```<code>con1968701440=?42~¿
c                   read input
 on                 hash it and then convert into integer
   1968701440       push the (aaa.zz) thing (but hashed) into the stack
             =      compare them
              ?     if true,
               42~  output 42
                  ¿ end if statement.
</code>```

That last inverted question mark messed me up by 2 bytes :|

Body:
Pylongolf2, 21 bytes

con1968701440=?42~¿

Explanations:

con1968701440=?42~¿
c                   read input
 on                 hash it and then convert into integer
   1968701440       push the (aaa.zz) thing (but hashed) into the stack
             =      compare them
              ?     if true,
               42~  output 42
                  ¿ end if statement.

That last inverted question mark messed me up by 2 bytes :|


答:
Lua, <s>89</s> 88 Bytes

I beat the Javascript! \o/
Saved 1 byte thanks to @LeakyNun ^^

It's a full program, takes its input as command-line argument.

i=1s=...r=s:reverse()while s:sub(i)~=r:sub(0,#r-i+1)do i=i+1 end print(s..r:sub(#r-i+2))
```

<h2>ungolfed</h2>

<pre class="lang-lua prettyprint-override"><code>i=1                             -- initialise i at 1 as string are 1-indexed in lua
s=...                           -- use s as a shorthand for the first argument
r=s:reverse()                   -- reverse the string s and save it into r
while(s:sub(i)~=r:sub(0,#r-i+1))-- iterate while the last i characters of s
do                              -- aren't equals to the first i characters of r
  i=i+1                         -- increment the number of character to skip
end
print(s..r:sub(#r-i+2))         -- output the merged string
</code>```

Title: Palindromizing the strings

Body:
Introduction

For the ones who don't know, a palindrome is when a string is equal to the string backwards (with exception to interpunction, spaces, etc.). An example of a palindrome is:

```<code>abcdcba
</code>```

If you reverse this, you will end up with:

```<code>abcdcba
</code>```

Which is the same. Therefore, we call this a palindrome. To palindromize things, let's take a look at an example of a string:

```<code>adbcb
</code>```

This is not a palindrome. To palindromize this, we need to merge the reversed string into the initial string at the right of the initial string, leaving both versions intact. The shorter, the better.

The first thing we can try is the following:

```<code>adbcb
bcbda
^^ ^^
</code>```

Not all characters match, so this is not the right position for the reversed string. We go one step to the right:

```<code>adbcb
 bcbda
 ^^^^
</code>```

This also doesn't match all characters. We go another step to the right:

```<code>adbcb
  bcbda
</code>```

This time, all characters match. We can merge both string leaving the intact. The final result is:

```<code>adbcbda
</code>```

This is the palindromized string.

The Task

Given a string (with at least one character) containing only lowercase letters (or uppercase, if that fits better), output the palindromized string.

Test cases

```<code>Input     Output

abcb      abcba
hello     hellolleh
bonobo    bonobonob
radar     radar
hex       hexeh
</code>```

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

Body:
Lua, <s>89</s> 88 Bytes

I beat the Javascript! \o/
Saved 1 byte thanks to @LeakyNun ^^

It's a full program, takes its input as command-line argument.

i=1s=...r=s:reverse()while s:sub(i)~=r:sub(0,#r-i+1)do i=i+1 end print(s..r:sub(#r-i+2))

ungolfed

i=1                             -- initialise i at 1 as string are 1-indexed in lua
s=...                           -- use s as a shorthand for the first argument
r=s:reverse()                   -- reverse the string s and save it into r
while(s:sub(i)~=r:sub(0,#r-i+1))-- iterate while the last i characters of s
do                              -- aren't equals to the first i characters of r
  i=i+1                         -- increment the number of character to skip
end
print(s..r:sub(#r-i+2))         -- output the merged string


Title: Rectangle Detection

Body:
Write a program or function that takes in a multiline string of 0's and 1's. No other characters will be in the string and the string will always be rectangular (all lines will have same number of characters), with dimensions as small as 1×1, but otherwise the 0's and 1's may be arranged arbitrarily.

You may assume the string has an optional trailing newline, and if desired you may use any two distinct printable ASCII characters in place of 0 and 1.

Print or return a truthy value if all of the path connected regions of both 0's and 1's in the string are solid rectangles, else output a falsy value.

A path connected region of 0's means that from any one 0 in the region, all the other 0's can be reached by only moving up, down, left and right to other 0's (and not moving diagonally, not moving to any 1, and not moving outside the string bounds). The same idea applies to 1 path connected regions.

A solid rectangle of 0's means the entire area of the rectangle is filled with 0's and no 1's. The same idea applies to 1 solid rectangles.

The shortest code in bytes wins. Tiebreaker is earlier answer.

(Note that the string does not wrap around with toroidal boundary conditions.)

Examples

1) This input string has 3 path connected regions (2 for 0 and 1 for 1). Only the bottom right 00 region is a solid rectangle though, so the output would be falsy.

```<code>0011
0111
0100
</code>```

2) This input string has 4 path connected regions (2 for both 0 and 1). All of them are solid rectangles so the output would be truthy.

```<code>0011
0011
1100
</code>```

3) This input has 2 path connected regions, but only one of them is a solid rectangle, so the output would be falsy.

```<code>00000000
01111110
00000000
</code>```

4) This input has only 1 path connected region and is trivially a solid rectangle, so the output is truthy.

```<code>11111111
11111111
11111111
</code>```

Test Cases

A T just below the input string means truthy, F means falsy.

```<code>0
T

1
T

00
T

01
T

10
T

11
T

0000000
T

1111111
T

011100100100101100110100100100101010100011100101
T

00
11
T

01
10
T

01
11
F

00
01
F

11
11
T

110
100
F

111
000
T

111
101
111
F

101
010
101
T

1101
0010
1101
0010
T

1101
0010
1111
0010
F

0011
0111
0100
F

0011
0011
1100
T

00000000
01111110
00000000
F

11111111
11111111
11111111
T

0000001111
0000001111
T

0000001111
0000011111
F

0000001111
1000001111
F

1000001111
1000001111
T

1110100110101010110100010111011101000101111
1010100100101010100100010101010101100101000
1110100110010010110101010111010101010101011
1010100100101010010101010110010101001101001
1010110110101010110111110101011101000101111
F</code>```

Body:
JavaScript (ES6), 79

Same algorithm of Jelly answer from @Sp3000 (and happy not having to prove it works). Just 8 times longer

s=>[...s].every((x,i)=>[++i,i+=s.search`
`,i+1].some(p=>!(x^=p=s[p],p>`
`))|!x)

Less golfed

s=>[...s].every((x,i)=> // repeat check for every sub square
     [++i,                  // array of position for next char in row
      i+=s.search`\n`, i+1] // and 2 chars at same column in next row
       .some(p=> // for each position
          !(
            x^=s[p],  // xor current value with value at position p
            s[p]>`\n` // true if value at position p is valid
           ) // the condition is negated
       ) // if any value scanned is not valid, .some return true
         // else, we must consider the check for current square
       | !x // x can be 0 or 1, to be valid must be 0
   )

Test suite

f=s=>[...s].every((x,i)=>[++i,i+=s.search`
`,i+1].some(p=>!(x^=p=s[p],p>`
`))|!x)

testData=`
0
T

1
T

00
T

01
T

10
T

11
T

0000000
T

1111111
T

011100100100101100110100100100101010100011100101
T

00
11
T

01
10
T

01
11
F

00
01
F

11
11
T

110
100
F

111
000
T

111
101
111
F

101
010
101
T

1101
0010
1101
0010
T

1101
0010
1111
0010
F

0011
0111
0100
F

0011
0011
1100
T

00000000
01111110
00000000
F

11111111
11111111
11111111
T

0000001111
0000001111
T

0000001111
0000011111
F

0000001111
1000001111
F

1000001111
1000001111
T

1110100110101010110100010111011101000101111
1010100100101010100100010101010101100101000
1110100110010010110101010111010101010101011
1010100100101010010101010110010101001101001
1010110110101010110111110101011101000101111
F`

console.log=x=>O.textContent+=x+'\n'

testData.split('\n\n').forEach(t=>{
  var k=t.slice(-1)=='T',
      r=f(t.slice(0,-1))
  console.log(t+' '+r+ (k==r?' OK\n':' KO\n'))
})

<pre id=O></pre>


问:
Tweetable hash function challenge
In this code-challenge you will write a hash function in 140 bytes1 or less of source code. The hash function must take an ASCII string as input, and return a 24-bit unsigned integer ([0, 224-1]) as output.

Your hash function will be evaluated for every word in this large British English dictionary2. Your score is the amount of words that share a hash value with another word (a collision).

The lowest score wins, ties broken by first poster.

Test case

Before submitting, please test your scoring script on the following input:

```<code>duplicate
duplicate
duplicate
duplicate
</code>```

If it gives any score other than 4, it is buggy.

Clarifying rules:

Your hash function must run on a single string, not a whole array. Also, your hash function may not do any other I/O than the input string and output integer.

Built-in hash functions or similar functionality (e.g. encryption to scramble bytes) is disallowed.

Your hash function must be deterministic.

Contrary to most other contests optimizing specifically for the scoring input is allowed.

1 I am aware Twitter limits characters instead of bytes, but for simplicity we will use bytes as a limit for this challenge.

2 Modified from Debian's wbritish-huge, removing any non-ASCII words.

Title: Tweetable hash function challenge

Body:
Alright fine I’ll go learn a golfing language.

CJam, 140 bytes, 3314 colliding words

00000000: 7b5f 3162 225e d466 4a55 a05e 9f47 fc51  {_1b"^.fJU.^.G.Q
00000010: c45b 4965 3073 72dd e1b4 d887 a4ac bcbd  .[Ie0sr.........
00000020: 9c8f 70ca 2981 b2df 745a 10d0 dfca 6cff  ..p.)...tZ....l.
00000030: 7a3b 64df e730 54b4 b068 8584 5f6c 9f6b  z;d..0T..h.._l.k
00000040: b7f8 7a1f a2d3 b2b8 bcf5 cfa6 1ef7 a55c  ..z............\
00000050: dca8 795c 2492 dc32 1fb6 f449 f9ca f6b7  ..y\$..2...I....
00000060: a2cf 4772 266e ad4f d90c d236 b51d c5d5  ..Gr&n.O...6....
00000070: 5c46 3f9b 7cb4 f195 4efc fe4a ce8d 9aee  \F?.|...N..J....
00000080: 9dbc 223d 6962 3443 2329 257d            .."=ib4C#)%}

Defines a block (anonymous function).  To test, you could add qN%%N*N to take the newline-separated list of words on stdin and write a newline-separated list of hashes on stdout.  Equivalent Python code:

b=lambda s,a:reduce(lambda n,c:n*a+ord(c),s,0)
f=lambda s:b(s,ord('^\xd4fJU\xa0^\x9fG\xfcQ\xc4[Ie0sr\xdd\xe1\xb4\xd8\x87\xa4\xac\xbc\xbd\x9c\x8fp\xca)\x81\xb2\xdftZ\x10\xd0\xdf\xcal\xffz;d\xdf\xe70T\xb4\xb0h\x85\x84_l\x9fk\xb7\xf8z\x1f\xa2\xd3\xb2\xb8\xbc\xf5\xcf\xa6\x1e\xf7\xa5\\\xdc\xa8y\\$\x92\xdc2\x1f\xb6\xf4I\xf9\xca\xf6\xb7\xa2\xcfGr&n\xadO\xd9\x0c\xd26\xb5\x1d\xc5\xd5\\F?\x9b|\xb4\xf1\x95N\xfc\xfeJ\xce\x8d\x9a\xee\x9d\xbc'[b(s,1)%125]))%(8**8+1)

Pyth, 140 bytes, <s>3535</s> 3396 colliding words

00000000: 4c25 4362 2d68 5e38 2038 2a36 3643 4022  L%Cb-h^8 8*66C@"
00000010: aa07 f29a 27a7 133a 3901 484d 3f9b 1982  ....'..:9.HM?...
00000020: d261 79ab adab 9d92 888c 3012 a280 76cf  .ay.......0...v.
00000030: a2e5 8f81 7039 acee c42e bc18 28d8 efbf  ....p9......(...
00000040: 0ebe 2910 9c90 158e 3742 71b4 bdf5 59c2  ..).....7Bq...Y.
00000050: f90b e291 8673 ea59 6975 10be e750 84c8  .....s.Yiu...P..
00000060: 0b0f e7e8 f591 f628 cefa 1ab3 2e3c 72a3  .......(.....<r.
00000070: 7f09 6190 dbd2 d54e d6d0 d391 a780 ebb6  ..a....N........
00000080: ae86 2d1e 49b0 552e 7522 4362            ..-.I.U.u"Cb

Defines a function named y.  To test, you could add jmyd.z to take the newline-separated list of words on stdin and write a newline-separated list of hashes on stdout.  Equivalent Python code:

b=lambda s,a:reduce(lambda n,c:n*a+ord(c),s,0)
f=lambda s:b(s,256)%(8**8+1-66*ord("\xaa\x07\xf2\x9a'\xa7\x13:9\x01HM?\x9b\x19\x82\xd2ay\xab\xad\xab\x9d\x92\x88\x8c0\x12\xa2\x80v\xcf\xa2\xe5\x8f\x81p9\xac\xee\xc4.\xbc\x18(\xd8\xef\xbf\x0e\xbe)\x10\x9c\x90\x15\x8e7Bq\xb4\xbd\xf5Y\xc2\xf9\x0b\xe2\x91\x86s\xeaYiu\x10\xbe\xe7P\x84\xc8\x0b\x0f\xe7\xe8\xf5\x91\xf6(\xce\xfa\x1a\xb3.<r\xa3\x7f\ta\x90\xdb\xd2\xd5N\xd6\xd0\xd3\x91\xa7\x80\xeb\xb6\xae\x86-\x1eI\xb0U.u"[b(s,256)%121]))

Theoretical limits

How well can we expect to do?  Here is a plot of x, the number of colliding words, vs. y, the entropy in bytes required to get at most x colliding words.  For example, the point (2835, 140) tells us that a random function gets at most 2835 colliding words with probability 1/256**140, so it’s exceedingly unlikely that we’ll ever be able to do much better than that with 140 bytes of code.


答:
JavaScript (ES6), 69 bytes

```<code>s=>!s.split`
`.some((t,i,u)=>[...t].some((v,j)=>v^t[0]^u[0][j]^s[0]))
</code>```

I believe that the path connectedness rectangle criterion is equivalent to requiring that given any four points that form the corners of an arbitrary rectangle that there is an even number of 1s. Note that the parity of the rectangle (0, b), (x, y) is the same as (0, b), (a, y) ^ (a, b), (x, y) so I only have to check those rectangles whose top left corner is at (0, 0). Also by De Morgan's laws, !.some() is the same as .every(!) which saves me a couple of bytes.

Edit: I notice that the Jelly solution checks the parity of the corners of all 2×2 rectangles, which can be shown to be equivalent.

Title: Rectangle Detection

Body:
JavaScript (ES6), 69 bytes

s=>!s.split`
`.some((t,i,u)=>[...t].some((v,j)=>v^t[0]^u[0][j]^s[0]))

I believe that the path connectedness rectangle criterion is equivalent to requiring that given any four points that form the corners of an arbitrary rectangle that there is an even number of 1s. Note that the parity of the rectangle (0, b), (x, y) is the same as (0, b), (a, y) ^ (a, b), (x, y) so I only have to check those rectangles whose top left corner is at (0, 0). Also by De Morgan's laws, !.some() is the same as .every(!) which saves me a couple of bytes.

Edit: I notice that the Jelly solution checks the parity of the corners of all 2×2 rectangles, which can be shown to be equivalent.


答:
05AB1E, 19 bytes

Input is given in quotes. Code:

```<code>"[](){}<>"2÷)"":g2Q
</code>```

Well crap, a lot of bugs and unimplemented features were found. Explanation:

```<code>"[](){}<>"           # Push this string
          2÷         # Split into pieces of two
            )        # Wrap it into an array (which should not be needed)
             ""      # Push an empty string
               :     # Infinite replacement
</code>```

This is actually a tricky part. What this looks like in pseudocode is:

```<code>input().replace(['[]', '()', '{}', '<>'], "")
</code>```

This is covered by this part from the 05AB1E code:

```<code>if type(b) is list:
    temp_string = temp_string_2 = str(a)
    while True:
        for R in b:
            temp_string = temp_string.replace(R, c)
        if temp_string == temp_string_2:
            break
        else:
            temp_string_2 = temp_string
    stack.append(temp_string)
</code>```

As you can see, this is infinite replacement (done until the string doesn't change anymore). So, I don't have to worry about setting the replacement into a loop, since this is already builtin. After that:

```<code>                g    # Take the length of the final string
                 2Q  # Check if equal with 2 (which are the quotes at the end)
</code>```

Uses CP-1252 encoding. Try it online! (slightly modified because the above version is deprecated).

Title: Are the brackets fully matched?

Body:
05AB1E, 19 bytes

Input is given in quotes. Code:

"[](){}<>"2÷)"":g2Q

Well crap, a lot of bugs and unimplemented features were found. Explanation:

"[](){}<>"           # Push this string
          2÷         # Split into pieces of two
            )        # Wrap it into an array (which should not be needed)
             ""      # Push an empty string
               :     # Infinite replacement

This is actually a tricky part. What this looks like in pseudocode is:

input().replace(['[]', '()', '{}', '<>'], "")

This is covered by this part from the 05AB1E code:

if type(b) is list:
    temp_string = temp_string_2 = str(a)
    while True:
        for R in b:
            temp_string = temp_string.replace(R, c)
        if temp_string == temp_string_2:
            break
        else:
            temp_string_2 = temp_string
    stack.append(temp_string)

As you can see, this is infinite replacement (done until the string doesn't change anymore). So, I don't have to worry about setting the replacement into a loop, since this is already builtin. After that:

                g    # Take the length of the final string
                 2Q  # Check if equal with 2 (which are the quotes at the end)

Uses CP-1252 encoding. Try it online! (slightly modified because the above version is deprecated).


答:
JavaScript (ES6), <s>52</s> 50 bytes

```<code>f=s=>(t=s.replace(/\(\)|\[]|{}|<>/,''))==s?!s:f(t)
</code>```

Repeatedly remove brackets until the result is the same as the original, then return false unless the string is now empty.

Edit: Saved 2 bytes thanks to @edc65.

Title: Are the brackets fully matched?

Body:
JavaScript (ES6), <s>52</s> 50 bytes

f=s=>(t=s.replace(/\(\)|\[]|{}|<>/,''))==s?!s:f(t)

Repeatedly remove brackets until the result is the same as the original, then return false unless the string is now empty.

Edit: Saved 2 bytes thanks to @edc65.


Title: The plus-minus sequence

Body:
The plus-minus sequence

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

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

Test cases

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

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

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

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

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

Catalog

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

Body:
k, 12

{(+;-).\:x}\

.

k){(+;-).\:x}\[10;10 2]
10  2
12  8
20  4
24  16
40  8
48  32
80  16
96  64
160 32
192 128
320 64

Could also be called in the form of

k)10{(+;-).\:x}\10 2


答:
Ruby, 76

```<code>->s{j=!r=1
s.lines{|t|i=t.to_i(2)
j&&r&&=(j^i)%t.tr(?0,?1).to_i(2)<1
j=i}
r}
</code>```

In any grid composed entirely of rectangles, each line must be identical to the line before, or have all bits flipped from 0 to 1 and vice versa.

This is easy to prove. Take a piece of paper and draw arbitrary vertical and horizontal lines all the way across it. Now colour the rectangles using only 2 colours. You will end up with a distorted checkerboard, where all the colours flip at each line.

Want to draw rectangles with lines only part way across? try deleting a segment of any of your lines. You will now need more than 2 colours to colour your design, because you will have points where 3 rectangles meet (2 corners and an edge.) Such designs are therefore irrelevant to this question.

I'm surprised answers so far haven't noticed this.

I think this algorithm should be a lot shorter in some other language.

Ungolfed in test program

```<code>f=->s{
  j=!r=1                              #r = truthy, j=falsy
  s.lines{|t|                         #for each line
    i=t.to_i(2)                       #i = value of current line, converted to a number in base 2 (binary)
    j&&                               #if j is truthy (i.e this is not the first line)
      r&&=(j^i)%t.tr(?0,?1).to_i(2)<1 #XOR i with the previous line. Take the result modulo (current line with all 0 replaced by 1)
                                      #if the result of the XOR was all 0 or all 1, the modulo == zero (<1). Otherwise, it will be a positive number.
j=i}                                  #j = value of current line (always truthy in ruby, even if zero)
r}                                    #return 1 or true if all the modulo calculations were zero, else false.

#text to print after test case to check answer is as desired
T='T

'
F='F

'

#test cases
puts f['0'],T

puts f['1'],T

puts f['00
'],T

puts f['01'],T

puts f['10'],T

puts f['11
'],T

puts f['0000000'],T

puts f['1111111'],T

puts f['011100100100101100110100100100101010100011100101'],T

puts f['00
11'],T

puts f['01
10'],T

puts f['01
11'],F

puts f['00
01'],F

puts f['11
11
'],T

puts f['110
100'],F

puts f['111
000'],T

puts f['111
101
111'],F

puts f['101
010
101
'],T

puts f['1101
0010
1101
0010'],T

puts f['1101
0010
1111
0010'],F

puts f['0011
0111
0100
'],F

puts f['0011
0011
1100'],T

puts f['00000000
01111110
00000000'],F

puts f['11111111
11111111
11111111'],T

puts f['0000001111
0000001111'],T

puts f['0000001111
0000011111'],F

puts f['0000001111
1000001111'],F

puts f['1000001111
1000001111'],T

puts f['1110100110101010110100010111011101000101111
1010100100101010100100010101010101100101000
1110100110010010110101010111010101010101011
1010100100101010010101010110010101001101001
1010110110101010110111110101011101000101111'],F
</code>```

Title: Rectangle Detection

Body:
Ruby, 76

->s{j=!r=1
s.lines{|t|i=t.to_i(2)
j&&r&&=(j^i)%t.tr(?0,?1).to_i(2)<1
j=i}
r}

In any grid composed entirely of rectangles, each line must be identical to the line before, or have all bits flipped from 0 to 1 and vice versa.

This is easy to prove. Take a piece of paper and draw arbitrary vertical and horizontal lines all the way across it. Now colour the rectangles using only 2 colours. You will end up with a distorted checkerboard, where all the colours flip at each line.

Want to draw rectangles with lines only part way across? try deleting a segment of any of your lines. You will now need more than 2 colours to colour your design, because you will have points where 3 rectangles meet (2 corners and an edge.) Such designs are therefore irrelevant to this question.

I'm surprised answers so far haven't noticed this.

I think this algorithm should be a lot shorter in some other language.

Ungolfed in test program

f=->s{
  j=!r=1                              #r = truthy, j=falsy
  s.lines{|t|                         #for each line
    i=t.to_i(2)                       #i = value of current line, converted to a number in base 2 (binary)
    j&&                               #if j is truthy (i.e this is not the first line)
      r&&=(j^i)%t.tr(?0,?1).to_i(2)<1 #XOR i with the previous line. Take the result modulo (current line with all 0 replaced by 1)
                                      #if the result of the XOR was all 0 or all 1, the modulo == zero (<1). Otherwise, it will be a positive number.
j=i}                                  #j = value of current line (always truthy in ruby, even if zero)
r}                                    #return 1 or true if all the modulo calculations were zero, else false.

#text to print after test case to check answer is as desired
T='T

'
F='F

'

#test cases
puts f['0'],T

puts f['1'],T

puts f['00
'],T

puts f['01'],T

puts f['10'],T

puts f['11
'],T

puts f['0000000'],T

puts f['1111111'],T

puts f['011100100100101100110100100100101010100011100101'],T

puts f['00
11'],T

puts f['01
10'],T

puts f['01
11'],F

puts f['00
01'],F

puts f['11
11
'],T

puts f['110
100'],F

puts f['111
000'],T

puts f['111
101
111'],F

puts f['101
010
101
'],T

puts f['1101
0010
1101
0010'],T

puts f['1101
0010
1111
0010'],F

puts f['0011
0111
0100
'],F

puts f['0011
0011
1100'],T

puts f['00000000
01111110
00000000'],F

puts f['11111111
11111111
11111111'],T

puts f['0000001111
0000001111'],T

puts f['0000001111
0000011111'],F

puts f['0000001111
1000001111'],F

puts f['1000001111
1000001111'],T

puts f['1110100110101010110100010111011101000101111
1010100100101010100100010101010101100101000
1110100110010010110101010111010101010101011
1010100100101010010101010110010101001101001
1010110110101010110111110101011101000101111'],F


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

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

Example input:

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

Example output:

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

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

Tests provided by @Neil :

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

答:
Dyalog APL, 6 bytes

```<code>∊,\∩¨⊢
</code>```

TryAPL!

4 functions is an atop (2-train) of a fork (3-train):

```<code>┌──┴──┐
∊ ┌───┼─┐
  \   ¨ ⊢
┌─┘ ┌─┘
,   ∩
</code>```

First ⊢ (right – a no-op) on the given string, giving 'bonobo'

Then ,\ (concatenation scan) on the string, giving 'b' 'bo' 'bon' 'bono' 'bonob' 'bonobo'

The two are forked together with (given as right and left arguments to) ∩¨ (intersection each), i.e. ('b'∩'b') ('bo'∩'o') ('bon'∩'n') ('bono'∩'o') ('bonob'∩'b') ('bonobo'∩'o'), which is 'b' 'o' 'n' 'oo' 'bb' 'ooo'

Finally, ∊ (enlist) is applied to the result to flatten it, giving 'bonoobbooo'

Hey, at least it matches Pyth! Obviously Jelly is shorter as it is a golf version of J, which in turn is an advanced 2-character-per-function dialect of APL.

Title: Stretch the word

Body:
Dyalog APL, 6 bytes

∊,\∩¨⊢

TryAPL!

4 functions is an atop (2-train) of a fork (3-train):

┌──┴──┐
∊ ┌───┼─┐
  \   ¨ ⊢
┌─┘ ┌─┘
,   ∩

First ⊢ (right – a no-op) on the given string, giving 'bonobo'

Then ,\ (concatenation scan) on the string, giving 'b' 'bo' 'bon' 'bono' 'bonob' 'bonobo'

The two are forked together with (given as right and left arguments to) ∩¨ (intersection each), i.e. ('b'∩'b') ('bo'∩'o') ('bon'∩'n') ('bono'∩'o') ('bonob'∩'b') ('bonobo'∩'o'), which is 'b' 'o' 'n' 'oo' 'bb' 'ooo'

Finally, ∊ (enlist) is applied to the result to flatten it, giving 'bonoobbooo'

Hey, at least it matches Pyth! Obviously Jelly is shorter as it is a golf version of J, which in turn is an advanced 2-character-per-function dialect of APL.