问:
Draw the national flag of Iceland
This year's UEFA Euro 2016 is over and besides a couple of negative headlines there has been a very positive surprise as well – the Iceland national football team. Let's draw their national flag.

Input

Well, obviously this challenge has no input.

Output

Draw the flag of Iceland in any applicable visual format of at least 100 x 72 pixels or 25 x 18 characters.

Save the output to a file or present it instantly – example formats are: images like png, jpg etc., vector graphics, draw on HTML canvas or even use non-whitespace characters for visualization.

Use these colors: blue: #0048e0, white: #ffffff and red: #d72828.

If your language doesn't support specific color values, use the standard values for red, blue and white from the ANSI color codes.

Draw the flag with the correct proportions, as shown in the figure below:

Boilerplate

You can write a program or a function. If it is an anonymous function, please include an example of how to invoke it.

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

Standard loopholes are disallowed.

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

If you can't find your answer, format your language and byte count as explained in the Leaderboard's "Info Section".

This challenge is inspired by Draw the national flag of france.

答:
Postscript 148 characters (84 bytes when using binary shortcuts)

First of all, there are two versions: One optimized for characters, and one optimized for binary shortcuts.

Golfed character version:

```<code>/s{setrgbcolor}def/R{rectfill}def 0.843 0.157 0.157 s 0 8 25 2 8 0 2 18 R R 0 0.282 0.878 s 0 0 7 7 0 11 7 7 8 copy R R 11 0 translate 2 1 scale R R
</code>```

Less golfed version (character optimised):

```<code>/s {setrgbcolor} def
/R {rectfill} def
0.843 0.157 0.157 s
0 8 25 2
8 0 2 18
R
R
0 0.282 0.878 s
0 0 7 7
0 11 7 7
8 copy
R
R
11 0 translate
2 1 scale
R
R
</code>```

Less golfed version (binary optimised):

```<code>0.843 0.157 0.157 setrgbcolor
0 8 25 2
8 0 2 18
rectfill
rectfill
0 0.282 0.878 setrgbcolor
0 0 7 7
0 11 7 7
8 copy
rectfill
rectfill
11 0 translate
2 1 scale
rectfill
rectfill
</code>```

Hex of the binary representation version:

 30 2E 38 34 33 20 30 2E 31 35 37 20 30 2E 31 35 37 92 9D 30 20 38 88 19 32 88 08 30 20 32 88 12 92 80 92 80 30 20 30 2E 32 38 32 20 30 2E 38 37 38 92 9D 30 88 00 37 88 07 30 88 0B 37 88 07 38 92 19 92 80 92 80 88 0B 30 92 AD 32 20 31 92 8B 92 80 92 80

Title: Draw the national flag of Iceland

Body:
Postscript 148 characters (84 bytes when using binary shortcuts)

First of all, there are two versions: One optimized for characters, and one optimized for binary shortcuts.

Golfed character version:

/s{setrgbcolor}def/R{rectfill}def 0.843 0.157 0.157 s 0 8 25 2 8 0 2 18 R R 0 0.282 0.878 s 0 0 7 7 0 11 7 7 8 copy R R 11 0 translate 2 1 scale R R

Less golfed version (character optimised):

/s {setrgbcolor} def
/R {rectfill} def
0.843 0.157 0.157 s
0 8 25 2
8 0 2 18
R
R
0 0.282 0.878 s
0 0 7 7
0 11 7 7
8 copy
R
R
11 0 translate
2 1 scale
R
R

Less golfed version (binary optimised):

0.843 0.157 0.157 setrgbcolor
0 8 25 2
8 0 2 18
rectfill
rectfill
0 0.282 0.878 setrgbcolor
0 0 7 7
0 11 7 7
8 copy
rectfill
rectfill
11 0 translate
2 1 scale
rectfill
rectfill

Hex of the binary representation version:

 30 2E 38 34 33 20 30 2E 31 35 37 20 30 2E 31 35 37 92 9D 30 20 38 88 19 32 88 08 30 20 32 88 12 92 80 92 80 30 20 30 2E 32 38 32 20 30 2E 38 37 38 92 9D 30 88 00 37 88 07 30 88 0B 37 88 07 38 92 19 92 80 92 80 88 0B 30 92 AD 32 20 31 92 8B 92 80 92 80


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

答:
Vim, <s>22</s>, 18 keystrokes

```<code>O <esc>J:h r<cr>lyEZZ<C-v>{@"
</code>```

Huge credit to @Udioica for coming up with an awesome vim answer that I expanded on. This answer does not contain any asterisks, in hopes of winning the bounty.

Explanation:

Input is typed before the rest of the program. Udioica came up with this awesome trick. Typing <n>O <esc> will create a pyramid of spaces and one empty line, as long as you have :set autoindent enabled. This option comes on by default in vim 8 and neovim, though not older versions of vim. Since this also creates an extra line, we use J to join this line with the next one, which effectively just removes the line below us.

