Title: Let's do the Wave!

Body:
Input:

A string (the wave-snippet) with a length >= 2.

A positive integer n >= 1.

Output:

We output a single-line wave. We do this by repeating the input string n times.

Challenge rules:

If the first and last character of the input string matches, we only output it once in the total output (i.e. ^_^ of length 2 becomes ^_^_^ and not ^_^^_^).

The input string won't contain any whitespaces/tabs/new-lines/etc.

If your language doesn't support non-ASCII characters, then that's fine. As long as it still complies to the challenge with ASCII-only wave-input.

General rules:

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

Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.

Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters, full programs. Your call.

Default Loopholes are forbidden.

If possible, please add a link with a test for your code.

Also, please add an explanation if necessary.

Test cases:

```<code>_.~"(              length 12
_.~"(_.~"(_.~"(_.~"(_.~"(_.~"(_.~"(_.~"(_.~"(_.~"(_.~"(_.~"(

'°º¤o,¸¸,o¤º°'     length 3
'°º¤o,¸¸,o¤º°'°º¤o,¸¸,o¤º°'°º¤o,¸¸,o¤º°'

-__                length 1
-__

-__                length 8
-__-__-__-__-__-__-__-__

-__-               length 8
-__-__-__-__-__-__-__-__-

¯`·.¸¸.·´¯         length 24
¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯

**                 length 6
*******

String & length of your own choice (be creative!)
</code>```

Body:
Common Lisp (LispWorks), 176 bytes

(defun f(s pos)(if(equal(elt s 0)(elt s #1=(1-(length s))))(let((s1(subseq s 0 1))(s2(subseq s 0 #1#)))(dotimes(j pos)(format t s2))(format t s1))(dotimes(j pos)(format t s))))

Usage:

    CL-USER 130 > (f "_.~~\"(" 12)
    _.~"(_.~"(_.~"(_.~"(_.~"(_.~"(_.~"(_.~"(_.~"(_.~"(_.~"(_.~"(
    NIL

    CL-USER 131 > (f "'°o¤o,??,o¤o°'" 3)
    '°o¤o,??,o¤o°'°o¤o,??,o¤o°'°o¤o,??,o¤o°'
    NIL

    CL-USER 132 > (f "-__" 1)
    -__
    NIL

    CL-USER 133 > (f "-__" 8)
    -__-__-__-__-__-__-__-__
    NIL

    CL-USER 134 > (f "ˉ`·.??.·′ˉ" 24)
    ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ`·.??.·′ˉ
    NIL

    CL-USER 135 > (f "**" 6)
    *******
    NIL

Explanation:

~~ =>   ~

\" =>   "

Ungolf:

    (defun f (s pos)
      (if (equal (elt s 0) (elt s (1- (length s))))
          (let ((s1 (subseq s 0 1)) (s2 (subseq s 0 (1- (length s)))))
            (dotimes (j pos)
              (format t s2))
            (format t s1))
        (dotimes (i pos)
          (format t s))))


问:
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

```

答:
Haskell, 53 bytes

```<code>a="rnbkqbnr"
unlines$a:map(<$a)"p....P"++["RNBKQBNR"]
</code>```

a is used as the first line and to determine the length of strings made of p, . and P (-> <$a). .

ContentLicense: CC BY-SA 3.0

Title: Draw an ASCII chess board!

Body:
Haskell, 53 bytes

a="rnbkqbnr"
unlines$a:map(<$a)"p....P"++["RNBKQBNR"]

a is used as the first line and to determine the length of strings made of p, . and P (-> <$a). .


答:
Python 2, 63 bytes

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

Unfortunately, the fairly simple approach was much shorter than the "clever" stuff I tried at first...

Bonus answer, also 63 bytes:

```<code>print"\n".join(["rnbqkbnr"]+[c*8for c in"p....P"]+["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 2, 63 bytes

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

Unfortunately, the fairly simple approach was much shorter than the "clever" stuff I tried at first...

Bonus answer, also 63 bytes:

print"\n".join(["rnbqkbnr"]+[c*8for c in"p....P"]+["RNBQKBNR"])


答:
Python 2, 68 bytes

Posting anyway although the above Python 2 version is shorter.
It would not have to be a one liner for the amount of bytes, just played with it.

```<code>x,y,z="rnbqkbnr\n","p"*8+"\n","."*8+"\n";print x,y,4*z,(y+x).upper()
</code>```

Title: Draw an ASCII chess board!

Body:
Python 2, 68 bytes

Posting anyway although the above Python 2 version is shorter.
It would not have to be a one liner for the amount of bytes, just played with it.

x,y,z="rnbqkbnr\n","p"*8+"\n","."*8+"\n";print x,y,4*z,(y+x).upper()


答:
C#, 94 92 bytes

Edit: Thanks to milk for saving 1 byte by changing string order to remove the return whitespace.

Edit: Saved 1 more byte by adding a dummy parameter (x instead of ()) for the anonymous function and calling it with any object.

```<code>x=>{string a="RNBQKBNR\n",b="PPPPPPPP\n",c="........\n";return(a+b).ToLower()+c+c+c+c+b+a;};
</code>```

Full program using the above function:

```<code>using System;

namespace DrawAnASCIIChessBoard
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<object,string>f= x=>{string a="RNBQKBNR\n",b="PPPPPPPP\n",c="........\n";return(a+b).ToLower()+c+c+c+c+b+a;};
            Console.WriteLine(f(1));
        }
    }
}
</code>```

C# is a very verbose language...

C# full program, 131 bytes

```<code>class P{static void Main(){string a="rnbqkbnr\n",b="pppppppp\n",c="........\n";System.Console.Write(a+b+c+c+c+c+(b+a).ToUpper());}}
</code>```

Ungolfed:

```<code>class P
{
    static void Main()
    {
        string a="rnbqkbnr\n",
            b="pppppppp\n",
            c="........\n";
        System.Console.Write(a+b+c+c+c+c+(b+a).ToUpper());
    }
}
</code>```

Title: Draw an ASCII chess board!

Body:
C#, 94 92 bytes

Edit: Thanks to milk for saving 1 byte by changing string order to remove the return whitespace.

Edit: Saved 1 more byte by adding a dummy parameter (x instead of ()) for the anonymous function and calling it with any object.

x=>{string a="RNBQKBNR\n",b="PPPPPPPP\n",c="........\n";return(a+b).ToLower()+c+c+c+c+b+a;};

Full program using the above function:

using System;

namespace DrawAnASCIIChessBoard
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<object,string>f= x=>{string a="RNBQKBNR\n",b="PPPPPPPP\n",c="........\n";return(a+b).ToLower()+c+c+c+c+b+a;};
            Console.WriteLine(f(1));
        }
    }
}

C# is a very verbose language...

C# full program, 131 bytes

class P{static void Main(){string a="rnbqkbnr\n",b="pppppppp\n",c="........\n";System.Console.Write(a+b+c+c+c+c+(b+a).ToUpper());}}

Ungolfed:

class P
{
    static void Main()
    {
        string a="rnbqkbnr\n",
            b="pppppppp\n",
            c="........\n";
        System.Console.Write(a+b+c+c+c+c+(b+a).ToUpper());
    }
}


答:
Pyke, <s>28</s> <s>27</s> 26 bytes

```<code>"rnbqkbnr"i"P..p"1c8m*Xil3
</code>```

Try it here!

I learned something new about my language today: 1c can be used as a 2 char way of splitting a string into a list of characters.

```<code>"rnbqkbnr"i                - i = "rnbqkbnr"
                             stack = ["rnbqkbnr"])
           "P..p"1c        -  chunk("P..p", 1)
                             stack = ["rnbqkbnr", ["P", ".", ".", "p"]]
                   8m*     - map(8*>, ^)
                             stack = ["rnbqkbnr", ["PPPPPPPP", "........", "........", "pppppppp"]]
                      X    - splat(^)
                             stack = ["rnbqkbnr", "pppppppp", "........", "........", "PPPPPPPP"]
                       il3 - i.changecase()
                             stack = ["rnbqkbnr", "pppppppp", "........", "........", "PPPPPPPP", "RNBQKBNR"]
                           - implicit join with newlines

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

Title: Draw an ASCII chess board!

Body:
Pyke, <s>28</s> <s>27</s> 26 bytes

"rnbqkbnr"i"P..p"1c8m*Xil3

Try it here!

I learned something new about my language today: 1c can be used as a 2 char way of splitting a string into a list of characters.

"rnbqkbnr"i                - i = "rnbqkbnr"
                             stack = ["rnbqkbnr"])
           "P..p"1c        -  chunk("P..p", 1)
                             stack = ["rnbqkbnr", ["P", ".", ".", "p"]]
                   8m*     - map(8*>, ^)
                             stack = ["rnbqkbnr", ["PPPPPPPP", "........", "........", "pppppppp"]]
                      X    - splat(^)
                             stack = ["rnbqkbnr", "pppppppp", "........", "........", "PPPPPPPP"]
                       il3 - i.changecase()
                             stack = ["rnbqkbnr", "pppppppp", "........", "........", "PPPPPPPP", "RNBQKBNR"]
                           - implicit join with newlines

rnbqkbnr
pppppppp
........
........
PPPPPPPP
RNBQKBNR


问:
A sign showing grouped opening hours of a cafe
You have probably seen these signs on the doors of various shops:

OPENING HOURS

mon-fri 0900-1800

  sat-sun 1100-1530

The task here is to generate a sign like that, grouping consecutive days with the same opening hours, from a list of opening hours for the whole week. Note that the week "wraps around" for what is considered consecutive.

Input:

7 elements, representing the opening hours for each day in a week, starting with Monday.

Each element is a string, on the form XXXX-XXXX

Example input:

```<code>0900-1800 0900-1800 0930-1730 0930-1730 0900-1500 1100-1500 1100-1500
</code>```

It's ok to send the input as an array (for instance as input to a function if you don't read from stdin)

Output:

A list of opening hours, where consecutive days with the same opening hours are shown as a range. Note that sunday (the last day) and monday (the first day) also are consecutive days.

A day where the day doesn't have similar opening hours to the days before or after is printed by itself

Days are specified as three lowercase letters: mon tue wed thu fri sat sun

Remember that first element in the input corresponds to mon, next to tue etc.

Opening hours are shown as in the input

