问:
Print all integers
Write a program or function which will provably print all integers exactly once given infinite time and memory.

Possible outputs could be:

```<code>0, 1, -1, 2, -2, 3, -3, 4, -4, …

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -2, -3, -4, -5, -6, -7, -8, -9, 10, 11, …
</code>```

This is not a valid output, as this would never enumerate negative numbers:

<s>```0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, …```</s>

The output must be in decimal, unless your language does not support decimal integer (in that case use the natural representation of integers your language uses).

Your program has to work up to the numbers with the biggest magnitude of the standard integer type of your language.

Each integer must be separated from the next using any separator (a space, a comma, a linebreak, etc.) that is not a digit nor the negative sign of your language.

The separator must not change at any point.

The separator can consist of multiple characters, as long as none of them is a digit nor the negative sign (e.g. ,  is as valid as just ,).

Any supported integer must eventually be printed after a finite amount of time.

Scoring

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

Leaderboard

var QUESTION_ID=93441,OVERRIDE_USER=41723;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

```

答:
Shakespeare Programming Language, 227 bytes

```<code>.
Ajax,.
Puck,.
Act I:
Scene I:
[Enter Ajax,Puck]
Puck:You ox!
Ajax:Be me without myself.Open thy heart.
Scene II:
Ajax:Be thyself and ash.Open thy heart.Be me times you.Open thy heart.Be me times you.Let us return to scene II.
</code>```

Obviously, this answer is nowhere near winning, but I liked that this is a use case that the SPL is comparatively well suited to.

Explained:

```<code>// Everything before the first dot is the play's title, the parser treats it as a comment.
.

// Dramatis personae. Must be characters from Shakespeare's plays, again with a comment.
Ajax,.
Puck,.

// Acts and scenes serve as labels. Like the whole play, they can have titles too,
// but for the sake of golfing I didn't give them any.
Act I:

// This scene would've been named "You are nothing"
Scene I:

// Characters can talk to each other when on stage
[Enter Ajax,Puck]

// Characters can assign each other values by talking. Nice nouns = 1, ugly nouns = -1.
Puck: You ox!                 // Assignment: $ajax = -1;
Ajax: Be me without myself.   // Arithmetic: $puck = $ajax - $ajax;
      Open thy heart.         // Standard output in numerical form: echo $puck;

// Working title "The circle of life"
Scene II:

// Poor Ajax always doing all the work for us
Ajax: Be thyself and ash.          // $puck = $puck + (-1);
      Open thy heart.              // echo $puck;
      Be me times you.             // $puck *= $ajax;  (remember $ajax==-1 from scene I)
      Open thy heart.              // echo $puck;
      Be me times you.             // negate again
      Let us return to scene II.   // infinite goto loop
</code>```

As you can see when comparing this code to my answer to the related challenge to count up forever (i.e. print all natural numbers), SPL code length grows rather badly when problem size increases...

Title: Print all integers

Body:
Shakespeare Programming Language, 227 bytes

.
Ajax,.
Puck,.
Act I:
Scene I:
[Enter Ajax,Puck]
Puck:You ox!
Ajax:Be me without myself.Open thy heart.
Scene II:
Ajax:Be thyself and ash.Open thy heart.Be me times you.Open thy heart.Be me times you.Let us return to scene II.

Obviously, this answer is nowhere near winning, but I liked that this is a use case that the SPL is comparatively well suited to.

Explained:

// Everything before the first dot is the play's title, the parser treats it as a comment.
.

// Dramatis personae. Must be characters from Shakespeare's plays, again with a comment.
Ajax,.
Puck,.

// Acts and scenes serve as labels. Like the whole play, they can have titles too,
// but for the sake of golfing I didn't give them any.
Act I:

// This scene would've been named "You are nothing"
Scene I:

// Characters can talk to each other when on stage
[Enter Ajax,Puck]

// Characters can assign each other values by talking. Nice nouns = 1, ugly nouns = -1.
Puck: You ox!                 // Assignment: $ajax = -1;
Ajax: Be me without myself.   // Arithmetic: $puck = $ajax - $ajax;
      Open thy heart.         // Standard output in numerical form: echo $puck;

// Working title "The circle of life"
Scene II:

// Poor Ajax always doing all the work for us
Ajax: Be thyself and ash.          // $puck = $puck + (-1);
      Open thy heart.              // echo $puck;
      Be me times you.             // $puck *= $ajax;  (remember $ajax==-1 from scene I)
      Open thy heart.              // echo $puck;
      Be me times you.             // negate again
      Let us return to scene II.   // infinite goto loop

As you can see when comparing this code to my answer to the related challenge to count up forever (i.e. print all natural numbers), SPL code length grows rather badly when problem size increases...


问:
Output the largest number with the fewest digits
Given a nonempty list of positive decimal integers, output the largest number from the set of numbers with the fewest digits.

The input list will not be in any particular order and may contain repeated values.

Examples:

```<code>[1] -> 1
[9] -> 9
[1729] -> 1729
[1, 1] -> 1
[34, 3] -> 3
[38, 39] -> 39
[409, 12, 13] -> 13
[11, 11, 11, 1] -> 1
[11, 11, 11, 11] -> 11
[78, 99, 620, 1] -> 1
[78, 99, 620, 10] -> 99
[78, 99, 620, 100] -> 99
[1, 5, 9, 12, 63, 102] -> 9
[3451, 29820, 2983, 1223, 1337] -> 3451
[738, 2383, 281, 938, 212, 1010] -> 938
</code>```

The shortest code in bytes wins.

答:
Bash + coreutils, 58 bytes

d=`sort -n`;egrep ^.{`sed q<<<"$d"|wc -L`}$<<<"$d"|tail -1
```

<p>Input format is one value per line. Golfing suggestions are welcomed.</p>

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

<pre class="lang-sh prettyprint-override"><code>d=`sort -n`                             #save the list in ascending numerical order
egrep ^.{                    }$<<<"$d"  #print only list lines having as many chars
         `sed q<<<"$d"|wc -L`                 #as the first sorted line does
|tail -1                                #and then get the last one (the answer)
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Bash + coreutils, 58 bytes

d=`sort -n`;egrep ^.{`sed q<<<"$d"|wc -L`}$<<<"$d"|tail -1

Input format is one value per line. Golfing suggestions are welcomed.

Explanation:

d=`sort -n`                             #save the list in ascending numerical order
egrep ^.{                    }$<<<"$d"  #print only list lines having as many chars
         `sed q<<<"$d"|wc -L`                 #as the first sorted line does
|tail -1                                #and then get the last one (the answer)


问:
String Distance

Challenge

Given an input of an all-lowercase string [a-z], output the total distance between the letters.

Example

```<code>Input: golf

Distance from g to o : 8
Distance from o to l : 3
Distance from l to f : 6

Output: 17
</code>```

Rules

Standard loopholes forbidden

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

The alphabet can be traversed from either direction. You must always use the shortest path. (i.e the distance between x and c is 5).

Test cases

```<code>Input: aa
Output: 0

Input: stack
Output: 18

Input: zaza
Output: 3

Input: valleys
Output: 35
</code>```

答:
Haskell, <s>57</s> 56 bytes

```<code>q=map$(-)13.abs
sum.q.q.(zipWith(-)=<<tail).map fromEnum
</code>```

Usage example: sum.q.q.(zipWith(-)=<<tail).map fromEnum $ "valleys" -> 35.

How it works:

```<code>q=map$(-)13.abs                -- helper function.
                               -- Non-pointfree: q l = map (\e -> 13 - abs e) l
                               -- foreach element e in list l: subtract the
                               -- absolute value of e from 13

               map fromEnum    -- convert to ascii values
      zipWith(-)=<<tail        -- build differences of neighbor elements
  q.q                          -- apply q twice on every element
sum                            -- sum it up
</code>```

Edit: @Damien saved one byte. Thanks!

Title: String Distance

Body:
Haskell, <s>57</s> 56 bytes

q=map$(-)13.abs
sum.q.q.(zipWith(-)=<<tail).map fromEnum

Usage example: sum.q.q.(zipWith(-)=<<tail).map fromEnum $ "valleys" -> 35.

How it works:

q=map$(-)13.abs                -- helper function.
                               -- Non-pointfree: q l = map (\e -> 13 - abs e) l
                               -- foreach element e in list l: subtract the
                               -- absolute value of e from 13

               map fromEnum    -- convert to ascii values
      zipWith(-)=<<tail        -- build differences of neighbor elements
  q.q                          -- apply q twice on every element
sum                            -- sum it up

Edit: @Damien saved one byte. Thanks!


答:
Burlesque, 12 bytes

```<code>0R@J-1?*_+[-
</code>```

You can try a restricted version here.

```<code>0R@  Range from 0 to Infinity
J    Duplicate
-1?* Multiply one Block by -1 (negative integeres)
_+   Concatenate
[-   Tail to Remove the duplicate zero
</code>```

Title: Print all integers

Body:
Write a program or function which will provably print all integers exactly once given infinite time and memory.

Possible outputs could be:

```<code>0, 1, -1, 2, -2, 3, -3, 4, -4, …

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -2, -3, -4, -5, -6, -7, -8, -9, 10, 11, …
</code>```

This is not a valid output, as this would never enumerate negative numbers:

<s>```0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, …```</s>

The output must be in decimal, unless your language does not support decimal integer (in that case use the natural representation of integers your language uses).

Your program has to work up to the numbers with the biggest magnitude of the standard integer type of your language.

Each integer must be separated from the next using any separator (a space, a comma, a linebreak, etc.) that is not a digit nor the negative sign of your language.

The separator must not change at any point.

The separator can consist of multiple characters, as long as none of them is a digit nor the negative sign (e.g. ,  is as valid as just ,).

Any supported integer must eventually be printed after a finite amount of time.

Scoring

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

Leaderboard

var QUESTION_ID=93441,OVERRIDE_USER=41723;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:
Burlesque, 12 bytes

