答:
R, 40 39 25 bytes

Completely reworked solution thanks to @Dason

```<code>sum(cumprod(rev(scan())))
</code>```

Read input from stdin, reverse the vector and if the first element of is !=0 then output the the first length of the run-length encoding (rle), else 0.

Title: Count trailing truths

Body:
R, 40 39 25 bytes

Completely reworked solution thanks to @Dason

sum(cumprod(rev(scan())))

Read input from stdin, reverse the vector and if the first element of is !=0 then output the the first length of the run-length encoding (rle), else 0.


问:
Primenary Strings

A Primenary (binary-prime) string is one which, when written as a binary grid, every row and column has a prime total.

That's quite a vague explanation, so let's break it down with a worked example...

For this example we'll use the string bunny:

First, find the ASCII code point of each character and its binary representation:

```<code>Char | ASCII | Binary

b      98      1100010
u      117     1110101
n      110     1101110
n      110     1101110
y      121     1111001
</code>```

Take these binary values, from top to bottom, and arrange them into grid (adding leading zeros if necessary):

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

Then, count the number of 1s in each row and column:

```<code>1 1 0 0 0 1 0   > 3
1 1 1 0 1 0 1   > 5
1 1 0 1 1 1 0   > 5
1 1 0 1 1 1 0   > 5
1 1 1 1 0 0 1   > 5

v v v v v v v

5 5 2 3 3 3 2
</code>```

If, and only if, every single total is prime (such as here) then the string is a valid binary-prime.

The Challenge

Your task is to create a function or program which, when given a string, returns/outputs truthy if the string is primenary, and falsy otherwise.

Rules/Details

You may assume that the string's characters will always be in the ASCII range 33-126 (inclusive).

The string will not be empty.

A primenary string does not have to have a prime length - for example, W1n* is valid, despite having 4 characters.

This is code-golf, so the shortest answer (in bytes) wins - but all submissions are welcome.

Standard loopholes are banned.

Test Cases

```<code>'husband'     -> True
'HOTJava'     -> True
'COmPaTIBILE' -> True
'AuT0HACk'    -> True

'PPCW'        -> False
'code-golf'   -> False
'C++'         -> False
'/kD'         -> False

'HI'          -> False
'A'           -> False
</code>```

There is also a working, but incredibly verbose Python example on repl.it that you can test your solution against.

答:
Jelly, 15 bytes

```<code>O+⁹Bṫ€3µS€;SÆPP
</code>```

Try it online! or Verify all test cases..

Explanation

```<code>O+⁹Bṫ€3µS€;SÆPP  Main link. Input: string z
O                Ordinal, get ASCII value of each char
  ⁹              Nilad representing 256
 +               Add 256 to each ordinal value
   B             Binary digits of each
    ṫ€3          Tail, take each list of digits from the 3rd value to the end
                 These are the last seven digits of each
       µ         Start a new monadic chain
        S€       Sum each list of digits by rows
           S     Sum by column
          ;      Concatenate
            ÆP   Test if each is prime, 1 if true else 0
              P  Product
</code>```

ContentLicense: CC BY-SA 3.0

Title: Primenary Strings

Body:
Jelly, 15 bytes

O+⁹Bṫ€3µS€;SÆPP

Try it online! or Verify all test cases..

Explanation

O+⁹Bṫ€3µS€;SÆPP  Main link. Input: string z
O                Ordinal, get ASCII value of each char
  ⁹              Nilad representing 256
 +               Add 256 to each ordinal value
   B             Binary digits of each
    ṫ€3          Tail, take each list of digits from the 3rd value to the end
                 These are the last seven digits of each
       µ         Start a new monadic chain
        S€       Sum each list of digits by rows
           S     Sum by column
          ;      Concatenate
            ÆP   Test if each is prime, 1 if true else 0
              P  Product


问:
Count trailing truths

Inspired by, and in memory of, my dear friend and colleague,

Dan Baronet, 1956 – 2016. R.I.P.

He found the shortest possible APL solution to this task:

Task

Given a Boolean list, count the number of trailing truth values.

Example cases

{} → 0

{0} → 0

{1} → 1

{0, 1, 1, 0, 0} → 0

{1, 1, 1, 0, 1} → 1

{1, 1, 0, 1, 1} → 2

{0, 0, 1, 1, 1} → 3

{1, 1, 1, 1, 1, 1} → 6

答:
Jelly, 4 bytes

```<code>ṣ0ṪL
</code>```

TryItOnline!, or all tests

How?

```<code>ṣ0ṪL - Main link: booleanList
ṣ0   - split on occurrences of 0 ([] -> [[]]; [0] -> [[],[]]; [1] -> [[1]]; ...)
  Ṫ  - tail (rightmost entry)
   L - length
</code>```

ContentLicense: CC BY-SA 4.0

Title: Count trailing truths

Body:
Jelly, 4 bytes

ṣ0ṪL

TryItOnline!, or all tests

How?

ṣ0ṪL - Main link: booleanList
ṣ0   - split on occurrences of 0 ([] -> [[]]; [0] -> [[],[]]; [1] -> [[1]]; ...)
  Ṫ  - tail (rightmost entry)
   L - length


问:
Draw some mountain peaks
Write a program or function that draws a mountain range, where each subsequent larger mountain peak is "behind" the ones in front, and alternates which side is visible.

This is a mountain range of size 1

```<code>/\
</code>```

This is a mountain range of size 2

```<code> /\
/\ \
</code>```

This is a mountain range of size 3

```<code>  /\
 / /\
/ /\ \
</code>```

This is a mountain range of size 4

```<code>   /\
  /\ \
 / /\ \
/ /\ \ \
</code>```

This is a mountain range of size 5

```<code>    /\
   / /\
  / /\ \
 / / /\ \
/ / /\ \ \
</code>```

And so on.

Input

A single positive integer in any convenient format, n > 0.

Output

An ASCII-art representation of the mountain range, following the above rules. Leading/trailing newlines or other whitespace are optional, provided that the peaks line up appropriately.

Rules

Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.

Standard loopholes are forbidden.

This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

答:
C++ 138(function)

Function :-

#define c(X) cout<<X;
#define L(X,Y) for(X=0;X<Y;X++)

