答:
CJam, <s>29</s> 28 bytes

```<code>ls_,,:)W%]~{_[X<aA*A,]zo}fX;
</code>```

Explanation:

```<code>ls                              read input as string
  _                             duplicate input
   ,,                           create range of length input
      :)W%]                     add 1 to all elements and reverse
           ~                    dump array on stack
            {            }fX    for loop
             _                  duplicate input string
              [X<aA*            slice input string and multiply by 10
                    A,]         range(10)
                       zo       zip array and print (no separator)
                            ;   clear stack

</code>```

Try it online

Title: Invalid Invali Inval

Body:
This idea is loosely based upon @TùxCräftîñg's chat message.

Take a look at the below example sequence:

INVALID0, INVALID1, INVALID2 INVALID3, INVALID4... INVALID9

After INVALID9, it goes on like this:

INVALI0, INVALI1, INVALI2, INVALI3... INVALI9

And after INVALI9, it's like this:

INVAL0,INVAL1, INVAL2, INVAL3... INVAL9

After, INVAL9, it's like this:

INVA0, INVA1, INVA2, INVA3, ... INVA9

Notice how we we kept removing a letter from the word INVALID each time.

You'll keep repeating this until you reach a single letter, that is, the letter I:

I0, I1, I2, I3, I4 ... I9

Now, your task is, to take an input of a word, and produce a sequence from it like the above example. Your code must also work with single letters, and in that case the resulting sequence will be shorter.

You may choose any input and output format that you prefer (with or without a separator, as you wish), but you must specify which one you have chosen.

The sequence needs to be in the exact specified order.

The shortest code, in bytes, that successfully completes this challenge, wins the challenge.

Full sequence in the above example:

```<code>INVALID0, INVALID1, INVALID2, INVALID3, INVALID4, INVALID5, INVALID6, INVALID7, INVALID8, INVALID9, INVALI0, INVALI1, INVALI2, INVALI3, INVALI4, INVALI5, INVALI6, INVALI7, INVALI8, INVALI9, INVAL0, INVAL1, INVAL2, INVAL3, INVAL4, INVAL5, INVAL6, INVAL7, INVAL8, INVAL9, INVA0, INVA1, INVA2, INVA3, INVA4, INVA5, INVA6, INVA7, INVA8, INVA9, INV0, INV1, INV2, INV3, INV4, INV5, INV6, INV7, INV8, INV9, IN0, IN1, IN2, IN3, IN4, IN5, IN6, IN7, IN8, IN9, I0, I1, I2, I3, I4, I5, I6, I7, I8, I9
</code>```

Other examples:

Input: MAYBE (Uppercase and lowercase don't matter)

Output:

```<code>MAYBE0, MAYBE1, MAYBE2, MAYBE3, MAYBE4, MAYBE5, MAYBE6, MAYBE7, MAYBE8, MAYBE9, MAYB0, MAYB1, MAYB2, MAYB3, MAYB4, MAYB5, MAYB6, MAYB7, MAYB8, MAYB9, MAY0, MAY1, MAY2, MAY3, MAY4, MAY5, MAY6, MAY7, MAY8, MAY9, MA0, MA1, MA2, MA3, MA4, MA5, MA6, MA7, MA8, MA9, M0, M1, M2, M3, M4, M5, M6, M7, M8, M9
</code>```

Input: AFTER

Output:

```<code>AFTER0, AFTER1, AFTER2, AFTER3, AFTER4, AFTER5, AFTER6, AFTER7, AFTER8, AFTER9, AFTE0, AFTE1, AFTE2, AFTE3, AFTE4, AFTE5, AFTE6, AFTE7, AFTE8, AFTE9, AFT0, AFT1, AFT2, AFT3, AFT4, AFT5, AFT6, AFT7, AFT8, AFT9, AF0, AF1, AF2, AF3, AF4, AF5, AF6, AF7, AF8, AF9, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9
</code>```

Input: WHAT ARE YOU DOING

```<code>WHAT ARE YOU DOING0, WHAT ARE YOU DOING1, WHAT ARE YOU DOING2, WHAT ARE YOU DOING3, WHAT ARE YOU DOING4, WHAT ARE YOU DOING5, WHAT ARE YOU DOING6, WHAT ARE YOU DOING7, WHAT ARE YOU DOING8, WHAT ARE YOU DOING9, WHAT ARE YOU DOIN0, WHAT ARE YOU DOIN1, WHAT ARE YOU DOIN2, WHAT ARE YOU DOIN3, WHAT ARE YOU DOIN4, WHAT ARE YOU DOIN5, WHAT ARE YOU DOIN6, WHAT ARE YOU DOIN7, WHAT ARE YOU DOIN8, WHAT ARE YOU DOIN9, WHAT ARE YOU DOI0, WHAT ARE YOU DOI1, WHAT ARE YOU DOI2, WHAT ARE YOU DOI3, WHAT ARE YOU DOI4, WHAT ARE YOU DOI5, WHAT ARE YOU DOI6, WHAT ARE YOU DOI7, WHAT ARE YOU DOI8, WHAT ARE YOU DOI9, WHAT ARE YOU DO0, WHAT ARE YOU DO1, WHAT ARE YOU DO2, WHAT ARE YOU DO3, WHAT ARE YOU DO4, WHAT ARE YOU DO5, WHAT ARE YOU DO6, WHAT ARE YOU DO7, WHAT ARE YOU DO8, WHAT ARE YOU DO9, WHAT ARE YOU D0, WHAT ARE YOU D1, WHAT ARE YOU D2, WHAT ARE YOU D3, WHAT ARE YOU D4, WHAT ARE YOU D5, WHAT ARE YOU D6, WHAT ARE YOU D7, WHAT ARE YOU D8, WHAT ARE YOU D9, WHAT ARE YOU 0, WHAT ARE YOU 1, WHAT ARE YOU 2, WHAT ARE YOU 3, WHAT ARE YOU 4, WHAT ARE YOU 5, WHAT ARE YOU 6, WHAT ARE YOU 7, WHAT ARE YOU 8, WHAT ARE YOU 9, WHAT ARE YOU0, WHAT ARE YOU1, WHAT ARE YOU2, WHAT ARE YOU3, WHAT ARE YOU4, WHAT ARE YOU5, WHAT ARE YOU6, WHAT ARE YOU7, WHAT ARE YOU8, WHAT ARE YOU9, WHAT ARE YO0, WHAT ARE YO1, WHAT ARE YO2, WHAT ARE YO3, WHAT ARE YO4, WHAT ARE YO5, WHAT ARE YO6, WHAT ARE YO7, WHAT ARE YO8, WHAT ARE YO9, WHAT ARE Y0, WHAT ARE Y1, WHAT ARE Y2, WHAT ARE Y3, WHAT ARE Y4, WHAT ARE Y5, WHAT ARE Y6, WHAT ARE Y7, WHAT ARE Y8, WHAT ARE Y9, WHAT ARE 0, WHAT ARE 1, WHAT ARE 2, WHAT ARE 3, WHAT ARE 4, WHAT ARE 5, WHAT ARE 6, WHAT ARE 7, WHAT ARE 8, WHAT ARE 9, WHAT ARE0, WHAT ARE1, WHAT ARE2, WHAT ARE3, WHAT ARE4, WHAT ARE5, WHAT ARE6, WHAT ARE7, WHAT ARE8, WHAT ARE9, WHAT AR0, WHAT AR1, WHAT AR2, WHAT AR3, WHAT AR4, WHAT AR5, WHAT AR6, WHAT AR7, WHAT AR8, WHAT AR9, WHAT A0, WHAT A1, WHAT A2, WHAT A3, WHAT A4, WHAT A5, WHAT A6, WHAT A7, WHAT A8, WHAT A9, WHAT 0, WHAT 1, WHAT 2, WHAT 3, WHAT 4, WHAT 5, WHAT 6, WHAT 7, WHAT 8, WHAT 9, WHAT0, WHAT1, WHAT2, WHAT3, WHAT4, WHAT5, WHAT6, WHAT7, WHAT8, WHAT9, WHA0, WHA1, WHA2, WHA3, WHA4, WHA5, WHA6, WHA7, WHA8, WHA9, WH0, WH1, WH2, WH3, WH4, WH5, WH6, WH7, WH8, WH9, W0, W1, W2, W3, W4, W5, W6, W7, W8, W9
</code>```

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
CJam, <s>29</s> 28 bytes

ls_,,:)W%]~{_[X<aA*A,]zo}fX;

Explanation:

ls                              read input as string
  _                             duplicate input
   ,,                           create range of length input
      :)W%]                     add 1 to all elements and reverse
           ~                    dump array on stack
            {            }fX    for loop
             _                  duplicate input string
              [X<aA*            slice input string and multiply by 10
                    A,]         range(10)
                       zo       zip array and print (no separator)
                            ;   clear stack

Try it online


问:
Mirror, Mirror, in the Code
Two-dimensional programming languages often have mirror commands like / and \ to redirect the instruction pointer on the grid:

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

In this challenge, you're given an incoming direction and a mirror and you need to determine the outgoing direction.

Rules

The incoming direction will be given as one of the characters NESW and the mirror will be given as either / or \. You may receive these in any order. You must use uppercase letters.

You may take input in any convenient format, including a two-character string, a string using some separator between the characters, a pair of characters in a list, or even a pair of singleton strings. If you do use a string with separator, the separator cannot use any of the characters NWSE\/.

Output should be a character from NESW or single-character string.

You may write a program or a function and use any of the our standard methods of receiving input and providing output.

You may use any programming language, but note that these loopholes are forbidden by default.

This is code-golf, so the shortest valid answer – measured in bytes – wins.

Test Cases

There are only 8 possible inputs you need to handle, so there is no excuse for not testing your code on all of them:

```<code>N /   -->   W
N \   -->   E
E /   -->   S
E \   -->   N
S /   -->   E
S \   -->   W
W /   -->   N
W \   -->   S
</code>```

答:
TI-Basic, 40 bytes

Hardcodes the inputs. Boring, but the shortest way.

```<code>sub("NEWS",1+int(inString("E/W\N\S/N/S\E\W/",Ans)/4),1
</code>```

ContentLicense: CC BY-SA 3.0

Title: Mirror, Mirror, in the Code

Body:
TI-Basic, 40 bytes

Hardcodes the inputs. Boring, but the shortest way.

