答:
Octave, <s>39</s> 35 bytes

```<code>@(x)[x'+~x;flip(x'+~x),''](1:end/2)

f('Hello!')
ans = Hello!!olleHHello!!olleHHello!!olleH
</code>```

Explanation:

```<code>@(x)            % Take x as input, inside apostrophes 'Hello!'
x'+~x           % Create a mesh of the ASCII-code of the input letters
                % For input `bcd` this will be:
                %    98    98    98
                %    99    99    99
                %   100   100   100
;flip(x'+~x)   % Concatenate vertically to create:
                %    98    98    98
                %    99    99    99
                %   100   100   100
                %   100   100   100
                %    99    99    99
                %    98    98    98
___,'']         % Short cut to convert ASCII-code to characters
(1:end/2)       % Display the first half of this array of letters, as a
                % horizontal string
</code>```

Saved 4 bytes thanks to Luis. ~x instead of 0*x saved one byte (works because all elements of x are non-zero. flip instead of flipud saved another two bytes (I didn't know flip existed).

Title: StringgnirtSStringgnirtSStringgnirtS

Body:
Octave, <s>39</s> 35 bytes

@(x)[x'+~x;flip(x'+~x),''](1:end/2)

f('Hello!')
ans = Hello!!olleHHello!!olleHHello!!olleH

Explanation:

@(x)            % Take x as input, inside apostrophes 'Hello!'
x'+~x           % Create a mesh of the ASCII-code of the input letters
                % For input `bcd` this will be:
                %    98    98    98
                %    99    99    99
                %   100   100   100
;flip(x'+~x)   % Concatenate vertically to create:
                %    98    98    98
                %    99    99    99
                %   100   100   100
                %   100   100   100
                %    99    99    99
                %    98    98    98
___,'']         % Short cut to convert ASCII-code to characters
(1:end/2)       % Display the first half of this array of letters, as a
                % horizontal string

Saved 4 bytes thanks to Luis. ~x instead of 0*x saved one byte (works because all elements of x are non-zero. flip instead of flipud saved another two bytes (I didn't know flip existed).


问:
StringgnirtSStringgnirtSStringgnirtS
Here is a relatively simple challenge for you.

Given a string of length N, output the string forwards, then backwards, then forwards, then backwards... etc. N times. For example, if your input was

```<code>Hello!
</code>```

You should output:

```<code>Hello!!olleHHello!!olleHHello!!olleH
</code>```

You may also optionally output one trailing newline.

Your submission may be either a full program or a function, and you may take input and output in any reasonable format. For example, you may take IO from STDIN/STDOUT, function arguments and return value, from a file, etc. You can safely assume that the input string will not be empty, and will only contain printable ASCII. You must output the new string on a single line. So, for example, if the output to the last example was

```<code>Hello!
!olleH
Hello!
!olleH
Hello!
!olleH
</code>```

This would not be a valid solution!

Here are some more test cases:

```<code>Input:
a
Output:
a

Input:
abcd
Output:
abcddcbaabcddcba

Input:
OK!
Output:
OK!!KOOK!

Input:
4815162342
Output:
4815162342243261518448151623422432615184481516234224326151844815162342243261518448151623422432615184

Input:
PPCG
Output:
PPCGGCPPPPCGGCPP

Input:
42
Output:
4224
</code>```

Leaderboards

Since this is a code-golf challenge, standard loopholes are banned, and the shortest answer in bytes wins! However, this is also a competition to have the shortest answer in any particular langauge. While it's unlikely that a Java answer will beat an answer in perl, or some golfing language, it's still very impressive to have the shortest Java answer. So, you can use this leaderboard to see both

The shortest answer out of all languages, and

The shortest answer in each individual language.

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

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

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

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

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

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

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

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

var QUESTION_ID=93261,OVERRIDE_USER=31716;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

```

答:
Straw, 10 bytes

```<code><:(:>"),*&
</code>```

Try it online!

```<code><:(:>"),*&
<          Take the input       (Stack: ["", input])
 :         Duplicate            (Stack: ["", input, input])
  (        Start a string
   :       Duplicate
    >      Output
     "     Reverse
      )    End the string       (Stack: ["", input, input, ':>"'])
       ,   Swap                 (Stack: ["", input, ':>"', input])
        *  Unary multiplication (Stack: ["", input, ':>"'*length of input])
         & Evaluate             (Stack: ["", input])
</code>```

ContentLicense: CC BY-SA 3.0

Title: StringgnirtSStringgnirtSStringgnirtS

Body:
Straw, 10 bytes

<:(:>"),*&

Try it online!

<:(:>"),*&
<          Take the input       (Stack: ["", input])
 :         Duplicate            (Stack: ["", input, input])
  (        Start a string
   :       Duplicate
    >      Output
     "     Reverse
      )    End the string       (Stack: ["", input, input, ':>"'])
       ,   Swap                 (Stack: ["", input, ':>"', input])
        *  Unary multiplication (Stack: ["", input, ':>"'*length of input])
         & Evaluate             (Stack: ["", input])


问:
Write a Polyquine
A polyquine is both quine and polyglot.1 You are to write a quine which is valid in at least two different languages. This is code golf, so the shortest answer (in bytes) wins.

1 I made that up. Or rather, Geobits did. Apparently, he wasn't the first one either, though.

Rules for Quines

Only true quines are accepted. That is, you need to print the entire source code verbatim to STDOUT, without:

reading your source code, directly or indirectly.

relying on a REPL environment which just simply evaluates and prints every expression you feed it.

relying on language features which just print out the source in certain cases.

using error messages or STDERR to write all or part of the quine. (You may write things to STDERR or produce warnings/non-fatal errors as long as STDOUT is a valid quine and the error messages are not part of it.)

Furthermore, your code must contain a string literal.

Rules for Polyglots

The two languages used must be distinctly different. In particular:

They must not be different versions of the same language (e.g. Python 2 vs. Python 3).

They must not be different dialects of the same language (e.g. Pascal vs. Delphi).

One language may not be a subset of the other one (e.g. C vs. C++).

答:
C#/Java, 746 bytes

I use the property that chars in Java can be written as identical unicode sequences. If we have A instruction for C# compiler and B instruction for Java, we can use the following code fragment:

//\u000A\u002F\u002A
A//\u002A\u002FB
```

<p>It will be "recognized" by the following way with C#:</p>

<pre class="lang-cs prettyprint-override"><code>//\u000A\u002F\u002A
A//\u002A\u002FB
</code>```

And by the following way by Java:

//
/*
A//*/B
```

<p>Because of <code>\u000A</code> is line break, <code>\u002F</code> is <code>/</code> and <code>\u002A</code> is <code>*</code> in Java.</p>

<p>So the final polyglot-quine is:</p>

<pre class="lang-cs prettyprint-override"><code>//\u000A\u002F\u002A
using System;//\u002A\u002F
class Program{public static void//\u000A\u002F\u002A
Main//\u002A\u002Fmain
(String[]z){String s="//@#'^using System;//'#^class Program{public static void//@#'^Main//'#main^(String[]z){String s=!$!,t=s;int[]a=new int[]{33,94,38,64,35,39,36};String[]b=new String[]{!&!!,!&n!,!&&!,!&@!,!&#!,!&'!,s};for(int i=0;i<7;i++)t=t.//@#'^Replace//'#replace^(!!+(char)a[i],b[i]);//@#'^Console.Write//'#System.out.printf^(t);}}",t=s;int[]a=new int[]{33,94,38,64,35,39,36};String[]b=new String[]{"\"","\n","\\","\\u000A","\\u002F","\\u002A",s};for(int i=0;i<7;i++)t=t.//\u000A\u002F\u002A
Replace//\u002A\u002Freplace
(""+(char)a[i],b[i]);//\u000A\u002F\u002A
Console.Write//\u002A\u002FSystem.out.printf
(t);}}
</code>```

However, the size is too huge because of languages verbosity.

Compilation available on ideone.com: C#, Java.

Title: Write a Polyquine

Body:
C#/Java, 746 bytes

I use the property that chars in Java can be written as identical unicode sequences. If we have A instruction for C# compiler and B instruction for Java, we can use the following code fragment:

//\u000A\u002F\u002A
A//\u002A\u002FB

It will be "recognized" by the following way with C#:

//\u000A\u002F\u002A
A//\u002A\u002FB

And by the following way by Java:

//
/*
A//*/B

Because of \u000A is line break, \u002F is / and \u002A is * in Java.

So the final polyglot-quine is:

//\u000A\u002F\u002A
using System;//\u002A\u002F
class Program{public static void//\u000A\u002F\u002A
Main//\u002A\u002Fmain
(String[]z){String s="//@#'^using System;//'#^class Program{public static void//@#'^Main//'#main^(String[]z){String s=!$!,t=s;int[]a=new int[]{33,94,38,64,35,39,36};String[]b=new String[]{!&!!,!&n!,!&&!,!&@!,!&#!,!&'!,s};for(int i=0;i<7;i++)t=t.//@#'^Replace//'#replace^(!!+(char)a[i],b[i]);//@#'^Console.Write//'#System.out.printf^(t);}}",t=s;int[]a=new int[]{33,94,38,64,35,39,36};String[]b=new String[]{"\"","\n","\\","\\u000A","\\u002F","\\u002A",s};for(int i=0;i<7;i++)t=t.//\u000A\u002F\u002A
Replace//\u002A\u002Freplace
(""+(char)a[i],b[i]);//\u000A\u002F\u002A
Console.Write//\u002A\u002FSystem.out.printf
(t);}}

However, the size is too huge because of languages verbosity.

Compilation available on ideone.com: C#, Java.


问:
Invert a boolean array
A nice simple one

Input

Given a boolean array (Or an acceptable alternative), you can assume the array will never be more than 32 elements long.

```<code>[false, false, true, false, false]
</code>```

Output

Invert every element of the array and output it.

```<code>[true, true, false, true, true]
</code>```

Rules

You can write a full program or just a function

Standard loopholes apply

Shortest code in bytes, per language, wins!

Test cases

```<code>Input:
[true, false]
Output:
[false, true]

Input: //Example of acceptable alternative
[0,1,1]
Output:
[1,0,0]
</code>```

答:
05AB1E, 1 byte

Code:

```<code>_
</code>```

Explanation:

```<code>_     # Logical not
</code>```

Try it online!

Title: Invert a boolean array

Body:
05AB1E, 1 byte

Code:

_

Explanation:

_     # Logical not

Try it online!


答:
Javascript ES6, 15 bytes

```<code>a=>a.map(b=>!b)
</code>```

Not much explanation needed I guess

f=
a=>a.map(b=>!b)

a.innerHTML = `[true, false, 1, 0] => ${ f([true, false, 1, 0]) }````
<pre class="snippet-code-html lang-html prettyprint-override"><code><pre id=a></code>```

Title: Invert a boolean array

Body:
A nice simple one

Input

Given a boolean array (Or an acceptable alternative), you can assume the array will never be more than 32 elements long.

```<code>[false, false, true, false, false]
</code>```

Output

Invert every element of the array and output it.

```<code>[true, true, false, true, true]
</code>```

Rules

You can write a full program or just a function

Standard loopholes apply

Shortest code in bytes, per language, wins!

Test cases

```<code>Input:
[true, false]
Output:
[false, true]

Input: //Example of acceptable alternative
[0,1,1]
Output:
[1,0,0]
</code>```

Body:
Javascript ES6, 15 bytes

a=>a.map(b=>!b)

Not much explanation needed I guess

f=
a=>a.map(b=>!b)

a.innerHTML = `[true, false, 1, 0] => ${ f([true, false, 1, 0]) }`

<pre id=a>


问:
Produce n n-squares of integers with rotating *'s in consecuitive corners
The objective is to produce output of n squares (nxn) of random integers (0-9) with a moving * that rotates clockwise around the corners, starting from the top left. The squares should be side by side and separated by a single space.

If n = 0, the output should be empty.

Output for n=1:

*

Output for n=2:

```<code>*3 4*
14 07
</code>```

Output for n=3:

```<code>*34 82* 291
453 224 924
145 158 57*
</code>```

Output for n=4:

```<code>*153 135* 0154 0235
2352 5604 3602 2065
2245 6895 3561 7105
7225 5785 479* *662
</code>```

Notice how, for each square, the * rotates around the corners of the square, from left to right, beginning in the top left corner of the first, then moving to the top right of the second, and so on.

The shortest answer (measured in bytes) wins.

答:
05AB1E, <s>50</s> 49 bytes

```<code>3mF9Ý.R}J¹ô¹ävy`¦'*ìN4%©>ir}®iRr}®<iR})ˆ}¯øvyðý}»
</code>```

Explanation

Examples for input = 4.

First we create a string of input^3 random numbers between 0 and 9.

```<code>3mF9Ý.R}J
</code>```

producing

```<code>6799762549425893341317984133999075245812305412010122884262903656
</code>```

Then we split that into pieces each the size of the input.

That is further split into input pieces.

```<code>¹ô¹ä
</code>```

This gives us a matrix of numbers.

```<code>[['6799', '7625', '4942', '5893'],
 ['3413', '1798', '4133', '9990'],
 ['7524', '5812', '3054', '1201'],
 ['0122', '8842', '6290', '3656']]
</code>```

We then loop over the rows of the matrix, inserting asterisks in the right places.

```<code>v                          } # for each row in matrix
 y`                          # flatten list to stack
   ¦'*ì                      # replace the first digit of the last number with "*"
       N4%©>ir}              # if row-nr % 4 == 0, move the number with "*" to the front
               ®iRr}         # if row-nr % 4 == 1, move the number with "*" to the front
                             # and reverse the number, moving "*" to the numbers right side
                    ®<iR}    # if row-nr % 4 == 2, reverse the number, moving "*"
                             # to the numbers right side
                         )ˆ  # wrap row in a list and add to global array