Now at this point, we need to replace all of these spaces with asterisks. If I was not worried about using asterisks in my code, I would just visually select the whole thing <C-v>{ and type r*, which replaces each character of the selection with an asterisk. But I can't do that.

So we open up the help pages to :h r. The interesting thing about this is that in the vim-window, this page is displayed as:

```<code>                            r
r{char}         Replace the character under the cursor with {char}.
                ...
</code>```

With the cursor on the first 'r'. However, the file itself actually contains this text:

```<code>                            *r*
r{char}         Replace the character under the cursor with {char}.
                ...
</code>```

Pretty convenient. So we move over one character with l, and yank the text r* with yE ([y]ank to the [E]nd of this word).

To close this buffer, we use the shortcut to save a file ZZ. Now, we visually select our spaces, and run the yanked text as if we had typed it by doing @". This works because "@" runs the following register as vim-keystrokes, and " is the default register for yanking.

ContentLicense: CC BY-SA 4.0

Title: Draw an asterisk triangle

Body:
Vim, <s>22</s>, 18 keystrokes

O <esc>J:h r<cr>lyEZZ<C-v>{@"

Huge credit to @Udioica for coming up with an awesome vim answer that I expanded on. This answer does not contain any asterisks, in hopes of winning the bounty.

Explanation:

Input is typed before the rest of the program. Udioica came up with this awesome trick. Typing <n>O <esc> will create a pyramid of spaces and one empty line, as long as you have :set autoindent enabled. This option comes on by default in vim 8 and neovim, though not older versions of vim. Since this also creates an extra line, we use J to join this line with the next one, which effectively just removes the line below us.

Now at this point, we need to replace all of these spaces with asterisks. If I was not worried about using asterisks in my code, I would just visually select the whole thing <C-v>{ and type r*, which replaces each character of the selection with an asterisk. But I can't do that.

So we open up the help pages to :h r. The interesting thing about this is that in the vim-window, this page is displayed as:

                            r
r{char}         Replace the character under the cursor with {char}.
                ...

With the cursor on the first 'r'. However, the file itself actually contains this text:

                            *r*
r{char}         Replace the character under the cursor with {char}.
                ...

Pretty convenient. So we move over one character with l, and yank the text r* with yE ([y]ank to the [E]nd of this word).

To close this buffer, we use the shortcut to save a file ZZ. Now, we visually select our spaces, and run the yanked text as if we had typed it by doing @". This works because "@" runs the following register as vim-keystrokes, and " is the default register for yanking.

ContentLicense: CC BY-SA 3.0


问:
The 3x3 Hexa Prime Square Puzzle

The 3x3 Hexa Prime Square Puzzle

Introduction

We consider 3x3 squares of hexadecimal digits (from 0 to F) such as:

```<code>2 E 3    1 F 3
8 1 5    7 2 7
D D 5    B B 9
</code>```

We define a 3x3 Hexa Prime Square (HPS3) as such a square for which all hexadecimal numbers read from left to right and from top to bottom are odd primes (i.e. primes greater than 2).

This is true for the left square and false for the right square:

```<code>2 E 3 --> 0x2E3 = 739       1 F 3 --> 0x1F3 = 499
8 1 5 --> 0x815 = 2069      7 2 7 --> 0x727 = 1831
D D 5 --> 0xDD5 = 3541      B B 9 --> 0xBB9 = 3001
| | |                       | | |
| | +---> 0x355 = 853       | | +---> 0x379 = 889 = 7 x 127
| +-----> 0xE1D = 3613      | +-----> 0xF2B = 3883 = 11 x 353
+-------> 0x28D = 653       +-------> 0x17B = 379
</code>```

Goal

Given a list of 9 hexadecimal digits, your goal is to find an arrangement that forms a HPS3.

Example:

```<code>Input: 123558DDE
Possible output: 2E3815DD5 (a flattened representation of the above left example)
</code>```

Input / Output

Input and output formats are flexible. The only requirement is that output digits are ordered from left to right and from top to bottom. Below are some possible options:

```<code>"2E3815DD5"
[ 0x2, 0xE, 0x3, 0x8, 0x1, 0x5, 0xD, 0xD, 0x5 ]
[ "2", "E", "3", "8", "1", "5", "D", "D", "5" ]
[
  [ 0x2, 0xE, 0x3 ],
  [ 0x8, 0x1, 0x5 ],
  [ 0xD, 0xD, 0x5 ]
]
[ "2E3", "815", "DD5" ]
etc.
</code>```

Using the same format for both input and output is not required.

Rules

This is code-golf, so the shortest answer in bytes wins. Standard loopholes are forbidden.

Your algorithm must be deterministic

You can't just bogosort the array until it's valid, even in a deterministic way (by using a constant random seed).

You may list all possible solutions for a given input, but this is neither required nor subject to a bonus.

You're not required to support inputs that do not admit any solution. (It's perfectly fine if your code is looping forever or crashing in that case.)

Test cases

```<code>Input       Possible output
---------------------------
123558dde   2e3815dd5
1155578ab   a7b851551
03bddffff   ffd0dfb3f
35899beff   8f99e3bf5
15899bbdf   581bb9fd9
14667799f   6f1469779
13378bcdd   78d1cd33b
24577bbdd   7274bd5db
1118bbddd   11b18dbdd
223556cdd   623c25dd5
12557899a   8a5295971
113579bbd   5b3db7191
</code>```

答:
Mathematica, 115 bytes

```<code>#<>""&@@Select[Permutations@#,And@@(PrimeQ@#&&#>2&)/@(FromDigits[#<>"",16]&/@#~Join~Transpose@#)&[#~Partition~3]&]&
</code>```

The input must be a list of characters (e.g. {"1", "2", "3", "5", "5", "8", "D", "D", "E"})

Title: The 3x3 Hexa Prime Square Puzzle

Body:
Mathematica, 115 bytes

#<>""&@@Select[Permutations@#,And@@(PrimeQ@#&&#>2&)/@(FromDigits[#<>"",16]&/@#~Join~Transpose@#)&[#~Partition~3]&]&

The input must be a list of characters (e.g. {"1", "2", "3", "5", "5", "8", "D", "D", "E"})


问:
Tips for golfing in Python
What general tips do you have for golfing in Python? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Python (e.g. "remove comments" is not an answer).

Please post one tip per answer.

答:
If you're drawing, for colors, instead of typing:

'#000' for black you can just use 0 (no apostrophes)

'#fff' for white you can simply use ~0 (no apostrophes)

'#f00' for red you can just use 'red'

Example of white being used with ~0

```<code>from PIL.ImageDraw import*
i=Image.new('RGB',(25,18),'#d72828')
Draw(i).rectangle((1,1,23,16),'#0048e0',~0)
i.show()
</code>```

Title: Tips for golfing in Python

Body:
If you're drawing, for colors, instead of typing:

'#000' for black you can just use 0 (no apostrophes)

'#fff' for white you can simply use ~0 (no apostrophes)

'#f00' for red you can just use 'red'

Example of white being used with ~0

from PIL.ImageDraw import*
i=Image.new('RGB',(25,18),'#d72828')
Draw(i).rectangle((1,1,23,16),'#0048e0',~0)
i.show()


问:
Export The $PATH Variable, Line-By-Line
Inspired by this question on AskUbuntu.

Your job is extremely simple. Take the PATH environment variable (echo $PATH) and export it such that each entry (separated by the : character) is on its own line.

For example, if the PATH is /bin:/usr/bin:/usr/local/bin, your program should output:

```<code>/bin
/usr/bin
/usr/local/bin
</code>```

Your program may not return a leading newline, but it may return a single trailing newline. You do not need to check if the PATH is right, or that the directory exists. Your program should take no input, meaning that your program is responsible for getting the PATH itself. You may safely assume that objects in the PATH do not contain : or newlines. However, spaces are fair game.

Reference implementations are present in the answers to the question above.

Rules

This is (obviously) code-golf, so the shortest answer will win the prized green checkmark.

The accepted answer will be tested to make sure it's actually legit.

Both Windows and *nix entries are accepted.

However, if you don't explicitly specify Windows, I will try running it in Linux and fail. (If it's obvious (hi, Batch!), you don't need to specify explicitly.)

Only have one solution per answer. If you have both a Windows and *nix version, I will count the shorter one.

If two answers have the same length, I will give priority to the one with the higher vote total. If they have the same vote total, I will count the older one. If the time posted is the same, I will choose the one that executes faster. If they execute in the same amount of time, I don't know.

Leaderboard

var QUESTION_ID=96334,OVERRIDE_USER=15422;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

```

答:
Node.js, 36 bytes

```<code>_=>process.env.PATH.split`:`.join`
`
</code>```

Pretty straight forward.

Title: Export The $PATH Variable, Line-By-Line

Body:
Node.js, 36 bytes

_=>process.env.PATH.split`:`.join`
`

Pretty straight forward.


答:
Z shell (zsh), 15 bytes

<<<${PATH//:/
}
```
<p>You can test the code on Anarchy Golf: click <em>use form</em>, select <em>zsh</em>, paste the code and submit.</p>
<h2>Bash (pure), 19 bytes</h2>
<pre class="lang-zsh prettyprint-override"><code>echo "${PATH//:/
}"
</code>```

Same idea, but with Bash's less golfy syntax. Test it on Ideone.

Title: Export The $PATH Variable, Line-By-Line

Body:
Inspired by this question on AskUbuntu.

Your job is extremely simple. Take the PATH environment variable (echo $PATH) and export it such that each entry (separated by the : character) is on its own line.

For example, if the PATH is /bin:/usr/bin:/usr/local/bin, your program should output:

```<code>/bin
/usr/bin
/usr/local/bin
</code>```

Your program may not return a leading newline, but it may return a single trailing newline. You do not need to check if the PATH is right, or that the directory exists. Your program should take no input, meaning that your program is responsible for getting the PATH itself. You may safely assume that objects in the PATH do not contain : or newlines. However, spaces are fair game.

Reference implementations are present in the answers to the question above.

Rules

This is (obviously) code-golf, so the shortest answer will win the prized green checkmark.

The accepted answer will be tested to make sure it's actually legit.

Both Windows and *nix entries are accepted.

However, if you don't explicitly specify Windows, I will try running it in Linux and fail. (If it's obvious (hi, Batch!), you don't need to specify explicitly.)

Only have one solution per answer. If you have both a Windows and *nix version, I will count the shorter one.

If two answers have the same length, I will give priority to the one with the higher vote total. If they have the same vote total, I will count the older one. If the time posted is the same, I will choose the one that executes faster. If they execute in the same amount of time, I don't know.

Leaderboard

var QUESTION_ID=96334,OVERRIDE_USER=15422;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:
Z shell (zsh), 15 bytes

<<<${PATH//:/
}

You can test the code on Anarchy Golf: click use form, select zsh, paste the code and submit.

Bash (pure), 19 bytes

echo "${PATH//:/
}"

Same idea, but with Bash's less golfy syntax. Test it on Ideone.


问:
Showcase of Languages

Notes

This thread is open and unlocked only because the community decided to make an exception. Please do not use this question as evidence that you can ask similar questions here. Please do not create additional showcase questions.

This is no longer a popularity-contest, nor are snippet lengths limited by the vote tally. If you know this thread from before, please make sure you familiarize yourself with the changes.

This thread is dedicated to showing off interesting, useful, obscure, and/or unique features your favorite programming languages have to offer. This is neither a challenge nor a competition, but a collaboration effort to showcase as many programming languages as possible as well as possible.

How this works

All answers should include the name of the programming language at the top of the post, prefixed by a #.

Answers may contain one (and only one) factoid, i.e., a couple of sentences without code that describe the language.

Aside from the factoid, answers should consist of snippets of code, which can (but don't have to be) programs or functions.

The snippets do not need to be related. In fact, snippets that are too related may be redundant.

Since this is not a contest, all programming languages are welcome, whenever they were created.

Answers that contain more than a handful of code snippets should use a Stack Snippet to collapse everything except the factoid and one of the snippets.

Whenever possible, there should be only one answer per programming language. This is a community wiki, so feel free to add snippets to any answer, even if you haven't created it yourself. There is a Stack Snippet for compressing posts, which should mitigate the effect of the 30,000 character limit.

Answers that predate these guidelines should be edited. Please help updating them as needed.

Current answers, sorted alphabetically by language name

$.ajax({type:"GET",url:"https://api.stackexchange.com/2.2/questions/44680/answers?site=codegolf&filter=withbody",success:function(data){for(var i=0;i<data.items.length;i++){var temp=document.createElement('p');temp.innerHTML = data.items[i].body.split("\n")[0];$('#list').append('
' + temp.innerText || temp.textContent + '');}}})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><base href="http://codegolf.stackexchange.com"><ul id="list"></ul></code>```

答:
Charcoal

Note: All snippets will be shown as if they were entered into a clean REPL.

39 bytes

```<code>Charcoal> ＵＯＮＮO_¶_OＡＫＡαＡ№αOβＨＷψβ«Ａ§α§⌕ＡαO‽βXＡ№αOβ
</code>```

This is an animated example, so REPL output is not shown. It's also the submission for Make a Bubble-wrap simulator. It uses the AssignAtIndex (Ａ§) command, which, when used with the Cells datatype (obtainable from Peek commands), changes the canvas.

30 bytes

```<code>Charcoal> ×⁶()↙↓¹⁰↖↖¹⁰↓↓²↘⁸Ｍ↑__↖←¤:↗¤≕Pi
()()()()()()
|\3.1415926|
|:\53589793|
\::\2384626|
 \::\433832|
  \::\79502|
   \::\8841|
    \::\971|
     \::\69|
      \::\3|
       \__\|
</code>```

This is the (noncompeting) submission for Bake a Slice of Pi. It shows the (very unfinished) Wolfram Language support.

11 bytes

```<code>Charcoal> Ｇ↘↗↘↗↖↙↖↙⁵#
    #       #
   ###     ###
  #####   #####
 ####### #######
#################
 ####### #######
  #####   #####
   ###     ###
    #       #
</code>```

Polygon(:DownRight, :UpRight, :DownRight, :UpRight, :UpLeft, :DownLeft, :UpLeft, :DownLeft, 5, '#'). An example of a more complex polygon.

10 bytes

```<code>Charcoal> Ｇ↗↘←⁴*#Ｍ↓*
   #
  *#*
 #*#*#
*#*#*#*
   *
</code>```

Polygon(:UpRight, :DownRight, :Left, 4, '*#'); Move(:Down); Print('*'). An example of multi-character fill in Polygon.

9 bytes

```<code>Charcoal> ┌┐‖Ｍ↓
┌┐
└┘
</code>```

Print('┌┐');ReflectMirror(:Down). Another ASCII-art oriented builtin. Note that ┌ and ┐ count as three bytes each.

8 bytes

```<code>Charcoal> Ｐ+abcＵＢ*
**c**
**b**
cbabc
**b**
**c**
</code>```

Multiprint(:+, 'abc');SetBackground('*'). A very useful builtin in many situations.

7 bytes

```<code>Charcoal> Ｂ⁵¦⁵123
12312
1   3
3   1
2   2
13213
</code>```

Box(5, 5, '123'). Demonstrates one of the many builtins with overloads for strings of length greater than 1.

6 bytes

```<code>Charcoal> aＪ³¦³a
a

    a
</code>```

This isn't a very interesting one - Print('a');Jump(3, 3);Print('a'); but it demonstrates the separator ¦, useful when you have two numbers or two strings in a row.

5 bytes

```<code>Charcoal> Ｇ↗↘⁴_
   _
  ___
 _____
_______
</code>```

An alternate syntax for Polygon - Polygon(:UpRight, :DownRight, 4, '_'), also demonstrating its autofill feature, when the cursor does not end up in the starting position.

4 bytes

```<code>Charcoal> Ｇ+⁵a
aaaaa
aaaaa
aaaaa
aaaaa
aaaaa
</code>```

In verbose mode, this is Polygon(:+, 5, 'a'). Self-explanatory. Any identifier with a preceding : is attempted to be parsed as a direction.

3 bytes

```<code>Charcoal> ×⁶()↙↓¹⁰↖↖¹⁰↓↓²↘⁸Ｍ↑__↖←¤:↗¤≕Pi
()()()()()()
|\3.1415926|
|:\53589793|
\::\2384626|
 \::\433832|
  \::\79502|
   \::\8841|
    \::\971|
     \::\69|
      \::\3|
       \__\|
</code>```0

This is a while loop. In verbose mode this is equivalent to:

```<code>Charcoal> ×⁶()↙↓¹⁰↖↖¹⁰↓↓²↘⁸Ｍ↑__↖←¤:↗¤≕Pi
()()()()()()
|\3.1415926|
|:\53589793|
\::\2384626|
 \::\433832|
  \::\79502|
   \::\8841|
    \::\971|
     \::\69|
      \::\3|
       \__\|
</code>```1

Loop variables are automatically chosen as the first free variable (greek letter starting at iota and wrapping around after omega). Truthiness is the same as Python truthiness.

2 bytes

```<code>Charcoal> ×⁶()↙↓¹⁰↖↖¹⁰↓↓²↘⁸Ｍ↑__↖←¤:↗¤≕Pi
()()()()()()
|\3.1415926|
|:\53589793|
\::\2384626|
 \::\433832|
  \::\79502|
   \::\8841|
    \::\971|
     \::\69|
      \::\3|
       \__\|
</code>```2

This demonstrates the syntax for operators, in this case a monadic Random operator. The syntax for integers can also be seen here, which is just a run of superscript digits. This returns an integer, which is implicitly printed as a line of that length using a character in \/-| depending on the direction of the line. In verbose mode this is Random(5).

1 byte

```<code>Charcoal> a
a
</code>```

Expressions are implicitly printed if they are not preceded by a command character.

Factoid:

This language was designed specifically for ASCII-art challenges. The 95 printable ASCII characters aren't used as commands, so string literals are not delimited.

Title: Showcase of Languages

Body:
Charcoal

Note: All snippets will be shown as if they were entered into a clean REPL.

39 bytes

Charcoal> ＵＯＮＮO_¶_OＡＫＡαＡ№αOβＨＷψβ«Ａ§α§⌕ＡαO‽βXＡ№αOβ

This is an animated example, so REPL output is not shown. It's also the submission for Make a Bubble-wrap simulator. It uses the AssignAtIndex (Ａ§) command, which, when used with the Cells datatype (obtainable from Peek commands), changes the canvas.

30 bytes

Charcoal> ×⁶()↙↓¹⁰↖↖¹⁰↓↓²↘⁸Ｍ↑__↖←¤:↗¤≕Pi
()()()()()()
|\3.1415926|
|:\53589793|
\::\2384626|
 \::\433832|
  \::\79502|
   \::\8841|
    \::\971|
     \::\69|
      \::\3|
       \__\|

This is the (noncompeting) submission for Bake a Slice of Pi. It shows the (very unfinished) Wolfram Language support.

11 bytes

Charcoal> Ｇ↘↗↘↗↖↙↖↙⁵#
    #       #
   ###     ###
  #####   #####
 ####### #######
#################
 ####### #######
  #####   #####
   ###     ###
    #       #

Polygon(:DownRight, :UpRight, :DownRight, :UpRight, :UpLeft, :DownLeft, :UpLeft, :DownLeft, 5, '#'). An example of a more complex polygon.

10 bytes

Charcoal> Ｇ↗↘←⁴*#Ｍ↓*
   #
  *#*
 #*#*#
*#*#*#*
   *

Polygon(:UpRight, :DownRight, :Left, 4, '*#'); Move(:Down); Print('*'). An example of multi-character fill in Polygon.

9 bytes

Charcoal> ┌┐‖Ｍ↓
┌┐
└┘

Print('┌┐');ReflectMirror(:Down). Another ASCII-art oriented builtin. Note that ┌ and ┐ count as three bytes each.

8 bytes

Charcoal> Ｐ+abcＵＢ*
**c**
**b**
cbabc
**b**
**c**

Multiprint(:+, 'abc');SetBackground('*'). A very useful builtin in many situations.

7 bytes

Charcoal> Ｂ⁵¦⁵123
12312
1   3
3   1
2   2
13213

Box(5, 5, '123'). Demonstrates one of the many builtins with overloads for strings of length greater than 1.

6 bytes

Charcoal> aＪ³¦³a
a

    a

This isn't a very interesting one - Print('a');Jump(3, 3);Print('a'); but it demonstrates the separator ¦, useful when you have two numbers or two strings in a row.

5 bytes

Charcoal> Ｇ↗↘⁴_
   _
  ___
 _____
_______

An alternate syntax for Polygon - Polygon(:UpRight, :DownRight, 4, '_'), also demonstrating its autofill feature, when the cursor does not end up in the starting position.

4 bytes

Charcoal> Ｇ+⁵a
aaaaa
aaaaa
aaaaa
aaaaa
aaaaa

In verbose mode, this is Polygon(:+, 5, 'a'). Self-explanatory. Any identifier with a preceding : is attempted to be parsed as a direction.

3 bytes

Charcoal> ＷＳι
Enter string: a
Enter string: sdf
Enter string:

asdf

This is a while loop. In verbose mode this is equivalent to:

While(InputString()) {
    Print(i)
}

Loop variables are automatically chosen as the first free variable (greek letter starting at iota and wrapping around after omega). Truthiness is the same as Python truthiness.

2 bytes

Charcoal> ‽⁵
---

This demonstrates the syntax for operators, in this case a monadic Random operator. The syntax for integers can also be seen here, which is just a run of superscript digits. This returns an integer, which is implicitly printed as a line of that length using a character in \/-| depending on the direction of the line. In verbose mode this is Random(5).

1 byte

Charcoal> a
a

Expressions are implicitly printed if they are not preceded by a command character.

Factoid:

This language was designed specifically for ASCII-art challenges. The 95 printable ASCII characters aren't used as commands, so string literals are not delimited.


问:
Tips for golfing in The Shakespeare Programming Language
What general tips do you have for golfing in The Shakespeare Programming Language? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to SPL (e.g. "remove comments" is not an answer).

Please post one tip per answer.

答:
You don't have to switch people in conditionals.

For example,

```<code>Ajax:Is you better than the sum of a fat fat fat fat cat and a fat cat?
Puck:If so,let us return to Scene I.
</code>```

is longer than

```<code>Ajax:Is you better than the sum of a fat fat fat fat cat and a fat cat?If so,let us return to Scene I.
</code>```

Body:
You don't have to switch people in conditionals.

For example,

Ajax:Is you better than the sum of a fat fat fat fat cat and a fat cat?
Puck:If so,let us return to Scene I.

is longer than

Ajax:Is you better than the sum of a fat fat fat fat cat and a fat cat?If so,let us return to Scene I.


问:
Draw a regular polygon
The goal of this code golf is to draw a regular polygon (one with equal side lengths) given the number of sides and radius (distance from center to vertex).

The number of sides and the radius can be entered via a file, STDIN, or just a plain old variable. Use whatever is shorter in your language.

-25% of total characters/bytes if the image is actually drawn instead of ASCII art.

答:
Python 2, 222 bytes

from math import*
def f(s,r):
 r*=cos(pi/s)
 v,R=2*pi/s,[(2*t)/98.-1for t in range(99)]
 print"P1 99 99 "+" ".join(["0","1"][all(w*(w-x)+z*(z-y)>0for w,z in[(r*cos(a*v),r*sin(a*v))for a in range(s)])]for x in R for y in R)
```

Checks if a pixel is on the inner side of all hyperplanes (lines) of the polygon. The radius is touched because actually the apothem is used.

Title: Draw a regular polygon

Body:
Python 2, 222 bytes

from math import*
def f(s,r):
 r*=cos(pi/s)
 v,R=2*pi/s,[(2*t)/98.-1for t in range(99)]
 print"P1 99 99 "+" ".join(["0","1"][all(w*(w-x)+z*(z-y)>0for w,z in[(r*cos(a*v),r*sin(a*v))for a in range(s)])]for x in R for y in R)

Checks if a pixel is on the inner side of all hyperplanes (lines) of the polygon. The radius is touched because actually the apothem is used.


答:
Use shorter words

Examples:

Thy and thyself are shorter than your and yourself.

Is is shorter than are.

and more...

Title: Tips for golfing in The Shakespeare Programming Language

Body:
What general tips do you have for golfing in The Shakespeare Programming Language? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to SPL (e.g. "remove comments" is not an answer).

Please post one tip per answer.


答:
Pyth, <s>23</s> 21 bytes

```<code>f*F}R-Pd2iR16sCBc3T.p
</code>```

Times out online, but finishes in 1.5 minutes on my laptop. Takes input in quotes.

Explanation

```<code>f*F}R-Pd2iR16sCBc3T.p
                   .pQ     permutations of input (implicit Q)