Two examples

```<code>mon-fri 0900-1800, sat-sun 1100-1500
mon-wed 1030-1530, thu 100-1800, fri-sun 1200-1630
</code>```

The output should be sorted, so ranges appear in the order the days do in the week. Monday is preferred to be first, but it may happen it is not first in a group because the week wraps. So in this case tue is the first range.

```<code>tue-fri 0900-1800, sat-mon 1100-1500
</code>```

Don't group unless consecutive, here wednesday and friday have same opening hours but are separated by a Thursday with different opening hours so they are listed by themselves.

```<code>mon-tue 1000-1200, wed 0900-1500, thu 1000-1800, fri 0900-1500, sat-sun 1000-1500
</code>```

The output can be either comma-separated as the examples here, or separated by a newline as in the example on top.

Test cases

First line is input, second line is expected output

```<code>0900-1800 0900-1800 0900-1800 0900-1800 0900-1800 1100-1500 1100-1500
mon-fri 0900-1800, sat-sun 1100-1500

0900-1800 0900-1800 0900-1800 0930-1700 0900-1800 1100-1500 1100-1500
mon-wed 0900-1800, thu 0930-1700, fri 0900-1800, sat-sun 1100-1500

1100-1500 0900-1800 0900-1800 0900-1800 0900-1800 1100-1500 1100-1500
tue-fri 0900-1800, sat-mon 1100-1500

1100-1500 1100-1500 0900-1800 0900-1800 0900-1800 0900-1800 1100-1500
wed-sat 0900-1800, sun-tue 1100-1500

1200-1500 1100-1500 0900-1800 0900-1800 0900-1800 0900-1800 1100-1500
mon 1200-1500, tue 1100-1500, wed-sat 0900-1800, sun 1100-1500
</code>```

Rules

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

答:
Jelly, <s>87 84 80</s> 75 bytes