</code>```

Now we have the matrix with a "*" on each row, but we want an asterisk per column.

```<code>[['*893', '4942', '7625', '6799'],
 ['099*', '4133', '1798', '3413'],
 ['7524', '5812', '3054', '102*'],
 ['0122', '8842', '6290', '*656']]
</code>```

So we zip this list turning rows into columns and vice versa.

```<code>[['*893', '099*', '7524', '0122'],
 ['4942', '4133', '5812', '8842'],
 ['7625', '1798', '3054', '6290'],
 ['6799', '3413', '102*', '*656']]
</code>```

All that's left now is to format the output.

```<code>vyðý}»
</code>```

Joining the rows on spaces and the columns on newlines gives us the final result.

```<code>*893 099* 7524 0122
4942 4133 5812 8842
7625 1798 3054 6290
6799 3413 102* *656
</code>```

Try it online!

Old 50 byte solution

```<code>3mF9Ý.R}J
</code>```0

ContentLicense: CC BY-SA 4.0

Body:
05AB1E, <s>50</s> 49 bytes

3mF9Ý.R}J¹ô¹ävy`¦'*ìN4%©>ir}®iRr}®<iR})ˆ}¯øvyðý}»

Explanation

Examples for input = 4.

First we create a string of input^3 random numbers between 0 and 9.

3mF9Ý.R}J

producing

6799762549425893341317984133999075245812305412010122884262903656

Then we split that into pieces each the size of the input.

That is further split into input pieces.

¹ô¹ä

This gives us a matrix of numbers.

[['6799', '7625', '4942', '5893'],
 ['3413', '1798', '4133', '9990'],
 ['7524', '5812', '3054', '1201'],
 ['0122', '8842', '6290', '3656']]

We then loop over the rows of the matrix, inserting asterisks in the right places.

v                          } # for each row in matrix
 y`                          # flatten list to stack
   ¦'*ì                      # replace the first digit of the last number with "*"
       N4%©>ir}              # if row-nr % 4 == 0, move the number with "*" to the front
               ®iRr}         # if row-nr % 4 == 1, move the number with "*" to the front
                             # and reverse the number, moving "*" to the numbers right side
                    ®<iR}    # if row-nr % 4 == 2, reverse the number, moving "*"
                             # to the numbers right side
                         )ˆ  # wrap row in a list and add to global array

Now we have the matrix with a "*" on each row, but we want an asterisk per column.

[['*893', '4942', '7625', '6799'],
 ['099*', '4133', '1798', '3413'],
 ['7524', '5812', '3054', '102*'],
 ['0122', '8842', '6290', '*656']]

So we zip this list turning rows into columns and vice versa.

[['*893', '099*', '7524', '0122'],
 ['4942', '4133', '5812', '8842'],
 ['7625', '1798', '3054', '6290'],
 ['6799', '3413', '102*', '*656']]

All that's left now is to format the output.

vyðý}»

Joining the rows on spaces and the columns on newlines gives us the final result.

*893 099* 7524 0122
4942 4133 5812 8842
7625 1798 3054 6290
6799 3413 102* *656

Try it online!

Old 50 byte solution

F¹Fõ¹F9Ý.R«}}¦'*ì})¹ävyN4%©>iR}®iíÁ}®<ií}})øvyðý}»


问:
An A , or An An?
In English, there is the fun and simple difference between an and a: you use an when preceding a word starting with a vowel sound, and a when the word starts with a consonant sound.

For the sake of simplicity in this challenge, an precedes a word that starts with a vowel (aeiou), and a precedes a word that starts with a consonant.

Input

A string comprising only printable ASCII characters, with [?] appearing in places where you must choose to insert an or a. [?] will always appear before a word. You can assume that the sentence will be grammatically correct and formatted like normal.

Output

The input string with [?] replaced with the appropriate word (an or a). You do have to worry about capitalization!

When to Capitalize

Capitalize a word if it is preceded by no characters (is the first one in the input) or if it is preceded by one of .?! followed by a space.

Examples

```<code>Input: Hello, this is [?] world!
Output: Hello, this is a world!

Input: How about we build [?] big building. It will have [?] orange banana hanging out of [?] window.
Output: How about we build a big building. It will have an orange banana hanging out of a window.

Input: [?] giant en le sky.
Output: A giant en le sky.

Input: [?] yarn ball? [?] big one!
Output: A yarn ball? A big one!

Input: [?] hour ago I met [?] European.
Output: A hour ago I met an European.

Input: Hey sir [Richard], how 'bout [?] cat?
Output: Hey sir [Richard], how 'bout a cat?
</code>```

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

答:
Python 3.5.1, <s>153</s> <s>147</s> 141 <s>124</s> Bytes

*s,=input().replace('[?]','*');print(*['aA'[i<1or s[i-2]in'.?!']+'n'*(s[i+2]in 'aeiouAEIOU')if c=='*' else c for i,c in enumerate(s)],sep='')
```

<p>Input :</p>

<p><code>[?] apple [?] day keeps the doctor away. [?] lie.</code></p>

<p>Output :</p>

<p><code>An apple a day keeps the doctor away. A lie.</code></p>

<p>123 Bytes version - This does not handle capitalization rule.</p>

<pre class="lang-py prettyprint-override"><code>s=list(input().replace('[?]','*'));print(*['a'+'n'*(s[i+2]in 'aeiouAEIOU')if c=='*'else c for i,c in enumerate(s)],sep='')
</code>```

Try it online!

Title: An A , or An An?

Body:
Python 3.5.1, <s>153</s> <s>147</s> 141 <s>124</s> Bytes

*s,=input().replace('[?]','*');print(*['aA'[i<1or s[i-2]in'.?!']+'n'*(s[i+2]in 'aeiouAEIOU')if c=='*' else c for i,c in enumerate(s)],sep='')

Input :

[?] apple [?] day keeps the doctor away. [?] lie.

Output :

An apple a day keeps the doctor away. A lie.

123 Bytes version - This does not handle capitalization rule.

s=list(input().replace('[?]','*'));print(*['a'+'n'*(s[i+2]in 'aeiouAEIOU')if c=='*'else c for i,c in enumerate(s)],sep='')

Try it online!


答:
Logicode, <s>9</s> 8 bytes

```<code>out!binp
</code>```

Simple, really.

Takes input as a binary string, as Logicode doesn't have support for lists (so [true, false] would be 10).

The out outputs the line's result.

The ! command calculates the NOT of every bit in the string, so something like !111 would be 000.

The binp is binary input.

1 byte saved thanks to @daHugLenny

Title: Invert a boolean array

Body:
Logicode, <s>9</s> 8 bytes

out!binp

Simple, really.

Takes input as a binary string, as Logicode doesn't have support for lists (so [true, false] would be 10).

The out outputs the line's result.

The ! command calculates the NOT of every bit in the string, so something like !111 would be 000.

The binp is binary input.

1 byte saved thanks to @daHugLenny


答:
Mathematica, 7 bytes

```<code>Not/@#&
</code>```

or without letters:

```<code>!#&/@#&
</code>```

As for the syntactic sugar: & marks the right end of an unnamed function and has very low precedence. # refers to the first argument of the nearest and enclosing &. ! is the operator for Not. So !#& is just an unnamed function that negates its argument, in other words its identical to the built-in Not. /@ is the operator for Map. So the code would also be equivalent to the somewhat more readable Map[Not, #]&.

Title: Invert a boolean array

Body:
Mathematica, 7 bytes

Not/@#&

or without letters:

!#&/@#&

As for the syntactic sugar: & marks the right end of an unnamed function and has very low precedence. # refers to the first argument of the nearest and enclosing &. ! is the operator for Not. So !#& is just an unnamed function that negates its argument, in other words its identical to the built-in Not. /@ is the operator for Map. So the code would also be equivalent to the somewhat more readable Map[Not, #]&.


答:
CJam, 4 bytes

```<code>{:!}
</code>```

Input is a list of 0s and 1s.

Try it online!

Title: Invert a boolean array

Body:
CJam, 4 bytes

{:!}

Input is a list of 0s and 1s.

Try it online!


答:
Pyth, 2 bytes

```<code>!M
</code>```

Explanation:  (M)ap boolean not (!) over input.

Try it online!

Title: Invert a boolean array

Body:
Pyth, 2 bytes

!M

Explanation:  (M)ap boolean not (!) over input.

Try it online!


答:
Jelly, 1 byte

```<code>¬
</code>```

Try it online!

¬ is logical NOT (1 if false-y, else 0). C (“complement”, 1−z) also works.

Title: Invert a boolean array

Body:
Jelly, 1 byte

¬

Try it online!

¬ is logical NOT (1 if false-y, else 0). C (“complement”, 1−z) also works.


问:
Generate a Universal-binary-function Lookup Table
This is tangentially related to my quest to invent an esoteric programming language.

A table of the binary numbers 0 .. 15 can be used to implement a Universal Binary Function using indexing operations. Given two 1-bit inputs X and Y, all 16 possible functions can be encoded in a 4-bit opcode.

```<code>X Y  F|0 1 2 3 4 5 6 7 8 9 A B C D E F
- -    - - - - - - - - - - - - - - - -
0 0    0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
0 1    0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
1 0    0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
1 1    0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
       -     -   - -   -   -   -   - -
       0    ~X  ~Y ^   &   Y   X   | 1
      ZERO    NOT-Y   AND         OR
          NOT-X   XOR              ONE
