答:
Vitsy, <s>19</s> 16 bytes

Yeah this needs some reducing. I'm out of practice!

```<code>D1H}\[\['*'O]aO]

(implicit input)
D                 Peek n, push n.
 1                Push 1.
  H               Pop x, pop y, push range(x, y)
   }              Reverse, pop n, reverse, push n.
    \[         ]  Pop n, do bracketed items n times.
      \[    ]     Pop n, do bracketed items n times.
        '*'O      Output the character *.
             aO   Output a newline.
</code>```

Think of it as though I'm iterating through a list (1 through n) and popping out the number of *s according to the currently selected list item.

Explanation soon.

Title: Draw an asterisk triangle

Body:
Inspired by a task for Programming 101, here's a challenge that hopefully isn't too easy (or a duplicate).

Input:

A positive integer n >= 1.

Output:

n lines of asterisks, where every new line has one asterisk more than the line before, and starting with one asterisk in the first line.

Test case (n=5):

```<code>    *
    **
    ***
    ****
    *****
</code>```

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

Body:
Vitsy, <s>19</s> 16 bytes

Yeah this needs some reducing. I'm out of practice!

D1H}\[\['*'O]aO]

(implicit input)
D                 Peek n, push n.
 1                Push 1.
  H               Pop x, pop y, push range(x, y)
   }              Reverse, pop n, reverse, push n.
    \[         ]  Pop n, do bracketed items n times.
      \[    ]     Pop n, do bracketed items n times.
        '*'O      Output the character *.
             aO   Output a newline.

Think of it as though I'm iterating through a list (1 through n) and popping out the number of *s according to the currently selected list item.

Explanation soon.


问:
Draw an asterisk triangle
Inspired by a task for Programming 101, here's a challenge that hopefully isn't too easy (or a duplicate).

Input:

A positive integer n >= 1.

Output:

n lines of asterisks, where every new line has one asterisk more than the line before, and starting with one asterisk in the first line.

Test case (n=5):

```<code>    *
    **
    ***
    ****
    *****
</code>```

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

答:
R, 45 bytes

For loop approach:

```<code>for(i in 1:scan())cat(rep("*",i),"\n",sep="")
</code>```

ContentLicense: CC BY-SA 4.0

Title: Draw an asterisk triangle

Body:
R, 45 bytes

For loop approach:

for(i in 1:scan())cat(rep("*",i),"\n",sep="")

ContentLicense: CC BY-SA 3.0


问:
Draw an ASCII chess board!
Here is a simple challenge for you: You must produce this ASCII representation of a chess board. White is represented by uppercase characters, and black is represented by lowercase. Empty tiles are represented by a .. Here is the full board:

```<code>rnbqkbnr
pppppppp
........
........
........
........
PPPPPPPP
RNBQKBNR
</code>```

Since this is a kolmogorov-complexity question, you may not take any input and you must output this board by any default method, for example, saving a file, printing to STDOUT or returning from a function. You may optionally produce one trailing newline. Standard loopholes apply, and the shortest program in bytes!

However, remember this is equally as much a competition between submissions in the same language. While it's unlikely that a languages like Java could beat a language like perl, or a golfing language like pyth or cjam, having the shortest Java answer is still really impressive! To help you track the shortest answer in each language, you may use this leaderboard, which will show the shortest submission by language and overall.

Leaderboards

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=95745,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

```

答:
Japt, 37 bytes

```<code>[A="rnbqkbnr"B='pp8 C='.p8 CCCBu Au]·
</code>```

I really oughta remake this language soon... Test it online!

How it works

```<code>[                                  ]  // Wrap all of the following in an array:
 A="rnbqkbnr"                         //   A = "rnbqkbnr",
             B='pp8                   //   B = 8 "p"s,
                    C='.p8            //   C = 8 periods,
                           CCC        //   3 more copies of C,
                              Bu      //   B.toUpperCase(),
                                 Au   //   and A.toUpperCase().
                                    · // Join everything with newlines and implicitly print.
</code>```

Title: Draw an ASCII chess board!

Body:
Japt, 37 bytes

[A="rnbqkbnr"B='pp8 C='.p8 CCCBu Au]·

I really oughta remake this language soon... Test it online!

How it works

[                                  ]  // Wrap all of the following in an array:
 A="rnbqkbnr"                         //   A = "rnbqkbnr",
             B='pp8                   //   B = 8 "p"s,
                    C='.p8            //   C = 8 periods,
                           CCC        //   3 more copies of C,
                              Bu      //   B.toUpperCase(),
                                 Au   //   and A.toUpperCase().
                                    · // Join everything with newlines and implicitly print.


答:
CJam, <s>13</s> <s>11</s> 10 bytes

Thanks to @MartinEnder for removing two bytes, and @Linus for removing one more!

```<code>ri{)'**N}%
</code>```

Try it online!

Explanation

```<code>ri            e# Read input as an integer n
  {     }%    e# Run this block for each k in [0 1 ... n-1]
   )          e# Add 1 to the implicitly pushed k
    '*        e# Push asterisk character
      *       e# Repeat the character k+1 times
       N      e# Push newline
              e# Implicitly display
