问:
Shortest infinite loop producing no output
Your task is to create the shortest infinite loop!

The point of this challenge is to create an infinite loop producing no output, unlike its possible duplicate. The reason to this is because the code might be shorter if no output is given.

Rules

Each submission must be a full program.

You must create the shortest infinite loop.

Even if your program runs out of memory eventually, it is still accepted as long as it is running the whole time from the start to when it runs out of memory. Also when it runs out of memory, it should still not print anything to STDERR.

The program must take no input (however, reading from a file is allowed), and should not print anything to STDOUT. Output to a file is also forbidden.

The program must not write anything to STDERR.

Feel free to use a language (or language version) even if it's newer than this challenge.
-Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language. :D

Submissions are scored in bytes, in an appropriate (pre-existing) encoding, usually (but not necessarily) UTF-8. Some languages, like Folders, are a bit tricky to score - if in doubt, please ask on Meta.

This is not about finding the language with the shortest infinite loop program. This is about finding the shortest infinite loop program in every language. Therefore, I will not accept an answer.

If your language of choice is a trivial variant of another (potentially more popular) language which already has an answer (think BASIC or SQL dialects, Unix shells or trivial Brainf**k-derivatives like Alphuck), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

There should be a website such as Wikipedia, Esolangs, or GitHub for the language. For example, if the language is CJam, then one could link to the site in the header like #[CJam](http://sourceforge.net/p/cjam/wiki/Home/), X bytes.

Standard loopholes are not allowed.