</code>```

So this set of 16 functions can be applied to binary inputs as the function

U(f,x,y): (f >> ((x<<1) | y)) & 1,

or

U(f,x,y): (f / 2^(x×2 + y)) % 2,

or with indexing or matrix partitioning.

It will be useful to know the most compact way to represent or generate such a table of values for any possible languages to be built upon this type of binary operation.

The goal:

Generate this exact text output:

```<code>0101010101010101
0011001100110011
0000111100001111
0000000011111111
</code>```

That's it! Shortest-code wins.

答:
Sprects, 44 bytes

```<code> aaaa
bbbb
zozo
zzoo o1111 z0000 b0011 a0101
</code>```

Cedric's answer ported to Sprects.

Body:
Sprects, 44 bytes

 aaaa
bbbb
zozo
zzoo o1111 z0000 b0011 a0101

Cedric's answer ported to Sprects.


答:
Haskell, 7 bytes

```<code>map not
</code>```

Example:

```<code>Prelude> (map not) [False, True, True]
[True,False,False]
</code>```

Title: Invert a boolean array

Body:
Haskell, 7 bytes

map not

Example:

Prelude> (map not) [False, True, True]
[True,False,False]


答:
Python, <s>27</s> <s>25</s> 24 bytes

Thanks to Lynn for golfing off two bytes, and xnor and Mego for golfing off another.

```<code>lambda a:[b^1for b in a]
</code>```

Title: Invert a boolean array

Body:
Python, <s>27</s> <s>25</s> 24 bytes

Thanks to Lynn for golfing off two bytes, and xnor and Mego for golfing off another.

lambda a:[b^1for b in a]


答:
Brachylog, 7 bytes

```<code>:{-$_}a
</code>```

Try it online!

Explanation

```<code>:{   }a   Apply this predicate to each element of the Input
  -         Decrement
   $_       Negate
</code>```

Title: Invert a boolean array

Body:
Brachylog, 7 bytes

:{-$_}a

Try it online!

Explanation

:{   }a   Apply this predicate to each element of the Input
  -         Decrement
   $_       Negate


答:
Matlab, <s> 4 </s> 1 byte

This should be self explanatory.

```<code>~
</code>```

Matlab has the one-byte negation operator ~, if you want a function you can use @not.

Title: Invert a boolean array

Body:
Matlab, <s> 4 </s> 1 byte

This should be self explanatory.

~

Matlab has the one-byte negation operator ~, if you want a function you can use @not.


答:
Groovy, <s>73</s> 162 bytes

```<code>def a(s){s.replaceAll(/(?i)(?:(.)?( )?)\[\?\] (.)/){r->"${r[1]?:''}${r[2]?:''}${'.?!'.contains(r[1]?:'.')?'A':'a'}${'aAeEiIoOuU'.contains(r[3])?'n':''} ${r[3]}"}}
</code>```

edit: damn, the capitalization totally complicated everything here

Title: An A , or An An?

Body:
In English, there is the fun and simple difference between an and a: you use an when preceding a word starting with a vowel sound, and a when the word starts with a consonant sound.

For the sake of simplicity in this challenge, an precedes a word that starts with a vowel (aeiou), and a precedes a word that starts with a consonant.

Input

A string comprising only printable ASCII characters, with [?] appearing in places where you must choose to insert an or a. [?] will always appear before a word. You can assume that the sentence will be grammatically correct and formatted like normal.

Output

The input string with [?] replaced with the appropriate word (an or a). You do have to worry about capitalization!

When to Capitalize

Capitalize a word if it is preceded by no characters (is the first one in the input) or if it is preceded by one of .?! followed by a space.

Examples

```<code>Input: Hello, this is [?] world!
Output: Hello, this is a world!

Input: How about we build [?] big building. It will have [?] orange banana hanging out of [?] window.
Output: How about we build a big building. It will have an orange banana hanging out of a window.

Input: [?] giant en le sky.
Output: A giant en le sky.

Input: [?] yarn ball? [?] big one!
Output: A yarn ball? A big one!

Input: [?] hour ago I met [?] European.
Output: A hour ago I met an European.

Input: Hey sir [Richard], how 'bout [?] cat?
Output: Hey sir [Richard], how 'bout a cat?
</code>```

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

Body:
Groovy, <s>73</s> 162 bytes

def a(s){s.replaceAll(/(?i)(?:(.)?( )?)\[\?\] (.)/){r->"${r[1]?:''}${r[2]?:''}${'.?!'.contains(r[1]?:'.')?'A':'a'}${'aAeEiIoOuU'.contains(r[3])?'n':''} ${r[3]}"}}

edit: damn, the capitalization totally complicated everything here


答:
MATL, 1 byte

```<code>~
</code>```

Try it online!

~ is the logical not and as many functions, it can also be applied to arrays/matrices.

Title: Invert a boolean array

Body:
MATL, 1 byte

~

Try it online!

~ is the logical not and as many functions, it can also be applied to arrays/matrices.


问:
Shortest power set implementation

Problem definition

Print out the powerset of a given set. For example:

```<code>[1, 2, 3] => [[], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]]
</code>```

Each element is to be printed on a separate line, so the above example would be printed as:

```<code>[]
[1]
[2]
...
[1, 2, 3]
</code>```

Example code (in D, python example here):

```<code>import std.stdio;

string[][] powerset(string[] set) {
    if (set.length == 1) {
        return [set, []];
    }

    string[][] ret;
    foreach (item; powerset(set[1 .. $])) {
        ret ~= set[0]~item;
        ret ~= item;
    }

    return ret;
}

void main(string[] argv) {
    foreach (set; powerset(argv[1 .. $]))
        writeln(set);
}
</code>```

Input

Elements will be passed as arguments. For example, the example provided above would be passed to a program called powerset as:

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

Arguments will be alphanumeric.

Rules

No libraries besides io

Output does not have to be ordered

Powerset does not have to be stored, only printed

Elements in the set must be delimited (e.g. 1,2,3, [1,2,3] and ['1','2','3'] are acceptable, but 123 is not

Trailing delimiters are fine (e.g. 1,2,3, == 1,2,3)

Best is determined based on number of bytes

The best solution will be decided no less than 10 days after the first submission.

答:
Ruby Array method combination (from 1.9 ) [50 chars]

```<code>0.upto(ARGV.size){|a|ARGV.combination(a){|v| p v}}
</code>```

Title: Shortest power set implementation

Body:
Ruby Array method combination (from 1.9 ) [50 chars]

0.upto(ARGV.size){|a|ARGV.combination(a){|v| p v}}


答:
PHP , 45 Bytes

```<code><?foreach($_GET[a]as$v)$a[]=1-$v;print_r($a);
</code>```

Title: Invert a boolean array

Body:
A nice simple one

Input

Given a boolean array (Or an acceptable alternative), you can assume the array will never be more than 32 elements long.

```<code>[false, false, true, false, false]
</code>```

Output

Invert every element of the array and output it.

```<code>[true, true, false, true, true]
</code>```

Rules

You can write a full program or just a function

Standard loopholes apply

Shortest code in bytes, per language, wins!

Test cases

```<code>Input:
[true, false]
Output:
[false, true]

Input: //Example of acceptable alternative
[0,1,1]
Output:
[1,0,0]
</code>```

Body:
PHP , 45 Bytes

<?foreach($_GET[a]as$v)$a[]=1-$v;print_r($a);


问:
How does math work in Anastasiya's world?

Background:

Standard operation math like basic addition and multiplication in the real world work like these:

```<code>12 + 123 = 135
</code>```

and

```<code>12 * 123 = 1476
</code>```

That's not interesting and boring! Many schools are already interpreting this as practice, practice, practice of formal algorithms. That implies a pretty rigid and boring mathematical diet and is not what is intended in this challenge. Get ready to play some fun on our beloved site.

Consider the process of adding two positive integer numbers, then adding again all the digits of its result. Repeating with the addition until only a single digit is obtained. For example:

The result of 12 + 123 is 135.

Adding all the digits of 135 we obtain 1 + 3 + 5 = 9.

The number of steps required to obtain a single digit value 9 in this repeated addition is 2.

As with the previous process of the addition, the multiplication of two positive integer numbers follows the same process. Multiply all the digits of its result and then repeating this process until only a single digit remains. Take the above example:

The result of 12 * 123 is 1476.

Multiply all the digits of 1476 we obtain 1 * 4 * 7 * 6 = 168.

Multiply again all the digits of 168 we obtain 1 * 6 * 8 = 48.

Multiply again all the digits of 48 we obtain 4 * 8 = 32.

Multiply once again all the digits of 32 we obtain 3 * 2 = 6.

The number of steps required to obtain a single digit value 6 this repeated multiplication is 5.

For this challenge's sake and avoiding any misuse of math notations, I introduce these two dummy notations: (+) and (*), but you may use any notation you like, which work like the followings:

The operation of repeated addition process to obtain a single value is 12 (+) 123 = 9.

The operation of repeated multiplication process to obtain a single value is 12 (*) 123  = 6.

Challenge:

The challenge is to write either a program or a function which can perform both of operations as explained in the background section: (+) and (*).

Input:

The inputs of the program or the function are two positive integers and one operation either (+) and (*). The format of the input is an arbitrary choice of the programmer. You may format the input, for example, a (+) b or F(a, (+), b) or any format you wish.

Output:

The output of the program or the function must contain the result of operation and the number of steps required with freestyle format as you wish.

Test Cases (ignore the input and output format):

```<code>    81 (+) 31       -->   (4 ; 2)
    351 (+) 14568   -->   (6 ; 3)
    21 (*) 111      -->   (8 ; 3)
    136 (*) 2356    -->   (0 ; 2)