</code>```

Title: Draw an asterisk triangle

Body:
CJam, <s>13</s> <s>11</s> 10 bytes

Thanks to @MartinEnder for removing two bytes, and @Linus for removing one more!

ri{)'**N}%

Try it online!

Explanation

ri            e# Read input as an integer n
  {     }%    e# Run this block for each k in [0 1 ... n-1]
   )          e# Add 1 to the implicitly pushed k
    '*        e# Push asterisk character
      *       e# Repeat the character k+1 times
       N      e# Push newline
              e# Implicitly display


Title: Draw an asterisk triangle

Body:
Ruby, 26 bytes

->n{s='';n.times{p s+=?*}}


答:
Perl, 19 bytes

-4 bytes thanks to @Ton Hospel and his rework of the solution!

```<code>eval"s//*/;say;"x<>
</code>```

Needs free -E (or -M5.010) flag to run. Takes a number from input :

```<code>perl -E 'eval"s//*/;say;"x<>' <<< "5"
</code>```

Title: Draw an asterisk triangle

Body:
Perl, 19 bytes

-4 bytes thanks to @Ton Hospel and his rework of the solution!

eval"s//*/;say;"x<>

Needs free -E (or -M5.010) flag to run. Takes a number from input :

perl -E 'eval"s//*/;say;"x<>' <<< "5"


问:
Simulate keystrokes
Your job is to simulate a couple of keystrokes that a user types in.

Input

A string array or string with a delimiter of your choice (outside the range 32-126) containing at least one 'keystroke'.

This array will only contain two types of string: passive keystrokes (single chars) and commands (chars within brackets [ ]).

Passive keystrokes

ASCII character codes [32-126]

Commands:

[B] : backspace (remove last character added if there is one)

[C] : copy all of what has already been written

[D] : delete all of what has been written

[P] : paste what has been copied

Output

The string produced by the keystrokes.

Examples

```<code>['H', 'e', 'l', 'l', 'o'] -> 'Hello'
['H', 'e', 'l', 'l', 'o', ' ', '[C]', '[P]'] -> 'Hello Hello '
['[D]', 'D', '[B]'] -> ''
['H', '[C]', 'i', '[P]', '[C]', '[P]'] -> 'HiHHiH'
['e', '[C]', '[B]', 'I', ' ', 'l', 'i', 'k', '[P]', ' ', 'b', '[P]', '[P]', 's', '!'] -> I like bees!
['N', '[P]'] -> 'N'
['#', '5', '0', 'K', '0', '0', '1', '[D]', '#', 'n', 'o', 't'] -> '#not'
['H', 'o', 'w', ' ', '[D]', 'H', 'e', 'y'] -> 'Hey'
['s', 'u', 'd', '[B]', 'p', '[C]', '[D]', 'I', ' ' , 'h', 'a', 'v', 'e', ' ', '[P]', 'p', 'e', 'r', '!'] -> 'I have supper!'
</code>```

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

答:
CJam, 33 bytes

```<code>q~{_[`';"];""L~""]:L~"]\1>3b=}%s~
</code>```

Try it online!

Explanation

```<code>q~                                  Read an evaluate input list.
  {                          }%     Map over each string in it:
   _                                 Duplicate the string, say S.
    [`';"];""L~""]:L~"]              Replace it the following list:
                                      [repr(S) '; "];" "L~" "]:L~"]
                       \             Bring S on top of the stack.
                        1>           Chop off the first char.
                          3b         Base-3 conversion.
                            =        Modular index into the list.
                               s~   Concatenate and run as CJam code.
</code>```

The “hash function” 1>3b maps

single-character strings to 0 (= 0 mod 5),

[B] to 291 (= 1 mod 5),

[D] to 297 (= 2 mod 5),

[P] to 333 (= 3 mod 5),

[C] to 294 (= 4 mod 5).

This value (mod 5) is used as an index into a list of CJam code snippets:

For single-character strings, say h, the snippet "h" is returned, which pushes a single-character string to the stack.

For [B], the snippet ; is returned, which pops an element.

For [D], the snippet ]; is returned, which clears the stack.

For [P], the snippet L~ is returned, which appends variable L onto the stack.

For [C], the snippet ]:L~ is returned, which stores the current stack in the variable L.

These snippets are concatenated and executed; the final stack is printed implicitly by CJam. L is initially the empty list, so the copy buffer is initially “empty”.

Title: Simulate keystrokes

Body:
CJam, 33 bytes

q~{_[`';"];""L~""]:L~"]\1>3b=}%s~

Try it online!

Explanation

q~                                  Read an evaluate input list.
  {                          }%     Map over each string in it:
   _                                 Duplicate the string, say S.
    [`';"];""L~""]:L~"]              Replace it the following list:
                                      [repr(S) '; "];" "L~" "]:L~"]
                       \             Bring S on top of the stack.
                        1>           Chop off the first char.
                          3b         Base-3 conversion.
                            =        Modular index into the list.
                               s~   Concatenate and run as CJam code.

The “hash function” 1>3b maps

single-character strings to 0 (= 0 mod 5),

[B] to 291 (= 1 mod 5),

[D] to 297 (= 2 mod 5),

[P] to 333 (= 3 mod 5),

[C] to 294 (= 4 mod 5).

This value (mod 5) is used as an index into a list of CJam code snippets:

For single-character strings, say h, the snippet "h" is returned, which pushes a single-character string to the stack.

For [B], the snippet ; is returned, which pops an element.

For [D], the snippet ]; is returned, which clears the stack.

For [P], the snippet L~ is returned, which appends variable L onto the stack.

For [C], the snippet ]:L~ is returned, which stores the current stack in the variable L.

These snippets are concatenated and executed; the final stack is printed implicitly by CJam. L is initially the empty list, so the copy buffer is initially “empty”.


问:
Output a Magical 8 Trapezium
Your task is to output a Magical 8 Trapezium:

```<code>        1 × 8 + 1 = 9
       12 × 8 + 2 = 98
      123 × 8 + 3 = 987
     1234 × 8 + 4 = 9876
    12345 × 8 + 5 = 98765
   123456 × 8 + 6 = 987654
  1234567 × 8 + 7 = 9876543
 12345678 × 8 + 8 = 98765432
123456789 × 8 + 9 = 987654321
</code>```

Output in your chosen language in the fewest bytes possible.

Note the number of spaces at the start of each line to maintain the trapezium shape.

Trailing spaces are allowed.

You can use × or the letter x - whichever you prefer.

Title: Output a Magical 8 Trapezium

Body:
///, 149 bytes

/:/ x 8 + //-/ = //0/1234//_/9876//|/  /||||1:1-9
||| 12:2-98
|||123:3-987
|| 0:4-_
||05:5-_5
| 056:6-_54
|0567:7-_543
 05678:8-_5432
056789:9-_54321

Try it online!


Title: Draw an ASCII chess board!

Body:
Here is a simple challenge for you: You must produce this ASCII representation of a chess board. White is represented by uppercase characters, and black is represented by lowercase. Empty tiles are represented by a .. Here is the full board:

```<code>rnbqkbnr
pppppppp
........
........
........
........
PPPPPPPP
RNBQKBNR
</code>```

Since this is a kolmogorov-complexity question, you may not take any input and you must output this board by any default method, for example, saving a file, printing to STDOUT or returning from a function. You may optionally produce one trailing newline. Standard loopholes apply, and the shortest program in bytes!

However, remember this is equally as much a competition between submissions in the same language. While it's unlikely that a languages like Java could beat a language like perl, or a golfing language like pyth or cjam, having the shortest Java answer is still really impressive! To help you track the shortest answer in each language, you may use this leaderboard, which will show the shortest submission by language and overall.

Leaderboards

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=95745,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:
Brainfuck, 224 bytes

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

Took almost an hour to get this.


问:
Add two numbers
Input: Two integers. Preferably decimal integers, but other forms of numbers can be used. These can be given to the code in standard input, as arguments to the program or function, or as a list.

Output: Their sum. Use the same format for output integers as input integers. For example, the input 5 16 would lead to the output 21.

Restrictions: No standard loopholes please. This is code-golf, answer in lowest amount of bytes wins.

Notes: This should be fairly trivial, however I'm interested to see how it can be implemented. The answer can be a complete program or a function, but please identify which one it is.

Test cases:

```<code>1 2 -> 3
14 15 -> 29
7 9 -> 16
-1 8 -> 7
8 -9 -> -1
-8 -9 -> -17
</code>```

Or as CSV:

```<code>a,b,c
1,2,3
14,15,29
7,9,16
-1,8,7
8,-9,-1
-8,-9,-17
</code>```

Leaderboard

var QUESTION_ID=84260,OVERRIDE_USER=8478;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

```

答:
QBIC, 6 bytes

```<code>::?a+b
</code>```

It takes two cmd line params as numbers (with two :'s), names them a and b, and adds them while printing (?).

Title: Add two numbers

Body:
QBIC, 6 bytes

::?a+b

It takes two cmd line params as numbers (with two :'s), names them a and b, and adds them while printing (?).


答:
sed, 275 bytes

s/[1-9]/0&/g
s/[5-9]/4&/g
s/[89]/4&/g
s/[2367]/xx&/g
s/[13579]/x/g
s/4/xxxx/g
s/[1-8]//g
s/$/ /
:a
s/\(.*\)0\(x*\) \(.*\)0\(x*\) /\1 \3 0\2\4/
ta
s/  *//g
:c
s/0xxxxxxxxxx/x0/g
tc
s/0x/-x/g
s/xx/2/g
y/x/1/
s/22/4/g
s/44/8/g
s/81/9/g
s/21/3/g
s/42/6/g
s/43/7/g
s/41/5/g
s/-//g
```
<p>Takes 2 space-separated non-negative decimal integers on standard input; prints their sum to standard output</p>
<h2>Explanation</h2>
<p>We represent each input in unary-coded decimal, using <code>x</code> as our digit, and <code>0</code> as separator.  For example, 42 is written <code>0xxxx0xx</code>.</p>
<pre class="lang-sed prettyprint-override"><code>#!/bin/sed -f

# Convert to unary decimal
s/[1-9]/0&/g
s/[5-9]/4&/g
s/[89]/4&/g
s/[2367]/xx&/g
s/[13579]/x/g
s/4/xxxx/g
s/[1-8]//g

# Append space to separate second input from output
s/$/ /
# Consume the smallest of each digit from input, and push
# the sum to output
:add
s/\(.*\)0\(x*\) \(.*\)0\(x*\) /\1 \3 0\2\4/
tadd

# Everything is now accumulated in output; remove the spaces
s/  *//g
# Add carry to the next position
:carry
s/0xxxxxxxxxx/x0/g
tcarry

# Back to decimal
s/0x/-x/g
s/xx/2/g
y/x/1/
s/22/4/g
s/44/8/g
s/81/9/g
s/21/3/g
s/42/6/g
s/43/7/g
s/41/5/g
s/-//g
</code>```

The extension to support decimal fractions is left as an exercise for the reader.

Title: Add two numbers

Body:
Input: Two integers. Preferably decimal integers, but other forms of numbers can be used. These can be given to the code in standard input, as arguments to the program or function, or as a list.

Output: Their sum. Use the same format for output integers as input integers. For example, the input 5 16 would lead to the output 21.

Restrictions: No standard loopholes please. This is code-golf, answer in lowest amount of bytes wins.

Notes: This should be fairly trivial, however I'm interested to see how it can be implemented. The answer can be a complete program or a function, but please identify which one it is.

Test cases:

```<code>1 2 -> 3
14 15 -> 29
7 9 -> 16
-1 8 -> 7
8 -9 -> -1
-8 -9 -> -17
</code>```

Or as CSV:

```<code>a,b,c
1,2,3
14,15,29
7,9,16
-1,8,7
8,-9,-1
-8,-9,-17
</code>```

Leaderboard

var QUESTION_ID=84260,OVERRIDE_USER=8478;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:
sed, 275 bytes

s/[1-9]/0&/g
s/[5-9]/4&/g
s/[89]/4&/g
s/[2367]/xx&/g
s/[13579]/x/g
s/4/xxxx/g
s/[1-8]//g
s/$/ /
:a
s/\(.*\)0\(x*\) \(.*\)0\(x*\) /\1 \3 0\2\4/
ta
s/  *//g
:c
s/0xxxxxxxxxx/x0/g
tc
s/0x/-x/g
s/xx/2/g
y/x/1/
s/22/4/g
s/44/8/g
s/81/9/g
s/21/3/g
s/42/6/g
s/43/7/g
s/41/5/g
s/-//g

Takes 2 space-separated non-negative decimal integers on standard input; prints their sum to standard output

Explanation

We represent each input in unary-coded decimal, using x as our digit, and 0 as separator.  For example, 42 is written 0xxxx0xx.

#!/bin/sed -f

# Convert to unary decimal
s/[1-9]/0&/g
s/[5-9]/4&/g
s/[89]/4&/g
s/[2367]/xx&/g
s/[13579]/x/g
s/4/xxxx/g
s/[1-8]//g

# Append space to separate second input from output
s/$/ /
# Consume the smallest of each digit from input, and push
# the sum to output
:add
s/\(.*\)0\(x*\) \(.*\)0\(x*\) /\1 \3 0\2\4/
tadd

# Everything is now accumulated in output; remove the spaces
s/  *//g
# Add carry to the next position
:carry
s/0xxxxxxxxxx/x0/g
tcarry

# Back to decimal
s/0x/-x/g
s/xx/2/g
y/x/1/
s/22/4/g
s/44/8/g
s/81/9/g
s/21/3/g
s/42/6/g
s/43/7/g
s/41/5/g
s/-//g

The extension to support decimal fractions is left as an exercise for the reader.


答:
Pyth, 7 Bytes

```<code>VQ*\*hN
</code>```

Knocked off a byte thanks to @ETHproductions
Try it online

using @PIetu1998's Technique

6, bytes

```<code>j*L*\*S
</code>```

Title: Draw an asterisk triangle

Body:
Pyth, 7 Bytes

VQ*\*hN

Knocked off a byte thanks to @ETHproductions
Try it online

using @PIetu1998's Technique

6, bytes

j*L*\*S


答:
Brain-Flak 75 Bytes

Includes +3 for -A

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

Try it online!

Explanation:

```<code>{(({})[()]<                                                        >)}
#reduce the top element by one until it is 0 after doing the following
#Push this element back on to act as a counter for the next step.
#(counts down from input to 0 we'll call this counter)

           {({}[()]<                          >)}
           #reduce the top element by one until it is 0 after doing the following
           #(counts down from counter to 0)

                    (((((()()()){}()){})){}{})
                    #push 42 (the ASCII code for *)

                                                 {}
                                                 #pop the counter used to push
                                                 #the right number of *s

                                                   ((()()()()()){})
                                                   #push a 10 (newline)

                                                                      {}
                                                                      #pop the null byte
</code>```

Title: Draw an asterisk triangle

Body:
Brain-Flak 75 Bytes

Includes +3 for -A

{(({})[()]<{({}[()]<(((((()()()){}()){})){}{})>)}{}((()()()()()){})>)}{}

Try it online!

Explanation:

{(({})[()]<                                                        >)}
#reduce the top element by one until it is 0 after doing the following
#Push this element back on to act as a counter for the next step.
#(counts down from input to 0 we'll call this counter)

           {({}[()]<                          >)}
           #reduce the top element by one until it is 0 after doing the following
           #(counts down from counter to 0)

                    (((((()()()){}()){})){}{})
                    #push 42 (the ASCII code for *)

                                                 {}
                                                 #pop the counter used to push
                                                 #the right number of *s

                                                   ((()()()()()){})
                                                   #push a 10 (newline)

                                                                      {}
                                                                      #pop the null byte


答:
Brainfuck, 70 bytes

```<code>,>++++++[<-------->>>+++++++<<-]<[>+[->+>.<<]>[-<+>]++++++++++.[-]<<-]
</code>```

I'm sure this could be golfed a little bit. This version only works for single-digit numbers; feel free to modify it to work on larger numbers too.

Edit: If it's allowed to use a single character's ASCII value as the input, the resulting code is below. Only 60 bytes.

```<code>,>++++++[>>+++++++<<-]>[>+[->+>.<<]>[-<+>]++++++++++.[-]<<-]
</code>```

Explanation:

```<code>,>++++++[<-------->>>+++++++<<-]  [this gets a single character from
input into the first cell, subtracts 48 to convert it to an integer
representation, and puts 42 in the 3rd cell (ASCII '*').]

<[ while the first cell is not zero do
    >+   add 1 to 2nd cell (empty when we start)
    [->+>.<<]  [while 2nd cell is not empty subtract 1 and print an *.
                Make a copy in 3rd cell.]
    >[-<+>]  copy 3rd cell value back to 2nd cell
    ++++++++++.[-] [put '\n' in 3rd cell, print, clear]
    <<-
 ] loop
</code>```

Edit: Here is a version that works for numbers up to 255, reading the text representation of the number followed by EOF. If your favorite interpreter has unbounded cells it will work up to 999.

```<code>>>,[----------
[
    >++++++[<------>-]<--
>],]

[
 Pointer is one past the end of a run of digits containing input.
 Assumption: input < 256.
 Add ten times most significant digit to second and ten times the
 second to the third to get it in one cell.
]

<<<[>++++++++++<-]>[>++++++++++<-]>

Store 42 '*' in the cell 3 to the right
>>++++++[>+++++++<-]<<

[ While first cell is not empty
    >+ Add 1 to 2nd cell
    [->+>.<<] [make a copy in 3rd cell, print '*']
    >[<+>-] copy 3rd back to 2nd
    ++++++++++.[-] print newline and clear 3rd
    <<- subtract 1 from 1st and continue
]
</code>```

Title: Draw an asterisk triangle

Body:
Brainfuck, 70 bytes

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

I'm sure this could be golfed a little bit. This version only works for single-digit numbers; feel free to modify it to work on larger numbers too.

Edit: If it's allowed to use a single character's ASCII value as the input, the resulting code is below. Only 60 bytes.

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

Explanation:

,>++++++[<-------->>>+++++++<<-]  [this gets a single character from
input into the first cell, subtracts 48 to convert it to an integer
representation, and puts 42 in the 3rd cell (ASCII '*').]

<[ while the first cell is not zero do
    >+   add 1 to 2nd cell (empty when we start)
    [->+>.<<]  [while 2nd cell is not empty subtract 1 and print an *.
                Make a copy in 3rd cell.]
    >[-<+>]  copy 3rd cell value back to 2nd cell
    ++++++++++.[-] [put '\n' in 3rd cell, print, clear]
    <<-
 ] loop

Edit: Here is a version that works for numbers up to 255, reading the text representation of the number followed by EOF. If your favorite interpreter has unbounded cells it will work up to 999.

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

[
 Pointer is one past the end of a run of digits containing input.
 Assumption: input < 256.
 Add ten times most significant digit to second and ten times the
 second to the third to get it in one cell.
]

<<<[>++++++++++<-]>[>++++++++++<-]>

Store 42 '*' in the cell 3 to the right
>>++++++[>+++++++<-]<<

[ While first cell is not empty
    >+ Add 1 to 2nd cell
    [->+>.<<] [make a copy in 3rd cell, print '*']
    >[<+>-] copy 3rd back to 2nd
    ++++++++++.[-] print newline and clear 3rd
    <<- subtract 1 from 1st and continue
]


答:
C++ - 92 96 Bytes

```<code>#include<string>
int main(){int n;std::string s;scanf("%d",&n);for(;n--;)puts((s+="*").data());}
</code>```

Try it online

Ungolfed:

```<code>//this one hurts, but c++ strings are mutable
#include<string>
int main(){
    int n;
    //this one hurts as well
    std::string s;
    //read input to n
    //longer than 'std::cin>>n', but no #include<iostream> needed
    scanf("%d",&n);
    // same as 'while(n--)', also characterwise, but way cooler
    for(;n--;)
        //add a '*' the string
        //data() does the same as c_str()
        //puts automatically adds an '\n'
        puts((s+="*").data());
}
</code>```

Title: Draw an asterisk triangle

Body:
Inspired by a task for Programming 101, here's a challenge that hopefully isn't too easy (or a duplicate).

Input:

A positive integer n >= 1.

Output:

n lines of asterisks, where every new line has one asterisk more than the line before, and starting with one asterisk in the first line.

Test case (n=5):

```<code>    *
    **
    ***
    ****
    *****
</code>```

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

Body:
C++ - 92 96 Bytes

#include<string>
int main(){int n;std::string s;scanf("%d",&n);for(;n--;)puts((s+="*").data());}

Try it online

Ungolfed:

//this one hurts, but c++ strings are mutable
#include<string>
int main(){
    int n;
    //this one hurts as well
    std::string s;
    //read input to n
    //longer than 'std::cin>>n', but no #include<iostream> needed
    scanf("%d",&n);
    // same as 'while(n--)', also characterwise, but way cooler
    for(;n--;)
        //add a '*' the string
        //data() does the same as c_str()
        //puts automatically adds an '\n'
        puts((s+="*").data());
}


答:
Javascript, 71 bytes 48 Bytes, thanks ETHproductions!

(n,c)=>{while(c<=n)console.log("*".repeat(c++))}
```

Title: Draw an asterisk triangle


答:
Pyke, 6 bytes

```<code>Voh\**
</code>```

Try it here!

Title: Draw an asterisk triangle

Body:
Pyke, 6 bytes

Voh\**

Try it here!


问:
Let's make a word-search!
In this challenge, we will together create a word-search containing many programs in different languages.

I have started us off with a grid of 60-by-25 blanks (·), some of which are replaced by the characters of a Ruby program.

To answer, choose a language that was not yet used. Using your chosen language, write a program that reads a character, token, line, or all input from the console, and prints it. Then, insert your program into the word-search.

For example, suppose you choose Python 3 for your answer, and write the program print(input()). Now you have to insert that program into the grid.

If the grid before your answer looks like this:

```<code>···a·24··········
··z····t·········
</code>```

Then you can just put your program in the second line, overlapping with the existing t:

```<code>···a·24··········
··zprint(input())
</code>```

Note that you can place your program in any direction: forward, backward, upward, downward, or diagonally, as long as it's in a straight line.

But what if the existing grid looks like this:

```<code>···a·24··········
··z····q·········
</code>```

There's no way to fit the print(input()) here without changing existing characters, which is forbidden. Instead, you can change the program:

```<code>print(
 input())
</code>```

This two-line program fits neatly:

```<code>···a·24·print(···
··z····q input())
</code>```

Here you replace a blank (·) with a space (). However, a space is just like any other character, and can not be overwritten in future programs.

Just like a one-liner, a multi-line program can be placed in any direction. For example, in a larger grid, you could do the following, by rotating the program 135° clockwise.

```<code>··········
········ ·
·······i·p
······n·r·
·····p·i··
····u·n···
···t·t····
··(·(·····
·)········
)·········
</code>```

Scoring

Your score for each answer is thirty divided by the number of characters added. Do not count characters that already existed in the grid, even if you use them yourself.

Your total score is the sum of the scores for all of your answers, multiplied by the number of answers. Highest score wins.

Rules

Every answer must be written in a different language. Languages that differ only in version number (e.g., Python 2 and Python 3) are considered the same.

Every answer must build off of the most recent valid answer. That is, take the grid of the most recent such answer, and insert your program into it.

To insert your program, replace at least one of the blanks (·) with characters of your choice. You may use existing characters from the grid in your answer, but you may not change or move any of them.

You may not insert more than 500 characters in total, across all your answers.

All characters you insert must be part of your program.

Your program may consist only of printable ASCII and newlines, but there may not be two or more consecutive newlines back-to-back.

Newlines do not count towards your score.

A full program, not just a function or snippet, is required.

The same user may not write two consecutive answers.

If someone's answer violates a rule, leave a comment. If the mistake is not fixed in 30 minutes, it should be deleted.

Used language snippet

This is a Stack Snippet, made by ETHproductions, FryAmTheEggman, and Mauris, that keeps track of users' scores and the used languages. It was originally copied from Martin Büttner's amazing template.

Original leaderboard:

function answersUrl(e){return"http://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,r){return"http://api.stackexchange.com/2.2/answers/"+r.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 r=+e.share_link.match(/\d+/);answer_ids.push(r),answers_hash[r]=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=[],r={},x={};answers.forEach(function(s){var a=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(a="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var n=a.match(SCORE_REG);if(n){var t=getAuthorName(s);e.push({user:getAuthorName(s),size:+n[2],language:n[1],link:s.share_link}),r[t]=r[t]||0,r[t]+=30/+n[2],x[t]=x[t]||0,x[t]++}});Object.keys(r).forEach(function(e){r[e]*=x[e]});var s=Object.keys(r).sort(function(e,s){return r[s]-r[e]});e.sort(function(e,r){var s=e.size,a=r.size;return s-a});var a={},t=null;e.forEach(function(e){t=e.size;var r=e.language;/<a/.test(r)&&(r=jQuery(r).text()),a[r]=a[r]||{lang:e.language,user:e.user,size:e.size,link:e.link}});for(var c=0,o=1;c<s.length;c++){var i=jQuery("#author-template").html();r[s[c]]!==r[s[c-1]]&&(o=c+1);i=i.replace("{{PLACE}}",o+'.').replace("{{NAME}}",s[c]).replace("{{SCORE}}",r[s[c]].toFixed(2)),jQuery("#authors").append(jQuery(i))}var u=[];for(var m in a)a.hasOwnProperty(m)&&u.push(a[m]);u.sort(function(e,r){var s=e.lang.replace(/<.*?>/g,"").toLowerCase(),a=r.lang.replace(/<.*?>/g,"").toLowerCase();return s>a?1:a>s?-1:0});for(var l=0;l<u.length;++l){var h=jQuery("#language-template").html(),m=u[l];h=h.replace("{{LANGUAGE}}",m.lang).replace("{{NAME}}",m.user).replace("{{SIZE}}",m.size).replace("{{LINK}}",m.link),h=jQuery(h),jQuery("#languages").append(h)}}var QUESTION_ID=57327,ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",OVERRIDE_USER=16294,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}#author-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	Score

Languages

Language	User	Score

{{PLACE}}	{{NAME}}	{{SCORE}}

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

```
</div>
</div>
</p>

<p>New (experimental) version, using a modified formula:</p>

<p><div class="snippet" data-lang="js" data-hide="true">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function answersUrl(e){return"http://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,r){return"http://api.stackexchange.com/2.2/answers/"+r.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 r=+e.share_link.match(/\d+/);answer_ids.push(r),answers_hash[r]=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=[],r={},x={};answers.forEach(function(s){var a=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(a="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var n=a.match(SCORE_REG);if(n){var t=getAuthorName(s);e.push({user:getAuthorName(s),size:+n[2],language:n[1],link:s.share_link}),r[t]=r[t]||0,r[t]+=30/+n[2]+20,x[t]=x[t]||0,x[t]++}});var s=Object.keys(r).sort(function(e,s){return r[s]-r[e]});e.sort(function(e,r){var s=e.size,a=r.size;return s-a});var a={},t=null;e.forEach(function(e){t=e.size;var r=e.language;/<a/.test(r)&&(r=jQuery(r).text()),a[r]=a[r]||{lang:e.language,user:e.user,size:e.size,link:e.link}});for(var c=0,o=1;c<s.length;c++){var i=jQuery("#author-template").html();r[s[c]]!==r[s[c-1]]&&(o=c+1);i=i.replace("{{PLACE}}",o+'.').replace("{{NAME}}",s[c]).replace("{{SCORE}}",r[s[c]].toFixed(2)),jQuery("#authors").append(jQuery(i))}var u=[];for(var m in a)a.hasOwnProperty(m)&&u.push(a[m]);u.sort(function(e,r){var s=e.lang.replace(/<.*?>/g,"").toLowerCase(),a=r.lang.replace(/<.*?>/g,"").toLowerCase();return s>a?1:a>s?-1:0});for(var l=0;l<u.length;++l){var h=jQuery("#language-template").html(),m=u[l];h=h.replace("{{LANGUAGE}}",m.lang).replace("{{NAME}}",m.user).replace("{{SIZE}}",m.size).replace("{{LINK}}",m.link),h=jQuery(h),jQuery("#languages").append(h)}}var QUESTION_ID=57327,ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",OVERRIDE_USER=16294,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;</code>```

body{text-align:left!important}#author-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="author-list"> <h2>Leaderboard</h2> <table class="author-list"> <thead> <tr><td></td><td>Author</td><td>Score</td></tr></thead> <tbody id="authors"> </tbody> </table> </div><div id="language-list"> <h2>Languages</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="author-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{SCORE}}</td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td>Link</td></tr></tbody> </table></code>```

To ensure your submission is recognized by the snippet, please use the following header template:

```<code># Language, X characters added
</code>```

答:
Brain-Flak, 2 characters added

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

Pops and pushes the top element,so the stack ends up unchanged. Input is implicitly put on the stack, and the stack is printed afterwards. Only numbers are allowed (unless you use the argument -c).

New grid:

```<code>·········v---H\OIv+C+<D_Include C by GS Psgv···········;····
G`····,.·>qir@uH·  IaP.C.%······LAMBDA·USE: io·········>····
Get a chr!?pio;p···Ol···Z: say TZEROYALreadln(write(···;····
Outputs it,u··a$ ohce····.··c······ ·L·print(readline())····
and 'BZam..t···a daer····x··a·····ai ··string))·o<v;i:j;p:j·
G·······~,@s······s t=" " r t#50:20 w !,t,!······?a?·:,Eu-··
G·····main( ){printf("%c",  (getchar()));}·······pr>>:.;tg··
O·········)g·>    input('','s'))(enildr ,tnirp···h_··)·P(e··
a··········e·····n··r·····^·c··{puts [gets stdin]pd····;Ct··
·······(write(read-host)····a)}·······r·input n$!?uread()(··
·······))E·s··w·····m·······n)···KVGH·e·print n$!·m····;.C··
········C·E·········p·······((···TIIA{print;exit}·pYEK·*·)··
$'main'H·TUPTUO·····t·00····,t···HSMI· ···r·······(······,··
 \/\I^O= ·TUPNI···S (I\\/\]]'u···XIM ·-···········$·········
  \/· ·/(println··FO) /·····'p···BBE1·main = interact id····
   \%·PQ  (read-line))······)n···YLH.·1··print(io.read())···
   A\     /-io-\············)io··EE 4n ··@.,`·····g·········
  % A\-e-<     |··········)#_(o··· V-·.··di _r(a)^v·········
 $ =      \----#·············t\·c&V ···$;di $a····)·········
{elbaworhT sworht )a][gnirtS(niam diov citats cilbup{C ssalc
;))(txen.)ni.metsyS(rennacS.litu.avaj wen(nltnirp.tuo.metsyS
··`[x.````?10xx][x.````?10xx]r··e···a b c d e f g h i·····}}
··········;>maertsoi<edulcni#p·h···=b c d e f g h i·········
····;s gnirts::dts{)(niam tni····v<   o<Ook. Ook! Ook! Ook.·
···};s<<tuoc::dts;s>>nic::dts···o>i:1+?/;][gnirtStupnI@tnirP
</code>```

My code (lines 8-11):

```<code>································(···························
·······························{····························
······························}·····························
·····························)······························
</code>```

Title: Let's make a word-search!

Body:
Brain-Flak, 2 characters added

({})

Pops and pushes the top element,so the stack ends up unchanged. Input is implicitly put on the stack, and the stack is printed afterwards. Only numbers are allowed (unless you use the argument -c).

New grid:

·········v---H\OIv+C+<D_Include C by GS Psgv···········;····
G`····,.·>qir@uH·  IaP.C.%······LAMBDA·USE: io·········>····
Get a chr!?pio;p···Ol···Z: say TZEROYALreadln(write(···;····
Outputs it,u··a$ ohce····.··c······ ·L·print(readline())····
and 'BZam..t···a daer····x··a·····ai ··string))·o<v;i:j;p:j·
G·······~,@s······s t=" " r t#50:20 w !,t,!······?a?·:,Eu-··
G·····main( ){printf("%c",  (getchar()));}·······pr>>:.;tg··
O·········)g·>    input('','s'))(enildr ,tnirp···h_··)·P(e··
a··········e·····n··r·····^·c··{puts [gets stdin]pd····;Ct··
·······(write(read-host)····a)}·······r·input n$!?uread()(··
·······))E·s··w·····m·······n)···KVGH·e·print n$!·m····;.C··
········C·E·········p·······((···TIIA{print;exit}·pYEK·*·)··
$'main'H·TUPTUO·····t·00····,t···HSMI· ···r·······(······,··
 \/\I^O= ·TUPNI···S (I\\/\]]'u···XIM ·-···········$·········
  \/· ·/(println··FO) /·····'p···BBE1·main = interact id····
   \%·PQ  (read-line))······)n···YLH.·1··print(io.read())···
   A\     /-io-\············)io··EE 4n ··@.,`·····g·········
  % A\-e-<     |··········)#_(o··· V-·.··di _r(a)^v·········
 $ =      \----#·············t\·c&V ···$;di $a····)·········
{elbaworhT sworht )a][gnirtS(niam diov citats cilbup{C ssalc
;))(txen.)ni.metsyS(rennacS.litu.avaj wen(nltnirp.tuo.metsyS
··`[x.````?10xx][x.````?10xx]r··e···a b c d e f g h i·····}}
··········;>maertsoi<edulcni#p·h···=b c d e f g h i·········
····;s gnirts::dts{)(niam tni····v<   o<Ook. Ook! Ook! Ook.·
···};s<<tuoc::dts;s>>nic::dts···o>i:1+?/;][gnirtStupnI@tnirP

My code (lines 8-11):

································(···························
·······························{····························
······························}·····························
·····························)······························


答:
Bash, 73 bytes

```<code>e=........\\n
echo -e "rnbqkbnr\npppppppp\n$e$e$e${e}PPPPPPPP\nRNBQKBNR"
</code>```

Title: Draw an ASCII chess board!

Body:
Bash, 73 bytes

e=........\\n
echo -e "rnbqkbnr\npppppppp\n$e$e$e${e}PPPPPPPP\nRNBQKBNR"


答:
C, 97 bytes

```<code>char *e="........\n";main(){printf("rnbqkbnr\npppppppp\n%s%s%s%sPPPPPPPP\nRNBQKBNR\n",e,e,e,e);}
</code>```

Title: Draw an ASCII chess board!

Body:
C, 97 bytes

char *e="........\n";main(){printf("rnbqkbnr\npppppppp\n%s%s%s%sPPPPPPPP\nRNBQKBNR\n",e,e,e,e);}


问:
Inverse permutation index

Introduction

The lexicographical permutations of a list with n elements can be numbered from 0 to n! - 1. For example, the 3! = 6 permutations of (1,2,3) would be (1,2,3), (1,3,2), (2,1,3), (2,3,1), (3,1,2), (3,2,1).

When a permutation is applied to a list, its elements are ordered in the same order as the numbers in the permutation. For example, applying the permutation (2,3,1) to l = (a,b,c) yields (l[2],l[3],l[1]) = (b,c,a).

The inverse of a permutation is defined as the permutation that reverses this operation, i.e. applying a permutation and then its inverse (or vice versa) does not modify the array. For example, the inverse of (2,3,1) is (3,1,2), since applying that to (b,c,a) yields (a,b,c).

Also, a permutation's inverse applied to the permutation itself yields the integers 1…n. For example, applying (3,1,2) to (2,3,1) yields (1,2,3).

We now define the function revind(x) as the index of the inverse permutation of the permutation with index x. (This is A056019, if you're interested.)

Since a permutation with index i only modifies the last k items of the list iff 0 ≤ i < k!, we can add any number of elements to the start of the list without affecting revind(i). Therefore the length of the list does not affect the result.

Challenge

Your task is to implement revind(x). You will write a full program or function that takes a single nonnegative integer x as input/argument and outputs/returns the result as a single nonnegative integer.

The input and output may be 0-indexed or 1-indexed, but this must be consistent between them.

Builtins that generate permutations by index, return the index of a permutation or find the inverse permutation are banned. (Builtins that generate all permutations or the next permutation are allowed.)

Standard code-golf rules apply.

Examples

The examples below are 0-indexed.

```<code>Input    Output
0        0
1        1
2        2
3        4
4        3
5        5
6        6
13       10
42       51
100      41
1000     3628
2000     3974
10000    30593
100000   303016
</code>```

Reference implementation (Python 3)

def revind(n):
    from math import factorial
    from itertools import permutations, count
    l = next(filter(lambda x: factorial(x) > n, count(1)))
    pms = list(permutations(range(l)))
    return [k for k in range(len(pms)) if tuple(pms[n][i] for i in pms[k]) == pms[0]][0]
```

答:
CJam, 16 bytes

```<code>ri_)e!_@=_$\f#a#
</code>```

Indices are 0-based.

Try it online!

I doesn't get a lot more inefficient than this... runs out of memory with Java's default settings for inputs greater than 8 (but works in principle for arbitrary inputs given a sufficient number of universes of time and memory).

Explanation

```<code>ri    e# Read input and convert to integer N.
_)e!  e# Duplicate N, get all permutations of [0 1 ... N].
_@=   e# Duplicate permutations, get the Nth permutation.
_$    e# Duplicate and sort to get the sorted range [0 1 ... N].
\f#   e# For each of these values, get its index in the Nth permutation.
      e# This inverts the permutation.