f                 T        filter each T:
                c3             divide into rows
              CB               make pair (rows, columns)
             s                 join those lists
         iR16                  interpret items as hex
   }R                          check if each number d is in
      Pd                           its prime factors
     -  2                          with twos removed
 *F                            product (also known as all)
                           implicitly print matches
</code>```

Title: The 3x3 Hexa Prime Square Puzzle

Body:
The 3x3 Hexa Prime Square Puzzle

Introduction

We consider 3x3 squares of hexadecimal digits (from 0 to F) such as:

```<code>2 E 3    1 F 3
8 1 5    7 2 7
D D 5    B B 9
</code>```

We define a 3x3 Hexa Prime Square (HPS3) as such a square for which all hexadecimal numbers read from left to right and from top to bottom are odd primes (i.e. primes greater than 2).

This is true for the left square and false for the right square:

```<code>2 E 3 --> 0x2E3 = 739       1 F 3 --> 0x1F3 = 499
8 1 5 --> 0x815 = 2069      7 2 7 --> 0x727 = 1831
D D 5 --> 0xDD5 = 3541      B B 9 --> 0xBB9 = 3001
| | |                       | | |
| | +---> 0x355 = 853       | | +---> 0x379 = 889 = 7 x 127
| +-----> 0xE1D = 3613      | +-----> 0xF2B = 3883 = 11 x 353
+-------> 0x28D = 653       +-------> 0x17B = 379
</code>```

Goal

Given a list of 9 hexadecimal digits, your goal is to find an arrangement that forms a HPS3.

Example:

```<code>Input: 123558DDE
Possible output: 2E3815DD5 (a flattened representation of the above left example)
</code>```

Input / Output

Input and output formats are flexible. The only requirement is that output digits are ordered from left to right and from top to bottom. Below are some possible options:

```<code>"2E3815DD5"
[ 0x2, 0xE, 0x3, 0x8, 0x1, 0x5, 0xD, 0xD, 0x5 ]
[ "2", "E", "3", "8", "1", "5", "D", "D", "5" ]
[
  [ 0x2, 0xE, 0x3 ],
  [ 0x8, 0x1, 0x5 ],
  [ 0xD, 0xD, 0x5 ]
]
[ "2E3", "815", "DD5" ]
etc.
</code>```

Using the same format for both input and output is not required.

Rules

This is code-golf, so the shortest answer in bytes wins. Standard loopholes are forbidden.

Your algorithm must be deterministic

You can't just bogosort the array until it's valid, even in a deterministic way (by using a constant random seed).

You may list all possible solutions for a given input, but this is neither required nor subject to a bonus.

You're not required to support inputs that do not admit any solution. (It's perfectly fine if your code is looping forever or crashing in that case.)

Test cases

```<code>Input       Possible output
---------------------------
123558dde   2e3815dd5
1155578ab   a7b851551
03bddffff   ffd0dfb3f
35899beff   8f99e3bf5
15899bbdf   581bb9fd9
14667799f   6f1469779
13378bcdd   78d1cd33b
24577bbdd   7274bd5db
1118bbddd   11b18dbdd
223556cdd   623c25dd5
12557899a   8a5295971
113579bbd   5b3db7191
</code>```

Body:
Pyth, <s>23</s> 21 bytes

f*F}R-Pd2iR16sCBc3T.p

Times out online, but finishes in 1.5 minutes on my laptop. Takes input in quotes.

Explanation

f*F}R-Pd2iR16sCBc3T.p
                   .pQ     permutations of input (implicit Q)
f                 T        filter each T:
                c3             divide into rows
              CB               make pair (rows, columns)
             s                 join those lists
         iR16                  interpret items as hex
   }R                          check if each number d is in
      Pd                           its prime factors
     -  2                          with twos removed
 *F                            product (also known as all)
                           implicitly print matches


问:
Tips for golfing in Haskell
What general tips do you have for golfing in Haskell? I am looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Haskell. Please post only one tip per answer.

If you are new to golfing in Haskell, please have a look at the Guide to Golfing Rules in Haskell. There is also a dedicated Haskell chat room: Of Monads and Men.

答:
Shorter conditional

last$x:[y|b]
```