</code>```

General rules:

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

Don't let esolangs discourage you from posting an answer with regular languages. Enjoy this challenge by providing an answer as short as possible with your programming language. If you post a clever answer and a clear explanation, your answer will be appreciated (hence the upvotes) regardless of the programming language you use.

Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/ method with the proper parameters, full programs, etc. The choice is yours.

If possible, your program can properly handle large numbers. If not, that will just be fine.

Let the game begin!!

答:
R, 91 bytes

Using @Vlo's code, which makes use of @plannapus's splitter, and some ideas I generated while golfing @Frédéric's answer, this is the shortest R answer yet. (An unusually large number of R answers here today...)

```<code>function(A,F,B){x=F(A,B);while(x>9){m=nchar(x);x=F(x%%10^(1:m)%/%10^(1:m-1));T=T+1};c(x,T)}
</code>```

Crucially, this requires that the input for the operator be either sum for (+) or prod for (*). Under the rules of the challenge, this seems to be okay.

With indentation:

```<code>function(A,F,B){
  x=F(A,B);
  while(x>9){
    m=nchar(x);
    x=F(x%%10^(1:m)%/%10^(1:m-1));
    T=T+1
  };
  c(x,T)
}
</code>```

Main differences from @Vlo's answer are:

Instead of using Reduce, we rely on the input argument being a function, and just call it explicitly. (Yay for functions being first-class objects!)

Instead of initializing a new variable as our counter, we abuse R's builtins and use T, which evaluates to TRUE (aka 1), but since it's not a reserved variable we can modify it. Thus T+T is 2. So we use that as our counter.

Instead of cating the output, we just return it as a vector with c. As well as saving two bytes, the fact that the output is forced into a vector ensures that T is of class numeric. If we use cat, and T hasn't been incremented, then we get erroneous output like 1 TRUE.

Body:
R, 91 bytes

Using @Vlo's code, which makes use of @plannapus's splitter, and some ideas I generated while golfing @Frédéric's answer, this is the shortest R answer yet. (An unusually large number of R answers here today...)

function(A,F,B){x=F(A,B);while(x>9){m=nchar(x);x=F(x%%10^(1:m)%/%10^(1:m-1));T=T+1};c(x,T)}

Crucially, this requires that the input for the operator be either sum for (+) or prod for (*). Under the rules of the challenge, this seems to be okay.

With indentation:

function(A,F,B){
  x=F(A,B);
  while(x>9){
    m=nchar(x);
    x=F(x%%10^(1:m)%/%10^(1:m-1));
    T=T+1
  };
  c(x,T)
}

Main differences from @Vlo's answer are:

Instead of using Reduce, we rely on the input argument being a function, and just call it explicitly. (Yay for functions being first-class objects!)

Instead of initializing a new variable as our counter, we abuse R's builtins and use T, which evaluates to TRUE (aka 1), but since it's not a reserved variable we can modify it. Thus T+T is 2. So we use that as our counter.

Instead of cating the output, we just return it as a vector with c. As well as saving two bytes, the fact that the output is forced into a vector ensures that T is of class numeric. If we use cat, and T hasn't been incremented, then we get erroneous output like 1 TRUE.


答:
R, 1 byte

```<code>!
</code>```

Example:

```<code>> !c(TRUE, FALSE)
[1] FALSE  TRUE
</code>```

It also works with numerical input:

```<code>> !c(1, 0)
[1] FALSE  TRUE
</code>```

We're not restricted to one-dimensional arrays, either. Let's make a matrix, and randomly populate it with 0s and 1s:

```<code>> mat = matrix(rbinom(16, 1, .5), ncol=4)
> mat
     [,1] [,2] [,3] [,4]
[1,]    0    1    1    1
[2,]    0    1    0    0
[3,]    0    0    0    0
[4,]    1    1    1    0
</code>```

We can invert this just as easily:

```<code>> !mat
      [,1]  [,2]  [,3]  [,4]
[1,]  TRUE FALSE FALSE FALSE
[2,]  TRUE FALSE  TRUE  TRUE
[3,]  TRUE  TRUE  TRUE  TRUE
[4,] FALSE FALSE FALSE  TRUE
</code>```

We can continue to do this for arbitrary numbers of dimensions. Here's an example on a four-dimensional array:

```<code>> bigarray = array(rbinom(32, 1, 0.5), dim=c(2,2,2,2))
> bigarray
, , 1, 1

     [,1] [,2]
[1,]    0    0
[2,]    0    0

, , 2, 1

     [,1] [,2]
[1,]    1    0
[2,]    0    0

, , 1, 2

     [,1] [,2]
[1,]    0    1
[2,]    0    1

, , 2, 2

     [,1] [,2]
[1,]    1    0
[2,]    1    1

> !bigarray
, , 1, 1

     [,1] [,2]
[1,] TRUE TRUE
[2,] TRUE TRUE

, , 2, 1

      [,1] [,2]
[1,] FALSE TRUE
[2,]  TRUE TRUE

, , 1, 2

     [,1]  [,2]
[1,] TRUE FALSE
[2,] TRUE FALSE

, , 2, 2

      [,1]  [,2]
[1,] FALSE  TRUE
[2,] FALSE FALSE
</code>```

Doesn't work for characters, I'm afraid.

```<code>> !"Hello world"
Error in !"Hello world" : Invalid argument type.
</code>```

Title: Invert a boolean array

Body:
R, 1 byte

!

Example:

> !c(TRUE, FALSE)
[1] FALSE  TRUE

It also works with numerical input:

> !c(1, 0)
[1] FALSE  TRUE

We're not restricted to one-dimensional arrays, either. Let's make a matrix, and randomly populate it with 0s and 1s:

> mat = matrix(rbinom(16, 1, .5), ncol=4)
> mat
     [,1] [,2] [,3] [,4]
[1,]    0    1    1    1
[2,]    0    1    0    0
[3,]    0    0    0    0
[4,]    1    1    1    0

We can invert this just as easily:

> !mat
      [,1]  [,2]  [,3]  [,4]
[1,]  TRUE FALSE FALSE FALSE
[2,]  TRUE FALSE  TRUE  TRUE
[3,]  TRUE  TRUE  TRUE  TRUE
[4,] FALSE FALSE FALSE  TRUE

We can continue to do this for arbitrary numbers of dimensions. Here's an example on a four-dimensional array:

> bigarray = array(rbinom(32, 1, 0.5), dim=c(2,2,2,2))
> bigarray
, , 1, 1

     [,1] [,2]
[1,]    0    0
[2,]    0    0

, , 2, 1

     [,1] [,2]
[1,]    1    0
[2,]    0    0

, , 1, 2

     [,1] [,2]
[1,]    0    1
[2,]    0    1

, , 2, 2

     [,1] [,2]
[1,]    1    0
[2,]    1    1

> !bigarray
, , 1, 1

     [,1] [,2]
[1,] TRUE TRUE
[2,] TRUE TRUE

, , 2, 1

      [,1] [,2]
[1,] FALSE TRUE
[2,]  TRUE TRUE

, , 1, 2

     [,1]  [,2]
[1,] TRUE FALSE
[2,] TRUE FALSE

, , 2, 2

      [,1]  [,2]
[1,] FALSE  TRUE
[2,] FALSE FALSE

Doesn't work for characters, I'm afraid.

> !"Hello world"
Error in !"Hello world" : Invalid argument type.


答:
Java (JDK), 68 bytes

s->{var r=""+s;for(int i=s.length();i-->1;)r+=s.reverse();return r;}
```

Try it online!

Title: StringgnirtSStringgnirtSStringgnirtS

Body:
Here is a relatively simple challenge for you.

Given a string of length N, output the string forwards, then backwards, then forwards, then backwards... etc. N times. For example, if your input was

```<code>Hello!
</code>```

You should output:

```<code>Hello!!olleHHello!!olleHHello!!olleH
</code>```

You may also optionally output one trailing newline.

Your submission may be either a full program or a function, and you may take input and output in any reasonable format. For example, you may take IO from STDIN/STDOUT, function arguments and return value, from a file, etc. You can safely assume that the input string will not be empty, and will only contain printable ASCII. You must output the new string on a single line. So, for example, if the output to the last example was

```<code>Hello!
!olleH
Hello!
!olleH
Hello!
!olleH
</code>```

This would not be a valid solution!

Here are some more test cases:

```<code>Input:
a
Output:
a

Input:
abcd
Output:
abcddcbaabcddcba

Input:
OK!
Output:
OK!!KOOK!

Input:
4815162342
Output:
4815162342243261518448151623422432615184481516234224326151844815162342243261518448151623422432615184

Input:
PPCG
Output:
PPCGGCPPPPCGGCPP

Input:
42
Output:
4224
</code>```

Leaderboards

Since this is a code-golf challenge, standard loopholes are banned, and the shortest answer in bytes wins! However, this is also a competition to have the shortest answer in any particular langauge. While it's unlikely that a Java answer will beat an answer in perl, or some golfing language, it's still very impressive to have the shortest Java answer. So, you can use this leaderboard to see both

The shortest answer out of all languages, and

The shortest answer in each individual language.

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

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

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

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

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

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

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

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

var QUESTION_ID=93261,OVERRIDE_USER=31716;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:
Java (JDK), 68 bytes

s->{var r=""+s;for(int i=s.length();i-->1;)r+=s.reverse();return r;}

Try it online!


问:
The sum is always 15
Write a program or function that takes an array of non-negative integers as input and outputs a set of vectors/arrays with the elements of the input array in order, split so that each vector sums up to 15. If the sum of the first N elements doesn't "hit 15", then the number that made it pass 15 must be cut off, and the remainder will be the first element of the next vector. This goes on until you reach the end of the input array. If the sum of the final vector is less than 15, then a number must be added at the end to make the sum go up.

I think the rules are more easily understood by looking at the examples:

```<code>Input: 3 7 5 10
Output:
3 7 5           <- Sum is 15
10 5            <- 5 is added to make the sum 15

Input: 2 4 5 9 2 3 5 0 2 4 5 0 3
Output:
2 4 5 4          <- Sum 15. 9 is split in two.
5 2 3 5          <- The first 5 is the remainder of 9
0 2 4 5 0 3 1    <- The last number is added to make the sum 15

Input: 1 1 1
Output:
1 1 1 12         <- The number 12 is added to make the sum 15

Input: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Output:
1 2 3 4 5
6 7 2           <- 2 is the first part of 8
6 9             <- 6 is the remainder of 8
10 5            <- 5 is first part of 11
6 9             <- 6 is remainder of 11. 9 is first part of 12
3 12            <- 3 is remainder of 12. 12 is first part of 13
1 14            <- 1 is remainder of 13. 14 is 14
15
15              <- 15 is first part of 16
1 14            <- 1 is remainder of 16. 14 is first part of 17
3 12            <- 3 is remainder of 17. 12 is added to make the sum 15

Input: 20 20
Output:
15
5 10           <- 5 is remainder from the first 20
10 5           <- 10 is remainder from second 20. 5 is added to make the sum = 15.

Input: 100
Output
15
15
15
15
15
15
10 5
</code>```

Both the input and the output format is optional. Whatever is best in your language.

The shortest code in bytes wins.

Leaderboard

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

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

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

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

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

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

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

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

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

var QUESTION_ID=65577,OVERRIDE_USER=44713;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+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