(I have taken some of these rules from Martin Büttner's "Hello World" challenge)

Please feel free to post in the comments to tell me how this challenge could be  improved.

Catalogue

This is a Stack Snippet which generates both an alphabetical catalogue of the used languages, and an overall leaderboard. To make sure your answer shows up, please start it with this Markdown header:

```<code># Language name, X bytes
</code>```

Obviously replacing Language name and X bytes with the proper items. If you want to link to the languages' website, use this template, as posted above:

```<code>#[Language name](http://link.to/the/language), X bytes
</code>```

Now, finally, here's the snippet: (Try pressing "Full page" for a better view.)

var QUESTION_ID=59347;var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk";var OVERRIDE_USER=41805;var answers=[],answers_hash,answer_ids,answer_page=1,more_answers=true,comment_page;function answersUrl(index){return"//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"//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,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\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,});else console.log(body)});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(''+lang+'').text();languages[lang]=languages[lang]||{lang:a.language,lang_raw:lang,user:a.user,size:a.size,link:a.link}});var langs=[];for(var lang in languages)if(languages.hasOwnProperty(lang))langs.push(languages[lang]);langs.sort(function(a,b){if(a.lang_raw.toLowerCase()>b.lang_raw.toLowerCase())return 1;if(a.lang_raw.toLowerCase()<b.lang_raw.toLowerCase())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:500px;float:left}#language-list{padding:10px;padding-right:40px;width:500px;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">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
dotsplit, 4 bytes

```<code>jump
</code>```

jump: pops number from stack, moves back that many commands

When the stack is empty, popping results in zero. Hence, it will jump on to the jump command.

In keeping with design principles, the problems this has will not be addressed, but perhaps a new command will be added, called loop-safe or something

Body:
dotsplit, 4 bytes

jump

jump: pops number from stack, moves back that many commands

When the stack is empty, popping results in zero. Hence, it will jump on to the jump command.

In keeping with design principles, the problems this has will not be addressed, but perhaps a new command will be added, called loop-safe or something


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

答:
Actually, 8 bytes

```<code>;²D@D╙*u
</code>```

Try it online!

Explanation:

This simply computes the formula (n**2 - 1)*(2**(n-1)) + 1.

```<code>;²D@D╙*u
;         duplicate n
 ²        square (n**2)
  D       decrement (n**2 - 1)
   @      swap (n)
    D     decrement (n-1)
     ╙    2**(n-1)
      *   product ((n**2 - 1)*(2**(n-1)))
       u  increment ((n**2 - 1)*(2**(n-1))+1)
</code>```

ContentLicense: CC BY-SA 3.0

Title: Compute the kangaroo sequence

Body:
Actually, 8 bytes

;²D@D╙*u

Try it online!

Explanation:

This simply computes the formula (n**2 - 1)*(2**(n-1)) + 1.

;²D@D╙*u
;         duplicate n
 ²        square (n**2)
  D       decrement (n**2 - 1)
   @      swap (n)
    D     decrement (n-1)
     ╙    2**(n-1)
      *   product ((n**2 - 1)*(2**(n-1)))
       u  increment ((n**2 - 1)*(2**(n-1))+1)


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:
Racket 33 bytes

Using formula explained by @Qwerp-Derp

(+(*(expt 2(- n 1))(-(* n n)1))1)

Ungolfed:

(define (f n)
  (+ (*(expt 2
            (- n 1))
      (-(* n n)
        1))
    1))

Testing:

(for/list((i(range 1 11)))(f i))

Output:

'(1 7 33 121 385 1121 3073 8065 20481 50689)


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

```

答:
Racket 39 bytes

Using sed command of @heemayl :

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

Ungolfed:

```<code>(define (f)
  (system "sed 's/:/\\n/g' <<<\"$PATH\"")
)
</code>```

Testing:

    (f)

Output:

```<code>/usr/local/bin
/usr/bin
/bin
/usr/games
/usr/lib/java/bin
/usr/lib/java/jre/bin
#t
</code>```

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

Body:
Racket 39 bytes

Using sed command of @heemayl :

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

Ungolfed:

(define (f)
  (system "sed 's/:/\\n/g' <<<\"$PATH\"")
)

Testing:

    (f)

Output:

/usr/local/bin
/usr/bin
/bin
/usr/games
/usr/lib/java/bin
/usr/lib/java/jre/bin
#t


答:
Pyth, 8 bytes

```<code>h.<t*QQt
</code>```

pyth.herokuapp.com

Explanation:

```<code>     Q   Input
      Q  Input
    *    Multiply
   t     Decrement
       t Decrement the input
 .<      Left bitshift
h        Increment
</code>```

Title: Compute the kangaroo sequence

Body:
Pyth, 8 bytes

h.<t*QQt

pyth.herokuapp.com

Explanation:

     Q   Input
      Q  Input
    *    Multiply
   t     Decrement
       t Decrement the input
 .<      Left bitshift
h        Increment


问:
Appease Your Google Overlords: Draw the "G" Logo
Write a program or function that takes in a positive integer N, and outputs an N×N pixel image of Google's "G" logo according to this* construction:

For example, if N is 400, a 400×400 pixel logo should be output, with correct dimensions and colors:

It should look accurate regardless of how large or small N is. e.g. here is N = 13:

Your code should not need to connect to the internet. For example, scaling an externally hosted svg is not allowed. (Scaling an svg encoded in your code would be fine though.)

Anti-aliasing may be used or not. It's up to you.

Notice that the horizontal bar of the "G" does not extend all the way to the right edge of the image. The circle curves normally inward on the right edge before it is cut off.

The shortest code in bytes wins.

* The construction of the logo has been simplified for this challenge. The correct construction can be seen here and here.

答:
Logo, 258 bytes

... because I figure logos should be made using Logo.  This is implemented as a function.  I developed it using Calormen.com's online Logo interpreter

I originally attempted to draw each segment and paint fill it, but that turned out to be bigger than expected.  There was a lot of wasted movement backtracking and such.  Instead, I decided to do a polar graph sweep, adjusting the color based on the heading.  The harder part of the math was doing the geometry for the curve at the top of the G's rectangle.  You could trim some decimals and have less accuracy, but I wanted this to be accurate to about 3 digits to accommodate typical screen sizes.

Golfed

```<code>to g:n
ht
make"a arctan 1/:n
seth 78.46
repeat 326.54/:a[make"h heading
pu fd:n/2 pd
setpc"#4285f4
if:h>135[setpc"#34a853]if:h>225[setpc"#fbbc05]if:h>315[setpc"#ea4335]bk:n*.2 pu bk:n*.3
rt:a]home bk:n*.1
filled"#4285f4[fd:n/5 rt 90 fd:n*.49 rt 90 fd:n/5]end
</code>```

Sample

g 200

Ungolfed

```<code>to g :n ; Draw a G of width/height n

hideturtle ; Hide the turtle, since she's not part of the Google logo

;Determine the proper size of the angle to rotate so that the circle stays smooth within 1 px at this size
make "a arctan 1/:n

setheading 78.46 ; Point toward the top corner of the upcoming rectangle

repeat 326.54 / :a [ ; Scoot around most of the circle, :a degrees at a time

  make"h heading ; Store heading into a variable for golfing purposes

  ; Position pen at the next stroke
  penup
  forward :n / 2
  pendown

  ; Set the pen color depending on the heading
  setpencolor "#4285f4
  if :h > 135 [ setpencolor "#34a853]
  if :h > 225 [ setpencolor "#fbbc05]
  if :h > 315 [ setpencolor "#ea4335]

  ; Draw the stroke and return to center
  back :n * .2
  penup
  back :n * .3

  right :a ; Rotate to the next sweep heading
]

; Draw the rectangle
home
back :n * .1
filled "#4285f4 [
  forward :n/5
  right 90
  forward :n * .49 ;This is just begging to be :n / 2 but I couldn't bring myself to do it.  Proper math is more like :n * (sqrt 6) / 5
  right 90
  forward :n / 5
]

end
</code>```

Body:
Logo, 258 bytes

... because I figure logos should be made using Logo.  This is implemented as a function.  I developed it using Calormen.com's online Logo interpreter

I originally attempted to draw each segment and paint fill it, but that turned out to be bigger than expected.  There was a lot of wasted movement backtracking and such.  Instead, I decided to do a polar graph sweep, adjusting the color based on the heading.  The harder part of the math was doing the geometry for the curve at the top of the G's rectangle.  You could trim some decimals and have less accuracy, but I wanted this to be accurate to about 3 digits to accommodate typical screen sizes.

Golfed

to g:n
ht
make"a arctan 1/:n
seth 78.46
repeat 326.54/:a[make"h heading
pu fd:n/2 pd
setpc"#4285f4
if:h>135[setpc"#34a853]if:h>225[setpc"#fbbc05]if:h>315[setpc"#ea4335]bk:n*.2 pu bk:n*.3
rt:a]home bk:n*.1
filled"#4285f4[fd:n/5 rt 90 fd:n*.49 rt 90 fd:n/5]end

Sample

g 200

Ungolfed

to g :n ; Draw a G of width/height n

hideturtle ; Hide the turtle, since she's not part of the Google logo

;Determine the proper size of the angle to rotate so that the circle stays smooth within 1 px at this size
make "a arctan 1/:n

setheading 78.46 ; Point toward the top corner of the upcoming rectangle

repeat 326.54 / :a [ ; Scoot around most of the circle, :a degrees at a time

  make"h heading ; Store heading into a variable for golfing purposes

  ; Position pen at the next stroke
  penup
  forward :n / 2
  pendown

  ; Set the pen color depending on the heading
  setpencolor "#4285f4
  if :h > 135 [ setpencolor "#34a853]
  if :h > 225 [ setpencolor "#fbbc05]
  if :h > 315 [ setpencolor "#ea4335]

  ; Draw the stroke and return to center
  back :n * .2
  penup
  back :n * .3

  right :a ; Rotate to the next sweep heading
]

; Draw the rectangle
home
back :n * .1
filled "#4285f4 [
  forward :n/5
  right 90
  forward :n * .49 ;This is just begging to be :n / 2 but I couldn't bring myself to do it.  Proper math is more like :n * (sqrt 6) / 5
  right 90
  forward :n / 5
]

end


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

答:
PHP, 76 (Code) + 41 (URL) = 117 bytes

```<code>preg_match_all('<h2>(.*) answers<span',file_get_contents("http://codegolf.stackexchange.com/q/96298"),$o);
echo $o[0];
</code>```

Body:
PHP, 76 (Code) + 41 (URL) = 117 bytes

preg_match_all('<h2>(.*) answers<span',file_get_contents("http://codegolf.stackexchange.com/q/96298"),$o);
echo $o[0];


答:
CMD, 2 bytes

Must be in a file named a.bat or a.cmd

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

Must be in a bat or cmd file

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

Title: Shortest infinite loop producing no output

Body:
Your task is to create the shortest infinite loop!

The point of this challenge is to create an infinite loop producing no output, unlike its possible duplicate. The reason to this is because the code might be shorter if no output is given.

Rules

Each submission must be a full program.

You must create the shortest infinite loop.

Even if your program runs out of memory eventually, it is still accepted as long as it is running the whole time from the start to when it runs out of memory. Also when it runs out of memory, it should still not print anything to STDERR.

The program must take no input (however, reading from a file is allowed), and should not print anything to STDOUT. Output to a file is also forbidden.

The program must not write anything to STDERR.

Feel free to use a language (or language version) even if it's newer than this challenge.
-Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language. :D

Submissions are scored in bytes, in an appropriate (pre-existing) encoding, usually (but not necessarily) UTF-8. Some languages, like Folders, are a bit tricky to score - if in doubt, please ask on Meta.

This is not about finding the language with the shortest infinite loop program. This is about finding the shortest infinite loop program in every language. Therefore, I will not accept an answer.

If your language of choice is a trivial variant of another (potentially more popular) language which already has an answer (think BASIC or SQL dialects, Unix shells or trivial Brainf**k-derivatives like Alphuck), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

There should be a website such as Wikipedia, Esolangs, or GitHub for the language. For example, if the language is CJam, then one could link to the site in the header like #[CJam](http://sourceforge.net/p/cjam/wiki/Home/), X bytes.

Standard loopholes are not allowed.

(I have taken some of these rules from Martin Büttner's "Hello World" challenge)

Please feel free to post in the comments to tell me how this challenge could be  improved.

Catalogue

This is a Stack Snippet which generates both an alphabetical catalogue of the used languages, and an overall leaderboard. To make sure your answer shows up, please start it with this Markdown header:

```<code># Language name, X bytes
</code>```

Obviously replacing Language name and X bytes with the proper items. If you want to link to the languages' website, use this template, as posted above:

```<code>#[Language name](http://link.to/the/language), X bytes
</code>```

Now, finally, here's the snippet: (Try pressing "Full page" for a better view.)

var QUESTION_ID=59347;var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk";var OVERRIDE_USER=41805;var answers=[],answers_hash,answer_ids,answer_page=1,more_answers=true,comment_page;function answersUrl(index){return"//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"//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,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\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,});else console.log(body)});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(''+lang+'').text();languages[lang]=languages[lang]||{lang:a.language,lang_raw:lang,user:a.user,size:a.size,link:a.link}});var langs=[];for(var lang in languages)if(languages.hasOwnProperty(lang))langs.push(languages[lang]);langs.sort(function(a,b){if(a.lang_raw.toLowerCase()>b.lang_raw.toLowerCase())return 1;if(a.lang_raw.toLowerCase()<b.lang_raw.toLowerCase())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:500px;float:left}#language-list{padding:10px;padding-right:40px;width:500px;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">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

Body:
CMD, 2 bytes

Must be in a file named a.bat or a.cmd

@a

Must be in a bat or cmd file

@%0


答:
Visity, 0 bytes

```<code>(no code)
</code>```

As this answer points out Visity wraps around producing an infinite loop.

Or more conventional (2 bytes):

```<code>[]
</code>```

Body:
Visity, 0 bytes

(no code)

As this answer points out Visity wraps around producing an infinite loop.

Or more conventional (2 bytes):

[]


答:
Vim, 19 bytes

"=$PATH<CR>p:s/:/\r/g<CR>

Grab $PATH from the expression register and paste it. Turn the :s into newlines. Nothing tricky.

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

```


答:
Unary, 695 bytes

695 zeros. Program that prints the actual code can be found here.


答:
MATL, 7 bytes

```<code>UqGqW*Q
</code>```

Uses the formula from other answers.

Try it online!

```<code>U    % Implicit input. Square
q    % Decrement by 1
G    % Push input again
q    % Decrement by 1
W    % 2 raised to that
*    % Multiply
Q    % Increment by 1. Implicit display
</code>```

Title: Compute the kangaroo sequence

Body:
MATL, 7 bytes

UqGqW*Q

Uses the formula from other answers.

Try it online!

U    % Implicit input. Square
q    % Decrement by 1
G    % Push input again
q    % Decrement by 1
W    % 2 raised to that
*    % Multiply
Q    % Increment by 1. Implicit display


答:
Ruby, 21 bytes

@Qwerp-Derp basically did the heavy lifting.

Because of the precedence in ruby, it seems we need some parens:

```<code>->(n){(n*n-1<<n-1)+1}
</code>```

Title: Compute the kangaroo sequence

Body:
Ruby, 21 bytes

@Qwerp-Derp basically did the heavy lifting.

Because of the precedence in ruby, it seems we need some parens:

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


答:
C#, 18 bytes

```<code>n=>(n*n-1<<n-1)+1;
</code>```

Anonymous function based on Qwerp-Derp's excellent mathematical analysis.

Full program with test cases:

```<code>using System;

namespace KangarooSequence
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<int,int>f= n=>(n*n-1<<n-1)+1;

            //test cases:
            for (int i = 1; i <= 10; i++)
                Console.WriteLine(i + " -> " + f(i));
            /* will display:
            1 -> 1
            2 -> 7
            3 -> 33
            4 -> 121
            5 -> 385
            6 -> 1121
            7 -> 3073
            8 -> 8065
            9 -> 20481
            10 -> 50689
            */
        }
    }
}
</code>```

Title: Compute the kangaroo sequence

Body:
C#, 18 bytes

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

Anonymous function based on Qwerp-Derp's excellent mathematical analysis.

Full program with test cases:

using System;

namespace KangarooSequence
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<int,int>f= n=>(n*n-1<<n-1)+1;

            //test cases:
            for (int i = 1; i <= 10; i++)
                Console.WriteLine(i + " -> " + f(i));
            /* will display:
            1 -> 1
            2 -> 7
            3 -> 33
            4 -> 121
            5 -> 385
            6 -> 1121
            7 -> 3073
            8 -> 8065
            9 -> 20481
            10 -> 50689
            */
        }
    }
}


答:
Scala, 23 bytes

```<code>(n:Int)=>(n*n-1<<n-1)+1
</code>```

Uses bit shift as exponentiation

Title: Compute the kangaroo sequence

Body:
Scala, 23 bytes

(n:Int)=>(n*n-1<<n-1)+1

Uses bit shift as exponentiation


答:
GolfScript, 11 bytes

```<code>~.2?(2@(?*)
</code>```

Try it online!

Thanks Martin Ender (8478) for removing 4 bytes.

Explanation:

```<code>            Implicit input                 ["A"]
~           Eval                           [A]
 .          Duplicate                      [A A]
  2         Push 2                         [A A 2]
   ?        Power                          [A A^2]
    (       Decrement                      [A A^2-1]
     2      Push 2                         [A A^2-1 2]
      @     Rotate three top elements left [A^2-1 2 A]
       (    Decrement                      [A^2-1 2 A-1]
        ?   Power                          [A^2-1 2^(A-1)]
         *  Multiply                       [(A^2-1)*2^(A-1)]
          ) Increment                      [(A^2-1)*2^(A-1)+1]
            Implicit output                []
</code>```

Title: Compute the kangaroo sequence

Body:
GolfScript, 11 bytes

~.2?(2@(?*)

Try it online!

Thanks Martin Ender (8478) for removing 4 bytes.

Explanation:

            Implicit input                 ["A"]
~           Eval                           [A]
 .          Duplicate                      [A A]
  2         Push 2                         [A A 2]
   ?        Power                          [A A^2]
    (       Decrement                      [A A^2-1]
     2      Push 2                         [A A^2-1 2]
      @     Rotate three top elements left [A^2-1 2 A]
       (    Decrement                      [A^2-1 2 A-1]
        ?   Power                          [A^2-1 2^(A-1)]
         *  Multiply                       [(A^2-1)*2^(A-1)]
          ) Increment                      [(A^2-1)*2^(A-1)+1]
            Implicit output                []


答:
Mathematica, 15 bytes

```<code>(#*#-1)2^#/2+1&
</code>```

There is no bitshift operator, so we need to do the actual exponentiation, but then it's shorter to divide by 2 instead of decrementing the exponent.

Title: Compute the kangaroo sequence

Body:
Mathematica, 15 bytes

(#*#-1)2^#/2+1&

There is no bitshift operator, so we need to do the actual exponentiation, but then it's shorter to divide by 2 instead of decrementing the exponent.


答:
Scala, 31 bytes

```<code>sys env "PATH"replace(':','\n')
</code>```

In scala, a b c is syntactic sugar for a.b(c), so this compiles to sys.env("PATH").replace(':','\n')

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

Body:
Scala, 31 bytes

sys env "PATH"replace(':','\n')

In scala, a b c is syntactic sugar for a.b(c), so this compiles to sys.env("PATH").replace(':','\n')


答:
C, 26 bytes

As a macro:

```<code>#define f(x)-~(x*x-1<<~-x)
</code>```

As a function (27):

```<code>f(x){return-~(x*x-1<<~-x);}
</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:
C, 26 bytes

As a macro:

#define f(x)-~(x*x-1<<~-x)

As a function (27):

f(x){return-~(x*x-1<<~-x);}


问:
EvenSt-ring C ode - g ol!f
An 'Even string' is any string where the parity of the ASCII values of the characters is always alternating. For example, the string EvenSt-ring$! is an even-string because the ASCII values of the characters are:

```<code>69 118 101 110 83 116 45 114 105 110 103 36 33
</code>```

And the parities of these numbers are:

```<code>Odd Even Odd Even Odd Even Odd Even Odd Even Odd Even Odd
</code>```

Which is alternating the whole way. However, a string like Hello world! is not an even string because the ASCII values are:

```<code>72 101 108 108 111 32 87 111 114 108 100 33
</code>```

And the parities are:

```<code>Even Odd Even Even Odd Even Odd Odd Even Even Even Odd
</code>```

Which is clearly not always alternating.

The challenge

You must write either a full program or a function that accepts a string for input and outputs a truthy value if the string is even, and a falsy value otherwise. You can take your input and output in any reasonable format, and you can assume that the input will only have printable ASCII (the 32-127 range). You do not have to handle empty input.

Examples

Here are some examples of even strings:

```<code>#define
EvenSt-ring$!
long
abcdABCD
3.141
~
0123456789
C ode - g ol!f
HatchingLobstersVexinglyPopulateJuvenileFoxglove
</code>```

And all of these examples are not even strings:

```<code>Hello World
PPCG
3.1415
babbage
Code-golf
Standard loopholes apply
Shortest answer in bytes wins
Happy golfing!
</code>```

You may also use this ungolfed solution to test any strings if you're curious about a certain test-case.

答:
Clean, 55 bytes

```<code>\x->all(\(a,b)->(toInt a-toInt b)rem 2>0)(zip2 x(tl x))
</code>```

Title: EvenSt-ring C ode - g ol!f

Body:
Clean, 55 bytes

\x->all(\(a,b)->(toInt a-toInt b)rem 2>0)(zip2 x(tl x))


答:
05AB1E, 7 bytes

```<code>n<¹<o*>
</code>```

Try it online!

Explanation

```<code>n<        # n^2
     *    # *
  ¹<o     # 2^(n-1)
      >   # + 1
</code>```

Title: Compute the kangaroo sequence

Body:
05AB1E, 7 bytes

n<¹<o*>

Try it online!

Explanation

n<        # n^2
     *    # *
  ¹<o     # 2^(n-1)
      >   # + 1


问:
Chebyshev Rotation
Consider a regular grid, where each cell has integer coordinates. We can group the cells into (square-shaped) "rings" where the cells in each ring have the same Chebyshev distance (or chessboard distance) from the origin. Your task is to take such a cell coordinate and rotate that cell by one position counter-clockwise within its ring. This implements the following mapping:

So for example if the input is (3, -2) you should output (3, -1). Note that (0, 0) is the only input that should map to itself.

Rules

The I/O format is fairly flexible. You can use two individual numbers, a pair/list/array/tuple of numbers, a single complex number, a string containing two numbers, etc.

You may assume that -128 < x,y < 128.

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

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

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

Test Cases

```<code>(0, 0)       => (0, 0)
(1, 0)       => (1, 1)
(1, 1)       => (0, 1)
(0, 1)       => (-1, 1)
(-1, 1)      => (-1, 0)
(-1, 0)      => (-1, -1)
(-1, -1)     => (0, -1)
(0, -1)      => (1, -1)
(1, -1)      => (1, 0)
(95, -12)    => (95, -11)
(127, 127)   => (126, 127)
(-2, 101)    => (-3, 101)
(-65, 65)    => (-65, 64)
(-127, 42)   => (-127, 41)
(-9, -9)     => (-8, -9)
(126, -127)  => (127, -127)
(105, -105)  => (105, -104)
</code>```

Title: Chebyshev Rotation

Body:
Racket 191 bytes

(cond[(= 0 x y)(list x y)][(= x y)(if(> x 0)(list(sub1 x)y)(list(add1 x)y))][(> x y)(if(>= x(abs y))
(list x(add1 y))(list(add1 x)y))][(< x y)(if(> y(abs x))(list(sub1 x)y)(list x(sub1 y)))])

Ungolfed (directly translating figure directions to code without using any intermediate formula):

(define(f x y)
  (cond
    [(= 0 x y) (list x y)]
    [(= x y)
     (if (> x 0)
         (list (sub1 x) y)   ; left
         (list (add1 x) y))] ; right
    [(> x y)
     (if (>= x (abs y))
         (list x (add1 y))   ; up
         (list (add1 x) y))] ; right
    [(< x y)
     (if (> y (abs x))
         (list (sub1 x) y)   ; left
         (list x (sub1 y)))] ; down
    ))

Testing:

(f 0  0)
(f 1  0)
(f 1  1)
(f 0  1)
(f -1  1)
(f -1  0)
(f -1  -1)
(f 0  -1)
(f 1  -1)
(f 95  -12)
(f 127  127)
(f -2  101)
(f -65  65)
(f -127  42)
(f -9  -9)
(f 126  -127)
(f 105  -105)

Output:

'(0 0)
'(1 1)
'(0 1)
'(-1 1)
'(-1 0)
'(-1 -1)
'(0 -1)
'(1 -1)
'(1 0)
'(95 -11)
'(126 127)
'(-3 101)
'(-65 64)
'(-127 41)
'(-8 -9)
'(127 -127)
'(105 -104)


答:
Scala, 184 bytes

```<code>val s=math.signum _
(x:Int,y:Int)=>{val m=x.abs max y.abs
if(x.abs==y.abs)if(s(x)==s(y))(x-s(x),y)else(x,y-s(y))else
if(x.abs==m)(x,y+Seq(0,x).indexOf(m))else(x-Seq(0,y).indexOf(m),y)}
</code>```

Ungolfed:

```<code>import math._

(x: Int, y: Int) => {
  val max = max(x.abs, y.abs)
  if (x.abs == y.abs)
    if (signum(x) == signum(y))
      (x - signum(x), y)
    else
      (x, y - signum(y))
  else
    if (x.abs == max)
      (x, y + Seq(0, x).indexOf(max))
    else
      (x - Seq(0, y).indexOf(max), y)
}
</code>```

Explanation:

```<code>val s=math.signum _             //define s as an alias to math.signum
(x:Int,y:Int)=>{                //define an anonymous function
  val m=x.abs max y.abs           //calculate the maximum of the absolute values,
                                  //which is 1 for the innermost circle and so on.
  if(x.abs==y.abs)                //if we have a cell at a corner of a circle
    if(s(x)==s(y))                  //if it's at the top-left or bottom-right, we need to
                                    //modify the x value
      (x-s(x),y)                      //if x is positive (bottom-right),
                                      //we need to return (x+1,y),
                                      //(x-1,y) If it's at the top-left.
                                      //This can be simplified to (x-s(x),y)
    else                            //for top-right and bottom-left,
      (x,y-s(y))                      //modify y in the same way.
  else                            //we don't have a corner piece
    if(x.abs==m)                    //if we're at the left or right edge of the square
      (x,y+Seq(0,x).indexOf(m))       //if it's a piece from the right edge, add one
                                      //to y, else subtract 1
    else                            //it's a piece from the top or bottm edge
      (x-Seq(0,y).indexOf(m),y)       //subtract 1 from x if it's from the top edge,
                                      //else subtract -1
}
</code>```

Title: Chebyshev Rotation

Body:
Consider a regular grid, where each cell has integer coordinates. We can group the cells into (square-shaped) "rings" where the cells in each ring have the same Chebyshev distance (or chessboard distance) from the origin. Your task is to take such a cell coordinate and rotate that cell by one position counter-clockwise within its ring. This implements the following mapping:

So for example if the input is (3, -2) you should output (3, -1). Note that (0, 0) is the only input that should map to itself.

Rules

The I/O format is fairly flexible. You can use two individual numbers, a pair/list/array/tuple of numbers, a single complex number, a string containing two numbers, etc.

You may assume that -128 < x,y < 128.

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

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

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

Test Cases

```<code>(0, 0)       => (0, 0)
(1, 0)       => (1, 1)
(1, 1)       => (0, 1)
(0, 1)       => (-1, 1)
(-1, 1)      => (-1, 0)
(-1, 0)      => (-1, -1)
(-1, -1)     => (0, -1)
(0, -1)      => (1, -1)
(1, -1)      => (1, 0)
(95, -12)    => (95, -11)
(127, 127)   => (126, 127)
(-2, 101)    => (-3, 101)
(-65, 65)    => (-65, 64)
(-127, 42)   => (-127, 41)
(-9, -9)     => (-8, -9)
(126, -127)  => (127, -127)
(105, -105)  => (105, -104)
</code>```

Body:
Scala, 184 bytes

val s=math.signum _
(x:Int,y:Int)=>{val m=x.abs max y.abs
if(x.abs==y.abs)if(s(x)==s(y))(x-s(x),y)else(x,y-s(y))else
if(x.abs==m)(x,y+Seq(0,x).indexOf(m))else(x-Seq(0,y).indexOf(m),y)}

Ungolfed:

import math._

(x: Int, y: Int) => {
  val max = max(x.abs, y.abs)
  if (x.abs == y.abs)
    if (signum(x) == signum(y))
      (x - signum(x), y)
    else
      (x, y - signum(y))
  else
    if (x.abs == max)
      (x, y + Seq(0, x).indexOf(max))
    else
      (x - Seq(0, y).indexOf(max), y)
}

Explanation:

val s=math.signum _             //define s as an alias to math.signum
(x:Int,y:Int)=>{                //define an anonymous function
  val m=x.abs max y.abs           //calculate the maximum of the absolute values,
                                  //which is 1 for the innermost circle and so on.
  if(x.abs==y.abs)                //if we have a cell at a corner of a circle
    if(s(x)==s(y))                  //if it's at the top-left or bottom-right, we need to
                                    //modify the x value
      (x-s(x),y)                      //if x is positive (bottom-right),
                                      //we need to return (x+1,y),
                                      //(x-1,y) If it's at the top-left.
                                      //This can be simplified to (x-s(x),y)
    else                            //for top-right and bottom-left,
      (x,y-s(y))                      //modify y in the same way.
  else                            //we don't have a corner piece
    if(x.abs==m)                    //if we're at the left or right edge of the square
      (x,y+Seq(0,x).indexOf(m))       //if it's a piece from the right edge, add one
                                      //to y, else subtract 1
    else                            //it's a piece from the top or bottm edge
      (x-Seq(0,y).indexOf(m),y)       //subtract 1 from x if it's from the top edge,
                                      //else subtract -1
}


问:
Tips for golfing in 05AB1E
Do you have any tips for code-golfing in 05AB1E, a golfing language created by Adnan?

Your tips should be at least somewhat specific to 05AB1E.

Please post one tip per answer.

答:
Predefined variables

They are a bit hidden in 05AB1E. Here's a list of all the predefined variables:

¾, pushes 0 if the counter_variable is not changed before this command.

X, pushes 1 if variable X is not changed before this command with U.

Y, pushes 2 if variable Y is not changed before this command with V.

®, pushes -1 if the register is not changed before this command with ©.

¯, pushes [] (empty array) if nothing is added to the global_array before this command.

¸, pushes [""] on an empty stack if there is no input. (Thank you @Emigna for finding this one.)

Title: Tips for golfing in 05AB1E

ContentLicense: CC BY-SA 4.0


答:
Batch, 30 bytes

```<code>@cmd/cset/a"(%1*%1-1<<%1-1)+1"
</code>```

Well, it beats Java anyway.

Title: Compute the kangaroo sequence

Body:
Batch, 30 bytes

@cmd/cset/a"(%1*%1-1<<%1-1)+1"

Well, it beats Java anyway.


答:
Substrings

£ is the command for taking the first b characters of string a.

ex: "hello_world"5£ -> "hello"

But if b is a list of indices it instead splits the string into parts of (upto) those sizes.

ex: "hello_world"5L£ -> ['h', 'el', 'lo_', 'worl', 'd']

Title: Tips for golfing in 05AB1E

Body:
Do you have any tips for code-golfing in 05AB1E, a golfing language created by Adnan?

Your tips should be at least somewhat specific to 05AB1E.

Please post one tip per answer.


Title: Chebyshev Rotation

Body:
JavaScript (ES6), <s>80</s> 76 bytes

(x,y,s=Math.max(x,y,-x,-y))=>(s?x+s?y-s?x-s?x++:y++:x--:y+s?y--:x++:0,[x,y])


答:
Conditionals and loops

Loops and conditionals automatically receive closing brackets at the end of a program, so you only need to add them in the code if you need to something outside of the loop/conditional.

For example, this (ungolfed) program creating a list of the first n prime numbers do not need closing brackets.
[¹¾Q#NpiNˆ¼

But if we wanted to perform some operation on the resulting list, for example taking delta's we'd need to close the loop first.
[¹¾Q#NpiNˆ¼]¯¥

Title: Tips for golfing in 05AB1E


问:
Generate a 6 character string from a 15 character alphabet
In one of our projects at work, we recently discovered a particularly large method for generating a 6 character string from a 15 character alphabet. A few of us claimed "I bet we can get that in one line" which started a little internal game of code golf.

Your task is to beat us, which I have no doubt won't take long!

The original algorithm used the alphabet 0-9A-E, but we've experimented with other alphabets. There are therefore three subtasks.

Generate a 6 character string randomly selecting from an arbitrary hardcoded 15 character alphabet like ABC123!@TPOI098. (This is just an example, and should be customizable without affecting the byte count.)

Generate a 6 character string randomly selecting from a 15 character alphabet 0123456789ABCDE.

Generate a 6 character string randomly selecting from a 15 character alphabet of your choice (printable characters only please).

Each character should have equal chance of selection and repetition should be possible.

The best we have been able to manage for each of the subtasks is:

"ABC123!@TPOI098" - 24 bytes

"0123456789ABCDE" - 21 bytes

Custom alphabet   -  13 bytes

Your score is the sum of the bytes in each subtask's solution. i.e. our score is currently 58.

We've attempted using among others, CJam and Ruby. The original was in C#. Use any language you like, but we'll be interested to see solutions in these languages particularly

答:
Pyke, 35 bytes

Arbitary alphabet, 20 bytes

```<code>6V"ABC123!@TPOI098"H
</code>```

Try it here!

Hex alphabet, 8 bytes

```<code>6V~J15<H
</code>```

Try it here!

```<code>~J15< - "0123456789abcdefghijklmno..."[:15]
</code>```

Custom alphabet, 7 bytes

```<code>6VG15<H
</code>```

Try it here!

```<code>G15< - alphabet[:15]
</code>```

Alphabet chosen: abcdefghijklmno

```<code>6V     - repeat 6 times:
  ...  -   get alphabet
     H -  choose_random(^)
</code>```

Body:
Pyke, 35 bytes

Arbitary alphabet, 20 bytes

6V"ABC123!@TPOI098"H

Try it here!

Hex alphabet, 8 bytes

6V~J15<H

Try it here!

~J15< - "0123456789abcdefghijklmno..."[:15]

Custom alphabet, 7 bytes

6VG15<H

Try it here!

G15< - alphabet[:15]

Alphabet chosen: abcdefghijklmno

6V     - repeat 6 times:
  ...  -   get alphabet
     H -  choose_random(^)


答:
Implicit input

Back in the days when 05AB1E was released, implicit input was quite new and fancy. Nowadays it seems to be necessary in order to keep track with other competitive languages (like Jelly, MATL, Pyth, etc.).

For example, when you want to add two numbers, you can do II+:

```<code>I    # Input_1.
 I   # Input_2.
  +  # Add them up.
</code>```

Test it here

However, using implicit input, we can shorten in to just 1 byte, namely +:

```<code>+    # Take two numbers implicitly and add them up.
</code>```

Test it here

This only happens when the length of the stack is smaller than the arity of the operator. A last example is 3+. The arity of the + operator is 2 while there is only 1 element in the stack:

```<code>3    # Push the number 3 on top of the stack.
 +   # Request implicit input and add to the 3.
</code>```

Test it here

Title: Tips for golfing in 05AB1E

Body:
Implicit input

Back in the days when 05AB1E was released, implicit input was quite new and fancy. Nowadays it seems to be necessary in order to keep track with other competitive languages (like Jelly, MATL, Pyth, etc.).

For example, when you want to add two numbers, you can do II+:

I    # Input_1.
 I   # Input_2.
  +  # Add them up.

Test it here

However, using implicit input, we can shorten in to just 1 byte, namely +:

+    # Take two numbers implicitly and add them up.

Test it here

This only happens when the length of the stack is smaller than the arity of the operator. A last example is 3+. The arity of the + operator is 2 while there is only 1 element in the stack:

3    # Push the number 3 on top of the stack.
 +   # Request implicit input and add to the 3.

Test it here


问:
Fraction to exact decimal
Write a program or function that given two integers a, b outputs a string containing a decimal number representing the fraction a/b exactly.

If a/b is integer, simply output the value, without a decimal dot or leading zeroes:

```<code>123562375921304812375087183597 / 2777 -> 44494913907563850333124661
81 / 3 -> 27
-6 / 2 -> -3
</code>```

If a/b is not integer but has a finite representation in base 10, output the value without leading or trailing zeroes (except a single zero before the dot):

```<code>1 / 2 -> 0.5
3289323463 / -250000000 -> -13.157293852
</code>```

Finally, if and only if (so no 0.999...) a/b is not integer and does not have a finite representation, output the finite part followed by the repeating part in parenthesis. The repeating part must be as small as possible, and start as early as possible.

```<code>-1 / 3 -> -0.(3)
235 / 14 -> 16.7(857142)
123 / 321 -> 0.(38317757009345794392523364485981308411214953271028037)
355 / 113 -> 3.(1415929203539823008849557522123893805309734513274336283185840707964601769911504424778761061946902654867256637168)
</code>```

Your program must work for all above examples in under 10 seconds on a modern desktop PC. Smallest program in bytes wins.

Title: Fraction to exact decimal

Body:
PHP, 277 Bytes

list(,$n,$d)=$argv;$a[]=$n;$n-=$d*$r[]=$n/$d^0;!$n?:$r[]=".";while($n&&!$t){$n*=10;$n-=$d*$r[]=$n/$d^0;$t=in_array($n%=$d,$a);$a[]=$n;}if($t){$l=count($a)-($p=array_search(end($a),$a));echo join(array_slice($r,0,2+$p))."(".join(array_slice($r,2+$p,$l)).")";}else echo join($r);


问:
Exploded Suffixes
Given an ASCII string, output the exploded suffixes of it. For example, if the string was abcde, there are 5 suffixes, ordered longest to shortest:

```<code>abcde
bcde
cde
de
e
</code>```

Each suffix is then exploded, meaning each character is copied as many times as its one-indexed location in that suffix. For example, exploding the suffixes of abcde,

```<code>abcde
12345
abbcccddddeeeee

bcde
1234
bccdddeeee

cde
123
cddeee

de
12
dee

e
1
e
</code>```

Altogether, the exploded suffixes of abcde are

```<code>abbcccddddeeeee
bccdddeeee
cddeee
dee
e
</code>```

Rules

This is code-golf so the shortest code wins.

The input will consist of the printable ASCII characters. (This excludes newlines but includes spaces.)

The output will have each string on a separate line.

Trailing spaces are allowed on each line and there may be an extra newline at the end.

Test Cases

```<code>''

'a'
a

'bc'
bcc
c

'xyz'
xyyzzz
yzz
z

'code-golf'
coodddeeee-----ggggggooooooollllllllfffffffff
oddeee----gggggoooooolllllllffffffff
dee---ggggooooollllllfffffff
e--gggoooolllllffffff
-ggooollllfffff
goolllffff
ollfff
lff
f

's p a c e'
s  ppp    aaaaa      ccccccc        eeeeeeeee
 pp   aaaa     cccccc       eeeeeeee
p  aaa    ccccc      eeeeeee
 aa   cccc     eeeeee
a  ccc    eeeee
 cc   eeee
c  eee
 ee
e
</code>```

答:
Pyke, 12 bytes

```<code>VilS],A*s
}t
</code>```

Try it here!

Title: Exploded Suffixes

Body:
Pyke, 12 bytes

VilS],A*s
}t

Try it here!


答:
JavaScript (ES6), <s>60</s> 59 bytes

Takes input with currying syntax (x)(y) and returns an array [new_x, new_y].

```<code>x=>y=>(x|y&&((z=x+(y<0))>-y?z>y?y++:x--:z>y?x++:y--),[x,y])
</code>```

How it works

Our main task is to determine in which quadrant we are, so that we know in which direction to move.

We can use this formula as a first approximation:

```<code>x > -y ? (x > y ? 0 : 1) : (x > y ? 2 : 3)
</code>```

Here is what we get:

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

Almost there. But the bottom left and bottom right corners of the rings are invalid. We need to shift the lower half of the matrix by one position to the left, so we define z as:

```<code>z = y < 0 ? x + 1 : x
</code>```

And we replace x with z in our formula:

```<code>z > -y ? (z > y ? 0 : 1) : (z > y ? 2 : 3)
</code>```

Which leads to:

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

The whole matrix is now correct, except for the special case [0, 0] (no move at all) which must be addressed separately.

Test cases

let f =

x=>y=>(x|y&&((z=x+(y<0))>-y?z>y?y++:x--:z>y?x++:y--),[x,y])

console.log(f(0)(0));       // => (0, 0)
console.log(f(1)(0));       // => (1, 1)
console.log(f(1)(1));       // => (0, 1)
console.log(f(0)(1));       // => (-1, 1)
console.log(f(-1)(1));      // => (-1, 0)
console.log(f(-1)(0));      // => (-1, -1)
console.log(f(-1)(-1));     // => (0, -1)
console.log(f(0)(-1));      // => (1, -1)
console.log(f(1)(-1));      // => (1, 0)
console.log(f(95)(-12));    // => (95, -11)
console.log(f(127)(127));   // => (126, 127)
console.log(f(-2)(101));    // => (-3, 101)
console.log(f(-65)(65));    // => (-65, 64)
console.log(f(-127)(42));   // => (-127, 41)
console.log(f(-9)(-9));     // => (-8, -9)
console.log(f(126)(-127));  // => (127, -127)
console.log(f(105)(-105));  // => (105, -104)```

Title: Chebyshev Rotation

Body:
JavaScript (ES6), <s>60</s> 59 bytes

Takes input with currying syntax (x)(y) and returns an array [new_x, new_y].

x=>y=>(x|y&&((z=x+(y<0))>-y?z>y?y++:x--:z>y?x++:y--),[x,y])

How it works

Our main task is to determine in which quadrant we are, so that we know in which direction to move.

We can use this formula as a first approximation:

x > -y ? (x > y ? 0 : 1) : (x > y ? 2 : 3)

Here is what we get:

3 1 1 1 1 1 1 1 1
3 3 1 1 1 1 1 1 0
3 3 3 1 1 1 1 0 0
3 3 3 3 1 1 0 0 0
3 3 3 3 3 0 0 0 0
3 3 3 3 2 2 0 0 0
3 3 3 2 2 2 2 0 0
3 3 2 2 2 2 2 2 0
3 2 2 2 2 2 2 2 2

Almost there. But the bottom left and bottom right corners of the rings are invalid. We need to shift the lower half of the matrix by one position to the left, so we define z as:

z = y < 0 ? x + 1 : x

And we replace x with z in our formula:

z > -y ? (z > y ? 0 : 1) : (z > y ? 2 : 3)

Which leads to:

3 1 1 1 1 1 1 1 1
3 3 1 1 1 1 1 1 0
3 3 3 1 1 1 1 0 0
3 3 3 3 1 1 0 0 0
3 3 3 3 3 0 0 0 0
3 3 3 2 2 0 0 0 0
3 3 2 2 2 2 0 0 0
3 2 2 2 2 2 2 0 0
2 2 2 2 2 2 2 2 0

The whole matrix is now correct, except for the special case [0, 0] (no move at all) which must be addressed separately.

Test cases

let f =

x=>y=>(x|y&&((z=x+(y<0))>-y?z>y?y++:x--:z>y?x++:y--),[x,y])

console.log(f(0)(0));       // => (0, 0)
console.log(f(1)(0));       // => (1, 1)
console.log(f(1)(1));       // => (0, 1)
console.log(f(0)(1));       // => (-1, 1)
console.log(f(-1)(1));      // => (-1, 0)
console.log(f(-1)(0));      // => (-1, -1)
console.log(f(-1)(-1));     // => (0, -1)
console.log(f(0)(-1));      // => (1, -1)
console.log(f(1)(-1));      // => (1, 0)
console.log(f(95)(-12));    // => (95, -11)
console.log(f(127)(127));   // => (126, 127)
console.log(f(-2)(101));    // => (-3, 101)
console.log(f(-65)(65));    // => (-65, 64)
console.log(f(-127)(42));   // => (-127, 41)
console.log(f(-9)(-9));     // => (-8, -9)
console.log(f(126)(-127));  // => (127, -127)
console.log(f(105)(-105));  // => (105, -104)


答:
Haskell, <s>77</s> <s>71</s> 69 bytes

```<code>x#y|y>=x,-x<y=(x-1,y)|y>x=(x,y-1)|y< -x=(x+1,y)|y<x=(x,y+1)|1>0=(0,0)
</code>```

This is just checking each of those tilted quadrants, and modifying the input accordingly. Note that the spaces are necessary, otherwise e.g. >- would be understood as an operator (which is not defined).

Thank you @nimi for removing a few more bytes!

Title: Chebyshev Rotation

Body:
Haskell, <s>77</s> <s>71</s> 69 bytes

x#y|y>=x,-x<y=(x-1,y)|y>x=(x,y-1)|y< -x=(x+1,y)|y<x=(x,y+1)|1>0=(0,0)

This is just checking each of those tilted quadrants, and modifying the input accordingly. Note that the spaces are necessary, otherwise e.g. >- would be understood as an operator (which is not defined).

Thank you @nimi for removing a few more bytes!


答:
Perl 6, <s> 28 25 </s> 24 bytes

%*ENV<PATH>.split(':')».put
```

<pre class="lang-perl6 prettyprint-override"><code>put %*ENV<PATH>~~tr/:/\n/
</code>```

put %*ENV<PATH>~~tr/:/
/
```

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:
Perl 6, <s> 28 25 </s> 24 bytes

%*ENV<PATH>.split(':')».put

put %*ENV<PATH>~~tr/:/\n/

put %*ENV<PATH>~~tr/:/
/


答:
C, <s>85</s> 84 bytes

-1 byte for using #import

#import<stdlib.h>
main(){char*a=getenv("PATH");while(*a)putchar(*a++==58?10:a[-1]);}
```

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


问:
Is this number a prime?
Believe it or not, we do not yet have a code golf challenge for a simple primality test. While it may not be the most interesting challenge, particularly for "usual" languages, it can be nontrivial in many languages.

Rosetta code features lists by language of idiomatic approaches to primality testing, one using the Miller-Rabin test specifically and another using trial division. However, "most idiomatic" often does not coincide with "shortest." In an effort to make Programming Puzzles and Code Golf the go-to site for code golf, this challenge seeks to compile a catalog of the shortest approach in every language, similar to "Hello, World!" and Golf you a quine for great good!.

Furthermore, the capability of implementing a primality test is part of our definition of programming language, so this challenge will also serve as a directory of proven programming languages.

Task

Write a full program that, given a strictly positive integer n as input, determines whether n is prime and prints a truthy or falsy value accordingly.

For the purpose of this challenge, an integer is prime if it has exactly two strictly positive divisors. Note that this excludes 1, who is its only strictly positive divisor.

Your algorithm must be deterministic (i.e., produce the correct output with probability 1) and should, in theory, work for arbitrarily large integers. In practice, you may assume that the input can be stored in your data type, as long as the program works for integers from 1 to 255.

Input

If your language is able to read from STDIN, accept command-line arguments or any other alternative form of user input, you can read the integer as its decimal representation, unary representation (using a character of your choice), byte array (big or little endian) or single byte (if this is your languages largest data type).

If (and only if) your language is unable to accept any kind of user input, you may hardcode the input in your program.

In this case, the hardcoded integer must be easily exchangeable. In particular, it may appear only in a single place in the entire program.

For scoring purposes, submit the program that corresponds to the input 1.

Output

Output has to be written to STDOUT or closest alternative.

If possible, output should consist solely of a truthy or falsy value (or a string representation thereof), optionally followed by a single newline.

The only exception to this rule is constant output of your language's interpreter that cannot be suppressed, such as a greeting, ANSI color codes or indentation.

Additional rules

This is not about finding the language with the shortest approach for prime testing, this is about finding the shortest approach in every language. Therefore, no answer will be marked as accepted.

Submissions in most languages will be scored in bytes in an appropriate preexisting encoding, usually (but not necessarily) UTF-8.

The language Piet, for example, will be scored in codels, which is the natural choice for this language.

Some languages, like Folders, are a bit tricky to score. If in doubt, please ask on Meta.

Unlike our usual rules, feel free to use a language (or language version) even if it's newer than this challenge. If anyone wants to abuse this by creating a language where the empty program performs a primality test, then congrats for paving the way for a very boring answer.

Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language.

If your language of choice is a trivial variant of another (potentially more popular) language which already has an answer (think BASIC or SQL dialects, Unix shells or trivial Brainfuck derivatives like Headsecks or Unary), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

Built-in functions for testing primality are allowed. This challenge is meant to catalog the shortest possible solution in each language, so if it's shorter to use a built-in in your language, go for it.

Unless they have been overruled earlier, all standard code-golf rules apply, including the http://meta.codegolf.stackexchange.com/q/1061.

As a side note, please don't downvote boring (but valid) answers in languages where there is not much to golf; these are still useful to this question as it tries to compile a catalog as complete as possible. However, do primarily upvote answers in languages where the author actually had to put effort into golfing the code.

Catalog

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

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

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

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

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

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

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

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

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

 <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

```

答:
PHP, <s>43 39 54 44</s> 43 bytes

improved my answer from stackoverflow:

```<code>for($i=$n=$argv[1];--$i&&$n%$i;);echo$i==1;
</code>```

Run with -r. prints 1 if argument is prime, empty string else.

loops $i down from $n-1 until it finds a divisor of $n; $n is prime if that divisor is 1.

6 bytes extra for the 1 case. almost happy.

Title: Is this number a prime?

Body:
PHP, <s>43 39 54 44</s> 43 bytes

improved my answer from stackoverflow:

for($i=$n=$argv[1];--$i&&$n%$i;);echo$i==1;

Run with -r. prints 1 if argument is prime, empty string else.

loops $i down from $n-1 until it finds a divisor of $n; $n is prime if that divisor is 1.

6 bytes extra for the 1 case. almost happy.


Title: Generate a 6 character string from a 15 character alphabet

Body:
In one of our projects at work, we recently discovered a particularly large method for generating a 6 character string from a 15 character alphabet. A few of us claimed "I bet we can get that in one line" which started a little internal game of code golf.

Your task is to beat us, which I have no doubt won't take long!

The original algorithm used the alphabet 0-9A-E, but we've experimented with other alphabets. There are therefore three subtasks.

Generate a 6 character string randomly selecting from an arbitrary hardcoded 15 character alphabet like ABC123!@TPOI098. (This is just an example, and should be customizable without affecting the byte count.)

Generate a 6 character string randomly selecting from a 15 character alphabet 0123456789ABCDE.

Generate a 6 character string randomly selecting from a 15 character alphabet of your choice (printable characters only please).

Each character should have equal chance of selection and repetition should be possible.

The best we have been able to manage for each of the subtasks is:

"ABC123!@TPOI098" - 24 bytes

"0123456789ABCDE" - 21 bytes

Custom alphabet   -  13 bytes

Your score is the sum of the bytes in each subtask's solution. i.e. our score is currently 58.

We've attempted using among others, CJam and Ruby. The original was in C#. Use any language you like, but we'll be interested to see solutions in these languages particularly

Body:
Julia (36+26+21 = 83)

join(rand(["ABC123!@TPOI098"...],6))

base(15,rand(15^6:15^7-1))

join(rand('a':'o',6))


答:
Factor, 28 bytes

for unix-likes. I dunno how to do it on Windows since I'm not at a Windows box.

```<code>"PATH"getenv ":" "\n"replace
</code>```

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

Body:
Factor, 28 bytes

for unix-likes. I dunno how to do it on Windows since I'm not at a Windows box.

"PATH"getenv ":" "\n"replace


答:
Skript/skQuery, 108 bytes

Hardcoded (43 bytes):

```<code>random 6 char string from `A@cD%F3h9JK{mN!`
</code>```

0123456789ABCDE (34 bytes):

```<code>random 6 char string from `0-9A-E`
</code>```

Choice (31 bytes):

```<code>random 6 char string from `A-M`
</code>```

Body:
Skript/skQuery, 108 bytes

Hardcoded (43 bytes):

random 6 char string from `A@cD%F3h9JK{mN!`

0123456789ABCDE (34 bytes):

random 6 char string from `0-9A-E`

Choice (31 bytes):

random 6 char string from `A-M`


答:
Haskell, 72 bytes

```<code>import System.Environment
m ':'='\n'
m x=x
map m<$>getEnv"PATH">>=putStr
</code>```

An expensive import and no replace within the standard library make it quite long.

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

Body:
Haskell, 72 bytes

import System.Environment
m ':'='\n'
m x=x
map m<$>getEnv"PATH">>=putStr

An expensive import and no replace within the standard library make it quite long.


答:
Julia, <s>38</s> 34 bytes

```<code>!z=z==0?0:z+im^int(2angle(z)/pi+1)
</code>```

Dennis saved four bytes. Thanks!

Try it online!

Title: Chebyshev Rotation

Body:
Consider a regular grid, where each cell has integer coordinates. We can group the cells into (square-shaped) "rings" where the cells in each ring have the same Chebyshev distance (or chessboard distance) from the origin. Your task is to take such a cell coordinate and rotate that cell by one position counter-clockwise within its ring. This implements the following mapping:

So for example if the input is (3, -2) you should output (3, -1). Note that (0, 0) is the only input that should map to itself.

Rules

The I/O format is fairly flexible. You can use two individual numbers, a pair/list/array/tuple of numbers, a single complex number, a string containing two numbers, etc.

You may assume that -128 < x,y < 128.

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

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

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

Test Cases

```<code>(0, 0)       => (0, 0)
(1, 0)       => (1, 1)
(1, 1)       => (0, 1)
(0, 1)       => (-1, 1)
(-1, 1)      => (-1, 0)
(-1, 0)      => (-1, -1)
(-1, -1)     => (0, -1)
(0, -1)      => (1, -1)
(1, -1)      => (1, 0)
(95, -12)    => (95, -11)
(127, 127)   => (126, 127)
(-2, 101)    => (-3, 101)
(-65, 65)    => (-65, 64)
(-127, 42)   => (-127, 41)
(-9, -9)     => (-8, -9)
(126, -127)  => (127, -127)
(105, -105)  => (105, -104)
</code>```

Body:
Julia, <s>38</s> 34 bytes

!z=z==0?0:z+im^int(2angle(z)/pi+1)

Dennis saved four bytes. Thanks!

<a href="http://julia.tryitonline.net/#code=IXo9ej09MD8wOnoraW1eaW50KDJhbmdsZSh6KS9waSsxKQoKcHJpbnRsbighKDAraW0qIDApICAgICApCnByaW50bG4oISgxK2ltKiAwKSAgICAgKQpwcmludGxuKCEoMStpbSogMSkgICAgICkKcHJpbnRsbighKDAraW0qIDEpICAgICApCnByaW50bG4oISgtMStpbSogMSkgICAgKQpwcmludGxuKCEoLTEraW0qIDApICAgICkKcHJpbnRsbighKC0xK2ltKiAtMSkgICApCnByaW50bG4oISgwK2ltKiAtMSkgICAgKQpwcmludGxuKCEoMStpbSogLTEpICAgICkKcHJpbnRsbighKDk1K2ltKiAtMTIpICApCnByaW50bG4oISgxMjcraW0qIDEyNykgKQpwcmludGxuKCEoLTIraW0qIDEwMSkgICkKcHJpbnRsbighKC02NStpbSogNjUpICApCnByaW50bG4oISgtMTI3K2ltKiA0MikgKQpwcmludGxuKCEoLTkraW0qIC05KSAgICkKcHJpbnRsbighKDEyNitpbSogLTEyNykpCnByaW50bG4oISgxMDUraW0qIC0xMDUpKQo&input=" rel="nofollow">Try it online!


答:
C (x86), 60 bytes

f(){char*p=getenv("PATH");for(;*p;p++)putchar(*p-58?*p:10);}
```

<p>This won't work on 64-bit platforms without including <em>stdlib.h</em>, since <em>getenv</em> returns an <em>int</em> (32 bits) while <em>char</em> pointers are 64 bits wide.</p>

<p>I have yet to find an online 32-bit C compiler.</p>

<h1>C (x86-64), 70 bytes</h1>

<pre class="lang-c prettyprint-override"><code>f(){char*getenv(),*p=getenv("PATH");for(;*p;p++)putchar(*p-58?*p:10);}
</code>```

Instead of including stdlib.h, we declare getenv ourselves as a function returning a char pointer.

I've tested this with gcc and clang on Linux; other setups may cry blood. Try it on Ideone.

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

Body:
C (x86), 60 bytes

f(){char*p=getenv("PATH");for(;*p;p++)putchar(*p-58?*p:10);}

This won't work on 64-bit platforms without including stdlib.h, since getenv returns an int (32 bits) while char pointers are 64 bits wide.

I have yet to find an online 32-bit C compiler.

C (x86-64), 70 bytes

f(){char*getenv(),*p=getenv("PATH");for(;*p;p++)putchar(*p-58?*p:10);}

Instead of including stdlib.h, we declare getenv ourselves as a function returning a char pointer.

I've tested this with gcc and clang on Linux; other setups may cry blood. Try it on Ideone.


答:
Vitsy, 27 + <s>24</s> 22 + <s>13</s> 10 = <s>64</s> <s>62</s> 59 bytes

#1:

```<code>"ABC123!@TPOI098"6\[eR2+@O]
</code>```

Try it online!

#2:

```<code>aH7+D4+H6\[eR2+@68*+O]
</code>```

Try it online!

#3:

```<code>6\[eR5F-O]
</code>```

Where the available characters are:

```<code>ﾖﾕﾔﾓﾒﾑﾐﾏﾎﾍﾌﾋﾊﾉﾈ
</code>```

Try it online!

Body:
Vitsy, 27 + <s>24</s> 22 + <s>13</s> 10 = <s>64</s> <s>62</s> 59 bytes

#1:

"ABC123!@TPOI098"6\[eR2+@O]

Try it online!

#2:

aH7+D4+H6\[eR2+@68*+O]

Try it online!

#3:

6\[eR5F-O]

Where the available characters are:

ﾖﾕﾔﾓﾒﾑﾐﾏﾎﾍﾌﾋﾊﾉﾈ

Try it online!


答:
Batch, 121 bytes

```<code>set i=2
if %1%==2 exit /b
if %1%==1 echo 0
:b
set /a a=%1%%%i%
set /a i=%i%+1
if %i%==%1% exit /b
if %a%==0 echo 0
goto b
</code>```

Outputs 0 if it's no prime. This works only for inputs input > 0.

Title: Is this number a prime?

Body:
Believe it or not, we do not yet have a code golf challenge for a simple primality test. While it may not be the most interesting challenge, particularly for "usual" languages, it can be nontrivial in many languages.

Rosetta code features lists by language of idiomatic approaches to primality testing, one using the Miller-Rabin test specifically and another using trial division. However, "most idiomatic" often does not coincide with "shortest." In an effort to make Programming Puzzles and Code Golf the go-to site for code golf, this challenge seeks to compile a catalog of the shortest approach in every language, similar to "Hello, World!" and Golf you a quine for great good!.

Furthermore, the capability of implementing a primality test is part of our definition of programming language, so this challenge will also serve as a directory of proven programming languages.

Task

Write a full program that, given a strictly positive integer n as input, determines whether n is prime and prints a truthy or falsy value accordingly.

For the purpose of this challenge, an integer is prime if it has exactly two strictly positive divisors. Note that this excludes 1, who is its only strictly positive divisor.

Your algorithm must be deterministic (i.e., produce the correct output with probability 1) and should, in theory, work for arbitrarily large integers. In practice, you may assume that the input can be stored in your data type, as long as the program works for integers from 1 to 255.

Input

If your language is able to read from STDIN, accept command-line arguments or any other alternative form of user input, you can read the integer as its decimal representation, unary representation (using a character of your choice), byte array (big or little endian) or single byte (if this is your languages largest data type).

If (and only if) your language is unable to accept any kind of user input, you may hardcode the input in your program.

In this case, the hardcoded integer must be easily exchangeable. In particular, it may appear only in a single place in the entire program.

For scoring purposes, submit the program that corresponds to the input 1.

Output

Output has to be written to STDOUT or closest alternative.

If possible, output should consist solely of a truthy or falsy value (or a string representation thereof), optionally followed by a single newline.

The only exception to this rule is constant output of your language's interpreter that cannot be suppressed, such as a greeting, ANSI color codes or indentation.

Additional rules

This is not about finding the language with the shortest approach for prime testing, this is about finding the shortest approach in every language. Therefore, no answer will be marked as accepted.

Submissions in most languages will be scored in bytes in an appropriate preexisting encoding, usually (but not necessarily) UTF-8.

The language Piet, for example, will be scored in codels, which is the natural choice for this language.

Some languages, like Folders, are a bit tricky to score. If in doubt, please ask on Meta.

Unlike our usual rules, feel free to use a language (or language version) even if it's newer than this challenge. If anyone wants to abuse this by creating a language where the empty program performs a primality test, then congrats for paving the way for a very boring answer.

Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language.

If your language of choice is a trivial variant of another (potentially more popular) language which already has an answer (think BASIC or SQL dialects, Unix shells or trivial Brainfuck derivatives like Headsecks or Unary), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

Built-in functions for testing primality are allowed. This challenge is meant to catalog the shortest possible solution in each language, so if it's shorter to use a built-in in your language, go for it.

Unless they have been overruled earlier, all standard code-golf rules apply, including the http://meta.codegolf.stackexchange.com/q/1061.

As a side note, please don't downvote boring (but valid) answers in languages where there is not much to golf; these are still useful to this question as it tries to compile a catalog as complete as possible. However, do primarily upvote answers in languages where the author actually had to put effort into golfing the code.

Catalog

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

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

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

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

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

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

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

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

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

 <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

```

Body:
Batch, 121 bytes

set i=2
if %1%==2 exit /b
if %1%==1 echo 0
:b
set /a a=%1%%%i%
set /a i=%i%+1
if %i%==%1% exit /b
if %a%==0 echo 0
goto b

Outputs 0 if it's no prime. This works only for inputs input > 0.


答:
R, 26 bytes

Shamelessly applying the formula

```<code>n=scan();2^(n-1)*(n^2-1)+1
</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:
R, 26 bytes

Shamelessly applying the formula

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