sub("NEWS",1+int(inString("E/W\N\S/N/S\E\W/",Ans)/4),1


问:
Play a sound, any sound
Your program has to make the computer produce a sound, any sound.

Shortest code wins, not sooner than 10 days after the first valid answer. If there is a tie, the one submitted sooner, wins.

The program should run on a reasonable, not too uncommon personal computer.

Opening a pop-up, message box, etc. (for example, on a web page) does not count, as they might or might not produce a sound, depending on a lot of settings.

Just entering a wrong command or invalid character on a console and receiving a warning beep does not count, just as the compiler/interpreter/OS beeping on an error or crash does not count either. Your code must be a valid program.

答:
*sh (5)

```<code>eject
</code>```

(does not work if you have no CD/DVD or similar drive..)

Title: Play a sound, any sound

Body:
*sh (5)

eject

(does not work if you have no CD/DVD or similar drive..)


问:
The Alphabet Chromosome

Introduction

Alphabet challenges are in our DNA, so let's show it.

Challenge

Print the following the text exactly:

```<code>AaBbCc        cCbBaA
BbCcDd        dDcCbB
EeFfGg        gGfFeE
HhIiJj        jJiIhH
KkLlMm        mMlLkK
NnOoPp        pPoOnN
QqRrSs        sSrRqQ
TtUuVv        vVuUtT
   WwXx      xXwW
       Yy  yY
         ZZ
         zz
         ZZ
       Yy  yY
   WwXx      xXwW
TtUuVv        vVuUtT
QqRrSs        sSrRqQ
NnOoPp        pPoOnN
KkLlMm        mMlLkK
HhIiJj        jJiIhH
EeFfGg        gGfFeE
BbCcDd        dDcCbB
AaBbCc        cCbBaA
</code>```

Rules

You must match the case of each letter

Trailing and/or leading newlines and/or spaces are allowed

Winning

Shortest code in bytes wins.

答:
///, 229 bytes

```<code>/*/\/\///^/        *0/AaBbCc^cCbBaA
*1/BbCcDd^dDcCbB
*2/EeFfGg^gGfFeE
*3/HhIiJj^jJiIhH
*4/KkLlMm^mMlLkK
*5/NnOoPp^pPoOnN
*6/QqRrSs^sSrRqQ
*7/TtUuVv^vVuUtT
*8/   WwXx      xXwW
*9/       Yy  yY
/0123456789^ ZZ
^ zz
^ ZZ
9876543210
</code>```

Try it online!

Title: The Alphabet Chromosome

Body:
///, 229 bytes

/*/\/\///^/        *0/AaBbCc^cCbBaA
*1/BbCcDd^dDcCbB
*2/EeFfGg^gGfFeE
*3/HhIiJj^jJiIhH
*4/KkLlMm^mMlLkK
*5/NnOoPp^pPoOnN
*6/QqRrSs^sSrRqQ
*7/TtUuVv^vVuUtT
*8/   WwXx      xXwW
*9/       Yy  yY
/0123456789^ ZZ
^ zz
^ ZZ
9876543210

Try it online!


问:
Hexplosive ASCII-art challenge
In the strategy game "Hexplode", players take turns placing tokens on a hexagonal board. Once the number of tokens equals the number of adjacent tiles, that tile hexplodes, and moves all of the tokes on it to the surrounding neighbors. You can play the game online here.

I like this game, but sometimes it's hard to know exactly how many tokens go on a specific tile; I'm always counting the number of neighbors. It would really convenient if I had an ASCII-art to help me remember how many tokens go on each tile.

You need to write a program or function that takes a positive integer as input, and produces this ASCII representation of hexagon of size N. Each tile will be the number of neighbors that tile has. Since 1 is a weird corner case with zero neighbors, you only have to handle inputs larger than 1.

You may take this number in any reasonable format, such as STDIN, function arguments, command-line arguments, from a file, etc. The output may also be in any reasonable format, such as printing to STDOUT, writing to a file, returning a list of strings, a newline separated string, etc.

Here is some sample output for the first 5 inputs:

```<code>2)

 3 3
3 6 3
 3 3

3)

  3 4 3
 4 6 6 4
3 6 6 6 3
 4 6 6 4
  3 4 3

4)

   3 4 4 3
  4 6 6 6 4
 4 6 6 6 6 4
3 6 6 6 6 6 3
 4 6 6 6 6 4
  4 6 6 6 4
   3 4 4 3

5)

    3 4 4 4 3
   4 6 6 6 6 4
  4 6 6 6 6 6 4
 4 6 6 6 6 6 6 4
3 6 6 6 6 6 6 6 3
 4 6 6 6 6 6 6 4
  4 6 6 6 6 6 4
   4 6 6 6 6 4
    3 4 4 4 3

6)

     3 4 4 4 4 3
    4 6 6 6 6 6 4
   4 6 6 6 6 6 6 4
  4 6 6 6 6 6 6 6 4
 4 6 6 6 6 6 6 6 6 4
3 6 6 6 6 6 6 6 6 6 3
 4 6 6 6 6 6 6 6 6 4
  4 6 6 6 6 6 6 6 4
   4 6 6 6 6 6 6 4
    4 6 6 6 6 6 4
     3 4 4 4 4 3
</code>```

And the pattern continues in a similar manner. As usual, standard loopholes apply, and the answer with the lowest byte-count will be crowned the winner!

Leaderboards

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

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

```<code># Language 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=92194,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

```

答:
Ruby, 87 bytes

Anonymous function takes n as argument and returns an array of strings.

```<code>->n{(1-n..n-=1).map{|i|j=i.abs
" "*j+(e=j%n>0?"4 ":"3 ")+["6 ","4 "][j/n]*(2*n-1-j)+e}}
</code>```

Ungolfed in test program

Input through stdin. Writes the whole shape to stdout.
Pretty self explanatory.

```<code>f=->n{
  (1-n..n-=1).map{|i|            #reduce n by 1 and iterate i from -n to n
    j=i.abs;                     #absolute magnitude of i
    " "*j+                       #j spaces +
    (e=j%n>0?"4 ":"3 ")+         #start the string with 3 or 4 +
    ["6 ","4 "][j/n]*(2*n-1-j)+  #2*n-1-j 6's or 4`s as appropriate +
    e                            #end the string with another 3 or 4
  }
}

puts f[gets.to_i]
</code>```

Title: Hexplosive ASCII-art challenge

Body:
Ruby, 87 bytes

Anonymous function takes n as argument and returns an array of strings.

->n{(1-n..n-=1).map{|i|j=i.abs
" "*j+(e=j%n>0?"4 ":"3 ")+["6 ","4 "][j/n]*(2*n-1-j)+e}}

Ungolfed in test program

Input through stdin. Writes the whole shape to stdout.
Pretty self explanatory.

f=->n{
  (1-n..n-=1).map{|i|            #reduce n by 1 and iterate i from -n to n
    j=i.abs;                     #absolute magnitude of i
    " "*j+                       #j spaces +
    (e=j%n>0?"4 ":"3 ")+         #start the string with 3 or 4 +
    ["6 ","4 "][j/n]*(2*n-1-j)+  #2*n-1-j 6's or 4`s as appropriate +
    e                            #end the string with another 3 or 4
  }
}

puts f[gets.to_i]


问:
Smallest positive number whose y-th power is divisible by x

Task

Given integers x and y which are both at least 2, find the smallest positive number whose y-th power is divisible by x.

Example

Given x=96 and y=2, the output should be 24 since 24 is the smallest positive n satisfying n^2 is divisible by 96.

Testcases

```<code>x  y output
26 2 26
96 2 24
32 3 4
64 9 2
27 3 3
</code>```

Scoring

This is code-golf. Solution with lowest byte-count wins.

References

y=2: OEIS A019554

y=3: OEIS A019555

y=4: OEIS A053166

y=5: OEIS A015052

y=6: OEIS A015054

答:
Pyth, 9 bytes

```<code>AQf!%^THG
</code>```

A program that takes input of a list of the form [x, y] on STDIN and prints the result.

Try it online

How it works

```<code>AQf!%^THG  Program. Input: Q
AQ         G=Q[0];H=Q[1]
  f        First truthy input T in [1, 2, 3, ...] with function:
     ^TH    T^H
    %   G   %G
   !        Logical not (0 -> True, all other modulus results -> False)
           Implicitly print
</code>```

Body:
Pyth, 9 bytes

AQf!%^THG

A program that takes input of a list of the form [x, y] on STDIN and prints the result.

Try it online

How it works

AQf!%^THG  Program. Input: Q
AQ         G=Q[0];H=Q[1]
  f        First truthy input T in [1, 2, 3, ...] with function:
     ^TH    T^H
    %   G   %G
   !        Logical not (0 -> True, all other modulus results -> False)
           Implicitly print


问:
Build a sandpile
An abelian sandpile, for our purposes, is an infinite grid with integer coordinates, initially empty of sand. After each second, a grain of sand is placed at (0,0). Whenever a grid cell has 4 or more grains of sand, it spills one grain of sand to each of its four neighbors simultaneously. The neighbors of (x,y) are (x-1,y), (x+1,y), (x,y-1), and (x,y+1).

When a cell spills, it may cause its neighbors to spill. Some facts:

This cascade will eventually stop.

The order in which the cells spill is irrelevant; the result will be the same.

Example

After 3 seconds, the grid looks like

```<code>.....
.....
..3..
.....
.....
</code>```

After 4 seconds:

```<code>.....
..1..
.1.1.
..1..
.....
</code>```

After 15 seconds:

```<code>.....
..3..
.333.
..3..
.....
</code>```

And after 16 seconds:

```<code>..1..
.212.
11.11
.212.
..1..
</code>```

The challenge

In as few bytes as possible, write a function that takes a single positive
integer t and outputs a picture of the sandpile after t seconds.

Input

A single positive integer t, in any format you choose.

Output

A picture of the sandpile after t seconds, using the characters

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

Edit: Use any four distinct characters you like, or draw a picture. If you're not using ".123" or "0123", specify in your answer what the characters signify.

Unlike in the examples, your output should contain the minimal number of rows and columns necessary to show the nonzero part of the sandpile.

That is, for input 3, the output should be

```<code> 3
</code>```

For 4, the output should be

```<code> .1.
 1.1
 .1.
</code>```

Scoring

Standard golf scoring applies.

Rules

No language functions or libraries that already know what a sandpile is are allowed.

Edit: The output section has been edited, the character set restriction has been completely lifted. Use any four distinct characters or colors you like.

答:
Matlab, <s>160 156</s> 148 bytes

```<code>n=input('');z=zeros(3*n);z(n+1,n+1)=n;for k=1:n;x=z>3;z=z+conv2(+x,1-mod(spiral(3),2),'s');z(x)=z(x)-4;end;v=find(sum(z));z=z(v,v);[z+48-(z<1)*2,'']
</code>```

First a way too big matrix is created, with the n in the middle somewhere. Then the cascading is calculated with a very convenient 2d convolution. At the end the excess is trimmed off and the whole thing is converted to a string.

Example output for t=100

```<code>...121...
..32.23..
.3.323.3.
123.3.321
2.23.32.2
123.3.321
.3.323.3.
..32.23..
...121...
</code>```

As always:

Convolution is the key to success.

Title: Build a sandpile

Body:
Matlab, <s>160 156</s> 148 bytes

n=input('');z=zeros(3*n);z(n+1,n+1)=n;for k=1:n;x=z>3;z=z+conv2(+x,1-mod(spiral(3),2),'s');z(x)=z(x)-4;end;v=find(sum(z));z=z(v,v);[z+48-(z<1)*2,'']

First a way too big matrix is created, with the n in the middle somewhere. Then the cascading is calculated with a very convenient 2d convolution. At the end the excess is trimmed off and the whole thing is converted to a string.

Example output for t=100

...121...
..32.23..
.3.323.3.
123.3.321
2.23.32.2
123.3.321
.3.323.3.
..32.23..
...121...

As always:

Convolution is the key to success.


答:
MATL, <s>55</s> <s>53</s> <s>48</s> <s>43</s> 42 bytes

Inspired by @flawr's answer.

Graphical output:

```<code>0i:"Gto~+XytP*+t"t4=t1Y6Z+b+w~*]]tat3$)1YG
</code>```

Try it at MATL Online!. It takes about 10 seconds for input 30. You may need to refresh the page and press "Run" again if it doesn't work.

Here's an example result for input 100:

ASCII output (43 bytes):

```<code>0i:"Gto~+XytP*+t"t4=t1Y6Z+b+w~*]]tat3$)48+c
</code>```

Try it online!

Explanation

```<code>0          % Push a 0. This is the initial array. Will be resized in first iteration
i:         % Take input n. Generate range [1 2 ... n]
"          % For each, i.e. repeat n times
  Gto~+    %   Push input and add negate parity. This "rounds up" n to odd number
           %   m = n or n+1
  Xy       %   Identity matrix with that size
  tP*      %   Multiply element-wise by vertically flipped copy. This produces a
           %   matrix with a 1 in the center and the rest entries equal to 0
  +        %   Add to previous array. This updates the sandpile array
  t        %   Duplicate
  "        %   For each column (i.e. repeat m times)
    t4=    %     Duplicate. Compare with 4 element-wise. This gives a 2D mask that
           %     contains 1 for entries of the sandpile array that equal 4, and 0
           %     for the rest
    t      %     Duplicate
    1Y6    %     Predefined literal: [0 1 0; 1 0 1; 0 1 0]
    Z+     %     2D convolution, maintaining size
    b      %     Bubble up to bring sandpile array to top
    +      %     Element-wise addition. This adds 1 to the neighbours of a 4
    w      %     Swap to bring copy of mask to top
    ~*     %     Multiply bu negated mask. This removes all previous 4
  ]        %  End
]          % End
t          % Duplicate the updated sandpile array
a          % 1D mask that contains 1 for columns that contain a 1. This will be
           % used as a logical index to select columns
t          % Duplicate. This will be used as logical index to select rows (this
           % can be done because of symmetry)
3$)        % Keep only those rows and columns. This trims the outer zeros in the
           % sandpile array
1YG        % Display as scaled image
</code>```

Title: Build a sandpile

Body:
An abelian sandpile, for our purposes, is an infinite grid with integer coordinates, initially empty of sand. After each second, a grain of sand is placed at (0,0). Whenever a grid cell has 4 or more grains of sand, it spills one grain of sand to each of its four neighbors simultaneously. The neighbors of (x,y) are (x-1,y), (x+1,y), (x,y-1), and (x,y+1).

When a cell spills, it may cause its neighbors to spill. Some facts:

This cascade will eventually stop.

The order in which the cells spill is irrelevant; the result will be the same.

Example

After 3 seconds, the grid looks like

```<code>.....
.....
..3..
.....
.....
</code>```

After 4 seconds:

```<code>.....
..1..
.1.1.
..1..
.....
</code>```

After 15 seconds:

```<code>.....
..3..
.333.
..3..
.....
</code>```

And after 16 seconds:

```<code>..1..
.212.
11.11
.212.
..1..
</code>```

The challenge

In as few bytes as possible, write a function that takes a single positive
integer t and outputs a picture of the sandpile after t seconds.

Input

A single positive integer t, in any format you choose.

Output

A picture of the sandpile after t seconds, using the characters

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

Edit: Use any four distinct characters you like, or draw a picture. If you're not using ".123" or "0123", specify in your answer what the characters signify.

Unlike in the examples, your output should contain the minimal number of rows and columns necessary to show the nonzero part of the sandpile.

That is, for input 3, the output should be

```<code> 3
</code>```

For 4, the output should be

```<code> .1.
 1.1
 .1.
</code>```

Scoring

Standard golf scoring applies.

Rules

No language functions or libraries that already know what a sandpile is are allowed.

Edit: The output section has been edited, the character set restriction has been completely lifted. Use any four distinct characters or colors you like.

Body:
MATL, <s>55</s> <s>53</s> <s>48</s> <s>43</s> 42 bytes

Inspired by @flawr's answer.

Graphical output:

0i:"Gto~+XytP*+t"t4=t1Y6Z+b+w~*]]tat3$)1YG

Try it at MATL Online!. It takes about 10 seconds for input 30. You may need to refresh the page and press "Run" again if it doesn't work.

Here's an example result for input 100:

ASCII output (43 bytes):

0i:"Gto~+XytP*+t"t4=t1Y6Z+b+w~*]]tat3$)48+c

Try it online!

Explanation

0          % Push a 0. This is the initial array. Will be resized in first iteration
i:         % Take input n. Generate range [1 2 ... n]
"          % For each, i.e. repeat n times
  Gto~+    %   Push input and add negate parity. This "rounds up" n to odd number
           %   m = n or n+1
  Xy       %   Identity matrix with that size
  tP*      %   Multiply element-wise by vertically flipped copy. This produces a
           %   matrix with a 1 in the center and the rest entries equal to 0
  +        %   Add to previous array. This updates the sandpile array
  t        %   Duplicate
  "        %   For each column (i.e. repeat m times)
    t4=    %     Duplicate. Compare with 4 element-wise. This gives a 2D mask that
           %     contains 1 for entries of the sandpile array that equal 4, and 0
           %     for the rest
    t      %     Duplicate
    1Y6    %     Predefined literal: [0 1 0; 1 0 1; 0 1 0]
    Z+     %     2D convolution, maintaining size
    b      %     Bubble up to bring sandpile array to top
    +      %     Element-wise addition. This adds 1 to the neighbours of a 4
    w      %     Swap to bring copy of mask to top
    ~*     %     Multiply bu negated mask. This removes all previous 4
  ]        %  End
]          % End
t          % Duplicate the updated sandpile array
a          % 1D mask that contains 1 for columns that contain a 1. This will be
           % used as a logical index to select columns
t          % Duplicate. This will be used as logical index to select rows (this
           % can be done because of symmetry)
3$)        % Keep only those rows and columns. This trims the outer zeros in the
           % sandpile array
1YG        % Display as scaled image

ContentLicense: CC BY-SA 4.0


答:
R, <s>378</s> <s>343</s> <s>297</s> 291 bytes

As usually, the user supplies his/her input via scan() (I already used the variable t, so let us take z instead), so the second line should be launched separately, and then the rest:

e=numeric
a=1%*%scan()
x=1
o=a>3
n=1
while(any(o)){
v=which(o,T)
if(any(v==1)){a=rbind(e(n+2),cbind(e(n),a,e(n)),e(n+2));x=x+1;n=n+2;v=which(a>3,T)}
q=nrow(v)
u=cbind(e(q),1)
l=v-u[,1:2];r=v+u[,1:2];t=v-u[,2:1];b=v+u[,2:1]
a[l]=a[l]+1;a[r]=a[r]+1;a[t]=a[t]+1;a[b]=a[b]+1
a[v]=a[v]-4
o=a>3}
a
```

<p>Outputs an array that contains the values of <code>a</code> at <code>t</code>th generation (0, 1, 2 or 3).</p>

<p>Test cases:</p>

<pre class="lang-r prettyprint-override"><code>z=3
     [,1]
[1,]    3
z=4
     [,1] [,2] [,3]
[1,]    0    1    0
[2,]    1    0    1
[3,]    0    1    0
z=16
     [,1] [,2] [,3] [,4] [,5]
[1,]    0    0    1    0    0
[2,]    0    2    1    2    0
[3,]    1    1    0    1    1
[4,]    0    2    1    2    0
[5,]    0    0    1    0    0
</code>```

It helps us that this thing is symmetrical both vertcially and horizontally, which means that is the leftmost point gets a height of 4, this means that the topmost, rightmost and lowest points are also 4.

Oh, and did I say that you can make beautiful visualisations?

After 1000 drops:

After 50000 drops (≈4 seconds):

After 333333 drops (≈15 minutes):

You can draw it, too!

image(1:n,1:n,a,col=colorRampPalette(c("#FFFFFF","#000000"))(4), axes=F, xlab="", ylab="")
```

<p>This thing took 4 seconds for 10000 iterations but slows down considerably for larger array sizes (e.g. a couple of minutes for 100000 iterations). This is why it gets so slow (I estimated the growth rate as in <img src="https://i.stack.imgur.com/5h0xt.png" alt="Growth rate"> and obtained  τ(i)≈689·i^1.08, so the average time per one additional grain until the whole sandpile settles after <code>i</code>th step is slightly larger than one), and the total time as a function of the number of grains grows a little bit slower than quadratically (T(i)≈0.028*i^1.74):</p>

<p><img src="https://i.stack.imgur.com/dHfnE.png" alt="Average iteration until the pile settles"></p>

<p><img src="https://i.stack.imgur.com/cr3zX.png" alt="Approximate computation time"></p>

<p>And now with a complete explanation:</p>

<pre class="lang-r prettyprint-override"><code>e=numeric # Convenient abbreviation for further repeated use
a=1%*%scan() # Creates a 1×1 array with a user-supplied number
x=1 # The coordinate of the centre
o=a>3 # Remember which cells were overflown
n=1 # Array height that is going to change over time
while(any(o)){ # If there is still any overflow
  v=which(o,T) # Get overflown cells' indices
  if(any(v==1)){ # If overflow occurred at the border, grow the array
    a=rbind(e(n+2),cbind(e(n),a,e(n)),e(n+2)) # Growing
    x=x+1 # Move the centre
    n=n+2 # Change the height
    v=which(a>3,T) # Re-index the overflowed cells
    }
  q=nrow(v) # See how many indices are overflown
  u=cbind(e(q),1) # Building block for neighbours' indices
  l=v-u[,1:2];r=v+u[,1:2];t=v-u[,2:1];b=v+u[,2:1] # L, R, T, B neighbours
  a[l]=a[l]+1;a[r]=a[r]+1;a[t]=a[t]+1;a[b]=a[b]+1 # Increment neighbours
  a[v]=a[v]-4 # Remove 4 grains from the overflown indices
  o=a>3} # See if still overflown indices remain
a # Output the matrix
</code>```

This is the first time in my life when growing objects (like a <- c(a, 1)) works so much faster than pre-allocating a big empty matrix for values and filling it gradually with a ton of zeros unused.

Update. Golfed 18 bytes by removing arr.ind in which owing to Billywob and replacing rep(0,n) with e=numeric;e(n) in 5 instances owing to JDL, and 17 more bytes owing to JDL.

Update 2. Since the sandpile is Abelian, it may start with a stack of desired height, so I removed the redundant loop and gained a huge boost in productivity!

Title: Build a sandpile

Body:
R, <s>378</s> <s>343</s> <s>297</s> 291 bytes

As usually, the user supplies his/her input via scan() (I already used the variable t, so let us take z instead), so the second line should be launched separately, and then the rest:

e=numeric
a=1%*%scan()
x=1
o=a>3
n=1
while(any(o)){
v=which(o,T)
if(any(v==1)){a=rbind(e(n+2),cbind(e(n),a,e(n)),e(n+2));x=x+1;n=n+2;v=which(a>3,T)}
q=nrow(v)
u=cbind(e(q),1)
l=v-u[,1:2];r=v+u[,1:2];t=v-u[,2:1];b=v+u[,2:1]
a[l]=a[l]+1;a[r]=a[r]+1;a[t]=a[t]+1;a[b]=a[b]+1
a[v]=a[v]-4
o=a>3}
a

Outputs an array that contains the values of a at tth generation (0, 1, 2 or 3).

Test cases:

z=3
     [,1]
[1,]    3
z=4
     [,1] [,2] [,3]
[1,]    0    1    0
[2,]    1    0    1
[3,]    0    1    0
z=16
     [,1] [,2] [,3] [,4] [,5]
[1,]    0    0    1    0    0
[2,]    0    2    1    2    0
[3,]    1    1    0    1    1
[4,]    0    2    1    2    0
[5,]    0    0    1    0    0

It helps us that this thing is symmetrical both vertcially and horizontally, which means that is the leftmost point gets a height of 4, this means that the topmost, rightmost and lowest points are also 4.

Oh, and did I say that you can make beautiful visualisations?

After 1000 drops:

After 50000 drops (≈4 seconds):

After 333333 drops (≈15 minutes):

You can draw it, too!

image(1:n,1:n,a,col=colorRampPalette(c("#FFFFFF","#000000"))(4), axes=F, xlab="", ylab="")

This thing took 4 seconds for 10000 iterations but slows down considerably for larger array sizes (e.g. a couple of minutes for 100000 iterations). This is why it gets so slow (I estimated the growth rate as in  and obtained  τ(i)≈689·i^1.08, so the average time per one additional grain until the whole sandpile settles after ith step is slightly larger than one), and the total time as a function of the number of grains grows a little bit slower than quadratically (T(i)≈0.028*i^1.74):

And now with a complete explanation:

e=numeric # Convenient abbreviation for further repeated use
a=1%*%scan() # Creates a 1×1 array with a user-supplied number
x=1 # The coordinate of the centre
o=a>3 # Remember which cells were overflown
n=1 # Array height that is going to change over time
while(any(o)){ # If there is still any overflow
  v=which(o,T) # Get overflown cells' indices
  if(any(v==1)){ # If overflow occurred at the border, grow the array
    a=rbind(e(n+2),cbind(e(n),a,e(n)),e(n+2)) # Growing
    x=x+1 # Move the centre
    n=n+2 # Change the height
    v=which(a>3,T) # Re-index the overflowed cells
    }
  q=nrow(v) # See how many indices are overflown
  u=cbind(e(q),1) # Building block for neighbours' indices
  l=v-u[,1:2];r=v+u[,1:2];t=v-u[,2:1];b=v+u[,2:1] # L, R, T, B neighbours
  a[l]=a[l]+1;a[r]=a[r]+1;a[t]=a[t]+1;a[b]=a[b]+1 # Increment neighbours
  a[v]=a[v]-4 # Remove 4 grains from the overflown indices
  o=a>3} # See if still overflown indices remain
a # Output the matrix

This is the first time in my life when growing objects (like a <- c(a, 1)) works so much faster than pre-allocating a big empty matrix for values and filling it gradually with a ton of zeros unused.

Update. Golfed 18 bytes by removing arr.ind in which owing to Billywob and replacing rep(0,n) with e=numeric;e(n) in 5 instances owing to JDL, and 17 more bytes owing to JDL.

Update 2. Since the sandpile is Abelian, it may start with a stack of desired height, so I removed the redundant loop and gained a huge boost in productivity!


问:
Invalid Invali Inval
This idea is loosely based upon @TùxCräftîñg's chat message.

Take a look at the below example sequence:

INVALID0, INVALID1, INVALID2 INVALID3, INVALID4... INVALID9

After INVALID9, it goes on like this:

INVALI0, INVALI1, INVALI2, INVALI3... INVALI9

And after INVALI9, it's like this:

INVAL0,INVAL1, INVAL2, INVAL3... INVAL9

After, INVAL9, it's like this:

INVA0, INVA1, INVA2, INVA3, ... INVA9

Notice how we we kept removing a letter from the word INVALID each time.

You'll keep repeating this until you reach a single letter, that is, the letter I:

I0, I1, I2, I3, I4 ... I9

Now, your task is, to take an input of a word, and produce a sequence from it like the above example. Your code must also work with single letters, and in that case the resulting sequence will be shorter.

You may choose any input and output format that you prefer (with or without a separator, as you wish), but you must specify which one you have chosen.

The sequence needs to be in the exact specified order.

The shortest code, in bytes, that successfully completes this challenge, wins the challenge.

Full sequence in the above example:

```<code>INVALID0, INVALID1, INVALID2, INVALID3, INVALID4, INVALID5, INVALID6, INVALID7, INVALID8, INVALID9, INVALI0, INVALI1, INVALI2, INVALI3, INVALI4, INVALI5, INVALI6, INVALI7, INVALI8, INVALI9, INVAL0, INVAL1, INVAL2, INVAL3, INVAL4, INVAL5, INVAL6, INVAL7, INVAL8, INVAL9, INVA0, INVA1, INVA2, INVA3, INVA4, INVA5, INVA6, INVA7, INVA8, INVA9, INV0, INV1, INV2, INV3, INV4, INV5, INV6, INV7, INV8, INV9, IN0, IN1, IN2, IN3, IN4, IN5, IN6, IN7, IN8, IN9, I0, I1, I2, I3, I4, I5, I6, I7, I8, I9
</code>```

Other examples:

Input: MAYBE (Uppercase and lowercase don't matter)

Output:

```<code>MAYBE0, MAYBE1, MAYBE2, MAYBE3, MAYBE4, MAYBE5, MAYBE6, MAYBE7, MAYBE8, MAYBE9, MAYB0, MAYB1, MAYB2, MAYB3, MAYB4, MAYB5, MAYB6, MAYB7, MAYB8, MAYB9, MAY0, MAY1, MAY2, MAY3, MAY4, MAY5, MAY6, MAY7, MAY8, MAY9, MA0, MA1, MA2, MA3, MA4, MA5, MA6, MA7, MA8, MA9, M0, M1, M2, M3, M4, M5, M6, M7, M8, M9
</code>```

Input: AFTER

Output:

```<code>AFTER0, AFTER1, AFTER2, AFTER3, AFTER4, AFTER5, AFTER6, AFTER7, AFTER8, AFTER9, AFTE0, AFTE1, AFTE2, AFTE3, AFTE4, AFTE5, AFTE6, AFTE7, AFTE8, AFTE9, AFT0, AFT1, AFT2, AFT3, AFT4, AFT5, AFT6, AFT7, AFT8, AFT9, AF0, AF1, AF2, AF3, AF4, AF5, AF6, AF7, AF8, AF9, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9
</code>```

Input: WHAT ARE YOU DOING

```<code>WHAT ARE YOU DOING0, WHAT ARE YOU DOING1, WHAT ARE YOU DOING2, WHAT ARE YOU DOING3, WHAT ARE YOU DOING4, WHAT ARE YOU DOING5, WHAT ARE YOU DOING6, WHAT ARE YOU DOING7, WHAT ARE YOU DOING8, WHAT ARE YOU DOING9, WHAT ARE YOU DOIN0, WHAT ARE YOU DOIN1, WHAT ARE YOU DOIN2, WHAT ARE YOU DOIN3, WHAT ARE YOU DOIN4, WHAT ARE YOU DOIN5, WHAT ARE YOU DOIN6, WHAT ARE YOU DOIN7, WHAT ARE YOU DOIN8, WHAT ARE YOU DOIN9, WHAT ARE YOU DOI0, WHAT ARE YOU DOI1, WHAT ARE YOU DOI2, WHAT ARE YOU DOI3, WHAT ARE YOU DOI4, WHAT ARE YOU DOI5, WHAT ARE YOU DOI6, WHAT ARE YOU DOI7, WHAT ARE YOU DOI8, WHAT ARE YOU DOI9, WHAT ARE YOU DO0, WHAT ARE YOU DO1, WHAT ARE YOU DO2, WHAT ARE YOU DO3, WHAT ARE YOU DO4, WHAT ARE YOU DO5, WHAT ARE YOU DO6, WHAT ARE YOU DO7, WHAT ARE YOU DO8, WHAT ARE YOU DO9, WHAT ARE YOU D0, WHAT ARE YOU D1, WHAT ARE YOU D2, WHAT ARE YOU D3, WHAT ARE YOU D4, WHAT ARE YOU D5, WHAT ARE YOU D6, WHAT ARE YOU D7, WHAT ARE YOU D8, WHAT ARE YOU D9, WHAT ARE YOU 0, WHAT ARE YOU 1, WHAT ARE YOU 2, WHAT ARE YOU 3, WHAT ARE YOU 4, WHAT ARE YOU 5, WHAT ARE YOU 6, WHAT ARE YOU 7, WHAT ARE YOU 8, WHAT ARE YOU 9, WHAT ARE YOU0, WHAT ARE YOU1, WHAT ARE YOU2, WHAT ARE YOU3, WHAT ARE YOU4, WHAT ARE YOU5, WHAT ARE YOU6, WHAT ARE YOU7, WHAT ARE YOU8, WHAT ARE YOU9, WHAT ARE YO0, WHAT ARE YO1, WHAT ARE YO2, WHAT ARE YO3, WHAT ARE YO4, WHAT ARE YO5, WHAT ARE YO6, WHAT ARE YO7, WHAT ARE YO8, WHAT ARE YO9, WHAT ARE Y0, WHAT ARE Y1, WHAT ARE Y2, WHAT ARE Y3, WHAT ARE Y4, WHAT ARE Y5, WHAT ARE Y6, WHAT ARE Y7, WHAT ARE Y8, WHAT ARE Y9, WHAT ARE 0, WHAT ARE 1, WHAT ARE 2, WHAT ARE 3, WHAT ARE 4, WHAT ARE 5, WHAT ARE 6, WHAT ARE 7, WHAT ARE 8, WHAT ARE 9, WHAT ARE0, WHAT ARE1, WHAT ARE2, WHAT ARE3, WHAT ARE4, WHAT ARE5, WHAT ARE6, WHAT ARE7, WHAT ARE8, WHAT ARE9, WHAT AR0, WHAT AR1, WHAT AR2, WHAT AR3, WHAT AR4, WHAT AR5, WHAT AR6, WHAT AR7, WHAT AR8, WHAT AR9, WHAT A0, WHAT A1, WHAT A2, WHAT A3, WHAT A4, WHAT A5, WHAT A6, WHAT A7, WHAT A8, WHAT A9, WHAT 0, WHAT 1, WHAT 2, WHAT 3, WHAT 4, WHAT 5, WHAT 6, WHAT 7, WHAT 8, WHAT 9, WHAT0, WHAT1, WHAT2, WHAT3, WHAT4, WHAT5, WHAT6, WHAT7, WHAT8, WHAT9, WHA0, WHA1, WHA2, WHA3, WHA4, WHA5, WHA6, WHA7, WHA8, WHA9, WH0, WH1, WH2, WH3, WH4, WH5, WH6, WH7, WH8, WH9, W0, W1, W2, W3, W4, W5, W6, W7, W8, W9
</code>```

Leaderboard

var QUESTION_ID=92156,OVERRIDE_USER=58717;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

```

答:
Ruby, 51

No separator used.

```<code>->s{(10*n=s.size).times{|i|print s[0,n-i/10],i%10}}
</code>```

Add the following after i%10 for separators:

,$/ for newline, ,?| for |  (similar for any printable character), ,' ' for space.

In test program

```<code>f=->s{(10*n=s.size).times{|i|print s[0,n-i/10],i%10}}

f[gets.chomp]
</code>```

Title: Invalid Invali Inval

Body:
Ruby, 51

No separator used.

->s{(10*n=s.size).times{|i|print s[0,n-i/10],i%10}}

Add the following after i%10 for separators:

,$/ for newline, ,?| for |  (similar for any printable character), ,' ' for space.

In test program

f=->s{(10*n=s.size).times{|i|print s[0,n-i/10],i%10}}

f[gets.chomp]


问:
Products of Consecutive Primes
As of time of submission to the sandbox, I had 17017 reputation, which you will all be able to factorise as 7×11×13×17, a product of 4 consecutive primes.

Please write a function or program to output all the products of two or more consecutive primes up to an input integer n. For example, given n=143 you should output 6, 15, 30, 35, 77, 105, 143 (or equivalent output format).

Normal restrictions on I/O and loopholes apply.

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

答:
Jelly, 11 bytes

```<code>ÆfÆCI=1Ȧµ€T
</code>```

Not the shortest Jelly answer, but this approach is rather efficient and the output is sorted.

Try it online!

How it works

```<code>ÆfÆCI=1Ȧµ€T  Main link. Argument: n

        µ€   Map the preceding chain over each k in [1, ..., n].
Æf             Compute all prime factors of k, with multiplicities.
  ÆC           Count the number of primes less than or equal to each prime factor.
               This maps the j-th to j.
    I          Increments; compute the forward differences of consecutive indices.
     =1        Compare each difference with 1.
       Ȧ       All; return 1 iff the array is non-empty and has no zeroes.
          T  Truth; yield all indices for which the chain returned 1.
</code>```

Title: Products of Consecutive Primes

Body:
Jelly, 11 bytes

ÆfÆCI=1Ȧµ€T

Not the shortest Jelly answer, but this approach is rather efficient and the output is sorted.

Try it online!

How it works

ÆfÆCI=1Ȧµ€T  Main link. Argument: n

        µ€   Map the preceding chain over each k in [1, ..., n].
Æf             Compute all prime factors of k, with multiplicities.
  ÆC           Count the number of primes less than or equal to each prime factor.
               This maps the j-th to j.
    I          Increments; compute the forward differences of consecutive indices.
     =1        Compare each difference with 1.
       Ȧ       All; return 1 iff the array is non-empty and has no zeroes.
          T  Truth; yield all indices for which the chain returned 1.


Title: Hexplosive ASCII-art challenge

Body:
In the strategy game "Hexplode", players take turns placing tokens on a hexagonal board. Once the number of tokens equals the number of adjacent tiles, that tile hexplodes, and moves all of the tokes on it to the surrounding neighbors. You can play the game online here.

I like this game, but sometimes it's hard to know exactly how many tokens go on a specific tile; I'm always counting the number of neighbors. It would really convenient if I had an ASCII-art to help me remember how many tokens go on each tile.

You need to write a program or function that takes a positive integer as input, and produces this ASCII representation of hexagon of size N. Each tile will be the number of neighbors that tile has. Since 1 is a weird corner case with zero neighbors, you only have to handle inputs larger than 1.

You may take this number in any reasonable format, such as STDIN, function arguments, command-line arguments, from a file, etc. The output may also be in any reasonable format, such as printing to STDOUT, writing to a file, returning a list of strings, a newline separated string, etc.

Here is some sample output for the first 5 inputs:

```<code>2)

 3 3
3 6 3
 3 3

3)

  3 4 3
 4 6 6 4
3 6 6 6 3
 4 6 6 4
  3 4 3

4)

   3 4 4 3
  4 6 6 6 4
 4 6 6 6 6 4
3 6 6 6 6 6 3
 4 6 6 6 6 4
  4 6 6 6 4
   3 4 4 3

5)

    3 4 4 4 3
   4 6 6 6 6 4
  4 6 6 6 6 6 4
 4 6 6 6 6 6 6 4
3 6 6 6 6 6 6 6 3
 4 6 6 6 6 6 6 4
  4 6 6 6 6 6 4
   4 6 6 6 6 4
    3 4 4 4 3

6)

     3 4 4 4 4 3
    4 6 6 6 6 6 4
   4 6 6 6 6 6 6 4
  4 6 6 6 6 6 6 6 4
 4 6 6 6 6 6 6 6 6 4
3 6 6 6 6 6 6 6 6 6 3
 4 6 6 6 6 6 6 6 6 4
  4 6 6 6 6 6 6 6 4
   4 6 6 6 6 6 6 4
    4 6 6 6 6 6 4
     3 4 4 4 4 3
</code>```

And the pattern continues in a similar manner. As usual, standard loopholes apply, and the answer with the lowest byte-count will be crowned the winner!

Leaderboards

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

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

```<code># Language 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=92194,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:
Racket, 487 bytes

(λ(n c e o)(let((sp(append(range(- n 1)-1 -1)(reverse(range(- n 1)0 -1))))
(mm(append(range(- n 2)(-(+ n(- n 1))2))(range(-(+ n(- n 1))2)(-(- n 1)2)-1)))
(r""))(for((i sp)(j mm))(define str"")(for((ss i))(set! str(string-append str" ")))
(set! str(string-append str(if(or(= i 0)(= i(- n 1))(= i(* 2(- n 1))))c e)" "))
(for((jj j))(set! str(string-append str(if(= j(- n 2))e o)" ")))(set! r(if(or(= i 0)
(= i(- n 1))(= i(* 2(- n 1))))c e))(set! str(string-append str r))(displayln str))))

Testing:

(f 4 "3" "4" "6")

   3 4 4 3
  4 6 6 6 4
 4 6 6 6 6 4
3 6 6 6 6 6 3
 4 6 6 6 6 4
  4 6 6 6 4
   3 4 4 3

(f 5 "o" "*" "-")

    o * * * o
   * - - - - *
  * - - - - - *
 * - - - - - - *
o - - - - - - - o
 * - - - - - - *
  * - - - - - *
   * - - - - *
    o * * * o

Detailed version:

(define(f1 n c e o)
  (let ((sp(append(range(sub1 n) -1 -1)
                  (reverse(range(sub1 n) 0 -1))))
        (mm(append(range(- n 2)(-(+ n(sub1 n)) 2))
                  (range(-(+ n(sub1 n)) 2)(-(sub1 n)2) -1) ))
        (r ""))
    (for((i sp)(j mm))
      (define str "")
      (for((ss i))(set! str(string-append str " ")))
      (set! str(string-append str
                              (if(or(= i 0)(= i(sub1 n))
                                    (= i(* 2(sub1 n)))) c e)
                              " "))
      (for((jj j))
        (set! str(string-append str
                                (if(= j(- n 2)) e o)
                                " ")))
      (set! r(if(or(= i 0)
                   (= i(sub1 n))
                   (= i(* 2(sub1 n)))) c e))
      (set! str(string-append str r))
      (displayln str))))


问:
Chinese checkerboard
The game of Chinese checkers is played on a board with spaces in the shape of a six-pointed star:

Image from Wikipedia

We can create an ASCII-art representation of this board, using . for empty spots and the letters GYORPB for the six colored starting locations:

```<code>            G
           G G
          G G G
         G G G G
B B B B . . . . . Y Y Y Y
 B B B . . . . . . Y Y Y
  B B . . . . . . . Y Y
   B . . . . . . . . Y
    . . . . . . . . .
   P . . . . . . . . O
  P P . . . . . . . O O
 P P P . . . . . . O O O
P P P P . . . . . O O O O
         R R R R
          R R R
           R R
            R
</code>```

To make it more interesting, we can also change the size. We'll measure the size of a board by the side length of its triangular starting locations: the board above is size 4.

Since it's really a pain to type all that by hand, let's write a program (or function) to do it!

Details

Your code should take a positive integer representing the size of the board, via STDIN, ARGV, or function argument. Output the checkerboard pattern to STDOUT (you may alternately return it as a string if your submission is a function).

Output must either

have no trailing spaces at all, or

have exactly enough trailing spaces to fill out the pattern to a perfect rectangle of width 6 * N + 1.

Output may optionally have a trailing newline. No other extra (leading, trailing) whitespace is permitted.

Examples

Size 1:

```<code>   G
B . . Y
 . . .
P . . O
   R
</code>```

Size 2:

```<code>      G
     G G
B B . . . Y Y
 B . . . . Y
  . . . . .
 P . . . . O
P P . . . O O
     R R
      R
</code>```

Size 4:

```<code>            G
           G G
          G G G
         G G G G
B B B B . . . . . Y Y Y Y
 B B B . . . . . . Y Y Y
  B B . . . . . . . Y Y
   B . . . . . . . . Y
    . . . . . . . . .
   P . . . . . . . . O
  P P . . . . . . . O O
 P P P . . . . . . O O O
P P P P . . . . . O O O O
         R R R R
          R R R
           R R
            R
</code>```

Scoring

This is code-golf: the shortest code in bytes wins.

答:
Ruby, <s>141</s> 127

Returns a rectangular string

```<code>->n{(-2*n..2*n).map{|i|j=i.abs
k=j>n ?0:j
(([i>0??P:?B]*k+[j>n ?i>0??R:?G:?.]*(2*n+1-j)+[i>0??O:?Y]*k)*" ").center(6*n+1)}*$/}
</code>```

Ungolfed in test program

```<code>f=->n{
  (-2*n..2*n).map{|i|                    #Iterate rows from -2*n to 2*n
    j=i.abs                              #Absolute value of i
    k=j>n ?0:j                           #Value of j up to n: for PBYO
    (                                    #An array of characters forming one line
      ([i>0??P:?B]*k+                    #B or P * (k=j or 0 as appropriate)
       [j>n ?i>0??R:?G:?.]*(2*n+1-j)+    #R,G or . * (2*n+1-j) to form centre diamond
       [i>0??O:?Y]*k                     #O or Y * (k=j or 0 as appropriate)
      )*" "                              #Concatenate the array of characters into a string separated by spaces.
    ).center(6*n+1)                      #pad the string to the full width of the image, adding spaces as necessary.
  }*$/                                   #Concatenate the array of lines into a string separated by newlines.
}

puts f[gets.to_i]
</code>```

Title: Chinese checkerboard

Body:
Ruby, <s>141</s> 127

Returns a rectangular string

->n{(-2*n..2*n).map{|i|j=i.abs
k=j>n ?0:j
(([i>0??P:?B]*k+[j>n ?i>0??R:?G:?.]*(2*n+1-j)+[i>0??O:?Y]*k)*" ").center(6*n+1)}*$/}

Ungolfed in test program

f=->n{
  (-2*n..2*n).map{|i|                    #Iterate rows from -2*n to 2*n
    j=i.abs                              #Absolute value of i
    k=j>n ?0:j                           #Value of j up to n: for PBYO
    (                                    #An array of characters forming one line
      ([i>0??P:?B]*k+                    #B or P * (k=j or 0 as appropriate)
       [j>n ?i>0??R:?G:?.]*(2*n+1-j)+    #R,G or . * (2*n+1-j) to form centre diamond
       [i>0??O:?Y]*k                     #O or Y * (k=j or 0 as appropriate)
      )*" "                              #Concatenate the array of characters into a string separated by spaces.
    ).center(6*n+1)                      #pad the string to the full width of the image, adding spaces as necessary.
  }*$/                                   #Concatenate the array of lines into a string separated by newlines.
}

puts f[gets.to_i]


答:
Python <s>3</s> 2, <s>418</s> <s>385</s> <s>362</s> <s>342</s> 330 bytes

w='[(i,j)for i in r(n)for j in r(n)if a[i][j]>3]'
def f(z):
 a,x,r=[[z]],0,range
 for _ in[0]*z:
  n=len(a);v=eval(w)
  if[1for b,c in v if(b==0)+(c==0)]:n+=2;a=[[0]*n]+[[0]+a[i]+[0]for i in r(n-2)]+[[0]*n];x+=1;v=eval(w)
  for c,d in v:exec'a[c+%s][d+%s]+=1;'*4%(-1,0,1,0,0,-1,0,1);a[c][d]-=4
 for i in a:print''.join(map(str,i))
```

Edit: saved 6 bytes thanks to @Qwerp-Derp

All credit to @Andreï Kostyrka, as this is a direct translation of his R code into Python.

Title: Build a sandpile

Body:
Python <s>3</s> 2, <s>418</s> <s>385</s> <s>362</s> <s>342</s> 330 bytes

w='[(i,j)for i in r(n)for j in r(n)if a[i][j]>3]'
def f(z):
 a,x,r=[[z]],0,range
 for _ in[0]*z:
  n=len(a);v=eval(w)
  if[1for b,c in v if(b==0)+(c==0)]:n+=2;a=[[0]*n]+[[0]+a[i]+[0]for i in r(n-2)]+[[0]*n];x+=1;v=eval(w)
  for c,d in v:exec'a[c+%s][d+%s]+=1;'*4%(-1,0,1,0,0,-1,0,1);a[c][d]-=4
 for i in a:print''.join(map(str,i))

Edit: saved 6 bytes thanks to @Qwerp-Derp

All credit to @Andreï Kostyrka, as this is a direct translation of his R code into Python.


问:
Find every digit from the largest column
Here's a relatively simple challenge for you:

Given a list of positive integers:

Line them up in a grid, and sum each column. For example, if the input was [123, 7, 49, 681], the grid would look like this:

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

And the sum of each column would be [18, 19, 4]:

```<code> 1  2  3
 7
 4  9
 6  8  1
 --------
 18 19 4
</code>```

Find the maximum of these sums, which in this case would be 19, and then

Output every digit that is at the same index as this maximum column. In this case, that would be

```<code>2
9
8
</code>```

You do not have to output these numbers in any particular order.
Note that there are only three outputs, even though we had 4 inputs. In the case of a tie, pick the earliest index. For example, if the input was [25, 223, 302], your grid is:

```<code>2  5
2  2  3
3  0  2
-------
7  7  5
</code>```

You should output

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

You can print these numbers in any format you like. List format, newline separated, space separated, etc. You may not take the input as a 2D array of digits, e.g.

```<code>[[1, 2, 3],
[7],
[4, 9],
[6, 8, 1]
</code>```

But other than that, you can take input as a list of strings, a list of digits, or any other reasonable format.

You may also assume that all inputs will be valid and contain at least two numbers.

As usual, the shortest answer in bytes wins!

Test IO:

```<code>#Input                      #Output
[1, 11, 111, 1111]      --> [1, 1, 1, 1]
[1, 12, 123]            --> [2, 2]
[987654321, 111]        --> [9, 1]
[111, 123456789]        --> [9]
[4, 8, 15, 16, 23, 42]  --> [4, 8, 1, 1, 2, 4]
[4, 8, 12, 26, 27, 38]  --> [2, 6, 7, 8]
[24, 53]                --> [2, 5]
[12, 304, 506]          --> [4, 6]
[30, 285, 121]          --> [0, 8, 2]
</code>```

答:
Perl, <s>49</s> 48 bytes

Includes +1 for -p

Run with the input on STDIN, prints to STDOUT the column numbers prefixed by +

```<code>lcolumn.pl
123
7
49
681
</code>```

lcolumn.pl:

```<code>#!/usr/bin/perl -p
s/./@;[@-].="+$&"/eg}{($_)=sort{eval"$b<=>$a"}@
</code>```

Body:
Perl, <s>49</s> 48 bytes

Includes +1 for -p

Run with the input on STDIN, prints to STDOUT the column numbers prefixed by +

lcolumn.pl
123
7
49
681

lcolumn.pl:

#!/usr/bin/perl -p
s/./@;[@-].="+$&"/eg}{($_)=sort{eval"$b<=>$a"}@


答:
Pyth, <s>5</s> 8 bytes

```<code>esDsMM.T
</code>```

Takes in input as a list of strings, outputs as a nothing-separated list of digits.

Try it online!

Explanation:

```<code>      .T  Transpose input to zip together corresponding columns
   sMM    Cast to digit lists
 sD       sort(D) by (s)um
e         take last element, implicitly print
</code>```

Title: Find every digit from the largest column

Body:
Here's a relatively simple challenge for you:

Given a list of positive integers:

Line them up in a grid, and sum each column. For example, if the input was [123, 7, 49, 681], the grid would look like this:

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

And the sum of each column would be [18, 19, 4]:

```<code> 1  2  3
 7
 4  9
 6  8  1
 --------
 18 19 4
</code>```

Find the maximum of these sums, which in this case would be 19, and then

Output every digit that is at the same index as this maximum column. In this case, that would be

```<code>2
9
8
</code>```

You do not have to output these numbers in any particular order.
Note that there are only three outputs, even though we had 4 inputs. In the case of a tie, pick the earliest index. For example, if the input was [25, 223, 302], your grid is:

```<code>2  5
2  2  3
3  0  2
-------
7  7  5
</code>```

You should output

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

You can print these numbers in any format you like. List format, newline separated, space separated, etc. You may not take the input as a 2D array of digits, e.g.

```<code>[[1, 2, 3],
[7],
[4, 9],
[6, 8, 1]
</code>```

But other than that, you can take input as a list of strings, a list of digits, or any other reasonable format.

You may also assume that all inputs will be valid and contain at least two numbers.

As usual, the shortest answer in bytes wins!

Test IO:

```<code>#Input                      #Output
[1, 11, 111, 1111]      --> [1, 1, 1, 1]
[1, 12, 123]            --> [2, 2]
[987654321, 111]        --> [9, 1]
[111, 123456789]        --> [9]
[4, 8, 15, 16, 23, 42]  --> [4, 8, 1, 1, 2, 4]
[4, 8, 12, 26, 27, 38]  --> [2, 6, 7, 8]
[24, 53]                --> [2, 5]
[12, 304, 506]          --> [4, 6]
[30, 285, 121]          --> [0, 8, 2]
</code>```

Body:
Pyth, <s>5</s> 8 bytes

esDsMM.T

Takes in input as a list of strings, outputs as a nothing-separated list of digits.

Try it online!

Explanation:

      .T  Transpose input to zip together corresponding columns
   sMM    Cast to digit lists
 sD       sort(D) by (s)um
e         take last element, implicitly print


问:
Chuck Norris vs Travelling Salesman

Introduction

Almost everyone is familiar with the Travelling Salesman Problem (TSP). The task is to, given a list of N cities, find the minimum Hamiltonian cycle which is to say the shortest path that visits each city and comes full-circle back to the start. That is not what this challenge is about. This challenge is to implement Chuck Norris' solution to the TSP:

Chuck Norris solved the Travelling Salesman problem in O(1) time: break salesman into N pieces; kick each piece to a different city.

Challenge

In order to solve the TSP in this way, we need a sufficiently durable Salesman that won't shy away from frivolities like dismemberment; a number of cities to visit; a set of products to sell; a concrete method for dismemberment; and a calculation for scoring.

Specification

Cities

N is the number of cites our Salesman will visit

Salesman

The main program or function

Written in language X

With length mod N equal to 0

Products

The full names of the elements on the Periodic Table

This includes the newly accepted names of elements

Dismemberment

Slicing the Salesman into N continuous pieces of equal length

Each piece is should be a valid function or program in language X

Output

When executed the Salesman should output Chuck Norris and the sliced pieces should each output a distinct product

Only extra trailing white space is acceptable

Scoring

The length, L, of the Salesman in bytes divided by the number of cities, N, squared.

Score = L/(N*N)

Smallest score wins

Please include 3 significant figures when posting your decimal score

Examples

This Salesman visits 3 cities so N=3 and and it has a length of 9 so L=9. Thus the score for this answer would be S = 9 / (3 * 3) = 9/9 = 1.

Note that the Salesman and each sliced piece (of which there are 3), should all be valid programs or functions in the same language.

```<code>Program      -> Output
-------         ------
aaaBBBccc    -> Chuck Norris

aaa          -> Helium
BBB          -> Iridium
ccc          -> Tennessine
</code>```

N=4 and L=20 so S=20/16=1.25

```<code>Program                 -> Output
-------                    ------
aaaaaBBBBBcccccDDDDD    -> Chuck Norris

aaaaa                   -> Hydrogen
BBBBB                   -> Cadmium
ccccc                   -> Mercury
DDDDD                   -> Iron
</code>```

答:
CJam, L = 1482, N = 114, score 0.114

```<code>'C:L"arbon"  L'h+:L;"Gold"L'u+:L;"Iron"L'c+:L;"Lead"L'k+:L;"Neon"LS+:L;"Argon"L'N+:L"ickel"L'o+:L;"Zinc""Coppe"L'r+:L"Silve"L'r+:LL'i+:L;"Tin" "Boron"      "Radon"      "Barium"     "Cerium"     "Cesium"     "Cobalt"     "Curium"     "Erbium"     "Helium"     "Indium"     "Iodine"     "Osmium"     "Oxygen"     "Radium"     "Sodium"     "Sulfur"     "Arsenic"    "Bismuth"    "Bohrium"    "Bromine"    "Cadmium"    "Calcium"    "Dubnium"    "Fermium"    "Gallium"    "Hafnium"    "Hassium"    "Holmium"    "Iridium"    "Krypton"    "Lithium"    "Mercury"    "Niobium"    "Rhenium"    "Rhodium"    "Silicon"    "Terbium"    "Thorium"    "Thulium"    "Uranium"    "Yttrium"    "Actinium"   "Aluminum"   "Antimony"   "Astatine"   "Chlorine"   "Chromium"   "Europium"   "Fluorine"   "Francium"   "Hydrogen"   "Lutetium"   "Nihonium"   "Nitrogen"   "Nobelium"   "Platinum"   "Polonium"   "Rubidium"   "Samarium"   "Scandium"   "Selenium"   "Tantalum"   "Thallium"   "Titanium"   "Tungsten"   "Vanadium"   "Americium"  "Berkelium"  "Beryllium"  "Flerovium"  "Germanium"  "Lanthanum"  "Magnesium"  "Manganese"  "Moscovium"  "Neodymium"  "Neptunium"  "Oganesson"  "Palladium"  "Plutonium"  "Potassium"  "Ruthenium"  "Strontium"  "Tellurium"  "Ytterbium"  "Zirconium"  "Dysprosium" "Gadolinium" "Lawrencium" "Meitnerium" "Molybdenum" "Phosphorus" "Promethium" "Seaborgium" "Technetium" "Tennessine" "Californium""Copernicium""Einsteinium""Livermorium""Mendelevium""Roentgenium"]L's+"Xenon"?
</code>```

Try it online!

Each program is 13 bytes long. Here they are split up into individual lines:

```<code>'C:L"arbon"
L'h+:L;"Gold"
L'u+:L;"Iron"
L'c+:L;"Lead"
L'k+:L;"Neon"
LS+:L;"Argon"
L'N+:L"ickel"
L'o+:L;"Zinc"
"Coppe"L'r+:L
"Silve"L'r+:L
L'i+:L;"Tin"
"Boron"
"Radon"
"Barium"
"Cerium"
"Cesium"
"Cobalt"
"Curium"
"Erbium"
"Helium"
"Indium"
"Iodine"
"Osmium"
"Oxygen"
"Radium"
"Sodium"
"Sulfur"
"Arsenic"
"Bismuth"
"Bohrium"
"Bromine"
"Cadmium"
"Calcium"
"Dubnium"
"Fermium"
"Gallium"
"Hafnium"
"Hassium"
"Holmium"
"Iridium"
"Krypton"
"Lithium"
"Mercury"
"Niobium"
"Rhenium"
"Rhodium"
"Silicon"
"Terbium"
"Thorium"
"Thulium"
"Uranium"
"Yttrium"
"Actinium"
"Aluminum"
"Antimony"
"Astatine"
"Chlorine"
"Chromium"
"Europium"
"Fluorine"
"Francium"
"Hydrogen"
"Lutetium"
"Nihonium"
"Nitrogen"
"Nobelium"
"Platinum"
"Polonium"
"Rubidium"
"Samarium"
"Scandium"
"Selenium"
"Tantalum"
"Thallium"
"Titanium"
"Tungsten"
"Vanadium"
"Americium"
"Berkelium"
"Beryllium"
"Flerovium"
"Germanium"
"Lanthanum"
"Magnesium"
"Manganese"
"Moscovium"
"Neodymium"
"Neptunium"
"Oganesson"
"Palladium"
"Plutonium"
"Potassium"
"Ruthenium"
"Strontium"
"Tellurium"
"Ytterbium"
"Zirconium"
"Dysprosium"
"Gadolinium"
"Lawrencium"
"Meitnerium"
"Molybdenum"
"Phosphorus"
"Promethium"
"Seaborgium"
"Technetium"
"Tennessine"
"Californium"
"Copernicium"
"Einsteinium"
"Livermorium"
"Mendelevium"
"Roentgenium"
]L's+"Xenon"?
</code>```

The missing elements are Darmstadtium, Praseodymium, Protactinium and Rutherfordium which are 12 or 13 characters long which means I can't print them in 13 characters each.

The idea is that the first few programs, which prints the elements with short names use their extraneous characters to build the string Chuck Norri in the variable L, which does not affect the output when used on their own. The final program then checks if anything is already on the stack, and uses it to choose between L (plus s) and Xenon.

A few additional bytes are saved by using the character we just added to L as part of the element name, specifically for Carbon, Nickel, Copper and Silver.

Title: Chuck Norris vs Travelling Salesman

Body:
CJam, L = 1482, N = 114, score 0.114

'C:L"arbon"  L'h+:L;"Gold"L'u+:L;"Iron"L'c+:L;"Lead"L'k+:L;"Neon"LS+:L;"Argon"L'N+:L"ickel"L'o+:L;"Zinc""Coppe"L'r+:L"Silve"L'r+:LL'i+:L;"Tin" "Boron"      "Radon"      "Barium"     "Cerium"     "Cesium"     "Cobalt"     "Curium"     "Erbium"     "Helium"     "Indium"     "Iodine"     "Osmium"     "Oxygen"     "Radium"     "Sodium"     "Sulfur"     "Arsenic"    "Bismuth"    "Bohrium"    "Bromine"    "Cadmium"    "Calcium"    "Dubnium"    "Fermium"    "Gallium"    "Hafnium"    "Hassium"    "Holmium"    "Iridium"    "Krypton"    "Lithium"    "Mercury"    "Niobium"    "Rhenium"    "Rhodium"    "Silicon"    "Terbium"    "Thorium"    "Thulium"    "Uranium"    "Yttrium"    "Actinium"   "Aluminum"   "Antimony"   "Astatine"   "Chlorine"   "Chromium"   "Europium"   "Fluorine"   "Francium"   "Hydrogen"   "Lutetium"   "Nihonium"   "Nitrogen"   "Nobelium"   "Platinum"   "Polonium"   "Rubidium"   "Samarium"   "Scandium"   "Selenium"   "Tantalum"   "Thallium"   "Titanium"   "Tungsten"   "Vanadium"   "Americium"  "Berkelium"  "Beryllium"  "Flerovium"  "Germanium"  "Lanthanum"  "Magnesium"  "Manganese"  "Moscovium"  "Neodymium"  "Neptunium"  "Oganesson"  "Palladium"  "Plutonium"  "Potassium"  "Ruthenium"  "Strontium"  "Tellurium"  "Ytterbium"  "Zirconium"  "Dysprosium" "Gadolinium" "Lawrencium" "Meitnerium" "Molybdenum" "Phosphorus" "Promethium" "Seaborgium" "Technetium" "Tennessine" "Californium""Copernicium""Einsteinium""Livermorium""Mendelevium""Roentgenium"]L's+"Xenon"?

<a href="http://cjam.tryitonline.net/#code=J0M6TCJhcmJvbiIgIEwnaCs6TDsiR29sZCJMJ3UrOkw7Iklyb24iTCdjKzpMOyJMZWFkIkwnays6TDsiTmVvbiJMUys6TDsiQXJnb24iTCdOKzpMImlja2VsIkwnbys6TDsiWmluYyIiQ29wcGUiTCdyKzpMIlNpbHZlIkwncis6TEwnaSs6TDsiVGluIiAiQm9yb24iICAgICAgIlJhZG9uIiAgICAgICJCYXJpdW0iICAgICAiQ2VyaXVtIiAgICAgIkNlc2l1bSIgICAgICJDb2JhbHQiICAgICAiQ3VyaXVtIiAgICAgIkVyYml1bSIgICAgICJIZWxpdW0iICAgICAiSW5kaXVtIiAgICAgIklvZGluZSIgICAgICJPc21pdW0iICAgICAiT3h5Z2VuIiAgICAgIlJhZGl1bSIgICAgICJTb2RpdW0iICAgICAiU3VsZnVyIiAgICAgIkFyc2VuaWMiICAgICJCaXNtdXRoIiAgICAiQm9ocml1bSIgICAgIkJyb21pbmUiICAgICJDYWRtaXVtIiAgICAiQ2FsY2l1bSIgICAgIkR1Ym5pdW0iICAgICJGZXJtaXVtIiAgICAiR2FsbGl1bSIgICAgIkhhZm5pdW0iICAgICJIYXNzaXVtIiAgICAiSG9sbWl1bSIgICAgIklyaWRpdW0iICAgICJLcnlwdG9uIiAgICAiTGl0aGl1bSIgICAgIk1lcmN1cnkiICAgICJOaW9iaXVtIiAgICAiUmhlbml1bSIgICAgIlJob2RpdW0iICAgICJTaWxpY29uIiAgICAiVGVyYml1bSIgICAgIlRob3JpdW0iICAgICJUaHVsaXVtIiAgICAiVXJhbml1bSIgICAgIll0dHJpdW0iICAgICJBY3Rpbml1bSIgICAiQWx1bWludW0iICAgIkFudGltb255IiAgICJBc3RhdGluZSIgICAiQ2hsb3JpbmUiICAgIkNocm9taXVtIiAgICJFdXJvcGl1bSIgICAiRmx1b3JpbmUiICAgIkZyYW5jaXVtIiAgICJIeWRyb2dlbiIgICAiTHV0ZXRpdW0iICAgIk5paG9uaXVtIiAgICJOaXRyb2dlbiIgICAiTm9iZWxpdW0iICAgIlBsYXRpbnVtIiAgICJQb2xvbml1bSIgICAiUnViaWRpdW0iICAgIlNhbWFyaXVtIiAgICJTY2FuZGl1bSIgICAiU2VsZW5pdW0iICAgIlRhbnRhbHVtIiAgICJUaGFsbGl1bSIgICAiVGl0YW5pdW0iICAgIlR1bmdzdGVuIiAgICJWYW5hZGl1bSIgICAiQW1lcmljaXVtIiAgIkJlcmtlbGl1bSIgICJCZXJ5bGxpdW0iICAiRmxlcm92aXVtIiAgIkdlcm1hbml1bSIgICJMYW50aGFudW0iICAiTWFnbmVzaXVtIiAgIk1hbmdhbmVzZSIgICJNb3Njb3ZpdW0iICAiTmVvZHltaXVtIiAgIk5lcHR1bml1bSIgICJPZ2FuZXNzb24iICAiUGFsbGFkaXVtIiAgIlBsdXRvbml1bSIgICJQb3Rhc3NpdW0iICAiUnV0aGVuaXVtIiAgIlN0cm9udGl1bSIgICJUZWxsdXJpdW0iICAiWXR0ZXJiaXVtIiAgIlppcmNvbml1bSIgICJEeXNwcm9zaXVtIiAiR2Fkb2xpbml1bSIgIkxhd3JlbmNpdW0iICJNZWl0bmVyaXVtIiAiTW9seWJkZW51bSIgIlBob3NwaG9ydXMiICJQcm9tZXRoaXVtIiAiU2VhYm9yZ2l1bSIgIlRlY2huZXRpdW0iICJUZW5uZXNzaW5lIiAiQ2FsaWZvcm5pdW0iIkNvcGVybmljaXVtIiJFaW5zdGVpbml1bSIiTGl2ZXJtb3JpdW0iIk1lbmRlbGV2aXVtIiJSb2VudGdlbml1bSJdTCdzKyJYZW5vbiI_&input=" rel="noreferrer">Try it online!

Each program is 13 bytes long. Here they are split up into individual lines:

'C:L"arbon"
L'h+:L;"Gold"
L'u+:L;"Iron"
L'c+:L;"Lead"
L'k+:L;"Neon"
LS+:L;"Argon"
L'N+:L"ickel"
L'o+:L;"Zinc"
"Coppe"L'r+:L
"Silve"L'r+:L
L'i+:L;"Tin"
"Boron"
"Radon"
"Barium"
"Cerium"
"Cesium"
"Cobalt"
"Curium"
"Erbium"
"Helium"
"Indium"
"Iodine"
"Osmium"
"Oxygen"
"Radium"
"Sodium"
"Sulfur"
"Arsenic"
"Bismuth"
"Bohrium"
"Bromine"
"Cadmium"
"Calcium"
"Dubnium"
"Fermium"
"Gallium"
"Hafnium"
"Hassium"
"Holmium"
"Iridium"
"Krypton"
"Lithium"
"Mercury"
"Niobium"
"Rhenium"
"Rhodium"
"Silicon"
"Terbium"
"Thorium"
"Thulium"
"Uranium"
"Yttrium"
"Actinium"
"Aluminum"
"Antimony"
"Astatine"
"Chlorine"
"Chromium"
"Europium"
"Fluorine"
"Francium"
"Hydrogen"
"Lutetium"
"Nihonium"
"Nitrogen"
"Nobelium"
"Platinum"
"Polonium"
"Rubidium"
"Samarium"
"Scandium"
"Selenium"
"Tantalum"
"Thallium"
"Titanium"
"Tungsten"
"Vanadium"
"Americium"
"Berkelium"
"Beryllium"
"Flerovium"
"Germanium"
"Lanthanum"
"Magnesium"
"Manganese"
"Moscovium"
"Neodymium"
"Neptunium"
"Oganesson"
"Palladium"
"Plutonium"
"Potassium"
"Ruthenium"
"Strontium"
"Tellurium"
"Ytterbium"
"Zirconium"
"Dysprosium"
"Gadolinium"
"Lawrencium"
"Meitnerium"
"Molybdenum"
"Phosphorus"
"Promethium"
"Seaborgium"
"Technetium"
"Tennessine"
"Californium"
"Copernicium"
"Einsteinium"
"Livermorium"
"Mendelevium"
"Roentgenium"
]L's+"Xenon"?

The missing elements are Darmstadtium, Praseodymium, Protactinium and Rutherfordium which are 12 or 13 characters long which means I can't print them in 13 characters each.

The idea is that the first few programs, which prints the elements with short names use their extraneous characters to build the string Chuck Norri in the variable L, which does not affect the output when used on their own. The final program then checks if anything is already on the stack, and uses it to choose between L (plus s) and Xenon.

A few additional bytes are saved by using the character we just added to L as part of the element name, specifically for Carbon, Nickel, Copper and Silver.


Title: Invalid Invali Inval

Body:
This idea is loosely based upon @TùxCräftîñg's chat message.

Take a look at the below example sequence:

INVALID0, INVALID1, INVALID2 INVALID3, INVALID4... INVALID9

After INVALID9, it goes on like this:

INVALI0, INVALI1, INVALI2, INVALI3... INVALI9

And after INVALI9, it's like this:

INVAL0,INVAL1, INVAL2, INVAL3... INVAL9

After, INVAL9, it's like this:

INVA0, INVA1, INVA2, INVA3, ... INVA9

Notice how we we kept removing a letter from the word INVALID each time.

You'll keep repeating this until you reach a single letter, that is, the letter I:

I0, I1, I2, I3, I4 ... I9

Now, your task is, to take an input of a word, and produce a sequence from it like the above example. Your code must also work with single letters, and in that case the resulting sequence will be shorter.

You may choose any input and output format that you prefer (with or without a separator, as you wish), but you must specify which one you have chosen.

The sequence needs to be in the exact specified order.

The shortest code, in bytes, that successfully completes this challenge, wins the challenge.

Full sequence in the above example:

```<code>INVALID0, INVALID1, INVALID2, INVALID3, INVALID4, INVALID5, INVALID6, INVALID7, INVALID8, INVALID9, INVALI0, INVALI1, INVALI2, INVALI3, INVALI4, INVALI5, INVALI6, INVALI7, INVALI8, INVALI9, INVAL0, INVAL1, INVAL2, INVAL3, INVAL4, INVAL5, INVAL6, INVAL7, INVAL8, INVAL9, INVA0, INVA1, INVA2, INVA3, INVA4, INVA5, INVA6, INVA7, INVA8, INVA9, INV0, INV1, INV2, INV3, INV4, INV5, INV6, INV7, INV8, INV9, IN0, IN1, IN2, IN3, IN4, IN5, IN6, IN7, IN8, IN9, I0, I1, I2, I3, I4, I5, I6, I7, I8, I9
</code>```

Other examples:

Input: MAYBE (Uppercase and lowercase don't matter)

Output:

```<code>MAYBE0, MAYBE1, MAYBE2, MAYBE3, MAYBE4, MAYBE5, MAYBE6, MAYBE7, MAYBE8, MAYBE9, MAYB0, MAYB1, MAYB2, MAYB3, MAYB4, MAYB5, MAYB6, MAYB7, MAYB8, MAYB9, MAY0, MAY1, MAY2, MAY3, MAY4, MAY5, MAY6, MAY7, MAY8, MAY9, MA0, MA1, MA2, MA3, MA4, MA5, MA6, MA7, MA8, MA9, M0, M1, M2, M3, M4, M5, M6, M7, M8, M9
</code>```

Input: AFTER

Output:

```<code>AFTER0, AFTER1, AFTER2, AFTER3, AFTER4, AFTER5, AFTER6, AFTER7, AFTER8, AFTER9, AFTE0, AFTE1, AFTE2, AFTE3, AFTE4, AFTE5, AFTE6, AFTE7, AFTE8, AFTE9, AFT0, AFT1, AFT2, AFT3, AFT4, AFT5, AFT6, AFT7, AFT8, AFT9, AF0, AF1, AF2, AF3, AF4, AF5, AF6, AF7, AF8, AF9, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9
</code>```

Input: WHAT ARE YOU DOING

```<code>WHAT ARE YOU DOING0, WHAT ARE YOU DOING1, WHAT ARE YOU DOING2, WHAT ARE YOU DOING3, WHAT ARE YOU DOING4, WHAT ARE YOU DOING5, WHAT ARE YOU DOING6, WHAT ARE YOU DOING7, WHAT ARE YOU DOING8, WHAT ARE YOU DOING9, WHAT ARE YOU DOIN0, WHAT ARE YOU DOIN1, WHAT ARE YOU DOIN2, WHAT ARE YOU DOIN3, WHAT ARE YOU DOIN4, WHAT ARE YOU DOIN5, WHAT ARE YOU DOIN6, WHAT ARE YOU DOIN7, WHAT ARE YOU DOIN8, WHAT ARE YOU DOIN9, WHAT ARE YOU DOI0, WHAT ARE YOU DOI1, WHAT ARE YOU DOI2, WHAT ARE YOU DOI3, WHAT ARE YOU DOI4, WHAT ARE YOU DOI5, WHAT ARE YOU DOI6, WHAT ARE YOU DOI7, WHAT ARE YOU DOI8, WHAT ARE YOU DOI9, WHAT ARE YOU DO0, WHAT ARE YOU DO1, WHAT ARE YOU DO2, WHAT ARE YOU DO3, WHAT ARE YOU DO4, WHAT ARE YOU DO5, WHAT ARE YOU DO6, WHAT ARE YOU DO7, WHAT ARE YOU DO8, WHAT ARE YOU DO9, WHAT ARE YOU D0, WHAT ARE YOU D1, WHAT ARE YOU D2, WHAT ARE YOU D3, WHAT ARE YOU D4, WHAT ARE YOU D5, WHAT ARE YOU D6, WHAT ARE YOU D7, WHAT ARE YOU D8, WHAT ARE YOU D9, WHAT ARE YOU 0, WHAT ARE YOU 1, WHAT ARE YOU 2, WHAT ARE YOU 3, WHAT ARE YOU 4, WHAT ARE YOU 5, WHAT ARE YOU 6, WHAT ARE YOU 7, WHAT ARE YOU 8, WHAT ARE YOU 9, WHAT ARE YOU0, WHAT ARE YOU1, WHAT ARE YOU2, WHAT ARE YOU3, WHAT ARE YOU4, WHAT ARE YOU5, WHAT ARE YOU6, WHAT ARE YOU7, WHAT ARE YOU8, WHAT ARE YOU9, WHAT ARE YO0, WHAT ARE YO1, WHAT ARE YO2, WHAT ARE YO3, WHAT ARE YO4, WHAT ARE YO5, WHAT ARE YO6, WHAT ARE YO7, WHAT ARE YO8, WHAT ARE YO9, WHAT ARE Y0, WHAT ARE Y1, WHAT ARE Y2, WHAT ARE Y3, WHAT ARE Y4, WHAT ARE Y5, WHAT ARE Y6, WHAT ARE Y7, WHAT ARE Y8, WHAT ARE Y9, WHAT ARE 0, WHAT ARE 1, WHAT ARE 2, WHAT ARE 3, WHAT ARE 4, WHAT ARE 5, WHAT ARE 6, WHAT ARE 7, WHAT ARE 8, WHAT ARE 9, WHAT ARE0, WHAT ARE1, WHAT ARE2, WHAT ARE3, WHAT ARE4, WHAT ARE5, WHAT ARE6, WHAT ARE7, WHAT ARE8, WHAT ARE9, WHAT AR0, WHAT AR1, WHAT AR2, WHAT AR3, WHAT AR4, WHAT AR5, WHAT AR6, WHAT AR7, WHAT AR8, WHAT AR9, WHAT A0, WHAT A1, WHAT A2, WHAT A3, WHAT A4, WHAT A5, WHAT A6, WHAT A7, WHAT A8, WHAT A9, WHAT 0, WHAT 1, WHAT 2, WHAT 3, WHAT 4, WHAT 5, WHAT 6, WHAT 7, WHAT 8, WHAT 9, WHAT0, WHAT1, WHAT2, WHAT3, WHAT4, WHAT5, WHAT6, WHAT7, WHAT8, WHAT9, WHA0, WHA1, WHA2, WHA3, WHA4, WHA5, WHA6, WHA7, WHA8, WHA9, WH0, WH1, WH2, WH3, WH4, WH5, WH6, WH7, WH8, WH9, W0, W1, W2, W3, W4, W5, W6, W7, W8, W9
</code>```

Leaderboard

var QUESTION_ID=92156,OVERRIDE_USER=58717;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:
PHP, <s>64</s> 56 bytes

for($i=9;$a=substr($argv[1].a,0,-++$i/10);)echo$a.$i%10;

<s>

for(;$a=substr($argv[1].a,$i=0,-++$l);)for(;$i<10;)echo $a.$i++;

</s>


问:
Golf all the 16 logic gates with 2 inputs and 1 output!
For example, the gate A and B is a logic gate with 2 inputs and 1 output.

There are exactly 16 of them, because:

each logic gate takes two inputs, which can be truthy or falsey, giving us 4 possible inputs

of the 4 possible inputs, each can have an output of truthy and falsey

therefore, there are 2^4 possible logic gates, which is 16.

Your task is to write 16 programs/functions which implement all of them separately.

Your functions/programs must be independent.

They are valid as long as they output truthy/falsey values, meaning that you can implement A or B in Python as lambda a,b:a+b, even if 2 is produced for A=True and B=True.

Score is total bytes used for each function/program.

List of logic gates

0,0,0,0 (false)

0,0,0,1 (and)

0,0,1,0 (A and not B)

0,0,1,1 (A)

0,1,0,0 (not A and B)

0,1,0,1 (B)

0,1,1,0 (xor)

0,1,1,1 (or)

1,0,0,0 (nor)

1,0,0,1 (xnor)

1,0,1,0 (not B)

1,0,1,1 (B implies A)

1,1,0,0 (not A)

1,1,0,1 (A implies B)

1,1,1,0 (nand)

1,1,1,1 (true)

Where the first number is the output for A=false, B=false,
the second number is the output for A=false, B=true,
the third number is the output for A=true, B=false,
the fourth number is the output for A=true, B=true.

Leaderboard

var QUESTION_ID=82938,OVERRIDE_USER=48934;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+(?:\.\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

```

答:
Chess/mediocre chess player in endgame, 70 pieces

Inspired by that domino answer, I decided another game should have this honor.

Note that I took a few rules for how the pieces move. Because I don't feel like studying the optimal moves for every situation, the rules for whites move is simple: Stay out of check, capture the highest ranking piece he can that turn, while losing as little material as possible, and stop a pawn from promoting, in that order of priority. If there are two spaces he can move to, with equal favourability, he can move to either (hence in these, if he can move to more than one square, they are the same colour). Note that white will capture with something even if it gets captured, if the piece it is attacking is higher value than the one lost. Values are here:pawn<knight=bishop<rook<queen

The input is whether a rook is present or not. Note that rooks are only labelled with names A and B when it matters: if the gate behaves the same when the rooks are switched, they are not labelled.

The output is the colour of the square white king ends on: White=1, black=0

Before the images, I want to apologise for poor images. I'm not much good at holding a camera steady.

False, 4:

AND, 4:

A and not B, 5 (I think I can get this down to three, but do not have board right now):

A, 4:

Not A and B,5 (I think I can get this down to three, but do not have board right now):

B, 4:

Xor,5 (I know a way to make it 4, but I don't have the board right now):

Or, 4:

Nor, 4:

Xnor, 5 (I know a way to make it 4, but I don't have the board right now):

Not B, 4:

B implies A, 5 (I think I can get this down to three, but do not have board right now):

Not A, 4:

A implies B, 5 (I think I can get this down to three, but do not have board right now):

Nand, 4:

True, 4:


问:
Slowly turn a string into another

The Challenge

Given two strings/an array of strings, output the first string slowly shrinking and expanding back into the second string.

You can assume the strings will always start with the same character.

Example

```<code>Input:
"Test", "Testing"

Output:
Test
Tes
Te
T
Te
Tes
Test
Testi
Testin
Testing
</code>```

First you output the first word:

```<code>Test
</code>```

Then you keep removing one letter until the string is one character long:

```<code>Tes
Te
T
</code>```

Then keep adding one letter of the second word until it's done:

```<code>Te
Tes
Test
Testi
Testin
Testing
</code>```

(if both strings are one character long, then just output one of them once.)

Test Cases

```<code>"Hello!", "Hi."
Hello!
Hello
Hell
Hel
He
H
Hi
Hi.

"O", "O"

O

"z", "zz"

z
zz

".vimrc", ".minecraft"

.vimrc
.vimr
.vim
.vi
.v
.
.m
.mi
.min
.mine
.minec
.minecr
.minecra
.minecraf
.minecraft

"     ", "   "

SSSSS
SSSS
SSS
SS
S
SS
SSS

"0123456789", "02468"

0123456789
012345678
01234567
0123456
012345
01234
0123
012
01
0
02
024
0246
02468
</code>```

(note: on the space/fourth test case, replace the S with spaces)

Rules

This is code-golf, so shortest answer in bytes wins! Tiebreaker is most upvoted post. Winner will be chosen on 09/10/2016.

Standard loopholes are forbidden.

Title: Slowly turn a string into another

Body:
Brainfuck, 38 55 bytes

>++++++++++>,[>,]<[<]>>[[.>]<[-]<[<]>.>],.[[<]>.>[.>],]

Edit: included newlines in output


问:
What's my name? Produce the name of the language indirectly
Produce only the name of a programming language using only the facilities of the language itself. The name of the language can only be invoked indirectly, i.e., from non custom environment variables, built-in functions or methods or the interpreter/compiler of the language. Output should be the name of the language only.

One example would be:

```<code>$ awk --v | awk 'NR<2 { print $2}'  # GNU Awk 3.1.8
Awk
</code>```

The answer I select will be the one with the most up votes. In case of a tie, the shortest golfed version (separate or the only given answer), will be the tie breaker.

答:
Python

import sys
try: from StringIO import StringIO
except: from io import StringIO # py3
stdout = sys.stdout
sys.stdout = s = StringIO()
import this # yeah
sys.stdout = stdout
print(s.getvalue()[11:17])
```


问:
This isn't rocket science
Write a program or function that takes in a single-line string. You can assume it only contains printable ASCII. Print or return a string of an ASCII art rocket such as

```<code>  |
 /_\
 |E|
 |a|
 |r|
 |t|
 |h|
 |_|
/___\
 VvV
</code>```

with the input string written from top to bottom on the fuselage. In this case the input was Earth. The height of the rocket (including flames) is always the length of the string plus five.

Each line in the output may have up to two trailing spaces and there may be a single optional trailing newline. The shortest code in bytes wins.

More Examples:

```<code>[empty string]

  |
 /_\
 |_|
/___\
 VvV

a

  |
 /_\
 |a|
 |_|
/___\
 VvV

|0

  |
 /_\
 |||
 |0|
 |_|
/___\
 VvV

\/\

  |
 /_\
 |\|
 |/|
 |\|
 |_|
/___\
 VvV

 _ _ [note trailing space]

  |
 /_\
 | |
 |_|
 | |
 |_|
 | |
 |_|
/___\
 VvV

    [4 spaces]

  |
 /_\
 | |
 | |
 | |
 | |
 |_|
/___\
 VvV

SPACEY

  |
 /_\
 |S|
 |P|
 |A|
 |C|
 |E|
 |Y|
 |_|
/___\
 VvV
</code>```

Leaderboard

var QUESTION_ID=91182,OVERRIDE_USER=26997;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

```

答:
dc, 55 bytes

Building a rocket with the desck calculator:

?[  |
 /_\
]n[[ |]nn[|
]nz0<R]sRz0!=R[ |_|
/___\
 VvV]p
```

<p>Because dc interprets input as commands, our string's characters are assumed to be already on the stack and the code is acting more like a function accessing its arguments.</p>

<p><strong>Example run:</strong></p>

<pre class="lang-sh prettyprint-override"><code>me@LCARS:/PPCG$ dc -f rocket_science.dc
[A][S][A][N] #the stack is LIFO, so the arguments (characters) are in reverse order
  |
 /_\
 |N|
 |A|
 |S|
 |A|
 |_|
/___\
 VvV
</code>```

Title: This isn't rocket science

Body:
dc, 55 bytes

Building a rocket with the desck calculator:

?[  |
 /_\
]n[[ |]nn[|
]nz0<R]sRz0!=R[ |_|
/___\
 VvV]p

Because dc interprets input as commands, our string's characters are assumed to be already on the stack and the code is acting more like a function accessing its arguments.

Example run:

me@LCARS:/PPCG$ dc -f rocket_science.dc
[A][S][A][N] #the stack is LIFO, so the arguments (characters) are in reverse order
  |
 /_\
 |N|
 |A|
 |S|
 |A|
 |_|
/___\
 VvV