```

答:
Perl, 76 bytes

Includes +3 for -p (normally +1, but +3 to play fair with the other perl solution)

Run with the input on STDIN (final newline on input is optional, but MUST be absent for the empty input)

```<code>sum15.pl <<< "1 2 3"
</code>```

sum15.pl:

```<code>#!/usr/bin/perl -p
s/$/ 15/;s/\d+/1x$&/eg;s/( *1){15}\K ?/
/g;s/
1*
*$//;s/1+|\B/length$&/eg
</code>```

Look ma, no calculations whatsoever...

Title: The sum is always 15

Body:
Perl, 76 bytes

Includes +3 for -p (normally +1, but +3 to play fair with the other perl solution)

Run with the input on STDIN (final newline on input is optional, but MUST be absent for the empty input)

sum15.pl <<< "1 2 3"

sum15.pl:

#!/usr/bin/perl -p
s/$/ 15/;s/\d+/1x$&/eg;s/( *1){15}\K ?/
/g;s/
1*
*$//;s/1+|\B/length$&/eg

Look ma, no calculations whatsoever...


答:
Pyth, 6 bytes

```<code>Vzp~_z
</code>```

Try it online!

Explanation

```<code>Vzp~_z
Vz      For every character in z (the input)
  p  z  Print z
   ~_z  Reverse z
</code>```

Title: StringgnirtSStringgnirtSStringgnirtS

Body:
Pyth, 6 bytes

Vzp~_z

Try it online!

Explanation

Vzp~_z
Vz      For every character in z (the input)
  p  z  Print z
   ~_z  Reverse z


问:
Generate a mandelbrot fractal
Your task is to draw the mandelbrot set in ascii. It should look something like

The complex number c lies in the mandelbrot set, when the sequence z(n+1) = z(n)^2 + c, z(0) = 0 remains bounded.
For the purpose of this challenge you can consider the sequence bounded for c if |z(32)| < 2.

Plot the mandelbrot set on the complex plane from (-2 - i) to (1 + i), and a minimum resolution of 40x30, using ascii characters in your favourite language, using as few characters as possible.

Title: Generate a mandelbrot fractal

Body:
><>, 118 bytes

1 v
2-\:01-(?;0
*&\0084
?!\}::*{::*$@-}2**}:@@:{+r+::*{::*$@+4(&1-:&*
ao\&~:*$:*+4(}" *"{?$~o1aa+,+:1)22@@?!.~~~1aa+,-

Try it online! Be warned, it takes about 25 seconds to run using TIO, so be patient!

More of a self-challenge than a serious entry. Produces the following output:

                                        *

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

                                        *


答:
JAISBaL, 1 byte

```<code>!
</code>```

Like all the other 1-byte answers, this is the negation operator, which can operate over an array if needed. This leaves the output on the stack, which is printed at the end of the program.

For two bytes, the array can be explicitly printed:

```<code>!§
</code>```

Input is in JAISBaL's incredibly odd array format (which I did invent, but I don't like it...).

Test Cases (Output from the Java interpreter, 3.0.5):

```<code>Enter a value > [true][false]

--------------------
Stack: [[false, true]]
Locals: {}
----------------------------------------
Enter a value > [false][false][true][false][false]

--------------------
Stack: [[true, true, false, true, true]]
Locals: {}
</code>```

Title: Invert a boolean array

Body:
JAISBaL, 1 byte

!

Like all the other 1-byte answers, this is the negation operator, which can operate over an array if needed. This leaves the output on the stack, which is printed at the end of the program.

For two bytes, the array can be explicitly printed:

!§

Input is in JAISBaL's incredibly odd array format (which I did invent, but I don't like it...).

Test Cases (Output from the Java interpreter, 3.0.5):

Enter a value > [true][false]

--------------------
Stack: [[false, true]]
Locals: {}
----------------------------------------
Enter a value > [false][false][true][false][false]

--------------------
Stack: [[true, true, false, true, true]]
Locals: {}


答:
Java, 51 bytes

```<code>l.stream().map(b->!b).collect(Collectors.toList());
</code>```

l = a Collection of Booleans
I feel like this could be shorter, then again golfing in java ^^

Title: Invert a boolean array

Body:
Java, 51 bytes

l.stream().map(b->!b).collect(Collectors.toList());

l = a Collection of Booleans
I feel like this could be shorter, then again golfing in java ^^


答:
Dyalog APL, 8 bytes

∊≢⍴⊂,⊂∘⌽
```

∊ flatten

≢ the tally

⍴ cyclically reshaping

⊂ the enclosed argument

, followed by

⊂∘⌽ the enclosed reversed argument

TryAPL online!

-1 byte thanks to jimmy23013.

Title: StringgnirtSStringgnirtSStringgnirtS

Body:
Dyalog APL, 8 bytes

∊≢⍴⊂,⊂∘⌽

∊ flatten

≢ the tally

⍴ cyclically reshaping

⊂ the enclosed argument

, followed by

⊂∘⌽ the enclosed reversed argument

TryAPL online!

-1 byte thanks to jimmy23013.


问:
Shortest way to reverse a number
Write a function (or equivalent subprogram) to accept a single integer valued argument and return a (similarly typed) value found by reversing the order of the base-10 digits of the argument.

For example given 76543 return 34567

答:
Kinda late but

APL, 3

```<code>⍎⌽⍞
</code>```

If you insists on a function

```<code>⍎∘⌽∘⍕
</code>```

OwnerDisplayName: eltond

Title: Shortest way to reverse a number

Body:
Kinda late but

APL, 3

⍎⌽⍞

If you insists on a function

⍎∘⌽∘⍕


答:
PowerShell v2+, 57 bytes

```<code>param($a)-join(1..($x=$a.length)|%{($a[$x..0],$a)[$_%2]})
</code>```

No real clean way to get string lengths or reverse 'em, so this is pretty lengthy.

Takes input $a, loops from 1 to $a.length (stored in $x for use later). Each iteration we use a pseudo-ternary to index into an array of either $a or $a[$x..0] (i.e., reversed), based on whether our input number is odd/even [$_%2]. These are all encapsulated in parens and -joined together to form a single string. That's left on the pipeline, and output is implicit.

```<code>PS C:\Tools\Scripts\golfing> .\stringgnirts.ps1 'TimmyD'
TimmyDDymmiTTimmyDDymmiTTimmyDDymmiT
</code>```

Title: StringgnirtSStringgnirtSStringgnirtS

Body:
PowerShell v2+, 57 bytes

param($a)-join(1..($x=$a.length)|%{($a[$x..0],$a)[$_%2]})

No real clean way to get string lengths or reverse 'em, so this is pretty lengthy.

Takes input $a, loops from 1 to $a.length (stored in $x for use later). Each iteration we use a pseudo-ternary to index into an array of either $a or $a[$x..0] (i.e., reversed), based on whether our input number is odd/even [$_%2]. These are all encapsulated in parens and -joined together to form a single string. That's left on the pipeline, and output is implicit.

PS C:\Tools\Scripts\golfing> .\stringgnirts.ps1 'TimmyD'
TimmyDDymmiTTimmyDDymmiTTimmyDDymmiT


答:
IBM/Lotus Notes Formula, 2 bytes

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

Usage:

Create a Notes form with two fields named a and b.

a (input) = editable, number, multi-value, comma separated

b (output) = computed, number, multi-value, comma separated

Paste the above formula into b and give a a default value of 0.

Create a new document with the form, enter a binary list in a and press F9 to update the output.

Examples:

Works because given a list as input, Notes formula will apply whatever specified action to every element in the list.

Title: Invert a boolean array

Body:
IBM/Lotus Notes Formula, 2 bytes

!a

Usage:

Create a Notes form with two fields named a and b.

a (input) = editable, number, multi-value, comma separated

b (output) = computed, number, multi-value, comma separated

Paste the above formula into b and give a a default value of 0.

Create a new document with the form, enter a binary list in a and press F9 to update the output.

Examples:

Works because given a list as input, Notes formula will apply whatever specified action to every element in the list.


答:
PowerShell, 15 bytes

```<code>$args[0]|%{!$_}
</code>```

I think this may even work in v1, hence I left the version number off the title. Loops through the input $args and negates each item in turn. That resulting array is left on the pipeline.

The neat thing, however, is because PowerShell is so loose on its casting requirements, you can do a completely mixed input and get an appropriate Boolean output. For example, here are the literal Boolean values $false/$true, the numbers 0 1 and 123456789 as integers, an empty string, a non-empty string, an empty array, and a non-empty array --

```<code>PS C:\Tools\Scripts\golfing> .\invert-a-boolean-array.ps1 @($false,$true,0,1,123456789,'','foo',@(),@(1,1))
True
False
True
False
False
True
False
True
False
</code>```

Title: Invert a boolean array

Body:
PowerShell, 15 bytes

$args[0]|%{!$_}

I think this may even work in v1, hence I left the version number off the title. Loops through the input $args and negates each item in turn. That resulting array is left on the pipeline.

The neat thing, however, is because PowerShell is so loose on its casting requirements, you can do a completely mixed input and get an appropriate Boolean output. For example, here are the literal Boolean values $false/$true, the numbers 0 1 and 123456789 as integers, an empty string, a non-empty string, an empty array, and a non-empty array --

PS C:\Tools\Scripts\golfing> .\invert-a-boolean-array.ps1 @($false,$true,0,1,123456789,'','foo',@(),@(1,1))
True
False
True
False
False
True
False
True
False


答:
Japt, 3 bytes

```<code>¡!X
</code>```

Japt doesn't have boolean input, so input is an array of 0s and 1s. Test it online!

How it works

```<code>¡    // Map each item X in the input to
 !X  //  the boolean NOT of X.
     // Implicit output
</code>```

Title: Invert a boolean array

Body:
Japt, 3 bytes

¡!X

Japt doesn't have boolean input, so input is an array of 0s and 1s. Test it online!

How it works

¡    // Map each item X in the input to
 !X  //  the boolean NOT of X.
     // Implicit output


答:
Perl, 7 bytes

Includes +2 for -lp

Give each boolean value as 0 or 1 on its own line

```<code>invert.pl
1
1
0
^D
</code>```

invert.pl:

```<code>#!/us/bin/perl -lp
$_^=1
</code>```

Title: Invert a boolean array

Body:
A nice simple one

Input

Given a boolean array (Or an acceptable alternative), you can assume the array will never be more than 32 elements long.

```<code>[false, false, true, false, false]
</code>```

Output

Invert every element of the array and output it.

```<code>[true, true, false, true, true]
</code>```

Rules

You can write a full program or just a function

Standard loopholes apply

Shortest code in bytes, per language, wins!

Test cases

```<code>Input:
[true, false]
Output:
[false, true]

Input: //Example of acceptable alternative
[0,1,1]
Output:
[1,0,0]
</code>```

Body:
Perl, 7 bytes

Includes +2 for -lp

Give each boolean value as 0 or 1 on its own line

invert.pl
1
1
0
^D

invert.pl:

#!/us/bin/perl -lp
$_^=1


答:
Retina, 3 bytes

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

Try it online!

For each line (%), count the number of 0s.

Title: Invert a boolean array

Body:
Retina, 3 bytes

