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

```

答:
Bash + GNU utilities, 26

```<code>seq NaN|sed '1i0
p;s/^/-/'
</code>```

Title: Print all integers

Body:
Bash + GNU utilities, 26

seq NaN|sed '1i0
p;s/^/-/'


答:
Commodore Basic, 18 bytes

```<code>1N=N+1:?N,1-N,:G┌1
</code>```

PETSCII substitution: ┌ = SHIFT+O

Prints the sequence "1, 0, 2, -1, 3, -2...", with characters separated by tabs.

ContentLicense: CC BY-SA 3.0

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:
Commodore Basic, 18 bytes

1N=N+1:?N,1-N,:G┌1

PETSCII substitution: ┌ = SHIFT+O

Prints the sequence "1, 0, 2, -1, 3, -2...", with characters separated by tabs.


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

Title: Invert a boolean array

Body:
Gogh, 4 bytes

{!}m

Usage:

$ ./gogh -noa '{!}m' "1 0 1 0 0 0 1"
[0 1 0 1 1 1 0]


答:
Racket, 15 bytes

(curry map not)
```

Basically the Haskell answer.

Title: Invert a boolean array

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

Body:
Racket, 15 bytes

(curry map not)

Basically the Haskell answer.


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

OwnerDisplayName: Judy

ContentLicense: CC BY-SA 4.0

Body:
Brainfuck - 534

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

My prng (from here) is both large and extremely slow. Perhaps a simpler LFSR or similar would suffice, but this works:


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

答:
C# 72 bytes

```<code>int S(int[]i){return i.OrderBy(v=>(""+v).Length).ThenBy(v=>-v).First();}
</code>```

Borrowing from some of the other answers, a very efficient way to accomplish this task is to sort by number of digits, then by value descending.  This moves the answer to the first position.  Linq accomplishes this fairly simply with the OrderBy and ThenBy statements.

```<code>Console.WriteLine(S(new[] { 738, 2383, 281, 938, 212, 1010 }));
</code>```

Output: 938

Body:
C# 72 bytes

int S(int[]i){return i.OrderBy(v=>(""+v).Length).ThenBy(v=>-v).First();}

Borrowing from some of the other answers, a very efficient way to accomplish this task is to sort by number of digits, then by value descending.  This moves the answer to the first position.  Linq accomplishes this fairly simply with the OrderBy and ThenBy statements.

Console.WriteLine(S(new[] { 738, 2383, 281, 938, 212, 1010 }));

Output: 938


问:
Lord of the Golfs

Intro

In J. R. R. Tolkien's Lord of the Rings, this phrase is on the cover of each book.

```<code>Three Rings for the Elven-kings under the sky,
Seven for the Dwarf-lords in their halls of stone,
Nine for Mortal Men doomed to die,
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
One Ring to rule them all, One Ring to find them,
One Ring to bring them all, and in the darkness bind them,
In the Land of Mordor where the Shadows lie
</code>```

However, this isn't that interesting. It's just kolmogorov-complexity. Let's change this to interesting-nonconstant-output.

What you have to do

Use the Stack Exchange API (or codegolf.stackexchange.com/users, or the Stack Exchange Data Explorer) and find the two users with the highest scores in code-golf, the newest user, and highest-reputation user with only negatively scored code-golf post.

Then, you must insert these usernames into the following text:

```<code>Three Golfs for the <highest-scored code-golf user>-king under the sky,
Seven for the <second-highest-scored code-golf user>-lord in their halls of stone,
Nine for the Mortal <newest user> doomed to die,
One for the Dark Lord <highest reuptation user with only negative scored code-golf posts>
In the land of Golfdor, where the Golfers lie
One Golf to rule them all, One Golf to find them,
One Golf to bring them all, and in the darkness bind them,
In the Land of Golfdor, where the Golfers lie
</code>```

You must insert the four usernames you found into the text in the angle-brackets.

Other Rules

This is code-golf so the shortest code wins.

No URL Shorteners (including ppcg.(ga|lol))

答:
PHP, 577 bytes

not tested; I currently have no system available with allow_url_fopen=On

and I didn´t take the time to copy&paste the page sources.

```<code>function g($s){return join(file("http://codegolf.stackexchange.com/$s"));}$m=preg_match_all;$m("#r-de.+/(\d+)/.+>(.+)<#U",$a=g($u="$u&filter=all"),$b);$h=$b[2];$m("#>(.+)</a.+\s1 i#",g("users?tab=NewUsers&sort=creationdate"),$c);while($a){foreach($b[1]as$i=>$n)if($m("#st \"><strong>(-?)\d+#",$e=g("search?tab=votes&q=user:$n+[code-golf]"),$d)&&$d[1][0])break 2;if($a=strstr($a,"l=\"n"))$m("#r-de.+/(\d+)/.+>(.+)<#U",$a=g("$u&page=".$p+=!$p++),$b);}$m("#<code>(.+)</code>#U",g("q/93545"),$t);echo join([1=>$h[0],3=>$h[1],5=>$c[1][0],7=>$b[2][$i];]+split("#&[lg]t;#",$t[1][2]));
</code>```

breakdown

```<code>// function to get page content from ppcg
function g($s){return join(file("http://codegolf.stackexchange.com/$s"));}

$m=preg_match_all;

// A,B: highest scores: find user names
$m("#r-de.+/(\d+)/.+>(.+)<#U",$a=g($u="users?filter=all"),$b);
$h=$b[2];   // remember the names

// C: new users: find username after "1 in one day"
$m("#>(.+)</a.+\s1 i#",g("$u&tab=NewUsers&sort=creationdate"),$c);

// D: loop through users from first query
while($a)
{
    foreach($b[1]as$i=>$n)
        // find "vote-count-post" in code-golf votes for that user
        if($m("#st \"><strong>(-?)\d+#",$e=g("search?tab=votes&q=user:$n+[code-golf]"),$d)
        &&$d[1][0])             // test if highest vote is negative
            break 2;
    // none found yet?
    if($a=strstr($a,"l=\"n"))   // if there is a "next" link, get next page
        $m("#r-de.+/(\d+)/.+>(.+)<#U",$a=g("$u&page=".$p+=!$p++),$b);
}

$m("#<code>(.+)</code>#U",g("q/93545"),$t); // get code blocks from question page

echo join([         // 4. join and print
    1=>$h[0],           // first two results from first preg_match
    3=>$h[1],
    5=>$c[1][0],        // first result from second preg_match
    7=>$b[2][$i];       // $i-th username from (latest) reputation list
]+                  // 3. and replace indexes 1,3,5,7 with above array
split("#&[lg]t;#",  // 2. split by "<" and ">"
    $t[1][2]        // 1. output template is the 3rd code block
));
</code>```

Title: Lord of the Golfs

Body:
PHP, 577 bytes

not tested; I currently have no system available with allow_url_fopen=On

and I didn´t take the time to copy&paste the page sources.

function g($s){return join(file("http://codegolf.stackexchange.com/$s"));}$m=preg_match_all;$m("#r-de.+/(\d+)/.+>(.+)<#U",$a=g($u="$u&filter=all"),$b);$h=$b[2];$m("#>(.+)</a.+\s1 i#",g("users?tab=NewUsers&sort=creationdate"),$c);while($a){foreach($b[1]as$i=>$n)if($m("#st \"><strong>(-?)\d+#",$e=g("search?tab=votes&q=user:$n+[code-golf]"),$d)&&$d[1][0])break 2;if($a=strstr($a,"l=\"n"))$m("#r-de.+/(\d+)/.+>(.+)<#U",$a=g("$u&page=".$p+=!$p++),$b);}$m("#<code>(.+)</code>#U",g("q/93545"),$t);echo join([1=>$h[0],3=>$h[1],5=>$c[1][0],7=>$b[2][$i];]+split("#&[lg]t;#",$t[1][2]));

breakdown

// function to get page content from ppcg
function g($s){return join(file("http://codegolf.stackexchange.com/$s"));}

$m=preg_match_all;

// A,B: highest scores: find user names
$m("#r-de.+/(\d+)/.+>(.+)<#U",$a=g($u="users?filter=all"),$b);
$h=$b[2];   // remember the names

// C: new users: find username after "1 in one day"
$m("#>(.+)</a.+\s1 i#",g("$u&tab=NewUsers&sort=creationdate"),$c);

// D: loop through users from first query
while($a)
{
    foreach($b[1]as$i=>$n)
        // find "vote-count-post" in code-golf votes for that user
        if($m("#st \"><strong>(-?)\d+#",$e=g("search?tab=votes&q=user:$n+[code-golf]"),$d)
        &&$d[1][0])             // test if highest vote is negative
            break 2;
    // none found yet?
    if($a=strstr($a,"l=\"n"))   // if there is a "next" link, get next page
        $m("#r-de.+/(\d+)/.+>(.+)<#U",$a=g("$u&page=".$p+=!$p++),$b);
}