a#    e# Find the index of this new permutation in the list of all permutations.
</code>```

Title: Inverse permutation index

Body:
CJam, 16 bytes

ri_)e!_@=_$\f#a#

Indices are 0-based.

Try it online!

I doesn't get a lot more inefficient than this... runs out of memory with Java's default settings for inputs greater than 8 (but works in principle for arbitrary inputs given a sufficient number of universes of time and memory).

Explanation

ri    e# Read input and convert to integer N.
_)e!  e# Duplicate N, get all permutations of [0 1 ... N].
_@=   e# Duplicate permutations, get the Nth permutation.
_$    e# Duplicate and sort to get the sorted range [0 1 ... N].
\f#   e# For each of these values, get its index in the Nth permutation.
      e# This inverts the permutation.
a#    e# Find the index of this new permutation in the list of all permutations.


答:
Emotinomicon, 89 bytes

Sadly Emotinomicon has nothing like an duplicate stack function. Would be usefull. But at least shorter than Java. :)

```<code>RNBKQBNR
PPPPPPPP
........
........
........
........
pppppppp
rnbkqbnr⏪⏬⏩
</code>```

Explanation:

```<code>(...)⏪⏬⏩
(...)            String literal
         ⏪  ⏩      Loop
           ⏬        Pop one char and output