%`0

Try it online!

For each line (%), count the number of 0s.


答:
Haskell (Lambdabot), 47 bytes

```<code>unlines$reverse$transpose$replicateM 4['1','0']
</code>```

Kinda cheaty because it uses transpose from Data.List and replicateM from Control.Monad, however both are loaded by default from Lambdabot.

Also, I'm sure there is room for improvement, just wanted to share the idea

Title: Generate a Universal-binary-function Lookup Table

Body:
This is tangentially related to my quest to invent an esoteric programming language.

A table of the binary numbers 0 .. 15 can be used to implement a Universal Binary Function using indexing operations. Given two 1-bit inputs X and Y, all 16 possible functions can be encoded in a 4-bit opcode.

```<code>X Y  F|0 1 2 3 4 5 6 7 8 9 A B C D E F
- -    - - - - - - - - - - - - - - - -
0 0    0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
0 1    0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
1 0    0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
1 1    0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
       -     -   - -   -   -   -   - -
       0    ~X  ~Y ^   &   Y   X   | 1
      ZERO    NOT-Y   AND         OR
          NOT-X   XOR              ONE
</code>```

So this set of 16 functions can be applied to binary inputs as the function

U(f,x,y): (f >> ((x<<1) | y)) & 1,

or

U(f,x,y): (f / 2^(x×2 + y)) % 2,

or with indexing or matrix partitioning.

It will be useful to know the most compact way to represent or generate such a table of values for any possible languages to be built upon this type of binary operation.

The goal:

Generate this exact text output:

```<code>0101010101010101
0011001100110011
0000111100001111
0000000011111111
</code>```

That's it! Shortest-code wins.

Body:
Haskell (Lambdabot), 47 bytes

unlines$reverse$transpose$replicateM 4['1','0']

Kinda cheaty because it uses transpose from Data.List and replicateM from Control.Monad, however both are loaded by default from Lambdabot.

Also, I'm sure there is room for improvement, just wanted to share the idea


答:
Java, 58 bytes

```<code>void f(boolean[]a){for(boolean i:a)System.out.print(!i);}
</code>```

Title: Invert a boolean array

Body:
Java, 58 bytes

void f(boolean[]a){for(boolean i:a)System.out.print(!i);}


问:
Make me a mooncake!
The mid-autumn festival has begun!

Unfortunately, all my mooncakes were stolen -- they're getting too expensive for small folk such as myself, and I fear I won't be able to eat any this year!

So I turn to you for help. Would you be able to make me some?

For those unaware, let me educate you on what a mooncake looks like.

Mooncakes come in many different sizes!

So I'm gonna give you my input, n, when I want one.

Here are some examples of the output I want:

Mooncake of size n = 3:

```<code>    (@@@@@)
    (@MAF@)
    (@@@@@)
</code>```

Mooncake of size n = 6:

```<code>    (@@@@@@@@@@@)
    (@         @)
    (@    M    @)
    (@    F    @)
    (@         @)
    (@@@@@@@@@@@)
</code>```

That is to say, a mooncake of size n is:

n lines high

2n - 1 @s long

2n + 1 characters long (@s and brackets)

And you better not throw me your too-tiny practice mooncakes!

Assume input will always be n >= 3.

Mooncakes also contain one of the following decorations:

MF

MAF

HMF

JCJ

TTT

ZJ

LF

RF

CF

Which one, it doesn't matter - as long as it is vertically and horizontally centered.

It can be written vertically or horizontally too!

I want variety!

If you're really going to make me two of the same mooncake, the decoration better be different!

That is, multiple executions of your program with the exact same input must not always yield the same decoration.

I can't wait to eat your moon cakes, so the sooner I can receive them (the shorter your code) the better!

Good Luck!

For those wondering about the decorations:

They are the initials of all alternative names for the Mid-Autumn Festival.

A list can be found in the Wikipedia page linked at the top of this post.

Clarifications:

There are no rules regarding leading and trailing whitespace.

Have as much or as little as you like!

The decorations must be in the very center of your mooncake!

On horizontal decorations, this means it must be on the middle line of your cake, and the number of characters to the left and right of the decoration string must be equal.

On vertical decorations, this means it must reside in the middle column of your cake, and the number of characters above and below the decoration must be equal.

Not all decorations must be used!

The only requirement is that there must be more than one possibility for any given input n. The possibilities also do not need to be even.

Functions are acceptable.

答:
JavaScript ES6, <s>206</s> <s>196</s> <s>192</s> <s>188</s> <s>187</s> <s>180</s> <s>176</s> <s>169</s> <s>165</s> 156 bytes

```<code>g=(n,r=new Date%2,a=(s,x,b=' @'[+!s].repeat(n-3+!x))=>`(@${b+(s||'@')+b}@)
`,l=a` `.repeat(n/2-2+n%2))=>a()+l+(n%2?a(r?'MAF':'HMF',1):a('RC'[r])+a`F`)+l+a()
</code>```

Breakdown

```<code>r=new Date%2                           // Sometimes 0, sometimes 1

// Function to create lines of the cake of the form `(@@@@@@@@@)` or `(@  ${s}  @)`
a=(s,x,b=' @'[+!s].repeat(n-3+!x))=>`(@${b+(s||'@')+b}@)
`

// Cake parts
a()                                    // Top of the cake.
l=a` `.repeat(n/2-2+n%2)               // Undecorated inner part.
a(r?'MAF':'HMF',1)                     // Decoration for uneven sized cakes.
a('RC'[r])+a`F`                        // Decoration for even sized cakes.
l                                      // Undecorated inner part.
a()                                    // Bottom part.
</code>```

My first attempt at code-golf. This can probably be golfed more.

saved 4 bytes thanks to @ETHProductions

Edit
I took the liberty of using <s>Date.now()%2</s> new Date%2 to satisfy:

multiple executions of your program with the exact same input must not always yield the same decoration

this allows me to save another 7 bytes over +Math.random()>.5

saved another 4 bytes thanks to @Arnauld

Title: Make me a mooncake!

Body:
JavaScript ES6, <s>206</s> <s>196</s> <s>192</s> <s>188</s> <s>187</s> <s>180</s> <s>176</s> <s>169</s> <s>165</s> 156 bytes

g=(n,r=new Date%2,a=(s,x,b=' @'[+!s].repeat(n-3+!x))=>`(@${b+(s||'@')+b}@)
`,l=a` `.repeat(n/2-2+n%2))=>a()+l+(n%2?a(r?'MAF':'HMF',1):a('RC'[r])+a`F`)+l+a()

Breakdown

r=new Date%2                           // Sometimes 0, sometimes 1

// Function to create lines of the cake of the form `(@@@@@@@@@)` or `(@  ${s}  @)`
a=(s,x,b=' @'[+!s].repeat(n-3+!x))=>`(@${b+(s||'@')+b}@)
`

// Cake parts
a()                                    // Top of the cake.
l=a` `.repeat(n/2-2+n%2)               // Undecorated inner part.
a(r?'MAF':'HMF',1)                     // Decoration for uneven sized cakes.
a('RC'[r])+a`F`                        // Decoration for even sized cakes.
l                                      // Undecorated inner part.
a()                                    // Bottom part.

My first attempt at code-golf. This can probably be golfed more.

saved 4 bytes thanks to @ETHProductions

Edit
I took the liberty of using <s>Date.now()%2</s> new Date%2 to satisfy:

multiple executions of your program with the exact same input must not always yield the same decoration

this allows me to save another 7 bytes over +Math.random()>.5

saved another 4 bytes thanks to @Arnauld


答:
C, 46 Bytes recursive version

```<code>f(char*s){*s?putchar(*s&72?*s:*s^1),f(++s):0;}
</code>```

C, 47 Bytes iterative version

```<code>f(char*s){for(;*s;putchar(*s&72?*s:*s^1),s++);}
</code>```

Run using this main function

```<code>main(c,v)char**v;
{
    f(v[1]);
}
</code>```

and input like this

```<code>a.exe [1,0,1,1,0]
[0,1,0,0,1]
</code>```

Title: Invert a boolean array

Body:
C, 46 Bytes recursive version

f(char*s){*s?putchar(*s&72?*s:*s^1),f(++s):0;}

C, 47 Bytes iterative version

f(char*s){for(;*s;putchar(*s&72?*s:*s^1),s++);}

Run using this main function

main(c,v)char**v;
{
    f(v[1]);
}

and input like this

a.exe [1,0,1,1,0]
[0,1,0,0,1]


问:
Test if given number is a Keith number
Since Fibonacci numbers and sequences seems like a popular subject for code golf I thought that it might be a fun challenge to code golf with Keith numbers.

So I propose a challenge that is to create a function that takes an integer and gives back a true or false depending on the number is a Keith number or not.

More about Keith numbers

In recreational mathematics, a Keith number or repfigit number (short for repetitive Fibonacci-like digit) is a number in the following integer sequence:
  14, 19, 28, 47, 61, 75, 197, 742, 1104, 1537, 2208, 2580, …

Numberphile has a video explaining how to calculate a Keith number. But basically you take the digits of a number. Add them together and then take the last digits of the original number and add them to the sum of the calculation, rinse and repeat. And example to make it clear.

14
1 + 4 = 5

  4 + 5 = 9

  5 + 9 = 14

Input

An integer.

Output

True if the number is a Keith number. False if it's not..

答:
GolfScript (31 25 chars)

```<code>..[10base{.{+}*+(\}@*]?0>
</code>```

Input as an integer on top of the stack. Output is 0 (false) or 1 (true). Online demo which lists the Keith numbers up to 100.

Title: Test if given number is a Keith number

Body:
GolfScript (31 25 chars)

..[10base{.{+}*+(\}@*]?0>

Input as an integer on top of the stack. Output is 0 (false) or 1 (true). Online demo which lists the Keith numbers up to 100.


答:
C#, <s>204</s> 235 bytes

```<code>string n(string b){for(int i=0;i<b.Length;i++){if(b[i]=='['){var r="a";r=i==0||b[i-2]=='.'?"A":r;r=System.Text.RegularExpressions.Regex.IsMatch(b[i+4].ToString(),@"[aeiouAEIOU]")?r+"n":r;b=b.Insert(i+3,r);}}return b.Replace("[?]","");}
</code>```

Ungolfed full program:

```<code>using System;

class a
{
    static void Main()
    {
        string s = Console.ReadLine();
        a c = new a();
        Console.WriteLine(c.n(s));
    }

    string n(string b)
    {
        for (int i = 0; i < b.Length; i++)
        {
            if (b[i] == '[')
            {
                var r = "a";
                r = i == 0 || b[i - 2] == '.' ? "A" : r;
                r = System.Text.RegularExpressions.Regex.IsMatch(b[i + 4].ToString(), @"[aeiouAEIOU]") ? r + "n" : r;
                b = b.Insert(i + 3, r);
            }
        }
        return b.Replace("[?]", "");
    }
}
</code>```

I'm sure this could be improved, especially the Regex part, but can't think of anything right now.

Title: An A , or An An?

Body:
In English, there is the fun and simple difference between an and a: you use an when preceding a word starting with a vowel sound, and a when the word starts with a consonant sound.

For the sake of simplicity in this challenge, an precedes a word that starts with a vowel (aeiou), and a precedes a word that starts with a consonant.

Input

A string comprising only printable ASCII characters, with [?] appearing in places where you must choose to insert an or a. [?] will always appear before a word. You can assume that the sentence will be grammatically correct and formatted like normal.

Output

The input string with [?] replaced with the appropriate word (an or a). You do have to worry about capitalization!

When to Capitalize

Capitalize a word if it is preceded by no characters (is the first one in the input) or if it is preceded by one of .?! followed by a space.

Examples

```<code>Input: Hello, this is [?] world!
Output: Hello, this is a world!

Input: How about we build [?] big building. It will have [?] orange banana hanging out of [?] window.
Output: How about we build a big building. It will have an orange banana hanging out of a window.

Input: [?] giant en le sky.
Output: A giant en le sky.

Input: [?] yarn ball? [?] big one!
Output: A yarn ball? A big one!

Input: [?] hour ago I met [?] European.
Output: A hour ago I met an European.

Input: Hey sir [Richard], how 'bout [?] cat?
Output: Hey sir [Richard], how 'bout a cat?
</code>```

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

Body:
C#, <s>204</s> 235 bytes

string n(string b){for(int i=0;i<b.Length;i++){if(b[i]=='['){var r="a";r=i==0||b[i-2]=='.'?"A":r;r=System.Text.RegularExpressions.Regex.IsMatch(b[i+4].ToString(),@"[aeiouAEIOU]")?r+"n":r;b=b.Insert(i+3,r);}}return b.Replace("[?]","");}

Ungolfed full program:

using System;

class a
{
    static void Main()
    {
        string s = Console.ReadLine();
        a c = new a();
        Console.WriteLine(c.n(s));
    }

    string n(string b)
    {
        for (int i = 0; i < b.Length; i++)
        {
            if (b[i] == '[')
            {
                var r = "a";
                r = i == 0 || b[i - 2] == '.' ? "A" : r;
                r = System.Text.RegularExpressions.Regex.IsMatch(b[i + 4].ToString(), @"[aeiouAEIOU]") ? r + "n" : r;
                b = b.Insert(i + 3, r);
            }
        }
        return b.Replace("[?]", "");
    }
}

I'm sure this could be improved, especially the Regex part, but can't think of anything right now.


答:
Python 2, 24 bytes (non-competing)

```<code>lambda a:[i-1for i in a]
</code>```

Logic is similar to Steven's, but I tried to use this comment's idea, but different, because it still takes 0/1 arrays, not 0/-1. There is no byte shaving for using 0/-1, so let's be sane. Note that this is non-competing, until Steven or Lynn allows me to use the idea. If so, I might remove the non-competing mark. Note that this code cannot be shamelessly stolen, it's still here. Only Steven can use it for his answer.

Title: Invert a boolean array

Body:
Python 2, 24 bytes (non-competing)

lambda a:[i-1for i in a]

Logic is similar to Steven's, but I tried to use this comment's idea, but different, because it still takes 0/1 arrays, not 0/-1. There is no byte shaving for using 0/-1, so let's be sane. Note that this is non-competing, until Steven or Lynn allows me to use the idea. If so, I might remove the non-competing mark. Note that this code cannot be shamelessly stolen, it's still here. Only Steven can use it for his answer.


答:
Labyrinth, 9 bytes

```<code>,$:)%#$.,
</code>```

Try it online! Assumes newline-separated input with a trailing newline. Thanks to @MartinEnder for help with golfing.

This program's a bit weird for a Labyrinth program - it doesn't make use of the 2D nature of the language, and it actually bounces back and forth. On the first forward trip, we have:

```<code>[Moving rightward]
,            Read char c of input
 $           XOR c with implicit 0 at bottom of stack
  :)%        Calculate c % (c+1), erroring out if c == -1 from EOF, otherwise returns c
     #$      XOR with (length of stack == 1)
       .     Output (c^1) as char
        ,    Read newline