$m("#<code>(.+)</code>#U",g("q/93545"),$t); // get code blocks from question page

echo join([         // 4. join and print
    1=>$h[0],           // first two results from first preg_match
    3=>$h[1],
    5=>$c[1][0],        // first result from second preg_match
    7=>$b[2][$i];       // $i-th username from (latest) reputation list
]+                  // 3. and replace indexes 1,3,5,7 with above array
split("#&[lg]t;#",  // 2. split by "<" and ">"
    $t[1][2]        // 1. output template is the 3rd code block
));


答:
C# 222 bytes (Infinite output version)

Being more fond of the infinite output version of the print-all-integers program, I created this.

```<code>IEnumerable<string>g(){var w=new[]{'0'};yield return "0";while(true){var c=true;for (var r=w.Length-1;c&&r>=0;r--)if(c=++w[r]==58)w[r]='0';var b=new string(w);if(c)w=(b="1"+b).ToArray();yield return b;yield return "-"+b;}}
</code>```

This function continuously returns the next greater positive and negative integers.  The values are not limited by the integer type but since integers are used to handle the array, the program will fail when the number has more than 2,147,483,647 digits.  However, it will most likely run out of memory long before that happens.

Usage:

```<code>static void Main(string[] args)
{
    foreach (var n in g())
    {
        Console.WriteLine(n);
    }
}
</code>```

Title: Print all integers

Body:
C# 222 bytes (Infinite output version)

Being more fond of the infinite output version of the print-all-integers program, I created this.

IEnumerable<string>g(){var w=new[]{'0'};yield return "0";while(true){var c=true;for (var r=w.Length-1;c&&r>=0;r--)if(c=++w[r]==58)w[r]='0';var b=new string(w);if(c)w=(b="1"+b).ToArray();yield return b;yield return "-"+b;}}

This function continuously returns the next greater positive and negative integers.  The values are not limited by the integer type but since integers are used to handle the array, the program will fail when the number has more than 2,147,483,647 digits.  However, it will most likely run out of memory long before that happens.

Usage:

static void Main(string[] args)
{
    foreach (var n in g())
    {
        Console.WriteLine(n);
    }
}


问:
The shortest code to invert bit-wise a binary string
Me thinks there aren't enough easy questions on here that beginners can attempt!

The challenge: Given a random input string of 1's and 0's such as:

```<code>10101110101010010100010001010110101001010
</code>```

Write the shortest code that outputs the bit-wise inverse like so:

```<code>01010001010101101011101110101001010110101
</code>```

答:
Gogh, 5 bytes

```<code>{n!}m
</code>```

This takes the logical not of the integer value of each character in the string.

Body:
Gogh, 5 bytes

{n!}m

This takes the logical not of the integer value of each character in the string.


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

答:
Mathematica, 61 bytes

Thanks to miles for saving 2 bytes, plus a whole bunch of bytes I counted for no reason!

```<code>Last@Select[{n,(#/n)^(1/n)}~Table~{n,2Log@#},IntegerQ@*Last]&
</code>```

Computes a table of pairs {n,x}, where x = (i/n)^(1/n), using all possible values of n; keeps only those for which the corresponding x is an integer; then returns the pair with the largest value of n.

Here, "all possible values of n" ranges from 1 to 2*ln(i). This ignores the solution {n,x} = {i,1}, but that's okay since the solution {n,x} = {1,i} will suffice if it's the best choice. So x never needs to get smaller than 2, which means that n*2^n ≤ i, and all such n are less than 2*ln(i).

One can show using calculus that the pair {n,x} that minimizes their sum in this context is the same as the pair {n,x} with largest n (not counting {i,1}). That's why the initial Last is good enough to find the optimal pair.

Title: Misconstrued Monomials

Body:
Mathematica, 61 bytes

Thanks to miles for saving 2 bytes, plus a whole bunch of bytes I counted for no reason!