4bytes with the kind help of @Dennis (fixed a hack I used with the ' quick, "flat")

Pretty sure there is a better way but for now:

```<code>Ṫ2ị$€;@µ+\µżṙ1’$Ṗị“ḅạṄMḤ9\E¥LḃɓṅÐĿ;$»s3¤Q€j€”-
ṙ7Ḷ¤Œr'€Ėµ2ịLµÐṂḢ
ÇṪḢ€ż@ÇÑ$G
</code>```

TryiItOnline

How?

```<code>            “ḅạṄMḤ9\E¥LḃɓṅÐĿ;$» - compressed string "montuewedthufrisatsun"
                  v  v
Ṫ2ị$€;@µ+\µżṙ1’$Ṗị -- s3¤Q€j€”- - Link 1, getDayStrings: [offset, groupedList]
Ṫ                               - Tail: get groupedList
 2ị$€                           - second index of each: get group sizes, e.g. mon-thu is 4
     ;@                         - concatenate (reversed arguments): prepend with offset
       µ                        - monadic chain separation
        +\                      - cumulative reduce with addition: start indexes
          µ                     - monadic chain separation
           ż                    - zip with
               $                - last two links as a monad
            ṙ1                  -     rotated left by one
              ’                 -     decrement:  end indexes
                Ṗ               - pop: remove last one, it's circular
                 ị              - index into
                        ¤       - last two links as a nilad
                    --          -     compressed string of weekdays (as shown at the top)
                      s3        -     split into 3s
                        Q€      - unique items for each: [tue,tue] -> [tue]
                          j€    - join each with
                            ”-  - literal string "-"

ṙ7Ḷ¤Œr'€Ėµ2ịLµÐṂḢ - Link 2: CalculateGroupingData: list of time strings
   ¤              - last two links as a nilad
ṙ                 -    rotate time strings list left by
 7Ḷ               -    range 7: [0,1,2,3,4,5,6]
       €          - for each
    Œr            -     run length encode
      '           -     flat - i.e. don't vectorise
        Ė         - enumerate [[1,[groupsFromMon]],[2,[groupsFromTue], ...]
         µ        - monadic chain separation
              ÐṂ  - filter for minimum of
             L    -     length of
          2ị      -     item at index 2: The number of groupings
                Ḣ - head: get the first occurring minimal (i.e Mon, or Tue, ...)

ÇṪḢ€ż@ÇÑ$G - Main link: list of time strings
Ç          - call last link (1) as a monad: get the offset and grouping
 Ṫ         - tail: get the grouping
  Ḣ€       - head each: get the time information
        $  - last two links as a monad
      Ç    -      call last link (1) as a monad: get the offset and grouping
       Ñ   -      call the next link as a monad: get the day strings
    ż@     - zip (with reversed arguments)
         G - arrange as a group (performs a tabulation to nicely align the result)

</code>```

Body:
Jelly, <s>87 84 80</s> 75 bytes

4bytes with the kind help of @Dennis (fixed a hack I used with the ' quick, "flat")

Pretty sure there is a better way but for now:

Ṫ2ị$€;@µ+\µżṙ1’$Ṗị“ḅạṄMḤ9\E¥LḃɓṅÐĿ;$»s3¤Q€j€”-
ṙ7Ḷ¤Œr'€Ėµ2ịLµÐṂḢ
ÇṪḢ€ż@ÇÑ$G

TryiItOnline

How?

            “ḅạṄMḤ9\E¥LḃɓṅÐĿ;$» - compressed string "montuewedthufrisatsun"
                  v  v
Ṫ2ị$€;@µ+\µżṙ1’$Ṗị -- s3¤Q€j€”- - Link 1, getDayStrings: [offset, groupedList]
Ṫ                               - Tail: get groupedList
 2ị$€                           - second index of each: get group sizes, e.g. mon-thu is 4
     ;@                         - concatenate (reversed arguments): prepend with offset
       µ                        - monadic chain separation
        +\                      - cumulative reduce with addition: start indexes
          µ                     - monadic chain separation
           ż                    - zip with
               $                - last two links as a monad
            ṙ1                  -     rotated left by one
              ’                 -     decrement:  end indexes
                Ṗ               - pop: remove last one, it's circular
                 ị              - index into
                        ¤       - last two links as a nilad
                    --          -     compressed string of weekdays (as shown at the top)
                      s3        -     split into 3s
                        Q€      - unique items for each: [tue,tue] -> [tue]
                          j€    - join each with
                            ”-  - literal string "-"

ṙ7Ḷ¤Œr'€Ėµ2ịLµÐṂḢ - Link 2: CalculateGroupingData: list of time strings
   ¤              - last two links as a nilad
ṙ                 -    rotate time strings list left by
 7Ḷ               -    range 7: [0,1,2,3,4,5,6]
       €          - for each
    Œr            -     run length encode
      '           -     flat - i.e. don't vectorise
        Ė         - enumerate [[1,[groupsFromMon]],[2,[groupsFromTue], ...]
         µ        - monadic chain separation
              ÐṂ  - filter for minimum of
             L    -     length of
          2ị      -     item at index 2: The number of groupings
                Ḣ - head: get the first occurring minimal (i.e Mon, or Tue, ...)

ÇṪḢ€ż@ÇÑ$G - Main link: list of time strings
Ç          - call last link (1) as a monad: get the offset and grouping
 Ṫ         - tail: get the grouping
  Ḣ€       - head each: get the time information
        $  - last two links as a monad
      Ç    -      call last link (1) as a monad: get the offset and grouping
       Ñ   -      call the next link as a monad: get the day strings
    ż@     - zip (with reversed arguments)
         G - arrange as a group (performs a tabulation to nicely align the result)


答:
JavaScript (ES6), 73

.toUpperCase is simply too long

_=>`rnbqkbnr
${r=c=>c[0].repeat(8)+`
`,r`p`+(b=r`.`)+b+b+b+r`P`}RNBQKBNR`
```
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>O.textContent=(

_=>`rnbqkbnr
${r=c=>c[0].repeat(8)+`
`,r`p`+(b=r`.`)+b+b+b+r`P`}RNBQKBNR`

)()</code>```

```</code>```

Title: Draw an ASCII chess board!

Body:
JavaScript (ES6), 73

.toUpperCase is simply too long

_=>`rnbqkbnr
${r=c=>c[0].repeat(8)+`
`,r`p`+(b=r`.`)+b+b+b+r`P`}RNBQKBNR`

O.textContent=(

_=>`rnbqkbnr
${r=c=>c[0].repeat(8)+`
`,r`p`+(b=r`.`)+b+b+b+r`P`}RNBQKBNR`

)()

<pre id=O></pre>


答:
Mathematica, <s>76</s> 72 bytes

```<code>{"rnbqkbnr
","p"~(t=Table)~8,"
",t["."~t~8<>"
",4],"P"~t~8}<>"
RNBQKBNR"
</code>```

Table is used to generate lists of strings. When lists of strings meet the concatenation operator <>, they get flattened into strings automatically, so the construction { ... , ... , ... }<>... is preferred over using <> throughout when there are sufficiently many strings to be concatenated.

Also 72 bytes:

```<code>{"rnbqkbnr
","p"~(t=Table)~8,"
",{"."~t~8,"
"}~t~4,"P"~t~8}<>"
RNBQKBNR"
</code>```

In comparison, the direct string itself is 73 bytes:

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

Title: Draw an ASCII chess board!

Body:
Mathematica, <s>76</s> 72 bytes

{"rnbqkbnr
","p"~(t=Table)~8,"
",t["."~t~8<>"
",4],"P"~t~8}<>"
RNBQKBNR"

Table is used to generate lists of strings. When lists of strings meet the concatenation operator <>, they get flattened into strings automatically, so the construction { ... , ... , ... }<>... is preferred over using <> throughout when there are sufficiently many strings to be concatenated.

Also 72 bytes:

{"rnbqkbnr
","p"~(t=Table)~8,"
",{"."~t~8,"
"}~t~4,"P"~t~8}<>"
RNBQKBNR"

In comparison, the direct string itself is 73 bytes:

"rnbqkbnr
pppppppp
........
........
........
........
PPPPPPPP
RNBQKBNR"


答:
R, 75 bytes

Edit: Fixed a silly error and simply write out the uppercase part of the board now.

```<code>cat("rnbqkbnr\npppppppp\n",rep("........\n",4),"PPPPPPPP\nRNBQKBNR",sep="")
</code>```

Title: Draw an ASCII chess board!

Body:
R, 75 bytes

Edit: Fixed a silly error and simply write out the uppercase part of the board now.

cat("rnbqkbnr\npppppppp\n",rep("........\n",4),"PPPPPPPP\nRNBQKBNR",sep="")


答:
IBM/Lotus Notes Formula, 69 bytes

```<code>A:="rnbqkbnr";B:="pppppppp";C:="........";A:B:C:C:C:C:@Uppercase(B:A)
</code>```

Formula in a multi-value field with newline as the seperator.

Output:

Title: Draw an ASCII chess board!

Body:
IBM/Lotus Notes Formula, 69 bytes

A:="rnbqkbnr";B:="pppppppp";C:="........";A:B:C:C:C:C:@Uppercase(B:A)

Formula in a multi-value field with newline as the seperator.

Output:


Title: Draw an ASCII chess board!

Body:
Powershell, <s>82</s> 73 bytes

$x=("rnbqkbnr",$("p"*8),$("."*8),$("."*8));$x+$x[3..0].ToUpper()-join"`n"


答:
Dart, 62 bytes

f()=>"rnbqkbnr\n${"p"*8}\n${"........\n"*4+"P"*8}\nRNBQKBNR";
```
<p>I am annoyed that I can't reduce the <code>"........\n"*4</code> part further, but due to the newline being included in the multiplication, all rewrites come out at the same length as the original:</p>
<pre class="lang-dart prettyprint-override"><code>"${"."*8}\n"*4
("."*8+"\n")*4
"........\n"*4
</code>```

Dart's string functions, like toUpperCase(), have too long names to use them in golfing.

Title: Draw an ASCII chess board!

Body:
Dart, 62 bytes

f()=>"rnbqkbnr\n${"p"*8}\n${"........\n"*4+"P"*8}\nRNBQKBNR";

I am annoyed that I can't reduce the "........\n"*4 part further, but due to the newline being included in the multiplication, all rewrites come out at the same length as the original:

"${"."*8}\n"*4
("."*8+"\n")*4
"........\n"*4

Dart's string functions, like toUpperCase(), have too long names to use them in golfing.


答:
MATL, 26 bytes

```<code>'rnbqkbnr' 'p..'!l8X"vtPXk
</code>```

Try it online!

Explanation

```<code>'rnbqkbnr'   % Push this string (1×8 char array)
'p..'!       % Push this string transposed (3×1 char array)
l8X"         % Repeat 1×8 times: gives 3×8 char array
v            % Concatenate the two arrays vertically into a 4×8 char array
tP           % Duplicate and flip vertically
Xk           % Convert to uppercase. Implicitly display the two 4×8 arrays
</code>```

Title: Draw an ASCII chess board!

Body:
MATL, 26 bytes

'rnbqkbnr' 'p..'!l8X"vtPXk

Try it online!

Explanation

'rnbqkbnr'   % Push this string (1×8 char array)
'p..'!       % Push this string transposed (3×1 char array)
l8X"         % Repeat 1×8 times: gives 3×8 char array
v            % Concatenate the two arrays vertically into a 4×8 char array
tP           % Duplicate and flip vertically
Xk           % Convert to uppercase. Implicitly display the two 4×8 arrays


答:
Batch, 105 bytes

```<code>@set e=@echo ........
@echo rnbqkbnr
@echo pppppppp
%e%
%e%
%e%
%e%
@echo PPPPPPPP
@echo RNBQKBNR
</code>```

Batch is seriously verbose...

Title: Draw an ASCII chess board!

Body:
Batch, 105 bytes

@set e=@echo ........
@echo rnbqkbnr
@echo pppppppp
%e%
%e%
%e%
%e%
@echo PPPPPPPP
@echo RNBQKBNR

Batch is seriously verbose...


问:
Sum the unique numbers in a list
For this challenge, the objective is to take a list of integers, and output the sum of every unique integer in that list, i.e. count multiples of the same integer only once.

Your input will be a string in the format "{1,2,3,4}" with any amount of elements. The string will never have whitespace or be in a format that does not match the example above. A list with 0 elements should return 0.

Examples

```<code>"{1,2,3,4}" -> 10
"{5,2,5}" -> 7
"{13,13,13}" -> 13
"{-5,5,5}" -> 0
"{12,12,13,13,14,14}" -> 39
"{}" -> 0
"{3}" -> 3
</code>```

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

Good luck!

答:
Bash + coreutils, 38 bytes

bc<<<0$(tr ,}{ \\n|sort -u|paste -sd+)
```

<p><strong>Try it on ideone.com!</strong></p>

<p><strong>Explanation:</strong> using <code>{1,2,1,4}</code> as test case</p>

<pre class="lang-sh prettyprint-override"><code>        tr ,}{ \\n       # replace commas and braces with newlines (\n1\n2\n1\n4\n)
        |sort -u         # sort and print unique lines (\n1\n2\n4)
        |paste -sd+      # merge lines with '+' as delimiter (+1+2+4)
bc<<<0$(           )     # prepend '0' and calculate sum (7)
</code>```

Note how prepending a '0' will also help to give a correct answer when the input list is empty ({}).

Run examples:

me@LCARS:/PPCG$ ./sum_unique.sh <<< "{}"
0
me@LCARS:/PPCG$ ./sum_unique.sh <<< "{3}"
3
me@LCARS:/PPCG$ ./sum_unique.sh <<< "{-5,5,5}"
0
me@LCARS:/PPCG$ ./sum_unique.sh <<< "{12,12,13,13,14,14}"
39
```

Title: Sum the unique numbers in a list

Body:
Bash + coreutils, 38 bytes

bc<<<0$(tr ,}{ \\n|sort -u|paste -sd+)

Try it on ideone.com!

Explanation: using {1,2,1,4} as test case

        tr ,}{ \\n       # replace commas and braces with newlines (\n1\n2\n1\n4\n)
        |sort -u         # sort and print unique lines (\n1\n2\n4)
        |paste -sd+      # merge lines with '+' as delimiter (+1+2+4)
bc<<<0$(           )     # prepend '0' and calculate sum (7)

Note how prepending a '0' will also help to give a correct answer when the input list is empty ({}).

Run examples:

me@LCARS:/PPCG$ ./sum_unique.sh <<< "{}"
0
me@LCARS:/PPCG$ ./sum_unique.sh <<< "{3}"
3
me@LCARS:/PPCG$ ./sum_unique.sh <<< "{-5,5,5}"
0
me@LCARS:/PPCG$ ./sum_unique.sh <<< "{12,12,13,13,14,14}"
39


问:
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!

答:
PHP, 108 bytes

```<code>for(;null!==$s=$argv[++$i];)($g=$s[1])!=B?$g!=C?$g!=D?$o.=$g!=P?$s:$c:$o='':$c=$o:$o=substr($o,0,-1);echo$o;
</code>```

Uses a string based approach rather than an array based one.

Use like:

```<code>php -r "for(;null!==$s=$argv[++$i];)($g=$s[1])!=B?$g!=C?$g!=D?$o.=$g!=P?$s:$c:$o='':$c=$o:$o=substr($o,0,-1);echo$o;" a b "[C]" "[B]" "[P]" "[C]" "[D]" j "[P]"
</code>```

edit: saved 8 bytes by fiddling the order of the ?:s and making them negative to avoid having to use so many brackets;

Title: Simulate keystrokes

Body:
PHP, 108 bytes

for(;null!==$s=$argv[++$i];)($g=$s[1])!=B?$g!=C?$g!=D?$o.=$g!=P?$s:$c:$o='':$c=$o:$o=substr($o,0,-1);echo$o;

Uses a string based approach rather than an array based one.

Use like:

php -r "for(;null!==$s=$argv[++$i];)($g=$s[1])!=B?$g!=C?$g!=D?$o.=$g!=P?$s:$c:$o='':$c=$o:$o=substr($o,0,-1);echo$o;" a b "[C]" "[B]" "[P]" "[C]" "[D]" j "[P]"

edit: saved 8 bytes by fiddling the order of the ?:s and making them negative to avoid having to use so many brackets;


答:
05AB1E, 24 bytes

Uses CP-1252 encoding.

```<code>"rnbqkbnr"'p8×'.8×D)Âu«»
</code>```

Try it online!

Explanation

```<code>"rnbqkbnr"                # push the string "rnbqkbnr"
                          # STACK: "rnbqkbnr"
          'p8×            # push the char "p" repeated 8 times
                          # STACK: "rnbqkbnr", "pppppppp"
              '.8×        # push the char "." repeated 8 times
                          # STACK: "rnbqkbnr", "pppppppp", "........"
                  D       # duplicate
                          # STACK: "rnbqkbnr", "pppppppp", "........", "........"
                   )      # wrap in list
                          # STACK: ["rnbqkbnr", "pppppppp", "........", "........"]
                    Â     # push a reversed copy of the list
                          # STACK: ["rnbqkbnr", "pppppppp", "........", "........"],
                                   ["........", "........", "pppppppp", "rnbqkbnr"]
                     u«   # convert to upper-case and concatenate
                          # STACK: ['rnbqkbnr', 'pppppppp', '........', '........',
                                    '........', '........', 'PPPPPPPP', 'RNBQKBNR']
                       »  # join list by newline
</code>```

Title: Draw an ASCII chess board!

Body:
05AB1E, 24 bytes

Uses CP-1252 encoding.

"rnbqkbnr"'p8×'.8×D)Âu«»

Try it online!

Explanation

"rnbqkbnr"                # push the string "rnbqkbnr"
                          # STACK: "rnbqkbnr"
          'p8×            # push the char "p" repeated 8 times
                          # STACK: "rnbqkbnr", "pppppppp"
              '.8×        # push the char "." repeated 8 times
                          # STACK: "rnbqkbnr", "pppppppp", "........"
                  D       # duplicate
                          # STACK: "rnbqkbnr", "pppppppp", "........", "........"
                   )      # wrap in list
                          # STACK: ["rnbqkbnr", "pppppppp", "........", "........"]
                    Â     # push a reversed copy of the list
                          # STACK: ["rnbqkbnr", "pppppppp", "........", "........"],
                                   ["........", "........", "pppppppp", "rnbqkbnr"]
                     u«   # convert to upper-case and concatenate
                          # STACK: ['rnbqkbnr', 'pppppppp', '........', '........',
                                    '........', '........', 'PPPPPPPP', 'RNBQKBNR']
                       »  # join list by newline


答:
Haskell, <s>136 133 130</s> 127 bytes

k c b(('[':m:_):i)|m<'C'=k c[q|b>"",q<-init b]i|m<'D'=k b b i|m<'P'=k c""i|1<3=k c(b++c)i
k c b(s:i)=k c(b++s)i
k c b[]=b
k""""
```
<p>Try it on Ideone.</p>
<p><strong>Explanation:</strong> <code>k</code> performs a tail recursion over a list of commands. <code>b</code> is the buffer in which the string is constructed, <code>c</code> saves the copied part.</p>
<pre class="lang-haskell prettyprint-override"><code>k c b ("[B]":i) = k c (take(length b - 1)b) i -- remove last element of buffer
k c b ("[C]":i) = k b b i                     -- set copy to buffer
k c b ("[D]":i) = k c "" i                    -- clear the buffer
k c b ("[P]":i) = k c (b++c) i                -- append content of copy to the buffer
k c b (s:i)     = k c (b++s) i                -- append char to the buffer
k c b []        = b                           -- command list is empty, return buffer
f = k "" ""                                   -- initialise copy and buffer with empty strings
</code>```

Edit: To save some bytes the commands[B][C][D][P]are no longer matched exactly but compared: less than 'C'? -> B and so on.
Thanks to @nimi for saving 3 bytes.

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:
Haskell, <s>136 133 130</s> 127 bytes

k c b(('[':m:_):i)|m<'C'=k c[q|b>"",q<-init b]i|m<'D'=k b b i|m<'P'=k c""i|1<3=k c(b++c)i
k c b(s:i)=k c(b++s)i
k c b[]=b
k""""

Try it on Ideone.

Explanation: k performs a tail recursion over a list of commands. b is the buffer in which the string is constructed, c saves the copied part.

k c b ("[B]":i) = k c (take(length b - 1)b) i -- remove last element of buffer
k c b ("[C]":i) = k b b i                     -- set copy to buffer
k c b ("[D]":i) = k c "" i                    -- clear the buffer
k c b ("[P]":i) = k c (b++c) i                -- append content of copy to the buffer
k c b (s:i)     = k c (b++s) i                -- append char to the buffer
k c b []        = b                           -- command list is empty, return buffer
f = k "" ""                                   -- initialise copy and buffer with empty strings

Edit: To save some bytes the commands[B][C][D][P]are no longer matched exactly but compared: less than 'C'? -> B and so on.
Thanks to @nimi for saving 3 bytes.


答:
JavaScript (ES6), <s>69</s> 65 bytes

Saved 4 bytes thanks to edc65

let f =

_=>`rnbqkbnr
p....PRNBQKBNR`.replace(/p|\./ig,c=>c.repeat(8)+`
`)

console.log(f());```

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

```


答:
PHP, <s>67</s> <s>64</s> <s>63</s> 62 bytes

Note: uses IBM-850 encoding.

```<code><?=~str_pad(ìæØÄöØæì§ÅÅÅÅÅÅÅÅ,54,§ÐÐÐÐÐÐÐÐ)?>PPPPPPPP
RNBQKBNR
</code>```

Run like this:

```<code>echo '<?=~str_pad(ìæØÄöØæì§ÅÅÅÅÅÅÅÅ,54,§ÐÐÐÐÐÐÐÐ)?>PPPPPPPP
RNBQKBNR' | php 2>/dev/null;echo
</code>```

And in "unencoded" form:

```<code>echo '<?=str_pad("rnbqkbnr\npppppppp",54,"\n........"),"PPPPPPPP\nRNBQKBNR";' | php 2>/dev/null;echo
</code>```

Explanation

Unfortunately I couldn't find a more interesting approach (that actually saves bytes) than to just print the string, except for the 4 middle lines which are repeated using <s>str_repeat</s> str_pad.

Tweaks

Saved 3 bytes by replacing str_repeat with str_pad.

Saved a byte by using closing tag, thx to user59178.

Saved a byte by changing the pad string to start with a newline, so last newline can be dropped from the first argument of str_pad

Title: Draw an ASCII chess board!

Body:
PHP, <s>67</s> <s>64</s> <s>63</s> 62 bytes

Note: uses IBM-850 encoding.

<?=~str_pad(ìæØÄöØæì§ÅÅÅÅÅÅÅÅ,54,§ÐÐÐÐÐÐÐÐ)?>PPPPPPPP
RNBQKBNR

Run like this:

echo '<?=~str_pad(ìæØÄöØæì§ÅÅÅÅÅÅÅÅ,54,§ÐÐÐÐÐÐÐÐ)?>PPPPPPPP
RNBQKBNR' | php 2>/dev/null;echo

And in "unencoded" form:

echo '<?=str_pad("rnbqkbnr\npppppppp",54,"\n........"),"PPPPPPPP\nRNBQKBNR";' | php 2>/dev/null;echo

Explanation

Unfortunately I couldn't find a more interesting approach (that actually saves bytes) than to just print the string, except for the 4 middle lines which are repeated using <s>str_repeat</s> str_pad.

Tweaks

Saved 3 bytes by replacing str_repeat with str_pad.

Saved a byte by using closing tag, thx to user59178.

Saved a byte by changing the pad string to start with a newline, so last newline can be dropped from the first argument of str_pad


答:
///, 52 bytes

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

Try it online!

Title: Draw an ASCII chess board!

Body:
///, 52 bytes

/:/........
/rnbqkbnr
pppppppp
::::PPPPPPPP
RNBQKBNR

Try it online!


答:
Vim, 50 strokes

```<code>qairnbqkbnr<enter><esc>8ip<esc><enter><esc>q3@a3ggqaVr.gqj@aj@aj@ajgU$jgU$
</code>```

Golfed out 8 bits thanks to @DJMcMayhem

Title: Draw an ASCII chess board!

Body:
Vim, 50 strokes

qairnbqkbnr<enter><esc>8ip<esc><enter><esc>q3@a3ggqaVr.gqj@aj@aj@ajgU$jgU$

Golfed out 8 bits thanks to @DJMcMayhem


问:
The shifting dot
Your program has to print out a number of spaces, followed by a dot and a newline.
The number of spaces is the x position of your dot defined with 0 < x < 30

Every new line is a turn. Your program runs for 30 turns. Your program starts with a random x position and every turn shifts this position randomly by 1 to the left or right, while staying inside the defined area. Every turn your dot has to change its position by 1.

Your score is the number of characters. You get 10 bonus points, if every printed line consists of exactly 30 characters (and newline). You get 50 bonus points, if, while random, your program tends to stay in the middle of the defined area.

Edit:
The 50 bonus points are intended to pull your dot to the middle. For example, this apply's if your dot is at x=20 and has a chance of 66% to go left and 33% to go right. This has to be independent from starting point and should only happen by altering the percentage value of left/right dynamically.

No input of any kind allowed, output has to be on the executing console!

For better understanding, here is a readable example in java, that would give you a score of 723:

public class DotJumper{
    public static void main(String[] args){
        int i = (int)(Math.random()*30);
        int max = 29;
        int step = 1;
        int count = 30;
        while(count>0){
            if(i<=1){
                i+=step;
            }else if(i>=max){
                i-=step;
            }else{
                if(Math.random() > 0.5){
                    i+=step;
                }else{
                    i-=step;
                }
            }
            print(i);
            count--;
        }
    }
    public static void print(int i){
        while(i>0){
            System.out.print(' ');
            i--;
        }
        System.out.println('.');
    }
}
```

答:
JavaScript

114 chars - 10 (30 char lines) - 50 (pull dot towards the middle) = 54

```<code>for(f=Math.random,a=[],i=30,j=k=f()*i|0;i--;a[j]='.',a[j+=29-k]='\n',j+=k+=f()>k/29?1:-1);console.log(a.join('-'))
</code>```

However, I noticed that a 10 character reward for filling up the lines to 30 chars may be a bad deal; so:

102 chars - 50 (pull dot towards the middle) = 52

```<code>for(f=Math.random,a=[],i=30,j=k=f()*i|0;i;i--,a[j]='.\n',j+=k+=f()>k/29?1:-1);console.log(a.join('-'))
</code>```

Kudos to @WallyWest for the simplified pull direction conditional f()>k/29?1:-1, my first draft used two nested conditionals.

Title: The shifting dot

Body:
JavaScript

114 chars - 10 (30 char lines) - 50 (pull dot towards the middle) = 54

for(f=Math.random,a=[],i=30,j=k=f()*i|0;i--;a[j]='.',a[j+=29-k]='\n',j+=k+=f()>k/29?1:-1);console.log(a.join('-'))

However, I noticed that a 10 character reward for filling up the lines to 30 chars may be a bad deal; so:

102 chars - 50 (pull dot towards the middle) = 52

for(f=Math.random,a=[],i=30,j=k=f()*i|0;i;i--,a[j]='.\n',j+=k+=f()>k/29?1:-1);console.log(a.join('-'))

Kudos to @WallyWest for the simplified pull direction conditional f()>k/29?1:-1, my first draft used two nested conditionals.


问:
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.

答:
Jelly, <s>6</s> 5 bytes

```<code>”*ẋþY
</code>```

TryItOnline

How?

```<code>”*ẋþY - Main link: n
”*    - literal string "*"
   þ  - form outer product with the dyadic function:
  ẋ   -     repeat list (right input is an implicit range(n), Jelly defaults to 1-based)
            so the outer product is like:
            [[i*'*' for i in range(1,len("*")+1)] for x in range(1,n+1)]
    Y - join with line feeds
      - implicit print
</code>```

Bounty:

I'm not sure what the no ordinals clause is, since a character is a lookup of an ordinal.

Direct lookup would just be 42Ọẋþ³Y for 7 bytes - where the ³ gets us the input)

A short slightly indirect method would be, for 8 bytes, “)’Ọẋþ³Y - where we lookup ')' in jelly's code page, which is 1-indexed so “)’ yields 42.