[Moving leftward]
       .     Output newline
      $      XOR two implicit 0s, stack [0]
    %#       Mod with (length of stack == 1), giving stack [0]
 $:)         Increment, duplicate then XOR, stack still [0]
,            Read char c of input
</code>```

The next occurence of $ then XORs the existing 0 on the stack with c, as opposed to an implicit 0 at the bottom of the stack like in the first run. Both situations leave the stack as [c], and the program repeats thereafter.

Alternative 9-bytes:

```<code>,:):/$.:,
,::)/)$.,
,:):%)$.,
</code>```

Title: Invert a boolean array

Body:
Labyrinth, 9 bytes

,$:)%#$.,

Try it online! Assumes newline-separated input with a trailing newline. Thanks to @MartinEnder for help with golfing.

This program's a bit weird for a Labyrinth program - it doesn't make use of the 2D nature of the language, and it actually bounces back and forth. On the first forward trip, we have:

[Moving rightward]
,            Read char c of input
 $           XOR c with implicit 0 at bottom of stack
  :)%        Calculate c % (c+1), erroring out if c == -1 from EOF, otherwise returns c
     #$      XOR with (length of stack == 1)
       .     Output (c^1) as char
        ,    Read newline

[Moving leftward]
       .     Output newline
      $      XOR two implicit 0s, stack [0]
    %#       Mod with (length of stack == 1), giving stack [0]
 $:)         Increment, duplicate then XOR, stack still [0]
,            Read char c of input

The next occurence of $ then XORs the existing 0 on the stack with c, as opposed to an implicit 0 at the bottom of the stack like in the first run. Both situations leave the stack as [c], and the program repeats thereafter.

Alternative 9-bytes:

,:):/$.:,
,::)/)$.,
,:):%)$.,


答:
Cheddar, 10 bytes

```<code>@.map((!))
</code>```

I hope I counted right as I'm writing from phone

Title: Invert a boolean array

Body:
Cheddar, 10 bytes

@.map((!))

I hope I counted right as I'm writing from phone


答:
R, <s>53</s> 41 bytes

A translation of @grc's python answer. Shaved off 12 bytes from the original translation through use of rep()'s each and length arguments (and partial argument matching), and by remembering that 0:1 is equivalent to c(0,1).

```<code>for(n in 2^(0:3))print(rep(0:1,e=n,l=16))
</code>```

<s>

```<code>for(n in 2^(0:3))print(rep(c(rep(0,n),rep(1,n)),8/n))
</code>```

</s>

You can also attempt a translation of @Gareth's J answer, something like this (34 bytes):

```<code>t(e1071::bincombinations(4))[4:1,]
</code>```

However, it uses a function that's not part of base R, and outputs a matrix which is hard to format into exact printed text like in the specification.

Body:
R, <s>53</s> 41 bytes

A translation of @grc's python answer. Shaved off 12 bytes from the original translation through use of rep()'s each and length arguments (and partial argument matching), and by remembering that 0:1 is equivalent to c(0,1).

for(n in 2^(0:3))print(rep(0:1,e=n,l=16))

<s>

for(n in 2^(0:3))print(rep(c(rep(0,n),rep(1,n)),8/n))

</s>

You can also attempt a translation of @Gareth's J answer, something like this (34 bytes):

t(e1071::bincombinations(4))[4:1,]

However, it uses a function that's not part of base R, and outputs a matrix which is hard to format into exact printed text like in the specification.


答:
PHP, 207 bytes

```<code>foreach(explode("[?]",$s)as$i=>$b){$r=Aa[$k=0|!strstr(".!?",''==($c=trim($a))?".":$c[strlen($c)-1])].n[!preg_match("#^['\"´`\s]*([aeiou]|$)#i",$d=trim($b))];echo$i?$r.$b:$b;$a=$i?''==$d?a:$b:(''==$d?".":a);}
</code>```

I like solutions more complete from time to time ...

but I must admit that this is a little overkill, although it´s not at all finished.

Save to file, run with php <filename> with input from STDIN.

test cases

```<code>How about we build [?] big building ... with [?] orange banana hanging out of [?] window.
=>  How about we build a big building ... with an orange banana hanging out of a window.

Hello, this is [?] world!               =>  Hello, this is a world!
Should I use [?] '[?]' or [?] '[?]'?    =>  Should I use an 'an' or an 'a'?
[?] elephant in [?] swimsuit.           =>  An elephant in a swimsuit.

How I met your moth[?].                 =>  How I met your motha.
b[?][?][?] short[?]ge!                  =>  banana shortage!
</code>```

breakdown

```<code>foreach(explode("[?]",$s)as$i=>$b)
{
    $r=
        // lookbehind: uppercase if the end of a sentence precedes
        Aa[$k=0|!strstr(".!?",''==($c=trim($a))?".":$c[strlen($c)-1])]
        .
        // lookahead: append "n" if a vowel follows (consider quote characters blank)
        n[!preg_match("#^['\"´`\s]*([aeiou]|$)#i",$d=trim($b))]
    ;
    // output replacement and this part
    echo$i?$r.$b:$b;
    // prepare previous part for next iteration
    $a=$i               // this part was NOT the first:
        ?   ''==$d
            ? a             // if empty -> a word ($r from the previous iteration)
            : $b            // default: $b
        :  (''==$d      // this WAS the first part:
            ? "."           // if empty: end of a sentence (= uppercase next $r)
            : a             // else not
        )
    ;
    // golfed down to `$a=!$i^''==$d?a:($i?$b:".");`
}
</code>```

Title: An A , or An An?

Body:
PHP, 207 bytes

foreach(explode("[?]",$s)as$i=>$b){$r=Aa[$k=0|!strstr(".!?",''==($c=trim($a))?".":$c[strlen($c)-1])].n[!preg_match("#^['\"´`\s]*([aeiou]|$)#i",$d=trim($b))];echo$i?$r.$b:$b;$a=$i?''==$d?a:$b:(''==$d?".":a);}

I like solutions more complete from time to time ...

but I must admit that this is a little overkill, although it´s not at all finished.

Save to file, run with php <filename> with input from STDIN.

test cases

How about we build [?] big building ... with [?] orange banana hanging out of [?] window.
=>  How about we build a big building ... with an orange banana hanging out of a window.

Hello, this is [?] world!               =>  Hello, this is a world!
Should I use [?] '[?]' or [?] '[?]'?    =>  Should I use an 'an' or an 'a'?
[?] elephant in [?] swimsuit.           =>  An elephant in a swimsuit.

How I met your moth[?].                 =>  How I met your motha.
b[?][?][?] short[?]ge!                  =>  banana shortage!

breakdown

foreach(explode("[?]",$s)as$i=>$b)
{
    $r=
        // lookbehind: uppercase if the end of a sentence precedes
        Aa[$k=0|!strstr(".!?",''==($c=trim($a))?".":$c[strlen($c)-1])]
        .
        // lookahead: append "n" if a vowel follows (consider quote characters blank)
        n[!preg_match("#^['\"´`\s]*([aeiou]|$)#i",$d=trim($b))]
    ;
    // output replacement and this part
    echo$i?$r.$b:$b;
    // prepare previous part for next iteration
    $a=$i               // this part was NOT the first:
        ?   ''==$d
            ? a             // if empty -> a word ($r from the previous iteration)
            : $b            // default: $b
        :  (''==$d      // this WAS the first part:
            ? "."           // if empty: end of a sentence (= uppercase next $r)
            : a             // else not
        )
    ;
    // golfed down to `$a=!$i^''==$d?a:($i?$b:".");`
}