</code>```

Title: Draw an ASCII chess board!

Body:
Emotinomicon, 89 bytes

Sadly Emotinomicon has nothing like an duplicate stack function. Would be usefull. But at least shorter than Java. :)

RNBKQBNR
PPPPPPPP
........
........
........
........
pppppppp
rnbkqbnr⏪⏬⏩

Explanation:

(...)⏪⏬⏩
(...)            String literal
         ⏪  ⏩      Loop
           ⏬        Pop one char and output


问:
Print this tic-tac-toe board!
Here is a tic-tac-toe board:

```<code>   a     b     c
      |     |
1  -  |  -  |  -
 _____|_____|_____
      |     |
2  -  |  -  |  -
 _____|_____|_____
      |     |
3  -  |  -  |  -
      |     |
</code>```

Given a set of moves, print the board with the tokens on.

Input will be taken in as moves separated by spaces, with each move being:

First, the token that's going

Next, the letter of the column it is moving on

Last, the number of the row it is moving on

Note that normal tic-tac-toe rules don't matter.

Also, there is no need to print the letters and numbers.

For example, the input Ob2 Xc2 Ob3 Xa1 would result in

```<code>     |     |
  X  |  -  |  -
_____|_____|_____
     |     |
  -  |  O  |  X
_____|_____|_____
     |     |
  -  |  O  |  -
     |     |