void M(int h){int l=1,r=1,j,H=h,i;L(i,h){for(j=H;j>0;j--)c(" ")L(j,l)c(" /")L(j, r)c("\\ ")c("\ n")(h%2)?(i%2)?r++:l++:(i%2)?l++:r++;H--;}
```
<p>Full program :-</p>
<pre class="lang-C++ prettyprint-override"><code>#include<conio.h>
#include<iostream>

using namespace std;

#define c(X) cout<<X;
#define L(X,Y) for(X=0;X<Y;X++)

void M(int h)
{
    int l=1,r=1,j,H=h,i;

    L(i, h)
    {
        for (j = H;j > 0;j--)
            c(" ")
        L(j, l)
            c(" /")
        L(j, r)
            c("\\ ")
        c("\n")

        (h % 2) ? (i % 2) ? r++ : l++ :(i % 2) ? l++ : r++;
        H--;
    }
}

int main()
{
    int h;
    cin >> h;
    M(h);
    _getch();
    return 0;
}
</code>```

NOTE :  the function _getch() may have different prototype names across different compilers.

Title: Draw some mountain peaks

Body:
C++ 138(function)

Function :-

#define c(X) cout<<X;
#define L(X,Y) for(X=0;X<Y;X++)

void M(int h){int l=1,r=1,j,H=h,i;L(i,h){for(j=H;j>0;j--)c(" ")L(j,l)c(" /")L(j, r)c("\\ ")c("\ n")(h%2)?(i%2)?r++:l++:(i%2)?l++:r++;H--;}

Full program :-

#include<conio.h>
#include<iostream>

using namespace std;

#define c(X) cout<<X;
#define L(X,Y) for(X=0;X<Y;X++)

void M(int h)
{
    int l=1,r=1,j,H=h,i;

    L(i, h)
    {
        for (j = H;j > 0;j--)
            c(" ")
        L(j, l)
            c(" /")
        L(j, r)
            c("\\ ")
        c("\n")

        (h % 2) ? (i % 2) ? r++ : l++ :(i % 2) ? l++ : r++;
        H--;
    }
}

int main()
{
    int h;
    cin >> h;
    M(h);
    _getch();
    return 0;
}

NOTE :  the function _getch() may have different prototype names across different compilers.


答:
Python2, <s>42</s> 41 Byes

```<code>t=input()[::-1];print len(t[:t.index(0)])
</code>```

takes input as [1, 1, 0, 1, 1]

Title: Count trailing truths

Body:
Inspired by, and in memory of, my dear friend and colleague,

Dan Baronet, 1956 – 2016. R.I.P.

He found the shortest possible APL solution to this task:

Task

Given a Boolean list, count the number of trailing truth values.

Example cases

{} → 0

{0} → 0

{1} → 1

{0, 1, 1, 0, 0} → 0

{1, 1, 1, 0, 1} → 1

{1, 1, 0, 1, 1} → 2

{0, 0, 1, 1, 1} → 3

{1, 1, 1, 1, 1, 1} → 6

Body:
Python2, <s>42</s> 41 Byes

t=input()[::-1];print len(t[:t.index(0)])

takes input as [1, 1, 0, 1, 1]


答:
Vitsy, <s>28</s> 26 bytes

This can be golfed a bit.

```<code>'\/'6\[4\[c\[4\[DO]r]aO]r]
</code>```

Try it online!

Title: This is my pillow

Body:
...will you help me immortalize it?

I've had this pillow a few years now, and apparently it's time to get rid of it. Can you please write a function or program, that I can bring with me and use to recreate this pillow whenever I want to reminisce a bit.

It must work with no input arguments.

The output should look exactly like this (trailing newlines and spaces are OK).

```<code>/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
</code>```

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

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Vitsy, <s>28</s> 26 bytes

This can be golfed a bit.

'\/'6\[4\[c\[4\[DO]r]aO]r]

Try it online!


问:
Pairable strings
A string is pairable if it can be split into subtrings, each of which is a string repeated twice consecutively. For example, aabaaababbbaba is pairable as:

```<code>aaba aaba
b b
ba ba
</code>```

Given a non-empty string of a's and b's, output a Truthy value if it's pairable and a Falsey value if it isn't.

Pairable:

```<code>aa
abaaba
bbababbb
aabaaababbbaba
babababa
bbbbbbbbbbbb
aaababbabbabbbababbaabaabaababaaba
aaaabaab
</code>```

Not pairable:

```<code>a
ba
baab
abaabaaba
bbbbbbbbbbbbbbb
baababbabaaaab
aaaaabbaaaaa
</code>```

I encourage you to come up with non-regex-based solutions even when there's already a shorter regex answer in your language. You can mark them as "no regex". By regex, I mean a built-in string pattern matching subsystem.

Leaderboard:

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Python, <s>66</s> 64 bytes

Thanks @Zgarb for -1 byte!

f=lambda x,s=1:x>x[:s]and(x==2*x[:s])|f(x[:s])&f(x[s:])|f(x,s+1)
```

Returns True or False.

Try it online!

Any help golfing this would be appreciated.

Title: Pairable strings

Body:
Python, <s>66</s> 64 bytes

Thanks @Zgarb for -1 byte!

f=lambda x,s=1:x>x[:s]and(x==2*x[:s])|f(x[:s])&f(x[s:])|f(x,s+1)

Returns True or False.

Try it online!

Any help golfing this would be appreciated.


答:
k, 6 bytes

```<code>+/&\|:
</code>```

This function composition translates to sum mins reverse in q, the language's more readable sibling, where mins is a rolling minimum.

Title: Count trailing truths

Body:
k, 6 bytes

+/&\|:

This function composition translates to sum mins reverse in q, the language's more readable sibling, where mins is a rolling minimum.


答:
MATL, 10 bytes

```<code>BtXsw!shZp
</code>```

Try it online!

This is the ideal language for the job. It's pretty much a literal transliteration of the challenge specification.

```<code>Bt % Converts input to binary matrix, duplicate
Xs  % Sum columns (alternative X version to prevent defaulting to sum along first non-singleton dimension, thanks @Jonathan Allan)
w! % Get the duplicate to the top of the stack, transpose
s  % Sum again
h  % Concatenate horizontally
Zp % Check primality element-wise. Display implicitly.
</code>```

Since any zero makes a MATL array falsy as per meta, nothing else is needed  - basically, an implicit A is called on ? (if).

Title: Primenary Strings

Body:
A Primenary (binary-prime) string is one which, when written as a binary grid, every row and column has a prime total.

That's quite a vague explanation, so let's break it down with a worked example...

For this example we'll use the string bunny:

First, find the ASCII code point of each character and its binary representation:

```<code>Char | ASCII | Binary

b      98      1100010
u      117     1110101
n      110     1101110
n      110     1101110
y      121     1111001
</code>```

Take these binary values, from top to bottom, and arrange them into grid (adding leading zeros if necessary):

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

Then, count the number of 1s in each row and column:

```<code>1 1 0 0 0 1 0   > 3
1 1 1 0 1 0 1   > 5
1 1 0 1 1 1 0   > 5
1 1 0 1 1 1 0   > 5
1 1 1 1 0 0 1   > 5

v v v v v v v

5 5 2 3 3 3 2
</code>```

If, and only if, every single total is prime (such as here) then the string is a valid binary-prime.

The Challenge

Your task is to create a function or program which, when given a string, returns/outputs truthy if the string is primenary, and falsy otherwise.

Rules/Details

You may assume that the string's characters will always be in the ASCII range 33-126 (inclusive).

The string will not be empty.

A primenary string does not have to have a prime length - for example, W1n* is valid, despite having 4 characters.

This is code-golf, so the shortest answer (in bytes) wins - but all submissions are welcome.

Standard loopholes are banned.

Test Cases

```<code>'husband'     -> True
'HOTJava'     -> True
'COmPaTIBILE' -> True
'AuT0HACk'    -> True

'PPCW'        -> False
'code-golf'   -> False
'C++'         -> False
'/kD'         -> False

'HI'          -> False
'A'           -> False
</code>```

There is also a working, but incredibly verbose Python example on repl.it that you can test your solution against.

Body:
MATL, 10 bytes

BtXsw!shZp

Try it online!

This is the ideal language for the job. It's pretty much a literal transliteration of the challenge specification.

Bt % Converts input to binary matrix, duplicate
Xs  % Sum columns (alternative X version to prevent defaulting to sum along first non-singleton dimension, thanks @Jonathan Allan)
w! % Get the duplicate to the top of the stack, transpose
s  % Sum again
h  % Concatenate horizontally
Zp % Check primality element-wise. Display implicitly.

Since any zero makes a MATL array falsy as per meta, nothing else is needed  - basically, an implicit A is called on ? (if).


问:
Print a letter Fibonacci
Given N (2 <= N), print N lines of the letter Fibonacci series like this (i.e. N = 5)
First, start with a and b:

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

Next, add the two lines.

```<code>a
b
ab
</code>```

Keep adding the last two lines.

```<code>a
b
ab
bab
</code>```

Keep going...

```<code>a
b
ab
bab
abbab
</code>```

And we're done.

Remember, this is code-golf, so the code with the fewest bytes wins.

答:
R, 82 bytes

This can surely be golfed.

```<code>x=c("b","a");for(i in 2:scan()-2)x=c(paste0(x[2],x[1]),x);cat(rev(x[-1]),sep="\n")
</code>```

Title: Print a letter Fibonacci

Body:
R, 82 bytes

This can surely be golfed.

x=c("b","a");for(i in 2:scan()-2)x=c(paste0(x[2],x[1]),x);cat(rev(x[-1]),sep="\n")


答:
Dyalog APL, <s>6</s> 2 bytes

```<code>⊥⍨
</code>```

Test it on TryAPL.

How it works

⊥ (uptack, dyadic: decode) performs base conversion. If the left operand is a vector, it performs mixed base conversion, which is perfect for this task.

For a base vector b = bn, ⋯, b0 and a digit vector a = an, ⋯, a0, b ⊥ a converts a to the mixed base b, i.e., it computes b0⋯bn-1an + ⋯ + b0b1a2 + b0a1 + a0.

Now, ⍨ (tilde dieresis, commute) modifies the operator to the left as follows. In a monadic context, it calls the operator with equal left and right arguments.

For example, ⊥⍨ a is defined as a ⊥ a, which computes a0⋯an + ⋯ + a0a1a2 + a0a1 + a0, the sum of all cumulative products from the right to the left.

For k trailing ones, the k rightmost products are 1 and all others are 0, so their sum is equal to k.

Title: Count trailing truths

Body:
Dyalog APL, <s>6</s> 2 bytes

⊥⍨

Test it on TryAPL.

How it works

⊥ (uptack, dyadic: decode) performs base conversion. If the left operand is a vector, it performs mixed base conversion, which is perfect for this task.

For a base vector b = bn, ⋯, b0 and a digit vector a = an, ⋯, a0, b ⊥ a converts a to the mixed base b, i.e., it computes b0⋯bn-1an + ⋯ + b0b1a2 + b0a1 + a0.

Now, ⍨ (tilde dieresis, commute) modifies the operator to the left as follows. In a monadic context, it calls the operator with equal left and right arguments.

For example, ⊥⍨ a is defined as a ⊥ a, which computes a0⋯an + ⋯ + a0a1a2 + a0a1 + a0, the sum of all cumulative products from the right to the left.

For k trailing ones, the k rightmost products are 1 and all others are 0, so their sum is equal to k.


Title: Count trailing truths

Body:
J, <s>9</s> 3 bytes

#.~

This is reflexive mixed base conversion. Because this is the same as mixed base conversion. Again.

Test cases

   v =: #.~
   ]t =: '';0;1;0 1 1 0 0;1 1 1 0 1;1 1 0 1 1;0 0 1 1 1;1 1 1 1 1 1
++-+-+---------+---------+---------+---------+-----------+
||0|1|0 1 1 0 0|1 1 1 0 1|1 1 0 1 1|0 0 1 1 1|1 1 1 1 1 1|
++-+-+---------+---------+---------+---------+-----------+
   v&.> t
+-+-+-+-+-+-+-+-+
|0|0|1|0|1|2|3|6|
+-+-+-+-+-+-+-+-+
   (,. v&.>) t
+-----------+-+
|           |0|
+-----------+-+
|0          |0|
+-----------+-+
|1          |1|
+-----------+-+
|0 1 1 0 0  |0|
+-----------+-+
|1 1 1 0 1  |1|
+-----------+-+
|1 1 0 1 1  |2|
+-----------+-+
|0 0 1 1 1  |3|
+-----------+-+
|1 1 1 1 1 1|6|
+-----------+-+


答:
Python, 37 bytes

```<code>f=lambda l:len(l)and-~f(l[:-1])*l[-1]
</code>```

Title: Count trailing truths

Body:
Python, 37 bytes

f=lambda l:len(l)and-~f(l[:-1])*l[-1]


答:
Python, 31 bytes

```<code>lambda a:(a[::-1]+[0]).index(0)
</code>```

Title: Count trailing truths

Body:
Python, 31 bytes

lambda a:(a[::-1]+[0]).index(0)


答:
MATL, <s>18</s> 16 bytes

```<code>'\/'6:&+thK5&Y")
</code>```

Try it online!

Explanation

```<code>'\/'   % Push this string
6:     % Push array [1 2 3 4 5 6]
&+     % 6×6 matrix with all pair-wise additions from that array
th     % Concatenate horizontally with itself. Gives a 6×12 matrix
K      % Push 4
5      % Push 5
&Y"    % Repeat each entry of the matrix 4 times vertically and 5 times horizontally
       % This gives a 24×60 matrix
)      % Index (modularly) into the string. This produces the desired 24×60 char array
</code>```

Title: This is my pillow

Body:
MATL, <s>18</s> 16 bytes

'\/'6:&+thK5&Y")

Try it online!

Explanation

'\/'   % Push this string
6:     % Push array [1 2 3 4 5 6]
&+     % 6×6 matrix with all pair-wise additions from that array
th     % Concatenate horizontally with itself. Gives a 6×12 matrix
K      % Push 4
5      % Push 5
&Y"    % Repeat each entry of the matrix 4 times vertically and 5 times horizontally
       % This gives a 24×60 matrix
)      % Index (modularly) into the string. This produces the desired 24×60 char array


Title: This is my pillow

Body:
C++ 138

void P(){int i,j,k,l;for(i=0;i<3;i++)for(j=0;j<8;j++)for(k=0;k<12;k++)for(l=0;l<5;l++)cout<<((j/4)?(k%2)?'/':'\\':(k%2)?'\\':'/')<<'\n';}

Ungolfed

#include<conio.h>
#include<iostream>
using namespace std;

void P()
{
    int i,j,k,l;
    for(i=0;i<3;i++)
        for(j=0;j<8;j++)
            for(k=0;k<12;k++)
                for(l=0;l<5;l++)
                    cout<<((j/4)?(k%2)?'/':'\\':(k%2)?'\\':'/')<<'\n';
}

int main()
{
    P();
    _getch();
    return 0;
}


答:
Perl, 16 +2 = 18 bytes (with regex)

Run with the -nl flags.  -E is free.

```<code>say/^((.+)\2)+$/
</code>```

Run as:

```<code>perl -nlE 'say/^((.+)\2)+$/'
</code>```

Returns a list of the capture groups (a truthy) if pairable, null string if not pairable.

Explanation

The -nl flags will run the code in a loop (-n), putting the input (with trailing newline removed because of -l) into the variable $_ each time, then evaluating the code each time input is entered, until the program is manually terminated.  The -E flag lets you evaluate code on the command line, and enables the say command.

```<code>say/^((.+)\2)+$/

   /^((.+)\2)+$/  #The regex engine
      (.+)\2      #Find any set of at least one character, followed by itself
     (      )+    #Do this at least one time
   /^         $/  #Make sure that this matches the entire string from start to end
say               #Output the result of the regex
</code>```

If a match is found (e.g. if the string is pairable), then the regex returns a list of the capture groups, which evaluates to a truthy, which is then passed to say, and output.  If no match is found, then the regex returns the empty string, which evaluates to falsy, which is then passed to say, and output.

Sample:

```<code>$ perl -nlE 'say/^((.+)\2)+$/'
aaababbabbabbbababbaabaabaababaaba
baababaababaaba                      #Truthy
baababbabaaaab
                                     #Falsy
bbababbb
bbb                                  #Truthy
aabaaababbbaba
bababa                               #Truthy
abaabaaba
                                     #Falsy
</code>```

Title: Pairable strings

Body:
A string is pairable if it can be split into subtrings, each of which is a string repeated twice consecutively. For example, aabaaababbbaba is pairable as:

```<code>aaba aaba
b b
ba ba
</code>```

Given a non-empty string of a's and b's, output a Truthy value if it's pairable and a Falsey value if it isn't.

Pairable:

```<code>aa
abaaba
bbababbb
aabaaababbbaba
babababa
bbbbbbbbbbbb
aaababbabbabbbababbaabaabaababaaba
aaaabaab
</code>```

Not pairable:

```<code>a
ba
baab
abaabaaba
bbbbbbbbbbbbbbb
baababbabaaaab
aaaaabbaaaaa
</code>```

I encourage you to come up with non-regex-based solutions even when there's already a shorter regex answer in your language. You can mark them as "no regex". By regex, I mean a built-in string pattern matching subsystem.

Leaderboard:

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Perl, 16 +2 = 18 bytes (with regex)

Run with the -nl flags.  -E is free.

say/^((.+)\2)+$/

Run as:

perl -nlE 'say/^((.+)\2)+$/'

Returns a list of the capture groups (a truthy) if pairable, null string if not pairable.

Explanation

The -nl flags will run the code in a loop (-n), putting the input (with trailing newline removed because of -l) into the variable $_ each time, then evaluating the code each time input is entered, until the program is manually terminated.  The -E flag lets you evaluate code on the command line, and enables the say command.

say/^((.+)\2)+$/

   /^((.+)\2)+$/  #The regex engine
      (.+)\2      #Find any set of at least one character, followed by itself
     (      )+    #Do this at least one time
   /^         $/  #Make sure that this matches the entire string from start to end
say               #Output the result of the regex

If a match is found (e.g. if the string is pairable), then the regex returns a list of the capture groups, which evaluates to a truthy, which is then passed to say, and output.  If no match is found, then the regex returns the empty string, which evaluates to falsy, which is then passed to say, and output.

Sample:

$ perl -nlE 'say/^((.+)\2)+$/'
aaababbabbabbbababbaabaabaababaaba
baababaababaaba                      #Truthy
baababbabaaaab
                                     #Falsy
bbababbb
bbb                                  #Truthy
aabaaababbbaba
bababa                               #Truthy
abaabaaba
                                     #Falsy


答:
MATL, 4 bytes

```<code>PYps
</code>```

Try it online!

```<code>P       % Flip
 Yp     % Cumulative product
   s    % Sum
</code>```

Title: Count trailing truths

Body:
Inspired by, and in memory of, my dear friend and colleague,

Dan Baronet, 1956 – 2016. R.I.P.

He found the shortest possible APL solution to this task:

Task

Given a Boolean list, count the number of trailing truth values.

Example cases

{} → 0

{0} → 0

{1} → 1

{0, 1, 1, 0, 0} → 0

{1, 1, 1, 0, 1} → 1

{1, 1, 0, 1, 1} → 2

{0, 0, 1, 1, 1} → 3

{1, 1, 1, 1, 1, 1} → 6

Body:
MATL, 4 bytes

PYps

Try it online!

P       % Flip
 Yp     % Cumulative product
   s    % Sum


答:
Retina, <s>7</s> 5 bytes

```<code>r`1\G
</code>```

Try it online! (The first line enables a linefeed-separated test suite.)

Defining the input format for Retina isn't entirely unambiguous. Since Retina has no concept of any type except strings (and also no value that can be used for our usual definition of truthy and falsy), I usually use 0 and 1 (or something positive in general) to correspond to truthy and falsy, as they represent zero or some matches, respectively.

With single-character representations, we also don't need a separator for the list (which in a way, is more the more natural list representation for a language that only has strings). Adám confirmed that this is an acceptable input format.

As for the regex itself, it matches from right to left and \G anchors each match to the previous one. Hence, this counts how many 1s we can match from the end of the string.

Title: Count trailing truths

Body:
Retina, <s>7</s> 5 bytes

r`1\G

Try it online! (The first line enables a linefeed-separated test suite.)

Defining the input format for Retina isn't entirely unambiguous. Since Retina has no concept of any type except strings (and also no value that can be used for our usual definition of truthy and falsy), I usually use 0 and 1 (or something positive in general) to correspond to truthy and falsy, as they represent zero or some matches, respectively.

With single-character representations, we also don't need a separator for the list (which in a way, is more the more natural list representation for a language that only has strings). Adám confirmed that this is an acceptable input format.

As for the regex itself, it matches from right to left and \G anchors each match to the previous one. Hence, this counts how many 1s we can match from the end of the string.


答:
Python 3, 228 227 225 bytes

Not a great answer, I wasn't able to golf it as much as I would've liked, but I spent so long on it I feel I should post it. Suggestions on cutting bytes would be greatly appreciated.

```<code>r=range
n=[format(ord(c),"08b")for c in input()]
n=map(lambda s:s.count("1"),n+["".join([f[1]for f in filter(lambda e:e[0]%8<1,enumerate("X"*-~i+"".join(n)))][1:])for i in r(8)])
print(all(all(s%d for d in r(2,s))for s in n))
</code>```

Edit 1: replaced e[0]%8==0 with e[0]%8<1, losing a byte. Thanks Flp.Tkc!

Edit 2: replacing (i+1) with -~i, losing two additional bytes. Thanks Erik for exposing how bad my bit-level knowledge is :) While testing this revision, I discovered that kappa is valid... make of that what you will.

Title: Primenary Strings

Body:
Python 3, 228 227 225 bytes

Not a great answer, I wasn't able to golf it as much as I would've liked, but I spent so long on it I feel I should post it. Suggestions on cutting bytes would be greatly appreciated.

r=range
n=[format(ord(c),"08b")for c in input()]
n=map(lambda s:s.count("1"),n+["".join([f[1]for f in filter(lambda e:e[0]%8<1,enumerate("X"*-~i+"".join(n)))][1:])for i in r(8)])
print(all(all(s%d for d in r(2,s))for s in n))

Edit 1: replaced e[0]%8==0 with e[0]%8<1, losing a byte. Thanks Flp.Tkc!

Edit 2: replacing (i+1) with -~i, losing two additional bytes. Thanks Erik for exposing how bad my bit-level knowledge is :) While testing this revision, I discovered that kappa is valid... make of that what you will.


问:
Tips for golfing in 05AB1E
Do you have any tips for code-golfing in 05AB1E, a golfing language created by Adnan?

Your tips should be at least somewhat specific to 05AB1E.

Please post one tip per answer.

答:
Strings and ints are equal types

Not something that everybody agrees with, but it works.

Consider the following two programs:

```<code>4 5+
"4""5"+
</code>```

They both result into 9. That is because every value is first evaluated (with ast.literal_eval). Because of that, we can perform all string manipulation operators on ints and all int manipulation operators on strings.

For example, 12345û palindromizes the number 12345, resulting in 123454321. After that, we can do the regular math on this number.

```<code>12345û50000-
</code>```

This would result into: 123404321.

Title: Tips for golfing in 05AB1E

Body:
Strings and ints are equal types

Not something that everybody agrees with, but it works.

Consider the following two programs:

4 5+
"4""5"+

They both result into 9. That is because every value is first evaluated (with ast.literal_eval). Because of that, we can perform all string manipulation operators on ints and all int manipulation operators on strings.

For example, 12345û palindromizes the number 12345, resulting in 123454321. After that, we can do the regular math on this number.

12345û50000-

This would result into: 123404321.


Title: This is my pillow

Body:
...will you help me immortalize it?

I've had this pillow a few years now, and apparently it's time to get rid of it. Can you please write a function or program, that I can bring with me and use to recreate this pillow whenever I want to reminisce a bit.

It must work with no input arguments.

The output should look exactly like this (trailing newlines and spaces are OK).

```<code>/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
</code>```

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

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Perl, <s>51</s> 50 bytes

Perl 5.10.0+:

perl -E 'say+((@_=("/"x5,"\\"x5)x6,$/)x4,(pop@_,@_,$/)x4)x3'

Perl before 5.10.0 (52 bytes):

perl -e 'print+((@_=("/"x5,"\\"x5)x6,$/)x4,(pop@_,@_,$/)x4)x3'

Ungolfed:

say(
    (
        (
            @_ = ('/' x 5, '\\' x 5) x 6,
            $/,  # new line symbol
        ) x 4,
        (
            pop(@_),
            @_,
            $/,
        ) x 4,
    ) x 3
);

Thanx to @DomHastings for 1 byte.


答:
Pyth, 24 bytes

```<code>Jj*4[*6+*5\/*5\\;j*3[J_J
</code>```

Try it!

Explanation:

```<code>Jj*4[*6+*5\/*5\\;j*3[J_J
   4                     4
      6                  6
         5               5
          \/             "/"
        *                Repeat
             5           5
              \\         "\\"
            *            Repeat
       +                 Concatenate
     *                   Repeat
    [                    List
  *                      Repeat
 j                       Join
J                        Assign copy to J
                ;        Close argument list
                   3     3
                     J   J
                       J J
                      _  Reverse
                    [    List
                  *      Repeat
                 j       Join
</code>```

Title: This is my pillow

Body:
Pyth, 24 bytes

Jj*4[*6+*5\/*5\\;j*3[J_J

Try it!

Explanation:

Jj*4[*6+*5\/*5\\;j*3[J_J
   4                     4
      6                  6
         5               5
          \/             "/"
        *                Repeat
             5           5
              \\         "\\"
            *            Repeat
       +                 Concatenate
     *                   Repeat
    [                    List
  *                      Repeat
 j                       Join
J                        Assign copy to J
                ;        Close argument list
                   3     3
                     J   J
                       J J
                      _  Reverse
                    [    List
                  *      Repeat
                 j       Join


问:
Wait... what was I going to say again?
I often forget what I wanted to say when the teacher calls on me to speak. Can you make me a tool to solve this?

Requirements:

The program must loop as follows:

First, take in input

If the input is empty, print the last stored question.

Otherwise, store the input as a question.

Notes:

The input will never be empty if there are no questions stored.

Clarification: The program does not need to store multiple questions. I originally wanted it to store multiple, but I changed it after many people misunderstood the question.

Remember, this is code-golf, so the code with the smallest number of bytes wins.

答:
Python 3, 60 bytes

q=[]
while 1:
 s=input()
 if''<s:q+=[s]
 else:print(q.pop())
```

Title: Wait... what was I going to say again?


答:
Perl, <s>151</s> <s>121</s> 111 + 3 = 114 bytes

Run with -lF.  The program will only function correctly for the first input.  Terminate the program and rerun for your next input.

Thanks to @Dada for letting me know the // after F were redundant.  An additional byte can be removed (for 112) by piping the input in via echo -n, but I feel that that's technically adding more code, so YMMV.

```<code>for$c(@a=map{sprintf"%07b",ord}@F){$b[$_].=substr$c,$_,1 for 0..6}s/0//g,$d|=/^1?$|^(11+?)\1+$/ for@a,@b;say!$d
</code>```

Readable:

```<code>                                     #Implicitly split input into characters in @F array
for$c(@a=map{sprintf"%07b",ord}@F)  #Convert @F to 7-bit binary as @a, then loop through it
    $b[$_].=substr$c,$_,1 for 0..6   #Transpose @a's bits into @b
}
s/0//g,$d|=/^1?$|^(11+?)\1+$/ for@a,@b; #Remove any zeros, then run through composite regex
say!$d                          #If all composite regex checks fail, then it's fully prime.
</code>```

Title: Primenary Strings

Body:
A Primenary (binary-prime) string is one which, when written as a binary grid, every row and column has a prime total.

That's quite a vague explanation, so let's break it down with a worked example...

For this example we'll use the string bunny:

First, find the ASCII code point of each character and its binary representation:

```<code>Char | ASCII | Binary

b      98      1100010
u      117     1110101
n      110     1101110
n      110     1101110
y      121     1111001
</code>```

Take these binary values, from top to bottom, and arrange them into grid (adding leading zeros if necessary):

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

Then, count the number of 1s in each row and column:

```<code>1 1 0 0 0 1 0   > 3
1 1 1 0 1 0 1   > 5
1 1 0 1 1 1 0   > 5
1 1 0 1 1 1 0   > 5
1 1 1 1 0 0 1   > 5

v v v v v v v

5 5 2 3 3 3 2
</code>```

If, and only if, every single total is prime (such as here) then the string is a valid binary-prime.

The Challenge

Your task is to create a function or program which, when given a string, returns/outputs truthy if the string is primenary, and falsy otherwise.

Rules/Details

You may assume that the string's characters will always be in the ASCII range 33-126 (inclusive).

The string will not be empty.

A primenary string does not have to have a prime length - for example, W1n* is valid, despite having 4 characters.

This is code-golf, so the shortest answer (in bytes) wins - but all submissions are welcome.

Standard loopholes are banned.

Test Cases

```<code>'husband'     -> True
'HOTJava'     -> True
'COmPaTIBILE' -> True
'AuT0HACk'    -> True

'PPCW'        -> False
'code-golf'   -> False
'C++'         -> False
'/kD'         -> False

'HI'          -> False
'A'           -> False
</code>```

There is also a working, but incredibly verbose Python example on repl.it that you can test your solution against.

Body:
Perl, <s>151</s> <s>121</s> 111 + 3 = 114 bytes

Run with -lF.  The program will only function correctly for the first input.  Terminate the program and rerun for your next input.

Thanks to @Dada for letting me know the // after F were redundant.  An additional byte can be removed (for 112) by piping the input in via echo -n, but I feel that that's technically adding more code, so YMMV.

for$c(@a=map{sprintf"%07b",ord}@F){$b[$_].=substr$c,$_,1 for 0..6}s/0//g,$d|=/^1?$|^(11+?)\1+$/ for@a,@b;say!$d

Readable:

                                     #Implicitly split input into characters in @F array
for$c(@a=map{sprintf"%07b",ord}@F)  #Convert @F to 7-bit binary as @a, then loop through it
    $b[$_].=substr$c,$_,1 for 0..6   #Transpose @a's bits into @b
}
s/0//g,$d|=/^1?$|^(11+?)\1+$/ for@a,@b; #Remove any zeros, then run through composite regex
say!$d                          #If all composite regex checks fail, then it's fully prime.


问:
Palindrome polyglot
Your task is to write a program that runs in two different languages, and does the following:

In one language, it palindromizes a given string.

Take the string. abcde

Reverse the string. edcba

Remove the first character. dcba

Glue it onto the original string. abcdedcba

In another language, it depalindromizes a given string.

Take a string palidromized by the above method. abcdedcba

Get the characters from the start to the middle. abcde

Remember, this is code-golf, so the code with the fewest characters (not bytes) wins.

Leaderboards

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

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

```<code># Language 1/Language 2, 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/Python, <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/C, 43 + 2 (-p flag) = 45 bytes
</code>```

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

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
05AB1E / MATL, <s>10</s> 9 characters

```<code>9LQ2/)%¹û
</code>```

In 05AB1E this palindromizes. In MATL it depalindromizes.

Explanation in 05AB1E

This part of the code does nothing (globally):

```<code>9L    Pushes array [1, 2, ... 9]
Q     Consumes the array, takes the input implicitly, and produces no output
2/    With no further input to take implicitly, this gives no output
)     Wrap stack into an array: gives an empty array
%     Consumes that array and, with no further input to take implicitly, gives no ouput
</code>```

This is the part that does the work:

```<code>¹     Push input again
û     Palindromize. Implicitly display
</code>```

Explanation in MATL

This is the part that does the work:

```<code>9L    Push array [0, 1j]
Q2/   Add 1, divide by two: transforms into [1/2, (1+1j)/2]
)     Use as index into implicit input. [1/2, (1+1j)/2] is interpreted as
      1/2:(end+1)/2, which is rounded to 1:(end+1)/2. So this takes elements
      from first to half, including both. Implicitly display
</code>```

This is ignored:

```<code>%¹û   Everything after '%' is a comment
</code>```

Title: Palindrome polyglot

Body:
05AB1E / MATL, <s>10</s> 9 characters

9LQ2/)%¹û

In 05AB1E this palindromizes. In MATL it depalindromizes.

Explanation in 05AB1E

This part of the code does nothing (globally):

9L    Pushes array [1, 2, ... 9]
Q     Consumes the array, takes the input implicitly, and produces no output
2/    With no further input to take implicitly, this gives no output
)     Wrap stack into an array: gives an empty array
%     Consumes that array and, with no further input to take implicitly, gives no ouput

This is the part that does the work:

¹     Push input again
û     Palindromize. Implicitly display

Explanation in MATL

This is the part that does the work:

9L    Push array [0, 1j]
Q2/   Add 1, divide by two: transforms into [1/2, (1+1j)/2]
)     Use as index into implicit input. [1/2, (1+1j)/2] is interpreted as
      1/2:(end+1)/2, which is rounded to 1:(end+1)/2. So this takes elements
      from first to half, including both. Implicitly display

This is ignored:

%¹û   Everything after '%' is a comment


答:
CJam / MATL, 18 characters

```<code>r_W%(;
"j9LQ2/)%";
</code>```

In CJam this palindromizes. In MATL it depalindromizes.

Explanation in CJam

Working part:

```<code>r           Read string
_           Duplicate
W%          Reverse
(;          Remove first element
</code>```

Dummy part:

```<code>"j9LQ2/)%"  Push this string
;           Remove it from the stack
            Implicitly display both strings obtained previously
</code>```

Explanation in MATL

Dummy part:

```<code>r           Push random number between 0 and 1
_           Negate
W           2 raised to that
%(;  Comment (ignored)
</code>```

Working part:

```<code>"           For each element in the array at the top of the stack. Since it is a number,
            which is the same as a length-1 array, the following is executed once
  j         Input string
  9L        Push array [0, 1j]
  Q2/       Add 1, divide by 2: transforms into [1/2, (1+1j)/2]
  )         Use as index. [1/2, (1+1j)/2] is interpreted as 1/2:(end+1)/2, which is
            rounded to 1:(1+end)/2. So this takes elements from first to half,
            including both
</code>```

Another dummy part:

```<code>   %";      Comment (ignored)
            Implicitly display the previously obtained string
</code>```

Title: Palindrome polyglot

Body:
Your task is to write a program that runs in two different languages, and does the following:

In one language, it palindromizes a given string.

Take the string. abcde

Reverse the string. edcba

Remove the first character. dcba

Glue it onto the original string. abcdedcba

In another language, it depalindromizes a given string.

Take a string palidromized by the above method. abcdedcba

Get the characters from the start to the middle. abcde

Remember, this is code-golf, so the code with the fewest characters (not bytes) wins.

Leaderboards

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

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

```<code># Language 1/Language 2, 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/Python, <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/C, 43 + 2 (-p flag) = 45 bytes
</code>```

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

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
CJam / MATL, 18 characters

r_W%(;
"j9LQ2/)%";

In CJam this palindromizes. In MATL it depalindromizes.

Explanation in CJam

Working part:

r           Read string
_           Duplicate
W%          Reverse
(;          Remove first element

Dummy part:

"j9LQ2/)%"  Push this string
;           Remove it from the stack
            Implicitly display both strings obtained previously

Explanation in MATL

Dummy part:

r           Push random number between 0 and 1
_           Negate
W           2 raised to that
%(;  Comment (ignored)

Working part:

"           For each element in the array at the top of the stack. Since it is a number,
            which is the same as a length-1 array, the following is executed once
  j         Input string
  9L        Push array [0, 1j]
  Q2/       Add 1, divide by 2: transforms into [1/2, (1+1j)/2]
  )         Use as index. [1/2, (1+1j)/2] is interpreted as 1/2:(end+1)/2, which is
            rounded to 1:(1+end)/2. So this takes elements from first to half,
            including both

Another dummy part:

   %";      Comment (ignored)
            Implicitly display the previously obtained string


答:
05AB1E, 15 bytes

```<code>'a'bVUFX,XYUYJV
</code>```

Title: Print a letter Fibonacci

Body:
Given N (2 <= N), print N lines of the letter Fibonacci series like this (i.e. N = 5)
First, start with a and b:

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

Next, add the two lines.

```<code>a
b
ab
</code>```

Keep adding the last two lines.

```<code>a
b
ab
bab
</code>```

Keep going...

```<code>a
b
ab
bab
abbab
</code>```

And we're done.

Remember, this is code-golf, so the code with the fewest bytes wins.

Body:
05AB1E, 15 bytes

'a'bVUFX,XYUYJV


答:
Jelly / CJam, <s>15</s> 14 chars

```<code>q_,2./m]<e#¶ŒB
</code>```

-1 char thanks to 42545 (ETHproductions)

Try it online! (Jelly) (Palindromization)

CJam interpreter (Depalindromization)

Jelly explanation:

In Jelly, ¶ is the same as \n, so this is what Jelly sees:

```<code>q_,2./m]<e#
ṖṚṭ

ṖṚṭ         Main link. Arguments: z
Ṗ           Pop
 Ṛ          Reverse
  ṭ         Append
   ⁸        (implicit) z
</code>```

CJam explanation:

In CJam, everything after e# on a line is a comment. So, this is what CJam sees:

```<code>q_,2./m]< Code
q         All input
 _        Duplicate
  ,       Length
   2.     2.0
     /    Float division
      m]  Ceil
        < Take
</code>```

Title: Palindrome polyglot

Body:
Jelly / CJam, <s>15</s> 14 chars

q_,2./m]<e#¶ŒB

-1 char thanks to 42545 (ETHproductions)

Try it online! (Jelly) (Palindromization)

CJam interpreter (Depalindromization)

Jelly explanation:

In Jelly, ¶ is the same as \n, so this is what Jelly sees:

q_,2./m]<e#
ṖṚṭ

ṖṚṭ         Main link. Arguments: z
Ṗ           Pop
 Ṛ          Reverse
  ṭ         Append
   ⁸        (implicit) z

CJam explanation:

In CJam, everything after e# on a line is a comment. So, this is what CJam sees:

q_,2./m]< Code
q         All input
 _        Duplicate
  ,       Length
   2.     2.0
     /    Float division
      m]  Ceil
        < Take


答:
DASH, 16 bytes

```<code>@len mstr"1+$"#0
</code>```

It's not the shortest possible DASH solution, but the shortest possible DASH solution is bugging out on me. I'm posting this novel approach in its place.

Usage:

```<code>(@len mstr"1+$"#0)"100111"
</code>```

Explanation

```<code>@(                 #. Lambda
  len (            #. Get the length of the array after...
    mstr "1+$" #0  #. ... matching the argument with regex /1+$/
  )                #. * mstr returns an empty array for no matches
)
</code>```

Title: Count trailing truths

Body:
DASH, 16 bytes

@len mstr"1+$"#0

It's not the shortest possible DASH solution, but the shortest possible DASH solution is bugging out on me. I'm posting this novel approach in its place.

Usage:

(@len mstr"1+$"#0)"100111"

Explanation

@(                 #. Lambda
  len (            #. Get the length of the array after...
    mstr "1+$" #0  #. ... matching the argument with regex /1+$/
  )                #. * mstr returns an empty array for no matches
)


答:
Jelly / Pyth, <s>15</s> 14 chars

```<code><Q.EclQ2*0"¶ŒB
</code>```

Credit where credit is due.

Try it online! (Jelly) (Palindromizes)

pyth.herokuapp.com (Pyth) (Depalindromizes) (trailing newline)

Title: Palindrome polyglot

Body:
Jelly / Pyth, <s>15</s> 14 chars

<Q.EclQ2*0"¶ŒB

Credit where credit is due.

Try it online! (Jelly) (Palindromizes)

pyth.herokuapp.com (Pyth) (Depalindromizes) (trailing newline)


答:
05AB1E / Jelly, 6 characters

Palindromizes in 05AB1E.

Depalindromizes in Jelly.

```<code>œs2Ḣ¹û
</code>```

Try it in 05AB1E

05AB1E Explanation

```<code>œ       # compute powerset of input
 s      # swap (does nothing)
  2     # push 2
   Ḣ    # does nothing
    ¹û  # palindromize input
</code>```

Try it in Jelly

Jelly Explanation

```<code>œs2     # split input in 2 chunks (first chunk is larger for odd length strings)
   Ḣ    # head, take first
    ¹û  # does nothing
</code>```

Title: Palindrome polyglot

Body:
05AB1E / Jelly, 6 characters

Palindromizes in 05AB1E.

Depalindromizes in Jelly.

œs2Ḣ¹û

Try it in 05AB1E

05AB1E Explanation

œ       # compute powerset of input
 s      # swap (does nothing)
  2     # push 2
   Ḣ    # does nothing
    ¹û  # palindromize input

Try it in Jelly

Jelly Explanation

œs2     # split input in 2 chunks (first chunk is larger for odd length strings)
   Ḣ    # head, take first
    ¹û  # does nothing


问:
N-dimensional Circles!
Write a program that takes two numbers as its input. The first one is the number of dimensions - 0 for a dot, 1 for a straight line, 2 for a circle, 3 for a sphere. The second number is the radius of the object, or, if it's 1-dimensional, the number itself. Output 0 for 0 dimensions. The output is the length/area/volume of the object.

If we call the first number n, the second one r, and the output x, we get that:

for n = 0, x = 1

for n = 1, x = 2×r

for n = 2, x = r2×π

for n = 3, x = (4/3)×r3×π

and so on... if you want, though.

Notes:

Cases when one or both numbers are negative, or when the first number is not whole, don't need to be covered.

The program must not read from any file and the only input are those two numbers.

The output should use only numerals (e.g. not "14*pi"), and should be accurate to at least two decimal digits.

As for n = 0, you can output 0 if it makes the code shorter.

Extra swag for an answer covering even 4 and more-dimensional "spheres"!

It's code-golf, so the shortest answer in bytes wins!

Examples:

```<code> 1 1 -> 2

 2 3 -> 28,27

 3 1 -> 4,19

 3 4,5 -> 381,70

 1 9.379 -> 18.758

 0 48 -> 1
</code>```

答:
Groovy, 49 47 bytes + extra swag!

Edit: Saved 2 bytes thanks to @AlexRacer

A dyadic function - first argument is number of dimensions, second is the radius of the n-ball.

def v(n,r){n<1?1:n<2?2*r:6.2832*r*r*v(n-2,r)/n}

Recursive formula for the volume of an n-ball:
Vn=(2πr2Vn-2)⁄n

Dynamic Typing FTW!

My Scala and Java answers use the same logic, but with static typing so higher byte counts due to type annotations :(. However, Scala and Groovy allow me to omit the return and the semicolon, so that helps the byte count, unlike Java/C...

Title: N-dimensional Circles!


答:
Scala, 81 79 bytes + extra swag!

Edit: Saved 2 bytes thanks to @AlexRacer

A dyadic function - first argument is number of dimensions, second is the radius of the n-ball.

def v(n:Int,r:Float):Float=if n<1 1 else if n<2 2*r else 6.2832f*r*r*v(n-2,r)/n

Recursive formula for the volume of an n-ball:
Vn=(2πr2Vn-2)⁄n

Scala's lack of type inference for return types of recursive functions and function parameters and verbose ternary syntax hurts quite a bit here :(

Title: N-dimensional Circles!

Body:
Write a program that takes two numbers as its input. The first one is the number of dimensions - 0 for a dot, 1 for a straight line, 2 for a circle, 3 for a sphere. The second number is the radius of the object, or, if it's 1-dimensional, the number itself. Output 0 for 0 dimensions. The output is the length/area/volume of the object.

If we call the first number n, the second one r, and the output x, we get that:

for n = 0, x = 1

for n = 1, x = 2×r

for n = 2, x = r2×π

for n = 3, x = (4/3)×r3×π

and so on... if you want, though.

Notes:

Cases when one or both numbers are negative, or when the first number is not whole, don't need to be covered.

The program must not read from any file and the only input are those two numbers.

The output should use only numerals (e.g. not "14*pi"), and should be accurate to at least two decimal digits.

As for n = 0, you can output 0 if it makes the code shorter.

Extra swag for an answer covering even 4 and more-dimensional "spheres"!

It's code-golf, so the shortest answer in bytes wins!

Examples:

```<code> 1 1 -> 2

 2 3 -> 28,27

 3 1 -> 4,19

 3 4,5 -> 381,70

 1 9.379 -> 18.758

 0 48 -> 1
</code>```


答:
Java/C/C++/C#, 69 67 bytes + extra swag!

Edit: Saved 2 bytes thanks to @AlexRacer

A dyadic function - first argument is number of dimensions, second is the radius of the n-ball.

float v(int n,float r){return n<1?1:n<2?2*r:6.283f*r*r*v(n-2,r)/n;}

Recursive formula for the volume of an n-ball:
Vn=(2πr2Vn-2)⁄n

Whoa! Java (my test language) beats Scala here, thanks to the terse ?: ternary syntax! This function is syntactically correct in all 4 languages in the heading, and I have tested it with C (MinGW GCC 5.4.0), & C# (VS Ultimate 2016, C# 6.0). I'm assuming that it will work in C++ too, so there. Since this function is pretty much library-independent, it should work in any C-like language with similar syntax.

Title: N-dimensional Circles!


答:
Scala, 25 bytes

```<code>l=>l.reverse:+0 indexOf 0
</code>```

Ungolfed:

```<code>l=>(l.reverse :+ 0).indexOf(0)
</code>```

Reverses the list, appends a 0 and find the first index of 0, which is the number of elements before the first 0

Title: Count trailing truths

Body:
Inspired by, and in memory of, my dear friend and colleague,

Dan Baronet, 1956 – 2016. R.I.P.

He found the shortest possible APL solution to this task:

Task

Given a Boolean list, count the number of trailing truth values.

Example cases

{} → 0

{0} → 0

{1} → 1

{0, 1, 1, 0, 0} → 0

{1, 1, 1, 0, 1} → 1

{1, 1, 0, 1, 1} → 2

{0, 0, 1, 1, 1} → 3

{1, 1, 1, 1, 1, 1} → 6

Body:
Scala, 25 bytes

l=>l.reverse:+0 indexOf 0

Ungolfed:

l=>(l.reverse :+ 0).indexOf(0)

Reverses the list, appends a 0 and find the first index of 0, which is the number of elements before the first 0


答:
Python 2 / Nim, <s>76</s> 74 bytes

```<code>#[
s=input();print s+s[-2::-1]#let s=stdin.readLine;echo s[0..s.len div 2]
</code>```

Palindromizes in Python, depalindromizes in Nim. Abuses comment syntax.

Python and Nim both use # for comments. Python doesn't support block comments at all (except for multiline strings with """), but Nim does with #[ comment ]#.

We abuse this to comment out the Python (at the beginning) for Nim, then use the trailing ] in the Python to start the Nim code, looking like a comment for Python.

The Python code requires its input surrounded with quotes. The Nim code doesn't have this restriction.

Tested on Python 2.7.8 and Nim 0.14.2.

Ideone it! -- Python 2, palindromizing

<s>Ideone it! -- Nim, depalindromizing</s> Apparently the version of Nim Ideone uses (0.11.2) doesn't support multiline comments. Works on Nim 0.14.2.

Title: Palindrome polyglot

Body:
Python 2 / Nim, <s>76</s> 74 bytes

#[
s=input();print s+s[-2::-1]#let s=stdin.readLine;echo s[0..s.len div 2]

Palindromizes in Python, depalindromizes in Nim. Abuses comment syntax.

Python and Nim both use # for comments. Python doesn't support block comments at all (except for multiline strings with """), but Nim does with #[ comment ]#.

We abuse this to comment out the Python (at the beginning) for Nim, then use the trailing ] in the Python to start the Nim code, looking like a comment for Python.

The Python code requires its input surrounded with quotes. The Nim code doesn't have this restriction.

Tested on Python 2.7.8 and Nim 0.14.2.

Ideone it! -- Python 2, palindromizing

<s>Ideone it! -- Nim, depalindromizing</s> Apparently the version of Nim Ideone uses (0.11.2) doesn't support multiline comments. Works on Nim 0.14.2.


答:
 / Javascript ES6, 55 chars

```<code>this._?Σ(`ï+ï.Ħ⬮.Đ1`):(x=prompt()).slice(0,-x.length/2)
</code>```

Try it here (ES6 browsers only).

Palindromizes in , depalindromizes in Javascript ES6.

I though this was going to be easy, since  compiles to ES6 and most of ES6 can be run in . Apparently, I'm completely wrong.

Explanation

this._ checks to see if variable _ exists in the global scope;  uses Lodash and therefore has _ stored, but pure ES6 doesn't.

The  segment - Σ(`ï+ï.Ħ⬮.Đ1`) - evaluates from string the code that palindromizes input. Normally, the code would be ï+ïĦ⬮Đ1, but I put the dots in to make the compiler happy.

The Javascript segment - (x=prompt()).slice(0,-x.length/2) - depalindromizes a string from a prompt.

I was going to use a function (so I didn't have to deal with prompt), but 's evaluation function didn't like that, so I used prompt and no function to make the compiler happy.

Title: Palindrome polyglot

Body:
 / Javascript ES6, 55 chars

this._?Σ(`ï+ï.Ħ⬮.Đ1`):(x=prompt()).slice(0,-x.length/2)

Try it here (ES6 browsers only).

Palindromizes in , depalindromizes in Javascript ES6.

I though this was going to be easy, since  compiles to ES6 and most of ES6 can be run in . Apparently, I'm completely wrong.

Explanation

this._ checks to see if variable _ exists in the global scope;  uses Lodash and therefore has _ stored, but pure ES6 doesn't.

The  segment - Σ(`ï+ï.Ħ⬮.Đ1`) - evaluates from string the code that palindromizes input. Normally, the code would be ï+ïĦ⬮Đ1, but I put the dots in to make the compiler happy.

The Javascript segment - (x=prompt()).slice(0,-x.length/2) - depalindromizes a string from a prompt.

I was going to use a function (so I didn't have to deal with prompt), but 's evaluation function didn't like that, so I used prompt and no function to make the compiler happy.


问:
Probability of All Combinations of Given Events
Given a sequences of events with probabilities between 0.0 and 1.0, generate and derive the probability of each combination occurring. You may presume that a sequence of numbers is provided in whatever construct your chosen language provides.

Here's an example; you may presume that the length of the sequence's combinations fit into memory:

```<code>{ 0.55, 0.67, 0.13 }
</code>```

The program shall print each combination and the associated probability of that sequence occurring. A 1 shall denote that the event in that index of the input sequence occurred and a 0 shall denote that that event did not occur. The desired output is below (I don't care about printing the work, that's just for informational purposes of the algorithm):

```<code>[0,0,0] = (1 - 0.55) * (1-0.67) * (1-0.13) = 0.129195
[0,0,1] = (1 - 0.55) * (1-0.67) * (0.13)   = 0.019305
[0,1,0] = (1 - 0.55) * (0.67)   * (1-0.13) = 0.262305
[0,1,1] = (1 - 0.55) * (0.67)   * (0.13)   = 0.039195
[1,0,0] = (0.55)     * (1-0.67) * (1-0.13) = 0.157905
[1,0,1] = (0.55)     * (1-0.67) * (0.13)   = 0.023595
[1,1,0] = (0.55)     * (0.67)   * (1-0.13) = 0.320595
[1,1,1] = (0.55)     * (0.67)   * (0.13)   = 0.047905
</code>```

This problem is tangentially related to calculating a "Cartesian product".

Remember, this is code-golf, so the code with the fewest number of bytes wins.

答:
JavaScript (Firefox 30-57), 57 bytes

```<code>f=([p,...a])=>1/p?[for(q of[1-p,p])for(b of f(a))q*b]:[1]
</code>```

Returns an array of all the probabilities. If you want the array of events too, then for 86 bytes:

```<code>f=([p,...a])=>1/p?[for(e of'01')for(b of f(a))[[+e,...b[0]],(+e?p:1-p)*b[1]]]:[[[],1]]
</code>```

If you're allowed the events as a string, then it's only 80 bytes:

```<code>f=([p,...a])=>1/p?[for(e of'01')for(b of f(a))[e+b[0],(+e?p:1-p)*b[1]]]:[['',1]]
</code>```

Subtract two bytes for 1/ for each solution if the probability is never going to be zero.

Body:
JavaScript (Firefox 30-57), 57 bytes

f=([p,...a])=>1/p?[for(q of[1-p,p])for(b of f(a))q*b]:[1]

Returns an array of all the probabilities. If you want the array of events too, then for 86 bytes:

f=([p,...a])=>1/p?[for(e of'01')for(b of f(a))[[+e,...b[0]],(+e?p:1-p)*b[1]]]:[[[],1]]

If you're allowed the events as a string, then it's only 80 bytes:

f=([p,...a])=>1/p?[for(e of'01')for(b of f(a))[e+b[0],(+e?p:1-p)*b[1]]]:[['',1]]

Subtract two bytes for 1/ for each solution if the probability is never going to be zero.


答:
Haskell, 52 bytes for tab indent 42 bytes + extra swag

Edit: Saved 10 bytes thanks to @WChargin

A dyadic curried function - first argument is number of dimensions, second is the radius of the n-ball.

```<code>v 0 r=1
v 1 r=2*r
v n r=2*pi*r*r*v(n-2)r/n
</code>```

Recursive formula for the volume of an n-ball:
Vn=(2πr2Vn-2)⁄n

Save this as a separate script file and run with GHCi, with a function for testing v for output, e.g., show (v 3 4.5). I did not test this, please let me know if this doesn't work.

Old program with 6.2832 approximation for 2π replaced (50 bytes with tab indent):

```<code>let v 0 r=1
    v 1 r=2*r
    v n r=2*pi*r*r*(v(n-2)r)/n
</code>```

This can be used with GHCi in multiline mode (using :set +m or enclosing the code between :{ & :}, the enclosures being on their own lines. Tester function required.

Static typing with full-program type inference comes into play here, allowing Haskell to do far better than Scala, and approaching Groovy, but not quite beating it thanks to the pattern match instead of a ternary, involving some character repetition.

Title: N-dimensional Circles!

Body:
Haskell, 52 bytes for tab indent 42 bytes + extra swag

Edit: Saved 10 bytes thanks to @WChargin

A dyadic curried function - first argument is number of dimensions, second is the radius of the n-ball.

v 0 r=1
v 1 r=2*r
v n r=2*pi*r*r*v(n-2)r/n

Recursive formula for the volume of an n-ball:
Vn=(2πr2Vn-2)⁄n

Save this as a separate script file and run with GHCi, with a function for testing v for output, e.g., show (v 3 4.5). I did not test this, please let me know if this doesn't work.

Old program with 6.2832 approximation for 2π replaced (50 bytes with tab indent):

let v 0 r=1
    v 1 r=2*r
    v n r=2*pi*r*r*(v(n-2)r)/n

This can be used with GHCi in multiline mode (using :set +m or enclosing the code between :{ & :}, the enclosures being on their own lines. Tester function required.

Static typing with full-program type inference comes into play here, allowing Haskell to do far better than Scala, and approaching Groovy, but not quite beating it thanks to the pattern match instead of a ternary, involving some character repetition.


问:
The nth numerator
You can create a list of all rationals 0 < r ≤ 1 by listing them ordered first by denominator and then by numerator:

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

Note that we skip any rational number that already occurred before. E.g. 2/4 is skipped because we already listed 1/2.

In this challenge we're interested in the numerators only. Looking at the list above, write a function or program taking a positive integer n that returns the nth numerator from the list.

Testcases:

```<code>1 -> 1
2 -> 1
3 -> 1
4 -> 2
5 -> 1
6 -> 3
7 -> 1
8 -> 2
9 -> 3
50 -> 4
80 -> 15
</code>```

答:
JavaScript (ES6), 95 bytes

```<code>n=>[...Array(n*n).keys()].filter(i=>i%n<=i/n&g(i%n+1,i/n+1|0)<2,g=(a,b)=>b?g(b,a%b):a)[n-1]%n+1
</code>```

Works by generating all n² fractions with numerators and denominators from 1 to n and filtering out those greater than 1 or previously seen, then taking the nth.

Title: The nth numerator

Body:
JavaScript (ES6), 95 bytes

n=>[...Array(n*n).keys()].filter(i=>i%n<=i/n&g(i%n+1,i/n+1|0)<2,g=(a,b)=>b?g(b,a%b):a)[n-1]%n+1

Works by generating all n² fractions with numerators and denominators from 1 to n and filtering out those greater than 1 or previously seen, then taking the nth.


答:
Scala / Javascript, 106 bytes

```<code>/*\u002A/print(args(0)+args(0).reverse.tail)//*/
/*/**/
alert((s=prompt()).slice(0,-s.length/2))//\u000A*/
</code>```

Palindromizes in scala and depalindromizes in javascript.

Try it on ideone (scala) - Warning: wrong syntax highlighting

Try it on jsfiddle (javascript).

Explanation:

Scala, like java, processes unicode escapes before everything else, so scalac sees the code like this:

```<code>/**/                                //\u002A is as asterisk, results in an empty block comment
print(args(0)+args(0).reverse.tail) //scala code
//*/                                //a line comment
/*                                  //scala supports nested block comments, so this comment...
  /*
  */
  alert((s=prompt()).slice(0,-s.length/2))
  //                                  //\u000A (newline) inserted here
*/                                  //...ends here
</code>```

The javascript gets parsed like this:

```<code>/*\u002A/print(args(0)+args(0).reverse.tail)//*/ //block comment
/*                                               //a block comment...
  /*
*/                                               //...ending here, no nesting
alert((s=prompt()).slice(0,-s.length/2))         //code
//\u000A*/                                       //line comment
</code>```

Title: Palindrome polyglot

Body:
Scala / Javascript, 106 bytes

/*\u002A/print(args(0)+args(0).reverse.tail)//*/
/*/**/
alert((s=prompt()).slice(0,-s.length/2))//\u000A*/

Palindromizes in scala and depalindromizes in javascript.

Try it on ideone (scala) - Warning: wrong syntax highlighting

Try it on jsfiddle (javascript).

Explanation:

Scala, like java, processes unicode escapes before everything else, so scalac sees the code like this:

/**/                                //\u002A is as asterisk, results in an empty block comment
print(args(0)+args(0).reverse.tail) //scala code
//*/                                //a line comment
/*                                  //scala supports nested block comments, so this comment...
  /*
  */
  alert((s=prompt()).slice(0,-s.length/2))
  //                                  //\u000A (newline) inserted here
*/                                  //...ends here

The javascript gets parsed like this:

/*\u002A/print(args(0)+args(0).reverse.tail)//*/ //block comment
/*                                               //a block comment...
  /*
*/                                               //...ending here, no nesting
alert((s=prompt()).slice(0,-s.length/2))         //code
//\u000A*/                                       //line comment


问:
Next Friday the 13th
What is the shortest program that can predict the next time Friday will fall on the 13th day of the month?

Must be an complete functioning program (not just a function/subroutine)

Must print out date in the following format: YYYY-MM-DD

Allow user to provide a start date either as a command line argument or through STDIN

If user provides no start date, use today as the start date.

If the start date is a Friday the 13th, the program should find the next Friday the 13th.

If I were to run the program today (Feb 16 2011) I should get the following output.

```<code>$ ./fr13th 2013-05-09
2013-09-13
$ ./fr13th 2007-06-29
2007-07-13
$ ./fr13th 2007-07-13
2008-06-13
$ ./fr13th
2011-05-13
</code>```

答:
C#, 206 194 characters

Update

This is a slightly different take on the problem, so I left my other attempt here in full.

```<code>using System:class p{static void Main(string[]a){var n=a.Length>0?DateTime.Parse(a[0]):DateTime.Now;for(;(n=n.AddDays(5-(int)n.DayOfWeek).AddDays(7)).Day!=13;);Console.Write("{0:yyy-MM-d}",n);}}
</code>```

Here, I'm finding the "current" week's Friday and then incrementing by 7 until I find one that's a 13. I also used Joey's for loop and output formatting to shave a few characters.

Ungolfed:

```<code>using System;
class p
{
    static void Main(string[] a)
    {
        var n = a.Length > 0 ? DateTime.Parse(a[0]) : DateTime.Now;

        for (; (n = n.AddDays(5 - (int)n.DayOfWeek).AddDays(7)).Day != 13; ) ;

        Console.Write("{0:yyy-MM-d}", n);
    }
}
</code>```

Original:

This is similar to Andrew's above, but there were enough differences I decided to post a separate answer rather than comment and suggest edits.

```<code>using System;class p{static void Main(string[]a){var n=a.Length>0?DateTime.Parse(a[0]):DateTime.Now;do n=n.AddDays(1);while(!(n.Day==13&&n.DayOfWeek+""=="Friday"));Console.Write(n.ToString("yyyy-MM-dd"));}}
</code>```

Ungolfed:

```<code>using System;
class p
{
    static void Main(string[] a)
    {
        var n = a.Length > 0 ? DateTime.Parse(a[0]) : DateTime.Now;
        do
        {
            n = n.AddDays(1);
        } while (!(n.Day == 13 && n.DayOfWeek + "" == "Friday"));

        Console.Write(n.ToString("yyyy-MM-dd"));
    }
}
</code>```

ContentLicense: CC BY-SA 2.5

Title: Next Friday the 13th

Body:
C#, 206 194 characters

Update

This is a slightly different take on the problem, so I left my other attempt here in full.

using System:class p{static void Main(string[]a){var n=a.Length>0?DateTime.Parse(a[0]):DateTime.Now;for(;(n=n.AddDays(5-(int)n.DayOfWeek).AddDays(7)).Day!=13;);Console.Write("{0:yyy-MM-d}",n);}}

Here, I'm finding the "current" week's Friday and then incrementing by 7 until I find one that's a 13. I also used Joey's for loop and output formatting to shave a few characters.

Ungolfed:

using System;
class p
{
    static void Main(string[] a)
    {
        var n = a.Length > 0 ? DateTime.Parse(a[0]) : DateTime.Now;

        for (; (n = n.AddDays(5 - (int)n.DayOfWeek).AddDays(7)).Day != 13; ) ;

        Console.Write("{0:yyy-MM-d}", n);
    }
}

Original:

This is similar to Andrew's above, but there were enough differences I decided to post a separate answer rather than comment and suggest edits.

using System;class p{static void Main(string[]a){var n=a.Length>0?DateTime.Parse(a[0]):DateTime.Now;do n=n.AddDays(1);while(!(n.Day==13&&n.DayOfWeek+""=="Friday"));Console.Write(n.ToString("yyyy-MM-dd"));}}

Ungolfed:

using System;
class p
{
    static void Main(string[] a)
    {
        var n = a.Length > 0 ? DateTime.Parse(a[0]) : DateTime.Now;
        do
        {
            n = n.AddDays(1);
        } while (!(n.Day == 13 && n.DayOfWeek + "" == "Friday"));

        Console.Write(n.ToString("yyyy-MM-dd"));
    }
}


答:
APL, 30 bytes

```<code>A←240⍴'/////\\\\\'⋄24 60⍴A,⊖A
</code>```

I'm quite new to APL, (I'm using APLX, but this should work across most implementations of APL), so this is a quite simplistic solution.

Explanation:

```<code>A ← 240 ⍴ '/////\\\\\' ⍝ set A to be a 240 character vector populated with '/////\\\\\'
⋄                      ⍝ statement separator
24 60 ⍴ A,⊖A           ⍝ populate a 24 by 60 character matrix with the concatenation
                          of A and the reverse of A (⊖A)
</code>```

Title: This is my pillow

Body:
...will you help me immortalize it?

I've had this pillow a few years now, and apparently it's time to get rid of it. Can you please write a function or program, that I can bring with me and use to recreate this pillow whenever I want to reminisce a bit.

It must work with no input arguments.

The output should look exactly like this (trailing newlines and spaces are OK).

```<code>/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////\\\\\/////
</code>```

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

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
APL, 30 bytes

A←240⍴'/////\\\\\'⋄24 60⍴A,⊖A

I'm quite new to APL, (I'm using APLX, but this should work across most implementations of APL), so this is a quite simplistic solution.

Explanation:

A ← 240 ⍴ '/////\\\\\' ⍝ set A to be a 240 character vector populated with '/////\\\\\'
⋄                      ⍝ statement separator
24 60 ⍴ A,⊖A           ⍝ populate a 24 by 60 character matrix with the concatenation
                          of A and the reverse of A (⊖A)


问:
Minimum insertions to make palindrome
Today you will be doing another palindrome challenge!

So, your task today is to take a string, and determine the minimum amount of letters required to insert to turn it into a palindrome.

For example, let's take the string fishes.

In this, case the best way would be to add h if, so the result would be 3.

```<code>fishe s
     h if
---------
fishehsif
</code>```

Now let's try with codegolf. Since there is a repeated o, we can just do:

```<code>  codeg  o lf
fl     ed c
-------------
flcodegedoclf
</code>```

to get a result of 5.

Test cases

```<code>ppcg -> 2
codegolf -> 5
palindrome -> 9
stackexchange -> 8
programmingpuzzlesandcodegolf -> 20
</code>```

答:
05AB1E, 11 bytes

Uses CP-1252 encoding.

```<code>ÂæsæÃ¤g¹g-Ä
</code>```

Try it online! or as a Test suite

Explanation

```<code>              # implicit input
Â             # push a reversed copy
 æ            # compute powerset of the reversed string
  sæ          # compute powerset of the string
    Ã¤g       # get length of the longest common subset
      ¹g-     # subtract the length of the original string
         Ä    # take absolute value
</code>```

Title: Minimum insertions to make palindrome

Body:
05AB1E, 11 bytes

Uses CP-1252 encoding.

ÂæsæÃ¤g¹g-Ä

Try it online! or as a Test suite

Explanation

              # implicit input
Â             # push a reversed copy
 æ            # compute powerset of the reversed string
  sæ          # compute powerset of the string
    Ã¤g       # get length of the longest common subset
      ¹g-     # subtract the length of the original string
         Ä    # take absolute value


答:
Batch, <s>234</s> 232 bytes

```<code>@echo off
set n=99
call:l 0 %1
echo %n%
exit/b
:g
set/am=%1
if %m% lss %n% set/an=m
exit/b
:l
if "%2"=="" goto g
set s=%2
if %s:~,1%==%s:~-1% call:l %1 %s:~1,-1%&exit/b
call:l %1+1 %s:~1%
set s=%2
call:l %1+1 %s:~,-1%
</code>```

Works by recursively trying to insert nonmatching characters at both ends, so very slow (I didn't try the last test case). Recursion limits mean that this only works for a limited string length anyway, so the 99 is somewhat arbitrary. I have to use call parameters as local variables as I couldn't get setlocal to work for me, which means that %1 parameter to the :l subroutine is an expression that evaluates to the number of insertions done so far.

Title: Minimum insertions to make palindrome

Body:
Today you will be doing another palindrome challenge!

So, your task today is to take a string, and determine the minimum amount of letters required to insert to turn it into a palindrome.

For example, let's take the string fishes.

In this, case the best way would be to add h if, so the result would be 3.

```<code>fishe s
     h if
---------
fishehsif
</code>```

Now let's try with codegolf. Since there is a repeated o, we can just do:

```<code>  codeg  o lf
fl     ed c
-------------
flcodegedoclf
</code>```

to get a result of 5.

Test cases

```<code>ppcg -> 2
codegolf -> 5
palindrome -> 9
stackexchange -> 8
programmingpuzzlesandcodegolf -> 20
</code>```

Body:
Batch, <s>234</s> 232 bytes

@echo off
set n=99
call:l 0 %1
echo %n%
exit/b
:g
set/am=%1
if %m% lss %n% set/an=m
exit/b
:l
if "%2"=="" goto g
set s=%2
if %s:~,1%==%s:~-1% call:l %1 %s:~1,-1%&exit/b
call:l %1+1 %s:~1%
set s=%2
call:l %1+1 %s:~,-1%

Works by recursively trying to insert nonmatching characters at both ends, so very slow (I didn't try the last test case). Recursion limits mean that this only works for a limited string length anyway, so the 99 is somewhat arbitrary. I have to use call parameters as local variables as I couldn't get setlocal to work for me, which means that %1 parameter to the :l subroutine is an expression that evaluates to the number of insertions done so far.


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

答:
Use pwd instead of echo to generate a line of output

Need to put a line on stdout but don't care about the contents, and want to restrict your answer to shell builtins? pwd is a byte shorter than echo.

Title: Tips for golfing in Bash