ContentLicense: CC BY-SA 4.0

Title: Draw an asterisk triangle

Body:
Jelly, <s>6</s> 5 bytes

”*ẋþY

TryItOnline

How?

”*ẋþY - Main link: n
”*    - literal string "*"
   þ  - form outer product with the dyadic function:
  ẋ   -     repeat list (right input is an implicit range(n), Jelly defaults to 1-based)
            so the outer product is like:
            [[i*'*' for i in range(1,len("*")+1)] for x in range(1,n+1)]
    Y - join with line feeds
      - implicit print

Bounty:

I'm not sure what the no ordinals clause is, since a character is a lookup of an ordinal.

Direct lookup would just be 42Ọẋþ³Y for 7 bytes - where the ³ gets us the input)

A short slightly indirect method would be, for 8 bytes, “)’Ọẋþ³Y - where we lookup ')' in jelly's code page, which is 1-indexed so “)’ yields 42.


答:
GNU sed, 54 bytes

s:^:rnbqkbnr:p;h
s:.:p:gp;G
h;s:[^\n]:.:gp;G
s:.:\U&:g
```

<p><strong>Try it online!</strong></p>

<p><strong>Explanation:</strong></p>

<p>The black pieces are printed first, saving the two associated board ranks in reverse order in the hold space. The white pieces are printed by converting the hold space to uppercase letters.</p>

<pre class="lang-sed prettyprint-override"><code>s:^:rnbqkbnr:p;h   # change pattern and hold spaces to 'rnbqkbnr' and print string
s:.:p:gp           # replace each pattern space letter with a 'p', then print
G;h                # append hold space, then copy pattern space to hold space
s:[^\n]:.:gp       # replace each pattern space letter with a '.', then print
G;s:.:\U&:g        # append hold space and convert pattern space to uppercase
                   # (automatic printing of pattern space at the end)
</code>```