<p>is equivalent to</p>

<pre class="lang-haskell prettyprint-override"><code>if b then y else x
</code>```

Here's how it works:

             [y|b]   x:[y|b]   last$x:[y|b]
if...      +--------------------------------
b == False | []      [x]       x
b == True  | [y]     [x,y]     y
```

Title: Tips for golfing in Haskell

Body:
Shorter conditional

last$x:[y|b]

is equivalent to

if b then y else x

Here's how it works:

             [y|b]   x:[y|b]   last$x:[y|b]
if...      +--------------------------------
b == False | []      [x]       x
b == True  | [y]     [x,y]     y


答:
MATLAB, 34 bytes

```<code>disp(strrep(getenv('PATH'),58,10))
</code>```

Here is an online demo in Octave with a slight modification since strrep in octave requires the second and third inputs to be char variables rather than numeric values.

Title: Export The $PATH Variable, Line-By-Line

Body:
MATLAB, 34 bytes

disp(strrep(getenv('PATH'),58,10))

Here is an online demo in Octave with a slight modification since strrep in octave requires the second and third inputs to be char variables rather than numeric values.


答:
Dotsplit

(whoops I forgot the link before :p)

(pair of) Factoid(s):

Dotsplit is a mostly syntax free language, with odd builtins (kind of like mathematica), but is currently in it's infancy. Dotsplit is named after the tokeniser used in the interpreter: str.split(). This is a weak tokeniser, but it fulfills all needs of the language, so far anyway.

1 byte:

```<code>D
</code>```

D does

...

nothing. it isn't a tiny builtin, unless you count a nop as a builtin, and it's only a nop because it isn't a defined command. Dotsplit has relatively long command names for most things. Note that the shortest happens to be three long. anything that isn't a defined command is ignored. also note commands are case insensitive, so if it were a command, d would be the same as D

2 bytes:

still not much interesting

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

b with a leading space. This program functions identically to b, as well as D, because nops, but if b was a command, b and D would not be the same, but b and [space]b would. Spaces are used to separate commands, but otherwise are ignored. Next upvote, and we get an actual command!

3 bytes

First command!

```<code>aDd
</code>```

This will pop a and b, and push a+b. Popping from an empty stack yields 0.
hence, this program will leave one 0 on the stack. add is case insensitive, and will function regardless of case (AdD will also work)

4 bytes

There are a fair amount more commands with 4 bytes, not many still. I chose this one

```<code>derp
</code>```

This program will wait for input by the user. If input is "derp" (case-sensitive), it prints "Derp". Otherwise, "Nope"

Title: Showcase of Languages

Body:
Notes

This thread is open and unlocked only because the community decided to make an exception. Please do not use this question as evidence that you can ask similar questions here. Please do not create additional showcase questions.

This is no longer a popularity-contest, nor are snippet lengths limited by the vote tally. If you know this thread from before, please make sure you familiarize yourself with the changes.

This thread is dedicated to showing off interesting, useful, obscure, and/or unique features your favorite programming languages have to offer. This is neither a challenge nor a competition, but a collaboration effort to showcase as many programming languages as possible as well as possible.

How this works

All answers should include the name of the programming language at the top of the post, prefixed by a #.

Answers may contain one (and only one) factoid, i.e., a couple of sentences without code that describe the language.