0R@J-1?*_+[-

You can try a restricted version here.

0R@  Range from 0 to Infinity
J    Duplicate
-1?* Multiply one Block by -1 (negative integeres)
_+   Concatenate
[-   Tail to Remove the duplicate zero


问:
Recreate the Windows ME screensaver as ASCII

This challenge is inspired from this answer at the Ask Ubuntu Stack Exchange.

Intro

Remember the Windows ME screensaver with the pipes? Time to bring the nostalgia back!

Challenge

You should write a program or function which will output an ASCII representation of the screensaver. In the screensaver there should be a single pipe which will grow in semi-random directions.

The start of the pipe will be randomly placed at any of the borders of the screen and the pipe piece should be perpendicular to the border (corner first-pipes can either be horizontal or vertical). Each tick the pipe will grow in the direction it is facing (horizontal/vertical) at an 80% chance or take a corner at a 20% chance.

Pipe representation

To create the pipe, 6 unicode characters will be used

```<code>─    \u2500    horizontal pipe
│    \u2502    vertical pipe
┌    \u250C    upper left corner pipe
┐    \u2510    upper right corner pipe
└    \u2514    lower left corner pipe
┘    \u2518    lower right corner pipe
</code>```

Input

The program / function will take 3 values of input, which can be gathered through function parameters or prompted to the user.

Amount of ticks

Screen width

Screen height

Amount of ticks

For every tick, a piece of pipe will be added to the screen. Pipes will overwrite old pipe pieces if they spawn at the same position.

For example, take a screen of size 3x3

```<code>ticks == 3
─┐
 ┘

ticks == 4
─┐
└┘

ticks == 5
│┐
└┘
</code>```

Whenever a pipe exits the screen, as in the last example at 5 ticks, then a new pipe will spawn at a random border. For example:

```<code>ticks == 6
│┐
└┘
  ─
</code>```

The new pipe should have a 50% chance of being horizontal or vertical.

Screen width/height

The screen width and height can be combined into a single value if that's preferrable in your language of choice. The screen width and height will always have a minimum value of 1 and a maximum value of 255. If your language of choice supports a console or output screen which is smaller than a 255x255 grid of characters then you may assume that the width and height will never exceed the boundaries of your console. (Example: Windows 80x25 cmd window)

Output

The output of your program/function should be printed to the screen, or returned from a function. For every run of your program, a different set of pipes should be generated.

Test cases

The following test cases are all random examples of valid outputs

```<code>f(4, 3, 3)
 │
─┘
  │

f(5, 3, 3)
 │
─┘┌
  │

f(6, 3, 3)
─│
─┘┌
  │

f(7, 3, 3)
──
─┘┌
  │
</code>```

Obviously, the more ticks that have occured, the harder it becomes to prove the validity of your program. Hence, posting a gif of your output running will be preferred. If this is not possible, please post a version of your code which includes printing the output. Obviously, this will not count towards your score.

Rules

This is code-golf, shortest amount of bytes wins

Standard loopholes apply

If you use the unicode pipe characters in your source code, you may count them as a single byte

This is quite a hard challenge that can possibly be solved in many creative ways, you are encouraged to write an answer in a more verbose language even though there are already answers in short esolangs. This will create a catalog of shortest answers per language. Bonus upvotes for fancy coloured gifs ;)

Happy golfing!

Disclaimer: I am aware that Unicode characters aren't ASCII, but in lack of a better name I just call it ASCII art. Suggestions are welcome :)

答:
JavaScript (ES6), 264 <s>266 274 281</s>

(t,w,h,r=n=>Math.random()*n|0,g=[...Array(h)].map(x=>Array(w).fill` `))=>((y=>{for(x=y;t--;d&1?y+=d-2:x+=d-1)x<w&y<h&&~x*~y?0:(d=r(4))&1?x=r(w,y=d&2?0:h-1):y=r(h,x=d?0:w-1),e=d,d=r(5)?d:2*r(2)-~d&3,g[y][x]="─└ ┌┐│┌  ┘─┐┘ └│"[e*4|d]})(w),g.map(x=>x.join``).join`
`)
```
<p>Counting unicode drawing characters as 1 byte each. (As specified by OP)</p>
<p><em>Less golfed</em></p>
<pre class="lang-js prettyprint-override"><code>(t,w,h)=>{
  r=n=>Math.random()*n|0; // integer range random function
  g=[...Array(h)].map(x=>Array(w).fill(' ')); // display grid
  for (x=y=w;t--;)
    x<w & y<h && ~x*~y||( // if passed boundary
      d = r(4), // select random direction
      d & 1? (x=r(w), y=d&2?0:h-1) : (y=r(h), x=d?0:w-1) // choose start position
    ),
    e=d, d=r(5)?d:2*r(2)-~d&3, // change direction 20% of times
    g[y][x]="─└ ┌┐│┌  ┘─┐┘ └│"[e*4|d], // use char based on current+prev direction
    d&1 ? y+=d-2 : x+=d-1 // change x,y position based on direction
  return g.map(x=>x.join``).join`\n`
}
</code>```

Animated test

Note: trying to keep the animation time under 30 sec,more thicks make animation pace faster

f=(t,w,h,r=n=>Math.random()*n|0,g=[...Array(h)].map(x=>Array(w).fill` `))=>
{
  z=[]
  for(x=y=w;t--;d&1?y+=d-2:x+=d-1)
    x<w&y<h&&~x*~y?0:(d=r(4))&1?x=r(w,y=d&2?0:h-1):y=r(h,x=d?0:w-1),
    e=d,d=r(5)?d:2*r(2)-~d&3,g[y][x]="─└ ┌┐│┌  ┘─┐┘ └│"[e*4|d],
    z.push(g.map(x=>x.join``).join`\n`)
  return z
}

function go() {
  B.disabled=true
  var [t,w,h]=I.value.match(/\d+/g)
  var r=f(+t,+w,+h)
  O.style.width = w+'ch';
  var step=0
  var animate =_=>{
    S.textContent = step
    var frame= r[step++]
    if (frame) O.textContent = frame,setTimeout(animate, 30000/t);
    else   B.disabled=false
  }

  animate()
}

go()```
<pre class="snippet-code-css lang-css prettyprint-override"><code>#O { border: 1px solid #000 }</code>```

Input - ticks,width,height
<input value='600,70,10' id=I><button id=B onclick='go()'>GO</button>

```</code>```

Body:
JavaScript (ES6), 264 <s>266 274 281</s>

(t,w,h,r=n=>Math.random()*n|0,g=[...Array(h)].map(x=>Array(w).fill` `))=>((y=>{for(x=y;t--;d&1?y+=d-2:x+=d-1)x<w&y<h&&~x*~y?0:(d=r(4))&1?x=r(w,y=d&2?0:h-1):y=r(h,x=d?0:w-1),e=d,d=r(5)?d:2*r(2)-~d&3,g[y][x]="─└ ┌┐│┌  ┘─┐┘ └│"[e*4|d]})(w),g.map(x=>x.join``).join`
`)

Counting unicode drawing characters as 1 byte each. (As specified by OP)

Less golfed

(t,w,h)=>{
  r=n=>Math.random()*n|0; // integer range random function
  g=[...Array(h)].map(x=>Array(w).fill(' ')); // display grid
  for (x=y=w;t--;)
    x<w & y<h && ~x*~y||( // if passed boundary
      d = r(4), // select random direction
      d & 1? (x=r(w), y=d&2?0:h-1) : (y=r(h), x=d?0:w-1) // choose start position
    ),
    e=d, d=r(5)?d:2*r(2)-~d&3, // change direction 20% of times
    g[y][x]="─└ ┌┐│┌  ┘─┐┘ └│"[e*4|d], // use char based on current+prev direction
    d&1 ? y+=d-2 : x+=d-1 // change x,y position based on direction
  return g.map(x=>x.join``).join`\n`
}

Animated test

Note: trying to keep the animation time under 30 sec,more thicks make animation pace faster

f=(t,w,h,r=n=>Math.random()*n|0,g=[...Array(h)].map(x=>Array(w).fill` `))=>
{
  z=[]
  for(x=y=w;t--;d&1?y+=d-2:x+=d-1)
    x<w&y<h&&~x*~y?0:(d=r(4))&1?x=r(w,y=d&2?0:h-1):y=r(h,x=d?0:w-1),
    e=d,d=r(5)?d:2*r(2)-~d&3,g[y][x]="─└ ┌┐│┌  ┘─┐┘ └│"[e*4|d],
    z.push(g.map(x=>x.join``).join`\n`)
  return z
}

function go() {
  B.disabled=true
  var [t,w,h]=I.value.match(/\d+/g)
  var r=f(+t,+w,+h)
  O.style.width = w+'ch';
  var step=0
  var animate =_=>{
    S.textContent = step
    var frame= r[step++]
    if (frame) O.textContent = frame,setTimeout(animate, 30000/t);
    else   B.disabled=false
  }

  animate()
}

go()

#O { border: 1px solid #000 }

Input - ticks,width,height
<input value='600,70,10' id=I><button id=B onclick='go()'>GO</button>
<span id=S></span>
<pre id=O></pre>


问:
Bake a slice of Pi
Write a program or function that prints or outputs this exact text (consisting of 142 characters):

```<code>()()()()()()
|\3.1415926|
|:\53589793|
\::\2384626|
 \::\433832|
  \::\79502|
   \::\8841|
    \::\971|
     \::\69|
      \::\3|
       \__\|
</code>```

Your program must take no input (except in languages where this is impossible, such as sed), and produce the above text (and only the above text) as output. A trailing newline is acceptable.

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

Title: Bake a slice of Pi

Body:
JavaScript (ES6), <s>187</s> 174 bytes

This is 1 byte shorter than just displaying the plain text.

for(y=n=0,s=`()()()()()()
`;y<10;y++,s+=`|
`)for(x=-2;x++<9;)s+=x>y?(Math.PI+'2384626433832795028841971693')[n++]:`\\${y>8?'__':x+1|y>2?'::':'||'}\\`[y-x]||' ';console.log(s)


Title: String Distance

Body:
Challenge

Given an input of an all-lowercase string [a-z], output the total distance between the letters.

Example

```<code>Input: golf

Distance from g to o : 8
Distance from o to l : 3
Distance from l to f : 6

Output: 17
</code>```

Rules

Standard loopholes forbidden

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

The alphabet can be traversed from either direction. You must always use the shortest path. (i.e the distance between x and c is 5).

Test cases

```<code>Input: aa
Output: 0

Input: stack
Output: 18

Input: zaza
Output: 3

Input: valleys
Output: 35
</code>```

Body:
PHP, 93 Bytes

for(;++$i<strlen($s=$argv[1]);)$r+=13<($a=abs(ord($s[$i-1])-ord($s[$i])))?$a=26-$a:$a;echo$r;


答:
MATL, <s>70</s> <s>68</s> 67 bytes

```<code>'()'12:)l10:&<toYP43Y$51hb(!10Xy'\::\'FFhZ++'|'3$Yc'||\'3:(95'Zd'o(
</code>```

Try it online!

Explanation

What a mess. But hey, there's a convolution!

The explanation will be clearer if you can inspect the stack contents after a given statement. To do it, just insert X#0$% at that point. (This means: X#  show stack contents, 0$ don't implicitly display anything else, % comment out rest of the code). For example, see the stack right after the convolution.

```<code>'()'       % Push this string
12:        % Range [1 2 ... 12]
)          % Index into string (modular, 1-based): gives '()()()()()()'
l          % Push 1 (will be used later)
10:        % Range [1 2 ... 10]
&<         % All pairwise "less than" comparisons. Gives matrix with "true"
           % below the main diagonal, and the remining entries equal to "false"
to         % Duplicate. Convert to numbers (true becomes 1, false becomes 0)
YP43Y$     % Compute pi with 43 significant digits (42 decimals). Gives a string
51h        % Append last decimal, '3' (ASCII 51). This is needed to avoid rounding
b          % Bubble up the true-false matrix, to be used as logical index
(          % Fill the chars from the pi string into the 0-1 matrix, at the positions
           % indicated by the true-false matrix. Thus each 1 is replaced by a char
           % from the pi string. Entries that were 0 remain as 0. This is done in
           % columm-major order...
!          % ...so transpose to make it row-major
10Xy       % Identity matrix of size 10
'\::\'     % Push this string...
FFh        % ...and append two zeros
Z+         % 2D convolution keeping size. The identity matrix convolved with the
           % above string gives the diagonal bands with chars '\'  and ':'
+          % Add to the matrix containing the digits of pi. At each entry, only one
           % of the two matrices is nonzero
'|'        % Push this string
3$Yc       % Three-input string concatenation. This prepends the 1 (which was pushed
           % a while ago) and appends '|' to each row of the matrix. This converts
           % the matrix to char. Note that char 1 will be displayed as a space. We
           % used char 1 and not char 0 (which would be displayed as a space too)
           % because function `Yc` (`strcat`) strips  off trailing space from the
           % inputs, counting char 0 as space, but not char 1
'||\'      % Push this string
3:(        % Assign it to the first 3 entries of the matrix (column-major), that is,
           % to the top of the first column
95         % Push ASCII for '_'
'Zd'o      % Push string 'Zd' and convert to numbers: gives [90 100]. These are the
           % (column-major) indices where the '_' char should appear in the last row
(          % Fill those chars
           % Implicitly display. (Chars 0 and 1 are displayed as space)
</code>```

Title: Bake a slice of Pi

Body:
Write a program or function that prints or outputs this exact text (consisting of 142 characters):

```<code>()()()()()()
|\3.1415926|
|:\53589793|
\::\2384626|
 \::\433832|
  \::\79502|
   \::\8841|
    \::\971|
     \::\69|
      \::\3|
       \__\|
</code>```

Your program must take no input (except in languages where this is impossible, such as sed), and produce the above text (and only the above text) as output. A trailing newline is acceptable.

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

Body:
MATL, <s>70</s> <s>68</s> 67 bytes

'()'12:)l10:&<toYP43Y$51hb(!10Xy'\::\'FFhZ++'|'3$Yc'||\'3:(95'Zd'o(

Try it online!

Explanation

What a mess. But hey, there's a convolution!

The explanation will be clearer if you can inspect the stack contents after a given statement. To do it, just insert X#0$% at that point. (This means: X#  show stack contents, 0$ don't implicitly display anything else, % comment out rest of the code). For example, see the stack right after the convolution.

'()'       % Push this string
12:        % Range [1 2 ... 12]
)          % Index into string (modular, 1-based): gives '()()()()()()'
l          % Push 1 (will be used later)
10:        % Range [1 2 ... 10]
&<         % All pairwise "less than" comparisons. Gives matrix with "true"
           % below the main diagonal, and the remining entries equal to "false"
