答:
Mathematica, 146 bytes

```<code>a:=RandomChoice[33~CharacterRange~126~Complement~{"Y","y"}];StringRiffle[Normal@SparseArray[{{b_, b_}:>a,{b_,c_}/;c-1==#-b:>a},{#,#}," "],"
",""]&
</code>```

Anonymous function. Takes a number as input, and returns a string as output.

Title: Do X without Y

Body:
Usually, it is said that "Doing X without Y" can be a trap to beginners writing challenges (source). However, I am cocky and think that I can definitely make an X without any Ys. Randomly. Oh yes, this will be good.

Challenge: Given an odd integer n greater than or equal to 1, output an ex of side length n made of random printable ascii characters sans "y" and "Y", and the space. All allowed characters must have a nonzero chance of occurring, but not necessarily uniform. This is a code-golf so the shortest code in bytes wins. You should, however, randomize each char--that is, the struts of the ex shouldn't be equal, unless if by chance.

The chars to appear

```<code>!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXZ[\]^_`abcdefghijklmnopqrstuvwxz{|}~"
</code>```

Constructing the ex

Side length 1:

```<code>x
</code>```

Side length 3:

```<code>x x
 x
x x
</code>```

Side length 5:

```<code>x   x
 x x
  x
 x x
x   x
</code>```

etc.

Example outputs

```<code>input
output
empty line

3
h 2
 ^
9 5

1
:

5
D   1
 W z
  W
 q j
W   1
</code>```

Example implementation

You do not need to handle invalid inputs.

function generate(sideLength){
    var result = "";
    var INNER = "@"
    for(var i = 0; i < sideLength; i++){
        var p = i < sideLength / 2 ? i : sideLength - i - 1;
        result += " ".repeat(p) + ((sideLength / 2 | 0) == p ? "" : INNER) + " ".repeat(Math.max(sideLength - p * 2 - 2, 0)) + INNER + "\n";
    }

    return result.replace(RegExp(INNER, "g"), function(e){
        let c = "y";
        while(c === "y" || c === "Y"){
            c = String.fromCharCode((Math.random() * 94) + 33 | 0);
        }
        return c;
    });
}

function print(v){
    output.innerHTML = "";
    output.appendChild(document.createTextNode(v));
}

function update(){
    var n = Number(input.value);
    if(n !== Math.floor(n)) print("error: " + n + " is not an integer.");
    else if(n % 2 === 0)    print("error: " + n + " is not odd.");
    else if(n < 1)          print("error: " + n + "is less than one.");
    else                    print(generate(n));
}

input.onchange = update;

update();```
<pre class="snippet-code-css lang-css prettyprint-override"><code>* {
  font-family: Consolas, monospace;
}

#output {
  white-space: pre;
}</code>```

<input id="input" min=1 value=1 type=Number>

```

Body:
Mathematica, 146 bytes