Title: Draw an ASCII chess board!

Body:
GNU sed, 54 bytes

s:^:rnbqkbnr:p;h
s:.:p:gp;G
h;s:[^\n]:.:gp;G
s:.:\U&:g

Try it online!

Explanation:

The black pieces are printed first, saving the two associated board ranks in reverse order in the hold space. The white pieces are printed by converting the hold space to uppercase letters.

s:^:rnbqkbnr:p;h   # change pattern and hold spaces to 'rnbqkbnr' and print string
s:.:p:gp           # replace each pattern space letter with a 'p', then print
G;h                # append hold space, then copy pattern space to hold space
s:[^\n]:.:gp       # replace each pattern space letter with a '.', then print
G;s:.:\U&:g        # append hold space and convert pattern space to uppercase
                   # (automatic printing of pattern space at the end)


答:
05AB1E, <s>7</s> 6 bytes

Uses CP-1252 encoding.

```<code>'*×.p»
</code>```

8 byte no-asterisk version:

```<code>žQTè×.p»
</code>```

Try it online!

Explanation

Example using input n = 5

```<code>'*      # push "*"
        # STACK: "*"
  ×     # repeat input number times
        # STACK: "*****"
   .p   # get prefixes of string
        # STACK: ['*', '**', '***', '****', '*****']
     »  # join by newlines
        # implicit print
</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:
05AB1E, <s>7</s> 6 bytes

Uses CP-1252 encoding.

'*×.p»

8 byte no-asterisk version:

žQTè×.p»

Try it online!

Explanation

Example using input n = 5

'*      # push "*"
        # STACK: "*"
  ×     # repeat input number times
        # STACK: "*****"
   .p   # get prefixes of string
        # STACK: ['*', '**', '***', '****', '*****']
     »  # join by newlines
        # implicit print


答:
Retina, 14 bytes

Byte count assumes ISO 8859-1 encoding.

```<code>.+
$**
.
$`$&¶
</code>```

Try it online!

Explanation

```<code>.+
$**
</code>```

Turn the input N into N asterisks.

```<code>.
$`$&¶
</code>```

Replace each asterisk with everything up to and including that asterisk (this is the $`$&) and a linefeed (this the ¶).

Title: Draw an asterisk triangle

Body:
Retina, 14 bytes

Byte count assumes ISO 8859-1 encoding.

.+
$**
.
$`$&¶

Try it online!

Explanation

.+
$**

Turn the input N into N asterisks.

.
$`$&¶

Replace each asterisk with everything up to and including that asterisk (this is the $`$&) and a linefeed (this the ¶).


答:
Python 2, <s>37</s> 34 bytes

i=1;exec"print'*'*i;i+=1;"*input()
```

Ideone

i is initialised to 1;

then exec commands to execute the following string of code, so it must be constructed;

the string is "print'*'*i;i+=1;" but the * following the string takes precedence over the exec and instructs to first repeat the string input() times;

the exec command now executes the long string which acts like a loop, printing another string of increasing length, again using * to repeat the character '*', then incrementing i with i+=1.

Python 3, 41 bytes:

def f(n):i=1;exec("print('*'*i);i+=1;"*n); or

lambda n,i=1:exec("print('*'*i);i+=1;"*n)

Title: Draw an asterisk triangle

Body:
Python 2, <s>37</s> 34 bytes

i=1;exec"print'*'*i;i+=1;"*input()

Ideone

i is initialised to 1;

then exec commands to execute the following string of code, so it must be constructed;

the string is "print'*'*i;i+=1;" but the * following the string takes precedence over the exec and instructs to first repeat the string input() times;

the exec command now executes the long string which acts like a loop, printing another string of increasing length, again using * to repeat the character '*', then incrementing i with i+=1.

Python 3, 41 bytes:

def f(n):i=1;exec("print('*'*i);i+=1;"*n); or

lambda n,i=1:exec("print('*'*i);i+=1;"*n)


答:
V, 8 bytes

```<code>Àé*hòlÄx
</code>```

Try it online!

Title: Draw an asterisk triangle

Body:
V, 8 bytes

Àé*hòlÄx

Try it online!


Title: Draw an asterisk triangle

Body:
Gema, 36 characters

*=@repeat{*;@append{s;\*}@out{$s\n}}

Sample run:

bash-4.3$ gema '*=@repeat{*;@append{s;\*}@out{$s\n}}' <<< 5
*
**
***
****
*****


答:
PowerShell, <s>21</s> 20 bytes

1.."$args"|%{'*'*$_}
```

<p>Try it online!</p>

<p>Loops from <code>1</code> to input <code>$args</code>, each iteration using string multiplication to construct a string of that many <code>$_</code> asterisks. Default behavior for the implicit <code>Write-Output</code> at the end is with a newline for separator, so we get that for free.</p>

<pre class="lang-powershell prettyprint-override"><code>PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 5
*
**
***
****
*****

PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 2
*
**

PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 7
*
**
***
****
*****
******
*******
</code>```

-1 byte thanks to Veskah.

Title: Draw an asterisk triangle

Body:
PowerShell, <s>21</s> 20 bytes

1.."$args"|%{'*'*$_}

Try it online!

Loops from 1 to input $args, each iteration using string multiplication to construct a string of that many $_ asterisks. Default behavior for the implicit Write-Output at the end is with a newline for separator, so we get that for free.

PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 5
*
**
***
****
*****

PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 2
*
**

PS C:\Tools\Scripts\golfing> .\draw-asterisk-pattern.ps1 7
*
**
***
****
*****
******
*******

-1 byte thanks to Veskah.


Title: Draw an asterisk triangle

Body:
JavaScript (ES6), 34 bytes

f=x=>x?f(x-1)+`
`+'*'.repeat(x):''


答:
Jellyfish, <s>12</s> <s>11</s> 9 bytes

```<code>\P$'*
  i
</code>```

Try it online!

Explanation

The above program is equivalent to the following functional pseudocode:

```<code>\            P      $       i        '*
map_prefixes(print, reshape(input(), '*'))
</code>```

The $ (reshape) creates a string of N asterisks. \P creates a function which takes a list (or string) and passes each of its prefixes to P (print). Hence, this successively prints strings of 1 to N asterisks.

Title: Draw an asterisk triangle

Body:
Jellyfish, <s>12</s> <s>11</s> 9 bytes

\P$'*
  i

Try it online!

Explanation

The above program is equivalent to the following functional pseudocode:

\            P      $       i        '*
map_prefixes(print, reshape(input(), '*'))

The $ (reshape) creates a string of N asterisks. \P creates a function which takes a list (or string) and passes each of its prefixes to P (print). Hence, this successively prints strings of 1 to N asterisks.


答:
C#, 42 bytes

```<code>f=n=>n<1?"":f(n-1)+"\n"+new string('*',n);
</code>```

Full program with test case:

```<code>using System;

namespace DrawAnAsteriskPattern
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<int,string>f= null;
            f=n=>n<1?"":f(n-1)+"\n"+new string('*',n);

            Console.WriteLine(f(5));
        }
    }
}
</code>```

Title: Draw an asterisk triangle

Body:
C#, 42 bytes

f=n=>n<1?"":f(n-1)+"\n"+new string('*',n);

Full program with test case:

using System;

namespace DrawAnAsteriskPattern
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<int,string>f= null;
            f=n=>n<1?"":f(n-1)+"\n"+new string('*',n);

            Console.WriteLine(f(5));
        }
    }
}


答:
Java <s>7</s> 11, <s>88</s> <s>73</s> 58 bytes

```<code>String c(int n){return(n<2?"":c(n-1)+"\n")+"*".repeat(n);}
</code>```

-15 bytes by converting to Java 11.