Aside from the factoid, answers should consist of snippets of code, which can (but don't have to be) programs or functions.

The snippets do not need to be related. In fact, snippets that are too related may be redundant.

Since this is not a contest, all programming languages are welcome, whenever they were created.

Answers that contain more than a handful of code snippets should use a Stack Snippet to collapse everything except the factoid and one of the snippets.

Whenever possible, there should be only one answer per programming language. This is a community wiki, so feel free to add snippets to any answer, even if you haven't created it yourself. There is a Stack Snippet for compressing posts, which should mitigate the effect of the 30,000 character limit.

Answers that predate these guidelines should be edited. Please help updating them as needed.

Current answers, sorted alphabetically by language name

$.ajax({type:"GET",url:"https://api.stackexchange.com/2.2/questions/44680/answers?site=codegolf&filter=withbody",success:function(data){for(var i=0;i<data.items.length;i++){var temp=document.createElement('p');temp.innerHTML = data.items[i].body.split("\n")[0];$('#list').append('
' + temp.innerText || temp.textContent + '');}}})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><base href="http://codegolf.stackexchange.com"><ul id="list"></ul></code>```

Body:
Dotsplit

(whoops I forgot the link before :p)

(pair of) Factoid(s):

Dotsplit is a mostly syntax free language, with odd builtins (kind of like mathematica), but is currently in it's infancy. Dotsplit is named after the tokeniser used in the interpreter: str.split(). This is a weak tokeniser, but it fulfills all needs of the language, so far anyway.

1 byte:

D

D does

...

nothing. it isn't a tiny builtin, unless you count a nop as a builtin, and it's only a nop because it isn't a defined command. Dotsplit has relatively long command names for most things. Note that the shortest happens to be three long. anything that isn't a defined command is ignored. also note commands are case insensitive, so if it were a command, d would be the same as D

2 bytes:

still not much interesting

 b

b with a leading space. This program functions identically to b, as well as D, because nops, but if b was a command, b and D would not be the same, but b and [space]b would. Spaces are used to separate commands, but otherwise are ignored. Next upvote, and we get an actual command!

3 bytes

First command!

aDd

This will pop a and b, and push a+b. Popping from an empty stack yields 0.
hence, this program will leave one 0 on the stack. add is case insensitive, and will function regardless of case (AdD will also work)

4 bytes

There are a fair amount more commands with 4 bytes, not many still. I chose this one

derp

This program will wait for input by the user. If input is "derp" (case-sensitive), it prints "Derp". Otherwise, "Nope"


问:
Draw the rainbow
The challenge is simple: Draw a rainbow in as few bytes as possible

The specs for the rainbow are as follows:

The figure must be exactly 400 pixels wide and 200 pixels high (optionally 401x201 if you want a single center pixel)

The red ring should touch all borders of the figure (outer radius = 200 pixels)

All rings shall have the same width (10 pixels)

The violet ring shall have an inner radius of 130 pixels

The bow should be the upper half of a perfect circle

The background shall be white (transparent is also accepted)

The figure shall not have borders, (exception is made if the border can't be suppressed)

Builtin rainbow making functions are not allowed!

The following colors are to be used in the rainbow:

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

Example:

Related, but different!

Title: Draw the rainbow

Body:
Postscript (87 bytes)

Hex dump:

00000000: 3188 0131 2030 2e35 3631 8800 3120 302e  1..1 0.561..1 0.
00000010: 3237 3888 0030 2e35 3188 0030 8801 3088  278..0.51..0..0.
00000020: 0130 8801 3188 0031 2030 2e35 8800 3188  .0..1..1 0.5..1.
00000030: 0030 87c8 0038 7b34 2031 9287 929d 87c8  .0...8{4 1......
00000040: 0030 2032 9258 3087 b400 9205 9216 9242  .0 2.X0........B
00000050: 880a 92a9 7d92 83                        ....}..

Output:


问:
Draw the national flag of France
There have been many other flag challenges posted but not one for the national flag of France. This week seems like an appropriate time.

Produce this flag in the fewest bytes possible:

The image must be in a ratio of 3:2, with size at least 78 pixels wide and 52 pixels tall.

Each stripe takes up one third of the width.

The stripe colors from left to right are RGB: (0, 85, 164), (255, 255, 255), (239, 65, 53).

The image can be saved to a file or piped raw to STDOUT in any common image file format, or it can be displayed.

Alternatively, output a block of text at least 78 characters wide made of non-whitespace characters that depicts the flag, using ANSI color codes to color it. (Use standard blue, white, and red.)

Built-in flag images/libraries are not allowed.

The shortest code in bytes wins.

Leaderboard

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

Title: Draw the national flag of France

Body:
PostScript, 48 bytes

Based on earlier (supposedly dodgy) postscript entry, optimized with a loop and 2-byte synonyms, also includes exact colours.

Hex dump:

00000000: 3020 2e33 3333 202e 3634 3388 0030 881a  0 .333 .643..0..
00000010: 8834 2e39 3337 202e 3235 3520 2e32 3038  .4.937 .255 .208
00000020: 8834 3088 1a88 3432 7b92 9d92 807d 9283  .40...42{....}..


答:
Ruby, 146 bytes

Anonymous function takes an array of nine integers, returns one solution as an array of nine integers. Relies on helper function g and a require.

```<code>require'prime'
g=->x,y,z{(2<s=x<<8|y<<4|z)&&s.prime?}
->r{r.permutation{|i|a=1
3.times{|j|a&&=g[*i[j*3,3]]&&g[i[j],i[j+3],i[j+6]]}
a&&(return i)}}
</code>```

This 140-byte version prints all possible solutions, with the integers as decimals (not sure if that's allowed.)

```<code>require'prime'
g=->x,y,z{(2<s=x<<8|y<<4|z)&&s.prime?}
->r{r.permutation{|i|a=1
3.times{|j|a&&=g[*i[j*3,3]]&&g[i[j],i[j+3],i[j+6]]}
a&&p(i)}}
</code>```

Ungolfed in test program

```<code>require'prime'
g=->x,y,z{(2<s=x<<8|y<<4|z)&&   #combine 3 input values, check if >2
  s.prime?}                     #and check if prime
h=->r{
  r.permutation{|i|             #iterate over all permutations
    a=1                         #a=truthy
    3.times{|j|
      a&&=g[*i[j*3,3]]&&        #check rows (3 consecutive integers)
          g[i[j],i[j+3],i[j+6]] #and columns
    }
    a&&(return i)               #if a still truthy, return solution.
  }
}

#test cases: uncomment to run. solutions do not always match example solution from OP.
a=10;b=11;c=12;d=13;e=14;f=15
#p h[[1,2,3,5,5,8,d,d,e]]   #2e3815dd5
#p h[[1,1,5,5,5,7,8,a,b]]   #a7b851551
#p h[[0,3,b,d,d,f,f,f,f]]   #ffd0dfb3f
#p h[[3,5,8,9,9,b,e,f,f]]   #8f99e3bf5
#p h[[1,5,8,9,9,b,b,d,f]]   #581bb9fd9
#p h[[1,4,6,6,7,7,9,9,f]]   #6f1469779
#p h[[1,3,3,7,8,b,c,d,d]]   #78d1cd33b
#p h[[2,4,5,7,7,b,b,d,d]]   #7274bd5db
#p h[[1,1,1,8,b,b,d,d,d]]   #11b18dbdd
#p h[[2,2,3,5,5,6,c,d,d]]   #623c25dd5
#p h[[1,2,5,5,7,8,9,9,a]]   #8a5295971
#p h[[1,1,3,5,7,9,b,b,d]]   #5b3db7191
</code>```

Title: The 3x3 Hexa Prime Square Puzzle

Body:
Ruby, 146 bytes

Anonymous function takes an array of nine integers, returns one solution as an array of nine integers. Relies on helper function g and a require.

require'prime'
g=->x,y,z{(2<s=x<<8|y<<4|z)&&s.prime?}
->r{r.permutation{|i|a=1
3.times{|j|a&&=g[*i[j*3,3]]&&g[i[j],i[j+3],i[j+6]]}
a&&(return i)}}

This 140-byte version prints all possible solutions, with the integers as decimals (not sure if that's allowed.)

require'prime'
g=->x,y,z{(2<s=x<<8|y<<4|z)&&s.prime?}
->r{r.permutation{|i|a=1
3.times{|j|a&&=g[*i[j*3,3]]&&g[i[j],i[j+3],i[j+6]]}
a&&p(i)}}

Ungolfed in test program

require'prime'
g=->x,y,z{(2<s=x<<8|y<<4|z)&&   #combine 3 input values, check if >2
  s.prime?}                     #and check if prime
h=->r{
  r.permutation{|i|             #iterate over all permutations
    a=1                         #a=truthy
    3.times{|j|
      a&&=g[*i[j*3,3]]&&        #check rows (3 consecutive integers)
          g[i[j],i[j+3],i[j+6]] #and columns
    }
    a&&(return i)               #if a still truthy, return solution.
  }
}

#test cases: uncomment to run. solutions do not always match example solution from OP.
a=10;b=11;c=12;d=13;e=14;f=15
#p h[[1,2,3,5,5,8,d,d,e]]   #2e3815dd5
#p h[[1,1,5,5,5,7,8,a,b]]   #a7b851551
#p h[[0,3,b,d,d,f,f,f,f]]   #ffd0dfb3f
#p h[[3,5,8,9,9,b,e,f,f]]   #8f99e3bf5
#p h[[1,5,8,9,9,b,b,d,f]]   #581bb9fd9
#p h[[1,4,6,6,7,7,9,9,f]]   #6f1469779
#p h[[1,3,3,7,8,b,c,d,d]]   #78d1cd33b
#p h[[2,4,5,7,7,b,b,d,d]]   #7274bd5db
#p h[[1,1,1,8,b,b,d,d,d]]   #11b18dbdd
#p h[[2,2,3,5,5,6,c,d,d]]   #623c25dd5
#p h[[1,2,5,5,7,8,9,9,a]]   #8a5295971
#p h[[1,1,3,5,7,9,b,b,d]]   #5b3db7191


答:
GNU sed + bash, 25 bytes:

```<code>sed 's/:/\n/g' <<<"$PATH"
</code>```

If the PATH contains no directory name with whitespace, no quoting needed, 23 bytes:

```<code>sed 's/:/\n/g' <<<$PATH
</code>```

Even shorter, transliterating : to newline, thanks to @Dennis:

```<code>sed y/:/\\n/<<<"$PATH"
</code>```

Title: Export The $PATH Variable, Line-By-Line

Body:
GNU sed + bash, 25 bytes:

sed 's/:/\n/g' <<<"$PATH"

If the PATH contains no directory name with whitespace, no quoting needed, 23 bytes:

sed 's/:/\n/g' <<<$PATH

Even shorter, transliterating : to newline, thanks to @Dennis:

sed y/:/\\n/<<<"$PATH"


问:
Square, diamond, square, diamond

Task

Given a non-empty string of lowercase ASCII letters a-z, take its first character, and:

Surround it with a square of copies of the second character,

Surround that with a diamond of copies of the third character,

Surround that with a square of copies of the fourth character…

…alternating between square and diamond borders until the end of the string. Empty space between the borders should be represented by ASCII spaces ().

To add a square border, draw a square exactly around the entire current “working array”:

```<code>                                               sssssssssss
                                t              s    t    s
                               t t             s   t t   s
                              t   t            s  t   t  s
                             t aaa t           s t aaa t s
                            t  aca  t    =>    st  aca  ts
                             t aaa t           s t aaa t s
                              t   t            s  t   t  s
                               t t             s   t t   s
                                t              s    t    s
                                               sssssssssss
</code>```

To add a diamond border, draw a centered diamond shape that touches the outermost square diagonally, but not orthogonally:

```<code>                                                     s
                                                    s s
                                                   s   s
                                                  s     s
                                                 s       s
                                                s         s
                                               s           s
                    wwwwwwwwwww               s wwwwwwwwwww s
                    w    o    w              s  w    o    w  s
                    w   o o   w             s   w   o o   w   s
                    w  o   o  w            s    w  o   o  w    s
                    w o eee o w           s     w o eee o w     s
                    wo  eme  ow    =>    s      wo  eme  ow      s
                    w o eee o w           s     w o eee o w     s
                    w  o   o  w            s    w  o   o  w    s
                    w   o o   w             s   w   o o   w   s
                    w    o    w              s  w    o    w  s
                    wwwwwwwwwww               s wwwwwwwwwww s
                                               s           s
                                                s         s
                                                 s       s
                                                  s     s
                                                   s   s
                                                    s s
                                                     s
</code>```

Your program must output the final array.

Each line may contain any amount of trailing spaces.

You may output a list of strings representing lines, or a single newline-separated string with an optional trailing newline.

Leading/trailing blank lines are disallowed.

Leading columns of spaces are also disallowed.

This is code-golf. The shortest code in bytes wins.

Test cases

The above examples are expected outputs for cat, cats, meow, and meows, in reading order. Some other cases worth handling:

For the input a, your program should output:

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

For the input ab, your program should output:

```<code>bbb
bab
bbb
</code>```

For the input codegolf, your program should output:

```<code>fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
f                            l                            f
f                           l l                           f
f                          l   l                          f
f                         l     l                         f
f                        l       l                        f
f                       l         l                       f
f                      l           l                      f
f                     l             l                     f
f                    l               l                    f
f                   l                 l                   f
f                  l                   l                  f
f                 l                     l                 f
f                l                       l                f
f               l                         l               f
f              l                           l              f
f             l ooooooooooooooooooooooooooo l             f
f            l  o            g            o  l            f
f           l   o           g g           o   l           f
f          l    o          g   g          o    l          f
f         l     o         g     g         o     l         f
f        l      o        g       g        o      l        f
f       l       o       g         g       o       l       f
f      l        o      g           g      o        l      f
f     l         o     g eeeeeeeeeee g     o         l     f
f    l          o    g  e    d    e  g    o          l    f
f   l           o   g   e   d d   e   g   o           l   f
f  l            o  g    e  d   d  e    g  o            l  f
f l             o g     e d ooo d e     g o             l f
fl              og      ed  oco  de      go              lf
f l             o g     e d ooo d e     g o             l f
f  l            o  g    e  d   d  e    g  o            l  f
f   l           o   g   e   d d   e   g   o           l   f
f    l          o    g  e    d    e  g    o          l    f
f     l         o     g eeeeeeeeeee g     o         l     f
f      l        o      g           g      o        l      f
f       l       o       g         g       o       l       f
f        l      o        g       g        o      l        f
f         l     o         g     g         o     l         f
f          l    o          g   g          o    l          f
f           l   o           g g           o   l           f
f            l  o            g            o  l            f
f             l ooooooooooooooooooooooooooo l             f
f              l                           l              f
f               l                         l               f
f                l                       l                f
f                 l                     l                 f
f                  l                   l                  f
f                   l                 l                   f
f                    l               l                    f
f                     l             l                     f
f                      l           l                      f
f                       l         l                       f
f                        l       l                        f
f                         l     l                         f
f                          l   l                          f
f                           l l                           f
f                            l                            f
fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
</code>```

Reference implementation

I wrote some Julia code that your program’s output should match (at least visually). Try it online!

答:
JavaScript (ES6), 322 bytes

Non Competitive

```<code>var L=s=>{var A=Array,a,D,c,d=-1,i,k,w,O,Z,P=(u,v)=>{Z=O-(d>>1);a[D?u-v+O:u+Z][D?u+v+O-d+1:v+Z]=c},G=(c,i)=>(D=~i&1)?(d+=2,w=2*d-1):(d+=d+1,w=d);s=[...s];s.map(G);a=A(w).fill(0).map(a=>A(w).fill` `);O=w>>1;d=-1;s.map((C,i)=>{G(0,i);c=C;for(k=d;k--;)P(0,k),P(d-1,k),P(k,0),P(k,d-1)});return a.map(v=>v.join("")).join("\n")}
</code>```

Less Golphed

```<code>var L=s=>{
    var A=Array,a,D,c,d=-1,i,k,w,O,Z
    P=(u,v)=>{
        Z=O-(d>>1)
        a[D?u-v+O:u+Z][D?u+v+O-d+1:v+Z]=c},
    G=(c,i)=>(D=~i&1)?(d+=2,w=2*d-1):(d+=d+1,w=d)
    s=[...s]
    s.map(G)
    a=A(w).fill(0).map( a=>A(w).fill` `)
    O=w>>1
    d=-1
    s.map((C,i)=>{
        G(0,i)
        c=C
        for(k=d;k--;)
            P(0,k),P(d-1,k),P(k,0),P(k,d-1)})
    return a.map(v=>v.join("")).join("\n")
}
</code>```

Test  with

```<code>L("arty*")
</code>```

Easy gains by leaving out the leading var L= and .join("\n") in the return statement for -17 bytes, but type them back in to test the code :D

It's a two pass answer, evaluating the width (w) required to plot a square or diamond plot, before plotting points with P in the second pass using rotation and translation. d is the dimension (height or width) of an unrotated square before translation or rotation.

Rotation and scale by √2 details from Mathematica answer. Use of tagged string template from first answer in this thread. Thanks to both for the learning. Votes for the question and answers.

Title: Square, diamond, square, diamond

Body:
JavaScript (ES6), 322 bytes

Non Competitive

var L=s=>{var A=Array,a,D,c,d=-1,i,k,w,O,Z,P=(u,v)=>{Z=O-(d>>1);a[D?u-v+O:u+Z][D?u+v+O-d+1:v+Z]=c},G=(c,i)=>(D=~i&1)?(d+=2,w=2*d-1):(d+=d+1,w=d);s=[...s];s.map(G);a=A(w).fill(0).map(a=>A(w).fill` `);O=w>>1;d=-1;s.map((C,i)=>{G(0,i);c=C;for(k=d;k--;)P(0,k),P(d-1,k),P(k,0),P(k,d-1)});return a.map(v=>v.join("")).join("\n")}

Less Golphed

var L=s=>{
    var A=Array,a,D,c,d=-1,i,k,w,O,Z
    P=(u,v)=>{
        Z=O-(d>>1)
        a[D?u-v+O:u+Z][D?u+v+O-d+1:v+Z]=c},
    G=(c,i)=>(D=~i&1)?(d+=2,w=2*d-1):(d+=d+1,w=d)
    s=[...s]
    s.map(G)
    a=A(w).fill(0).map( a=>A(w).fill` `)
    O=w>>1
    d=-1
    s.map((C,i)=>{
        G(0,i)
        c=C
        for(k=d;k--;)
            P(0,k),P(d-1,k),P(k,0),P(k,d-1)})
    return a.map(v=>v.join("")).join("\n")
}

Test  with

L("arty*")

Easy gains by leaving out the leading var L= and .join("\n") in the return statement for -17 bytes, but type them back in to test the code :D

It's a two pass answer, evaluating the width (w) required to plot a square or diamond plot, before plotting points with P in the second pass using rotation and translation. d is the dimension (height or width) of an unrotated square before translation or rotation.

Rotation and scale by √2 details from Mathematica answer. Use of tagged string template from first answer in this thread. Thanks to both for the learning. Votes for the question and answers.


答:
Powershell, 20 bytes

```<code>$env:PATH-split':'
</code>```

Edit:

-2 bytes off. Thanks to @TimmyD

Old:

```<code>$env:PATH.split(":")
</code>```

Title: Export The $PATH Variable, Line-By-Line

Body:
Inspired by this question on AskUbuntu.

Your job is extremely simple. Take the PATH environment variable (echo $PATH) and export it such that each entry (separated by the : character) is on its own line.

For example, if the PATH is /bin:/usr/bin:/usr/local/bin, your program should output:

```<code>/bin
/usr/bin
/usr/local/bin
</code>```

Your program may not return a leading newline, but it may return a single trailing newline. You do not need to check if the PATH is right, or that the directory exists. Your program should take no input, meaning that your program is responsible for getting the PATH itself. You may safely assume that objects in the PATH do not contain : or newlines. However, spaces are fair game.

Reference implementations are present in the answers to the question above.

Rules

This is (obviously) code-golf, so the shortest answer will win the prized green checkmark.

The accepted answer will be tested to make sure it's actually legit.

Both Windows and *nix entries are accepted.

However, if you don't explicitly specify Windows, I will try running it in Linux and fail. (If it's obvious (hi, Batch!), you don't need to specify explicitly.)

Only have one solution per answer. If you have both a Windows and *nix version, I will count the shorter one.

If two answers have the same length, I will give priority to the one with the higher vote total. If they have the same vote total, I will count the older one. If the time posted is the same, I will choose the one that executes faster. If they execute in the same amount of time, I don't know.

Leaderboard

var QUESTION_ID=96334,OVERRIDE_USER=15422;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:
Powershell, 20 bytes

$env:PATH-split':'

Edit:

-2 bytes off. Thanks to @TimmyD

Old:

$env:PATH.split(":")


问:
Compute the kangaroo sequence

Backstory

Disclaimer: May contain made up information about kangaroos.

Kangaroos traverse several stages of development. As they grow older and stronger, they can jump higher and longer, and they can jump more times before they get hungry.

In stage 1, the kangaroo is very little and cannot jump at all. Despite this, is constantly requires nourishment. We can represent a stage 1 kangaroo's activity pattern like this.

```<code>o
</code>```

In stage 2, the kangaroo can make small jumps, but not more than 2 before it gets hungry. We can represent a stage 2 kangaroo's activity pattern like this.

```<code> o o
o o o
</code>```

After stage 2 the kangaroo improves quickly. In each subsequent stage, the kangaroo can jump a bit higher (1 unit in the graphical representation) and twice as many times. For example, a stage 3 kangaroo's activity pattern looks like this.

```<code>  o   o   o   o
 o o o o o o o o
o   o   o   o   o
</code>```

All that jumping requires energy, so the kangaroo requires nourishment after completing each activity pattern. The exact amount required can be calculated as follows.

Assign each o in the activity pattern of a stage n kangaroo its height, i.e., a number from 1 to n, where 1 corresponds to the ground and n to the highest position.

Compute the sum of all heights in the activity pattern.

For example, a stage 3 kangaroo's activity pattern includes the following heights.

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

We have five 1's, eight 2's, and four 3's; the sum is 5·1 + 8·2 + 4·3 = 33.

Task

Write a full program or a function that takes a positive integer n as input and prints or returns the nutritional requirements per activity of a stage n kangaroo.

This is code-golf; may the shortest answer in bytes win!

Examples

```<code> 1 ->     1
 2 ->     7
 3 ->    33
 4 ->   121
 5 ->   385
 6 ->  1121
 7 ->  3073
 8 ->  8065
 9 -> 20481
10 -> 50689
</code>```

答:
Lua, 105 bytes

```<code>s=tonumber(arg[1])e=1 for i=1,s>1 and 2^(s-1)or 0 do e=e+1 for j=2,s-1 do e=e+j*2 end e=e+s end print(e)
</code>```

De-golfed:

```<code>stage = tonumber(arg[1])
energy = 1
for i = 1, stage > 1 and 2 ^ (stage - 1) or 0 do
    energy = energy + 1
    for j = 2, stage - 1 do
        energy = energy + j * 2
    end
    energy = energy + stage
end
print(energy)
</code>```

Entertaining problem!

Title: Compute the kangaroo sequence

Body:
Lua, 105 bytes

s=tonumber(arg[1])e=1 for i=1,s>1 and 2^(s-1)or 0 do e=e+1 for j=2,s-1 do e=e+j*2 end e=e+s end print(e)

De-golfed:

stage = tonumber(arg[1])
energy = 1
for i = 1, stage > 1 and 2 ^ (stage - 1) or 0 do
    energy = energy + 1
    for j = 2, stage - 1 do
        energy = energy + j * 2
    end
    energy = energy + stage
end
print(energy)

Entertaining problem!


答:
Jelly, 6 bytes

```<code>²’æ«’‘
</code>```

Uses the formula (n2 - 1) 2n - 1 + 1 to compute each value. @Qwerp-Derp's was kind enough to provide a proof.

Try it online! or Verify all test cases.

Explanation

```<code>²’æ«’‘  Input: n
²       Square n
 ’      Decrement
  æ«    Bit shift left by
    ’     Decrement of n
     ‘  Increment
</code>```

Title: Compute the kangaroo sequence

Body:
Backstory

Disclaimer: May contain made up information about kangaroos.

Kangaroos traverse several stages of development. As they grow older and stronger, they can jump higher and longer, and they can jump more times before they get hungry.

In stage 1, the kangaroo is very little and cannot jump at all. Despite this, is constantly requires nourishment. We can represent a stage 1 kangaroo's activity pattern like this.

```<code>o
</code>```

In stage 2, the kangaroo can make small jumps, but not more than 2 before it gets hungry. We can represent a stage 2 kangaroo's activity pattern like this.

```<code> o o
o o o
</code>```

After stage 2 the kangaroo improves quickly. In each subsequent stage, the kangaroo can jump a bit higher (1 unit in the graphical representation) and twice as many times. For example, a stage 3 kangaroo's activity pattern looks like this.

```<code>  o   o   o   o
 o o o o o o o o
o   o   o   o   o
</code>```

All that jumping requires energy, so the kangaroo requires nourishment after completing each activity pattern. The exact amount required can be calculated as follows.

Assign each o in the activity pattern of a stage n kangaroo its height, i.e., a number from 1 to n, where 1 corresponds to the ground and n to the highest position.

Compute the sum of all heights in the activity pattern.

For example, a stage 3 kangaroo's activity pattern includes the following heights.

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

We have five 1's, eight 2's, and four 3's; the sum is 5·1 + 8·2 + 4·3 = 33.

Task

Write a full program or a function that takes a positive integer n as input and prints or returns the nutritional requirements per activity of a stage n kangaroo.

This is code-golf; may the shortest answer in bytes win!

Examples

```<code> 1 ->     1
 2 ->     7
 3 ->    33
 4 ->   121
 5 ->   385
 6 ->  1121
 7 ->  3073
 8 ->  8065
 9 -> 20481
10 -> 50689
</code>```

Body:
Jelly, 6 bytes

²’æ«’‘

Uses the formula (n2 - 1) 2n - 1 + 1 to compute each value. @Qwerp-Derp's was kind enough to provide a proof.

Try it online! or Verify all test cases.

Explanation

²’æ«’‘  Input: n
²       Square n
 ’      Decrement
  æ«    Bit shift left by
    ’     Decrement of n
     ‘  Increment


答:
Java, 58 bytes

```<code>System.out.print(System.getenv("Path").replace(';','\n'));
</code>```

Full program: 106 bytes

```<code>class E {
    public static void main (String[] args) {
        System.out.print(System.getenv("Path").replace(';', '\n'));
    }
}
</code>```

Title: Export The $PATH Variable, Line-By-Line

Body:
Java, 58 bytes

System.out.print(System.getenv("Path").replace(';','\n'));

Full program: 106 bytes

class E {
    public static void main (String[] args) {
        System.out.print(System.getenv("Path").replace(';', '\n'));
    }
}


答:
Python 2, <s>25</s> 23 bytes

```<code>lambda x:(x*x-1<<x-1)+1
</code>```

Used miles's formula.

Thanks to Jonathan Allan for -2 bytes.

Title: Compute the kangaroo sequence

Body:
Python 2, <s>25</s> 23 bytes

lambda x:(x*x-1<<x-1)+1

Used miles's formula.

Thanks to Jonathan Allan for -2 bytes.


答:
Coffeescript, 19 bytes

(n)->(n*n-1<<n-1)+1
```

<p>Edit: Thanks to Dennis for chopping off 6 bytes!</p>

<p>The formula for generating Kangaroo numbers is this:</p>

<p><img src="https://i.stack.imgur.com/P4608.png" alt="enter image description here"></p>

<h2>Explanation of formula:</h2>

<p>The number of <code>1</code>'s in <code>K(n)</code>'s final sum is <code>2^(n - 1) + 1</code>.</p>

<p>The number of <code>n</code>'s in <code>K(n)</code>'s final sum is <code>2^(n - 1)</code>, so the sum of all the <code>n</code>'s is <code>n * 2^(n - 1)</code>.</p>

<p>The number of any other number (<code>d</code>) in <code>K(n)</code>'s final sum is <code>2^n</code>, so the sum of all the <code>d</code>'s would be <code>d * 2^n</code>.</p>

<ul>
<li><p>Thus, the sum of all the other numbers <code>= (T(n) - (n + 1)) * 2^n</code>, where <code>T(n)</code> is the triangle number function (which has the formula <code>T(n) = (n^2 + 1) / 2</code>).</p>

<p>Substituting that in, we get the final sum </p>

```  (((n^2 + 1) / 2) - (n + 1)) * 2^n
= (((n + 1) * n / 2) - (n + 1)) * 2^n
= ((n + 1) * (n - 2) / 2) * 2^n
= 2^(n - 1) * (n + 1) * (n - 2)
```</li>
</ul>

<p>When we add together all the sums, we get <code>K(n)</code>, which equals</p>

```  (2^(n - 1) * (n + 1) * (n - 2)) + (2^(n - 1) + 1) + (n * 2^(n - 1))
= 2^(n - 1) * ((n + 1) * (n - 2) + n + 1) + 1
= 2^(n - 1) * ((n^2 - n - 2) + n + 1) + 1
= 2^(n - 1) * (n^2 - 1) + 1
```

... which is equal to the formula above.

Title: Compute the kangaroo sequence

Body:
Coffeescript, 19 bytes

(n)->(n*n-1<<n-1)+1

Edit: Thanks to Dennis for chopping off 6 bytes!

The formula for generating Kangaroo numbers is this:

Explanation of formula:

The number of 1's in K(n)'s final sum is 2^(n - 1) + 1.

The number of n's in K(n)'s final sum is 2^(n - 1), so the sum of all the n's is n * 2^(n - 1).

The number of any other number (d) in K(n)'s final sum is 2^n, so the sum of all the d's would be d * 2^n.

Thus, the sum of all the other numbers = (T(n) - (n + 1)) * 2^n, where T(n) is the triangle number function (which has the formula T(n) = (n^2 + 1) / 2).

Substituting that in, we get the final sum

  (((n^2 + 1) / 2) - (n + 1)) * 2^n
= (((n + 1) * n / 2) - (n + 1)) * 2^n
= ((n + 1) * (n - 2) / 2) * 2^n
= 2^(n - 1) * (n + 1) * (n - 2)

When we add together all the sums, we get K(n), which equals

  (2^(n - 1) * (n + 1) * (n - 2)) + (2^(n - 1) + 1) + (n * 2^(n - 1))
= 2^(n - 1) * ((n + 1) * (n - 2) + n + 1) + 1
= 2^(n - 1) * ((n^2 - n - 2) + n + 1) + 1
= 2^(n - 1) * (n^2 - 1) + 1

... which is equal to the formula above.


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

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

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

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

Points for:

Smallest code (in bytes)

Most obfuscated/obscure solution

Using esoteric/obscure languages

Successfully using languages that are difficult to golf in

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

var QUESTION_ID=69;
var OVERRIDE_USER=98;

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

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

Winners by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

 ```

答:
Shakespeare Programming Language, 6060001 bytes

Disclaimer: I do not take credit for this, the generator was made by Florian Pommerening and Thomas Mayer.

```<code>An Epic Never-Ending Saga.

Paris, a stacky person.
Pinch, impersonates Paris.
Venus, the opposite of Paris and Pinch.
Puck, continuously speaking.
Ajax, constantly complaining.
Page, perpetually blabbing.
Ford, incessantly talking.
Viola, ceaselessly communicating.

            Act I: Prelude.

        Scene I: Best things last.

[Enter Venus and Paris]

Paris:
    Let us proceed to act V.

            Act II: Remembrance.

        Scene I: Forgetful Venus.

Paris:
    Remember nothing.
    [...]
</code>```

Generator Link

Generated SPL Code

Translated C Code (requires spl.h and libspl.a from a bugfixed SPL version to compile)

Compiled binary

Title: Golf you a quine for great good!

Body:
Shakespeare Programming Language, 6060001 bytes

Disclaimer: I do not take credit for this, the generator was made by Florian Pommerening and Thomas Mayer.

An Epic Never-Ending Saga.

Paris, a stacky person.
Pinch, impersonates Paris.
Venus, the opposite of Paris and Pinch.
Puck, continuously speaking.
Ajax, constantly complaining.
Page, perpetually blabbing.
Ford, incessantly talking.
Viola, ceaselessly communicating.

            Act I: Prelude.

        Scene I: Best things last.

[Enter Venus and Paris]

Paris:
    Let us proceed to act V.

            Act II: Remembrance.

        Scene I: Forgetful Venus.

Paris:
    Remember nothing.
    [...]

Generator Link

Generated SPL Code

Translated C Code (requires spl.h and libspl.a from a bugfixed SPL version to compile)

Compiled binary


问:
How many answers does this question have?
Write a program or a function that outputs the integer number of answers this question has. Your solution should still work as more answers are added.

Languages that run in a browser may be run from the js console while on this page. Otherwise, you'd probably have to download this page. Multi-language solutions, e.g. wgeting the page and parsing it using grep is ok. Just sum up the command line and all source used.

This is code golf; shortest answer in bytes wins.

EDIT:

Let's allow at most one occourance of the url of this page to not count, either as input or in the source. No url shorteners, no data stored as get parameters etc. Quotes around url, if needed, still count. Taking the url as input is also fine. If you want to remove some part of the url, e.g. /how-many-answers..., you can, but it probably doesn't help you.

答:
99 bytes sh + curl + jq + stackexchange API

```<code>curl -s --compressed api.stackexchange.com/questions/96298/answers?site=codegolf|jq .items\|length
</code>```

Using the API, I was able to avoid issues related to page formatting and html. Unfortunately, 60 bytes of my answer are the maximally golfed url for this particular api query, and another 13 bytes for curl to unzip the resulting of the query, because stackexchange refuses to serve uncompressed data via the api.

The actual "logic" comes from curling the api to ask for a json reply with the answers to this post. That is unzipped and then piped into jq, a json parser, which extracts the "items" array and outputs its length.

You can get impressively close to having the api just return the number of answers, but from what I could come up with you could not get 100% of the way there, and getting closer would cost more bytes than just passing it through jq.

101 bytes to return {"total":}:

```<code>curl -s --compressed api.stackexchange.com/questions/96298/answers?site=codegolf&filter=!)V)MSZJUgX_
</code>```

The filter parameter in api queries is very powerful, but it falls just short of providing a "just curl a url" solution. There may be a middle ground here, where you can get a shorter response and then just count the lines or extract the number, but unfortunately filter strings are a set length, and the required jq command was already more efficient.

Body:
99 bytes sh + curl + jq + stackexchange API

curl -s --compressed api.stackexchange.com/questions/96298/answers?site=codegolf|jq .items\|length

Using the API, I was able to avoid issues related to page formatting and html. Unfortunately, 60 bytes of my answer are the maximally golfed url for this particular api query, and another 13 bytes for curl to unzip the resulting of the query, because stackexchange refuses to serve uncompressed data via the api.

The actual "logic" comes from curling the api to ask for a json reply with the answers to this post. That is unzipped and then piped into jq, a json parser, which extracts the "items" array and outputs its length.

You can get impressively close to having the api just return the number of answers, but from what I could come up with you could not get 100% of the way there, and getting closer would cost more bytes than just passing it through jq.

101 bytes to return {"total":}:

curl -s --compressed api.stackexchange.com/questions/96298/answers?site=codegolf&filter=!)V)MSZJUgX_

The filter parameter in api queries is very powerful, but it falls just short of providing a "just curl a url" solution. There may be a middle ground here, where you can get a shorter response and then just count the lines or extract the number, but unfortunately filter strings are a set length, and the required jq command was already more efficient.


答:
Java 7, 35 bytes

```<code>int c(int n){return(n*n-1<<n-1)+1;}
</code>```

Title: Compute the kangaroo sequence

Body:
Java 7, 35 bytes

int c(int n){return(n*n-1<<n-1)+1;}


答:
CJam, 11 bytes

```<code>ri_2#(\(m<)
</code>```

Try it Online.

Explanation:

```<code>r           e# Get token.       ["A"]
 i          e# Integer.         [A]
  _         e# Duplicate.       [A A]
   2#       e# Square.          [A A^2]
     (      e# Decrement.       [A A^2-1]
      \     e# Swap.            [A^2-1 A]
       (    e# Decrement.       [A^2-1 A-1]
        m<  e# Left bitshift.   [(A^2-1)*2^(A-1)]
          ) e# Increment.       [(A^2-1)*2^(A-1)+1]
            e# Implicit output.
</code>```

Title: Compute the kangaroo sequence

Body:
CJam, 11 bytes

ri_2#(\(m<)

Try it Online.

Explanation:

r           e# Get token.       ["A"]
 i          e# Integer.         [A]
  _         e# Duplicate.       [A A]
   2#       e# Square.          [A A^2]
     (      e# Decrement.       [A A^2-1]
      \     e# Swap.            [A^2-1 A]
       (    e# Decrement.       [A^2-1 A-1]
        m<  e# Left bitshift.   [(A^2-1)*2^(A-1)]
          ) e# Increment.       [(A^2-1)*2^(A-1)+1]
            e# Implicit output.