Last@Select[{n,(#/n)^(1/n)}~Table~{n,2Log@#},IntegerQ@*Last]&

Computes a table of pairs {n,x}, where x = (i/n)^(1/n), using all possible values of n; keeps only those for which the corresponding x is an integer; then returns the pair with the largest value of n.

Here, "all possible values of n" ranges from 1 to 2*ln(i). This ignores the solution {n,x} = {i,1}, but that's okay since the solution {n,x} = {1,i} will suffice if it's the best choice. So x never needs to get smaller than 2, which means that n*2^n ≤ i, and all such n are less than 2*ln(i).

One can show using calculus that the pair {n,x} that minimizes their sum in this context is the same as the pair {n,x} with largest n (not counting {i,1}). That's why the initial Last is good enough to find the optimal pair.


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

答:
Nothing says nostalgia quite like...

QBasic, 332 bytes

```<code>INPUT t,w,h
RANDOMIZE
CLS
1b=INT(RND*4)
d=b
IF b MOD 2THEN c=(b-1)/2*(w-1)+1:r=1+INT(RND*h)ELSE c=1+INT(RND*w):r=b/2*(h-1)+1
WHILE t
LOCATE r,c
m=(b+d)MOD 4
IF b=d THEN x=8.5*m ELSE x=13*m+(1<((b MOD m*3)+m)MOD 5)
?CHR$(179+x);
r=r-(d-1)MOD 2
c=c-(d-2)MOD 2
b=d
d=(4+d+INT(RND*1.25-.125))MOD 4
t=t-1
IF(r<=h)*(c<=w)*r*c=0GOTO 1
WEND
</code>```

QBasic is the right language for the task because:

Its encoding includes box drawing characters--no need for Unicode

LOCATE allows you to print to any location on the screen, overwriting what was there previously

Microsoft®

Specifics

This is golfed QBasic, written and tested on QB64 with autoformatting turned off. If you type/paste it into the actual QBasic IDE, it will add a bunch of spaces and expand ? into PRINT, but it should run exactly the same.

The program inputs three comma-separated values: ticks, width, and height. It then asks for a random-number seed. (If this behavior isn't acceptable, change the second line to RANDOMIZE TIMER for +6 bytes.) Finally, it draws the pipes to the screen.

The maximum dimensions that can be entered are 80 (width) by 25 (height). Giving a height of 25 will result in the bottom row getting cut off when QBasic says "Press any key to continue."

How?

TL;DR: A lot of math.

The current row and column are r and c; the current direction is d and the previous direction is b. Direction values 0-3 are down, right, up, left. Arithmetic translates those into the correct step values for r and c, as well as the correct edge coordinates to start on.

The box drawing characters │┐└─┘┌ are code points 179, 191, 192, 196, 217, and 218 in QBasic. Those appear pretty random, but it still used fewer characters to generate the numbers with some (pretty convoluted, I'm-not-sure-even-I-understand-it) math than to do a bunch of conditional statements.

The code for changing direction generates a random number between -0.125 and 1.125 and takes its floor. This gives -1 10% of the time, 0 80% of the time, and 1 10% of the time. We then add this to the current value of d, mod 4. Adding 0 keeps the current direction; adding +/-1 makes a turn.

As for control flow, the WHILE t ... WEND is the main loop; the section before it, starting with line number 1 (1b=INT(RND*4)), restarts the pipe at a random edge. Whenever r and c are outside the window, we GOTO 1.

Show me the GIF!

Here you go:

This was generated by a somewhat ungolfed version with animation, color, and an automatic random seed:

```<code>INPUT t, w, h
RANDOMIZE TIMER
CLS

restart:
' Calculate an edge to start from

b = INT(RND * 4)
'0: top edge (moving down)
'1: left edge (moving right)
'2: bottom edge (moving up)
'3: right edge (moving left)
d = b

' Calculate column and row for a random point on that edge
IF b MOD 2 THEN
    c = (b - 1) / 2 * (w - 1) + 1
    r = 1 + INT(RND * h)
ELSE
    c = 1 + INT(RND * w)
    r = b / 2 * (h - 1) + 1
END IF
COLOR INT(RND * 15) + 1

WHILE t
    ' Mathemagic to generate the correct box-drawing character
    m = (b + d) MOD 4
    IF b = d THEN
        x = 17 * m / 2
    ELSE
        x = 13 * m + (1 < ((b MOD m * 3) + m) MOD 5)
    END IF
    LOCATE r, c
    PRINT CHR$(179 + x);

    ' Update row and column
    r = r - (d - 1) MOD 2
    c = c - (d - 2) MOD 2
    ' Generate new direction (10% turn one way, 10% turn the other way,
    ' 80% go straight)
    b = d
    d = (4 + d + INT(RND * 1.25 - .125)) MOD 4

    ' Pause
    z = TIMER
    WHILE TIMER < z + 0.01
        IF z > TIMER THEN z = z - 86400
    WEND

    t = t - 1
    IF r > h OR c > w OR r = 0 OR c = 0 THEN GOTO restart
WEND
</code>```

Body:
Nothing says nostalgia quite like...

QBasic, 332 bytes

INPUT t,w,h
RANDOMIZE
CLS
1b=INT(RND*4)
d=b
IF b MOD 2THEN c=(b-1)/2*(w-1)+1:r=1+INT(RND*h)ELSE c=1+INT(RND*w):r=b/2*(h-1)+1
WHILE t
LOCATE r,c
m=(b+d)MOD 4
IF b=d THEN x=8.5*m ELSE x=13*m+(1<((b MOD m*3)+m)MOD 5)
?CHR$(179+x);
r=r-(d-1)MOD 2
c=c-(d-2)MOD 2
b=d
d=(4+d+INT(RND*1.25-.125))MOD 4
t=t-1
IF(r<=h)*(c<=w)*r*c=0GOTO 1
WEND

QBasic is the right language for the task because:

Its encoding includes box drawing characters--no need for Unicode

LOCATE allows you to print to any location on the screen, overwriting what was there previously

Microsoft®

Specifics

This is golfed QBasic, written and tested on QB64 with autoformatting turned off. If you type/paste it into the actual QBasic IDE, it will add a bunch of spaces and expand ? into PRINT, but it should run exactly the same.

The program inputs three comma-separated values: ticks, width, and height. It then asks for a random-number seed. (If this behavior isn't acceptable, change the second line to RANDOMIZE TIMER for +6 bytes.) Finally, it draws the pipes to the screen.

The maximum dimensions that can be entered are 80 (width) by 25 (height). Giving a height of 25 will result in the bottom row getting cut off when QBasic says "Press any key to continue."

How?

TL;DR: A lot of math.

The current row and column are r and c; the current direction is d and the previous direction is b. Direction values 0-3 are down, right, up, left. Arithmetic translates those into the correct step values for r and c, as well as the correct edge coordinates to start on.

The box drawing characters │┐└─┘┌ are code points 179, 191, 192, 196, 217, and 218 in QBasic. Those appear pretty random, but it still used fewer characters to generate the numbers with some (pretty convoluted, I'm-not-sure-even-I-understand-it) math than to do a bunch of conditional statements.

The code for changing direction generates a random number between -0.125 and 1.125 and takes its floor. This gives -1 10% of the time, 0 80% of the time, and 1 10% of the time. We then add this to the current value of d, mod 4. Adding 0 keeps the current direction; adding +/-1 makes a turn.

As for control flow, the WHILE t ... WEND is the main loop; the section before it, starting with line number 1 (1b=INT(RND*4)), restarts the pipe at a random edge. Whenever r and c are outside the window, we GOTO 1.

Show me the GIF!

Here you go:

This was generated by a somewhat ungolfed version with animation, color, and an automatic random seed:

INPUT t, w, h
RANDOMIZE TIMER
CLS

restart:
' Calculate an edge to start from

b = INT(RND * 4)
'0: top edge (moving down)
'1: left edge (moving right)
'2: bottom edge (moving up)
'3: right edge (moving left)
d = b

' Calculate column and row for a random point on that edge
IF b MOD 2 THEN
    c = (b - 1) / 2 * (w - 1) + 1
    r = 1 + INT(RND * h)
ELSE
    c = 1 + INT(RND * w)
    r = b / 2 * (h - 1) + 1
END IF
COLOR INT(RND * 15) + 1

WHILE t
    ' Mathemagic to generate the correct box-drawing character
    m = (b + d) MOD 4
    IF b = d THEN
        x = 17 * m / 2
    ELSE
        x = 13 * m + (1 < ((b MOD m * 3) + m) MOD 5)
    END IF
    LOCATE r, c
    PRINT CHR$(179 + x);

    ' Update row and column
    r = r - (d - 1) MOD 2
    c = c - (d - 2) MOD 2
    ' Generate new direction (10% turn one way, 10% turn the other way,
    ' 80% go straight)
    b = d
    d = (4 + d + INT(RND * 1.25 - .125)) MOD 4

    ' Pause
    z = TIMER
    WHILE TIMER < z + 0.01
        IF z > TIMER THEN z = z - 86400
    WEND

    t = t - 1
    IF r > h OR c > w OR r = 0 OR c = 0 THEN GOTO restart
WEND


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

Title: Print a layered cake

Body:
Python 2, 238 chars

i=input()
m=["+"+"-"*(i*4+1)+"+","|"+" "*(i*4+1)+"|"]
for v in range(i,1,-1):
 m+=[" "*(i-v)*2+"+"+"-"*(v*4+1)+"+"," "*(i-v+1)*2+"|"+" "*((v-1)*4+1)+"|"]
m.pop()
m+=[" "*(i-1)*2+"|"+" "*5+"|"," "*(i-1)*2+" _|_|_"]
print'\n'.join(m[::-1])

The missing example of Cake 2:

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


问:
Let's get Animated!

The Challenge

GIFs are the most common image format for animation, and are used pretty heavily in today's social media. For the purpose of this challenge, I'm going to redefine what a GIF can be. This challenge will require you to take in a 3D array containing some sort of representation of a 2D 'image' and iterate through them, displaying an animation. This animation can be done anywhere, in a GIF, in your console, in a GUI, etc; the delivery doesn't matter, so long as it is animated.

The Input

A 3D array where the data inside somehow represents a 2D image.

The array may contain RGB data, true/false data or anything else you see fit.

I'm also fine with you dumbing it down to a 2D array of strings or something similar, but the animation must be a 2D animation.

The time between each frame in a format of your choosing (Seconds, Milliseconds, etc...).

People have been asking me whether or not they HAVE to include the duration length. My answer is "meh", as long as you are able to show animation. I'm more concerned that you adhere to the "Array" parameter than this one, meaning no random animations.

The Output

A seamlessly iterated sequence of output that looks like a 2D animation with the correct delay on each transition based on the value input.

The Rules

Output can be, but is not limited to:

GIF image.

GUI animation (my example).

In-console animation.

Honestly, any "animation" that you see fit, as long as it follows the below rules.

When outputting your image you must clear the console before showing the next frame, you cannot just print them sequentially.

Emulating a console "clear" is also acceptable, as long as it looks like a seamless animation (see the hint under my example for more information on what I mean).

Regardless of implementation, your animation should loop forever, or until stopped.

The "looping" can be as simple as while(true){} or infinite recursion, you may assume the user wants to view this masterpiece until they hit "ctrl+c".

You must be able to handle any size 2D 'images', if your language is limited by buffer sizes, this is acceptable and you may state this in your explanation.

Standard loopholes are disallowed.

Example I/O

Input (3D Array, Delay)

```<code>f([
  [[1,0,0],
   [0,0,0],
   [0,0,0]],
  [[0,0,0],
   [0,1,0],
   [0,0,0]],
  [[0,0,0],
   [0,0,0],
   [0,0,1]],
], 1)
</code>```

Output (Example, 2020 Bytes - Java)

```<code>import javax.swing.JFrame;
import javax.swing.JTextArea;

/**
 * Simple GIF class to animate a 3D integer array in a swing text area.
 * (Clearing the console in java isn't something you really do, so I chose
 * java on purpose to make it an extremely ungolf-able answer that someone
 * wouldn't bother to steal).
 */
public class Gif implements Runnable {
    /**
     * The output area.
     */
    private final JTextArea area;

    /**
     * The list of images.
     */
    private final int[][][] images;

    /**
     * The delay between image transitions.
     */
    private final long transitionDelay;

    /**
     * Main method, instantiates a GIF object and runs it.
     * @param args Does absolutely nothing.
     */
    public static void main(String[] args) {
        final int[][][] images = {{{1,0,0},{0,0,0},{0,0,0}},{{0,0,0},{0,1,0},{0,0,0}},{{0,0,0},{0,0,0},{0,0,1}}};
        final long transitionDelay = 1000L;
        new Thread(new Gif(images, transitionDelay)).start();
    }

    /**
     * Constructor for a GIF, takes in a 3D array of images and a transition
     * delay to wait between transitioning the images.
     * @param images The list of images.
     * @param delay The delay between each image.
     */
    public Gif(int[][][] images, long transitionDelay) {
        this.images = images;
        this.transitionDelay = transitionDelay;
        this.area = new JTextArea();
        final JFrame frame = new JFrame("It's a GIF!");
        frame.setSize(10,100);
        frame.add(area);
        frame.setVisible(true);
    }

    /**
     * When run, it will alter the area to imitate an animated GIF.
     */
    @Override
    public void run() {
        while (true) {
            for (int i = 0; i < images.length; i++) {
                final StringBuffer frame = new StringBuffer();
                for (int j = 0; j < images[i].length; j++) {
                    for (int k = 0; k < images[i][j].length; k++) {
                        frame.append("" + images[i][j][k]);
                    }
                    frame.append("\n");
                }
                this.area.setText(frame.toString());
                try{Thread.sleep(transitionDelay);}catch(Exception e){}
                this.area.setText("");
            }
        }
    }
}
</code>```

This results in a swing GUI popping up, animating the array:

HINT HINT: Use a language where console clearing is possible, or specify why what you are doing will end up with a result that looks like an animation in the language you chose. I think some languages have default buffer sizes on their consoles, you may use this to your advantage, but I expect an explanation or example. Just because I output my animation as a string, you don't have to; I could've just as easily used 0 for black and 1 for white and made a real GIF.

Judging

This is code-golf, lowest byte count wins (inputs excluded).

I'll +1 anyone who uses a language in a cool or unexpected way as well.

答:
SmallBasic, 167 bytes

As a parameter, define and set the global var i!
Sadly, SmallBasic does not support parameters for own Sub-routines.

```<code>sub animate
for j=0 to Array.getItemCount(i)
for k=0 to Array.getItemCount(i[0])
TextWindow.writeLine(i[j][k])
endfor
Program.delay(9)
TextWindow.clear()
endfor
endsub
</code>```

Title: Let's get Animated!

Body:
SmallBasic, 167 bytes

As a parameter, define and set the global var i!
Sadly, SmallBasic does not support parameters for own Sub-routines.

sub animate
for j=0 to Array.getItemCount(i)
for k=0 to Array.getItemCount(i[0])
TextWindow.writeLine(i[j][k])
endfor
Program.delay(9)
TextWindow.clear()
endfor
endsub


答:
dc, 16 bytes

```<code>zpc[zp0r-prdx]dx
</code>```

Explanation:

```<code>zp    # Push stack depth (0) and peek (print top of stack and newline without popping)
c     # Clear stack
[     # Open macro definition
 z    #  Push stack depth (1 on first iteration, because this macro is on the stack)
 p    #  Peek (print positive number)
 0r-  #  Subtract ToS from 0 (make negative)
 p    #  Peek (print negative number)
 rdx  #  Rotate (move this macro on top of the negative number), duplicate, and execute
]dx   # Duplicate string and execute as macro
</code>```

This does feel a little too similar to yeti's answer; however, this solution makes use of all-natural, grass-fed, free-range negative numbers!

In case anyone finds these to be of interest, here are some other approaches I tried:

```<code>zp[zp_1/plax]dsax    # uses a named macro rather than a stack-squatting macro
zpc[zdp;ar-prdx]dx   # uses an array to fetch a 0 for subtracting from...in retrospect this
                     #  is just a longer way of writing `0' and has no advantages whatsoever

0p[z1-p_1~+prdx]dx   # uses ~ with -1 to convert a positive to a negative
0p[zp_1~+plax]dsax   # uses ~ with _1 in a named macro
                   #  The difference between the two above is in stack depth: Since the
                   #  named macro doesn't reside perpetually on the stack, we don't lose
                   #  access to a number through `z'. Because the first macro must stay on
                   #  the stack, we have to decrement (`1-') to start with 1 and -1. (Both
                   #  methods require explicitly printing 0 so that it's only printed once.)

0p[zp0r-pzz>a]dsax   # uses an always-true conditional, which is also kind of pointless
0p[zp_1*ddp=a]dsax   # `_1*' == `0r-';  `ddp=a' == `pzz>a'; just some alternative notations
z[p1+_1/p_1/lax]dsax # I don't remember what I was doing with these last two
[zpd_1/+z-p0d=a]dsax #
</code>```

Even though these other methods are all longer, I think at least half the fun is in discovering new mechanisms that one could adapt for use in other situations.

Title: Print all integers

Body:
dc, 16 bytes

zpc[zp0r-prdx]dx

Explanation:

zp    # Push stack depth (0) and peek (print top of stack and newline without popping)
c     # Clear stack
[     # Open macro definition
 z    #  Push stack depth (1 on first iteration, because this macro is on the stack)
 p    #  Peek (print positive number)
 0r-  #  Subtract ToS from 0 (make negative)
 p    #  Peek (print negative number)
 rdx  #  Rotate (move this macro on top of the negative number), duplicate, and execute
]dx   # Duplicate string and execute as macro

This does feel a little too similar to yeti's answer; however, this solution makes use of all-natural, grass-fed, free-range negative numbers!

In case anyone finds these to be of interest, here are some other approaches I tried:

zp[zp_1/plax]dsax    # uses a named macro rather than a stack-squatting macro
zpc[zdp;ar-prdx]dx   # uses an array to fetch a 0 for subtracting from...in retrospect this
                     #  is just a longer way of writing `0' and has no advantages whatsoever

0p[z1-p_1~+prdx]dx   # uses ~ with -1 to convert a positive to a negative
0p[zp_1~+plax]dsax   # uses ~ with _1 in a named macro
                   #  The difference between the two above is in stack depth: Since the
                   #  named macro doesn't reside perpetually on the stack, we don't lose
                   #  access to a number through `z'. Because the first macro must stay on
                   #  the stack, we have to decrement (`1-') to start with 1 and -1. (Both
                   #  methods require explicitly printing 0 so that it's only printed once.)

0p[zp0r-pzz>a]dsax   # uses an always-true conditional, which is also kind of pointless
0p[zp_1*ddp=a]dsax   # `_1*' == `0r-';  `ddp=a' == `pzz>a'; just some alternative notations
z[p1+_1/p_1/lax]dsax # I don't remember what I was doing with these last two
[zpd_1/+z-p0d=a]dsax #

Even though these other methods are all longer, I think at least half the fun is in discovering new mechanisms that one could adapt for use in other situations.


问:
English to Alien translator

Briefing

Aliens have settled on earth and strangely enough, their alphabet is the exact same as ours. Their language is also very similar to ours with some very distinct and easy to compute differences.

Challenge

Take a string and output the alien's language equivalent. The translation works as such:

Swap all the vowels in the word with the corresponding:

```<code>  Vowel |   With
--------+--------
   a    |   obo
   e    |   unu
   i    |   ini
   o    |   api
   u    |   iki
</code>```

You may also write another translator to translate Alien->English, this is optional however.

Examples

```<code>Input: Shaun
Output: Shoboikin

Input: Java
Output: Jobovobo

Input: Hello, World!
Output: Hunullapi, Wapirld!
</code>```

If the vowel is capitalized then you capitalize the first letter..

```<code>Input: Alan
Output: Obolobon

Input: Australia
Output: Oboikistroboliniobo
</code>```

Rules

Standard loopholes apply

Must work for text that contains new lines

You can either write a function, lambda, or full program

Capingrobotikilobotiniapins apin wrinitining thunu runuvunursunu trobonslobotapir!

答:
Ruby, 102 93 91 88 78 bytes

```<code>gsub(/[#{b='aeiouAEIOU'}]/){'obounuiniapiikiOboUnuIniApiIki'[b.index($&)*3,3]}
</code>```

Explanation:

Execute the line like ruby -pe "gsub(/[#{b='aeiouAEIOU'}]/){'obounuiniapiikiOboUnuIniApiIki'[b.index($&)*3,3]}", next up type, for example, Australia it should output: Oboikistroboliniobo.

It's pretty straightforward, replace all vowels with a substring based on the index of the to-be replaced vowel in (b), times 3 and the next 3 characters in the translation string.

Title: English to Alien translator

Body:
Ruby, 102 93 91 88 78 bytes

gsub(/[#{b='aeiouAEIOU'}]/){'obounuiniapiikiOboUnuIniApiIki'[b.index($&)*3,3]}

Explanation:

Execute the line like ruby -pe "gsub(/[#{b='aeiouAEIOU'}]/){'obounuiniapiikiOboUnuIniApiIki'[b.index($&)*3,3]}", next up type, for example, Australia it should output: Oboikistroboliniobo.

It's pretty straightforward, replace all vowels with a substring based on the index of the to-be replaced vowel in (b), times 3 and the next 3 characters in the translation string.


答:
C (GCC/linux), 402 353 352 302 300 298 296 288 bytes

```<code>#define R rand()%
x,y,w,h,r;main(c){srand(time(0));scanf(
"%d%d",&w,&h);for(printf("\e[2J");x%~w*
(y%~h)||(c=R 8,(r=R 4)&1?x=1+R w,y=r&2
?1:h:(y=1+R h,x=r&2?1:w));usleep('??'))
printf("\e[%dm\e[%d;%dH\342\224%c\e[H\n",
30+c,y,x,2*"@J_FHAF__L@HL_JA"[r*4|(r^=R 5
?0:1|R 4)]),x+=--r%2,y+=~-r++%2;}
</code>```

Credit to edc65 for storing the direction in a single 4-bit number.

Reads a width/height on stdin before looping the screensaver forever. E.g.:

```<code>gcc -w golf.c && echo "25 25" | ./a.out
</code>```

Or for a full-screen screensaver:

```<code>gcc -w golf.c && resize | sed 's/[^0-9]*//g' | ./a.out
</code>```

For readability I added newlines. Requires a linux machine with a terminal respecting ANSI codes. Has colors! If you remove color support it costs 17 bytes less.

Title: Recreate the Windows ME screensaver as ASCII

Body:
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 :)

Body:
C (GCC/linux), 402 353 352 302 300 298 296 288 bytes

#define R rand()%
x,y,w,h,r;main(c){srand(time(0));scanf(
"%d%d",&w,&h);for(printf("\e[2J");x%~w*
(y%~h)||(c=R 8,(r=R 4)&1?x=1+R w,y=r&2
?1:h:(y=1+R h,x=r&2?1:w));usleep('??'))
printf("\e[%dm\e[%d;%dH\342\224%c\e[H\n",
30+c,y,x,2*"@J_FHAF__L@HL_JA"[r*4|(r^=R 5
?0:1|R 4)]),x+=--r%2,y+=~-r++%2;}

Credit to edc65 for storing the direction in a single 4-bit number.

Reads a width/height on stdin before looping the screensaver forever. E.g.:

gcc -w golf.c && echo "25 25" | ./a.out

Or for a full-screen screensaver:

gcc -w golf.c && resize | sed 's/[^0-9]*//g' | ./a.out

For readability I added newlines. Requires a linux machine with a terminal respecting ANSI codes. Has colors! If you remove color support it costs 17 bytes less.


问:
Decode the chmod

Challenge

Given a three digit octal permissions number, output the permissions that it grants.

chmod

On UNIX OSes file permissions are changed using the chmod command. There are few different ways of using chmod, but the one we will focus on today is using octal permissions.

The three digits in the permissions number represent a different person:

The first digit represents the permissions for the user

The second digit represents the permissions for the group

The last digit represents the permissions for others

Next, each digit represents a permission as shown below in:

```<code>Key: number | permission

7 | Read Write and Execute
6 | Read and Write
5 | Read and Execute
4 | Read only
3 | Write and Execute
2 | Write only
1 | Execute only
0 | None
</code>```

Input

The input will be the three digit number as a string, e.g.:

```<code>133
</code>```

or

```<code>007
</code>```

This will be passed either via STDIN or via function arguments.

Output

Your output should be the different permissions for each of the user, the group and the others. You must display this information like so:

```<code>User:   ddd
Group:  ddd
Others: ddd
</code>```

Where there are three spaces after User, two spaces after Group and one space after Others. You replace ddd with the permissions information.

Your output may be to STDOUT or as a returned string.

Examples

Input: 666

Output:

```<code>User:   Read and Write
Group:  Read and Write
Others: Read and Write
</code>```

Input: 042

Output:

```<code>User:   None
Group:  Read only
Others: Write only
</code>```

Input: 644

Output:

```<code>User:   Read and Write
Group:  Read only
Others: Read only
</code>```

Winning

The shortest code in bytes wins.

答:
bash - 221 213 bytes

GNU bash, version 4.3.46

```<code>l=("User:   " "Group:  " "Others: ")
o=\ only;a=" and ";x=Execute;w=Write;r=Read
b=(None "$x$o" "$w$o" "$w$a$x" "$r$o" "$r$a$x" "$r$a$w" "$r $w$a$x")
for c in `echo $1|grep -o .`;{ echo "${l[$((z++))]}${b[$c]}";}
</code>```

Unclear if this can be condensed any further, at least not without fundamentally changing the approach here (splitting up input and using it as an index to the array ${b} that holds the corresponding strings).

Title: Decode the chmod

Body:
bash - 221 213 bytes

GNU bash, version 4.3.46

l=("User:   " "Group:  " "Others: ")
o=\ only;a=" and ";x=Execute;w=Write;r=Read
b=(None "$x$o" "$w$o" "$w$a$x" "$r$o" "$r$a$x" "$r$a$w" "$r $w$a$x")
for c in `echo $1|grep -o .`;{ echo "${l[$((z++))]}${b[$c]}";}

Unclear if this can be condensed any further, at least not without fundamentally changing the approach here (splitting up input and using it as an index to the array ${b} that holds the corresponding strings).


问:
Carmichael Numbers
Write a program to print Carmichael numbers. The challenge is to print the maximum number of them in less than 5 secs. The numbers should be in increasing order. Please do not use built in functions. Also please don't store the carmichael numbers in any form. To keep a common time measurement use Ideone. The program to print the maximum number of Carmichael number wins.

```<code>Sample Output
561
1105
1729
2465
2821
6601
8911
.
.
.
</code>```

OEIS A002997

答:
Python

This generates 1332 Carmichael numbers in under 5 seconds.  Remove the print to actually get ideone to run to completion.

```<code>N=180000

maxprime = 18*N+1
prime = [1]*maxprime
prime[0] = prime[1] = 0
for i in xrange(maxprime):
  if prime[i]:
    for j in xrange(2*i,maxprime,i):prime[j]=0

for i in xrange(N):
  a=6*i+1
  b=12*i+1
  c=18*i+1
  if prime[a] and prime[b] and prime[c]:print a*b*c
</code>```

Note that you could make this a whole lot faster in C.

Title: Carmichael Numbers

Body:
Python

This generates 1332 Carmichael numbers in under 5 seconds.  Remove the print to actually get ideone to run to completion.

N=180000

maxprime = 18*N+1
prime = [1]*maxprime
prime[0] = prime[1] = 0
for i in xrange(maxprime):
  if prime[i]:
    for j in xrange(2*i,maxprime,i):prime[j]=0

for i in xrange(N):
  a=6*i+1
  b=12*i+1
  c=18*i+1
  if prime[a] and prime[b] and prime[c]:print a*b*c

Note that you could make this a whole lot faster in C.

ContentLicense: CC BY-SA 2.5


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

答:
Befunge, 1

I don't know Befunge, but...

```<code>1
</code>```

from Stack overflow code golf

Body:
Befunge, 1

I don't know Befunge, but...

1

from Stack overflow code golf


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

(saved 12 bytes with suggestion by @StevenH)

(λ()(let l((i 0))(printf"~a, ~a, "i(- -1 i))(l(+ 1 i))))

Ungolfed:

(define(f)
  (let loop ((i 0))
     (printf "~a, ~a, "  i  (- -1 i))
     (loop (add1 i))))

Following can also be used:

(for((i(in-naturals)))(printf"~a, ~a, "i(- -1 i)))

or:

(for ((i (in-naturals)))
   (printf "~a, ~a, " i (- -1 i)))

Testing:

(f)

0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10, -11, 11, -12, 12, -13, 13, -14, 14, -15, 15, -16, 16, -17, 17, -18, 18, -19, 19, -20, 20, -21, 21, -22, 22, -23, 23


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

答:
MATL, <s>14</s>, 10 bytes

```<code>dt_v26\X<s
</code>```

Try it online!

Thanks @Suever for saving 4 bytes!

Explanation:

```<code>d           % Take the difference between consecutive characters
 t_         % Make a copy of this array, and take the negative of each element
   v        % Join these two arrays together into a matrix with height 2
    26\     % Mod 26 of each element
       X<   % Grab the minimum of each column
         s  % Sum these. Implicitly print
</code>```

Previous version:

```<code>d26\t13>26*-|s
</code>```

Title: String Distance

Body:
MATL, <s>14</s>, 10 bytes

dt_v26\X<s

Try it online!

Thanks @Suever for saving 4 bytes!

Explanation:

d           % Take the difference between consecutive characters
 t_         % Make a copy of this array, and take the negative of each element
   v        % Join these two arrays together into a matrix with height 2
    26\     % Mod 26 of each element
       X<   % Grab the minimum of each column
         s  % Sum these. Implicitly print

Previous version:

d26\t13>26*-|s


答:
Actually, 7 bytes

```<code>01W;±@u
</code>```

This solution requires infinite time to actually print anything. Finite memory will cause an out of memory error and premature printing. No TIO link for obvious reasons.

Explanation:

```<code>01W;±@u
0        push 0
 1       push 1
  W      infinite loop:
   ;       duplicate
    ±      unary negate
     @     swap with positive
      u    increment
</code>```

This solution works for 8 bytes, prints a finite amount of numbers in a finite amount of time, and uses significantly less memory (the memory used doesn't start growing until after INT_MAX is printed, at which point Python seamlessly transitions to arbitrary-precision integers).

```<code>0■~W■±■~
</code>```

Try it online! (only prints up to around 9292 due to timeout).

Explanation:

```<code>0■~W■±■~
0         push 0
 ■        print entire stack without popping (just the 0)
  ~       bitwise negate (~n is equivalent to -n-1)
   W      infinite loop:
    ■       print stack without popping
     ±      unary negate
      ■     print without pop
       ~    bitwise negate
</code>```

Title: Print all integers

Body:
Actually, 7 bytes

01W;±@u

This solution requires infinite time to actually print anything. Finite memory will cause an out of memory error and premature printing. No TIO link for obvious reasons.

Explanation:

01W;±@u
0        push 0
 1       push 1
  W      infinite loop:
   ;       duplicate
    ±      unary negate
     @     swap with positive
      u    increment

This solution works for 8 bytes, prints a finite amount of numbers in a finite amount of time, and uses significantly less memory (the memory used doesn't start growing until after INT_MAX is printed, at which point Python seamlessly transitions to arbitrary-precision integers).

0■~W■±■~

Try it online! (only prints up to around 9292 due to timeout).

Explanation:

0■~W■±■~
0         push 0
 ■        print entire stack without popping (just the 0)
  ~       bitwise negate (~n is equivalent to -n-1)
   W      infinite loop:
    ■       print stack without popping
     ±      unary negate
      ■     print without pop
       ~    bitwise negate


答:
dc, 44 bytes

Append this to a line of space-delimited input and echo it into dc. Output is delimited with newlines and punctuated with error messages (due to the blatant abuse of k). If you quote the stuff, it'll give you even more errors. (When we re-vamp dc in the next version, we should probably do something about that.) I suggest pairing with a 2>nul or other system-specific hack for suppressing whiny programs.

```<code>0sz[1r-SAlz1+szz0<a]dsax[lzd1-szLApk0<a]dsax
</code>```

Explained:

```<code>              # "ToS" := "top of stack"
0sz           # Initialise register `z' with 0: this will hold the length of our input
[             # Open macro definition
 1r-          #  Replace ToS with !(ToS): 1-1==0, 1-0==1
 SA           #  Store this result on the top of stack `A'
 lz1+sz       #  Increment z, our length counter
 z0<a         #  If the stack depth is positive, repeat (we still have input to negate)
]dsax         # Store a copy of macro in register `a' and execute it
              # At this point, our input has been negated and stored in A,
              #  first-in-first-out orientation
[             # Open macro definition
 lzd1-sz      #  Decrement z and keep a copy of it for later
 LA           #  Push ToS(A) onto stack; pop from A
 p            #  Peek at ToS
 k            #  `k' is for KILL THE TOP OF STACK BWAHAHAHA
 0<a          #  The value from register `z' is now on top: if positive, we still have
              #   values to print, so repeat macro
]dsax         # I'm in a chaotic mood, so let's just re-use `a'
</code>```

Title: Invert a boolean array

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

Body:
dc, 44 bytes

Append this to a line of space-delimited input and echo it into dc. Output is delimited with newlines and punctuated with error messages (due to the blatant abuse of k). If you quote the stuff, it'll give you even more errors. (When we re-vamp dc in the next version, we should probably do something about that.) I suggest pairing with a 2>nul or other system-specific hack for suppressing whiny programs.

0sz[1r-SAlz1+szz0<a]dsax[lzd1-szLApk0<a]dsax

Explained:

              # "ToS" := "top of stack"
0sz           # Initialise register `z' with 0: this will hold the length of our input
[             # Open macro definition
 1r-          #  Replace ToS with !(ToS): 1-1==0, 1-0==1
 SA           #  Store this result on the top of stack `A'
 lz1+sz       #  Increment z, our length counter
 z0<a         #  If the stack depth is positive, repeat (we still have input to negate)
]dsax         # Store a copy of macro in register `a' and execute it
              # At this point, our input has been negated and stored in A,
              #  first-in-first-out orientation
[             # Open macro definition
 lzd1-sz      #  Decrement z and keep a copy of it for later
 LA           #  Push ToS(A) onto stack; pop from A
 p            #  Peek at ToS
 k            #  `k' is for KILL THE TOP OF STACK BWAHAHAHA
 0<a          #  The value from register `z' is now on top: if positive, we still have
              #   values to print, so repeat macro
]dsax         # I'm in a chaotic mood, so let's just re-use `a'


答:
Python 3, 126 bytes

With list incomprehension.

```<code>d=input()
print(sum([min(abs(x-y),x+26-y)for x,y in[map(lambda x:(ord(x)-97),sorted(d[i:i+2]))for i in range(len(d))][:-1]]))
</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:
Python 3, 126 bytes

With list incomprehension.

d=input()
print(sum([min(abs(x-y),x+26-y)for x,y in[map(lambda x:(ord(x)-97),sorted(d[i:i+2]))for i in range(len(d))][:-1]]))


答:
Brachylog, 35 bytes

```<code>,[N:X]#>>==L(.rMtT;Lr.rMtT),M^:T*?,
</code>```

Try it online!

Explanation

We construct a list [N, X], where N >= X, then after assigning values to it, we  try both [N, X] and [X, N] as possible output. For example, if N gets assigned to 3, we will test through backtracking [3, 1], [1, 3], [3, 2], [2, 3], [3, 3] and [3, 3]. After that the next backtracking step will occur on the value of N, which will go to 4, etc.

```<code>,[N:X]     The list [N, X]
#>         Both N and X are strictly positive
>=         N >= X
=L         Assign values to N and X, and L = [N, X]
(          Either...
    .          Output = L
    rM         M is the reverse of the Output
    tT         T is the second element of M
;          ...or...
    Lr.        Output is the reverse of L
    rM         M = L
    tT         T is the last element of M
),
M^         First element of M to the power of the second element of L (T)...
:T*?,      ... times T is equal to the Input
</code>```

Title: Misconstrued Monomials

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

Body:
Brachylog, 35 bytes

,[N:X]#>>==L(.rMtT;Lr.rMtT),M^:T*?,

Try it online!

Explanation

We construct a list [N, X], where N >= X, then after assigning values to it, we  try both [N, X] and [X, N] as possible output. For example, if N gets assigned to 3, we will test through backtracking [3, 1], [1, 3], [3, 2], [2, 3], [3, 3] and [3, 3]. After that the next backtracking step will occur on the value of N, which will go to 4, etc.

,[N:X]     The list [N, X]
#>         Both N and X are strictly positive
>=         N >= X
=L         Assign values to N and X, and L = [N, X]
(          Either...
    .          Output = L
    rM         M is the reverse of the Output
    tT         T is the second element of M
;          ...or...
    Lr.        Output is the reverse of L
    rM         M = L
    tT         T is the last element of M
),
M^         First element of M to the power of the second element of L (T)...
:T*?,      ... times T is equal to the Input


答:
Mathematica, 128 bytes

```<code>#~StringReplace~{"a"->"obo","A"->"Obo","e"->"unu","E"->"Unu","i"->"ini","I"->"Ini","o"->"api","O"->"Api","u"->"iki","U"->"Iki"}&
</code>```

Not sure whether a shorter program can be obtained by using IgnoreCase->True together with a case check.

Title: English to Alien translator

Body:
Briefing

Aliens have settled on earth and strangely enough, their alphabet is the exact same as ours. Their language is also very similar to ours with some very distinct and easy to compute differences.

Challenge

Take a string and output the alien's language equivalent. The translation works as such:

Swap all the vowels in the word with the corresponding:

```<code>  Vowel |   With
--------+--------
   a    |   obo
   e    |   unu
   i    |   ini
   o    |   api
   u    |   iki
</code>```

You may also write another translator to translate Alien->English, this is optional however.

Examples

```<code>Input: Shaun
Output: Shoboikin

Input: Java
Output: Jobovobo

Input: Hello, World!
Output: Hunullapi, Wapirld!
</code>```

If the vowel is capitalized then you capitalize the first letter..

```<code>Input: Alan
Output: Obolobon

Input: Australia
Output: Oboikistroboliniobo
</code>```

Rules

Standard loopholes apply

Must work for text that contains new lines

You can either write a function, lambda, or full program

Capingrobotikilobotiniapins apin wrinitining thunu runuvunursunu trobonslobotapir!

Body:
Mathematica, 128 bytes

#~StringReplace~{"a"->"obo","A"->"Obo","e"->"unu","E"->"Unu","i"->"ini","I"->"Ini","o"->"api","O"->"Api","u"->"iki","U"->"Iki"}&

Not sure whether a shorter program can be obtained by using IgnoreCase->True together with a case check.


答:
JavaScript (ES6), <s>84</s> <s>82</s> 79 bytes

Saved 3 bytes thanks to Cyoce:

f=([d,...s],p=parseInt,v=(26+p(s[0],36)-p(d,36))%26)=>s[0]?f(s)+(v>13?26-v:v):0
```

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

<pre class="lang-js prettyprint-override"><code>f=(
  [d,...s],                    //Destructured input, separates first char from the rest
  p=parseInt,                  //p used as parseInt
  v=(26+p(s[0],36)-p(d,36))%26 //v is the absolute value of the difference using base 36 to get number from char
  )
)=>
  s[0]?                        //If there is at least two char in the input
    f(s)                       //sum recursive call
    +                          //added to
    (v>13?26-v:v)              //the current shortest path
  :                            //else
    0                          //ends the recursion, returns 0
</code>```

Example:

Call: f('golf')

Output: 17

Previous solutions :

82 bytes thanks to Neil:

f=([d,...s],v=(26+parseInt(s[0],36)-parseInt(d,36))%26)=>s[0]?f(s)+(v>13?26-v:v):0
```

<p>84 bytes:</p>

<pre class="lang-js prettyprint-override"><code>f=([d,...s],v=Math.abs(parseInt(s[0],36)-parseInt(d,36)))=>s[0]?f(s)+(v>13?26-v:v):0
</code>```

Title: String Distance

Body:
JavaScript (ES6), <s>84</s> <s>82</s> 79 bytes

Saved 3 bytes thanks to Cyoce:

f=([d,...s],p=parseInt,v=(26+p(s[0],36)-p(d,36))%26)=>s[0]?f(s)+(v>13?26-v:v):0

Explanation:

f=(
  [d,...s],                    //Destructured input, separates first char from the rest
  p=parseInt,                  //p used as parseInt
  v=(26+p(s[0],36)-p(d,36))%26 //v is the absolute value of the difference using base 36 to get number from char
  )
)=>
  s[0]?                        //If there is at least two char in the input
    f(s)                       //sum recursive call
    +                          //added to
    (v>13?26-v:v)              //the current shortest path
  :                            //else
    0                          //ends the recursion, returns 0

Example:

Call: f('golf')

Output: 17

Previous solutions :

82 bytes thanks to Neil:

f=([d,...s],v=(26+parseInt(s[0],36)-parseInt(d,36))%26)=>s[0]?f(s)+(v>13?26-v:v):0

84 bytes:

f=([d,...s],v=Math.abs(parseInt(s[0],36)-parseInt(d,36)))=>s[0]?f(s)+(v>13?26-v:v):0


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

答:
Jelly, <s>42</s> 7 bytes

```<code>⁴ḶBUz0Y
</code>```

Try it online!

Thanks to Dennis for his help. Here is the first message, here is the last (other discussions also occured). With his help, I apparently (almost) square-rooted the score.

Body:
Jelly, <s>42</s> 7 bytes

⁴ḶBUz0Y

Try it online!

Thanks to Dennis for his help. Here is the first message, here is the last (other discussions also occured). With his help, I apparently (almost) square-rooted the score.


答:
Jelly, <s>11</s> 8 bytes

```<code>OIæ%13AS
</code>```

Saved 3 bytes thanks to @Martin Ender.

Try it online! or Verify all test cases.

Explanation

```<code>OIæ%13AS  Input: string Z
O         Ordinal. Convert each char in Z to its ASCII value
 I        Increments. Find the difference between each pair of values
  æ%13    Symmetric mod. Maps each to the interval (-13, 13]
      A   Absolute value of each
       S  Sum
          Return implicitly
</code>```

Title: String Distance

Body:
Jelly, <s>11</s> 8 bytes

OIæ%13AS

Saved 3 bytes thanks to @Martin Ender.

Try it online! or Verify all test cases.

Explanation

OIæ%13AS  Input: string Z
O         Ordinal. Convert each char in Z to its ASCII value
 I        Increments. Find the difference between each pair of values
  æ%13    Symmetric mod. Maps each to the interval (-13, 13]
      A   Absolute value of each
       S  Sum
          Return implicitly


答:
MATL, 22 bytes

```<code>`T@XK:"@K@-@^*G=?3Mb~.
</code>```

Outputs are x, n in that order.

Input is limited by MATL's default double data type, which can accurately represent integers up to 2^53 only. This excludes the first test (still, it gives the correct result, but that can't be guaranteed in general for inputs so large).

Try it online!

Explanation

The code uses two nested loops:

The outer do...while loop goes through all possible sums n+x in increasing order. The loop will be stopped as soon as a solution is found. This guarantees that we output the solution with minimum sum.

The inner for each loop tests all n and x with that sum. When the sum coincides with the input, the inner loop is exited and the loop condition of the outer loop is set to false so that one is exited too.

Commented code:

```<code>`         % Do...while
  T       %   Push "true". Will be used as loop condition (possibly negated to exit loop)
  @       %   Push iteration index, say K, which represents n+x
  XK      %   Copy that into clipboard K
  :       %   Range [1 2 ... K]
  "       %   For each
    @     %     Push loop variable (1, 2, ... K), which represents n
    K@-   %     Compute x as K minus n
    @     %     Push n again
    ^*    %     Power, multiply. This gives n*x^n
    G=    %     Does this equal the input?
    ?     %     If so
      3M  %       Push the inputs of the third-last function, that is, x and n
      b   %       Bubble up the "true" that is at the bottom of the stack
      ~   %       Transform it into "false". This will exit the do...while loop
      .   %       Break the for loop
          %     Implicitly end if
          %   Implicitly end for
          % Implicitly end do...while
          % Implicitly display
</code>```

Title: Misconstrued Monomials

Body:
MATL, 22 bytes

`T@XK:"@K@-@^*G=?3Mb~.

Outputs are x, n in that order.

Input is limited by MATL's default double data type, which can accurately represent integers up to 2^53 only. This excludes the first test (still, it gives the correct result, but that can't be guaranteed in general for inputs so large).

Try it online!

Explanation

The code uses two nested loops:

The outer do...while loop goes through all possible sums n+x in increasing order. The loop will be stopped as soon as a solution is found. This guarantees that we output the solution with minimum sum.

The inner for each loop tests all n and x with that sum. When the sum coincides with the input, the inner loop is exited and the loop condition of the outer loop is set to false so that one is exited too.

Commented code:

`         % Do...while
  T       %   Push "true". Will be used as loop condition (possibly negated to exit loop)
  @       %   Push iteration index, say K, which represents n+x
  XK      %   Copy that into clipboard K
  :       %   Range [1 2 ... K]
  "       %   For each
    @     %     Push loop variable (1, 2, ... K), which represents n
    K@-   %     Compute x as K minus n
    @     %     Push n again
    ^*    %     Power, multiply. This gives n*x^n
    G=    %     Does this equal the input?
    ?     %     If so
      3M  %       Push the inputs of the third-last function, that is, x and n
      b   %       Bubble up the "true" that is at the bottom of the stack
      ~   %       Transform it into "false". This will exit the do...while loop
      .   %       Break the for loop
          %     Implicitly end if
          %   Implicitly end for
          % Implicitly end do...while
          % Implicitly display


问:
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:
Javascript (ES6), <s>119</s> <s>116</s> <s>96</s> <s>92</s> 91 bytes

for(i=8;i--;)console.log(`834
3554
2610
2160
7777`.replace(/./g,c=>'|/|/\\_\\- '[c<i?8:c]))


答:
PHP, 104 Bytes

```<code>for(;1<$x=(($i=$argv[1])/++$n)**(1/$n);)!($x==ceil($x))?:$a[$x+$n]="[$x, $n]";ksort($a);echo$a[key($a)];
</code>```

This outputs all possible solutions not in the proposed format 73 Bytes

```<code>for(;1<=$x=(($i=$argv[1])/++$n)**(1/$n);)!($x==ceil($x))?:print"$x,$n\n";
</code>```

Title: Misconstrued Monomials

Body:
PHP, 104 Bytes

for(;1<$x=(($i=$argv[1])/++$n)**(1/$n);)!($x==ceil($x))?:$a[$x+$n]="[$x, $n]";ksort($a);echo$a[key($a)];

This outputs all possible solutions not in the proposed format 73 Bytes

for(;1<=$x=(($i=$argv[1])/++$n)**(1/$n);)!($x==ceil($x))?:print"$x,$n\n";


答:
Python 3, <s>69</s> 68 bytes

```<code>lambda s:sum([13-abs(13-abs(ord(a)-ord(b)))for a,b in zip(s,s[1:])])
</code>```

Breakdown:

```<code>lambda s:
         sum(                                                      )
             [                             for a,b in zip(s,s[1:])]
              13-abs(13-abs(ord(a)-ord(b)))
</code>```

Title: String Distance

Body:
Python 3, <s>69</s> 68 bytes

lambda s:sum([13-abs(13-abs(ord(a)-ord(b)))for a,b in zip(s,s[1:])])

Breakdown:

lambda s:
         sum(                                                      )
             [                             for a,b in zip(s,s[1:])]
              13-abs(13-abs(ord(a)-ord(b)))


问:
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:
Perl, 93 bytes

$_=bpi$=;printf'()'x6x!$`.'
%12s',F.ee x!$\--^substr"\32::\\$&|",-12while/.{$\}/g

Requires the command line option -l71Mbignum=bpi, counted as 14. The \32 should be replaced by a literal character 26.

Sample Usage

$ perl -l71Mbignum=bpi pi-slice.pl
()()()()()()
|\3.1415926|
|:\53589793|
\::\2384626|
 \::\433832|
  \::\79502|
   \::\8841|
    \::\971|
     \::\69|
      \::\3|
       \__\|

Perl, 111 bytes

$_=bpi$_*($l=($.=$_)-3);printf'()'x($./2)x!$`."
%$.s",F.ee x!$l--^substr"\32::\\$&|",-$.while/.{$l}/g

Parameterized version. Requires the command line option -nMbignum=bpi, counted as 12.

Sample Usage

$ echo 10 | perl -nMbignum=bpi pi-slice.pl
()()()()()
|\3.14159|
|:\265358|
\::\97932|
 \::\3846|
  \::\264|
   \::\33|
    \::\8|
     \__\|

$ echo 20 | perl -nMbignum=bpi pi-slice.pl
()()()()()()()()()()
|\3.141592653589793|
|:\2384626433832795|
\::\028841971693993|
 \::\75105820974944|
  \::\5923078164062|
   \::\862089986280|
    \::\34825342117|
     \::\0679821480|
      \::\865132823|
       \::\06647093|
        \::\8446095|
         \::\505822|
          \::\31725|
           \::\3594|
            \::\081|
             \::\28|
              \::\4|
               \__\|


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:
Batch, 195 bytes

@echo ()()()()()()
@echo ^|\3.1415926^|
@echo ^|:\53589793^|
@set i=\
@for %%d in (2384626 433832 79502 8841 971 69 3)do @call:l %%d
@echo %i%__\^|
@exit/b
:l
@set i= %i%
@echo%i%::\%1^|


问:
An A , or An An?
In English, there is the fun and simple difference between an and a: you use an when preceding a word starting with a vowel sound, and a when the word starts with a consonant sound.

For the sake of simplicity in this challenge, an precedes a word that starts with a vowel (aeiou), and a precedes a word that starts with a consonant.

Input

A string comprising only printable ASCII characters, with [?] appearing in places where you must choose to insert an or a. [?] will always appear before a word. You can assume that the sentence will be grammatically correct and formatted like normal.

Output

The input string with [?] replaced with the appropriate word (an or a). You do have to worry about capitalization!

When to Capitalize

Capitalize a word if it is preceded by no characters (is the first one in the input) or if it is preceded by one of .?! followed by a space.

Examples

```<code>Input: Hello, this is [?] world!
Output: Hello, this is a world!

Input: How about we build [?] big building. It will have [?] orange banana hanging out of [?] window.
Output: How about we build a big building. It will have an orange banana hanging out of a window.

Input: [?] giant en le sky.
Output: A giant en le sky.

Input: [?] yarn ball? [?] big one!
Output: A yarn ball? A big one!

Input: [?] hour ago I met [?] European.
Output: A hour ago I met an European.

Input: Hey sir [Richard], how 'bout [?] cat?
Output: Hey sir [Richard], how 'bout a cat?
</code>```

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

答:
Java, <s>180</s>178 bytes

My first post here, I did use a part of the Kevin Cruijssen post but and up with a different approach, he helped me to reduce a bit more so, thanks to him !

```<code>String c(String s){String x[]=s.split("\\[\\?]",2),r=x[0];return x.length>1?r+(r.matches("(.+[.!?] )|(^)$")?"A":"a")+("aeiouAEIOU".contains(""+x[1].charAt(1))?"n":"")+c(x[1]):r;}
</code>```

Here it is ungolfed :

```<code>static String c(String s) {
        String x[] = s.split("\\[\\?\\]", 2), r = x[0];
        return x.length > 1 ? r + (r.matches("(.+[.!?] )|(^)$") ? "A" : "a")
                + ("aeiouAEIOU".contains("" + x[1].charAt(1)) ? "n" : "") + c(x[1]) : r;
    }
</code>```

And the result

A simple explanation, I use a recursive approch to find every [?].

I couldn't find a way to use the matches with insensitive case (not sure it is possible).

178bytes : Thanks to Martin Ender !

Title: An A , or An An?

Body:
Java, <s>180</s>178 bytes

My first post here, I did use a part of the Kevin Cruijssen post but and up with a different approach, he helped me to reduce a bit more so, thanks to him !

String c(String s){String x[]=s.split("\\[\\?]",2),r=x[0];return x.length>1?r+(r.matches("(.+[.!?] )|(^)$")?"A":"a")+("aeiouAEIOU".contains(""+x[1].charAt(1))?"n":"")+c(x[1]):r;}

Here it is ungolfed :

static String c(String s) {
        String x[] = s.split("\\[\\?\\]", 2), r = x[0];
        return x.length > 1 ? r + (r.matches("(.+[.!?] )|(^)$") ? "A" : "a")
                + ("aeiouAEIOU".contains("" + x[1].charAt(1)) ? "n" : "") + c(x[1]) : r;
    }

And the result

A simple explanation, I use a recursive approch to find every [?].

I couldn't find a way to use the matches with insensitive case (not sure it is possible).

178bytes : Thanks to Martin Ender !


答:
Batch, <s>356</s> <s>344</s> <s>341</s> 337 bytes

```<code>@set s=@set "
%s%g=@goto 1
%s%r=
%s%c=
%s%u=|
%s%l=|
%s%f=
@for /l %%i in (1,1,7)do @call:%%i
%s%u=|\/|
%s%l=|/\|
%g%
:7
%s%u=|\/
%s%l=|/\
%g%
:6
%s%f=----
%g%
:5
%s%u=|\
%s%l=| \
%g%
:4
%s%c=/__\
%g%
:3
%s%r= /\
%s%c=/  \
%g%
:2
%s%r= /
%s%c=/
:1
@for %%l in ("%r%" "%c%" "%u%" "%l%" "%f%")do @echo(%%~l
</code>```

<s>Stupid Batch | quoting rules... if you want a | in a variable, you need to quote it with three ^s, so it's cheaper to use @ instead and substitute it on output, although to achieve this I have to start with the left wall. Line one has a trailing space.</s> echo( is used because the r, c, and f variables could be empty and we don't want ECHO is off. printed.

Edit: Saved 12 bytes by using fallthrough for the last part. Saved 3 bytes by using a for loop to print each part, this means that I now use |s in my variables which makes the code slightly easier to read. Saved 4 bytes by using explicit @ characters instead of @echo off. I think starting with the left wall still requires the fewest bytes.

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:
Batch, <s>356</s> <s>344</s> <s>341</s> 337 bytes

@set s=@set "
%s%g=@goto 1
%s%r=
%s%c=
%s%u=|
%s%l=|
%s%f=
@for /l %%i in (1,1,7)do @call:%%i
%s%u=|\/|
%s%l=|/\|
%g%
:7
%s%u=|\/
%s%l=|/\
%g%
:6
%s%f=----
%g%
:5
%s%u=|\
%s%l=| \
%g%
:4
%s%c=/__\
%g%
:3
%s%r= /\
%s%c=/  \
%g%
:2
%s%r= /
%s%c=/
:1
@for %%l in ("%r%" "%c%" "%u%" "%l%" "%f%")do @echo(%%~l

<s>Stupid Batch | quoting rules... if you want a | in a variable, you need to quote it with three ^s, so it's cheaper to use @ instead and substitute it on output, although to achieve this I have to start with the left wall. Line one has a trailing space.</s> echo( is used because the r, c, and f variables could be empty and we don't want ECHO is off. printed.

Edit: Saved 12 bytes by using fallthrough for the last part. Saved 3 bytes by using a for loop to print each part, this means that I now use |s in my variables which makes the code slightly easier to read. Saved 4 bytes by using explicit @ characters instead of @echo off. I think starting with the left wall still requires the fewest bytes.