Try it online. (NOTE: String#repeat(int) is emulated as repeat(String,int) for the same byte-count, because TIO doesn't contain Java 11 yet.)

Explanation:

```<code>String c(int n){          // Recursive method with integer parameter and String return-type
  return(n<2?             //  If `n` is 1:
          ""              //   Start with an empty String
         :                //  Else:
          c(n-1)          //   Start with a recursive call with `n-1`
                +"\n")    //   and a trailing new-line
         +"*".repeat(n);} //  And append `n` amount of '*'
</code>```

Title: Draw an asterisk triangle

Body:
Java <s>7</s> 11, <s>88</s> <s>73</s> 58 bytes

String c(int n){return(n<2?"":c(n-1)+"\n")+"*".repeat(n);}

-15 bytes by converting to Java 11.

Try it online. (NOTE: String#repeat(int) is emulated as repeat(String,int) for the same byte-count, because TIO doesn't contain Java 11 yet.)

Explanation:

String c(int n){          // Recursive method with integer parameter and String return-type
  return(n<2?             //  If `n` is 1:
          ""              //   Start with an empty String
         :                //  Else:
          c(n-1)          //   Start with a recursive call with `n-1`
                +"\n")    //   and a trailing new-line
         +"*".repeat(n);} //  And append `n` amount of '*'


答:
Brachylog, 12 bytes

```<code>yke:"*"rj@w\
</code>```

Try it online!

This assumes that a trailing new line is acceptable

Explanation

```<code>yk                The range [0, …, Input - 1]
  e               Take one element I of that range
   :"*"rj         Juxtapose "*" I times to itself
         @w       Write that string followed by a new line
           \      False: backtrack to another element of the range
</code>```

No trailing new line, 15 bytes

```<code>-:"*"rj:@[f~@nw
</code>```

Try it online!

This one works by taking all prefixes of "*" × Input.

Title: Draw an asterisk triangle

Body:
Brachylog, 12 bytes

yke:"*"rj@w\

Try it online!

This assumes that a trailing new line is acceptable

Explanation

yk                The range [0, …, Input - 1]
  e               Take one element I of that range
   :"*"rj         Juxtapose "*" I times to itself
         @w       Write that string followed by a new line
           \      False: backtrack to another element of the range

No trailing new line, 15 bytes

-:"*"rj:@[f~@nw

Try it online!

This one works by taking all prefixes of "*" × Input.


答:
JavaScript (ES6), 31 bytes

This one includes both a leading and a trailing line-break.

We start with a string s containing only a line-break. Then we process n recursive calls, adding an asterisk on the left side of this string at each iteration. The concatenation of all intermediate strings leads to the expected result.

f=(n,s=`
`)=>n?s+f(n-1,'*'+s):s
```
<p>Try it online!</p>
<h3>Without asterisk, 36 bytes</h3>
<pre class="lang-javascript prettyprint-override"><code>f=(n,s=`
`)=>n?s+f(n-1,atob`Kg`+s):s
</code>```

Try it online!

Title: Draw an asterisk triangle

Body:
JavaScript (ES6), 31 bytes

This one includes both a leading and a trailing line-break.

We start with a string s containing only a line-break. Then we process n recursive calls, adding an asterisk on the left side of this string at each iteration. The concatenation of all intermediate strings leads to the expected result.

f=(n,s=`
`)=>n?s+f(n-1,'*'+s):s

Try it online!

Without asterisk, 36 bytes

f=(n,s=`
`)=>n?s+f(n-1,atob`Kg`+s):s

Try it online!


答:
Java 7, <s>103</s> <s>99</s> 89 bytes

```<code>String f(){return"rnbqkbnr\npppppppp\nxxxxPPPPPPPP\nRNBQKBNR".replace("x","........\n");}
</code>```

10 bytes saved compared to hardcoded output thanks to @SLC's approach in his C# answer.

Try it here.

Output:

```<code>rnbqkbnr
pppppppp
........
........
........
........
PPPPPPPP
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:
Java 7, <s>103</s> <s>99</s> 89 bytes

String f(){return"rnbqkbnr\npppppppp\nxxxxPPPPPPPP\nRNBQKBNR".replace("x","........\n");}

10 bytes saved compared to hardcoded output thanks to @SLC's approach in his C# answer.

Try it here.

Output:

rnbqkbnr
pppppppp
........
........
........
........
PPPPPPPP
RNBQKBNR


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

1 byte saved thanks to @Luis

```<code>:"42@Y"c
</code>```

Try it Online

Title: Draw an asterisk triangle

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

1 byte saved thanks to @Luis

:"42@Y"c

Try it Online


答:
GNU sed, <s>25</s> <s>24</s> 20 + 1(n flag) = 21 bytes

Edit: 4 bytes less based on Riley's comments

x;G;:;P;s:\n.:*\n:;t
```
<p><strong>Try it online!</strong></p>
<p><strong>Run example:</strong> the input is in unary format, which for sed is allowed based on this consensus</p>
<pre class="lang-sh prettyprint-override"><code>me@LCARS:/PPCG$ sed -nf draw_triangle.sed <<< "0000"

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

A leading newline is present in the output, but this is allowed by the OP.

Explanation:

x;G             # prepend a newline to unary string
:               # start loop
   P            # print first line only
   s:\n.:*\n:   # shift one unary char from 2nd line to 1st, converted to a '*'
t               # repeat
```

Title: Draw an asterisk triangle

Body:
GNU sed, <s>25</s> <s>24</s> 20 + 1(n flag) = 21 bytes

Edit: 4 bytes less based on Riley's comments

x;G;:;P;s:\n.:*\n:;t

Try it online!

Run example: the input is in unary format, which for sed is allowed based on this consensus

me@LCARS:/PPCG$ sed -nf draw_triangle.sed <<< "0000"

*
**
***
****

A leading newline is present in the output, but this is allowed by the OP.

Explanation:

x;G             # prepend a newline to unary string
:               # start loop
   P            # print first line only
   s:\n.:*\n:   # shift one unary char from 2nd line to 1st, converted to a '*'
t               # repeat


答:
Batch, 69 bytes

```<code>@set s=
@for /l %%i in (1,1,%1)do @call set s=*%%s%%&call echo %%s%%
</code>```

Title: Draw an asterisk triangle

Body:
Batch, 69 bytes

@set s=
@for /l %%i in (1,1,%1)do @call set s=*%%s%%&call echo %%s%%


答:
SpecBAS - 216 bytes

```<code>1 s$,t$="": INPUT a$: DIM b$(SPLIT a$,NOT ",")
2 FOR EACH l$ IN b$()
3 CASE l$
4 WHEN "[B]": s$=s$( TO LEN s$-1)
5 WHEN "[C]": t$=s$
6 WHEN "[D]": s$=""
7 WHEN "[P]": s$=s$+t$
8 OTHERWISE : s$=s$+l$
9 END CASE
10 NEXT l$: ?s$
</code>```

Input is given as a string with commas, which is then turned into array.

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:
SpecBAS - 216 bytes

1 s$,t$="": INPUT a$: DIM b$(SPLIT a$,NOT ",")
2 FOR EACH l$ IN b$()
3 CASE l$
4 WHEN "[B]": s$=s$( TO LEN s$-1)
5 WHEN "[C]": t$=s$
6 WHEN "[D]": s$=""
7 WHEN "[P]": s$=s$+t$
8 OTHERWISE : s$=s$+l$
9 END CASE
10 NEXT l$: ?s$

Input is given as a string with commas, which is then turned into array.


答:
Matlab, 26 23 bytes

Good old Matlab...

```<code>@(n)tril(repmat('*',n))
</code>```

Has trailing whitespaces. tril gives you the lower triangular matrix.

edit: saved 2 bythes thanks to Luis Mendo

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:
Matlab, 26 23 bytes

Good old Matlab...

@(n)tril(repmat('*',n))

Has trailing whitespaces. tril gives you the lower triangular matrix.

edit: saved 2 bythes thanks to Luis Mendo


答:
Racket 82 bytes

```<code>(display"rnbqknbr
pppppppp
........
........
........
........
PPPPPPPP
RNBQKNBR")
</code>```

Another version: 162 bytes

```<code>(display(string-append"rnbqknbr\n"(make-string 8 #\p)(list->string(for/list((i
(range 0 37)))(if(= 0(modulo i 9))#\newline #\.)))(make-string 8 #\P)"\nRNBQKNBR"))
</code>```

Ungolfed:

```<code>(define (f)
  (display (string-append
            "rnbqknbr\n"
            (make-string 8 #\p)
            (list->string
             (for/list ((i (range 0 37)))
               (if(= 0 (modulo i 9)) #\newline #\.)))
            (make-string 8 #\P)
            "\nRNBQKNBR"))
  )
</code>```

Testing:

```<code>(f)
</code>```

Output:

```<code>rnbqknbr
pppppppp
........
........
........
........
PPPPPPPP
RNBQKNBR
</code>```

Title: Draw an ASCII chess board!

Body:
Racket 82 bytes

(display"rnbqknbr
pppppppp
........
........
........
........
PPPPPPPP
RNBQKNBR")

Another version: 162 bytes

(display(string-append"rnbqknbr\n"(make-string 8 #\p)(list->string(for/list((i
(range 0 37)))(if(= 0(modulo i 9))#\newline #\.)))(make-string 8 #\P)"\nRNBQKNBR"))

Ungolfed:

(define (f)
  (display (string-append
            "rnbqknbr\n"
            (make-string 8 #\p)
            (list->string
             (for/list ((i (range 0 37)))
               (if(= 0 (modulo i 9)) #\newline #\.)))
            (make-string 8 #\P)
            "\nRNBQKNBR"))
  )

Testing:

(f)

Output:

rnbqknbr
pppppppp
........
........
........
........
PPPPPPPP
RNBQKNBR


答:
Racket 47 bytes

```<code>(for((i(+ 1 n)))(displayln(make-string i #\*)))
</code>```

Ungolfed:

```<code>(define (f n)
  (for ((i (+ 1 n)))                         ; (i 5) in 'for' produces 0,1,2,3,4
    (displayln (make-string i #\*))))        ; #\* means character '*'
</code>```

Testing:

```<code>(f 5)
</code>```

Output:

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

Title: Draw an asterisk triangle

Body:
Racket 47 bytes

(for((i(+ 1 n)))(displayln(make-string i #\*)))

Ungolfed:

(define (f n)
  (for ((i (+ 1 n)))                         ; (i 5) in 'for' produces 0,1,2,3,4
    (displayln (make-string i #\*))))        ; #\* means character '*'

Testing:

(f 5)

Output:

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


答:
Java 7, <s>207</s> 203 bytes

```<code>String c(String[]a){String r="",c=r;for(String s:a){int k=s.length(),l=r.length(),z;if(k>1){z=s.charAt(1);r=z<67?l>0?r.substring(0,l-1):"":z<68?r:z<69?"":z<81?r+c:r+s;c=z==67?r:c;}r+=k<2?s:"";}return r;}
</code>```

This can most definitely be golfed some more, <s>but this is my initial answer. Will edit after I found something to remove those equals-checks..</s> replaced with charAt, but can probably still be golfed..

Ungolfed & test code:

Try it here.

```<code>class M{
  static String c(final String[] a) {
    String r = "",
           c = r;
    for(String s : a){
      int k = s.length(),
          l = r.length(),
          z;
      if(k > 1){
        z = s.charAt(1);
        r = z < 67
             ? l > 0
                ? r.substring(0, l-1)
                : ""
             : z < 68
                ? r
                : z < 69
                   ? ""
                   : z < 81
                      ? r + c
                      : r + s;
        c = z == 67
             ? r
             : c;
      }
      r += k < 2
            ? s
            : "";
    }
    return r;
  }

  public static void main(String[] a){
    System.out.println(c(new String[]{ "H", "e", "l", "l", "o" }));
    System.out.println(c(new String[]{ "H", "e", "l", "l", "o", " ", "[C]", "[P]" }));
    System.out.println(c(new String[]{ "[D]", "D", "[B]" }));
    System.out.println(c(new String[]{ "H", "[C]", "i", "[P]", "[C]", "[P]" }));
    System.out.println(c(new String[]{ "e", "[C]", "[B]", "I", " ", "l", "i", "k", "[P]", " ", "b", "[P]", "[P]", "s", "!" }));
    System.out.println(c(new String[]{ "N", "[P]" }));
    System.out.println(c(new String[]{ "#", "5", "0", "K", "0", "0", "1", "[D]", "#", "n", "o", "t" }));
    System.out.println(c(new String[]{ "H", "o", "w", " ", "[D]", "H", "e", "y" }));
    System.out.println(c(new String[]{ "s", "u", "d", "[B]", "p", "[C]", "[D]", "I", " ", "h", "a", "v", "e", " ", "[P]", "p", "e", "r", "!" }));
  }
}
</code>```

Output:

```<code>Hello
Hello Hello

HiHHiH
I like bees!
N
#not
Hey
I have supper!
</code>```

Title: Simulate keystrokes

Body:
Java 7, <s>207</s> 203 bytes

String c(String[]a){String r="",c=r;for(String s:a){int k=s.length(),l=r.length(),z;if(k>1){z=s.charAt(1);r=z<67?l>0?r.substring(0,l-1):"":z<68?r:z<69?"":z<81?r+c:r+s;c=z==67?r:c;}r+=k<2?s:"";}return r;}

This can most definitely be golfed some more, <s>but this is my initial answer. Will edit after I found something to remove those equals-checks..</s> replaced with charAt, but can probably still be golfed..

Ungolfed & test code:

Try it here.

class M{
  static String c(final String[] a) {
    String r = "",
           c = r;
    for(String s : a){
      int k = s.length(),
          l = r.length(),
          z;
      if(k > 1){
        z = s.charAt(1);
        r = z < 67
             ? l > 0
                ? r.substring(0, l-1)
                : ""
             : z < 68
                ? r
                : z < 69
                   ? ""
                   : z < 81
                      ? r + c
                      : r + s;
        c = z == 67
             ? r
             : c;
      }
      r += k < 2
            ? s
            : "";
    }
    return r;
  }

  public static void main(String[] a){
    System.out.println(c(new String[]{ "H", "e", "l", "l", "o" }));
    System.out.println(c(new String[]{ "H", "e", "l", "l", "o", " ", "[C]", "[P]" }));
    System.out.println(c(new String[]{ "[D]", "D", "[B]" }));
    System.out.println(c(new String[]{ "H", "[C]", "i", "[P]", "[C]", "[P]" }));
    System.out.println(c(new String[]{ "e", "[C]", "[B]", "I", " ", "l", "i", "k", "[P]", " ", "b", "[P]", "[P]", "s", "!" }));
    System.out.println(c(new String[]{ "N", "[P]" }));
    System.out.println(c(new String[]{ "#", "5", "0", "K", "0", "0", "1", "[D]", "#", "n", "o", "t" }));
    System.out.println(c(new String[]{ "H", "o", "w", " ", "[D]", "H", "e", "y" }));
    System.out.println(c(new String[]{ "s", "u", "d", "[B]", "p", "[C]", "[D]", "I", " ", "h", "a", "v", "e", " ", "[P]", "p", "e", "r", "!" }));
  }
}

Output:

Hello
Hello Hello

HiHHiH
I like bees!
N
#not
Hey
I have supper!


答:
Forth, 39 bytes

Quite simple, with a couple of nested loops. ASCII 42 is an asterisk.

```<code>: f 0 do I -1 do 42 emit loop CR loop ;
</code>```

Try it online

Prints a trailing newline.

Title: Draw an asterisk triangle

Body:
Forth, 39 bytes

Quite simple, with a couple of nested loops. ASCII 42 is an asterisk.

: f 0 do I -1 do 42 emit loop CR loop ;

Try it online

Prints a trailing newline.


答:
PHP 7.1, <s>95</s> 92 bytes

Note: requires PHP 7.1 for negative string offsets.

```<code>for(;n|$i=$argv[++$x];)($l=$i[1])?$l^r?$l^s?$l^t?$o.=$c:$o="":$c=$o:$o[-1]="":$o.=$i;echo$o;
</code>```

Without negative string offsets (101 bytes):

```<code>php -r 'for(;n|$i=$argv[++$x];)($l=$i[1])?$l^r?$l^s?$l^t?$o.=$c:$o="":$c=$o:$o=substr($o,0,-1):$o.=$i;echo$o;' e [C] [B] I ' ' l i k [P] ' ' b [P] [P] s ! 2>/dev/null;echo
</code>```

Run like this:

```<code>php -nr 'for(;n|$i=$argv[++$x];)($l=$i[1])?$l^r?$l^s?$l^t?$o.=$c:$o="":$c=$o:$o[-1]="":$o.=$i;echo$o;' e [C] [B] I ' ' l i k [P] ' ' b [P] [P] s !;echo
> I like bees!
</code>```

Explanation

```<code>for(
  ;
  n|$i=$argv[++$x];   # Iterates over the input until null.
)
  ($l=$i[1])?         # Check if this item is a command, if so set to $l
    $l^r?             # If the command is not B
      $l^s?           # If the command is not C
        $l^t?         # If the command is not D
          $o.=$c      # Then it's P, so paste the clipboard ($c)
        :$o=""        #      It's D, so delete output
      :$c=$o          #      It's C, so copy output to clipboard
    :$o[-1]=""        #      It's B, so remove the last output char
  :$o.=$i;            # No command, add the current item to the output.

echo$o;               # Print the output.
</code>```

Tweaks

Saved 3 bytes by combining the output handling with the command handling

Title: Simulate keystrokes

Body:
PHP 7.1, <s>95</s> 92 bytes

Note: requires PHP 7.1 for negative string offsets.

for(;n|$i=$argv[++$x];)($l=$i[1])?$l^r?$l^s?$l^t?$o.=$c:$o="":$c=$o:$o[-1]="":$o.=$i;echo$o;

Without negative string offsets (101 bytes):

php -r 'for(;n|$i=$argv[++$x];)($l=$i[1])?$l^r?$l^s?$l^t?$o.=$c:$o="":$c=$o:$o=substr($o,0,-1):$o.=$i;echo$o;' e [C] [B] I ' ' l i k [P] ' ' b [P] [P] s ! 2>/dev/null;echo

Run like this:

php -nr 'for(;n|$i=$argv[++$x];)($l=$i[1])?$l^r?$l^s?$l^t?$o.=$c:$o="":$c=$o:$o[-1]="":$o.=$i;echo$o;' e [C] [B] I ' ' l i k [P] ' ' b [P] [P] s !;echo
> I like bees!

Explanation

for(
  ;
  n|$i=$argv[++$x];   # Iterates over the input until null.
)
  ($l=$i[1])?         # Check if this item is a command, if so set to $l
    $l^r?             # If the command is not B
      $l^s?           # If the command is not C
        $l^t?         # If the command is not D
          $o.=$c      # Then it's P, so paste the clipboard ($c)
        :$o=""        #      It's D, so delete output
      :$c=$o          #      It's C, so copy output to clipboard
    :$o[-1]=""        #      It's B, so remove the last output char
  :$o.=$i;            # No command, add the current item to the output.

echo$o;               # Print the output.

Tweaks

Saved 3 bytes by combining the output handling with the command handling


答:
PowerShell v2+, 44 bytes

```<code>'rnbqknbr'
'p'*8
,('.'*8)*4
'P'*8
'RNBQKNBR'
</code>```

Strings left on the pipeline are implicitly printed with Write-Output at program execution. We couple that with the default newline behavior for an array to produce the four lines of periods with the comma-operator.

```<code>PS C:\Tools\Scripts\golfing> .\draw-ascii-chess-board.ps1
rnbqknbr
pppppppp
........
........
........
........
PPPPPPPP
RNBQKNBR
</code>```

Title: Draw an ASCII chess board!

Body:
PowerShell v2+, 44 bytes

'rnbqknbr'
'p'*8
,('.'*8)*4
'P'*8
'RNBQKNBR'

Strings left on the pipeline are implicitly printed with Write-Output at program execution. We couple that with the default newline behavior for an array to produce the four lines of periods with the comma-operator.

PS C:\Tools\Scripts\golfing> .\draw-ascii-chess-board.ps1
rnbqknbr
pppppppp
........
........
........
........
PPPPPPPP
RNBQKNBR


问:
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:
Python 2, 267 bytes

It works with decimals and negative numbers as well.

p=1
while p!=len(a):
 q=p-1;k=a[p:];m=min(k);n=k.index(m)+p;b=map(str,a)
 if a[q]>m:print','.join(b)+'\n'+''.join(' '*len(i)for i in b[:q])+' '*q+'*'+'-'*(len(b[n])+n-q-2)+''.join('-'*len(i)for i in b[q:n])+'*';a[q],a[n]=[a[n],a[q]]
 p+=1
print','.join(map(str,a))

Example:

7,2,64,-106,52.7,-542.25,54,209,0,-1,200.005,200,3,6,1,0,335,-500,3.1,-0.002
*----------------------*
-542.25,2,64,-106,52.7,7,54,209,0,-1,200.005,200,3,6,1,0,335,-500,3.1,-0.002
        *-------------------------------------------------------*
-542.25,-500,64,-106,52.7,7,54,209,0,-1,200.005,200,3,6,1,0,335,2,3.1,-0.002
             *-----*
-542.25,-500,-106,64,52.7,7,54,209,0,-1,200.005,200,3,6,1,0,335,2,3.1,-0.002
                  *-------------------*
-542.25,-500,-106,-1,52.7,7,54,209,0,64,200.005,200,3,6,1,0,335,2,3.1,-0.002
                     *-----------------------------------------------------*
-542.25,-500,-106,-1,-0.002,7,54,209,0,64,200.005,200,3,6,1,0,335,2,3.1,52.7
                            *--------*
-542.25,-500,-106,-1,-0.002,0,54,209,7,64,200.005,200,3,6,1,0,335,2,3.1,52.7
                              *-----------------------------*
-542.25,-500,-106,-1,-0.002,0,0,209,7,64,200.005,200,3,6,1,54,335,2,3.1,52.7
                                *------------------------*
-542.25,-500,-106,-1,-0.002,0,0,1,7,64,200.005,200,3,6,209,54,335,2,3.1,52.7
                                  *-------------------------------*
-542.25,-500,-106,-1,-0.002,0,0,1,2,64,200.005,200,3,6,209,54,335,7,3.1,52.7
                                    *--------------*
-542.25,-500,-106,-1,-0.002,0,0,1,2,3,200.005,200,64,6,209,54,335,7,3.1,52.7
                                      *-------------------------------*
-542.25,-500,-106,-1,-0.002,0,0,1,2,3,3.1,200,64,6,209,54,335,7,200.005,52.7
                                          *------*
-542.25,-500,-106,-1,-0.002,0,0,1,2,3,3.1,6,64,200,209,54,335,7,200.005,52.7
                                            *-----------------*
-542.25,-500,-106,-1,-0.002,0,0,1,2,3,3.1,6,7,200,209,54,335,64,200.005,52.7
                                              *----------------------------*
-542.25,-500,-106,-1,-0.002,0,0,1,2,3,3.1,6,7,52.7,209,54,335,64,200.005,200
                                                   *----*
-542.25,-500,-106,-1,-0.002,0,0,1,2,3,3.1,6,7,52.7,54,209,335,64,200.005,200
                                                      *--------*
-542.25,-500,-106,-1,-0.002,0,0,1,2,3,3.1,6,7,52.7,54,64,335,209,200.005,200
                                                         *-----------------*
-542.25,-500,-106,-1,-0.002,0,0,1,2,3,3.1,6,7,52.7,54,64,200,209,200.005,335
                                                             *---------*
-542.25,-500,-106,-1,-0.002,0,0,1,2,3,3.1,6,7,52.7,54,64,200,200.005,209,335


答:
Bash, 35 characters

```<code>for((;i++<$1;));{ s+=\*;echo "$s";}
</code>```

Sample run:

```<code>bash-4.3$ bash draw-an-asterisk-triangle.sh 5
*
**
***
****
*****
</code>```

Title: Draw an asterisk triangle

Body:
Bash, 35 characters

for((;i++<$1;));{ s+=\*;echo "$s";}

Sample run:

bash-4.3$ bash draw-an-asterisk-triangle.sh 5
*
**
***
****
*****


Title: Draw an asterisk triangle

Body:
Haskell, 35 <s>38</s> bytes

List comprehension thanks to nimi:

f x=unlines[[1..n]>>"*"|n<-[1..x]]

Old version:

f 0=""
f n=f(n-1)++([1..n]>>"*")++"\n"

Alternate version:

g n=([1..n]>>"*")++"\n"
f n=[1..n]>>=g


答:
QBIC, 16 bytes

```<code>:#*|[1,a|B=B+A?B
</code>```

Explanation:

```<code>:         Gets a cmd line param as number called 'a'
#*|       Define A$ as '*'
[1,a|     FOR b = 1 to a
B=B+A     Extend B$ with another astrix
?B        Print B$
<FOR LOOP implicitly closed>
</code>```

QBIC's seen a few updates since this answer was posted. This could now be done with these 12 bytes:

```<code>[:|B=B+@*`?B
</code>```

Title: Draw an asterisk triangle

Body:
QBIC, 16 bytes

:#*|[1,a|B=B+A?B

Explanation:

:         Gets a cmd line param as number called 'a'
#*|       Define A$ as '*'
[1,a|     FOR b = 1 to a
B=B+A     Extend B$ with another astrix
?B        Print B$
<FOR LOOP implicitly closed>

QBIC's seen a few updates since this answer was posted. This could now be done with these 12 bytes:

[:|B=B+@*`?B


答:
V, 49 bytes

```<code>íÛBÝ/
íÛCÝ/0y$A
íÛDÝ/"_S
íÛPÝ/"
íî
0éiD@"
</code>```

Try it online!

Since this contains unprintable characters, here is a hexdump:

```<code>0000000: eddb 42dd 2f16 080a eddb 43dd 2f16 1b30  ..B./.....C./..0
0000010: 7924 410a eddb 44dd 2f16 1b22 5f53 0aed  y$A...D./.."_S..
0000020: db50 dd2f 1612 220a edee 0a30 e969 4440  .P./.."....0.iD@
0000030: 22
</code>```

This is just a direct translation of my vim answer so that I could compete with Jelly. Unfortunately, I'm still one byte over, but I'm still working on the last one. :)

I'm more proud of that answer anyway, so if you want a very detailed explanation, read that one instead.

Title: Simulate keystrokes

Body:
V, 49 bytes

íÛBÝ/
íÛCÝ/0y$A
íÛDÝ/"_S
íÛPÝ/"
íî
0éiD@"

Try it online!

Since this contains unprintable characters, here is a hexdump:

0000000: eddb 42dd 2f16 080a eddb 43dd 2f16 1b30  ..B./.....C./..0
0000010: 7924 410a eddb 44dd 2f16 1b22 5f53 0aed  y$A...D./.."_S..
0000020: db50 dd2f 1612 220a edee 0a30 e969 4440  .P./.."....0.iD@
0000030: 22

This is just a direct translation of my vim answer so that I could compete with Jelly. Unfortunately, I'm still one byte over, but I'm still working on the last one. :)

I'm more proud of that answer anyway, so if you want a very detailed explanation, read that one instead.


答:
PHP, <s>43</s> <s>34</s> <s>31</s> 28 bytes

Note: uses IBM 850 encoding (old favorite reinvented recently)

```<code>for(;$argn--;)echo$o.=~ı,~§;
</code>```

Run like this:

```<code>echo 5 | php -nR 'for(;$argn--;)echo$o.=~ı,~§;';echo
> *
> **
> ***
> ****
> *****
</code>```

Explanation

Iterates from N down to 0. Add an asterisk to $o for each iteration, then outputs $o and a newline.

Tweaks

Add an asterisk to $o for each iteration, and then output $o. Saves 9 bytes

Combined adding an asterisk to $o with outputting, saves 3 bytes

Saved 3 bytes by using $argn

Title: Draw an asterisk triangle

Body:
PHP, <s>43</s> <s>34</s> <s>31</s> 28 bytes

Note: uses IBM 850 encoding (old favorite reinvented recently)

for(;$argn--;)echo$o.=~ı,~§;

Run like this:

echo 5 | php -nR 'for(;$argn--;)echo$o.=~ı,~§;';echo
> *
> **
> ***
> ****
> *****

Explanation

Iterates from N down to 0. Add an asterisk to $o for each iteration, then outputs $o and a newline.

Tweaks

Add an asterisk to $o for each iteration, and then output $o. Saves 9 bytes

Combined adding an asterisk to $o with outputting, saves 3 bytes

Saved 3 bytes by using $argn


答:
Perl 5, 22 20 bytes

```<code>say"*"x$_ for 1..pop
</code>```

Run it with the -E switch to get say.

```<code>$ perl -E 'say"*"x$_ for 1..pop' 5
*
**
***
****
*****
</code>```

Written out as a full program it would look like this:

```<code>use strict;
use feature 'say';

# get the argument
my $limit = pop @ARGV;

foreach my $i (1 .. $limit) {
    say "*" x $i;
}
</code>```

shift and pop implicitly work on @ARGV (the list of arguments) outside of subs

.. is the range operator

say includes a newline

x is an operator to repeat strings and is explained in perlop

Title: Draw an asterisk triangle

Body:
Perl 5, 22 20 bytes

say"*"x$_ for 1..pop

Run it with the -E switch to get say.

$ perl -E 'say"*"x$_ for 1..pop' 5
*
**
***
****
*****

Written out as a full program it would look like this:

use strict;
use feature 'say';

# get the argument
my $limit = pop @ARGV;

foreach my $i (1 .. $limit) {
    say "*" x $i;
}

shift and pop implicitly work on @ARGV (the list of arguments) outside of subs

.. is the range operator

say includes a newline

x is an operator to repeat strings and is explained in perlop


答:
Perl 6, 23 bytes

{.put for [\~] '*'xx$_}
```

<p>( If the output is allowed to be a list of "lines" without newlines <code>.put for </code> can be removed )</p>

<h2>Explanation:</h2>

<pre class="lang-perl6 prettyprint-override"><code># bare block lambda with implicit parameter ｢$_｣
{
  .put            # print with trailing newline
    for           # for every one of the following
      [\~]        # produce using concatenation operator
        '*' xx $_ # list repeat '*' by the input
}
</code>```

( See documentation for produce if you don't understand what [\~] ... is doing )

Title: Draw an asterisk triangle

Body:
Perl 6, 23 bytes

{.put for [\~] '*'xx$_}

( If the output is allowed to be a list of "lines" without newlines .put for  can be removed )

Explanation:

# bare block lambda with implicit parameter ｢$_｣
{
  .put            # print with trailing newline
    for           # for every one of the following
      [\~]        # produce using concatenation operator
        '*' xx $_ # list repeat '*' by the input
}

( See documentation for produce if you don't understand what [\~] ... is doing )


答:
C++, 108 chars

```<code>#import<iostream>
main(){int n;std::cin>>n;for(int i=1;i<=n;++i){for(int j=i;j--;)std::cout<<"*";puts("");}}
</code>```

Straightforward.

Try it online

Title: Draw an asterisk triangle

Body:
C++, 108 chars

#import<iostream>
main(){int n;std::cin>>n;for(int i=1;i<=n;++i){for(int j=i;j--;)std::cout<<"*";puts("");}}

Straightforward.

Try it online