a:=RandomChoice[33~CharacterRange~126~Complement~{"Y","y"}];StringRiffle[Normal@SparseArray[{{b_, b_}:>a,{b_,c_}/;c-1==#-b:>a},{#,#}," "],"
",""]&

Anonymous function. Takes a number as input, and returns a string as output.


问:
Visualize chain rule

Definition

The chain rule with two functions state that:

```<code>D[f(g(x))] = f'(g(x)) * g'(x)
</code>```

Or, alternatively:

```<code>D[f1(f2(x))] = f1'(f2(x)) * f2'(x)
</code>```

The chain rule with three functions state that:

```<code>D[f(g(h(x)))] = f'(g(h(x))) * g'(h(x)) * h'(x)
</code>```

Or, alternatively:

```<code>D[f1(f2(f3(x)))] = f1'(f2(f3(x))) * f2'(f3(x)) * f3'(x)
</code>```

Et cetera.

Task

Given an integer between 2 and 21, output the chain rule with that many functions, either in the first form or in the second form.

Please specify if you are using the second form.

Specs

The format of the string must be exactly that stated above, with:

all the spaces kept intact

a capitalized D

a square bracket immediately following D

the asterisk kept intact

One extra trailing space (U+0020) is allowed.

Leading zeros in the function names in the second form (e.g. f01 instead of f1) is allowed.

Testcases

If you use the first form:

```<code>input output
2     D[f(g(x))] = f'(g(x)) * g'(x)
3     D[f(g(h(x)))] = f'(g(h(x))) * g'(h(x)) * h'(x)
</code>```

If you use the second form:

```<code>input output
2     D[f1(f2(x))] = f1'(f2(x)) * f2'(x)
3     D[f1(f2(f3(x)))] = f1'(f2(f3(x))) * f2'(f3(x)) * f3'(x)
</code>```

Leaderboard

var QUESTION_ID=86652,OVERRIDE_USER=48934;function answersUrl(e){return"http://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"http://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

```

答:
Julia, 66 bytes

```<code>!x=x>1?replace(!~-x,"x","f$x(x)")*" * f$x'(x)":"D[f1(x)] = f1'(x)"
</code>```

Port of @Neil's ES6 answer. Uses the second form.

ContentLicense: CC BY-SA 3.0

Title: Visualize chain rule

Body:
Julia, 66 bytes

!x=x>1?replace(!~-x,"x","f$x(x)")*" * f$x'(x)":"D[f1(x)] = f1'(x)"

Port of @Neil's ES6 answer. Uses the second form.


答:
Sesos, 49 bytes

```<code>0000000: 2ac992 63fb92 245fb6 6c57be 255bbe 2cc9bf 6d49da  *..c..$_.lW.%[.,..mI.
0000015: 025e7f fdced0 fd67f8 fcde33 b6a7b2 643d4f 65597e  .^.....g...3...d=OeY~
000002a: f77a72 dd73cf fe                                  .zr.s..
</code>```

Try it online

Disassembled

```<code>set numin
add 68   ; 'D'
put
sub 7    ; '=' - 'D'
fwd 1
add 32   ; ' '
fwd 1
add 91   ; '['
put
add 2    ; ']' - '['
fwd 1
add 102  ; 'f'
fwd 1
add 40   ; '('
fwd 3
add 120  ; 'x'
rwd 2
get
jmp
    jmp
        fwd 1
        add 1
        rwd 3
        put
        add 1
        fwd 1
        put
        fwd 1
        sub 1
    jnz
    sub 1
    rwd 1
    add 1    ; ')' - '('
    fwd 3
    put
    rwd 1
    jmp
        rwd 3
        sub 1
        fwd 1
        put
        fwd 1
        add 1
        fwd 1
        sub 1
    jnz
    rwd 4
    put
    get
    add 41   ; ')'
    rwd 1
    put
    rwd 1
    put
    get
    add 42   ; '*'
    fwd 1
    put
    fwd 2
    put
    add 1
    fwd 1
    sub 2    ; '\'' - ')'
    put
    add 1    ; '(' - '\''
    put
    fwd 1
jnz
fwd 2
put
rwd 5
put
</code>```

Title: Visualize chain rule

Body:
Definition

The chain rule with two functions state that:

```<code>D[f(g(x))] = f'(g(x)) * g'(x)
</code>```

Or, alternatively:

```<code>D[f1(f2(x))] = f1'(f2(x)) * f2'(x)
</code>```

The chain rule with three functions state that:

```<code>D[f(g(h(x)))] = f'(g(h(x))) * g'(h(x)) * h'(x)
</code>```

Or, alternatively:

```<code>D[f1(f2(f3(x)))] = f1'(f2(f3(x))) * f2'(f3(x)) * f3'(x)
</code>```

Et cetera.

Task

Given an integer between 2 and 21, output the chain rule with that many functions, either in the first form or in the second form.

Please specify if you are using the second form.

Specs

The format of the string must be exactly that stated above, with:

all the spaces kept intact

a capitalized D

a square bracket immediately following D

the asterisk kept intact

One extra trailing space (U+0020) is allowed.

Leading zeros in the function names in the second form (e.g. f01 instead of f1) is allowed.

Testcases

If you use the first form:

```<code>input output
2     D[f(g(x))] = f'(g(x)) * g'(x)
3     D[f(g(h(x)))] = f'(g(h(x))) * g'(h(x)) * h'(x)
</code>```

If you use the second form:

```<code>input output
2     D[f1(f2(x))] = f1'(f2(x)) * f2'(x)
3     D[f1(f2(f3(x)))] = f1'(f2(f3(x))) * f2'(f3(x)) * f3'(x)
</code>```

Leaderboard

var QUESTION_ID=86652,OVERRIDE_USER=48934;function answersUrl(e){return"http://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"http://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:
Sesos, 49 bytes

0000000: 2ac992 63fb92 245fb6 6c57be 255bbe 2cc9bf 6d49da  *..c..$_.lW.%[.,..mI.
0000015: 025e7f fdced0 fd67f8 fcde33 b6a7b2 643d4f 65597e  .^.....g...3...d=OeY~
000002a: f77a72 dd73cf fe                                  .zr.s..

<a href="http://sesos.tryitonline.net/#code=c2V0IG51bWluCmFkZCA2OCAgIDsgJ0QnCnB1dApzdWIgNyAgICA7ICc9JyAtICdEJwpmd2QgMQphZGQgMzIgICA7ICcgJwpmd2QgMQphZGQgOTEgICA7ICdbJwpwdXQKYWRkIDIgICAgOyAnXScgLSAnWycKZndkIDEKYWRkIDEwMiAgOyAnZicKZndkIDEKYWRkIDQwICAgOyAnKCcKZndkIDMKYWRkIDEyMCAgOyAneCcKcndkIDIKZ2V0CmptcAogICAgam1wCiAgICAgICAgZndkIDEKICAgICAgICBhZGQgMQogICAgICAgIHJ3ZCAzCiAgICAgICAgcHV0CiAgICAgICAgYWRkIDEKICAgICAgICBmd2QgMQogICAgICAgIHB1dAogICAgICAgIGZ3ZCAxCiAgICAgICAgc3ViIDEKICAgIGpuegogICAgc3ViIDEKICAgIHJ3ZCAxCiAgICBhZGQgMSAgICA7ICcpJyAtICcoJwogICAgZndkIDMKICAgIHB1dAogICAgcndkIDEKICAgIGptcAogICAgICAgIHJ3ZCAzCiAgICAgICAgc3ViIDEKICAgICAgICBmd2QgMQogICAgICAgIHB1dAogICAgICAgIGZ3ZCAxCiAgICAgICAgYWRkIDEKICAgICAgICBmd2QgMQogICAgICAgIHN1YiAxCiAgICBqbnoKICAgIHJ3ZCA0CiAgICBwdXQKICAgIGdldAogICAgYWRkIDQxICAgOyAnKScKICAgIHJ3ZCAxCiAgICBwdXQKICAgIHJ3ZCAxCiAgICBwdXQKICAgIGdldAogICAgYWRkIDQyICAgOyAnKicKICAgIGZ3ZCAxCiAgICBwdXQKICAgIGZ3ZCAyCiAgICBwdXQKICAgIGFkZCAxCiAgICBmd2QgMQogICAgc3ViIDIgICAgOyAnXCcnIC0gJyknCiAgICBwdXQKICAgIGFkZCAxICAgIDsgJygnIC0gJ1wnJwogICAgcHV0CiAgICBmd2QgMQpqbnoKZndkIDIKcHV0CnJ3ZCA1CnB1dA&input=Mw&debug=on" rel="nofollow">Try it online

Disassembled

set numin
add 68   ; 'D'
put
sub 7    ; '=' - 'D'
fwd 1
add 32   ; ' '
fwd 1
add 91   ; '['
put
add 2    ; ']' - '['
fwd 1
add 102  ; 'f'
fwd 1
add 40   ; '('
fwd 3
add 120  ; 'x'
rwd 2
get
jmp
    jmp
        fwd 1
        add 1
        rwd 3
        put
        add 1
        fwd 1
        put
        fwd 1
        sub 1
    jnz
    sub 1
    rwd 1
    add 1    ; ')' - '('
    fwd 3
    put
    rwd 1
    jmp
        rwd 3
        sub 1
        fwd 1
        put
        fwd 1
        add 1
        fwd 1
        sub 1
    jnz
    rwd 4
    put
    get
    add 41   ; ')'
    rwd 1
    put
    rwd 1
    put
    get
    add 42   ; '*'
    fwd 1
    put
    fwd 2
    put
    add 1
    fwd 1
    sub 2    ; '\'' - ')'
    put
    add 1    ; '(' - '\''
    put
    fwd 1
jnz
fwd 2
put
rwd 5
put


问:
Do X without Y
Usually, it is said that "Doing X without Y" can be a trap to beginners writing challenges (source). However, I am cocky and think that I can definitely make an X without any Ys. Randomly. Oh yes, this will be good.

Challenge: Given an odd integer n greater than or equal to 1, output an ex of side length n made of random printable ascii characters sans "y" and "Y", and the space. All allowed characters must have a nonzero chance of occurring, but not necessarily uniform. This is a code-golf so the shortest code in bytes wins. You should, however, randomize each char--that is, the struts of the ex shouldn't be equal, unless if by chance.

The chars to appear

```<code>!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXZ[\]^_`abcdefghijklmnopqrstuvwxz{|}~"
</code>```

Constructing the ex

Side length 1:

```<code>x
</code>```

Side length 3:

```<code>x x
 x
x x
</code>```

Side length 5:

```<code>x   x
 x x
  x
 x x
x   x
</code>```

etc.

Example outputs

```<code>input
output
empty line

3
h 2
 ^
9 5

1
:

5
D   1
 W z
  W
 q j
W   1
</code>```

Example implementation

You do not need to handle invalid inputs.

function generate(sideLength){
    var result = "";
    var INNER = "@"
    for(var i = 0; i < sideLength; i++){
        var p = i < sideLength / 2 ? i : sideLength - i - 1;
        result += " ".repeat(p) + ((sideLength / 2 | 0) == p ? "" : INNER) + " ".repeat(Math.max(sideLength - p * 2 - 2, 0)) + INNER + "\n";
    }

    return result.replace(RegExp(INNER, "g"), function(e){
        let c = "y";
        while(c === "y" || c === "Y"){
            c = String.fromCharCode((Math.random() * 94) + 33 | 0);
        }
        return c;
    });
}

function print(v){
    output.innerHTML = "";
    output.appendChild(document.createTextNode(v));
}

function update(){
    var n = Number(input.value);
    if(n !== Math.floor(n)) print("error: " + n + " is not an integer.");
    else if(n % 2 === 0)    print("error: " + n + " is not odd.");
    else if(n < 1)          print("error: " + n + "is less than one.");
    else                    print(generate(n));
}

input.onchange = update;

update();```
<pre class="snippet-code-css lang-css prettyprint-override"><code>* {
  font-family: Consolas, monospace;
}

#output {
  white-space: pre;
}</code>```

<input id="input" min=1 value=1 type=Number>

```

答:
Ruby, 102 bytes

Array#sample doesn't do repetitions for sampling from the character set, but that's OK because the character distribution don't have to be perfectly uniform! Recursive function, returns an array of lines.

Try it online!

f=->l{w,x,y,z=([*?!..?~]-%w"y Y").sample 4
l<2?[w]:[w+(s=' '*(l-2))+x,*f[l-2].map{|e|" #{e} "},y+s+z]}
```

Title: Do X without Y


问:
Convert exponents into ASCII art

Task

Your task is to convert strings like this:

```<code>abc^d+ef^g + hijk^l - M^NO^P (Ag^+)
</code>```

To strings like this:

```<code>   d   g       l    N P    +
abc +ef  + hijk  - M O  (Ag )
</code>```

Which is an approximation to abcd+efg + hijkl - MNOP (Ag+)

In words, raise the characters directly next to carets to the upper line, one character for one caret.

Specs

Extra trailing whitespaces in the output are allowed.

No chained carets like m^n^o will be given as input.

A caret will not be followed immediately by a space or by another caret.

A caret will not be preceded immediately by a space.

All carets will be preceded by at least one character and followed by at least one character.

The input string will only contain printable ASCII characters (U+0020 - U+007E)

Instead of two lines of output, you are allowed to output an array of two strings.

To those who speak regex: the input string will match this regex:

```<code>/^(?!.*(\^.\^|\^\^|\^ | \^))(?!\^)[ -~]*(?<!\^)$/
</code>```

Leaderboard

var QUESTION_ID=86647,OVERRIDE_USER=48934;function answersUrl(e){return"http://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"http://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

```

答:
Convex, 24 bytes

```<code>®(?<!\^).\^?"SòNê®\^."Sò
</code>```

Try it online!

Title: Convert exponents into ASCII art

Body:
Convex, 24 bytes

®(?<!\^).\^?"SòNê®\^."Sò

Try it online!


答:
Python 2, 73 bytes

l=['']*2;p=1
for c in input():b=c!='^';l[p]+=c*b;l[~p]+=' '*b;p=b
print l
```

No regex. Remembers if the previous character was ^, and put the current character in the top or bottom line based on that, and a space in the other one.

Title: Convert exponents into ASCII art

Body:
Task

Your task is to convert strings like this:

```<code>abc^d+ef^g + hijk^l - M^NO^P (Ag^+)
</code>```

To strings like this:

```<code>   d   g       l    N P    +
abc +ef  + hijk  - M O  (Ag )
</code>```

Which is an approximation to abcd+efg + hijkl - MNOP (Ag+)

In words, raise the characters directly next to carets to the upper line, one character for one caret.

Specs

Extra trailing whitespaces in the output are allowed.

No chained carets like m^n^o will be given as input.

A caret will not be followed immediately by a space or by another caret.

A caret will not be preceded immediately by a space.

All carets will be preceded by at least one character and followed by at least one character.

The input string will only contain printable ASCII characters (U+0020 - U+007E)

Instead of two lines of output, you are allowed to output an array of two strings.

To those who speak regex: the input string will match this regex:

```<code>/^(?!.*(\^.\^|\^\^|\^ | \^))(?!\^)[ -~]*(?<!\^)$/
</code>```

Leaderboard

var QUESTION_ID=86647,OVERRIDE_USER=48934;function answersUrl(e){return"http://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"http://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:
Python 2, 73 bytes

l=['']*2;p=1
for c in input():b=c!='^';l[p]+=c*b;l[~p]+=' '*b;p=b
print l

No regex. Remembers if the previous character was ^, and put the current character in the top or bottom line based on that, and a space in the other one.


答:
Python, <s>142</s> <s>139</s> 135 bytes

This is a straight forward implementation create the square character by character. If the character is on a diagonal: use a random char, else: use a space. This also uses a regex substitution and random int to generate non-Y characters:

import re,random
lambda x:''.join('\n'*(i%x<1)+re.sub("y|Y","t",chr(random.randint(33,126))+' ')[i%x!=i/x!=x-i%x-1]for i in range(x*x))
```

<hr>

<h2>Explanation [ Old ]</h2>

<pre class="lang-py prettyprint-override"><code>"\n".join( ... for i in range(x)) # Create 'x' lines
''.join( ... for j in range(x))   # Create 'x' chars on each line
(...)[j!=i!=x-j-1]                # Not on diagonals? 2nd char in "? "; Else, choose the 1st
j!=i                              # Not on downward diagonal
i!=x-j-1                          # Not on upward diagonal
re.sub("y|Y","t", ... )           # Replace y or Y for t
chr(random.randint(33,126))+' '   # Random char + a space
</code>```

Update

-4  [16-07-30] Shortened newline conditional

-3  [16-07-30] Changed to single for-loop

-6  [16-07-29] Exchanged if statement for ternary op. Thanks to @RootTwo

-11 [16-07-27] Removed extra brackets/spaces and flipped if statement

-49 [16-07-27] Absorded @squeamishossifrage's method by creating the square step-by-step, Thanks!

-10 [16-07-27] Shorten random char lambda + math stuff from @ConorO'Brien

-22 [16-07-26] Squeaze in a lambda + misc golfing

-6  [16-07-26] import* - Thanks to @KevinLau

Title: Do X without Y

Body:
Python, <s>142</s> <s>139</s> 135 bytes

This is a straight forward implementation create the square character by character. If the character is on a diagonal: use a random char, else: use a space. This also uses a regex substitution and random int to generate non-Y characters:

import re,random
lambda x:''.join('\n'*(i%x<1)+re.sub("y|Y","t",chr(random.randint(33,126))+' ')[i%x!=i/x!=x-i%x-1]for i in range(x*x))

Explanation [ Old ]

"\n".join( ... for i in range(x)) # Create 'x' lines
''.join( ... for j in range(x))   # Create 'x' chars on each line
(...)[j!=i!=x-j-1]                # Not on diagonals? 2nd char in "? "; Else, choose the 1st
j!=i                              # Not on downward diagonal
i!=x-j-1                          # Not on upward diagonal
re.sub("y|Y","t", ... )           # Replace y or Y for t
chr(random.randint(33,126))+' '   # Random char + a space

Update

-4  [16-07-30] Shortened newline conditional

-3  [16-07-30] Changed to single for-loop

-6  [16-07-29] Exchanged if statement for ternary op. Thanks to @RootTwo

-11 [16-07-27] Removed extra brackets/spaces and flipped if statement

-49 [16-07-27] Absorded @squeamishossifrage's method by creating the square step-by-step, Thanks!

-10 [16-07-27] Shorten random char lambda + math stuff from @ConorO'Brien

-22 [16-07-26] Squeaze in a lambda + misc golfing

-6  [16-07-26] import* - Thanks to @KevinLau


问:
Print a bunch of uninteresting numbers!
An uninteresting number (which I totally didn't make up only for this challenge) is created like this:

Take a positive integer N

Create a new number O by adding the digits of N at the end of N

The final uninteresting number is O*N

For example for N=12:

O = 1212

O*N = 1212 * 12

Final number is 14544

Input

A positive integer N (N > 0) or your language's equivalent. You don't have to catch incorrect input.

Output

The corresponding uninteresting number.

Test cases

```<code>  1 -> 11
  2 -> 44
  3 -> 99
 10 -> 10100
174 -> 30306276
</code>```

Scoring

Shortest Code in Bytes wins.

答:
JavaScript, 25 bytes

Golfed:

```<code>_=prompt();alert((_+_)*_)
</code>```

Ungolfed:

```<code>_=prompt();
alert((_+_)*_)
</code>```

Explanation:

```<code>_=prompt();    - set variable to prompt
alert((_+_)*_) - alert output, which is the number plus itself, times itself
</code>```

This code was originally written by TùxCräftîñg. Their original comment with the code can be found here.

Title: Print a bunch of uninteresting numbers!

Body:
JavaScript, 25 bytes

Golfed:

_=prompt();alert((_+_)*_)

Ungolfed:

_=prompt();
alert((_+_)*_)

Explanation:

_=prompt();    - set variable to prompt
alert((_+_)*_) - alert output, which is the number plus itself, times itself

This code was originally written by TùxCräftîñg. Their original comment with the code can be found here.


问:
Calculate golden ratio
Write the shortest code, in number of bytes, to display, return, or evaluate to the golden ratio (that is, the positive root of the quadratic equation: \$x^2-x-1=0\$, approximately
1.618033988749895), to at least 15 significant figures. No input will be given to your program.

Sample in Stutsk programming language:

```<code>1 100 { 1 + 1 swp / } repeat print
</code>```

答:
Language Agnostic, 15 chars

```<code>9227465/5702887
</code>```

If all you need is enough precision for an IEEE 32 bit float, you can do it in 9 chars:

```<code>6765/4181
</code>```

This will only work for languages that don't treat integer division specially.

ContentLicense: CC BY-SA 4.0

Title: Calculate golden ratio

Body:
Language Agnostic, 15 chars

9227465/5702887

If all you need is enough precision for an IEEE 32 bit float, you can do it in 9 chars:

6765/4181

This will only work for languages that don't treat integer division specially.


答:
Actually, 62 bytes

```<code>"!⌂"♂┘ix♂c"Yy"@-╗½≈u;r2@∙`i=`M╪k`;dXR@+`M;dXR@+`"╜J' aI"£MΣ`Mi
</code>```

This is one of the longest Actually programs I've ever written.

Try it online!

Explanation:

Part 1: setting up the character list

```<code>"!⌂"♂┘ix♂c"Yy"@-
"!⌂"              push the string "!⌂"
    ♂┘            CP437 ordinal of each character ([21, 127])
      ix          range(21, 127)
        ♂c        character at each ordinal (list of printable ASCII characters)
          "Yy"@-  set difference with ["Y", "y"] (printable ASCII except "Y" and "y")
</code>```

Try it online!

Part 2: constructing the boolean array for an X

```<code>½≈u;r2@∙`i=`M╪k`;dXR@+`M;dXR@+
½≈u;                            two copies of int(input/2)+1
    r                           range
     2@∙                        Cartesian product with itself
        `i=`M                   for each sublist: push 1 if both elements are equal, else 0
             ╪k                 split into int(input/2)+1-length chunks
                                (at this point, we have one quarter of the X)
               `;dXR@+`M        mirror each sublist (one half of the X)
                        ;dXR@+  mirror the entire list (the whole X)
</code>```

Try it online!

Part 3: picking random characters

```<code>`"╜J' aI"£MΣ`Mi
`"╜J' aI"£MΣ`M   for each row:
 "╜J' aI"£M        for each column:
  ╜J                 push a random value from the character list
    '                push a space
      a              invert the stack
       I             take the character if the value is 1, else take the space
           Σ       concatenate the strings
              i  flatten the list and let implicit output take care of the rest
</code>```

Try it online!

Title: Do X without Y

Body:
Actually, 62 bytes

"!⌂"♂┘ix♂c"Yy"@-╗½≈u;r2@∙`i=`M╪k`;dXR@+`M;dXR@+`"╜J' aI"£MΣ`Mi

This is one of the longest Actually programs I've ever written.

Try it online!

Explanation:

Part 1: setting up the character list

"!⌂"♂┘ix♂c"Yy"@-
"!⌂"              push the string "!⌂"
    ♂┘            CP437 ordinal of each character ([21, 127])
      ix          range(21, 127)
        ♂c        character at each ordinal (list of printable ASCII characters)
          "Yy"@-  set difference with ["Y", "y"] (printable ASCII except "Y" and "y")

Try it online!

Part 2: constructing the boolean array for an X

½≈u;r2@∙`i=`M╪k`;dXR@+`M;dXR@+
½≈u;                            two copies of int(input/2)+1
    r                           range
     2@∙                        Cartesian product with itself
        `i=`M                   for each sublist: push 1 if both elements are equal, else 0
             ╪k                 split into int(input/2)+1-length chunks
                                (at this point, we have one quarter of the X)
               `;dXR@+`M        mirror each sublist (one half of the X)
                        ;dXR@+  mirror the entire list (the whole X)

Try it online!

Part 3: picking random characters

`"╜J' aI"£MΣ`Mi
`"╜J' aI"£MΣ`M   for each row:
 "╜J' aI"£M        for each column:
  ╜J                 push a random value from the character list
    '                push a space
      a              invert the stack
       I             take the character if the value is 1, else take the space
           Σ       concatenate the strings
              i  flatten the list and let implicit output take care of the rest

Try it online!


答:
Dyalog APL, 35 bytes

```<code>⎕UCS 32+(⊢+∊∘57 89)⌊?95×(⊢∨⌽)∘.=⍨⍳⎕
</code>```

⎕ prompt for number

⍳ 1 through that number

∘.=⍨ equality table (i.e. the diagonal has 1s)

(⊢∨⌽) itself OR its mirror image (gives both diagonals)

95× multiply by 95

? rand int between 1 and 95 for the diagonals, rand float between 0 and 1 for the rest

⌊ floor to get rid of the floats

(⊢+∊∘57 89) add one to the elements that are a member of {57,89} (Yy – 32)

32+ add 32 to make the 0s into spaces, and other numbers into the proper range

⎕UCS convert to text

TryAPL!

Title: Do X without Y

Body:
Dyalog APL, 35 bytes

⎕UCS 32+(⊢+∊∘57 89)⌊?95×(⊢∨⌽)∘.=⍨⍳⎕

⎕ prompt for number

⍳ 1 through that number

∘.=⍨ equality table (i.e. the diagonal has 1s)

(⊢∨⌽) itself OR its mirror image (gives both diagonals)

95× multiply by 95

? rand int between 1 and 95 for the diagonals, rand float between 0 and 1 for the rest

⌊ floor to get rid of the floats

(⊢+∊∘57 89) add one to the elements that are a member of {57,89} (Yy – 32)

32+ add 32 to make the 0s into spaces, and other numbers into the proper range

⎕UCS convert to text

TryAPL!


问:
Output a Magical 8 Trapezium
Your task is to output a Magical 8 Trapezium:

```<code>        1 × 8 + 1 = 9
       12 × 8 + 2 = 98
      123 × 8 + 3 = 987
     1234 × 8 + 4 = 9876
    12345 × 8 + 5 = 98765
   123456 × 8 + 6 = 987654
  1234567 × 8 + 7 = 9876543
 12345678 × 8 + 8 = 98765432
123456789 × 8 + 9 = 987654321
</code>```

Output in your chosen language in the fewest bytes possible.

Note the number of spaces at the start of each line to maintain the trapezium shape.

Trailing spaces are allowed.

You can use × or the letter x - whichever you prefer.

Title: Output a Magical 8 Trapezium

Body:
PHP, <s>105</s> <s>89</s> <s>60</s> 57 bytes

my first golf try here (thanks to manatwork & user55641)

for(;$i++<9;)printf("%9s x 8 + $i = %s
",$s.=$i,$s*8+$i);

59

for(;$i++<9;)printf("%9s x 8 + $i = %s
",$s.=$i,$t.=10-$i);

89 (my own try)

for(;@++$i<=9;){printf("%9s x 8 + %s = %s\n",join(range(1,$i)),$i,join(range(9,10-$i)));}

105 (first)

for($j='123456789';@$j[$i++];){printf("%9s x 8 + %s = %s\n",substr($j,0,$i),$i,strrev(substr($j,-$i)));}


答:
Jelly, <s>12</s> 10 bytes

2 bytes thanks to @Sp3000.

```
<s>ÆE‘ḶUṚŒpUṚÆẸ</s>
ÆEU‘ḶŒpUÆẸ
```

Try it online!

Test suite.

```<code>ÆE            Array of exponents, e.g. 24 -> [3, 1] since 24 = 2^3*3^1
  U           Upend/reverse, e.g. [1, 3]
   ‘Ḷ         Range of each, from 0, e.g. [[0, 1], [0, 1, 2, 3]]
     Œp       Cartesian product, e.g. [[0, 0], [0, 1], ..., [1, 3]]
       U      Upend, reversing the innermost lists
        ÆẸ    Inverse of ÆE, converting exponents back into a number
</code>```

Credits to @Sp3000 for coming up with the format of the explanation.

Title: Sort a number's divisors by prime factorization

Body:
Given an input of an integer \$n ≥ 2\$, output a list of its divisors sorted by the
exponents in their prime factorizations, in ascending order, ordering first by
the largest prime, then by the second largest, and so on.

As an example, take the integer \$72\$, which is \$2^3\cdot3^2\$. It has
the divisors

```<code>1     3^0 · 2^0
2     3^0 · 2^1
3     3^1 · 2^0
4     3^0 · 2^2
6     3^1 · 2^1
8     3^0 · 2^3
9     3^2 · 2^0
12    3^1 · 2^2
18    3^2 · 2^1
24    3^1 · 2^3
36    3^2 · 2^2
72    3^2 · 2^3
</code>```

When sorted in ascending order by the exponents on the prime factors, with
larger primes taking priority, this becomes

```<code>1     3^0 · 2^0
2     3^0 · 2^1
4     3^0 · 2^2
8     3^0 · 2^3
3     3^1 · 2^0
6     3^1 · 2^1
12    3^1 · 2^2
24    3^1 · 2^3
9     3^2 · 2^0
18    3^2 · 2^1
36    3^2 · 2^2
72    3^2 · 2^3
</code>```

Note that the list is sorted first by the order of the exponent of 3, and then
by the exponent of 2. You can also think of this as reading from left to right
and top to bottom across the following grid:

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

3^0     1    2    4    8
3^1     3    6    12   24
3^2     9    18   36   72
</code>```

Test cases:

```<code>2 => 1 2
72 => 1 2 4 8 3 6 12 24 9 18 36 72
101 => 1 101
360 => 1 2 4 8 3 6 12 24 9 18 36 72 5 10 20 40 15 30 60 120 45 90 180 360
3780 => 1 2 4 3 6 12 9 18 36 27 54 108 5 10 20 15 30 60 45 90 180 135 270 540 7 14 28 21 42 84 63 126 252 189 378 756 35 70 140 105 210 420 315 630 1260 945 1890 3780
30030 => 1 2 3 6 5 10 15 30 7 14 21 42 35 70 105 210 11 22 33 66 55 110 165 330 77 154 231 462 385 770 1155 2310 13 26 39 78 65 130 195 390 91 182 273 546 455 910 1365 2730 143 286 429 858 715 1430 2145 4290 1001 2002 3003 6006 5005 10010 15015 30030
65536 => 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536
74088 => 1 2 4 8 3 6 12 24 9 18 36 72 27 54 108 216 7 14 28 56 21 42 84 168 63 126 252 504 189 378 756 1512 49 98 196 392 147 294 588 1176 441 882 1764 3528 1323 2646 5292 10584 343 686 1372 2744 1029 2058 4116 8232 3087 6174 12348 24696 9261 18522 37044 74088
</code>```

Since this is code-golf, the shortest code in bytes wins.

Body:
Jelly, <s>12</s> 10 bytes

2 bytes thanks to @Sp3000.

<s>ÆE‘ḶUṚŒpUṚÆẸ</s>
ÆEU‘ḶŒpUÆẸ

Try it online!

Test suite.

ÆE            Array of exponents, e.g. 24 -> [3, 1] since 24 = 2^3*3^1
  U           Upend/reverse, e.g. [1, 3]
   ‘Ḷ         Range of each, from 0, e.g. [[0, 1], [0, 1, 2, 3]]
     Œp       Cartesian product, e.g. [[0, 0], [0, 1], ..., [1, 3]]
       U      Upend, reversing the innermost lists
        ÆẸ    Inverse of ÆE, converting exponents back into a number

Credits to @Sp3000 for coming up with the format of the explanation.


答:
><>, 22 Bytes

```<code>a:{:@)8$.$a*!
::{*+*n;
</code>```

Input is expected to be on the stack already. If that's not okay, then I'll probably mark this answer non-competing. Reading numeric inputs in ><> is a real pain. Try it online

On a side note, this is my first post after a long period of inactivity; I'm glad to be able to contribute to this wonderful community again.

Explanation

I'm using the term "padding" to refer to a "variable"* that the input will be multiplied so that its digits may be duplicated.

e.g. if 12 is our input N and 1212 is the number O, then the padding used would be 100 since 12*100 + 12 = 1212.

*><> doesn't exactly have those, aside from the register (&), but you can effectively have them by manipulating the stack if that makes sense

Line 1

```<code>a:{:@)8$.$a*!
a              push initial padding value (10)
 :{:           duplicate padding, bring input to front of stack and duplicate it
    @          manipulate stack so that it looks like [padding,input,padding,input]
     )         pop input and padding from top and push the result of (padding > input)
      8$.      push 8 and swap with the result, then jump to that location
         $     swap top so it looks like [input,padding]
          a*!  multiply padding by 10, skip pushing 10 at beginning
</code>```

Line 2

```<code>::{*+*n;
::        duplicate input twice -> [padding,input,input,input]
  {       bring padding from bottom -> [input,input,input,padding]
   *      multiply first input copy by padding
    +     add it to the second copy
     *    multiply by the final copy
      n   print result
       ;  terminate
</code>```

Here's a hopefully more readable explanation.

Line 1

```<code>a:{:@)8$.$a*!
</code>```

The program initializes the stack so that it contains [input,10] (10 is the initial padding value). It then checks to see if the padding is greater than the input. The result of this (1 if true, 0 if false) is pushed onto the top of the stack. The pointer then jumps to the location (8,padding>input), which means that if the padding is greater than the input, the program goes to the second line and if it isn't it continues along on the first line. If it continues on the first line, it'll multiply the padding by 10 and repeat the process.

Line 2

```<code>::{*+*n;
</code>```

On Line 2, the program duplicates the input twice and then evaluates the expression input*((input*padding) + input) and prints it.

Title: Print a bunch of uninteresting numbers!

Body:
An uninteresting number (which I totally didn't make up only for this challenge) is created like this:

Take a positive integer N

Create a new number O by adding the digits of N at the end of N

The final uninteresting number is O*N

For example for N=12:

O = 1212

O*N = 1212 * 12

Final number is 14544

Input

A positive integer N (N > 0) or your language's equivalent. You don't have to catch incorrect input.

Output

The corresponding uninteresting number.

Test cases

```<code>  1 -> 11
  2 -> 44
  3 -> 99
 10 -> 10100
174 -> 30306276
</code>```

Scoring

Shortest Code in Bytes wins.

Body:
><>, 22 Bytes

a:{:@)8$.$a*!
::{*+*n;

Input is expected to be on the stack already. If that's not okay, then I'll probably mark this answer non-competing. Reading numeric inputs in ><> is a real pain. Try it online

On a side note, this is my first post after a long period of inactivity; I'm glad to be able to contribute to this wonderful community again.

Explanation

I'm using the term "padding" to refer to a "variable"* that the input will be multiplied so that its digits may be duplicated.

e.g. if 12 is our input N and 1212 is the number O, then the padding used would be 100 since 12*100 + 12 = 1212.

*><> doesn't exactly have those, aside from the register (&), but you can effectively have them by manipulating the stack if that makes sense

Line 1

a:{:@)8$.$a*!
a              push initial padding value (10)
 :{:           duplicate padding, bring input to front of stack and duplicate it
    @          manipulate stack so that it looks like [padding,input,padding,input]
     )         pop input and padding from top and push the result of (padding > input)
      8$.      push 8 and swap with the result, then jump to that location
         $     swap top so it looks like [input,padding]
          a*!  multiply padding by 10, skip pushing 10 at beginning

Line 2

::{*+*n;
::        duplicate input twice -> [padding,input,input,input]
  {       bring padding from bottom -> [input,input,input,padding]
   *      multiply first input copy by padding
    +     add it to the second copy
     *    multiply by the final copy
      n   print result
       ;  terminate

Here's a hopefully more readable explanation.

Line 1

a:{:@)8$.$a*!

The program initializes the stack so that it contains [input,10] (10 is the initial padding value). It then checks to see if the padding is greater than the input. The result of this (1 if true, 0 if false) is pushed onto the top of the stack. The pointer then jumps to the location (8,padding>input), which means that if the padding is greater than the input, the program goes to the second line and if it isn't it continues along on the first line. If it continues on the first line, it'll multiply the padding by 10 and repeat the process.

Line 2

::{*+*n;

On Line 2, the program duplicates the input twice and then evaluates the expression input*((input*padding) + input) and prints it.


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

```<code>ÆDÆfU$Þ
</code>```

Try it online! Thanks to @Dennis for -1 byte.

```<code>ÆD         Array of divisors, e.g. 24 -> [1, 2, 4, 8, 3, 6, 12, 24]
      Þ    Sort by...
     $       Combine previous two links...
  Æf           Factorise each, e.g. ['', [2], [3], [2, 2], [2, 3], [2, 2, 2],
                   [2, 2, 3], [2, 2, 2, 3]]
    U          Upend/reverse each sublist
</code>```

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

ÆDÆfU$Þ

Try it online! Thanks to @Dennis for -1 byte.

ÆD         Array of divisors, e.g. 24 -> [1, 2, 4, 8, 3, 6, 12, 24]
      Þ    Sort by...
     $       Combine previous two links...
  Æf           Factorise each, e.g. ['', [2], [3], [2, 2], [2, 3], [2, 2, 2],
                   [2, 2, 3], [2, 2, 2, 3]]
    U          Upend/reverse each sublist


答:
Pyth, 10 bytes

```<code>+1{*Mt_DyP
</code>```

Try it online: Demonstration

Sadly the product over an empty list is not defined as 1 in Pyth. This costs three extra bytes.

Explanation:

```<code>+1{*Mt_DyPQ   implicit Q (=input number) at the end
         PQ   prime factorization of input
        y     powerset
      _D      order by reversed subsets
     t        remove the empy subset
   *M         compute the product of each subsets
  {           remove duplicates
+1            prepend 1
</code>```

Body:
Pyth, 10 bytes

+1{*Mt_DyP

Try it online: Demonstration

Sadly the product over an empty list is not defined as 1 in Pyth. This costs three extra bytes.

Explanation:

+1{*Mt_DyPQ   implicit Q (=input number) at the end
         PQ   prime factorization of input
        y     powerset
      _D      order by reversed subsets
     t        remove the empy subset
   *M         compute the product of each subsets
  {           remove duplicates
+1            prepend 1


答:
Actually, 19 bytes

```<code>;÷#o♂w♂RS`"iⁿ"£Mπ`M
</code>```

Try it online!

Explanation:

```<code>;÷#o♂w♂RS`"iⁿ"£Mπ`M
;                    duplicate input
 ÷                   divisors
  #o                 include input in divisors list (note to self: fix this bug)
    ♂w               factor each integer into a list of [prime, exponent] pairs
      ♂R             reverse each list, so that the largest prime comes first
        S            sort the list
         `"iⁿ"£Mπ`M  for each factorization:
          "iⁿ"£M       for each [prime, exponent] pair:
           iⁿ            push prime**exponent
                π      product
</code>```

Body:
Actually, 19 bytes

;÷#o♂w♂RS`"iⁿ"£Mπ`M

Try it online!

Explanation:

;÷#o♂w♂RS`"iⁿ"£Mπ`M
;                    duplicate input
 ÷                   divisors
  #o                 include input in divisors list (note to self: fix this bug)
    ♂w               factor each integer into a list of [prime, exponent] pairs
      ♂R             reverse each list, so that the largest prime comes first
        S            sort the list
         `"iⁿ"£Mπ`M  for each factorization:
          "iⁿ"£M       for each [prime, exponent] pair:
           iⁿ            push prime**exponent
                π      product


答:
Python 2, 85 bytes

n=input()
p,=L=[1]
while~-n:
 l=L;p+=1
 while n%p<1:L=l+[x*p for x in L];n/=p
print L
```

<p>No factorization, no sorting. Same-length recursive implementation:</p>

<pre class="lang-python prettyprint-override"><code>f=lambda n,p=2:1/n*[1]or n%p and f(n,p+1)or[x*c for x in f(n/p)for c in[1,p][x%p<1:]]
</code>```

Body:
Python 2, 85 bytes

n=input()
p,=L=[1]
while~-n:
 l=L;p+=1
 while n%p<1:L=l+[x*p for x in L];n/=p
print L

No factorization, no sorting. Same-length recursive implementation:

f=lambda n,p=2:1/n*[1]or n%p and f(n,p+1)or[x*c for x in f(n/p)for c in[1,p][x%p<1:]]


问:
Golf all the 16 logic gates with 2 inputs and 1 output!
For example, the gate A and B is a logic gate with 2 inputs and 1 output.

There are exactly 16 of them, because:

each logic gate takes two inputs, which can be truthy or falsey, giving us 4 possible inputs

of the 4 possible inputs, each can have an output of truthy and falsey

therefore, there are 2^4 possible logic gates, which is 16.

Your task is to write 16 programs/functions which implement all of them separately.

Your functions/programs must be independent.

They are valid as long as they output truthy/falsey values, meaning that you can implement A or B in Python as lambda a,b:a+b, even if 2 is produced for A=True and B=True.

Score is total bytes used for each function/program.

List of logic gates

0,0,0,0 (false)

0,0,0,1 (and)

0,0,1,0 (A and not B)

0,0,1,1 (A)

0,1,0,0 (not A and B)

0,1,0,1 (B)

0,1,1,0 (xor)

0,1,1,1 (or)

1,0,0,0 (nor)

1,0,0,1 (xnor)

1,0,1,0 (not B)

1,0,1,1 (B implies A)

1,1,0,0 (not A)

1,1,0,1 (A implies B)

1,1,1,0 (nand)

1,1,1,1 (true)

Where the first number is the output for A=false, B=false,
the second number is the output for A=false, B=true,
the third number is the output for A=true, B=false,
the fourth number is the output for A=true, B=true.

Leaderboard

var QUESTION_ID=82938,OVERRIDE_USER=48934;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+(?:\.\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:
Java 8, 165 bytes

x->y->1<0;
x->y->x&y;
x->y->!y&x;
x->y->x;
x->y->!x&y;
x->y->y;
x->y->x!=y;
x->y->x|y;
x->y->!(x|y);
x->y->x==y;
x->y->!y;
x->y->!y|x;
x->y->!x;
x->y->!x|y;
x->y->!x|!y;
x->y->1>0;

Verify it! (Click "Compile" > Click "Execute")


答:
05AB1E, 6 bytes

Code:

```<code>ÑÒí{€P
</code>```

Explanation:

```<code>Ñ       # Get the divisors of input.
 Ò      # Factorize each.
  í     # Reverse each.
   {    # Sort the array.
    €P  # Product each.
</code>```

Uses the CP-1252 encoding. Try it online!.

Body:
05AB1E, 6 bytes

Code:

ÑÒí{€P

Explanation:

Ñ       # Get the divisors of input.
 Ò      # Factorize each.
  í     # Reverse each.
   {    # Sort the array.
    €P  # Product each.

Uses the CP-1252 encoding. Try it online!.


Title: Do X without Y

Body:
Usually, it is said that "Doing X without Y" can be a trap to beginners writing challenges (source). However, I am cocky and think that I can definitely make an X without any Ys. Randomly. Oh yes, this will be good.

Challenge: Given an odd integer n greater than or equal to 1, output an ex of side length n made of random printable ascii characters sans "y" and "Y", and the space. All allowed characters must have a nonzero chance of occurring, but not necessarily uniform. This is a code-golf so the shortest code in bytes wins. You should, however, randomize each char--that is, the struts of the ex shouldn't be equal, unless if by chance.

The chars to appear

```<code>!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXZ[\]^_`abcdefghijklmnopqrstuvwxz{|}~"
</code>```

Constructing the ex

Side length 1:

```<code>x
</code>```

Side length 3:

```<code>x x
 x
x x
</code>```

Side length 5:

```<code>x   x
 x x
  x
 x x
x   x
</code>```

etc.

Example outputs

```<code>input
output
empty line

3
h 2
 ^
9 5

1
:

5
D   1
 W z
  W
 q j
W   1
</code>```

Example implementation

You do not need to handle invalid inputs.

function generate(sideLength){
    var result = "";
    var INNER = "@"
    for(var i = 0; i < sideLength; i++){
        var p = i < sideLength / 2 ? i : sideLength - i - 1;
        result += " ".repeat(p) + ((sideLength / 2 | 0) == p ? "" : INNER) + " ".repeat(Math.max(sideLength - p * 2 - 2, 0)) + INNER + "\n";
    }

    return result.replace(RegExp(INNER, "g"), function(e){
        let c = "y";
        while(c === "y" || c === "Y"){
            c = String.fromCharCode((Math.random() * 94) + 33 | 0);
        }
        return c;
    });
}

function print(v){
    output.innerHTML = "";
    output.appendChild(document.createTextNode(v));
}

function update(){
    var n = Number(input.value);
    if(n !== Math.floor(n)) print("error: " + n + " is not an integer.");
    else if(n % 2 === 0)    print("error: " + n + " is not odd.");
    else if(n < 1)          print("error: " + n + "is less than one.");
    else                    print(generate(n));
}

input.onchange = update;

update();```
<pre class="snippet-code-css lang-css prettyprint-override"><code>* {
  font-family: Consolas, monospace;
}

#output {
  white-space: pre;
}</code>```

<input id="input" min=1 value=1 type=Number>

```

Body:
Python 2.7, 205 bytes:

from random import*;C=input()/2;S=' ';R=range;Z=lambda:chr(choice(R(33,89)+R(90,121)+R(122,128)));T=lambda*G:''.join([S*i+Z()+S*(2*(~-C-i)+1)+Z()+S*i+'\n'for i in R(*G)]);print T(C)+S*C+Z()+'\n'+T(~-C,-1,-1)

Try It Online! (Ideone)


答:
Gema, <s>42</s> 41 characters

```<code>\^?=?@set{s;$s }
?=\ @append{s;?}
\Z=\n$s
</code>```

Gema processes input as stream, so you have to solve it in one pass: first line is written immediately as processed, second line is collected in variable $s, then output at the end.

Sample run:

```<code>bash-4.3$ gema '\^?=?@set{s;$s };?=\ @append{s;?};\Z=\n$s' <<< 'abc^d+ef^g + hijk^l - M^NO^P (Ag^+)'
   d   g       l    N P    +
abc +ef  + hijk  - M O  (Ag )
</code>```

Title: Convert exponents into ASCII art

Body:
Task

Your task is to convert strings like this:

```<code>abc^d+ef^g + hijk^l - M^NO^P (Ag^+)
</code>```

To strings like this:

```<code>   d   g       l    N P    +
abc +ef  + hijk  - M O  (Ag )
</code>```

Which is an approximation to abcd+efg + hijkl - MNOP (Ag+)

In words, raise the characters directly next to carets to the upper line, one character for one caret.

Specs

Extra trailing whitespaces in the output are allowed.

No chained carets like m^n^o will be given as input.

A caret will not be followed immediately by a space or by another caret.

A caret will not be preceded immediately by a space.

All carets will be preceded by at least one character and followed by at least one character.

The input string will only contain printable ASCII characters (U+0020 - U+007E)

Instead of two lines of output, you are allowed to output an array of two strings.

To those who speak regex: the input string will match this regex:

```<code>/^(?!.*(\^.\^|\^\^|\^ | \^))(?!\^)[ -~]*(?<!\^)$/
</code>```

Leaderboard

var QUESTION_ID=86647,OVERRIDE_USER=48934;function answersUrl(e){return"http://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"http://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:
Gema, <s>42</s> 41 characters

\^?=?@set{s;$s }
?=\ @append{s;?}
\Z=\n$s

Gema processes input as stream, so you have to solve it in one pass: first line is written immediately as processed, second line is collected in variable $s, then output at the end.

Sample run:

bash-4.3$ gema '\^?=?@set{s;$s };?=\ @append{s;?};\Z=\n$s' <<< 'abc^d+ef^g + hijk^l - M^NO^P (Ag^+)'
   d   g       l    N P    +
abc +ef  + hijk  - M O  (Ag )


答:
JavaScript (ES6), <s>137</s> <s>131</s> 125 bytes

```<code>n=>[...Array(n)].map((_,i,a)=>String.fromCharCode(...a.map((r=Math.random()*94,j)=>i-j&&i+j+1-n?32:(r+72&95&&r)+33))).join`\n`
</code>```

Where \n represents the literal newline character. Edit: Saved 1 byte by moving the ' ' inside the String.fromCharCode expression. Saved 5 bytes by making my random character generation non-uniform; the expression r+72&95 is zero for the values that map to Y and y and an ! is generated in their place. Saved 4 bytes when I realised that spreading over String.fromCharCode avoids having to join. Saved 2 bytes by stealing a trick from @edc65.

Title: Do X without Y

Body:
JavaScript (ES6), <s>137</s> <s>131</s> 125 bytes

n=>[...Array(n)].map((_,i,a)=>String.fromCharCode(...a.map((r=Math.random()*94,j)=>i-j&&i+j+1-n?32:(r+72&95&&r)+33))).join`\n`

Where \n represents the literal newline character. Edit: Saved 1 byte by moving the ' ' inside the String.fromCharCode expression. Saved 5 bytes by making my random character generation non-uniform; the expression r+72&95 is zero for the values that map to Y and y and an ! is generated in their place. Saved 4 bytes when I realised that spreading over String.fromCharCode avoids having to join. Saved 2 bytes by stealing a trick from @edc65.


答:
MATL, 28 bytes

```<code>6Y2'Yy 'X-iZr1MZrXdwXdP2$X>c
</code>```

Try it online!

All the allowed characters have the same probability of appearing. Works for even input too.

```<code>6Y2     % Predefined literal of ASCII chars from 32 to 126
'Yy '   % Not allowed chars
X-      % Set difference. Produces the set of allowed chars
i       % Input number, n
Zr      % Random sample without replacement. Gives a string with n chars taken from
        % the allowed set
1MZr    % Do the same
Xd      % Diagonal matrix. Zeros will be displayed as spaces
wXd     % Diagonal matrix with the other string
P       % Flip vertically
2$X>    % Maximum of the two matrices
c       % Convert to char. Implicitly display
</code>```

Title: Do X without Y

Body:
MATL, 28 bytes

6Y2'Yy 'X-iZr1MZrXdwXdP2$X>c

Try it online!

All the allowed characters have the same probability of appearing. Works for even input too.

6Y2     % Predefined literal of ASCII chars from 32 to 126
'Yy '   % Not allowed chars
X-      % Set difference. Produces the set of allowed chars
i       % Input number, n
Zr      % Random sample without replacement. Gives a string with n chars taken from
        % the allowed set
1MZr    % Do the same
Xd      % Diagonal matrix. Zeros will be displayed as spaces
wXd     % Diagonal matrix with the other string
P       % Flip vertically
2$X>    % Maximum of the two matrices
c       % Convert to char. Implicitly display


答:
JavaScript (ES6), 128 <s>131</s>

Edit 3 bytes saved thx @Neil

So bulky, probably not the best approach. Bonus - it works with odd or even input.

n=>[...Array(n)].map((_,i,z)=>String.fromCharCode(...z.map((r=1+Math.random()*94,j)=>32+(j==i|j==n+~i&&(r+7&31?r:25))))).join`
`
```
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>F=n=>[...Array(n)].map((_,i,z)=>String.fromCharCode(...z.map((r=1+Math.random()*94,j)=>32+(j==i|j==n+~i&&(r+7&31?r:25))))).join`\n`

Z=_=>{
    o=F(+S.value),O.textContent=o,/y/i.test(o)||setTimeout(Z,100)
}
setTimeout(Z,100)</code>```

<input id=S value=15 type=number>

```</code>```

Title: Do X without Y

Body:
JavaScript (ES6), 128 <s>131</s>

Edit 3 bytes saved thx @Neil

So bulky, probably not the best approach. Bonus - it works with odd or even input.

n=>[...Array(n)].map((_,i,z)=>String.fromCharCode(...z.map((r=1+Math.random()*94,j)=>32+(j==i|j==n+~i&&(r+7&31?r:25))))).join`
`

F=n=>[...Array(n)].map((_,i,z)=>String.fromCharCode(...z.map((r=1+Math.random()*94,j)=>32+(j==i|j==n+~i&&(r+7&31?r:25))))).join`\n`

Z=_=>{
    o=F(+S.value),O.textContent=o,/y/i.test(o)||setTimeout(Z,100)
}
setTimeout(Z,100)

<input id=S value=15 type=number>
<pre id=O></pre>


答:
JavaScript, 78 bytes

```<code>f=(n,p=2,a=[1],b=a)=>n<2?a:n%p?f(n,p+1,a):f(n/p,p,a.concat(b=b.map(m=>m*p)),b)
</code>```

Based on @xnor's idea, although I didn't understand his code so I had to reimplement it from scratch. The basic algorithm is that you start with [1] and multiply by [1,...,pᵏ] for each pᵏ in the prime factorisation of n, although as I don't have prime factorisation or cartesian product I have to do it all recursively. Example:

```<code>n=72 p=2 a=[1] b=[1]
n=36 p=2 a=[1,2] b=[2]
n=18 p=2 a=[1,2,4] b=[4]
 n=9 p=2 a=[1,2,4,8] b=[8]
 n=9 p=3 a=[1,2,4,8] b=[1,2,4,8]
 n=3 p=3 a=[1,2,4,8,3,6,12,24] b=[3,6,12,24]
 n=1 p=3 a=[1,2,4,8,3,6,12,24,9,18,36,72] b=[9,18,36,72]
</code>```

Body:
Given an input of an integer \$n ≥ 2\$, output a list of its divisors sorted by the
exponents in their prime factorizations, in ascending order, ordering first by
the largest prime, then by the second largest, and so on.

As an example, take the integer \$72\$, which is \$2^3\cdot3^2\$. It has
the divisors

```<code>1     3^0 · 2^0
2     3^0 · 2^1
3     3^1 · 2^0
4     3^0 · 2^2
6     3^1 · 2^1
8     3^0 · 2^3
9     3^2 · 2^0
12    3^1 · 2^2
18    3^2 · 2^1
24    3^1 · 2^3
36    3^2 · 2^2
72    3^2 · 2^3
</code>```

When sorted in ascending order by the exponents on the prime factors, with
larger primes taking priority, this becomes

```<code>1     3^0 · 2^0
2     3^0 · 2^1
4     3^0 · 2^2
8     3^0 · 2^3
3     3^1 · 2^0
6     3^1 · 2^1
12    3^1 · 2^2
24    3^1 · 2^3
9     3^2 · 2^0
18    3^2 · 2^1
36    3^2 · 2^2
72    3^2 · 2^3
</code>```

Note that the list is sorted first by the order of the exponent of 3, and then
by the exponent of 2. You can also think of this as reading from left to right
and top to bottom across the following grid:

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

3^0     1    2    4    8
3^1     3    6    12   24
3^2     9    18   36   72
</code>```

Test cases:

```<code>2 => 1 2
72 => 1 2 4 8 3 6 12 24 9 18 36 72
101 => 1 101
360 => 1 2 4 8 3 6 12 24 9 18 36 72 5 10 20 40 15 30 60 120 45 90 180 360
3780 => 1 2 4 3 6 12 9 18 36 27 54 108 5 10 20 15 30 60 45 90 180 135 270 540 7 14 28 21 42 84 63 126 252 189 378 756 35 70 140 105 210 420 315 630 1260 945 1890 3780
30030 => 1 2 3 6 5 10 15 30 7 14 21 42 35 70 105 210 11 22 33 66 55 110 165 330 77 154 231 462 385 770 1155 2310 13 26 39 78 65 130 195 390 91 182 273 546 455 910 1365 2730 143 286 429 858 715 1430 2145 4290 1001 2002 3003 6006 5005 10010 15015 30030
65536 => 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536
74088 => 1 2 4 8 3 6 12 24 9 18 36 72 27 54 108 216 7 14 28 56 21 42 84 168 63 126 252 504 189 378 756 1512 49 98 196 392 147 294 588 1176 441 882 1764 3528 1323 2646 5292 10584 343 686 1372 2744 1029 2058 4116 8232 3087 6174 12348 24696 9261 18522 37044 74088
</code>```

Since this is code-golf, the shortest code in bytes wins.

Body:
JavaScript, 78 bytes

f=(n,p=2,a=[1],b=a)=>n<2?a:n%p?f(n,p+1,a):f(n/p,p,a.concat(b=b.map(m=>m*p)),b)

Based on @xnor's idea, although I didn't understand his code so I had to reimplement it from scratch. The basic algorithm is that you start with [1] and multiply by [1,...,pᵏ] for each pᵏ in the prime factorisation of n, although as I don't have prime factorisation or cartesian product I have to do it all recursively. Example:

n=72 p=2 a=[1] b=[1]
n=36 p=2 a=[1,2] b=[2]
n=18 p=2 a=[1,2,4] b=[4]
 n=9 p=2 a=[1,2,4,8] b=[8]
 n=9 p=3 a=[1,2,4,8] b=[1,2,4,8]
 n=3 p=3 a=[1,2,4,8,3,6,12,24] b=[3,6,12,24]
 n=1 p=3 a=[1,2,4,8,3,6,12,24,9,18,36,72] b=[9,18,36,72]


答:
php, 135 bytes

```<code><?php for(;$i<$n=$argv[1];){$s=str_pad('',$n);$s[$i?:0]=chr(rand(33,126));$s[$n-++$i]=chr(rand(33,126));echo str_ireplace(Y,X,"$s
");}
</code>```

Fairly straightforward approach uses str_pad to make a string of spaces of the required length, replaces the necessary characters with random ones then replaces any Ys (case insensitive) with Xs and echos the line.
Generates 2n+3 notices but, as usual, that's fine.

Title: Do X without Y

Body:
php, 135 bytes

<?php for(;$i<$n=$argv[1];){$s=str_pad('',$n);$s[$i?:0]=chr(rand(33,126));$s[$n-++$i]=chr(rand(33,126));echo str_ireplace(Y,X,"$s
");}

Fairly straightforward approach uses str_pad to make a string of spaces of the required length, replaces the necessary characters with random ones then replaces any Ys (case insensitive) with Xs and echos the line.
Generates 2n+3 notices but, as usual, that's fine.


问:
Modulo code golf
Write a function f(a,b) that returns a mod b given the constraints:

you can't use division in any way

f(a,b) is always positive, eg: f(-1,5) = 4

it performs reasonably well for values of ~10e50 for a and b

Title: Modulo code golf

Body:
Haskell <s>36</s> 35 (<s>34?</s> 33)

If I may call the function ? instead:

1234567890123456789012345678901234
a?b|a<0=(a+b)?b|a>b=(a-b)?b|0<1=a

Elseway:

f a b|a<0=f(a+b)b|a>b=f(a-b)b|0<1=a

ContentLicense: CC BY-SA 2.5


问:
Removing unique elements from string
I came upon this question, because it seems to be very common use-case to find unique characters in string. But what if we want to get rid of them?

Input contains only lower case alphabets. Only letters from a to z are used. Input length may be from 1 to 1000 characters.

Example:

input: helloworld

output: llool

Objective: Shortest code wins

Language: Any of the top 20 of TIOBE languages

答:
Mathematica 72 63

Ok, Mathematica isn't among the top 20 languages, but I decided to join the party anyway.

x is the input string.

```<code>"" <> Select[y = Characters@x, ! MemberQ[Cases[Tally@y, {a_, 1} :> a], #] &]
</code>```

Title: Removing unique elements from string

Body:
Mathematica 72 63

Ok, Mathematica isn't among the top 20 languages, but I decided to join the party anyway.

x is the input string.

"" <> Select[y = Characters@x, ! MemberQ[Cases[Tally@y, {a_, 1} :> a], #] &]


答:
Emacs Lisp, 269 bytes

```<code>(defalias'n'number-sequence)(set'c(mapcar'string(delq 89(delq 121(n 33 126)))))(defun c()(nth(random(length c))c))(defun s(x)" ")(defun x(l)(let((s(mapcar's(n 1 l))))(dotimes(i l)(set'x(copy-seq s))(setf(nth i x)(c)(nth(-(length x)i 1)x)(c))(message(apply'concat x)))))
</code>```

Ungolfed and slightly modified:

```<code>(defvar c (mapcar 'string (delq 89 (delq 121 (number-sequence 33 126)))))
(defun c() (nth (random (length c)) c))
(defun s(x)" ")
(defun x(l)
  (let ((s(mapcar's(n 1 l)))
        x)
    (dotimes (i l)
      (set 'x (copy-seq s))
      (setf (nth i x) (c)
            (nth (- (length x) i 1) x) (c))
      (message (apply 'concat x)))))
</code>```

Title: Do X without Y

Body:
Emacs Lisp, 269 bytes

(defalias'n'number-sequence)(set'c(mapcar'string(delq 89(delq 121(n 33 126)))))(defun c()(nth(random(length c))c))(defun s(x)" ")(defun x(l)(let((s(mapcar's(n 1 l))))(dotimes(i l)(set'x(copy-seq s))(setf(nth i x)(c)(nth(-(length x)i 1)x)(c))(message(apply'concat x)))))

Ungolfed and slightly modified:

(defvar c (mapcar 'string (delq 89 (delq 121 (number-sequence 33 126)))))
(defun c() (nth (random (length c)) c))
(defun s(x)" ")
(defun x(l)
  (let ((s(mapcar's(n 1 l)))
        x)
    (dotimes (i l)
      (set 'x (copy-seq s))
      (setf (nth i x) (c)
            (nth (- (length x) i 1) x) (c))
      (message (apply 'concat x)))))


答:
Dyalog APL, 34 bytes

```<code>{(0 1=⊂b/¯1⌽b){⍺\⍺/⍵}¨⊂⍵/⍨b←⍵≠'∧'}
</code>```

It returns a two-element vector with the two lines

Sample run (the uparrow in front is to format the two-el. vector for human consumption):

```<code>      ↑{(0 1=⊂b/¯1⌽b){⍺\⍺/⍵}¨⊂⍵/⍨b←⍵≠'∧'}'abc∧d+ef∧g + hijk∧l - M∧NO∧P (Ag∧+)'
   d   g       l    N P    +
abc +ef  + hijk  - M O  (Ag )
</code>```

Title: Convert exponents into ASCII art

Body:
Dyalog APL, 34 bytes

{(0 1=⊂b/¯1⌽b){⍺\⍺/⍵}¨⊂⍵/⍨b←⍵≠'∧'}

It returns a two-element vector with the two lines

Sample run (the uparrow in front is to format the two-el. vector for human consumption):

      ↑{(0 1=⊂b/¯1⌽b){⍺\⍺/⍵}¨⊂⍵/⍨b←⍵≠'∧'}'abc∧d+ef∧g + hijk∧l - M∧NO∧P (Ag∧+)'
   d   g       l    N P    +
abc +ef  + hijk  - M O  (Ag )


答:
Retina, 16 bytes

```<code>S`^
\^(.)
♥[A$1↓
</code>```

A port of my Perl answer, pointed out by Martin Ender. Replace ♥ by a raw ESC byte (0x1b) and ↓ with a vertical tab (0x0b).

Title: Convert exponents into ASCII art

Body:
Retina, 16 bytes

S`^
\^(.)
♥[A$1↓

A port of my Perl answer, pointed out by Martin Ender. Replace ♥ by a raw ESC byte (0x1b) and ↓ with a vertical tab (0x0b).


问:
Legalize Reversed Date
Input:

A Date (containing dd, MM and yyyy). A date-object, or three separate integers are also valid as input.

Output:

Each part (dd, MM and yyyy) individually reverted and than rounded to the nearest valid date.

For example (in the format dd-MM-yyyy):

21-10-2016 becomes 12-01-6102

Challenge rules:

Only dd, MM, yyyy is valid, but the order and which separate-symbols you use is your own choice.

So these are some valid format examples: dd-MM-yyyy; MM/dd/yyyy; yyyy MM dd; ddMMyyyy, etc.

And these are some invalid format examples: dd MMM yyyy; dd-MM-'yy; etc.

You can also choose to just input a Date-object if your language supports it or three separate integer parameters, instead of the string representing a date.

Please state which date-format you've used! (And the input and output must be in the same format.) It is also allowed to output a Date-object, as long as it can handle all test cases and the challenge rule below.

The Julian to Gregorian Calendar transition is ignored for this challenge. So 1582 is just a valid reversed year for 2851.

See Challenge info / tips for all valid years, months and days.

Since you cannot have February as reversed of any other month, you don't have to worry about leap years.

All reversed years, months and days:

The year can always be reversed without a problem, reaching from 0001 (reversed of 1000) to 9999 (remains 9999). (So 0000 isn't a valid input, and there are also no test cases for it.)

The only months you'll have reversed are: January (reversed from October / 10); October (reversed from January / 01); November (remains November / 11); and December (reversed from every other month / 02-09, 12).

The only days you'll have reversed are: 01 (reversed from 10), 02 (reversed from 20), 03 (reversed from 30), 10 (reversed from 01), 11 (remains 11), 12 (reversed from 21), 13 (reversed from 31), 20 (reversed from 02), 21 (reversed from 12), 22 (remains 22), 30 (reversed from 03 or the same as 31 for November!), 31 (reversed from 04-09 / 13-19 / 23-29).

General rules:

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

Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.

Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return statements/output, full programs. Your call.

Default Loopholes are forbidden.

If possible, please add a link with a test for your code.

Also, please add an explanation if necessary.

Test cases (dd-MM-yyyy as format):

```<code>21-07-2016   ->   12-12-6102
12-11-1991   ->   21-11-1991
01-01-2000   ->   10-10-0002
27-08-1875   ->   31-12-5781
18-12-2010   ->   31-12-0102
13-01-1981   ->   31-10-1891
04-11-1671   ->   30-11-1761  // Semi-tricky case, since November has 30 days
28-11-2036   ->   30-11-6302  // Semi-tricky case, since November has 30 days
14-06-1855   ->   31-12-5581
30-10-9999   ->   03-01-9999
01-01-2851   ->   10-10-1582
</code>```

答:
Dyalog APL, <s>32</s> 33 bytes

```<code>⍕¨{⍵-3↑31 11≡2↑⍵}31 12 1E4⌊⍎∊⍕⌽¨⎕
</code>```

I/O is list of three strings ('dd' 'mm' 'yyyy').

TryAPL, but note that ⎕ (prompt for input) has been replaced with ⍵ and the entire line enclosed in {...} to enable online testing, and ⍎ (execute expression) has been replaced with 2⊃⎕VFI (verify and fix input) because execution of arbitrary code is blocked.

Title: Legalize Reversed Date

Body:
Dyalog APL, <s>32</s> 33 bytes

⍕¨{⍵-3↑31 11≡2↑⍵}31 12 1E4⌊⍎∊⍕⌽¨⎕

I/O is list of three strings ('dd' 'mm' 'yyyy').

<a href="http://tryapl.org/?a=%u2191%7B%u2355%A8%7B%u2375-3%u219131%2011%u22612%u2191%u2375%7D31%2012%209999%u230A2%u2283%u2395VFI%u220A%u2355%u233D%A8%u2375%7D%A8%28%2721%27%20%2707%27%20%272016%27%29%28%2712%27%20%2711%27%20%271991%27%29%28%2701%27%20%2701%27%20%272000%27%29%28%2727%27%20%2708%27%20%271875%27%29%28%2718%27%20%2712%27%20%272010%27%29%28%2713%27%20%2701%27%20%271981%27%29%28%2704%27%20%2711%27%20%271671%27%29%28%2728%27%20%2711%27%20%272036%27%29%28%2714%27%20%2706%27%20%271855%27%29%28%2730%27%20%2710%27%20%279999%27%29%28%2701%27%20%2701%27%20%272851%27%29&run" rel="nofollow noreferrer">TryAPL, but note that ⎕ (prompt for input) has been replaced with ⍵ and the entire line enclosed in {...} to enable online testing, and ⍎ (execute expression) has been replaced with 2⊃⎕VFI (verify and fix input) because execution of arbitrary code is blocked.


问:
Add two numbers
Input: Two integers. Preferably decimal integers, but other forms of numbers can be used. These can be given to the code in standard input, as arguments to the program or function, or as a list.

Output: Their sum. Use the same format for output integers as input integers. For example, the input 5 16 would lead to the output 21.

Restrictions: No standard loopholes please. This is code-golf, answer in lowest amount of bytes wins.

Notes: This should be fairly trivial, however I'm interested to see how it can be implemented. The answer can be a complete program or a function, but please identify which one it is.

Test cases:

```<code>1 2 -> 3
14 15 -> 29
7 9 -> 16
-1 8 -> 7
8 -9 -> -1
-8 -9 -> -17
</code>```

Or as CSV:

```<code>a,b,c
1,2,3
14,15,29
7,9,16
-1,8,7
8,-9,-1
-8,-9,-17
</code>```

Leaderboard

var QUESTION_ID=84260,OVERRIDE_USER=8478;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

```

Title: Add two numbers

Body:
Gema, 13 characters

* *=@add{*;*}

Sample run:

bash-4.3$ gema '* *=@add{*;*}' <<< '5 16'
21


答:
jq, 3 characters

```<code>add
</code>```

Sample run:

```<code>bash-4.3$ jq 'add' <<< '[5,16]'
21
</code>```

On-line test

Title: Add two numbers

Body:
Input: Two integers. Preferably decimal integers, but other forms of numbers can be used. These can be given to the code in standard input, as arguments to the program or function, or as a list.

Output: Their sum. Use the same format for output integers as input integers. For example, the input 5 16 would lead to the output 21.

Restrictions: No standard loopholes please. This is code-golf, answer in lowest amount of bytes wins.

Notes: This should be fairly trivial, however I'm interested to see how it can be implemented. The answer can be a complete program or a function, but please identify which one it is.

Test cases:

```<code>1 2 -> 3
14 15 -> 29
7 9 -> 16
-1 8 -> 7
8 -9 -> -1
-8 -9 -> -17
</code>```

Or as CSV:

```<code>a,b,c
1,2,3
14,15,29
7,9,16
-1,8,7
8,-9,-1
-8,-9,-17
</code>```

Leaderboard

var QUESTION_ID=84260,OVERRIDE_USER=8478;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:
jq, 3 characters

add

Sample run:

bash-4.3$ jq 'add' <<< '[5,16]'
21

On-line test


答:
Pyth, <s>55</s> <s>53</s> <s>46</s> <s>43</s> 41 bytes

```
<s>APJ_Mczd=HhS,12sH=GhS,sGC@."❤❤ó»î"H%"%02d %02d %s"[GHeJ</s>
<s>APJ_Mczd=hS,12sH=hS,sGC@."❤❤ó»î"H%"%02d %02d %s"[GHeJ</s>
<s>APJ_Mcz\-%"%02d %02d %s"[hS,sGx31q11sHhS,12sHeJ</s>
<s>APJ_Mczdjd[>2+\0hS,sGx31q11sH>2+\0hS,12sHeJ</s>
APJ_Mczdjd.[L\02[`hS,sGx31q11sH`hS,12sHeJ
```

where ❤❤ were two unprintables, respectively U+001C and U+001F.

Test suite.

Title: Legalize Reversed Date

Body:
Input:

A Date (containing dd, MM and yyyy). A date-object, or three separate integers are also valid as input.

Output:

Each part (dd, MM and yyyy) individually reverted and than rounded to the nearest valid date.

For example (in the format dd-MM-yyyy):

21-10-2016 becomes 12-01-6102

Challenge rules:

Only dd, MM, yyyy is valid, but the order and which separate-symbols you use is your own choice.

So these are some valid format examples: dd-MM-yyyy; MM/dd/yyyy; yyyy MM dd; ddMMyyyy, etc.

And these are some invalid format examples: dd MMM yyyy; dd-MM-'yy; etc.

You can also choose to just input a Date-object if your language supports it or three separate integer parameters, instead of the string representing a date.

Please state which date-format you've used! (And the input and output must be in the same format.) It is also allowed to output a Date-object, as long as it can handle all test cases and the challenge rule below.

The Julian to Gregorian Calendar transition is ignored for this challenge. So 1582 is just a valid reversed year for 2851.

See Challenge info / tips for all valid years, months and days.

Since you cannot have February as reversed of any other month, you don't have to worry about leap years.

All reversed years, months and days:

The year can always be reversed without a problem, reaching from 0001 (reversed of 1000) to 9999 (remains 9999). (So 0000 isn't a valid input, and there are also no test cases for it.)

The only months you'll have reversed are: January (reversed from October / 10); October (reversed from January / 01); November (remains November / 11); and December (reversed from every other month / 02-09, 12).

The only days you'll have reversed are: 01 (reversed from 10), 02 (reversed from 20), 03 (reversed from 30), 10 (reversed from 01), 11 (remains 11), 12 (reversed from 21), 13 (reversed from 31), 20 (reversed from 02), 21 (reversed from 12), 22 (remains 22), 30 (reversed from 03 or the same as 31 for November!), 31 (reversed from 04-09 / 13-19 / 23-29).

General rules:

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

Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.

Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return statements/output, full programs. Your call.

Default Loopholes are forbidden.

If possible, please add a link with a test for your code.

Also, please add an explanation if necessary.

Test cases (dd-MM-yyyy as format):

```<code>21-07-2016   ->   12-12-6102
12-11-1991   ->   21-11-1991
01-01-2000   ->   10-10-0002
27-08-1875   ->   31-12-5781
18-12-2010   ->   31-12-0102
13-01-1981   ->   31-10-1891
04-11-1671   ->   30-11-1761  // Semi-tricky case, since November has 30 days
28-11-2036   ->   30-11-6302  // Semi-tricky case, since November has 30 days
14-06-1855   ->   31-12-5581
30-10-9999   ->   03-01-9999
01-01-2851   ->   10-10-1582
</code>```

Body:
Pyth, <s>55</s> <s>53</s> <s>46</s> <s>43</s> 41 bytes

<s>APJ_Mczd=HhS,12sH=GhS,sGC@."❤❤ó»î"H%"%02d %02d %s"[GHeJ</s>
<s>APJ_Mczd=hS,12sH=hS,sGC@."❤❤ó»î"H%"%02d %02d %s"[GHeJ</s>
<s>APJ_Mcz\-%"%02d %02d %s"[hS,sGx31q11sHhS,12sHeJ</s>
<s>APJ_Mczdjd[>2+\0hS,sGx31q11sH>2+\0hS,12sHeJ</s>
APJ_Mczdjd.[L\02[`hS,sGx31q11sH`hS,12sHeJ

where ❤❤ were two unprintables, respectively U+001C and U+001F.

Test suite.


答:
CJam, 24 bytes

```<code>qS/Wf%[_1=:=31^sCs].e<S*
</code>```

I/O format is dd mm yyyy.

Try it online!

Same byte count, I/O format mm dd yyyy:

```<code>qS/Wf%_0=:=1231^s2/.e<S*
</code>```

Try it online!

Explanation

```<code>qS/     e# Read input, split around spaces.
Wf%     e# Reverse each component.
[       e# Set marker for new list.
  _1=   e#   Duplicate reversed strings, extract reversed month.
  :=    e#   Check for equality of the characters. This gives 1 for
        e#   November (11) and 0 for everything else.
  31^   e#   XOR the result with 31, giving 30 for November and 31
        e#   for everything else.
  s     e#   Convert the result to a string, "30"/"31".
  Cs    e#   Push 12, convert to string, "12".
]       e# Wrap "30"/"31" and "12" in a list.
.e<     e# Element-wise minimum. This clamps the day and month to their
        e# respective maxima.
S*      e# Join the result with spaces.
</code>```

The other version works similarly, except that we start from the integer 1230 or 1231 before converting it to ["12" "30"]  or ["12" "31"].

Title: Legalize Reversed Date

Body:
CJam, 24 bytes

qS/Wf%[_1=:=31^sCs].e<S*

I/O format is dd mm yyyy.

Try it online!

Same byte count, I/O format mm dd yyyy:

qS/Wf%_0=:=1231^s2/.e<S*

Try it online!

Explanation

qS/     e# Read input, split around spaces.
Wf%     e# Reverse each component.
[       e# Set marker for new list.
  _1=   e#   Duplicate reversed strings, extract reversed month.
  :=    e#   Check for equality of the characters. This gives 1 for
        e#   November (11) and 0 for everything else.
  31^   e#   XOR the result with 31, giving 30 for November and 31
        e#   for everything else.
  s     e#   Convert the result to a string, "30"/"31".
  Cs    e#   Push 12, convert to string, "12".
]       e# Wrap "30"/"31" and "12" in a list.
.e<     e# Element-wise minimum. This clamps the day and month to their
        e# respective maxima.
S*      e# Join the result with spaces.

The other version works similarly, except that we start from the integer 1230 or 1231 before converting it to ["12" "30"]  or ["12" "31"].


答:
Python 2.7 (<s>52</s> 51), <s>Python 3 (52)</s>

I didn't expect it to be so short.

2.7: a=raw_input();print filter(lambda x:a.count(x)>1,a)

<s>3.0: a=input();print''.join(i for i in a if a.count(x)>1)</s>

raw_input(): store input as a string (input() = eval(raw_input()))

(Python 3.0: input() has been turned into raw_input())

filter(lambda x:a.count(x)>1,a):
Filter through all characters within a if they are found in a more than once (a.count(x)>1).

Title: Removing unique elements from string

Body:
I came upon this question, because it seems to be very common use-case to find unique characters in string. But what if we want to get rid of them?

Input contains only lower case alphabets. Only letters from a to z are used. Input length may be from 1 to 1000 characters.

Example:

input: helloworld

output: llool

Objective: Shortest code wins

Language: Any of the top 20 of TIOBE languages


答:
Convex, 23 bytes

Byte count assumes CP-1252 encoding.

```<code>qS/Wf%_1=:=31^sCs¶.e<S*
</code>```

I/O format is dd mm yyyy.

Try it online!

This is a direct port of my CJam answer. Convex is heavily based on CJam, and therefore the only difference is the use of Convex's ¶ operator which wraps the top two stack elements in a list, saving a byte over [...].

Title: Legalize Reversed Date

Body:
Convex, 23 bytes

Byte count assumes CP-1252 encoding.

qS/Wf%_1=:=31^sCs¶.e<S*

I/O format is dd mm yyyy.

Try it online!

This is a direct port of my CJam answer. Convex is heavily based on CJam, and therefore the only difference is the use of Convex's ¶ operator which wraps the top two stack elements in a list, saving a byte over [...].


答:
golflua, 12 characters

```<code>\f(a,b)~a+b$
</code>```

Sample run:

```<code>> \f(a,b)~a+b$
> w(f(5,16))
21
</code>```

Title: Add two numbers

Body:
golflua, 12 characters

\f(a,b)~a+b$

Sample run:

> \f(a,b)~a+b$
> w(f(5,16))
21


答:
MoonScript, 10 characters

```<code>(a,b)->a+b
</code>```

Sample run:

```<code>bash-4.3$ .luarocks/moon <(echo 'print ((a,b)->a+b)(5,16)')
21
</code>```

Title: Add two numbers

Body:
MoonScript, 10 characters

(a,b)->a+b

Sample run:

bash-4.3$ .luarocks/moon <(echo 'print ((a,b)->a+b)(5,16)')
21


答:
Pascal (FPC), 128 125 138 bytes

One recursive procedure takes care of everything. Call with m(9,9).

```<code>procedure m(i,j:int8);begin if i<1then Exit;if i=j then begin m(i-1,j-1);writeln;end;m(i-1,j);write(i,'x',j,'=',i*j,' ':2-i*j div 10);end;
</code>```

Ungolfed:

```<code>procedure m(i, j: int8);
begin
  if i<1 then
    Exit;
  if i=j then
  begin
    m(i-1, j-1);
    writeln;
  end;
  m(i-1, j);
  write(i,'x',j,'=',i*j,' ':2-i*j div 10);
end;
</code>```

The reason for the byte count going up: the output was not aligned correctly. It is fixed now.

Try it online!

Title: Print this Multiplication Table

Body:
Write shortest code to print the following Multiplication Table:</p>

```<code>1×1=1
1×2=2  2×2=4
1×3=3  2×3=6  3×3=9
1×4=4  2×4=8  3×4=12 4×4=16
1×5=5  2×5=10 3×5=15 4×5=20 5×5=25
1×6=6  2×6=12 3×6=18 4×6=24 5×6=30 6×6=36
1×7=7  2×7=14 3×7=21 4×7=28 5×7=35 6×7=42 7×7=49
1×8=8  2×8=16 3×8=24 4×8=32 5×8=40 6×8=48 7×8=56 8×8=64
1×9=9  2×9=18 3×9=27 4×9=36 5×9=45 6×9=54 7×9=63 8×9=72 9×9=81
</code>```

Body:
Pascal (FPC), 128 125 138 bytes

One recursive procedure takes care of everything. Call with m(9,9).

procedure m(i,j:int8);begin if i<1then Exit;if i=j then begin m(i-1,j-1);writeln;end;m(i-1,j);write(i,'x',j,'=',i*j,' ':2-i*j div 10);end;

Ungolfed:

procedure m(i, j: int8);
begin
  if i<1 then
    Exit;
  if i=j then
  begin
    m(i-1, j-1);
    writeln;
  end;
  m(i-1, j);
  write(i,'x',j,'=',i*j,' ':2-i*j div 10);
end;

The reason for the byte count going up: the output was not aligned correctly. It is fixed now.

Try it online!


问:
Interquartile Mean

Task

Given (by any means) a sorted floating point dataset, return (by any means and within 1‰ of the correct value) the interquartile mean.

One possible algorithm

Discard the lowest and highest quarters of the data points.

Calculate the average (sum divided by count) of the remaining data points.

Note: If the dataset size is not evenly split-able in four, you will have to weigh the datapoints that are shared by sub-sets. See Example evaluation 2 below.

Example evaluation 1

Given {1, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 38}

Data count is 12, so we remove lowest and highest 3 datapoints:
{<s>1, 3, 4,</s> 5, 6, 6, 7, 7, 8, <s>8, 9, 38</s>}

Average of the remaining 6 datapoints:
(5 + 6 + 6 + 7 + 7 + 8) / 6 = 6.5

Example evaluation 2

Given {1, 3, 5, 7, 9, 11, 13, 15, 17}

Count is 9, so each quarter has 2¼ datapoints:
{<s>1, 2, (0.25×5),</s> (0.75×5), 7, 9, 11, (0.75×13), <s>(0.25×13), 15, 17</s>}

Average of the remaining 4.5 datapoints:
(0.75×5 + 7 + 9 + 11 + 0.75×13) / 4.5 = 9

答:
R, <s>17</s> 11 bytes

```<code>mean(n,0.25)
</code>```

Assuming n is the input vector in the standard R form n=c(1, 2, 3, ...).

This is in no way surprising since R can be considered “THE language for  statistical computing” and has many statistical built-ins.

UPDATE. Saved 6 bytes thanks to rturnbull because trim is the first optional argument by default!

Test cases:

```<code>a <- c(1, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 38)
b <- c(1, 3, 5, 7, 9, 11, 13, 15, 17)
mean(a,trim=0.25) # Returns 6.5
mean(b,trim=0.25) # Returns 9
</code>```

Title: Interquartile Mean

Body:
R, <s>17</s> 11 bytes

mean(n,0.25)

Assuming n is the input vector in the standard R form n=c(1, 2, 3, ...).

This is in no way surprising since R can be considered “THE language for  statistical computing” and has many statistical built-ins.

UPDATE. Saved 6 bytes thanks to rturnbull because trim is the first optional argument by default!

Test cases:

a <- c(1, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 38)
b <- c(1, 3, 5, 7, 9, 11, 13, 15, 17)
mean(a,trim=0.25) # Returns 6.5
mean(b,trim=0.25) # Returns 9


Title: Print this Multiplication Table

Body:
golflua, <s>54</s> 49 characters

~@i=1,9~@j=1,i I.w(S.q(i.."x%d=%-3d",j,i*j))$w()$

Sample run:

bash-4.3$ golflua -e '~@i=1,9~@j=1,i I.w(S.q(i.."x%d=%-3d",j,i*j))$w()$'
1x1=1
2x1=2  2x2=4
3x1=3  3x2=6  3x3=9
4x1=4  4x2=8  4x3=12 4x4=16
5x1=5  5x2=10 5x3=15 5x4=20 5x5=25
6x1=6  6x2=12 6x3=18 6x4=24 6x5=30 6x6=36
7x1=7  7x2=14 7x3=21 7x4=28 7x5=35 7x6=42 7x7=49
8x1=8  8x2=16 8x3=24 8x4=32 8x5=40 8x6=48 8x7=56 8x8=64
9x1=9  9x2=18 9x3=27 9x4=36 9x5=45 9x6=54 9x7=63 9x8=72 9x9=81