问:
Output an upside-down tent
Given an integer, output an upside-down tent.

The input determines both the size of the tent (absolute value) and whether the entrance is on the left side (negative numbers) or the right side (positive numbers).

```<code>If input = -1:
____
\/_/

If input = -2:
________
\  /   /
 \/___/

If input = -3:
____________
\    /     /
 \  /     /
  \/_____/

If input = 1:
____
\_\/

If input = 2:
________
\   \  /
 \___\/

If input = 3:
____________
\     \    /
 \     \  /
  \_____\/

et cetera
</code>```

Note that the top of the tent (i.e. the last line) has 2 * abs(input) - 1 underscores.

There can be no leading spaces, such that the first line directly starts with an underscore.

Assume that the input will never be 0.

Your code should be as short as possible.

This challenge is based on a chat mini challenge by Helka Homba, which is allowed to be used in real challenges under the conditions of Calvin's Hobbies Public License.

答:
C#, <s>215</s> 214 bytes

```<code>string t(int N){var n=N<0;N=n?-N:N;var t=new string('_',4*N);for(int i=0;i<N;){string f=new string(i<N-1?' ':'_',2*N-1),p=new string(' ',2*N-2*i-2);t+='\n'+new string(' ',i++)+'\\'+(n?p+'/'+f:f+'\\'+p)+'/';}return t;}
</code>```

There's a possibility to save a few bytes when using using s=string; beforehand.

```<code>s t(int N){var n=N<0;N=n?-N:N;var t=new s('_',4*N);for(int i=0;i<N;){s f=new s(i<N-1?' ':'_',2*N-1),p=new s(' ',2*N-2*i-2);t+='\n'+new s(' ',i++)+'\\'+(n?p+'/'+f:f+'\\'+p)+'/';}return t;}
</code>```

which would be 15 (using) + 184 (method) = 199 bytes.

Title: Output an upside-down tent

Body:
C#, <s>215</s> 214 bytes

string t(int N){var n=N<0;N=n?-N:N;var t=new string('_',4*N);for(int i=0;i<N;){string f=new string(i<N-1?' ':'_',2*N-1),p=new string(' ',2*N-2*i-2);t+='\n'+new string(' ',i++)+'\\'+(n?p+'/'+f:f+'\\'+p)+'/';}return t;}

There's a possibility to save a few bytes when using using s=string; beforehand.

s t(int N){var n=N<0;N=n?-N:N;var t=new s('_',4*N);for(int i=0;i<N;){s f=new s(i<N-1?' ':'_',2*N-1),p=new s(' ',2*N-2*i-2);t+='\n'+new s(' ',i++)+'\\'+(n?p+'/'+f:f+'\\'+p)+'/';}return t;}

which would be 15 (using) + 184 (method) = 199 bytes.


答:
Racket 451 bytes (without regex)

It is obviously a long answer but it replaces a and an with capitalization also:

```<code>(define(lc sl item)(ormap(lambda(x)(equal? item x))sl))
(define(lr l i)(list-ref l i))(define(f str)(define sl(string-split str))
(for((i(length sl))#:when(equal?(lr sl i)"[?]"))(define o(if(lc(string->list"aeiouAEIOU")
(string-ref(lr sl(add1 i))0))#t #f))(define p(if(or(= i 0)(lc(string->list".!?")
(let((pr(lr sl(sub1 i))))(string-ref pr(sub1(string-length pr))))))#t #f))
(set! sl(list-set sl i(if o(if p"An""an")(if p"A""a")))))(string-join sl))
</code>```

Testing:

```<code>(f "[?] giant en le [?] sky.")
(f "[?] yarn ball?")
(f "[?] hour ago I met [?] European. ")
(f "How about we build [?] big building. It will have [?] orange banana hanging out of [?] window.")
(f "Hello, this is [?] world!")
</code>```

Output:

```<code>"A giant en le a sky."
"A yarn ball?"
"A hour ago I met an European."
"How about we build a big building. It will have an orange banana hanging out of a window."
"Hello, this is a world!"
</code>```

Detailed version:

```<code>(define(contains sl item)
  (ormap(lambda(x)(equal? item x))sl))

(define(lr l i)
  (list-ref l i))

(define(f str)
  (define sl(string-split str))
  (for((i(length sl))#:when(equal?(lr sl i)"[?]"))
    (define an   ; a or an
      (if(contains(string->list "aeiouAEIOU")
                  (string-ref(lr sl(add1 i))0))
         #t #f ))
    (define cap   ; capital or not
      (if(or(= i 0)(contains(string->list ".!?")
                            (let ((prev (lr sl(sub1 i)))) (string-ref prev
                                       (sub1(string-length prev))))))
         #t #f))
    (set! sl(list-set sl i (if an (if cap "An" "an" )
                                 (if cap "A" "a")))))
  (string-join sl))
</code>```

Title: An A , or An An?

Body:
Racket 451 bytes (without regex)

It is obviously a long answer but it replaces a and an with capitalization also:

(define(lc sl item)(ormap(lambda(x)(equal? item x))sl))
(define(lr l i)(list-ref l i))(define(f str)(define sl(string-split str))
(for((i(length sl))#:when(equal?(lr sl i)"[?]"))(define o(if(lc(string->list"aeiouAEIOU")
(string-ref(lr sl(add1 i))0))#t #f))(define p(if(or(= i 0)(lc(string->list".!?")
(let((pr(lr sl(sub1 i))))(string-ref pr(sub1(string-length pr))))))#t #f))
(set! sl(list-set sl i(if o(if p"An""an")(if p"A""a")))))(string-join sl))

Testing:

(f "[?] giant en le [?] sky.")
(f "[?] yarn ball?")
(f "[?] hour ago I met [?] European. ")
(f "How about we build [?] big building. It will have [?] orange banana hanging out of [?] window.")
(f "Hello, this is [?] world!")

Output:

"A giant en le a sky."
"A yarn ball?"
"A hour ago I met an European."
"How about we build a big building. It will have an orange banana hanging out of a window."
"Hello, this is a world!"

Detailed version:

(define(contains sl item)
  (ormap(lambda(x)(equal? item x))sl))

(define(lr l i)
  (list-ref l i))

(define(f str)
  (define sl(string-split str))
  (for((i(length sl))#:when(equal?(lr sl i)"[?]"))
    (define an   ; a or an
      (if(contains(string->list "aeiouAEIOU")
                  (string-ref(lr sl(add1 i))0))
         #t #f ))
    (define cap   ; capital or not
      (if(or(= i 0)(contains(string->list ".!?")
                            (let ((prev (lr sl(sub1 i)))) (string-ref prev
                                       (sub1(string-length prev))))))
         #t #f))
    (set! sl(list-set sl i (if an (if cap "An" "an" )
                                 (if cap "A" "a")))))
  (string-join sl))


问:
Make an error quine!
Your challenge: write a "program", for a language of your choice, that causes the compiler/interpreter/runtime to produce error output when compiling/running your program which is identical to your program's source code.

Rules:

Your program may be specific to a particular version or implementation of your language's compiler/interpreter/runtime environment. If so, please specify the particulars.

Only standard compiler/interpreter/runtime options are permitted. You cannot pass some weird flag to your compiler to get a specific result.

The program does not need to be syntactically or semantically valid, but I may give a bounty to the best syntactically valid submission.

The program must not produce any output of its own (e.g. by calling a print or output function). All output generated upon attempting to compile/run the program must originate from the compiler/interpreter/runtime.

The complete output of the compiler/interpreter/runtime must be exactly identical to your program source code.

The compiler/interpreter/runtime must generate at least one error message when invoked with your program.

This is a popularity contest. Most creative answer, as determined by upvotes, wins. If you can give a good case for using a standard loophole, you may do so.

答:
Straw

```<code>/opt/straw/straw.rb:108:in `initialize': no implicit conversion of nil into String (TypeError)
    from /opt/straw/straw.rb:108:in `new'
    from /opt/straw/straw.rb:108:in `step'
    from /opt/straw/straw.rb:225:in `run'
    from /opt/straw/straw.rb:254:in `<main>'
</code>```

Try It Online!

Title: Make an error quine!

Body:
Straw

/opt/straw/straw.rb:108:in `initialize': no implicit conversion of nil into String (TypeError)
    from /opt/straw/straw.rb:108:in `new'
    from /opt/straw/straw.rb:108:in `step'
    from /opt/straw/straw.rb:225:in `run'
    from /opt/straw/straw.rb:254:in `<main>'

Try It Online!


答:
Common Lisp, 134

CL can be quite unreadable at times.

```<code>(defun k(n)(do((a(map'list #'digit-char-p(prin1-to-string n))(cdr(nconc a(list(apply'+ a))))))((>=(car a)n)(and(> n 9)(=(car a)n)))))
</code>```

Some formatting to avoid horizontal scrolling:

```<code>(defun k(n)
  (do
    ((a(map'list #'digit-char-p(prin1-to-string n))(cdr(nconc a(list(apply'+ a))))))
    ((>=(car a)n)(and(> n 9)(=(car a)n)))))
</code>```

Test:

```<code>(loop for i from 10 to 1000
      if (k i)
      collect i)

=> (14 19 28 47 61 75 197 742)
</code>```

Title: Test if given number is a Keith number

Body:
Since Fibonacci numbers and sequences seems like a popular subject for code golf I thought that it might be a fun challenge to code golf with Keith numbers.

So I propose a challenge that is to create a function that takes an integer and gives back a true or false depending on the number is a Keith number or not.

More about Keith numbers

In recreational mathematics, a Keith number or repfigit number (short for repetitive Fibonacci-like digit) is a number in the following integer sequence:
  14, 19, 28, 47, 61, 75, 197, 742, 1104, 1537, 2208, 2580, …

Numberphile has a video explaining how to calculate a Keith number. But basically you take the digits of a number. Add them together and then take the last digits of the original number and add them to the sum of the calculation, rinse and repeat. And example to make it clear.

14
1 + 4 = 5

  4 + 5 = 9

  5 + 9 = 14

Input

An integer.

Output

True if the number is a Keith number. False if it's not..

Body:
Common Lisp, 134

CL can be quite unreadable at times.

(defun k(n)(do((a(map'list #'digit-char-p(prin1-to-string n))(cdr(nconc a(list(apply'+ a))))))((>=(car a)n)(and(> n 9)(=(car a)n)))))

Some formatting to avoid horizontal scrolling:

(defun k(n)
  (do
    ((a(map'list #'digit-char-p(prin1-to-string n))(cdr(nconc a(list(apply'+ a))))))
    ((>=(car a)n)(and(> n 9)(=(car a)n)))))

Test:

(loop for i from 10 to 1000
      if (k i)
      collect i)

=> (14 19 28 47 61 75 197 742)