答:
Oracle SQL 11.2, <s>77</s> <s>73</s> <s>72</s> 68 bytes

SELECT CEIL((LEVEL-1)/2)*(MOD(LEVEL,2)*2-1)FROM DUAL CONNECT BY 1=1;
```

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

```


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

```

答:
Cubix, <s>14</s> 12 bytes

```<code>.(.\OSo;?.>~
</code>```

Test it online! You can now adjust the speed if you want it to run faster or slower.

How it works

The first thing the interpreter does is remove all whitespace and pad the code with no-ops . until it fits perfectly on a cube. That means that the above code can also be written like this:

```<code>    . (
    . \
O S o ; ? . > ~
. . . . . . . .
    . .
    . .
</code>```

Now the code is run. The IP (instruction pointer) starts out at the top left corner of the far left face, pointed east. Here's the paths it takes throughout the course of running the program:

The IP starts on the red trail at the far left of the image. It then runs OSo;, which does the following:

O Print the TOS (top-of-stack) as an integer. At the beginning of the program, the stack contains infinite zeroes, so this prints 0.

S Push 32, the char code for the space character.

o Print the TOS as a character. This prints a space.

; Pop the TOS. Removes the 32 from the stack.

Now the IP hits the ?, which directs it left, right, or straight depending on the sign of the TOS. Right now, the TOS is 0, so it goes straight. This is the blue path; . does nothing, and the IP hits the arrow >, which directs it east along the red path again. ~ takes the bitwise NOT of the TOS, changing it to -1.

Here the IP reaches the right edge of the net, which wraps it back around to the left; this again prints the TOS (this time -1) and a space.

Now the IP hits the ? again. This time, the TOS is -1; since this is negative, the IP turns left, taking the green path. The mirror \ deflects the IP to the (, which decrements the TOS, changing it to -2. It comes back around and hits the arrow; ~ takes bitwise NOT again, turning the -2 to 1.

Again the TOS is outputted and a space printed. This time when the IP hits the ?, the TOS is 1; since this is positive, the IP turns right, taking the yellow path. The first operator it encounters is S, pushing an extra 32; the ; pops it before it can cause any trouble.

Now the IP comes back around to the arrow and performs its routine, ~ changing the TOS to -2 and O printing it. Since the TOS is negative again, the IP takes the green path once more. And it just keeps cycling like that forever*: red, green, red, yellow, red, green, red, yellow..., printing in the following cycle:

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

TL;DR

This program repeatedly goes through these 3 easy steps:

Output the current number and a space.

If the current number is negative, decrement it by 1.

Take bitwise NOT of the current number.

Non-separated version, 6 bytes

```<code>nO?~>~
</code>```

Removing the separation simplifies the program so much that it can fit onto a unit cube:

```<code>  n
O ? ~ >
  ~
</code>```

* Note: Neither program is truly infinite, as they only count up to 252 (where JavaScript starts to lose integer precision).

ContentLicense: CC BY-SA 3.0

Title: Print all integers

Body:
Cubix, <s>14</s> 12 bytes

.(.\OSo;?.>~

Test it online! You can now adjust the speed if you want it to run faster or slower.

How it works

The first thing the interpreter does is remove all whitespace and pad the code with no-ops . until it fits perfectly on a cube. That means that the above code can also be written like this:

    . (
    . \
O S o ; ? . > ~
. . . . . . . .
    . .
    . .

Now the code is run. The IP (instruction pointer) starts out at the top left corner of the far left face, pointed east. Here's the paths it takes throughout the course of running the program:

The IP starts on the red trail at the far left of the image. It then runs OSo;, which does the following:

O Print the TOS (top-of-stack) as an integer. At the beginning of the program, the stack contains infinite zeroes, so this prints 0.

S Push 32, the char code for the space character.

o Print the TOS as a character. This prints a space.

; Pop the TOS. Removes the 32 from the stack.

Now the IP hits the ?, which directs it left, right, or straight depending on the sign of the TOS. Right now, the TOS is 0, so it goes straight. This is the blue path; . does nothing, and the IP hits the arrow >, which directs it east along the red path again. ~ takes the bitwise NOT of the TOS, changing it to -1.

Here the IP reaches the right edge of the net, which wraps it back around to the left; this again prints the TOS (this time -1) and a space.

Now the IP hits the ? again. This time, the TOS is -1; since this is negative, the IP turns left, taking the green path. The mirror \ deflects the IP to the (, which decrements the TOS, changing it to -2. It comes back around and hits the arrow; ~ takes bitwise NOT again, turning the -2 to 1.

Again the TOS is outputted and a space printed. This time when the IP hits the ?, the TOS is 1; since this is positive, the IP turns right, taking the yellow path. The first operator it encounters is S, pushing an extra 32; the ; pops it before it can cause any trouble.

Now the IP comes back around to the arrow and performs its routine, ~ changing the TOS to -2 and O printing it. Since the TOS is negative again, the IP takes the green path once more. And it just keeps cycling like that forever*: red, green, red, yellow, red, green, red, yellow..., printing in the following cycle:

0 -1 1 -2 2 -3 3 -4 4 -5 5 -6 6 -7 7 -8 8 -9 9 -10 10 ...

TL;DR

This program repeatedly goes through these 3 easy steps:

Output the current number and a space.

If the current number is negative, decrement it by 1.

Take bitwise NOT of the current number.

Non-separated version, 6 bytes

nO?~>~

Removing the separation simplifies the program so much that it can fit onto a unit cube:

  n
O ? ~ >
  ~

* Note: Neither program is truly infinite, as they only count up to 252 (where JavaScript starts to lose integer precision).


问:
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# (85 bytes)

It's a full function:

```<code>int y(int[] t) {int m=t.Min(i=>(i+"").Length);return t.Max(n=>(n+"").Length==m?n:0);}
</code>```

Unriddled:

```<code>int y(int[] t)
{
    int m = t.Min(i => (i+"").Length);
    return t.Max(n => (n+"").Length == m ? n : 0);
}
</code>```

Body:
C# (85 bytes)

It's a full function:

int y(int[] t) {int m=t.Min(i=>(i+"").Length);return t.Max(n=>(n+"").Length==m?n:0);}

Unriddled:

int y(int[] t)
{
    int m = t.Min(i => (i+"").Length);
    return t.Max(n => (n+"").Length == m ? n : 0);
}


答:
C, <s>51</s> 50 bytes

```<code>void f(){long i=0;for(;;)printf("%d %d ",i++,-i);}
</code>```

I could save a byte by doing int instead of long, but since this can go longer than int without wrapping I'm leaving it.

Output:

```<code>0 -1 1 -2 2 -3 3 -4 4 -5 5 -6 6 ...
</code>```

Title: Print all integers

Body:
C, <s>51</s> 50 bytes

void f(){long i=0;for(;;)printf("%d %d ",i++,-i);}

I could save a byte by doing int instead of long, but since this can go longer than int without wrapping I'm leaving it.

Output:

0 -1 1 -2 2 -3 3 -4 4 -5 5 -6 6 ...


问:
Is it a Bumpy Word?
(inspired by this challenge over on Puzzling -- SPOILERS for that puzzle are below, so stop reading here if you want to solve that puzzle on your own!)

If a letter in a word occurs alphabetically later than the previous letter in the word, we call that a rise between the two letters. Otherwise, including if it's the same letter, it's called a fall.

For example, the word ACE has two rises (A to C and C to E) and no falls, while THE has two falls (T to H and H to E) and no rises.

We call a word Bumpy if the sequence of rises and falls alternates. For example, BUMP goes rise (B to U), fall (U to M), rise (M to P). Note that the first sequence need not be a rise -- BALD goes fall-rise-fall and is also Bumpy.

The challenge

Given a word, output whether or not it's Bumpy.

Input

A word (not necessarily a dictionary word) consisting of ASCII alphabet ([A-Z] or [a-z]) letters only, in any suitable format.

Your choice if the input is all uppercase or all lowercase, but it must be consistent.

The word will be at least 3 characters in length.

Output

A truthy/falsey value for whether the input word is Bumpy (truthy) or not Bumpy (falsey).

The Rules

Either a full program or a function are acceptable.

Standard loopholes are forbidden.

This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Examples

Truthy:

```<code>ABA
ABB
BAB
BUMP
BALD
BALDY
UPWARD
EXAMINATION
AZBYCXDWEVFUGTHSIRJQKPLOMN
</code>```

Falsey:

```<code>AAA
BBA
ACE
THE
BUMPY
BALDING
ABCDEFGHIJKLMNOPQRSTUVWXYZ
</code>```

Leaderboards

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

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

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

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

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

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

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

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

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
PHP 7, <s>137</s> 118 bytes

```<code>for($i=0;$i<strlen($argv[1])-2;$i++)if(((($s[$i]<=>$s[$i+1])<0)?1:0)==((($s[$i+1]<=>$s[$i+2])<0)?1:0)){echo"0";break;}
</code>```

Empty output for Bumpy, 0 for Not Bumpy.

This is my first attempt at code golfing and I have to improve a lot, but it was a wonderful method to learn new things for me. I also wanted to challenge myself on that task by using the new PHP 7 Spaceship Operator which seems very interesting.

<s>Anyway I'm not satisfied about it, first of all for the fact that I had to add an extra if(isset($s[$i+2])) to check if the variable exist because I did not find another workaround to the problem, but this is it for now.</s> (Note: I fixed that simply by changing strlen($s)-1 to strlen($s)-2, I couldn't really see that before...).

Testing code:

```<code>$as = array("ABA", "ABB", "BAB", "BUMP", "BALD", "BALDY", "UPWARD",
            "EXAMINATION", "AZBYCXDWEVFUGTHSIRJQKPLOMN", "AAA", "BBA",
            "ACE", "THE", "BUMPY", "BALDING", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");

foreach ($as as $s) {
    for($i=0;$i<strlen($s)-2;$i++)if(((($s[$i]<=>$s[$i+1])<0)?1:0)==((($s[$i+1]<=>$s[$i+2])<0)?1:0)){echo"0";break;}
}
</code>```

Test online

Title: Is it a Bumpy Word?

Body:
PHP 7, <s>137</s> 118 bytes

for($i=0;$i<strlen($argv[1])-2;$i++)if(((($s[$i]<=>$s[$i+1])<0)?1:0)==((($s[$i+1]<=>$s[$i+2])<0)?1:0)){echo"0";break;}

Empty output for Bumpy, 0 for Not Bumpy.

This is my first attempt at code golfing and I have to improve a lot, but it was a wonderful method to learn new things for me. I also wanted to challenge myself on that task by using the new PHP 7 Spaceship Operator which seems very interesting.

<s>Anyway I'm not satisfied about it, first of all for the fact that I had to add an extra if(isset($s[$i+2])) to check if the variable exist because I did not find another workaround to the problem, but this is it for now.</s> (Note: I fixed that simply by changing strlen($s)-1 to strlen($s)-2, I couldn't really see that before...).

Testing code:

$as = array("ABA", "ABB", "BAB", "BUMP", "BALD", "BALDY", "UPWARD",
            "EXAMINATION", "AZBYCXDWEVFUGTHSIRJQKPLOMN", "AAA", "BBA",
            "ACE", "THE", "BUMPY", "BALDING", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");

foreach ($as as $s) {
    for($i=0;$i<strlen($s)-2;$i++)if(((($s[$i]<=>$s[$i+1])<0)?1:0)==((($s[$i+1]<=>$s[$i+2])<0)?1:0)){echo"0";break;}
}

Test online


问:
Rolling three dice and show the probabilities
Roll 3 dice, count the two highest two values and add them to the result. Every 1 must be rolled once again.

Now show the average throw after 1000000 tries and the probabilities for each result occurring:

Desired Result:

avg(9.095855)

  2: 0.0023

  3: 0.0448

  4: 1.1075

  5: 2.8983

  6: 6.116

  7: 10.1234

  8: 15.4687

  9: 18.9496

  10: 19.3575

  11: 16.0886

  12: 9.8433

答:
R - 98

```<code>S=sample
D=matrix(S(6,3e6,T),3)
D[D<2]=S(6,3e6,T)
A=colSums(D)-apply(D,2,min)
mean(A)
table(A)/1e4
</code>```

Like some other answers, my output is not in the same format as the OP; I was not sure if it was a strict requirement or not:

```<code>[1] 9.095695

A
      2       3       4       5       6       7       8       9      10      11      12
 0.0018  0.0426  1.1008  2.8748  6.1438 10.1147 15.5406 18.9276 19.3525 16.0126  9.8882
</code>```

Body:
R - 98

S=sample
D=matrix(S(6,3e6,T),3)
D[D<2]=S(6,3e6,T)
A=colSums(D)-apply(D,2,min)
mean(A)
table(A)/1e4

Like some other answers, my output is not in the same format as the OP; I was not sure if it was a strict requirement or not:

[1] 9.095695

A
      2       3       4       5       6       7       8       9      10      11      12
 0.0018  0.0426  1.1008  2.8748  6.1438 10.1147 15.5406 18.9276 19.3525 16.0126  9.8882


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

答:
Perl, 56 bytes

Includes +1 for -p

Give input on STDIN

alien.pl:

```<code>#!/usr/bin/perl -p
s%\w%"`"&$&|("A\x0fboE\x15nuI\x09niO\x01piU\x09ki"=~/\u$&\K.../,$&)%eg
</code>```

Works as shown, but replace the \xXX escapes by the actual character to get the claimed score

Title: English to Alien translator

Body:
Perl, 56 bytes

Includes +1 for -p

Give input on STDIN

alien.pl:

#!/usr/bin/perl -p
s%\w%"`"&$&|("A\x0fboE\x15nuI\x09niO\x01piU\x09ki"=~/\u$&\K.../,$&)%eg

Works as shown, but replace the \xXX escapes by the actual character to get the claimed score


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

答:
Swift(2.2) 44 bytes

I am using x as the input variable here. For example,

```<code>let x = [true,false]
</code>```

¯\_(ツ)_/¯

Golfed

```<code>let y = {let b = $0.map({!$0});print(b);}(x)
</code>```

unGolfed

```<code>let y = {
   let b = $0.map({!$0})
   print(b);
}(x)
</code>```

Title: Invert a boolean array

Body:
Swift(2.2) 44 bytes

I am using x as the input variable here. For example,

let x = [true,false]

¯\_(ツ)_/¯

Golfed

let y = {let b = $0.map({!$0});print(b);}(x)

unGolfed

let y = {
   let b = $0.map({!$0})
   print(b);
}(x)


答:
Java 8, 172 bytes

```<code>String f(String s){String v="AEIOUaeiou",r="OboUnuIniApiIkiobounuiniapiiki",o="";for(char c:s.toCharArray()){int n=v.indexOf(c);o+=n>-1?r.substring(n*3,n*3+3):c;}return o;}
</code>```

ungolfed:

```<code>String f(String s){
    String v="AEIOUaeiou",r="OboUnuIniApiIkiobounuiniapiiki",o="";
    for(char c:s.toCharArray()){
        int n=v.indexOf(c);
        o+=n>-1?r.substring(n*3,n*3+3):c;
    }
    return o;
}
</code>```

And Alien back to English (171 bytes):

```<code>String g(String s){String[] v="AEIOUaeiou".split(""),r="Obo Unu Ini Api Iki obo unu ini api iki".split(" ");for(int i=0;i<v.length;i++)s=s.replaceAll(r[i],v[i]);return s;}
</code>```

Ungolfed:

```<code>String g(String s){
    String[] v="AEIOUaeiou".split(""),r="Obo Unu Ini Api Iki obo unu ini api iki".split(" ");
    for(int i=0;i<v.length;i++)s=s.replaceAll(r[i],v[i]);
    return s;
}
</code>```

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:
Java 8, 172 bytes

String f(String s){String v="AEIOUaeiou",r="OboUnuIniApiIkiobounuiniapiiki",o="";for(char c:s.toCharArray()){int n=v.indexOf(c);o+=n>-1?r.substring(n*3,n*3+3):c;}return o;}

ungolfed:

String f(String s){
    String v="AEIOUaeiou",r="OboUnuIniApiIkiobounuiniapiiki",o="";
    for(char c:s.toCharArray()){
        int n=v.indexOf(c);
        o+=n>-1?r.substring(n*3,n*3+3):c;
    }
    return o;
}

And Alien back to English (171 bytes):

String g(String s){String[] v="AEIOUaeiou".split(""),r="Obo Unu Ini Api Iki obo unu ini api iki".split(" ");for(int i=0;i<v.length;i++)s=s.replaceAll(r[i],v[i]);return s;}

Ungolfed:

String g(String s){
    String[] v="AEIOUaeiou".split(""),r="Obo Unu Ini Api Iki obo unu ini api iki".split(" ");
    for(int i=0;i<v.length;i++)s=s.replaceAll(r[i],v[i]);
    return s;
}


问:
Print the alphabet without using each vowel
Inspiration: in 1939, a man named Ernest Vincent Wright wrote a novel called Gadsby without using the letter 'e'.

Your task is to write a set of (up to 5) programs in any language (which has a text-based syntax*) to output all 26 letters of the alphabet in order.  However for each vowel aeiou, at least one of the programs must not include any occurrence of the vowel.

So there must be

a program that does not use 'a' or 'A' anywhere in the syntax of the program.

a program that does not use 'e' or 'E' anywhere in the syntax of the program.

a program that does not use 'i'  or 'I' anywhere in the syntax of the program.

a program that does not use 'o' or 'O' anywhere in the syntax of the program.

a program that does not use 'u' or 'U' anywhere in the syntax of the program.

All of them must output abcdefghijklmnopqrstuvwxyz.

The winner shall be the solution where the length of all programs is the shortest.

* since the constraint wouldn't be much of a challenge in Piet or Whitespace

答:
Python 2, 91 bytes

Vowels are escaped with octal where necessary.

No ae

print"\141bcd\145fghijklmnopqrstuvwxyz"
```
<p>No <code>iou</code></p>
<pre class="lang-python prettyprint-override"><code>exec"pr\151nt''.j\157\151n(map(chr,range(97,123)))"
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Python 2, 91 bytes

Vowels are escaped with octal where necessary.

No ae

print"\141bcd\145fghijklmnopqrstuvwxyz"

No iou

exec"pr\151nt''.j\157\151n(map(chr,range(97,123)))"


Title: Print all integers

Body:
Brainfuck, 127 bytes

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

Try it online!

Given an infinite tape would theoretically run forever.

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,24,-24,25,-25,26,-26,27,-27,28,-28,29,-29,30,-30,31,-31,32,-32,33,-33,34,-34,35,-35,36,-36,37,-37,38,-38,39,-39,40,-40,41,-41,42,-42,43,-43,44,-44,45,-45,46,-46,47,-47,48,-48,49,-49,50,-50,51,-51,52,-52,53,-53,54,-54,55,-55,56,-56,57,-57,58,-58,59,-59,60,-60,61,-61,62,-62,63,-63,64,-64,65,-65,66,-66,67,-67,68,-68,69,-69,70,-70,71,-71,72,-72,73,-73,74,-74,75,-75,76,-76,77,-77,78,-78,79,-79,80,-80,81,-81,82,-82,83,-83,84,-84,85,-85,86,-86,87,-87,88,-88,89,-89,90,-90,91,-91,92,-92,93,-93,94,-94,95,-95,96,-96,97,-97,98,-98,99,-99,...

Uncompressed

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


答:
Sesos, <s>113</s> 3 bytes

```<code>0000000: c4ceb9                                            ...
</code>```

Try it online! Check Debug to see the generated SBIN code.

Sesos assembly

The binary file above has been generated by assembling the following SASM code.

set numout

jmp ; implicitly promoted to nop
    put,   fwd 1
    sub 1, put
    rwd 1, add 1
; jnz (implicit)
```

Title: Print all integers

Body:
Sesos, <s>113</s> 3 bytes

0000000: c4ceb9                                            ...

Try it online! Check Debug to see the generated SBIN code.

Sesos assembly

The binary file above has been generated by assembling the following SASM code.

set numout

jmp ; implicitly promoted to nop
    put,   fwd 1
    sub 1, put
    rwd 1, add 1
; jnz (implicit)


答:
C++ with Boost, 143 bytes

```<code>#include <boost/multiprecision/cpp_int.hpp>
#include <iostream>
boost::multiprecision::cpp_int i;main(){while(++i)std::cout<<1-i<<','<<i<<',';}
</code>```

Not very short, but it does use an arbitrary-precision type. To test that, I tried replacing ++i with i=2*i+1, and very soon there were numbers several hundred digits long being printed correctly. This should work until the number takes up all your stack memory.

Title: Print all integers

Body:
C++ with Boost, 143 bytes

#include <boost/multiprecision/cpp_int.hpp>
#include <iostream>
boost::multiprecision::cpp_int i;main(){while(++i)std::cout<<1-i<<','<<i<<',';}

Not very short, but it does use an arbitrary-precision type. To test that, I tried replacing ++i with i=2*i+1, and very soon there were numbers several hundred digits long being printed correctly. This should work until the number takes up all your stack memory.


问:
Cambridge Transposition
I'm sure most, if not all, of you have come across this at some point or another:

Aoccdrnig to a rscheeachr at Cmabrigde Uinervtisy, it deosn't mttaer
in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is
taht the frist and lsat ltteer be at the rghit pclae. The rset can be
a toatl mses and you can sitll raed it wouthit porbelm. Tihs is
bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the
wrod as a wlohe.

Create a program that inputs any amount of text. For testing purposes, use the unscrambled version of the above text, found below.

The program must then randomly transpose the letters of each word with a length of 4 or more letters, except the first and last letter of each word.

All other formatting must remain the same (capitalization and punctuation, etc.).

Testing text:

According to a researcher at Cambridge University, it doesn't matter
in what order the letters in a word are, the only important thing is
that the first and last letter be at the right place. The rest can be
a total mess and you can still read it without problem. This is
because the human mind does not read every letter by itself but the
word as a whole.

As usual, this is a code-golf. Shortest code wins.

答:
Python, 118

Python is terribly awkward for things like this!

```<code>from random import*
for w in raw_input().split():l=len(w)-2;print l>0and w[0]+''.join((sample(w[1:-1],l)))+w[-1]or w,
</code>```

Bonus

I tried some other things that I thought would be clever, but you have to import all sorts of things, and a lot of methods don't have return values, but need to be called separately as its own statement. The worst is when you need to convert the string to a list and then joining it back to a string again.

Anyways, here are some of the things that I tried:

Regex!

```<code>import re,random
def f(x):a,b,c=x.group(1,2,3);return a+''.join(random.sample(b,len(b)))+c
print re.sub('(\w)(\w+)(\w)',f,raw_input())
</code>```

Permutations!

```<code>import itertools as i,random as r
for w in raw_input().split():print''.join(r.choice([x for x in i.permutations(w)if w[0]+w[-1]==x[0]+x[-1]])),
</code>```

You can't shuffle a partition of a list directly and shuffle returns None, yay!

```<code>from random import*
for w in raw_input().split():
 w=list(w)
 if len(w)>3:v=w[1:-1];shuffle(v);w[1:-1]=v
 print ''.join(w),
</code>```

Title: Cambridge Transposition

Body:
Python, 118

Python is terribly awkward for things like this!

from random import*
for w in raw_input().split():l=len(w)-2;print l>0and w[0]+''.join((sample(w[1:-1],l)))+w[-1]or w,

Bonus

I tried some other things that I thought would be clever, but you have to import all sorts of things, and a lot of methods don't have return values, but need to be called separately as its own statement. The worst is when you need to convert the string to a list and then joining it back to a string again.

Anyways, here are some of the things that I tried:

Regex!

import re,random
def f(x):a,b,c=x.group(1,2,3);return a+''.join(random.sample(b,len(b)))+c
print re.sub('(\w)(\w+)(\w)',f,raw_input())

Permutations!

import itertools as i,random as r
for w in raw_input().split():print''.join(r.choice([x for x in i.permutations(w)if w[0]+w[-1]==x[0]+x[-1]])),

You can't shuffle a partition of a list directly and shuffle returns None, yay!

from random import*
for w in raw_input().split():
 w=list(w)
 if len(w)>3:v=w[1:-1];shuffle(v);w[1:-1]=v
 print ''.join(w),


答:
bc, <s>17</s> 16 bytes

Edit: 1 byte less thanks to Digital Trauma.

Adding to the diversity of languages used so far, I present a bc solution that works with integers of arbitrary size. A newline is required after the code and it is counted in the bytes total.

for(;;){i;-++i}
```

In the first iteration i is not defined, but printing it gives 0 to my surprise.

Title: Print all integers

Body:
bc, <s>17</s> 16 bytes

Edit: 1 byte less thanks to Digital Trauma.

Adding to the diversity of languages used so far, I present a bc solution that works with integers of arbitrary size. A newline is required after the code and it is counted in the bytes total.

for(;;){i;-++i}

In the first iteration i is not defined, but printing it gives 0 to my surprise.


答:
Jelly, 5 bytes

```<code>Ṅ~ṄNß
</code>```

Try it online!

How it works

```<code>Ṅ~ṄNß  Main link. Argument: n. Implict argument: 0

Ṅ      Print n and a linefeed.
 ~     Apply bitwise NOT, yielding -(n + 1).
  Ṅ    Print -(n + 1) and a linefeed.
   N   Negate, yielding n + 1.
    ß  Recursively call the main link with argument n + 1.
</code>```

Title: Print all integers

Body:
Jelly, 5 bytes

Ṅ~ṄNß

Try it online!

How it works

Ṅ~ṄNß  Main link. Argument: n. Implict argument: 0

Ṅ      Print n and a linefeed.
 ~     Apply bitwise NOT, yielding -(n + 1).
  Ṅ    Print -(n + 1) and a linefeed.
   N   Negate, yielding n + 1.
    ß  Recursively call the main link with argument n + 1.


答:
Swift 3 (7 bytes)

```<code>.map(!)
</code>```

e.g.

```<code>[true, false].map(!)
</code>```

Explanation

Seems pretty obvious. Calls map on the array [true, false]. The one "gotcha" is that, in Swift, operators are just functions and can be passed around as arguments. This means map(!) is passing the "not" function ! into map.

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:
Swift 3 (7 bytes)

.map(!)

e.g.

[true, false].map(!)

Explanation

Seems pretty obvious. Calls map on the array [true, false]. The one "gotcha" is that, in Swift, operators are just functions and can be passed around as arguments. This means map(!) is passing the "not" function ! into map.


答:
Vim, 19 keystrokes

```<code>i0<cr>1<esc>qqYpi-<esc>p<C-a>@qq@q
</code>```

Creates a recursive macro that duplicates a number, makes it negative, prints the original number again and increments it.

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:
Vim, 19 keystrokes

i0<cr>1<esc>qqYpi-<esc>p<C-a>@qq@q

Creates a recursive macro that duplicates a number, makes it negative, prints the original number again and increments it.


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

答:
Python 2.7, <s>624</s> <s>616</s> <s>569</s> <s>548</s> 552 bytes

```<code>from random import*
from time import*
i=randint
z=lambda a,b:dict(zip(a,b))
c={'u':z('lur',u'┐│┌'),'d':z('ldr',u'┘│└'),'l':z('uld',u'└─┌'),'r':z('urd',u'┘─┐')}
m=z('udlr',[[0,-1],[0,1],[-1,0],[1,0]])
def f(e,t,w,h):
 seed(e);s=[w*[' ',]for _ in' '*h]
 while t>0:
  _=i(0,1);x,y=((i(0,w-1),i(0,1)*(h-1)),(i(0,1)*(w-1),i(0,h-1)))[_];o=('du'[y>0],'rl'[x>0])[_]
  while t>0:
   d=c[o].keys()[i(7,16)//8];s[y][x]=c[o][d];x+=m[d][0];y+=m[d][1];t-=1;sleep(.5);print'\n'.join([''.join(k)for k in s]);o=d
   if(x*y<0)+(x>=w)+(y>=h):break
</code>```

The first parameter is a seed, same seeds will generate the same output, printing each step with a 500 ms delay.

-10 bytes thanks to @TuukkaX

repl it

Example run

```<code>f(5,6,3,3)
</code>```

will output

```<code>

  ┐
</code>```

```<code>

 ─┐
</code>```

```<code>

──┐
</code>```

```<code>

┘─┐
</code>```

```<code>
┐
┘─┐
</code>```

verbose version

```<code>import random as r
from time import *
char={
'u':{'u':'│','l':'┐','r':'┌'},
'd':{'d':'│','l':'┘','r':'└'},
'l':{'u':'└','d':'┌','l':'─'},
'r':{'u':'┘','d':'┐','r':'─'}
}
move={'u':[0,-1],'d':[0,1],'l':[-1,0],'r':[1,0]}
def f(seed,steps,w,h):
 r.seed(seed)
 screen=[[' ',]*w for _ in ' '*h]
 while steps > 0:
  if r.randint(0,1):
   x,y=r.randint(0,w-1),r.randint(0,1)*(h-1)
   origin='du'[y>0]
  else:
   x,y=r.randint(0,1)*(w-1),r.randint(0,h-1)
   origin = 'rl'[x>0]
  while steps > 0:
   direction = char[origin].keys()[r.randint(0,2)]
   screen[y][x]=char[origin][direction]
   x+=move[direction][0]
   y+=move[direction][1]
   steps-=1
   sleep(0.5)
   print '\n'.join([''.join(k) for k in screen]),''
   if x<0 or y<0 or x>=w or y>=h:
    break
   origin=direction
</code>```

Body:
Python 2.7, <s>624</s> <s>616</s> <s>569</s> <s>548</s> 552 bytes

from random import*
from time import*
i=randint
z=lambda a,b:dict(zip(a,b))
c={'u':z('lur',u'┐│┌'),'d':z('ldr',u'┘│└'),'l':z('uld',u'└─┌'),'r':z('urd',u'┘─┐')}
m=z('udlr',[[0,-1],[0,1],[-1,0],[1,0]])
def f(e,t,w,h):
 seed(e);s=[w*[' ',]for _ in' '*h]
 while t>0:
  _=i(0,1);x,y=((i(0,w-1),i(0,1)*(h-1)),(i(0,1)*(w-1),i(0,h-1)))[_];o=('du'[y>0],'rl'[x>0])[_]
  while t>0:
   d=c[o].keys()[i(7,16)//8];s[y][x]=c[o][d];x+=m[d][0];y+=m[d][1];t-=1;sleep(.5);print'\n'.join([''.join(k)for k in s]);o=d
   if(x*y<0)+(x>=w)+(y>=h):break

The first parameter is a seed, same seeds will generate the same output, printing each step with a 500 ms delay.

-10 bytes thanks to @TuukkaX

repl it

Example run

f(5,6,3,3)

will output

  ┐

 ─┐

──┐

┘─┐

┐
┘─┐

verbose version

import random as r
from time import *
char={
'u':{'u':'│','l':'┐','r':'┌'},
'd':{'d':'│','l':'┘','r':'└'},
'l':{'u':'└','d':'┌','l':'─'},
'r':{'u':'┘','d':'┐','r':'─'}
}
move={'u':[0,-1],'d':[0,1],'l':[-1,0],'r':[1,0]}
def f(seed,steps,w,h):
 r.seed(seed)
 screen=[[' ',]*w for _ in ' '*h]
 while steps > 0:
  if r.randint(0,1):
   x,y=r.randint(0,w-1),r.randint(0,1)*(h-1)
   origin='du'[y>0]
  else:
   x,y=r.randint(0,1)*(w-1),r.randint(0,h-1)
   origin = 'rl'[x>0]
  while steps > 0:
   direction = char[origin].keys()[r.randint(0,2)]
   screen[y][x]=char[origin][direction]
   x+=move[direction][0]
   y+=move[direction][1]
   steps-=1
   sleep(0.5)
   print '\n'.join([''.join(k) for k in screen]),''
   if x<0 or y<0 or x>=w or y>=h:
    break
   origin=direction


答:
Swift 3 (34 bytes)

```<code>(Int.min...Int.max).map{print($0)}
</code>```

Really, we should be able to get this down to 30 bytes like so:

```<code>(Int.min...Int.max).map(print)
</code>```

But the compiler doesn't allow this yet.

Title: Print all integers

Body:
Swift 3 (34 bytes)

(Int.min...Int.max).map{print($0)}

Really, we should be able to get this down to 30 bytes like so:

(Int.min...Int.max).map(print)

But the compiler doesn't allow this yet.


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

答:
C#, <s>47</s> 44 bytes

as an anonymous function takes a string and returns a string

```<code>s=>s.Aggregate("",(a,b)=>a+(b>'0'?'0':'1'));
</code>```

<s>
or as an anonymous function takes a string and prints the inverted, also in 47 bytes

```<code>s=>{foreach(var c in s)Write(c=='0'?'1':'0');};
</code>```

</s>

Body:
C#, <s>47</s> 44 bytes

as an anonymous function takes a string and returns a string

s=>s.Aggregate("",(a,b)=>a+(b>'0'?'0':'1'));

<s>
or as an anonymous function takes a string and prints the inverted, also in 47 bytes

s=>{foreach(var c in s)Write(c=='0'?'1':'0');};

</s>


Title: Print all integers

Body:
bash, 46 Bytes

echo 0;for((i=1;;i++)){ echo -e "$i\n-$i"; }


答:
APL, 67

```<code>÷1e2÷+/×/x←⍉↑n,1e4÷⍨+/(n←⊂⍳12)∘.={+/2↑x[⍒x←{⍵=1:?6⋄⍵}¨?3⍴6]}¨⍳1e6⋄x
</code>```

Explanation

⍳1e6 Create array from 1 to milliion,

¨ and for each of those

{+/2↑x[⍒x←{⍵=1:?6⋄⍵}¨?3⍴6]} do a roll, re-roll 1s, and sum the high
dices:

?3⍴6 roll 3 dice,

¨ and for each die

{⍵=1:?6⋄⍵} if it is a 1, replace it by a re-roll result, else don't change it.

x← Save the result in (local) variable x,

x[⍒x...] sort it in descending order,

+/2↑ take the first 2 items (high dices) and return the sum.

+/(n←⊂⍳12)∘.= Create array of the no. of times each sum appears,

1e4÷⍨ divide by 10000,

⍉↑n, insert a row to the top with numbers 1 to 12, and matrix transpose it. The result would be something like the table in the question.

x← Save that in (global) variable x.

+/×/ Calculate the average of the million rolls by multiplying the columns, summing those...

÷1e2÷ and divide by 100.

The result is displayed (by default)

⋄x Finally, output x

Example output

```
9.097008
 1  0
 2  0.0028
 3  0.0466
 4  1.0914
 5  2.8873
 6  6.0957
 7 10.1242
 8 15.6108
 9 18.8688
10 19.2834
11 16.0979
12  9.8911```

Notes

-5 chars if allowed to represent 10% by 0.1 instead of 10

-3 chars if allowed to use probabilistic approach (like o_o's) instead of explicit re-roll

+12 chars if the "avg()" is required

+2 chars if the "1" row needs to be removed

+8 chars if the colon is required in output

Title: Rolling three dice and show the probabilities

Body:
Roll 3 dice, count the two highest two values and add them to the result. Every 1 must be rolled once again.

Now show the average throw after 1000000 tries and the probabilities for each result occurring:

Desired Result:

avg(9.095855)

  2: 0.0023

  3: 0.0448

  4: 1.1075

  5: 2.8983

  6: 6.116

  7: 10.1234

  8: 15.4687

  9: 18.9496

  10: 19.3575

  11: 16.0886

  12: 9.8433

Body:
APL, 67

÷1e2÷+/×/x←⍉↑n,1e4÷⍨+/(n←⊂⍳12)∘.={+/2↑x[⍒x←{⍵=1:?6⋄⍵}¨?3⍴6]}¨⍳1e6⋄x

Explanation

⍳1e6 Create array from 1 to milliion,

¨ and for each of those

{+/2↑x[⍒x←{⍵=1:?6⋄⍵}¨?3⍴6]} do a roll, re-roll 1s, and sum the high
dices:

?3⍴6 roll 3 dice,

¨ and for each die

{⍵=1:?6⋄⍵} if it is a 1, replace it by a re-roll result, else don't change it.

x← Save the result in (local) variable x,

x[⍒x...] sort it in descending order,

+/2↑ take the first 2 items (high dices) and return the sum.

+/(n←⊂⍳12)∘.= Create array of the no. of times each sum appears,

1e4÷⍨ divide by 10000,

⍉↑n, insert a row to the top with numbers 1 to 12, and matrix transpose it. The result would be something like the table in the question.

x← Save that in (global) variable x.

+/×/ Calculate the average of the million rolls by multiplying the columns, summing those...

÷1e2÷ and divide by 100.

The result is displayed (by default)

⋄x Finally, output x

Example output

9.097008
 1  0
 2  0.0028
 3  0.0466
 4  1.0914
 5  2.8873
 6  6.0957
 7 10.1242
 8 15.6108
 9 18.8688
10 19.2834
11 16.0979
12  9.8911

Notes

-5 chars if allowed to represent 10% by 0.1 instead of 10

-3 chars if allowed to use probabilistic approach (like o_o's) instead of explicit re-roll

+12 chars if the "avg()" is required

+2 chars if the "1" row needs to be removed

+8 chars if the colon is required in output


答:
Swift 3 (40 bytes)

As a closure expression that takes x as input and returns a String:

```<code>{x in String(cString:x.utf8.map{$0^1})}
</code>```

Explanation

```<code>// make a function…
let invert = { (x: String) in

  // …that will xor each UInt8 character in the input string
  let y = x.utf8.map { $0 ^ 1 }

  // …and create String from the resultant [UInt8]
  String(cString: y)
}
</code>```

Title: The shortest code to invert bit-wise a binary string

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

Body:
Swift 3 (40 bytes)

As a closure expression that takes x as input and returns a String:

{x in String(cString:x.utf8.map{$0^1})}

Explanation

// make a function…
let invert = { (x: String) in

  // …that will xor each UInt8 character in the input string
  let y = x.utf8.map { $0 ^ 1 }

  // …and create String from the resultant [UInt8]
  String(cString: y)
}


答:
C# 85 bytes

```<code>int S(int[] i){var m=i.Min();return i.Where(v=>v<m*10&&$"{v}{m}".Length%2==0).Max();}
</code>```

Usage:

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

Output: 938

Explanation

Get the minimum value from the array and assume that the minimum value is the value with the shortest length.

Filter the array to remove all values greater than 10 * the minimum. i.e if the value is 8, the first check removes all values greater than 80.

Also filter to remove all values where the length of the combined string is odd.  "8" + "9" is length 2 which is even, "8" + "10" is length 3 which is odd and eliminated.

```<code>int S(int[] i)
{
    var m = i.Min();
    return i.Where(v => v < m * 10 && $"{v}{m}".Length % 2 == 0).Max();
}
</code>```

Title: Output the largest number with the fewest digits

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

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

Examples:

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

The shortest code in bytes wins.

Body:
C# 85 bytes

int S(int[] i){var m=i.Min();return i.Where(v=>v<m*10&&$"{v}{m}".Length%2==0).Max();}

Usage:

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

Output: 938

Explanation

Get the minimum value from the array and assume that the minimum value is the value with the shortest length.

Filter the array to remove all values greater than 10 * the minimum. i.e if the value is 8, the first check removes all values greater than 80.

Also filter to remove all values where the length of the combined string is odd.  "8" + "9" is length 2 which is even, "8" + "10" is length 3 which is odd and eliminated.

int S(int[] i)
{
    var m = i.Min();
    return i.Where(v => v < m * 10 && $"{v}{m}".Length % 2 == 0).Max();
}


答:
PHP, <s>48</s> 41 bytes

```<code>foreach(str_split($argv[1])as$c)echo+!$c;
</code>```

Saved 7 bytes thanks to Jörg Hülsermann!

Test online

Body:
PHP, <s>48</s> 41 bytes

foreach(str_split($argv[1])as$c)echo+!$c;

Saved 7 bytes thanks to Jörg Hülsermann!

Test online


答:
Ruby, <s>413</s> <s>403</s> 396 bytes

A function that takes a number of ticks and a width as input and returns the final screen as a string. Could no doubt be golfed more.

->t,w{k=[-1,0,1,0,-1]
b=(" "*w+$/)*w
f=->t,a=[[0,m=rand(w),2],[w-1,m,0],[m,0,1],[m,w-1,3]].sample{n,m,i=a
d=k[i,2]
q=->n,m,i{_,g,j=rand>0.2?[[1,0],[3,0],[0,1],[2,1]].assoc(i):"021322033132243140251350".chars.map(&:to_i).each_slice(3).select{|c,|c==i}.sample
v,u=k[j||=i,2]
y=n+v
x=m+u
[g,y,x,j]}
g,y,x,j=q[n,m,i]
b[n*w+n+m]="─│┌┐┘└"[g]
y>=0&&y<w&&x>=0&&x<w ?t>1?f[t-1,[y,x,j]]:b:f[t]}
f[t]}
```

<p>See it on repl.it: https://repl.it/Db5h/4</p>

<p>In order to see it in action, insert the following after the line that begins <code>b[n*w+n+m]=</code>:</p>

<pre class="lang-ruby prettyprint-override"><code>puts b; sleep 0.2
</code>```

...then assign the lambda to a variable e.g. pipes=->... and call it like pipes[100,20] (for 100 ticks and a 20x20 screen).

Ungolfed & explanation

# Anonymous function
# t - Number of ticks
# w - Screen width
->t,w{
  # The cardinal directions ([y,x] vectors)
  # Up = k[0..1], Right = k[1..2] etc.
  k = [-1, 0, 1, 0, -1]

  # An empty screen as a string
  b = (" " * w + $/) * w

  # Main tick function (recursive)
  # t - The number of ticks remaining
  # a - The current position and vector index; if not given is generated randomly
  f = ->t,a=[[0,m=rand(w),2], [w-1,m,0], [m,0,1], [m,w-1,3]].sample{
    # Current row, column, and vector index
    n, m, i = a
    d = k[i,2] # Get vector by index

    # Function to get the next move based on the previous position (n,m) and direction (d)
    q = ->n,m,i{
      # Choose the next pipe (`g` for glyph) and get the subsequent vector index (j)
      _, g, j = (
        rand > 0.2 ?
          [[1,0], [3,0], [0,1], [2,1]].assoc(i) : # 80% of the time go straight
          "021322033132243140251350".chars.map(&:to_i).each_slice(3)
            .select{|c,|c==i}.sample
      )

      # Next vector (`v` for vertical, `u` for horizontal)
      # If straight, `j` will be nil so previous index `i` is used
      v, u = k[j||=i, 2]

      # Calculate next position
      y = n + v
      x = m + u

      # Return next glyph, position and vector index
      [g, y, x, j]
    }

    # Get next glyph, and subsequent position and vector index
    g, y, x, j = q[n, m, i]

    # Draw the glyph
    b[n * w + n + m] = "─│┌┐┘└"[g]

    # Check for out-of-bounds
    y >= 0 && y < w && x >=0 && x < w ?
      # In bounds; check number of ticks remaining
      t > 1 ?
        f[t-1, [y,x,j]] : # Ticks remain; start next iteration
        b : # No more ticks; return final screen

      # Out of bounds; repeat tick with new random start position
      f[t]
  }
  f[t]
}
```

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:
Ruby, <s>413</s> <s>403</s> 396 bytes

A function that takes a number of ticks and a width as input and returns the final screen as a string. Could no doubt be golfed more.

->t,w{k=[-1,0,1,0,-1]
b=(" "*w+$/)*w
f=->t,a=[[0,m=rand(w),2],[w-1,m,0],[m,0,1],[m,w-1,3]].sample{n,m,i=a
d=k[i,2]
q=->n,m,i{_,g,j=rand>0.2?[[1,0],[3,0],[0,1],[2,1]].assoc(i):"021322033132243140251350".chars.map(&:to_i).each_slice(3).select{|c,|c==i}.sample
v,u=k[j||=i,2]
y=n+v
x=m+u
[g,y,x,j]}
g,y,x,j=q[n,m,i]
b[n*w+n+m]="─│┌┐┘└"[g]
y>=0&&y<w&&x>=0&&x<w ?t>1?f[t-1,[y,x,j]]:b:f[t]}
f[t]}

See it on repl.it: https://repl.it/Db5h/4

In order to see it in action, insert the following after the line that begins b[n*w+n+m]=:

puts b; sleep 0.2

...then assign the lambda to a variable e.g. pipes=->... and call it like pipes[100,20] (for 100 ticks and a 20x20 screen).

Ungolfed & explanation

# Anonymous function
# t - Number of ticks
# w - Screen width
->t,w{
  # The cardinal directions ([y,x] vectors)
  # Up = k[0..1], Right = k[1..2] etc.
  k = [-1, 0, 1, 0, -1]

  # An empty screen as a string
  b = (" " * w + $/) * w

  # Main tick function (recursive)
  # t - The number of ticks remaining
  # a - The current position and vector index; if not given is generated randomly
  f = ->t,a=[[0,m=rand(w),2], [w-1,m,0], [m,0,1], [m,w-1,3]].sample{
    # Current row, column, and vector index
    n, m, i = a
    d = k[i,2] # Get vector by index

    # Function to get the next move based on the previous position (n,m) and direction (d)
    q = ->n,m,i{
      # Choose the next pipe (`g` for glyph) and get the subsequent vector index (j)
      _, g, j = (
        rand > 0.2 ?
          [[1,0], [3,0], [0,1], [2,1]].assoc(i) : # 80% of the time go straight
          "021322033132243140251350".chars.map(&:to_i).each_slice(3)
            .select{|c,|c==i}.sample
      )

      # Next vector (`v` for vertical, `u` for horizontal)
      # If straight, `j` will be nil so previous index `i` is used
      v, u = k[j||=i, 2]

      # Calculate next position
      y = n + v
      x = m + u

      # Return next glyph, position and vector index
      [g, y, x, j]
    }

    # Get next glyph, and subsequent position and vector index
    g, y, x, j = q[n, m, i]

    # Draw the glyph
    b[n * w + n + m] = "─│┌┐┘└"[g]

    # Check for out-of-bounds
    y >= 0 && y < w && x >=0 && x < w ?
      # In bounds; check number of ticks remaining
      t > 1 ?
        f[t-1, [y,x,j]] : # Ticks remain; start next iteration
        b : # No more ticks; return final screen

      # Out of bounds; repeat tick with new random start position
      f[t]
  }
  f[t]
}


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

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

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

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

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

or

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

or with indexing or matrix partitioning.

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

The goal:

Generate this exact text output:

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

That's it! Shortest-code wins.

Body:
PHP , 56 Bytes

for(;$i<64;$i++)echo($i%16?"":"\n").($i&2**($i>>4)?1:0);

86 Bytes

for($i=1;$i<9;$i*=2)echo str_repeat(str_pad(decbin(2**$i-1),2*$i,0,0),16/(2*$i))."\n";


问:
Round to n Sig Figs

Challenge

Given a number x and a number n, round number x to n significant figures and output the result.

Significant figures

The significant figures of a number are digits that carry meaning contributing to its measurement resolution. This includes all numbers except leading zeroes.

Bear in mind that leading zeroes after a decimal point are still insignificant figures.

When rounding a digit, you must round away from zero if the following digit is greater or equal than five.

All trailing zeroes after a decimal point are counted as significant.

Input

The first number will be x, the number to be rounded. The second number will be n, the number of significant figures you should round x to.

x will be a number (your code should handle both integers and floating points) between -1,000,000,000 and 1,000, 000,000 inclusive. n will be a positive integer between 1 and 50 inclusive. n will never be greater than the nunber of digits in x.

The input will never be 0 or any form of 0, e.g. 0.000 or 000.

Examples

```<code>Inputs: 2.6754, 2
Output: 2.7
</code>```

An output of 2.7000 would be invalid because the trailing zeroes after the decimal point are counted as significant figures.

```<code>Inputs: 0.00034551, 4
Output: 0.0003455
</code>```

```<code>Inputs: 50237.1238, 3
Output: 50200
</code>```

Note that this must not have a decimal point.

```<code>Inputs: 2374905, 1
Output: 2000000
</code>```

```<code>Inputs: 543.0489, 4
Output: 543.0
</code>```

```<code>Inputs: 15, 1
Output: 20
</code>```

```<code>Inputs: 520.3, 3
Output: 520
</code>```

If you wish, you can output 520. instead but not 520.0.

```<code>Inputs: -53.87, 2
Output: -54
</code>```

```<code>Inputs: 0.0999, 2
Output: 0.10
</code>```

Rules

Built-in functions and libraries which allow you to round a number to n significant figures are disallowed.

Winning

The shortest code in bytes wins.

答:
PHP, 130 Bytes

<?=number_format($r=round($i=$argv[1],($n=$argv[2])-ceil(log(abs($i),10))),($d=(1+floor(log(abs($r),10))-$n))<0?abs($d):0,".","");
```

<p>PHP, 133 Bytes works with values <1 for the significant figures</p>

<pre class="lang-php prettyprint-override"><code><?=number_format($r=round($i=$argv[1],($n=$argv[2])-floor(log(abs($i),10))-1),($d=(1+floor(log(abs($r),10))-$n))<0?abs($d):0,".","");
</code>```

PHP, 56 Bytes works but skip unneccessary Zeros

<?=round($i=$argv[1],$argv[2]-floor(log(abs($i),10))-1);
```

<p>Someone has stolen or deleted the round function in PHP! To make the challenge more interesting. 127 Bytes</p>

```<?=ceil($x=($i=$argv[1])*10**(($r=$argv[2])-($l=floor(log(abs($i),10))+1)))-$x<=0.5?ceil($x)*10**($l-$r):floor($x)*10**($l-$r);
```

Title: Round to n Sig Figs

Body:
PHP, 130 Bytes

<?=number_format($r=round($i=$argv[1],($n=$argv[2])-ceil(log(abs($i),10))),($d=(1+floor(log(abs($r),10))-$n))<0?abs($d):0,".","");

PHP, 133 Bytes works with values <1 for the significant figures

<?=number_format($r=round($i=$argv[1],($n=$argv[2])-floor(log(abs($i),10))-1),($d=(1+floor(log(abs($r),10))-$n))<0?abs($d):0,".","");

PHP, 56 Bytes works but skip unneccessary Zeros

<?=round($i=$argv[1],$argv[2]-floor(log(abs($i),10))-1);

Someone has stolen or deleted the round function in PHP! To make the challenge more interesting. 127 Bytes

<?=ceil($x=($i=$argv[1])*10**(($r=$argv[2])-($l=floor(log(abs($i),10))+1)))-$x<=0.5?ceil($x)*10**($l-$r):floor($x)*10**($l-$r);


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

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

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

答:
Python 2, 74 bytes - 25% = 55.5

Input is in the variables r,n. If included in the count, it would be r,n=input(), for 12 bytes more.

import math,turtle as t
exec"t.fd(2*r*math.sin(180/n));t.rt(360/n);"*n
```

Try it online - (uses different code since exec is not implemented in the online interpreter)

Title: Draw a regular polygon

Body:
Python 2, 74 bytes - 25% = 55.5

Input is in the variables r,n. If included in the count, it would be r,n=input(), for 12 bytes more.

import math,turtle as t
exec"t.fd(2*r*math.sin(180/n));t.rt(360/n);"*n

Try it online - (uses different code since exec is not implemented in the online interpreter)


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

Title: Decode the chmod

Body:
Javascript (ES6), 159 bytes

a=>`User:  ${(b=[' None',(c=' Execute')+(d=' only'),(e=' Write')+d,f=e+(g=' and')+c,(h=' Read')+d,h+g+c,h+g+e,h+f])[a[0]]}\nGroup: ${b[a[1]]}\nOthers:`+b[a[2]]

Example:

(a=>`User:  ${(b=[' None',(c=' Execute')+(d=' only'),(e=' Write')+d,f=e+(g=' and')+c,(h=' Read')+d,h+g+c,h+g+e,h+f])[a[0]]}\nGroup: ${b[a[1]]}\nOthers:`+b[a[2]])("042")


答:
PHP (231 Bytes)

```<code>function flip_bool_array($array) {
  $newarray = array();
  foreach ($array as $bool) {

   if ($bool === true) {
    $bool = false;
   } else {
    $bool = true;
   }

  $newarray[] = $bool;

}

return $newarray;

}
</code>```

Explanation

The function accepts an array and loops over it testing each value for a true value and setting it to false, if the value is not true then it is set to true. Each boolean is added to a new array and returned.

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:
PHP (231 Bytes)

function flip_bool_array($array) {
  $newarray = array();
  foreach ($array as $bool) {

   if ($bool === true) {
    $bool = false;
   } else {
    $bool = true;
   }

  $newarray[] = $bool;

}

return $newarray;

}

Explanation

The function accepts an array and loops over it testing each value for a true value and setting it to false, if the value is not true then it is set to true. Each boolean is added to a new array and returned.


问:
Shortest 8-bit xor cipher
8-bit XOR encryption takes a single byte and XORs every byte in the file by that byte. Here is a reference program in C++:

```<code>/*xorcipher.cpp
 *Encrypts a file using 8-bit xor encrytpion
 */

#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;

int main(int argc, char** argv){
   ifstream* in = NULL;
   ofstream* out = NULL;

   if(argc < 3){
      cerr << "Usage: xor <key> <filename...>" << endl;
      exit(1);
   }

   int key = atoi(argv[1]);

   for(int x = 2; x < argc; x++){
      in = new ifstream(argv[x], ios::binary);
      if(!in->good()){
         cerr << "Error reading from " << argv[x] << endl;
         exit(1);
      }

      //Get file size
      in->seekg(0, ios::end);
      int size = in->tellg();
      in->seekg(0, ios::beg);

      //Allocate memory
      int* data = new int[size];

      int c = 0;
      for(int y = 0; (c = in->get()) != EOF; y++)
         data[y] = c ^ key;

      in->close();
      delete in;
      in = NULL;

      out = new ofstream(argv[x], ios::binary);
      if(!out->good()){
         cerr << "Error writing to " << argv[x] << endl;
         exit(1);
      }

      for(int y = 0; y < size; y++)
         out->put(data[y]);

      out->flush();
      out->close();
      delete out;
      out = NULL;

      delete[] data;
      data = NULL;
   }
   cout << "Operation complete" << endl;

   return 0;
}
</code>```

The shortest answer (whitespace doesn't count) that produces the same end result will be selected. It does not have to store everything in memory at once or open and close every file multiple times. It can do anything as long as a file encrypted with the reference program can be decrypted with the answer, and vice versa.

Edit: The above program is not a specification. The only requirement is that answers should be able to decrypt a file encrypted with the above program, and the above program should be able to decrypt a file encrypted with the answer. I'm sorry if that was unclear.

The above program can be compiled with:

```<code>g++ xorcipher.cpp -o ~/bin/xor
</code>```

It can be run like this:

```<code>xor <key> <filename...>
</code>```

For example, if the key is 42 and the file is alpha.txt, you would use:

```<code>xor 42 alpha.txt
</code>```

Title: Shortest 8-bit xor cipher

Body:
Brainfuck - 269

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


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

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

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

You should output:

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

You may also optionally output one trailing newline.

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

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

This would not be a valid solution!

Here are some more test cases:

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

Input:
abcd
Output:
abcddcbaabcddcba

Input:
OK!
Output:
OK!!KOOK!

Input:
4815162342
Output:
4815162342243261518448151623422432615184481516234224326151844815162342243261518448151623422432615184

Input:
PPCG
Output:
PPCGGCPPPPCGGCPP

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

Leaderboards

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

The shortest answer out of all languages, and

The shortest answer in each individual language.

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

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

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

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

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

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

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

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Scala, <s>73</s> <s>72</s> 71 bytes

```<code>def f(s:String)=for(i<-1 to s.length){print(if(i%2>0)s else s.reverse)}
</code>```

This is my first attempt at code golfing, so I'm sure there are countless improvements.

Update:

Golfed away 1 byte by removing brackets.

Thanks to Destructible Watermelon for suggestion, shaved off a byte.

Title: StringgnirtSStringgnirtSStringgnirtS

Body:
Scala, <s>73</s> <s>72</s> 71 bytes

def f(s:String)=for(i<-1 to s.length){print(if(i%2>0)s else s.reverse)}

This is my first attempt at code golfing, so I'm sure there are countless improvements.

Update:

Golfed away 1 byte by removing brackets.

Thanks to Destructible Watermelon for suggestion, shaved off a byte.


问:
Make me a mooncake!
The mid-autumn festival has begun!

Unfortunately, all my mooncakes were stolen -- they're getting too expensive for small folk such as myself, and I fear I won't be able to eat any this year!

So I turn to you for help. Would you be able to make me some?

For those unaware, let me educate you on what a mooncake looks like.

Mooncakes come in many different sizes!

So I'm gonna give you my input, n, when I want one.

Here are some examples of the output I want:

Mooncake of size n = 3:

```<code>    (@@@@@)
    (@MAF@)
    (@@@@@)
</code>```

Mooncake of size n = 6:

```<code>    (@@@@@@@@@@@)
    (@         @)
    (@    M    @)
    (@    F    @)
    (@         @)
    (@@@@@@@@@@@)
</code>```

That is to say, a mooncake of size n is:

n lines high

2n - 1 @s long

2n + 1 characters long (@s and brackets)

And you better not throw me your too-tiny practice mooncakes!

Assume input will always be n >= 3.

Mooncakes also contain one of the following decorations:

MF

MAF

HMF

JCJ

TTT

ZJ

LF

RF

CF

Which one, it doesn't matter - as long as it is vertically and horizontally centered.

It can be written vertically or horizontally too!

I want variety!

If you're really going to make me two of the same mooncake, the decoration better be different!

That is, multiple executions of your program with the exact same input must not always yield the same decoration.

I can't wait to eat your moon cakes, so the sooner I can receive them (the shorter your code) the better!

Good Luck!

For those wondering about the decorations:

They are the initials of all alternative names for the Mid-Autumn Festival.

A list can be found in the Wikipedia page linked at the top of this post.

Clarifications:

There are no rules regarding leading and trailing whitespace.

Have as much or as little as you like!

The decorations must be in the very center of your mooncake!

On horizontal decorations, this means it must be on the middle line of your cake, and the number of characters to the left and right of the decoration string must be equal.

On vertical decorations, this means it must reside in the middle column of your cake, and the number of characters above and below the decoration must be equal.

Not all decorations must be used!

The only requirement is that there must be more than one possibility for any given input n. The possibilities also do not need to be even.

Functions are acceptable.

Title: Make me a mooncake!

Body:
I was bored ... here are two more versions:

PHP, 193 bytes

function p($s){global$n;return"(@".str_pad($s,2*$n-3,$s?" ":"@",2)."@)
";}$p=[M,MA,R,HM][rand()&2|1&$n=$argv[1]];echo p(""),$e=str_repeat(p(" "),($n+$n%2)/2-2),$n&1?p($p.F):p($p).p(F),$e,p("");

a port of Lmis´ answer

PHP, 191 bytes

for($p=[M,MA,R,HM][rand()&2|1&$n=$argv[1]].F;$i<$n*$w=2*$n+1;$i++)echo($x=$i%$w)?$w-1-$x?($y=$i/$w|0)%($n-1)&&1-$x&&$w-2-$x?$p[$n&1?$n>>1!=$y?9:$x-$n+1:($n-$x?9:$y-$n/2+1)]?:" ":"@":")
":"(";

printing the cake character by character in a single loop

breakdown

for(
    $p=[M,MA,R,HM][rand()&2|1&$n=$argv[1]].F;   // pick decoration
    $i<$n*$w=2*$n+1;$i++)       // loop $i from 0 to $n*width-1:
echo                                // print ...
    $w-1-($x=$i%$w)                 // 1. not last column
        ?$x                         // 2. not first column
            ?
                ($y=$i/$w|0)%($n-1) // 3. not first or last line
                && 1-$x%($w-3)      // and not second or (width-2)th column
                ?$p[$n&1
                    ?$n>>1!=$y?3:1+$x-$n
                    :($n-$x?3:1+$y-$n/2)
                ]   ?               // 4. decoration character
                    :" "            // 4. else: blank
                :"@"                // 3. else: "@"
            :"("                    // 2. else: "("
        :")\n"                      // 1. else: ")"+newline
    ;


答:
Tcl, 75 bytes

String to be translated is in the variable s.

```<code>string map {A Obo a obo E Unu e unu I Ini i ini O Api o api U Iki u iki} $s
</code>```

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:
Tcl, 75 bytes

String to be translated is in the variable s.

string map {A Obo a obo E Unu e unu I Ini i ini O Api o api U Iki u iki} $s


答:
Scala, <s>36</s> <s>35</s> 34 bytes

def f(a:Array[Boolean])=a.map(!_)

Discovered I could remove the second space.
Discovered I could remove brackets.

Title: Invert a boolean array


答:
Pyth, 42 bytes

```<code>#sXw"aeiouAEIOU"+Jc"obounuiniapiiki"3mrd3J
</code>```

A program that takes input on STDIN and prints the output.

Try it online

How it works

```<code>#sXw"aeiouAEIOU"+Jc"obounuiniapiiki"3mrd3J  Program.
#                                           Loop until error statement:
   w                                         Get w, the next line of the input
                   "obounuiniapiiki"         Yield string literal "obounuiniapiiki"
                  c                 3        Split that into groups of three characters
                 J                           Assign that to J and yield J
                                     mrd3J   Map title case over J
                +                            Merge the lower and title groups
    "aeiouAEIOU"                             Yield string literal "aeiouAEIOU"
  X                                          Translate w from that to the three-character
                                             groups
 s                                           Concatenate that
                                             Implicitly print
</code>```

Title: English to Alien translator

Body:
Pyth, 42 bytes

#sXw"aeiouAEIOU"+Jc"obounuiniapiiki"3mrd3J

A program that takes input on STDIN and prints the output.

Try it online

How it works

#sXw"aeiouAEIOU"+Jc"obounuiniapiiki"3mrd3J  Program.
#                                           Loop until error statement:
   w                                         Get w, the next line of the input
                   "obounuiniapiiki"         Yield string literal "obounuiniapiiki"
                  c                 3        Split that into groups of three characters
                 J                           Assign that to J and yield J
                                     mrd3J   Map title case over J
                +                            Merge the lower and title groups
    "aeiouAEIOU"                             Yield string literal "aeiouAEIOU"
  X                                          Translate w from that to the three-character
                                             groups
 s                                           Concatenate that
                                             Implicitly print


答:
Matlab 58 bytes - 25% = 43.5

Saw no Matlab solution, so here is one which is pretty straightforward:

```<code>f=@(n,r) plot(r*cos(0:2*pi/n:2*pi),r*sin(0:2*pi/n:2*pi));
</code>```

You can shave off some bytes if r and n are already in the workspace.

Example call:

```<code>f(7,8)
</code>```

Title: Draw a regular polygon

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

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

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

Body:
Matlab 58 bytes - 25% = 43.5

Saw no Matlab solution, so here is one which is pretty straightforward:

f=@(n,r) plot(r*cos(0:2*pi/n:2*pi),r*sin(0:2*pi/n:2*pi));

You can shave off some bytes if r and n are already in the workspace.

Example call:

f(7,8)