</code>```

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

Leaderboards

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

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Autovim,  110 bytes (not competing)

Test driving Autovim... This is pretty much a Vimscript answer. Not competing because Autovim is still being developed.

```<code>ñ5i ␛a|␛ÿp3hr-phv0r_⌥v$kkyPPy2jPP$⌥vG$xGđkÿjp
…nsplit(@m)
ñğ0(@n[2]*3-2)j((char2nr(@n[1])-96)*6-4)lr(@n[0])
e…
</code>```

To run it:

```<code>./bin/autovim run tictactoe.autovim -ni -@m "Ob2 Xc2 Ob3 Xa1"
</code>```

Ungolfed:

```<code>execute "normal 5i \<esc>a|\<esc>yyp3hr-phv0r_\<c-v>$kkyPPy2jPP$\<c-v>G$xGddkyyjp"
for @n in split(@m)
execute "normal gg0".(@n[2]*3-2)."j".((char2nr(@n[1])-96)*6-4)."lr".(@n[0]).""
endfor
</code>```

Explanation to follow if there is interest :)

Title: Print this tic-tac-toe board!

Body:
Autovim,  110 bytes (not competing)

Test driving Autovim... This is pretty much a Vimscript answer. Not competing because Autovim is still being developed.

ñ5i ␛a|␛ÿp3hr-phv0r_⌥v$kkyPPy2jPP$⌥vG$xGđkÿjp
…nsplit(@m)
ñğ0(@n[2]*3-2)j((char2nr(@n[1])-96)*6-4)lr(@n[0])
e…

To run it:

./bin/autovim run tictactoe.autovim -ni -@m "Ob2 Xc2 Ob3 Xa1"

Ungolfed:

execute "normal 5i \<esc>a|\<esc>yyp3hr-phv0r_\<c-v>$kkyPPy2jPP$\<c-v>G$xGddkyyjp"
for @n in split(@m)
execute "normal gg0".(@n[2]*3-2)."j".((char2nr(@n[1])-96)*6-4)."lr".(@n[0]).""
endfor

Explanation to follow if there is interest :)


答:
Mathematica, 74 bytes

```<code>Max@k[i,Flatten@Outer[i=Permutations[j=Range@#];k=Position,{i[[#]]},j,1]]&
</code>```

Uses 1-indexing. Very inefficient. (uses ~11GB of memory when the input is 11)

Explanation

```<code>j=Range@#
</code>```

Generate a list from 1 to N. Store that in j.

```<code>i=Permutations[...]
</code>```

Find all permutations of j. Store that in i.

```<code>k=Position
</code>```

Store the Position function in k. (to reduce byte-count when using Position again)

```<code>Flatten@Outer[...,{i[[#]]},j,1]
</code>```

Find the inverse permutation of the N-th permutation.

```<code>Max@k[i,...]
</code>```

Find the k (Position) of the inverse permutation in i (all permutations)

Using built-ins, <s>46</s> 43 bytes

```<code>a[(a=Ordering)/@Permutations@Range@#][[#]]&
</code>```

1-indexed.

Title: Inverse permutation index

Body:
Introduction

The lexicographical permutations of a list with n elements can be numbered from 0 to n! - 1. For example, the 3! = 6 permutations of (1,2,3) would be (1,2,3), (1,3,2), (2,1,3), (2,3,1), (3,1,2), (3,2,1).

When a permutation is applied to a list, its elements are ordered in the same order as the numbers in the permutation. For example, applying the permutation (2,3,1) to l = (a,b,c) yields (l[2],l[3],l[1]) = (b,c,a).

The inverse of a permutation is defined as the permutation that reverses this operation, i.e. applying a permutation and then its inverse (or vice versa) does not modify the array. For example, the inverse of (2,3,1) is (3,1,2), since applying that to (b,c,a) yields (a,b,c).

Also, a permutation's inverse applied to the permutation itself yields the integers 1…n. For example, applying (3,1,2) to (2,3,1) yields (1,2,3).

We now define the function revind(x) as the index of the inverse permutation of the permutation with index x. (This is A056019, if you're interested.)

Since a permutation with index i only modifies the last k items of the list iff 0 ≤ i < k!, we can add any number of elements to the start of the list without affecting revind(i). Therefore the length of the list does not affect the result.

Challenge

Your task is to implement revind(x). You will write a full program or function that takes a single nonnegative integer x as input/argument and outputs/returns the result as a single nonnegative integer.

The input and output may be 0-indexed or 1-indexed, but this must be consistent between them.

Builtins that generate permutations by index, return the index of a permutation or find the inverse permutation are banned. (Builtins that generate all permutations or the next permutation are allowed.)

Standard code-golf rules apply.

Examples

The examples below are 0-indexed.

```<code>Input    Output
0        0
1        1
2        2
3        4
4        3
5        5
6        6
13       10
42       51
100      41
1000     3628
2000     3974
10000    30593
100000   303016
</code>```

Reference implementation (Python 3)

def revind(n):
    from math import factorial
    from itertools import permutations, count
    l = next(filter(lambda x: factorial(x) > n, count(1)))
    pms = list(permutations(range(l)))
    return [k for k in range(len(pms)) if tuple(pms[n][i] for i in pms[k]) == pms[0]][0]
```

Body:
Mathematica, 74 bytes

Max@k[i,Flatten@Outer[i=Permutations[j=Range@#];k=Position,{i[[#]]},j,1]]&

Uses 1-indexing. Very inefficient. (uses ~11GB of memory when the input is 11)

Explanation

j=Range@#

Generate a list from 1 to N. Store that in j.

i=Permutations[...]

Find all permutations of j. Store that in i.

k=Position

Store the Position function in k. (to reduce byte-count when using Position again)

Flatten@Outer[...,{i[[#]]},j,1]

Find the inverse permutation of the N-th permutation.

Max@k[i,...]

Find the k (Position) of the inverse permutation in i (all permutations)

Using built-ins, <s>46</s> 43 bytes

a[(a=Ordering)/@Permutations@Range@#][[#]]&

1-indexed.


答:
RubyGolf, 15 bytes

```<code>p gets.i+gets.i
</code>```

code is so short it hit the character limit. ugh.

New language created by me, interpreter going up soon.

Title: Add two numbers

Body:
RubyGolf, 15 bytes

p gets.i+gets.i

code is so short it hit the character limit. ugh.

New language created by me, interpreter going up soon.


答:
Brain-Flak, 81 bytes

78 bytes but three for the -A flag, which enables ASCII output.

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

Try it online!

Brain-flak isn't the greatest language for ASCII-art, but it still managed to be somewhat short. Ish. Kinda.

Explanation:

```<code>While True:
{

(
Decrement counter
({}[()])

And move copy to other stack
<>())

Push N '*'s
{({}[()]<(((((()()()){}())){}{}){})>)}

Pop 0
{}

Push newline
((()()()()()){})

Move back to counter
<>

Endwhile
}

Move to other stack
<>

Pop an extra newline
{}
</code>```

Title: Draw an asterisk triangle

Body:
Brain-Flak, 81 bytes

78 bytes but three for the -A flag, which enables ASCII output.

{(({}[()])<>()){({}[()]<(((((()()()){}())){}{}){})>)}{}((()()()()()){})<>}<>{}

Try it online!

Brain-flak isn't the greatest language for ASCII-art, but it still managed to be somewhat short. Ish. Kinda.

Explanation:

While True:
{

(
Decrement counter
({}[()])

And move copy to other stack
<>())

Push N '*'s
{({}[()]<(((((()()()){}())){}{}){})>)}

Pop 0
{}

Push newline
((()()()()()){})

Move back to counter
<>

Endwhile
}

Move to other stack
<>

Pop an extra newline
{}


答:
Actually, 8 bytes

```<code>R`'**`Mi
</code>```

Try it online!

Explanation:

```<code>R`'**`Mi
R         range(1, n+1) ([1, 2, ..., n])
 `'**`M   for each element: that many asterisks
       i  flatten and implicitly print
</code>```

5 bytes

```<code>R'**i
</code>```

Try it online!

Title: Draw an asterisk triangle

Body:
Actually, 8 bytes

R`'**`Mi

Try it online!

Explanation:

R`'**`Mi
R         range(1, n+1) ([1, 2, ..., n])
 `'**`M   for each element: that many asterisks
       i  flatten and implicitly print

5 bytes

R'**i

Try it online!


答:
Pyth, <s>10</s> 8 Bytes

thanks to Jakube for helping me shave off the extra 2 bytes!

```<code>VQ*Np"*"
</code>```

Try it

Title: Draw an asterisk triangle

Body:
Pyth, <s>10</s> 8 Bytes

thanks to Jakube for helping me shave off the extra 2 bytes!

VQ*Np"*"

Try it


答:
Actually, 56 bytes

```<code>''j"'[B]"'XaÆ"'[C]""k;╗i"aÆ"'[P]""╜i"aÆ"'[D]"'éaÆ''+ƒkΣR
</code>```

Try it online!

Explanation:

```<code>''j"'[B]"'XaÆ"'[C]""k;╗i"aÆ"'[P]""╜i"aÆ"'[D]"'éaÆ''+ƒkΣR
''j                                                       insert an apostrophe between every pair of commands
   "'[B]"'XaÆ"'[C]""k;╗i"aÆ"'[P]""╜i"aÆ"'[D]"'éaÆ         replace:
   "'[B]"'XaÆ                                               "'[B]" with "X"
             "'[C]""k;╗i"aÆ                                 "'[C]" with "k;╗i"
                           "'[P]""╜i"aÆ                     "'[P]" with "╜i"
                                       "'[D]"'éaÆ           "'[D]" with "é"
                                                 ''+      prepend an apostrophe
                                                          now the input has been converted to the equivalent Actually program ("'<character>" pushes the character, "X" removes the last character, "k;╗i" saves the current stack state to a register, and "╜i" pushes the saved stack state)
                                                    ƒ     execute the code
                                                     kΣ   concatenate the characters
                                                       R  reverse the string
</code>```

Title: Simulate keystrokes

Body:
Your job is to simulate a couple of keystrokes that a user types in.

Input

A string array or string with a delimiter of your choice (outside the range 32-126) containing at least one 'keystroke'.

This array will only contain two types of string: passive keystrokes (single chars) and commands (chars within brackets [ ]).

Passive keystrokes

ASCII character codes [32-126]

Commands:

[B] : backspace (remove last character added if there is one)

[C] : copy all of what has already been written

[D] : delete all of what has been written

[P] : paste what has been copied

Output

The string produced by the keystrokes.

Examples

```<code>['H', 'e', 'l', 'l', 'o'] -> 'Hello'
['H', 'e', 'l', 'l', 'o', ' ', '[C]', '[P]'] -> 'Hello Hello '
['[D]', 'D', '[B]'] -> ''
['H', '[C]', 'i', '[P]', '[C]', '[P]'] -> 'HiHHiH'
['e', '[C]', '[B]', 'I', ' ', 'l', 'i', 'k', '[P]', ' ', 'b', '[P]', '[P]', 's', '!'] -> I like bees!
['N', '[P]'] -> 'N'
['#', '5', '0', 'K', '0', '0', '1', '[D]', '#', 'n', 'o', 't'] -> '#not'
['H', 'o', 'w', ' ', '[D]', 'H', 'e', 'y'] -> 'Hey'
['s', 'u', 'd', '[B]', 'p', '[C]', '[D]', 'I', ' ' , 'h', 'a', 'v', 'e', ' ', '[P]', 'p', 'e', 'r', '!'] -> 'I have supper!'
</code>```

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

Body:
Actually, 56 bytes

''j"'[B]"'XaÆ"'[C]""k;╗i"aÆ"'[P]""╜i"aÆ"'[D]"'éaÆ''+ƒkΣR

Try it online!

Explanation:

''j"'[B]"'XaÆ"'[C]""k;╗i"aÆ"'[P]""╜i"aÆ"'[D]"'éaÆ''+ƒkΣR
''j                                                       insert an apostrophe between every pair of commands
   "'[B]"'XaÆ"'[C]""k;╗i"aÆ"'[P]""╜i"aÆ"'[D]"'éaÆ         replace:
   "'[B]"'XaÆ                                               "'[B]" with "X"
             "'[C]""k;╗i"aÆ                                 "'[C]" with "k;╗i"
                           "'[P]""╜i"aÆ                     "'[P]" with "╜i"
                                       "'[D]"'éaÆ           "'[D]" with "é"
                                                 ''+      prepend an apostrophe
                                                          now the input has been converted to the equivalent Actually program ("'<character>" pushes the character, "X" removes the last character, "k;╗i" saves the current stack state to a register, and "╜i" pushes the saved stack state)
                                                    ƒ     execute the code
                                                     kΣ   concatenate the characters
                                                       R  reverse the string


答:
05AB1E, <s>34</s> <s>33</s> <s>31</s> 27 bytes

Uses CP-1252 encoding.

```<code>õUvygiyJë"XJ¨DU\"4äyáÇ5%è.V
</code>```

Try it online!

Explanation

```<code>õU                                  # initialize X as the empty string
v                                   # for each y in input
 ygiyJ                              # if len(y) == 1 join y with stack
      ë                             # else
       "XJ¨DU\"                     # push this string
               4ä                   # split into 4 parts (of size [2,1,2,1])
                 yá                 # push only letters of y
                   Ç5%              # mod its ascii code by 5
                      è             # index into the string above with this
                       .V           # evaluate as 05AB1E code
</code>```

The pairs of functions evaluated in the code above are:

```<code>DU    # [C] -> duplicate and store in X
XJ    # [P] -> push X and join with stack
¨     # [B] -> remove last char of string
\     # [D] -> remove top of stack
</code>```

Saved 4 bytes using the mod 5 trick from Lynn's CJam answer

Title: Simulate keystrokes

Body:
05AB1E, <s>34</s> <s>33</s> <s>31</s> 27 bytes

Uses CP-1252 encoding.

õUvygiyJë"XJ¨DU\"4äyáÇ5%è.V

Try it online!

Explanation

õU                                  # initialize X as the empty string
v                                   # for each y in input
 ygiyJ                              # if len(y) == 1 join y with stack
      ë                             # else
       "XJ¨DU\"                     # push this string
               4ä                   # split into 4 parts (of size [2,1,2,1])
                 yá                 # push only letters of y
                   Ç5%              # mod its ascii code by 5
                      è             # index into the string above with this
                       .V           # evaluate as 05AB1E code

The pairs of functions evaluated in the code above are:

DU    # [C] -> duplicate and store in X
XJ    # [P] -> push X and join with stack
¨     # [B] -> remove last char of string
\     # [D] -> remove top of stack

Saved 4 bytes using the mod 5 trick from Lynn's CJam answer


答:
Ruby, 27 (or 24) bytes

(Thanks to m-chrzan for pointing out the miscounting.)

Returns a string.

```<code>->n{(1..n).map{|i|?**i}*$/}
</code>```

the map makes an array of strings of * of increasing length. The *$/ takes the array and joins the elements to make a newline-separated string. If an array of strings is acceptable, these three bytes can be saved, scoring 24.

In test program

```<code>f=->n{(1..n).map{|i|?**i}*$/}
puts f[5]
</code>```

Title: Draw an asterisk triangle

Body:
Inspired by a task for Programming 101, here's a challenge that hopefully isn't too easy (or a duplicate).

Input:

A positive integer n >= 1.

Output:

n lines of asterisks, where every new line has one asterisk more than the line before, and starting with one asterisk in the first line.

Test case (n=5):

```<code>    *
    **
    ***
    ****
    *****
</code>```

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

Body:
Ruby, 27 (or 24) bytes

(Thanks to m-chrzan for pointing out the miscounting.)

Returns a string.

->n{(1..n).map{|i|?**i}*$/}

the map makes an array of strings of * of increasing length. The *$/ takes the array and joins the elements to make a newline-separated string. If an array of strings is acceptable, these three bytes can be saved, scoring 24.

In test program

f=->n{(1..n).map{|i|?**i}*$/}
puts f[5]


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

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

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

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

Points for:

Smallest code (in bytes)

Most obfuscated/obscure solution

Using esoteric/obscure languages

Successfully using languages that are difficult to golf in

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

var QUESTION_ID=69;
var OVERRIDE_USER=98;

var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk";var answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;function answersUrl(index){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+index+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}
function commentUrl(index,answers){return"https://api.stackexchange.com/2.2/answers/"+answers.join(';')+"/comments?page="+index+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}
function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(data){answers.push.apply(answers,data.items);answers_hash=[];answer_ids=[];data.items.forEach(function(a){a.comments=[];var id=+a.share_link.match(/\d+/);answer_ids.push(id);answers_hash[id]=a});if(!data.has_more)more_answers=!1;comment_page=1;getComments()}})}
function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(data){data.items.forEach(function(c){if(c.owner.user_id===OVERRIDE_USER)
answers_hash[c.post_id].comments.push(c)});if(data.has_more)getComments();else if(more_answers)getAnswers();else process()}})}
getAnswers();var SCORE_REG=(function(){var headerTag=String.raw `h\d`
var score=String.raw `\-?\d+\.?\d*`
var normalText=String.raw `[^\n<>]*`
var strikethrough=String.raw `<s>${normalText}</s>|<strike>${normalText}</strike>|<del>${normalText}</del>`
var noDigitText=String.raw `[^\n\d<>]*`
var htmlTag=String.raw `<[^\n<>]+>`
return new RegExp(String.raw `<${headerTag}>`+String.raw `\s*([^\n,]*[^\s,]),.*?`+String.raw `(${score})`+String.raw `(?=`+String.raw `${noDigitText}`+String.raw `(?:(?:${strikethrough}|${htmlTag})${noDigitText})*`+String.raw `</${headerTag}>`+String.raw `)`)})();var OVERRIDE_REG=/^Override\s*header:\s*/i;function getAuthorName(a){return a.owner.display_name}
function process(){var valid=[];answers.forEach(function(a){var body=a.body;a.comments.forEach(function(c){if(OVERRIDE_REG.test(c.body))
body='
'+c.body.replace(OVERRIDE_REG,'')+'
'});var match=body.match(SCORE_REG);if(match)
valid.push({user:getAuthorName(a),size:+match[2],language:match[1],link:a.share_link,})});valid.sort(function(a,b){var aB=a.size,bB=b.size;return aB-bB});var languages={};var place=1;var lastSize=null;var lastPlace=1;valid.forEach(function(a){if(a.size!=lastSize)
lastPlace=place;lastSize=a.size;++place;var answer=jQuery("#answer-template").html();answer=answer.replace("{{PLACE}}",lastPlace+".").replace("{{NAME}}",a.user).replace("{{LANGUAGE}}",a.language).replace("{{SIZE}}",a.size).replace("{{LINK}}",a.link);answer=jQuery(answer);jQuery("#answers").append(answer);var lang=a.language;lang=jQuery(''+a.language+'').text().toLowerCase();languages[lang]=languages[lang]||{lang:a.language,user:a.user,size:a.size,link:a.link,uniq:lang}});var langs=[];for(var lang in languages)
if(languages.hasOwnProperty(lang))
langs.push(languages[lang]);langs.sort(function(a,b){if(a.uniq>b.uniq)return 1;if(a.uniq<b.uniq)return-1;return 0});for(var i=0;i<langs.length;++i)
{var language=jQuery("#language-template").html();var lang=langs[i];language=language.replace("{{LANGUAGE}}",lang.lang).replace("{{NAME}}",lang.user).replace("{{SIZE}}",lang.size).replace("{{LINK}}",lang.link);language=jQuery(language);jQuery("#languages").append(language)}}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list{padding:10px;float:left}#language-list{padding:10px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

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

Winners by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

 ```

答:
C++, <s>286</s> <s>284</s> 236 bytes

Now with extra golf!

```<code>#include<iostream>
int main(){char a[]="#include<iostream>%sint main(){char a[]=%s%s%s,b[]=%s%s%s%s,c[]=%s%sn%s,d[]=%s%s%s%s;printf(a,c,b,a,b,b,d,b,b,b,d,b,b,d,d,b);}",b[]="\"",c[]="\n",d[]="\\";printf(a,c,b,a,b,b,d,b,b,b,d,b,b,d,d,b);}
</code>```

I'm currently learning C++, and thought "Hey, I should make a quine in it to see how much I know!" 40 minutes later, I have this, a full <s>64</s> 114 bytes shorter than the current one. I compiled it as:

```<code>g++ quine.cpp
</code>```

Output and running:

```<code>C:\Users\Conor O'Brien\Documents\Programming\cpp
λ g++ quine.cpp & a
#include<iostream>
int main(){char a[]="#include<iostream>%sint main(){char a[]=%s%s%s,b[]=%s%s%s%s,c[]=%s%sn%s,d[]=%s%s%s%s;printf(a,c,b,a,b,b,d,b,b,b,d,b,b,d,d,b);}",b[]="\"",c[]="\n",d[]="\\";printf(a,c,b,a,b,b,d,b,b,b,d,b,b,d,d,b);}
</code>```

Title: Golf you a quine for great good!

Body:
C++, <s>286</s> <s>284</s> 236 bytes

Now with extra golf!

#include<iostream>
int main(){char a[]="#include<iostream>%sint main(){char a[]=%s%s%s,b[]=%s%s%s%s,c[]=%s%sn%s,d[]=%s%s%s%s;printf(a,c,b,a,b,b,d,b,b,b,d,b,b,d,d,b);}",b[]="\"",c[]="\n",d[]="\\";printf(a,c,b,a,b,b,d,b,b,b,d,b,b,d,d,b);}

I'm currently learning C++, and thought "Hey, I should make a quine in it to see how much I know!" 40 minutes later, I have this, a full <s>64</s> 114 bytes shorter than the current one. I compiled it as:

g++ quine.cpp

Output and running:

C:\Users\Conor O'Brien\Documents\Programming\cpp
λ g++ quine.cpp & a
#include<iostream>
int main(){char a[]="#include<iostream>%sint main(){char a[]=%s%s%s,b[]=%s%s%s%s,c[]=%s%sn%s,d[]=%s%s%s%s;printf(a,c,b,a,b,b,d,b,b,b,d,b,b,d,d,b);}",b[]="\"",c[]="\n",d[]="\\";printf(a,c,b,a,b,b,d,b,b,b,d,b,b,d,d,b);}


Title: Draw an asterisk triangle

Body:
Befunge93, 31 chars (3 spaces, 8 pure directionals)

&>:#v_@
-^  : >$55+,1
,"*"<_^#:-1

Befunge98, 28 chars

&>:#v_@
-^  : >$a,1
1,*'<_^#:-


答:
Java, 181

```<code>String v(String[]a){String r="",c=r;for(String s:a){try{int p=s.charAt(1)%5;r=p<1?r+c:p>2?"":p==1?r.length()<2?"":r.split(".$")[0]:r;c=p==2?r:c;}catch(Exception e){r+=s;}}return r;}
</code>```

More readable version:

```<code>String v(String[]a){
    String r="",c=r;
    for(String s:a){
        try{
            int p=s.charAt(1)%5;
            r= p<1
                 ? r+c
                 : p>2
                    ? ""
                    :p==1
                        ? r.length()<2
                                     ?""
                                     :r.split(".$")[0]
                        :r;
            c=p==2?r:c;
        }catch(Exception e){
            r+=s;
        }
    }return r;
}
</code>```

Title: Simulate keystrokes

Body:
Java, 181

String v(String[]a){String r="",c=r;for(String s:a){try{int p=s.charAt(1)%5;r=p<1?r+c:p>2?"":p==1?r.length()<2?"":r.split(".$")[0]:r;c=p==2?r:c;}catch(Exception e){r+=s;}}return r;}

More readable version:

String v(String[]a){
    String r="",c=r;
    for(String s:a){
        try{
            int p=s.charAt(1)%5;
            r= p<1
                 ? r+c
                 : p>2
                    ? ""
                    :p==1
                        ? r.length()<2
                                     ?""
                                     :r.split(".$")[0]
                        :r;
            c=p==2?r:c;
        }catch(Exception e){
            r+=s;
        }
    }return r;
}


答:
Python 3, 64 bytes

Based off DLosc answer to Python 2 as on mine I could not improve.

```<code>print(*["rnbqkbnr","p"*8]+["."*8]*4+["P"*8,"RNBQKBNR"],sep="\n")
</code>```

1 byte less compared to using "\n".join

```<code>print("\n".join(["rnbqkbnr","p"*8]+["."*8]*4+["P"*8,"RNBQKBNR"]))
</code>```

Title: Draw an ASCII chess board!

Body:
Here is a simple challenge for you: You must produce this ASCII representation of a chess board. White is represented by uppercase characters, and black is represented by lowercase. Empty tiles are represented by a .. Here is the full board:

```<code>rnbqkbnr
pppppppp
........
........
........
........
PPPPPPPP
RNBQKBNR
</code>```

Since this is a kolmogorov-complexity question, you may not take any input and you must output this board by any default method, for example, saving a file, printing to STDOUT or returning from a function. You may optionally produce one trailing newline. Standard loopholes apply, and the shortest program in bytes!

However, remember this is equally as much a competition between submissions in the same language. While it's unlikely that a languages like Java could beat a language like perl, or a golfing language like pyth or cjam, having the shortest Java answer is still really impressive! To help you track the shortest answer in each language, you may use this leaderboard, which will show the shortest submission by language and overall.

Leaderboards

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=95745,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:
Python 3, 64 bytes

Based off DLosc answer to Python 2 as on mine I could not improve.

print(*["rnbqkbnr","p"*8]+["."*8]*4+["P"*8,"RNBQKBNR"],sep="\n")

1 byte less compared to using "\n".join

print("\n".join(["rnbqkbnr","p"*8]+["."*8]*4+["P"*8,"RNBQKBNR"]))


答:
MATL, 15 bytes

```<code>:Y@tGY)Z)G:=!Af
</code>```

Input and output are 1-based.

Similar to @MartinEnder's CJam answer, but finds the inverse permutation by composing all possible permutations with that specified by the input, and seeing which has become the identity permutation.

It runs out of memory in the online compiler for input 10.

Try it online!

Explanation

```<code>:      % Implicitly input N. Push range [1 2 ... N]
Y@     % Matrix witll all permutations of size N. Each permutation is a row
tGY)   % Duplicate. Get the N-th row
Z)     % Use that as a column index into the matrix of all permutations
G:=    % Compare each row with [1 2 ... N]
!Af    % Find index of the row that matches. Implicitly display
</code>```

Title: Inverse permutation index

Body:
MATL, 15 bytes

:Y@tGY)Z)G:=!Af

Input and output are 1-based.

Similar to @MartinEnder's CJam answer, but finds the inverse permutation by composing all possible permutations with that specified by the input, and seeing which has become the identity permutation.

It runs out of memory in the online compiler for input 10.

Try it online!

Explanation

:      % Implicitly input N. Push range [1 2 ... N]
Y@     % Matrix witll all permutations of size N. Each permutation is a row
tGY)   % Duplicate. Get the N-th row
Z)     % Use that as a column index into the matrix of all permutations
G:=    % Compare each row with [1 2 ... N]
!Af    % Find index of the row that matches. Implicitly display


答:
Clojure, 59 bytes

```<code>#(doseq[m(range 1(inc %))](println(apply str(repeat m\*))))
</code>```

Basically, just uses doseq to loop over the range, printing the corresponding number of stars.

It's really unfortunate that the shortest way I've been able to repeat a character in Clojure is (apply str (repeat m \*)). That's hardly competitive here. Some good ol' python string multiplication would have been awesome.

Ungolfed:

```<code>(defn tri [n]
  (doseq [m (range 1 (inc n))]
    (println (apply str (repeat m \*)))))
</code>```

Should be fairly self-explanatory.

Title: Draw an asterisk triangle

Body:
Clojure, 59 bytes

#(doseq[m(range 1(inc %))](println(apply str(repeat m\*))))

Basically, just uses doseq to loop over the range, printing the corresponding number of stars.

It's really unfortunate that the shortest way I've been able to repeat a character in Clojure is (apply str (repeat m \*)). That's hardly competitive here. Some good ol' python string multiplication would have been awesome.

Ungolfed:

(defn tri [n]
  (doseq [m (range 1 (inc n))]
    (println (apply str (repeat m \*)))))

Should be fairly self-explanatory.


问:
Visualize sorting
Say I have a list such as [3, 0, 4, 2, 1], and I use selection sort to sort it, I could visualize it like this:

```<code>3,0,4,2,1
|-|
0,3,4,2,1
  |-----|
0,1,4,2,3
    |-|
0,1,2,4,3
      |-|
0,1,2,3,4
</code>```

This challenge is about visualizing sorting like this.

Input

Your input will be a list of positive integers, in any format you like.

Task

Your submission should sort the input list by only swapping two elements at a time, and at each swap, the submission should display the list, and a character under each of the elements being swapped. If a number that was swapped has more than one digit, the character can be anywhere underneath it. At the end, the submission should display the sorted list.

Other rules

The sorting must use fewer swaps than n4, where n is the length of the list.

The sorting doesn't have to be deterministic.

The characters under the swapped can be any char except space.

Title: Visualize sorting

Body:
Haskell, <s>165</s> <s>164</s> 162 bytes

s%c=drop 2$show s>>c
p#x|(h,t:s)<-span(/=minimum x)x=id=<<[show$p++x,"\n ",[' '|p>[]],p%" ","|",h%"-",['|'|h>[]],"\n",(p++[t])#(drop 1h++take 1h++s)]|1<2=""
([]#)

This visualizes selection sort. Usage example:

*Main> putStr $ ([]#) [31,7,0,5,5,5,753,5,99,4,333,5,2,1001,35,1,67]
[31,7,0,5,5,5,753,5,99,4,333,5,2,1001,35,1,67]
 |----|
[0,7,31,5,5,5,753,5,99,4,333,5,2,1001,35,1,67]
   |-------------------------------------|
[0,1,31,5,5,5,753,5,99,4,333,5,2,1001,35,7,67]
     |-------------------------|
[0,1,2,5,5,5,753,5,99,4,333,5,31,1001,35,7,67]
       |--------------|
[0,1,2,4,5,5,753,5,99,5,333,5,31,1001,35,7,67]
         |
[0,1,2,4,5,5,753,5,99,5,333,5,31,1001,35,7,67]
           |
[0,1,2,4,5,5,753,5,99,5,333,5,31,1001,35,7,67]
             |---|
[0,1,2,4,5,5,5,753,99,5,333,5,31,1001,35,7,67]
               |------|
[0,1,2,4,5,5,5,5,99,753,333,5,31,1001,35,7,67]
                 |----------|
[0,1,2,4,5,5,5,5,5,753,333,99,31,1001,35,7,67]
                   |---------------------|
[0,1,2,4,5,5,5,5,5,7,333,99,31,1001,35,753,67]
                     |------|
[0,1,2,4,5,5,5,5,5,7,31,99,333,1001,35,753,67]
                        |-----------|
[0,1,2,4,5,5,5,5,5,7,31,35,333,1001,99,753,67]
                           |---------------|
[0,1,2,4,5,5,5,5,5,7,31,35,67,1001,99,753,333]
                              |----|
[0,1,2,4,5,5,5,5,5,7,31,35,67,99,1001,753,333]
                                 |--------|
[0,1,2,4,5,5,5,5,5,7,31,35,67,99,333,753,1001]
                                     |
[0,1,2,4,5,5,5,5,5,7,31,35,67,99,333,753,1001]
                                         |

How it works:

s % c is a helper function that makes length (show s) - 2 copies of character c. It's used for spacing before both |, one time with c == ' ' and one time with c == '-'.

The main function # takes a list p which is the sorted part of the list and x which is the yet to sort part. The pattern match (h,t:s)<-span(/=minimum x)x splits the list x at its minimum element and binds h to the part before the minimum, t to the minimum itself and s to the part after the minimum. The rest is formatting two lines: 1) the list at its current state (p++x) and 2) the |----| part followed by a recursive call of # with t appended to p and the head of h inserted between the tail of h and s.

PS: works also with negativ and/or floating point numbers:

*Main> putStr $ ([]#) [-3,-1,4e33,-7.3]
[-3.0,-1.0,4.0e33,-7.3]
 |----------------|
[-7.3,-1.0,4.0e33,-3.0]
      |-----------|
[-7.3,-3.0,4.0e33,-1.0]
           |------|
[-7.3,-3.0,-1.0,4.0e33]
                |

Edit: @BlackCap saved 2 bytes. Thanks!