to         % Duplicate. Convert to numbers (true becomes 1, false becomes 0)
YP43Y$     % Compute pi with 43 significant digits (42 decimals). Gives a string
51h        % Append last decimal, '3' (ASCII 51). This is needed to avoid rounding
b          % Bubble up the true-false matrix, to be used as logical index
(          % Fill the chars from the pi string into the 0-1 matrix, at the positions
           % indicated by the true-false matrix. Thus each 1 is replaced by a char
           % from the pi string. Entries that were 0 remain as 0. This is done in
           % columm-major order...
!          % ...so transpose to make it row-major
10Xy       % Identity matrix of size 10
'\::\'     % Push this string...
FFh        % ...and append two zeros
Z+         % 2D convolution keeping size. The identity matrix convolved with the
           % above string gives the diagonal bands with chars '\'  and ':'
+          % Add to the matrix containing the digits of pi. At each entry, only one
           % of the two matrices is nonzero
'|'        % Push this string
3$Yc       % Three-input string concatenation. This prepends the 1 (which was pushed
           % a while ago) and appends '|' to each row of the matrix. This converts
           % the matrix to char. Note that char 1 will be displayed as a space. We
           % used char 1 and not char 0 (which would be displayed as a space too)
           % because function `Yc` (`strcat`) strips  off trailing space from the
           % inputs, counting char 0 as space, but not char 1
'||\'      % Push this string
3:(        % Assign it to the first 3 entries of the matrix (column-major), that is,
           % to the top of the first column
95         % Push ASCII for '_'
'Zd'o      % Push string 'Zd' and convert to numbers: gives [90 100]. These are the
           % (column-major) indices where the '_' char should appear in the last row
(          % Fill those chars
           % Implicitly display. (Chars 0 and 1 are displayed as space)


Title: Bake a slice of Pi

Body:
///, <s>129</s> 127 bytes

/-/\\\\//&/--::--//%/  //#/|
%//!/()()/!!!
|-3.1415926|
|:-53589793|
&2384626|
 &433832#&79502# &8841#%&971#% &69#%%&3#%% -__-|

Try it online!


答:
05AB1E, 12 bytes

```<code>SÇ¥YFÄ5Ø-}(O
</code>```

Explanation

```<code>SÇ                   # convert to list of ascii values
  ¥                  # take delta's
   YF    }           # 2 times do
     Ä5Ø-            # for x in list: abs(x) - 13
          (O         # negate and sum
</code>```

Try it online!

Title: String Distance

Body:
05AB1E, 12 bytes

SÇ¥YFÄ5Ø-}(O

Explanation

SÇ                   # convert to list of ascii values
  ¥                  # take delta's
   YF    }           # 2 times do
     Ä5Ø-            # for x in list: abs(x) - 13
          (O         # negate and sum

Try it online!


Title: Bake a slice of Pi

Body:
Bash, 153 bytes

cat << _
()()()()()()
|\3.1415926|
|:\53589793|
\::\2384626|
 \::\433832|
  \::\79502|
   \::\8841|
    \::\971|
     \::\69|
      \::\3|
       \__\|
_


Title: Bake a slice of Pi

Body:
PHP, 170 bytes

no arbritrary precision Pi in PHP? Calculating takes much more space than Copy&Paste.  Doesn´t matter that the last digit here is cut, not rounded;  but in 64 bit Pi the last digit gets rounded up.

for(;$i<11;)echo str_pad($i?["\\__\\","|\\","|:\\","\\::\\"][$i>9?0:min(3,$i)].[3.1415926,53589793,2384626,433832,79502,8841,971,69,3][$i-1]."|
":"
",13,$i++?" ":"()",0);

Run with php -r '<code>'

uncommented breakdown

for(;$i<11;)
    echo str_pad($i?
         ["\\__\\","|\\","|:\\","\\::\\"][$i>9?0:min(3,$i)]
        .[3.1415926,53589793,2384626,433832,79502,8841,971,69,3][$i-1]
        ."|\n"
    :"\n"
    ,13,$i++?" ":"()",0);


问:
The House of Santa Claus

The House of Santa Claus

Note: This is the first challenge that I have attempted to set. It has been through the Sandbox however if you find something wrong with it please do not just downvote but leave a comment so that I can improve it.

Background

There is a old childrens puzzle where the challenge is to draw a box with a roof and a cross through the middle without lifting your pen from the paper or going over any line twice.

In Germany it is known as "das Haus des Nikolaus" or "The House of Santa Claus". I honestly can't remember what we used to call it. For anyone who is not familiar with the puzzle, full details are available here.

Here is an ASCII art representation of the house.

```<code> /\
/__\
|\/|
|/\|
----
</code>```

Challenge

Write a program or function to draw the House of Santa Claus in any language of your choice.

Sounds too easy? Well here's the catch. It must also output each stage of the drawing and comply with the rules of the puzzle. Your program is not required to take any input. The finished house must look exactly as shown above.

According to the site above there are 44 possible solutions. You may use any one of them. This is an ASCII art challenge so you are not required to calculate the solution but only to draw it.

Output

An example of the required output from one of the 44 solutions is shown below:

```<code>----

 \
  \
----

 __
 \
  \
----

  \
 __\
 \
  \
----

 /\
/__\
 \
  \
----

 /\
/__\
|\
| \
----

 /\
/__\
|\/
|/\
----

 /\
/__\
|\/|
|/\|
----
</code>```

Rules

I have added 1 extra newline between each expected output to try to make the requirements clearer. This is optional. Any number of blank lines between each output is allowed.

Your output must consist only of the characters /,\,-,_, and space as
shown above. Trailing spaces are allowed.

Each line in your drawing must continue from the end of the previous
line and you may not repeat any line.

Standard loopholes prohibited.

You are not required to output the rhyme mentioned in the above link.

This is code golf so the shortest answer in bytes will be the winner.

Result

Some great answers and thanks and respect to all who posted. I did say lowest byte count but I have marked as top answer not just for that but also for the great explanation of the code. Nice one @Dennis.

Title: The House of Santa Claus

Body:
///, 112 bytes

/!/\/\///*/----
 !@/\\\\!$/ @@!^/
*@\/@@
@\/__@@
/*@
 $
*__
$
 $
*$
 __@
$
 $^$
 $^|@
|$^|@\/
|\/@^|@\/|
|\/@|
*

Try it online!


问:
Print a layered cake

Challenge

Given an input n, print an ASCII art cake n layers tall, viewed from the side, with two candles on top. Refer to the examples below for details.

Output

```<code>>> cake(1)

 _|_|_
|     |
+-----+

>> cake(3)

     _|_|_
    |     |
  +---------+
  |         |
+-------------+
|             |
+-------------+
</code>```

...and so on.

Rules

Standard loopholes prohibited

Please make an attempt at a clever solution

This is code-golf, so shortest answer in bytes wins. However, the answer will not be selected.

Have fun!

答:
Batch, 233 bytes

```<code>@echo off
set i=
for /l %%j in (2,1,%1)do call set i=  %%i%%
echo %i% _^|_^|_
set s=-----
for /l %%j in (2,1,%1)do call:l
echo ^|%s:-= %^|
echo +%s%+
exit/b
:l
echo %i%^|%s:-= %^|
set i=%i:~2%
set s=----%s%
echo %i%+%s%+
</code>```

Shorter than Python? Something must be wrong...

Title: Print a layered cake

Body:
Batch, 233 bytes

@echo off
set i=
for /l %%j in (2,1,%1)do call set i=  %%i%%
echo %i% _^|_^|_
set s=-----
for /l %%j in (2,1,%1)do call:l
echo ^|%s:-= %^|
echo +%s%+
exit/b
:l
echo %i%^|%s:-= %^|
set i=%i:~2%
set s=----%s%
echo %i%+%s%+

Shorter than Python? Something must be wrong...


答:
Labyrinth, 9 bytes

```<code>!`
\:"
 (
</code>```

Try it online!

This also works and is essentially the same:

```<code> "
`:(
\!
</code>```

Explanation

The control flow in this code is rather funny. Remember that the instruction pointer (IP) in a Labyrinth program follows the path of non-space characters and examines the top of the stack at any junction to decide which path to take:

If the top of the stack is positive, turn right.

If the top of the stack is zero, keep moving straight ahead.

If the top of the stack is negative, turn left.

When the IP hits a dead end, it turns around (executing the command at the end only once). And the IP starts in the top left corner moving east. Also note that the stack is implicitly filled with an infinite amount of zeros to begin with.

The program starts with this short bit:

```<code>!    Print top of stack (0).
`    Multiply by -1 (still 0).
:    Duplicate.
</code>```

Now the IP is at the relevant junction and moves straight ahead onto the ( which decrements the top of the stack to -1. The IP hits a dead end and turns around. : duplicates the top of the stack once more. Now the top of the stack is negative and the IP turns left (west). We now execute one more iteration of the main loop:

```<code>\   Print linefeed.
!   Print top of stack (-1).
`   Multiply by -1 (1).
:   Duplicate.
</code>```

This time, the top of the stack is positive, so IP turns right (west) and immediately executes another iteration of the main loop, which prints the 1. Then after it is negated again, we hit the : with -1 on the stack.

This time the IP turns left (east). The " is just a no-op and the IP turns around in the dead end. : makes another copy and this time the IP turns south. ( decrements the value to -2, the IP turns around again. With the top of the stack still negative, the IP now turns west on the : and does the next iteration of the main loop.

In this way, the IP will now iterate between a tight loop iteration, printing a positive number, and an iteration that goes through both dead ends to decrement the value before printing a negative number.

You might ask yourself why there's the " on the second line if it doesn't actually do anything: without it, when the IP reaches : on a negative value, it can't turn left (east) so it would turn right (west) instead (as a rule of thumb, if the usual direction at a junction isn't available, the IP will take the opposite direction). That means the IP would also never reach the ( at the bottom and we couldn't distinguish positive from negative iterations.

Title: Print all integers

Body:
Labyrinth, 9 bytes

!`
\:"
 (

Try it online!

This also works and is essentially the same:

 "
`:(
\!

Explanation

The control flow in this code is rather funny. Remember that the instruction pointer (IP) in a Labyrinth program follows the path of non-space characters and examines the top of the stack at any junction to decide which path to take:

If the top of the stack is positive, turn right.

If the top of the stack is zero, keep moving straight ahead.

If the top of the stack is negative, turn left.

When the IP hits a dead end, it turns around (executing the command at the end only once). And the IP starts in the top left corner moving east. Also note that the stack is implicitly filled with an infinite amount of zeros to begin with.

The program starts with this short bit:

!    Print top of stack (0).
`    Multiply by -1 (still 0).
:    Duplicate.

Now the IP is at the relevant junction and moves straight ahead onto the ( which decrements the top of the stack to -1. The IP hits a dead end and turns around. : duplicates the top of the stack once more. Now the top of the stack is negative and the IP turns left (west). We now execute one more iteration of the main loop:

\   Print linefeed.
!   Print top of stack (-1).
`   Multiply by -1 (1).
:   Duplicate.

This time, the top of the stack is positive, so IP turns right (west) and immediately executes another iteration of the main loop, which prints the 1. Then after it is negated again, we hit the : with -1 on the stack.

This time the IP turns left (east). The " is just a no-op and the IP turns around in the dead end. : makes another copy and this time the IP turns south. ( decrements the value to -2, the IP turns around again. With the top of the stack still negative, the IP now turns west on the : and does the next iteration of the main loop.

In this way, the IP will now iterate between a tight loop iteration, printing a positive number, and an iteration that goes through both dead ends to decrement the value before printing a negative number.

You might ask yourself why there's the " on the second line if it doesn't actually do anything: without it, when the IP reaches : on a negative value, it can't turn left (east) so it would turn right (west) instead (as a rule of thumb, if the usual direction at a junction isn't available, the IP will take the opposite direction). That means the IP would also never reach the ( at the bottom and we couldn't distinguish positive from negative iterations.


答:
k (20 bytes)

The function between curly braces is repeatedly iterated on it's result, starting at zero, until the result converges at 0W (k infinity).

```<code>{-1@'$?-1 1*x;x+1}/0
</code>```

The function prints the argument and its negation and then returns incremented argument.

Title: Print all integers

Body:
k (20 bytes)

The function between curly braces is repeatedly iterated on it's result, starting at zero, until the result converges at 0W (k infinity).

{-1@'$?-1 1*x;x+1}/0

The function prints the argument and its negation and then returns incremented argument.


答:
Java 7,128 bytes

```<code> int f(String s){char[]c=s.toCharArray();int t=0;for(int i=1,a;i<c.length;a=Math.abs(c[i]-c[i++-1]),t+=26-a<a?26-a:a);return t;}
</code>```

Ungolfed

```<code> int f(String s){
 char[]c=s.toCharArray();
 int t=0;
 for(int i=1,a;
     i<c.length;
   a=Math.abs(c[i]-c[i++-1]),t+=26-a<a?26-a:a);
return t;
 }
</code>```

Title: String Distance

Body:
Java 7,128 bytes

 int f(String s){char[]c=s.toCharArray();int t=0;for(int i=1,a;i<c.length;a=Math.abs(c[i]-c[i++-1]),t+=26-a<a?26-a:a);return t;}

Ungolfed

 int f(String s){
 char[]c=s.toCharArray();
 int t=0;
 for(int i=1,a;
     i<c.length;
   a=Math.abs(c[i]-c[i++-1]),t+=26-a<a?26-a:a);
return t;
 }


问:
Shortest program that throws StackOverflow Error
Write a program that throws a StackOverflow Error or the equivalent in the language used. For example, in java, the program should throw java.lang.StackOverflowError.

You are not allowed to define a function that calls itself or a new class(except the one containing main in java). It should use the classes of the selected programming language.

And it should not throw the error explicitly.

答:
GolfScript (8 chars)

```<code>{]}333*`
</code>```

Result:

```<code>$ golfscript.rb overflow.gs
golfscript.rb:246:in `initialize': stack level too deep (SystemStackError)
from /home/pjt33/bin/golfscript.rb:130:in `new'
from /home/pjt33/bin/golfscript.rb:130:in `ginspect'
from /home/pjt33/bin/golfscript.rb:130:in `ginspect'
from /home/pjt33/bin/golfscript.rb:130:in `map'
from /home/pjt33/bin/golfscript.rb:130:in `ginspect'
from /home/pjt33/bin/golfscript.rb:130:in `ginspect'
from /home/pjt33/bin/golfscript.rb:130:in `map'
from /home/pjt33/bin/golfscript.rb:130:in `ginspect'
 ... 993 levels...
from (eval):4
from /home/pjt33/bin/golfscript.rb:293:in `call'
from /home/pjt33/bin/golfscript.rb:293:in `go'
from /home/pjt33/bin/golfscript.rb:485
</code>```

Basically this creates a heavily nested data structure and then overflows the stack when trying to turn it into a string.

Body:
GolfScript (8 chars)

{]}333*`

Result:

$ golfscript.rb overflow.gs
golfscript.rb:246:in `initialize': stack level too deep (SystemStackError)
from /home/pjt33/bin/golfscript.rb:130:in `new'
from /home/pjt33/bin/golfscript.rb:130:in `ginspect'
from /home/pjt33/bin/golfscript.rb:130:in `ginspect'
from /home/pjt33/bin/golfscript.rb:130:in `map'
from /home/pjt33/bin/golfscript.rb:130:in `ginspect'
from /home/pjt33/bin/golfscript.rb:130:in `ginspect'
from /home/pjt33/bin/golfscript.rb:130:in `map'
from /home/pjt33/bin/golfscript.rb:130:in `ginspect'
 ... 993 levels...
from (eval):4
from /home/pjt33/bin/golfscript.rb:293:in `call'
from /home/pjt33/bin/golfscript.rb:293:in `go'
from /home/pjt33/bin/golfscript.rb:485

Basically this creates a heavily nested data structure and then overflows the stack when trying to turn it into a string.


答:
Racket 119 bytes

```<code>(λ(s)(for/sum((i(sub1(string-length s))))(abs(-(char->integer
(string-ref s i))(char->integer(string-ref s(+ 1 i)))))))
</code>```

Testing:

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

Output:

```<code>17
</code>```

Detailed version:

```<code>(define(f s)
  (for/sum((i(sub1(string-length s))))
    (abs(-(char->integer(string-ref s i))
          (char->integer(string-ref s(+ 1 i)))))))
</code>```

Title: String Distance

Body:
Racket 119 bytes

(λ(s)(for/sum((i(sub1(string-length s))))(abs(-(char->integer
(string-ref s i))(char->integer(string-ref s(+ 1 i)))))))

Testing:

(f "golf")

Output:

17

Detailed version:

(define(f s)
  (for/sum((i(sub1(string-length s))))
    (abs(-(char->integer(string-ref s i))
          (char->integer(string-ref s(+ 1 i)))))))


答:
C++, 84 Bytes

```<code>#include <iostream>
int main(){for(int i=0;;)std::cout<<i++<<','<<-i<<',';return 0;}
</code>```

Edit: thanks for the debugging, commenters

Title: Print all integers

Body:
Write a program or function which will provably print all integers exactly once given infinite time and memory.

Possible outputs could be:

```<code>0, 1, -1, 2, -2, 3, -3, 4, -4, …

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -2, -3, -4, -5, -6, -7, -8, -9, 10, 11, …
</code>```

This is not a valid output, as this would never enumerate negative numbers:

<s>```0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, …```</s>

The output must be in decimal, unless your language does not support decimal integer (in that case use the natural representation of integers your language uses).

Your program has to work up to the numbers with the biggest magnitude of the standard integer type of your language.

Each integer must be separated from the next using any separator (a space, a comma, a linebreak, etc.) that is not a digit nor the negative sign of your language.

The separator must not change at any point.

The separator can consist of multiple characters, as long as none of them is a digit nor the negative sign (e.g. ,  is as valid as just ,).

Any supported integer must eventually be printed after a finite amount of time.

Scoring

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

Leaderboard

var QUESTION_ID=93441,OVERRIDE_USER=41723;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:
C++, 84 Bytes

#include <iostream>
int main(){for(int i=0;;)std::cout<<i++<<','<<-i<<',';return 0;}

Edit: thanks for the debugging, commenters


答:
C, 118 bytes

```<code>main(){char *p,n;for(n='B';n++<'J';)for(p="ZFEAFDDEAGCHIAGHCIABBBBAA";*p;p++)putchar(" \n-\\_\\/|/|"[(*p<n)**p&15]);}
</code>```

Title: The House of Santa Claus

Body:
The House of Santa Claus

Note: This is the first challenge that I have attempted to set. It has been through the Sandbox however if you find something wrong with it please do not just downvote but leave a comment so that I can improve it.

Background

There is a old childrens puzzle where the challenge is to draw a box with a roof and a cross through the middle without lifting your pen from the paper or going over any line twice.

In Germany it is known as "das Haus des Nikolaus" or "The House of Santa Claus". I honestly can't remember what we used to call it. For anyone who is not familiar with the puzzle, full details are available here.

Here is an ASCII art representation of the house.

```<code> /\
/__\
|\/|
|/\|
----
</code>```

Challenge

Write a program or function to draw the House of Santa Claus in any language of your choice.

Sounds too easy? Well here's the catch. It must also output each stage of the drawing and comply with the rules of the puzzle. Your program is not required to take any input. The finished house must look exactly as shown above.

According to the site above there are 44 possible solutions. You may use any one of them. This is an ASCII art challenge so you are not required to calculate the solution but only to draw it.

Output

An example of the required output from one of the 44 solutions is shown below:

```<code>----

 \
  \
----

 __
 \
  \
----

  \
 __\
 \
  \
----

 /\
/__\
 \
  \
----

 /\
/__\
|\
| \
----

 /\
/__\
|\/
|/\
----

 /\
/__\
|\/|
|/\|
----
</code>```

Rules

I have added 1 extra newline between each expected output to try to make the requirements clearer. This is optional. Any number of blank lines between each output is allowed.

Your output must consist only of the characters /,\,-,_, and space as
shown above. Trailing spaces are allowed.

Each line in your drawing must continue from the end of the previous
line and you may not repeat any line.

Standard loopholes prohibited.

You are not required to output the rhyme mentioned in the above link.

This is code golf so the shortest answer in bytes will be the winner.

Result

Some great answers and thanks and respect to all who posted. I did say lowest byte count but I have marked as top answer not just for that but also for the great explanation of the code. Nice one @Dennis.

Body:
C, 118 bytes

main(){char *p,n;for(n='B';n++<'J';)for(p="ZFEAFDDEAGCHIAGHCIABBBBAA";*p;p++)putchar(" \n-\\_\\/|/|"[(*p<n)**p&15]);}


答:
PHP, <s>98</s> 95 bytes

inspired by Arnauld´s solution

```<code>for($i=8;$i--;)for($p=24;$p--;)echo"|/|/\\_\\-
"[($c="977779061290162945539438"[$p])<$i?8:$c];
</code>```

Note: The first code line has a trailing space.

Title: The House of Santa Claus

Body:
PHP, <s>98</s> 95 bytes

inspired by Arnauld´s solution

for($i=8;$i--;)for($p=24;$p--;)echo"|/|/\\_\\-
"[($c="977779061290162945539438"[$p])<$i?8:$c];

Note: The first code line has a trailing space.


Title: Print a layered cake

Body:
Challenge

Given an input n, print an ASCII art cake n layers tall, viewed from the side, with two candles on top. Refer to the examples below for details.

Output

```<code>>> cake(1)

 _|_|_
|     |
+-----+

>> cake(3)

     _|_|_
    |     |
  +---------+
  |         |
+-------------+
|             |
+-------------+
</code>```

...and so on.

Rules

Standard loopholes prohibited

Please make an attempt at a clever solution

This is code-golf, so shortest answer in bytes wins. However, the answer will not be selected.

Have fun!

Body:
JavaScript (ES6), 171 bytes

n=>[(s="  "[R='repeat'](n-1))+" _|_|_",s+"|     |",...Array(n-1),`+${"-"[R](n*4+1)}+`].map((_,i)=>_||(s="  "[R](n-i))+`+${"-"[R](i=i*4+1)}+`+`
${s}|${" "[R](i)}|`).join`
`

First pass, probably not optimal...


答:
PHP with GD, <s>348</s> 338 bytes (not competing)

not exactly what was being asked for, but ...

```<code>function f($v,$w){global$x,$y,$i;imageline($i,$x,$y,$x=$v,$y=$w,1);ob_start();imagepng($i);$s=ob_get_clean();ob_end_clean();echo'<img src="data:image/png;base64,',base64_encode($s),'" > ';}$i=imagecreate($w=9,$h=$w+$z=$w/2);imagecolorallocate($i,255,255,255);f(--$w,$y=--$h);f(0,$z);f($w,$z);f($w/2,0);f(0,$z);f(0,$h);f($w,$z);f($w,$h);
</code>```

save to file, call in a browser

breakdown

```<code>function f($v,$w)
{
    global$x,$y,$i;
    imageline($i,$x,$y,$x=$v,$y=$w,1);      // draw line, set end coords as new start coords
    ob_start();imagepng($i);$s=ob_get_clean();ob_end_clean();           // get image output
    echo'<img src="data:image/png;base64,',base64_encode($s),'" > ';    // print <img> tag
}
// calculate dimensions, create image, allocate background color (foreground implicitly black)
$i=imagecreate($w=9,$h=$w+$z=$w/2);imagecolorallocate($i,255,255,255);
// paint lines: implicit `$x=0`
f(--$w,$y=--$h);f(0,$z);f($w,$z);f($w/2,0);f(0,$z);f(0,$h);f($w,$z);f($w,$h);
</code>```

To draw a larger house, change $w=9 to your desired width.

Title: The House of Santa Claus

Body:
PHP with GD, <s>348</s> 338 bytes (not competing)

not exactly what was being asked for, but ...

function f($v,$w){global$x,$y,$i;imageline($i,$x,$y,$x=$v,$y=$w,1);ob_start();imagepng($i);$s=ob_get_clean();ob_end_clean();echo'<img src="data:image/png;base64,',base64_encode($s),'" > ';}$i=imagecreate($w=9,$h=$w+$z=$w/2);imagecolorallocate($i,255,255,255);f(--$w,$y=--$h);f(0,$z);f($w,$z);f($w/2,0);f(0,$z);f(0,$h);f($w,$z);f($w,$h);

save to file, call in a browser

breakdown

function f($v,$w)
{
    global$x,$y,$i;
    imageline($i,$x,$y,$x=$v,$y=$w,1);      // draw line, set end coords as new start coords
    ob_start();imagepng($i);$s=ob_get_clean();ob_end_clean();           // get image output
    echo'<img src="data:image/png;base64,',base64_encode($s),'" > ';    // print <img> tag
}
// calculate dimensions, create image, allocate background color (foreground implicitly black)
$i=imagecreate($w=9,$h=$w+$z=$w/2);imagecolorallocate($i,255,255,255);
// paint lines: implicit `$x=0`
f(--$w,$y=--$h);f(0,$z);f($w,$z);f($w/2,0);f(0,$z);f(0,$h);f($w,$z);f($w,$h);

To draw a larger house, change $w=9 to your desired width.


问:
Interpret Repetition!
This challenge is the first in a two-challenge series about Repetition. The second will be up soon.

In a language called Repetition (something I just made up), there consists an infinite string of 12345678901234567890..., with 1234567890 repeating forever.

The following syntax is available to output numbers:

+-*/: This inserts the operator into the string of repeating digits.

Examples:

+ -> 1+2 = 3 (The + inserts a + between 1 and 2)

+* -> 1+2*3 = 1+6 = 7 (Same as above, except two operators are used now)

/ -> 1/2 = 0 (Repetition uses integer division)

// -> 1/2/3 = 0/3 = 0 (Repetition uses "left association" with multiple subtractions and divisions)

Each operator is inserted so that it has one digit to its left, unless there are c's (see below).

c: Concatenates with the next digit in the string.

Examples:

c+ -> 12+3 = 15 (The c "continues" the 1 and concatenates it with the next digit, 2, to form 12)

+c -> 1+23 = 24

ccc -> 1234

(): Brackets for processing numbers.

Examples:

(c+)* -> (12+3)*4 = 15*4 = 60 (Repetition uses the order of operations)

(c+)/c -> (12+3)/45 = 15/45 = 0

(cc+c)/ -> (123+45)/6 = 168/6 = 28

s: Skip a number (removes the number from the infinite string).

s+ -> 2+3 = 5 (s skips 1)

csc -> 124 (The first c concats 1 and 2, the s skips 3, and the final c concats 12 to 4)

+s+ -> 7 (The first + adds 1 and 2 to make 3, s skips 3, and the final + adds 3 to 4 to make 7)

cs*(++) -> 12*(4+5+6) = 12*15 = 180

In the examples above, only a finite amount of digits in the infinite string are used. The number of digits used is equivalent to number of operators, concats and skips + 1.

Your task is, when given a string of Repetition code, output the result.

Examples of input and output are:

```<code>++ -> 6
- -> -1
(-)* -> -3
cscc -> 1245
(cc+c)/ -> 28
cc+c/ -> 130
cs*(++) -> 180
</code>```

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

Specs:

You are guaranteed that the result will never go above 2^31-1.

You are also guaranteed that the input will only consist of the symbols +-*/cs().

An empty program will output 1.

答:
JavaScript (ES6), 110 bytes

```<code>s=>eval((" "+s)[R='replace'](/[^\)](?!\()/g,x=>x+i++%10,i=1)[R](/c| (\ds)+|s\d/g,"")[R](/\d+\/\d+/g,"($&|0)"))
</code>```

Very simple, but integer division adds 25 bytes. For some reason a regex in JS can't match both the beginning of a string and the first character, so that adds a few bytes as well.

How it works

Prepend a space to the input.

Append the next digit to each character (except )) that isn't immediately before a (.

Remove each c, a digit + s at the beginning (1s2 -> 2), and each s + a digit (3s4 -> 3).

Turn each division operation into int-division (1/2 -> (1/2|0)).

Evaluate and return.

Title: Interpret Repetition!

Body:
JavaScript (ES6), 110 bytes

s=>eval((" "+s)[R='replace'](/[^\)](?!\()/g,x=>x+i++%10,i=1)[R](/c| (\ds)+|s\d/g,"")[R](/\d+\/\d+/g,"($&|0)"))

Very simple, but integer division adds 25 bytes. For some reason a regex in JS can't match both the beginning of a string and the first character, so that adds a few bytes as well.

How it works

Prepend a space to the input.

Append the next digit to each character (except )) that isn't immediately before a (.

Remove each c, a digit + s at the beginning (1s2 -> 2), and each s + a digit (3s4 -> 3).

Turn each division operation into int-division (1/2 -> (1/2|0)).

Evaluate and return.


答:
Brainfuck, 10 bytes

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

Does not rely on cell wrapping to print the negative values. Does rely on accepting the cell value, which is commonly printed as a character by converting it to ASCII, to be the value to print.

Try it online!

Title: Print all integers

Body:
Brainfuck, 10 bytes

.+[>-.<.+]

Does not rely on cell wrapping to print the negative values. Does rely on accepting the cell value, which is commonly printed as a character by converting it to ASCII, to be the value to print.

Try it online!


问:
10 PRINT CHR$(205.5+RND(1)); : GOTO 10 in PHP (or anything else, for that matter)
Just had a 'spirited' conversation with a co-worker about the succinctness of the following BASIC statement:

```<code>10 PRINT CHR$(205.5+RND(1)); : GOTO 10
</code>```

It's the title of this book, and will simply print a sequence of / and \ characters, alternating between the two randomly, resulting in a pattern similar to this:

(Image borrowed from http://www.flickr.com/photos/rndmcnlly/5058442151/sizes/o/in/photostream/)

Being of a PHP proclivity, we wondered what the most compact way of writing the same thing in PHP would be, and came up with this:

```<code>while(1) { echo chr(47 + 45 * rand(0,1)); }
</code>```

chr(47) is a / character, and chr(92) is a \. So the statement echo chr(47 + 45 * rand(0,1)); will randomly alternate between the two, ad nauseam.

In a language of your choosing, write the shortest program or function to output an infinite random sequence of \ and / characters, where each character has an equal probability of being chosen.

答:
Common Lisp - 68

```<code>(defun s(l)(elt l(random(length l))))(loop do(format t"~a"(s"/\\")))
</code>```

OwnerDisplayName: Judy

ContentLicense: CC BY-SA 4.0

Body:
Common Lisp - 68

(defun s(l)(elt l(random(length l))))(loop do(format t"~a"(s"/\\")))


问:
Misconstrued Monomials
There exists an equation, assuming n and x are positive,

that expresses the relationship between two monomials, one being a common misrepresentation of the other. Many people make the simple mistake of equating these (i.e. 3x^2 and (3x)^2).

Challenge

Given a positive integer, i, determine and return the solution n and x with the smallest sum as an array [n, x]. In the case of a tie, any solution set is acceptable.

Test Cases

```<code>62658722541234765
[15, 11]

202500
[4, 15]

524288
[8, 4]

33044255768277
[13, 9]
</code>```

答:
Jelly, <s>23</s> 16 bytes

```<code>×*@¥/=³
ṗ2ÇÐfSÞḢ
</code>```

Given i, this generates all integer pairs with replacement in [1, i]. It then performs the same filtering and sorting as in the previous solution shown below. Since there is no time constraint, brute force will work given enough time.

Try it online!, but don't try large values online.

On my pc, it takes about 6 minutes to compute the result for i = 2048 using the inefficient version.

Efficient version

This is the previous solution for 23 bytes that is able to solve the large values quickly.

```<code>×*@¥/=³
ÆDµṚ*İ⁸żḞÇÐfSÞḢ
</code>```

Given i, computes the divisors of i to generate pairs of [n, x] where n is a divisor and x = floor( (i/n)^(1/n) ). Then filters it for values where n * x^n == i, sort the remaining pairs by their sum, and returns the first pair.

Try it online! or Verify all test cases.

Explanation

```<code>×*@¥/=³  Helper link. Input: list [n, x]
    /    Reduce using
   ¥       A dyadic chain
 *@        Compute x^n
×          Multiply by n
      ³  The initial value i
     =   Test if n * x^n == i

ṗ2ÇÐfSÞḢ  Main link (16 byte version). Input: integer i
ṗ2        Generate all pairs of integers in [1, i]
  ÇÐf     Filter for where the helper link is true
     SÞ   Sort them by their sum
       Ḣ  Return the first result

ÆDµṚ*İ⁸żḞÇÐfSÞḢ  Main link (23 byte version). Input: integer i
ÆD               Compute the divisors of i
  µ              Begin a new monadic chain operating on the divisors
   Ṛ             Reverse the divisors
     İ           Reciprocal of each divisors
    *            Raise each in the reversed divisors to the reciprocal of a divisor
      ⁸          Get the divisors
       ż         Interleave the divisors with the previous powers
        Ḟ        Floor each
         ÇÐf     Filter for where the helper link is true
            SÞ   Sort them by their sum
              Ḣ  Return the first result
</code>```

Title: Misconstrued Monomials

Body:
Jelly, <s>23</s> 16 bytes

×*@¥/=³
ṗ2ÇÐfSÞḢ

Given i, this generates all integer pairs with replacement in [1, i]. It then performs the same filtering and sorting as in the previous solution shown below. Since there is no time constraint, brute force will work given enough time.

Try it online!, but don't try large values online.

On my pc, it takes about 6 minutes to compute the result for i = 2048 using the inefficient version.

Efficient version

This is the previous solution for 23 bytes that is able to solve the large values quickly.

×*@¥/=³
ÆDµṚ*İ⁸żḞÇÐfSÞḢ

Given i, computes the divisors of i to generate pairs of [n, x] where n is a divisor and x = floor( (i/n)^(1/n) ). Then filters it for values where n * x^n == i, sort the remaining pairs by their sum, and returns the first pair.

Try it online! or Verify all test cases.

Explanation

×*@¥/=³  Helper link. Input: list [n, x]
    /    Reduce using
   ¥       A dyadic chain
 *@        Compute x^n
×          Multiply by n
      ³  The initial value i
     =   Test if n * x^n == i

ṗ2ÇÐfSÞḢ  Main link (16 byte version). Input: integer i
ṗ2        Generate all pairs of integers in [1, i]
  ÇÐf     Filter for where the helper link is true
     SÞ   Sort them by their sum
       Ḣ  Return the first result

ÆDµṚ*İ⁸żḞÇÐfSÞḢ  Main link (23 byte version). Input: integer i
ÆD               Compute the divisors of i
  µ              Begin a new monadic chain operating on the divisors
   Ṛ             Reverse the divisors
     İ           Reciprocal of each divisors
    *            Raise each in the reversed divisors to the reciprocal of a divisor
      ⁸          Get the divisors
       ż         Interleave the divisors with the previous powers
        Ḟ        Floor each
         ÇÐf     Filter for where the helper link is true
            SÞ   Sort them by their sum
              Ḣ  Return the first result


答:
Java, <s>126</s> <s>120</s> 117 bytes

```<code>int f(String s){byte[]z=s.getBytes();int r=0,i=0,e;for(;++i<z.length;r+=(e=(26+z[i]-z[i-1])%26)<14?e:26-e);return r;}
</code>```

Thanks to @KevinCruijssen for pointing out a bug in the original version and suggesting to make the for-loop empty.

The use of (26 + z[i] - z[i - 1]) % 26) is inspired from a comment by @Neil on another answer. (26 + ...)%26 serves the same purpose as Math.abs(...) because of ...? e : 26 - e.

Ungolfed:

```<code>int f(String s) {
    byte[]z = s.getBytes();
    int r = 0, i = 0, e;
    for (; ++i < z.length; r += (e = (26 + z[i] - z[i - 1]) % 26) < 14 ? e : 26 - e);
    return r;
}
</code>```

Title: String Distance

Body:
Challenge

Given an input of an all-lowercase string [a-z], output the total distance between the letters.

Example

```<code>Input: golf

Distance from g to o : 8
Distance from o to l : 3
Distance from l to f : 6

Output: 17
</code>```

Rules

Standard loopholes forbidden

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

The alphabet can be traversed from either direction. You must always use the shortest path. (i.e the distance between x and c is 5).

Test cases

```<code>Input: aa
Output: 0

Input: stack
Output: 18

Input: zaza
Output: 3

Input: valleys
Output: 35
</code>```

Body:
Java, <s>126</s> <s>120</s> 117 bytes

int f(String s){byte[]z=s.getBytes();int r=0,i=0,e;for(;++i<z.length;r+=(e=(26+z[i]-z[i-1])%26)<14?e:26-e);return r;}

Thanks to @KevinCruijssen for pointing out a bug in the original version and suggesting to make the for-loop empty.

The use of (26 + z[i] - z[i - 1]) % 26) is inspired from a comment by @Neil on another answer. (26 + ...)%26 serves the same purpose as Math.abs(...) because of ...? e : 26 - e.

Ungolfed:

int f(String s) {
    byte[]z = s.getBytes();
    int r = 0, i = 0, e;
    for (; ++i < z.length; r += (e = (26 + z[i] - z[i - 1]) % 26) < 14 ? e : 26 - e);
    return r;
}


答:
Perl, 46 bytes

Includes +3 for -p (code contains ')

Give input on STDIN without final newline:

```<code>echo -n zaza | stringd.pl
</code>```

stringd.pl:

```<code>#!/usr/bin/perl -p
s%.%$\+=13-abs 13-abs ord($&)-ord$'.$&%eg}{
</code>```

Title: String Distance

Body:
Perl, 46 bytes

Includes +3 for -p (code contains ')

Give input on STDIN without final newline:

echo -n zaza | stringd.pl

stringd.pl:

#!/usr/bin/perl -p
s%.%$\+=13-abs 13-abs ord($&)-ord$'.$&%eg}{


答:
Ruby, 73 bytes

```<code>->x{eval x.chars.each_cons(2).map{|a,b|13-(13-(a.ord-b.ord).abs).abs}*?+}
</code>```

Title: String Distance

Body:
Ruby, 73 bytes

->x{eval x.chars.each_cons(2).map{|a,b|13-(13-(a.ord-b.ord).abs).abs}*?+}


答:
Jelly, <s>40</s> <s>39</s> 36 bytes

```<code>“ḥ%DtƊVḍI’ḃ9W;“|_/-\/\|‘Ė¤y@\FỌ»⁶s4Y
</code>```

Try it online!

How it works

```<code>“ḥ%DtƊVḍI’
</code>```

is a bijective base-250 literal; each character corresponds to its code point in Jelly's code page. The result is the integer 13192938935880491074.

```<code>          ḃ9
</code>```

converts the generated integer to bijective base 9, yielding the integer array

[9, 6, 7, 9, 6, 2, 2, 7, 1, 5, 3, 8, 1, 3, 5, 8, 4, 4, 4, 4]. The integers correspond to the order of the stroke, with the exception of 9, which indicates a space.

```<code>            W
</code>```

wraps the generated array into a singleton array, which will be required to prepend it to the array we'll generate now.

```<code>              “|_/-\/\|‘Ė¤
</code>```

works as follows. ¤ combines the two links to the left into a niladic chain. The first one, “|_/-\/\|‘ yields the code points of the specified characters, yielding [124, 95, 47, 45, 92, 47, 92, 124]. Then, Ė enumerates the code points, yielding

[[1, 124], [2, 95], [3, 47], [4, 45], [5, 92], [6, 47], [7, 92], [8, 124]]. The pair [n, c] means that the nth stroke will be the ASCII character with code point c.

```<code>             ;
</code>```

concatenates the generated arrays. The result is the array

[[9,6,7,9,6,2,2,7,1,5,3,8,1,3,5,8,4,4,4,4],[1,124],[2,95],[3,47],[4,45],[5,92],[6,47],[7,92],[8,124]].

```<code>                          y@\
</code>```

performs a cumulative (i. e., showing all intermediate steps) reduce, using transliteration (y) with swapped arguments (@). In the first step, e.g., we replace each 1 in the original array with 124, which is the code point of the character |.

```<code>                             FỌ
</code>```

flattens the result and replaces all code points with the corresponding ASCII characters. In all steps, this will generate some unprintable characters with code points 1 to 9.

```<code>                               »⁶
</code>```

takes the character-wise maximum with the space character, replacing all unprintable characters with spaces.

```<code>                                 s4Y
</code>```

splits the generated string into chunks of length four and joins them with a linefeed as separator.

Title: The House of Santa Claus

Body:
Jelly, <s>40</s> <s>39</s> 36 bytes

“ḥ%DtƊVḍI’ḃ9W;“|_/-\/\|‘Ė¤y@\FỌ»⁶s4Y

Try it online!

How it works

“ḥ%DtƊVḍI’

is a bijective base-250 literal; each character corresponds to its code point in Jelly's code page. The result is the integer 13192938935880491074.

          ḃ9

converts the generated integer to bijective base 9, yielding the integer array

[9, 6, 7, 9, 6, 2, 2, 7, 1, 5, 3, 8, 1, 3, 5, 8, 4, 4, 4, 4]. The integers correspond to the order of the stroke, with the exception of 9, which indicates a space.

            W

wraps the generated array into a singleton array, which will be required to prepend it to the array we'll generate now.

              “|_/-\/\|‘Ė¤

works as follows. ¤ combines the two links to the left into a niladic chain. The first one, “|_/-\/\|‘ yields the code points of the specified characters, yielding [124, 95, 47, 45, 92, 47, 92, 124]. Then, Ė enumerates the code points, yielding

[[1, 124], [2, 95], [3, 47], [4, 45], [5, 92], [6, 47], [7, 92], [8, 124]]. The pair [n, c] means that the nth stroke will be the ASCII character with code point c.

             ;

concatenates the generated arrays. The result is the array

[[9,6,7,9,6,2,2,7,1,5,3,8,1,3,5,8,4,4,4,4],[1,124],[2,95],[3,47],[4,45],[5,92],[6,47],[7,92],[8,124]].

                          y@\

performs a cumulative (i. e., showing all intermediate steps) reduce, using transliteration (y) with swapped arguments (@). In the first step, e.g., we replace each 1 in the original array with 124, which is the code point of the character |.

                             FỌ

flattens the result and replaces all code points with the corresponding ASCII characters. In all steps, this will generate some unprintable characters with code points 1 to 9.

                               »⁶

takes the character-wise maximum with the space character, replacing all unprintable characters with spaces.

                                 s4Y

splits the generated string into chunks of length four and joins them with a linefeed as separator.


Title: Print a layered cake

Body:
Ruby, 109 107 bytes

->n{p=->t{puts t.center 3+4*n}
p['_|_|_']
(1..n).map{|i|p[?|+' '*(1+4*i)+?|]
p[?++?-*((i<n ?5:1)+4*i)+?+]}}


问:
Generate a Universal-binary-function Lookup Table
This is tangentially related to my quest to invent an esoteric programming language.

A table of the binary numbers 0 .. 15 can be used to implement a Universal Binary Function using indexing operations. Given two 1-bit inputs X and Y, all 16 possible functions can be encoded in a 4-bit opcode.

```<code>X Y  F|0 1 2 3 4 5 6 7 8 9 A B C D E F
- -    - - - - - - - - - - - - - - - -
0 0    0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
0 1    0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
1 0    0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
1 1    0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
       -     -   - -   -   -   -   - -
       0    ~X  ~Y ^   &   Y   X   | 1
      ZERO    NOT-Y   AND         OR
          NOT-X   XOR              ONE
</code>```

So this set of 16 functions can be applied to binary inputs as the function

U(f,x,y): (f >> ((x<<1) | y)) & 1,

or

U(f,x,y): (f / 2^(x×2 + y)) % 2,

or with indexing or matrix partitioning.

It will be useful to know the most compact way to represent or generate such a table of values for any possible languages to be built upon this type of binary operation.

The goal:

Generate this exact text output:

```<code>0101010101010101
0011001100110011
0000111100001111
0000000011111111
</code>```

That's it! Shortest-code wins.

Body:
C 70 bytes

c,k=1,i;x(){putchar(48+i);i^=!(++c%k);c%16||(k*=2)+puts("");k>8||x();}

use recursive function... in https://ideone.com/ it compile and result:

0101010101010101
0011001100110011
0000111100001111
0000000011111111

even if in the compiler i use it does not compile...


答:
JavaScript (ES6), 134 bytes

A recursive cake.

f=(n,i=--n,r=(n,c)=>'- '[+!c].repeat(n),p=r((i-n)*2),j=n*4+5,x=p+`+${r(j,1)}+
`)=>(n?f(n-1,i)+x:p+` _|_|_
`)+p+`|${r(j)}|
`+(n-i?'':x)
```
<h3>Demo</h3>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>let f=(n,i=--n,r=(n,c)=>'- '[+!c].repeat(n),p=r((i-n)*2),j=n*4+5,x=p+`+${r(j,1)}+
`)=>(n?f(n-1,i)+x:p+` _|_|_
`)+p+`|${r(j)}|
`+(n-i?'':x)

console.log(f(4))</code>```

Title: Print a layered cake

Body:
JavaScript (ES6), 134 bytes

A recursive cake.

f=(n,i=--n,r=(n,c)=>'- '[+!c].repeat(n),p=r((i-n)*2),j=n*4+5,x=p+`+${r(j,1)}+
`)=>(n?f(n-1,i)+x:p+` _|_|_
`)+p+`|${r(j)}|
`+(n-i?'':x)

Demo

let f=(n,i=--n,r=(n,c)=>'- '[+!c].repeat(n),p=r((i-n)*2),j=n*4+5,x=p+`+${r(j,1)}+
`)=>(n?f(n-1,i)+x:p+` _|_|_
`)+p+`|${r(j)}|
`+(n-i?'':x)

console.log(f(4))


问:
Invert a boolean array
A nice simple one

Input

Given a boolean array (Or an acceptable alternative), you can assume the array will never be more than 32 elements long.

```<code>[false, false, true, false, false]
</code>```

Output

Invert every element of the array and output it.

```<code>[true, true, false, true, true]
</code>```

Rules

You can write a full program or just a function

Standard loopholes apply

Shortest code in bytes, per language, wins!

Test cases

```<code>Input:
[true, false]
Output:
[false, true]

Input: //Example of acceptable alternative
[0,1,1]
Output:
[1,0,0]
</code>```

答:
Java, 15 bytes

```<code>s->s.map(b->!b)
</code>```

Note: s is a java.util.stream.Stream<Boolean> and the import is not necessary, proof below.

Testing and ungolfed

LookMaNoImports.java

```<code>class LookMaNoImports {
  static Main.F f = s -> // transform a Stream<Boolean>
    s.map(               // by applying its map method
      b ->               // which in turns transforms a boolean
        !b               // by applying its negation.
    );
}
</code>```

Main.java

```<code>    import java.util.Arrays;
    import java.util.List;
    import java.util.stream.Collectors;
    import java.util.stream.Stream;

    public class Main {

        interface F {
            Stream<Boolean> f(Stream<Boolean> s);
        }

        public static void main(String[] args) {
            F f=LookMaNoImports.f;

            test(f, new Boolean[]{true}, new Boolean[]{false});
            test(f, new Boolean[]{false}, new Boolean[]{true});
            test(f, new Boolean[]{true, false}, new Boolean[]{false, true});
            test(f, new Boolean[]{true, true}, new Boolean[]{false, false});
        }

        static void test(F f, Boolean[] param, Boolean[] expected) {
            List<Boolean> result = f.f(Arrays.stream(param)).collect(Collectors.toList());
            if (result.equals(Arrays.asList(expected))) {
                System.out.printf("%s: OK%n", Arrays.toString(param));
            } else {
                System.out.printf("%s: NOT OK, expected %s%n", Arrays.toString(param), Arrays.toString(expected));
            }
        }
    }
</code>```

Title: Invert a boolean array

Body:
Java, 15 bytes

s->s.map(b->!b)

Note: s is a java.util.stream.Stream<Boolean> and the import is not necessary, proof below.

Testing and ungolfed

LookMaNoImports.java

class LookMaNoImports {
  static Main.F f = s -> // transform a Stream<Boolean>
    s.map(               // by applying its map method
      b ->               // which in turns transforms a boolean
        !b               // by applying its negation.
    );
}

Main.java

    import java.util.Arrays;
    import java.util.List;
    import java.util.stream.Collectors;
    import java.util.stream.Stream;

    public class Main {

        interface F {
            Stream<Boolean> f(Stream<Boolean> s);
        }

        public static void main(String[] args) {
            F f=LookMaNoImports.f;

            test(f, new Boolean[]{true}, new Boolean[]{false});
            test(f, new Boolean[]{false}, new Boolean[]{true});
            test(f, new Boolean[]{true, false}, new Boolean[]{false, true});
            test(f, new Boolean[]{true, true}, new Boolean[]{false, false});
        }

        static void test(F f, Boolean[] param, Boolean[] expected) {
            List<Boolean> result = f.f(Arrays.stream(param)).collect(Collectors.toList());
            if (result.equals(Arrays.asList(expected))) {
                System.out.printf("%s: OK%n", Arrays.toString(param));
            } else {
                System.out.printf("%s: NOT OK, expected %s%n", Arrays.toString(param), Arrays.toString(expected));
            }
        }
    }


Title: Print a layered cake

Body:
PHP, <s>150</s> <s>147</s> <s>138</s> <s>136</s> <s>130</s> 140 bytes

new approach:

echo$p=str_pad("",-2+2*$n=$argv[1])," _|_|_";for($x="    ",$b=$y="----";$n--;){$a.=$x;if($n)$b.=$y;echo"
$p| $a|
",$p=substr($p,2),"+-$b+";}

old version for reference:

$p=str_pad;for($o=["_|_|_"];$i++<$n=$argv[1];$o[]="+".$p("",($i<$n)*4+$e,"-")."+")$o[]="|".$p("",$e=$i*4+1)."|";foreach($o as$s)echo$p($s,$n*4+3," ",2),"
";


答:
05AB1E, <s>115</s>, 101 chars

```<code>>UXð×?" _|_|_",Xð×?"|     |",X<U0<VXGNVXY-ð×?'+?8Y·+G'-?}'+,XY-ð×?'|?7Y·+ð×?'|,}XY-ð×?'+?8Y·+G'-?}'+,
</code>```

Saved 14 chars thanks to Adnan!

Definitely some room for golfing here.

Try it online!

Note that this does print everything offset by one space.

Title: Print a layered cake

Body:
Challenge

Given an input n, print an ASCII art cake n layers tall, viewed from the side, with two candles on top. Refer to the examples below for details.

Output

```<code>>> cake(1)

 _|_|_
|     |
+-----+

>> cake(3)

     _|_|_
    |     |
  +---------+
  |         |
+-------------+
|             |
+-------------+
</code>```

...and so on.

Rules

Standard loopholes prohibited

Please make an attempt at a clever solution

This is code-golf, so shortest answer in bytes wins. However, the answer will not be selected.

Have fun!

Body:
05AB1E, <s>115</s>, 101 chars

>UXð×?" _|_|_",Xð×?"|     |",X<U0<VXGNVXY-ð×?'+?8Y·+G'-?}'+,XY-ð×?'|?7Y·+ð×?'|,}XY-ð×?'+?8Y·+G'-?}'+,

Saved 14 chars thanks to Adnan!

Definitely some room for golfing here.

Try it online!

Note that this does print everything offset by one space.


问:
StringgnirtSStringgnirtSStringgnirtS
Here is a relatively simple challenge for you.

Given a string of length N, output the string forwards, then backwards, then forwards, then backwards... etc. N times. For example, if your input was

```<code>Hello!
</code>```

You should output:

```<code>Hello!!olleHHello!!olleHHello!!olleH
</code>```

You may also optionally output one trailing newline.

Your submission may be either a full program or a function, and you may take input and output in any reasonable format. For example, you may take IO from STDIN/STDOUT, function arguments and return value, from a file, etc. You can safely assume that the input string will not be empty, and will only contain printable ASCII. You must output the new string on a single line. So, for example, if the output to the last example was

```<code>Hello!
!olleH
Hello!
!olleH
Hello!
!olleH
</code>```

This would not be a valid solution!

Here are some more test cases:

```<code>Input:
a
Output:
a

Input:
abcd
Output:
abcddcbaabcddcba

Input:
OK!
Output:
OK!!KOOK!

Input:
4815162342
Output:
4815162342243261518448151623422432615184481516234224326151844815162342243261518448151623422432615184

Input:
PPCG
Output:
PPCGGCPPPPCGGCPP

Input:
42
Output:
4224
</code>```

Leaderboards

Since this is a code-golf challenge, standard loopholes are banned, and the shortest answer in bytes wins! However, this is also a competition to have the shortest answer in any particular langauge. While it's unlikely that a Java answer will beat an answer in perl, or some golfing language, it's still very impressive to have the shortest Java answer. So, you can use this leaderboard to see both

The shortest answer out of all languages, and

The shortest answer in each individual language.

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

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

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

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

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

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

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

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
bash + util-linux, 68 58 53 bytes

```<code>y=$1;for((i;i<${#1};i++)){ echo -n $y;y=`rev<<<$y`;}
</code>```

Explanation

Two things with the for loop:

There is an apparently undocumented way of writing for loops where one replaces the do and done keywords with curly braces { and }. The space after the first bracket is necessary, and the semicolon at the end is also necessary.

It turns out that in the "C-style" for loops, you can just initialize with i; instead of using i=0;.

The ${#1} part of the condition i < ${#1} refers to the length of our input (the first parameter $1). In general, you can use ${#foo} to retrieve the size of the string $foo.

Additionally:

rev is the tool in util-linux that reverses a string.

We need to pass the -n flag to echo to get rid of newlines.

The expression rev<<<$y is called a here-string (see this relevant tldp.org page), which passes the variable $y to the standard input of rev.

Title: StringgnirtSStringgnirtSStringgnirtS

Body:
bash + util-linux, 68 58 53 bytes

y=$1;for((i;i<${#1};i++)){ echo -n $y;y=`rev<<<$y`;}

Explanation

Two things with the for loop:

There is an apparently undocumented way of writing for loops where one replaces the do and done keywords with curly braces { and }. The space after the first bracket is necessary, and the semicolon at the end is also necessary.

It turns out that in the "C-style" for loops, you can just initialize with i; instead of using i=0;.

The ${#1} part of the condition i < ${#1} refers to the length of our input (the first parameter $1). In general, you can use ${#foo} to retrieve the size of the string $foo.

Additionally:

rev is the tool in util-linux that reverses a string.

We need to pass the -n flag to echo to get rid of newlines.

The expression rev<<<$y is called a here-string (see this relevant tldp.org page), which passes the variable $y to the standard input of rev.


答:
Pyth, 20 bytes

```<code>Lm-13.adbsyy-M.:CMQ2
</code>```

A program that takes input of a quoted string on STDIN and prints the result.

Try it online

How it works

```<code>Lm-13.adbsyy-M.:CMQ2  Program. Input: Q
L                     def y(b) ->
 m      b              Map over b with variable d:
  -13                   13-
     .ad                abs(d)
                CMQ   Map code-point over Q
              .:   2  All length 2 sublists of that
            -M        Map subtraction over that
          yy          y(y(that))
         s            Sum of that
                      Implicitly print
</code>```

Title: String Distance

Body:
Pyth, 20 bytes

Lm-13.adbsyy-M.:CMQ2

A program that takes input of a quoted string on STDIN and prints the result.

Try it online

How it works

Lm-13.adbsyy-M.:CMQ2  Program. Input: Q
L                     def y(b) ->
 m      b              Map over b with variable d:
  -13                   13-
     .ad                abs(d)
                CMQ   Map code-point over Q
              .:   2  All length 2 sublists of that
            -M        Map subtraction over that
          yy          y(y(that))
         s            Sum of that
                      Implicitly print


答:
Python 2 - 41 bytes

```<code>lambda l:max((-len(`x`),x) for x in l)[1]
</code>```

Title: Output the largest number with the fewest digits

Body:
Given a nonempty list of positive decimal integers, output the largest number from the set of numbers with the fewest digits.

The input list will not be in any particular order and may contain repeated values.

Examples:

```<code>[1] -> 1
[9] -> 9
[1729] -> 1729
[1, 1] -> 1
[34, 3] -> 3
[38, 39] -> 39
[409, 12, 13] -> 13
[11, 11, 11, 1] -> 1
[11, 11, 11, 11] -> 11
[78, 99, 620, 1] -> 1
[78, 99, 620, 10] -> 99
[78, 99, 620, 100] -> 99
[1, 5, 9, 12, 63, 102] -> 9
[3451, 29820, 2983, 1223, 1337] -> 3451
[738, 2383, 281, 938, 212, 1010] -> 938
</code>```

The shortest code in bytes wins.

Body:
Python 2 - 41 bytes

lambda l:max((-len(`x`),x) for x in l)[1]


答:
JavaScript (ES6), <s>58</s> 52 bytes

Builds the string recursively.

```<code>f=(n=64)=>n--?f(n)+(!n|n&15?'':`
`)+(n>>(n>>4)&1):''
</code>```

How it works

This recursion is based on the fact that the pattern is made of the vertical binary representation of nibbles 0x0 to 0xF:

```<code>  0101010101010101 bit #0 <- Y = 0
  0011001100110011 bit #1
  0000111100001111 bit #2
  0000000011111111 bit #3 <- Y = 3
  ----------------
  0123456789ABCDEF
  ^              ^
X = 0          X = 15
</code>```

Therefore, each position (X,Y) in this pattern can be expressed as the Y-th bit of X: X & (1 << Y). We can also isolate this bit with: (X >> Y) & 1. Rather than keeping track of X and Y, we iterate on a single variable n ranging from 0 to 63. So, the formula becomes: (n >> (n >> 4)) & 1. It's actually easier to iterate from 63 to 0, so the string is built in reverse order. In other words, character n-1 is appended to the left of character n.

As a side note, recursion doesn't bring anything here except shorter code.

Without the linebreaks, the code is 35 bytes long:

```<code>f=(n=64)=>n--?f(n)+(n>>(n>>4)&1):''
</code>```

We need 17 more bytes to insert the linebreaks. This could be shortened to 14 bytes if a leading linebreak is acceptable.

Demo

f=(n=64)=>n--?f(n)+(!n|n&15?'':`
`)+(n>>(n>>4)&1):''

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

Title: Generate a Universal-binary-function Lookup Table

Body:
This is tangentially related to my quest to invent an esoteric programming language.

A table of the binary numbers 0 .. 15 can be used to implement a Universal Binary Function using indexing operations. Given two 1-bit inputs X and Y, all 16 possible functions can be encoded in a 4-bit opcode.

```<code>X Y  F|0 1 2 3 4 5 6 7 8 9 A B C D E F
- -    - - - - - - - - - - - - - - - -
0 0    0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
0 1    0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
1 0    0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
1 1    0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
       -     -   - -   -   -   -   - -
       0    ~X  ~Y ^   &   Y   X   | 1
      ZERO    NOT-Y   AND         OR
          NOT-X   XOR              ONE
</code>```

So this set of 16 functions can be applied to binary inputs as the function

U(f,x,y): (f >> ((x<<1) | y)) & 1,

or

U(f,x,y): (f / 2^(x×2 + y)) % 2,

or with indexing or matrix partitioning.

It will be useful to know the most compact way to represent or generate such a table of values for any possible languages to be built upon this type of binary operation.

The goal:

Generate this exact text output:

```<code>0101010101010101
0011001100110011
0000111100001111
0000000011111111
</code>```

That's it! Shortest-code wins.

Body:
JavaScript (ES6), <s>58</s> 52 bytes

Builds the string recursively.

f=(n=64)=>n--?f(n)+(!n|n&15?'':`
`)+(n>>(n>>4)&1):''

How it works

This recursion is based on the fact that the pattern is made of the vertical binary representation of nibbles 0x0 to 0xF:

  0101010101010101 bit #0 <- Y = 0
  0011001100110011 bit #1
  0000111100001111 bit #2
  0000000011111111 bit #3 <- Y = 3
  ----------------
  0123456789ABCDEF
  ^              ^
X = 0          X = 15

Therefore, each position (X,Y) in this pattern can be expressed as the Y-th bit of X: X & (1 << Y). We can also isolate this bit with: (X >> Y) & 1. Rather than keeping track of X and Y, we iterate on a single variable n ranging from 0 to 63. So, the formula becomes: (n >> (n >> 4)) & 1. It's actually easier to iterate from 63 to 0, so the string is built in reverse order. In other words, character n-1 is appended to the left of character n.

As a side note, recursion doesn't bring anything here except shorter code.

Without the linebreaks, the code is 35 bytes long:

f=(n=64)=>n--?f(n)+(n>>(n>>4)&1):''

We need 17 more bytes to insert the linebreaks. This could be shortened to 14 bytes if a leading linebreak is acceptable.

Demo

f=(n=64)=>n--?f(n)+(!n|n&15?'':`
`)+(n>>(n>>4)&1):''

console.log(f());