答:
Haskell, 52

```<code>Import Data.Ratio
f n=denominator$sum[1%k|k<-[1..n]]
</code>```

If the file is loaded into GHCI, f can be used as a function.

Title: Denominator of harmonic series

Body:
Earlier, we did the pseudofactorial of a number, which is the LCM of the numbers from 1 to n.

It would be useful in adding fractions together.

However, we find that the denominator of 1/1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6 is 20 instead of the pseudofactorial of 6, which is 60.

Your task is to find the denominator of 1/1 + 1/2 + ... + 1/n given positive integer n.

Testcases

```<code> n result
 1 1
 2 2
 3 6
 4 12
 5 60
 6 20
 7 140
 8 280
 9 2520
10 2520
11 27720
12 27720
13 360360
14 360360
15 360360
16 720720
17 12252240
18 4084080
19 77597520
20 15519504
21 5173168
22 5173168
23 118982864
24 356948592
25 8923714800
26 8923714800
27 80313433200
28 80313433200
29 2329089562800
30 2329089562800
</code>```

List for n from 1 to 200.

List for n from 1 to 1000.

List for n from 1 to 10000.

References

Obligatory OEIS A002805 (thanks to @FryAmTheEggman)

Leaderboard

var QUESTION_ID=82815,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:
Haskell, 52

Import Data.Ratio
f n=denominator$sum[1%k|k<-[1..n]]

If the file is loaded into GHCI, f can be used as a function.


问:
Are the two sets equal
{}is the empty set. You may use () or [] if you choose.

We aren't going to rigorously define "set", but sets all satisfy the following properties:

Sets follow the usual mathematical structure. Here are some important points:

Sets are not ordered.

No set contains itself.

Elements are either in a set or not, this is boolean. Therefore set elements cannot have multiplicities (i.e. an element cannot be in a set multiple times.)

Elements of a set are also sets and {} is the only primitive element.

Task

Write a program/function that determines whether two sets are equal.

Input

Two valid sets via stdin or function argument.  The input format is loose within reason.

Some valid inputs are:

```<code>{} {{}}
{{},{{}}} {{{{{},{{}}}}}}
{{},{{},{{}}}} {{{},{{}}},{{{{{},{{}}}}}}}
</code>```

Invalid inputs:

```<code>{{} {}              Brackets will always be balanced.
{{},{}} {}          Set contains the same element twice
</code>```

Output

A truthy value if the inputs are equal, falsy otherwise.

Test cases

Your submission should answer correctly for all valid inputs, not just for the test cases. These may be updated at any point.

Truthy:

```<code>{} {}
{{},{{}}} {{{}},{}}
{{},{{},{{{}},{}}}} {{{{},{{}}},{}},{}}
</code>```

Falsy:

```<code>{} {{}}
{{},{{},{{{}},{}}}} {{{{}}},{},{{}}}
{{},{{}},{{{}}},{{},{{}}}} {}
</code>```

Scoring

code-golf

Additional Rules

An additional rule has been added banning unordered iterable types altogether. They are too common and trivialize this challenge far too much. Feel free to leave answers that violate this in place, please just make an indication that they were made before the rule change.

答:
Julia, <s>36</s> <s>35</s> 32 bytes

u*v=(sort(u.*v)...)
s%t=s*s==t*t
```

Input is a nested array either either the (deprecated) {} syntax or Any[].

Try it online!

ContentLicense: CC BY-SA 3.0

Title: Are the two sets equal

Body:
Julia, <s>36</s> <s>35</s> 32 bytes

u*v=(sort(u.*v)...)
s%t=s*s==t*t

Input is a nested array either either the (deprecated) {} syntax or Any[].

Try it online!


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

```

答:
Javascript ES6, 124 bytes

```<code>a=>0
Math.min
parseInt
a=>a
a=>b=>a<b
a=>b=>b
a=>b=>a^b
Math.max
a=>b=>~a&~b
a=>b=>a==b
a=>b=>~b
Math.pow
a=>~a
a=>b=>a<=b
a=>b=>~a|~b
a=>1
</code>```

I seriously hate lambdas right now.

Body:
Javascript ES6, 124 bytes

a=>0
Math.min
parseInt
a=>a
a=>b=>a<b
a=>b=>b
a=>b=>a^b
Math.max
a=>b=>~a&~b
a=>b=>a==b
a=>b=>~b
Math.pow
a=>~a
a=>b=>a<=b
a=>b=>~a|~b
a=>1

I seriously hate lambdas right now.


答:
MATL, <s>34</s> 23 bytes

I hope I got the order all right! Zero is falsey, non-zero is truthy. Each function takes two implicit inputs (although it may ignore some inputs). The first input is A, and the second is B. You can input 0/1 for true/false, or T/F.

Here is a TryItOnline example for test case 3.

Saved 4 bytes by using * for and, and another 4 by using >/< instead of ~wY&/w~Y& after I saw Dennis' answer!

```<code>1.  0,0,0,0 0 (ignores input, just returns a zero)
2.  0,0,0,1 * (and)
3.  0,0,1,0 < (not-A and B)
4.  0,0,1,1 D (A)
5.  0,1,0,0 > (not-B and A)
6.  0,1,0,1 xD (discard A, display B)
7.  0,1,1,0 Y~ (xor)
8.  0,1,1,1 + (or)
9.  1,0,0,0 +~ (not-or)
10. 1,0,0,1 = (A=B)
11. 1,0,1,0 x~ (not-B)
12. 1,0,1,1 <~ (not-B or A)
13. 1,1,0,0 ~ (not-A)
14. 1,1,0,1 ~+ (not-A or B)
15. 1,1,1,0 *~ (not(A and B))
16. 1,1,1,1 1 (just returns 1)
</code>```

Title: Golf all the 16 logic gates with 2 inputs and 1 output!

Body:
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:
MATL, <s>34</s> 23 bytes

I hope I got the order all right! Zero is falsey, non-zero is truthy. Each function takes two implicit inputs (although it may ignore some inputs). The first input is A, and the second is B. You can input 0/1 for true/false, or T/F.

Here is a TryItOnline example for test case 3.

Saved 4 bytes by using * for and, and another 4 by using >/< instead of ~wY&/w~Y& after I saw Dennis' answer!

1.  0,0,0,0 0 (ignores input, just returns a zero)
2.  0,0,0,1 * (and)
3.  0,0,1,0 < (not-A and B)
4.  0,0,1,1 D (A)
5.  0,1,0,0 > (not-B and A)
6.  0,1,0,1 xD (discard A, display B)
7.  0,1,1,0 Y~ (xor)
8.  0,1,1,1 + (or)
9.  1,0,0,0 +~ (not-or)
10. 1,0,0,1 = (A=B)
11. 1,0,1,0 x~ (not-B)
12. 1,0,1,1 <~ (not-B or A)
13. 1,1,0,0 ~ (not-A)
14. 1,1,0,1 ~+ (not-A or B)
15. 1,1,1,0 *~ (not(A and B))
16. 1,1,1,1 1 (just returns 1)


答:
Jelly, 19 bytes

```<code>0 0 0 0 ¤  1 byte  Empty niladic chain. Returns default argument 0.
0 0 0 1 &  1 byte  Bitwise AND.
0 0 1 0 >  1 byte  Greater than.
0 0 1 1    0 bytes Empty link. Returns left argument.
0 1 0 0 <  1 byte  Less than.
0 1 0 1 ị  1 byte  At-index (x,y -> [y][x]). Returns right argument.
0 1 1 0 ^  1 byte  Bitwise XOR.
0 1 1 1 |  1 byte  Bitwise OR.
1 0 0 0 |¬ 2 byte  Logical NOT of bitwise OR.
1 0 0 1 =  1 byte  Equals.
1 0 1 0 ¬} 2 bytes Logical NOT of right argument.
1 0 1 1 *  1 byte  Exponentiation.
1 1 0 0 ¬  1 byte  Logical NOT of left argument.
1 1 0 1 >¬ 2 bytes Logical NOT of greater than.
1 1 1 0 &¬ 2 bytes Logical NOT of bitwise AND.
1 1 1 1 !  1 byte  Factorial.
</code>```

Try it online!

Body:
Jelly, 19 bytes

0 0 0 0 ¤  1 byte  Empty niladic chain. Returns default argument 0.
0 0 0 1 &  1 byte  Bitwise AND.
0 0 1 0 >  1 byte  Greater than.
0 0 1 1    0 bytes Empty link. Returns left argument.
0 1 0 0 <  1 byte  Less than.
0 1 0 1 ị  1 byte  At-index (x,y -> [y][x]). Returns right argument.
0 1 1 0 ^  1 byte  Bitwise XOR.
0 1 1 1 |  1 byte  Bitwise OR.
1 0 0 0 |¬ 2 byte  Logical NOT of bitwise OR.
1 0 0 1 =  1 byte  Equals.
1 0 1 0 ¬} 2 bytes Logical NOT of right argument.
1 0 1 1 *  1 byte  Exponentiation.
1 1 0 0 ¬  1 byte  Logical NOT of left argument.
1 1 0 1 >¬ 2 bytes Logical NOT of greater than.
1 1 1 0 &¬ 2 bytes Logical NOT of bitwise AND.
1 1 1 1 !  1 byte  Factorial.

Try it online!


问:
Find operations required to get result
So task is simple, given array of numbers and result, you need to find what operations you need to use on numbers from array , to obtain requested result.

Let's make it simple for start, and allow only basic operations such as: addition, subtraction, multiplication and division.

Example:

```<code>Input  : [5,5,5,5,5] 100
Output : 5*5*5-5*5
</code>```

To give some advantage to languages like Java, request is to implement function, not entire program, and result can be return via parameter or print to console.

Code is scored based on amount bytes, and as it's golf code challenge, lowest score wins.

Another requirment is <s>You can get additional -10 points</s> if for array contains only digids, support solutions where you could construct numbers from following digits.
Ie

```<code>Input  : [1,2,3,4,5] 0
Output : 12-3-4-5
</code>```

Note that, provided outputs are proposed outputs, some cases might have more than one solution. It's up to you will you provide one or more solutions for given task.

EDIT:
Result has to be valid from mathematical point of view, hence division is rational division, not integer, and operation precedence is same as in classical math (first multiplication and division then addition and subtraction).

答:
Python 3, <s>170</s> 155 bytes

```<code>from itertools import*
def f(n,o):print({k for k in[''.join(map(str,sum(j,())))[1:]for j in[zip(x,n)for x in product('+-*/',repeat=len(n))]]if eval(k)==o})
</code>```

Create a generator with all possible orders of the operators, combine that with the numbers, then eval until we get the answer.

https://repl.it/C2F5

Title: Find operations required to get result

Body:
Python 3, <s>170</s> 155 bytes

from itertools import*
def f(n,o):print({k for k in[''.join(map(str,sum(j,())))[1:]for j in[zip(x,n)for x in product('+-*/',repeat=len(n))]]if eval(k)==o})

Create a generator with all possible orders of the operators, combine that with the numbers, then eval until we get the answer.

https://repl.it/C2F5


答:
TI-BASIC, 106 bytes

```<code>0000. 0 (1 byte)
0001.*Prompt A:prod(∟A (7 bytes)
0010. Prompt A,B:A>B (8 bytes)
0011. Prompt A,B:A (6 bytes)
0100. Prompt A,B:A<B (8 bytes)
0101. Prompt A,B:B (6 bytes)
0110. Prompt A,B:A xor B (8 bytes)
0111.*Prompt A:sum(∟A (7 bytes)
1000.*Prompt A:not(sum(∟A (8 bytes)
1001. Prompt A,B:A=B (8 bytes)
1010. Prompt A,B:not(B (7 bytes)
1011. Prompt A,B:A≥B (8 bytes)
1100. Prompt A,B:not(A (7 bytes)
1101. Prompt A,B:A≤B (8 bytes)
1110.*Prompt A:not(prod(∟A (8 bytes)
1111. 1 (1 byte)
</code>```

Starred numbers take input as a list. Answering on my phone again :P

Body:
TI-BASIC, 106 bytes

0000. 0 (1 byte)
0001.*Prompt A:prod(∟A (7 bytes)
0010. Prompt A,B:A>B (8 bytes)
0011. Prompt A,B:A (6 bytes)
0100. Prompt A,B:A<B (8 bytes)
0101. Prompt A,B:B (6 bytes)
0110. Prompt A,B:A xor B (8 bytes)
0111.*Prompt A:sum(∟A (7 bytes)
1000.*Prompt A:not(sum(∟A (8 bytes)
1001. Prompt A,B:A=B (8 bytes)
1010. Prompt A,B:not(B (7 bytes)
1011. Prompt A,B:A≥B (8 bytes)
1100. Prompt A,B:not(A (7 bytes)
1101. Prompt A,B:A≤B (8 bytes)
1110.*Prompt A:not(prod(∟A (8 bytes)
1111. 1 (1 byte)

Starred numbers take input as a list. Answering on my phone again :P


答:
ClojureScript, 88 84 76 74 bytes

nil and false are falsy, all other values are truthy.  Booleans coerce to 0/1 for arithmetic and inequalities.  Functions can take the wrong number of arguments.

```<code>0000   nil?            ; previously: (fn[]nil)
0001   and
0010   <
0011   true?           ; previously: (fn[x]x)
0100   >
0101   (fn[x y]y)
0110   not=
0111   or
1000   #(= 0(+ % %2))
1001   =
1010   #(not %2)
1011   <=
1100   not
1101   >=
1110   #(= 0(* % %2))
1111   /               ; previously: (fn[]4), inc
</code>```

Body:
ClojureScript, 88 84 76 74 bytes

nil and false are falsy, all other values are truthy.  Booleans coerce to 0/1 for arithmetic and inequalities.  Functions can take the wrong number of arguments.

0000   nil?            ; previously: (fn[]nil)
0001   and
0010   <
0011   true?           ; previously: (fn[x]x)
0100   >
0101   (fn[x y]y)
0110   not=
0111   or
1000   #(= 0(+ % %2))
1001   =
1010   #(not %2)
1011   <=
1100   not
1101   >=
1110   #(= 0(* % %2))
1111   /               ; previously: (fn[]4), inc


答:
Brachylog, <s>36</s> 34 bytes

```<code>0000 false              \     Backtrack (always false)
0001 p and q            1.    Unify input and output with 1
0010 p and not q        >.    Input > Output
0011 p                  1     Unify input with 1
0100 not p and q        <.    Input < Output
0101 q                  ,1.   Unify output with 1
0110 xor                '.    Input and output cannot unify
0111 p or q             1;1.  Unify input with 1 or unify output with 1
1000 not p and not q    0.    Unify input and output with 0
1001 eq                 .     Unify input with output
1010 not q              ,0.   Unify output with 0
1011 p or not q         >=.   Input >= Output
1100 not p              0     Unify input with 0
1101 not p or q         <=.   Input <= Output
1110 not p or not q     0;0.  Unify input with 0 or unify output with 0
1111 true                     Empty program (always true)
</code>```

This expects 0 as falsy value and 1 as truthy value. Returns true or false. p is Input and q is Output.

Body:
Brachylog, <s>36</s> 34 bytes

0000 false              \     Backtrack (always false)
0001 p and q            1.    Unify input and output with 1
0010 p and not q        >.    Input > Output
0011 p                  1     Unify input with 1
0100 not p and q        <.    Input < Output
0101 q                  ,1.   Unify output with 1
0110 xor                '.    Input and output cannot unify
0111 p or q             1;1.  Unify input with 1 or unify output with 1
1000 not p and not q    0.    Unify input and output with 0
1001 eq                 .     Unify input with output
1010 not q              ,0.   Unify output with 0
1011 p or not q         >=.   Input >= Output
1100 not p              0     Unify input with 0
1101 not p or q         <=.   Input <= Output
1110 not p or not q     0;0.  Unify input with 0 or unify output with 0
1111 true                     Empty program (always true)

This expects 0 as falsy value and 1 as truthy value. Returns true or false. p is Input and q is Output.


答:
Mathematica, 67 bytes

```<code>0>1&
And
#&&!#2&
#&
!#&&#2&
#2&
Xor
Or
Nor
Xnor
!#2&
#||!#2&
!#&
!#||#2&
Nand
1>0&
</code>```

Each of these evaluates to a function, so you can use them like

```<code>#&&!#2&[True, False]
Xor[True, False]
</code>```

Ah, if only integers were truthy/falsy in Mathematica, those four longer ones could have been shortened considerably.

Body:
Mathematica, 67 bytes

0>1&
And
#&&!#2&
#&
!#&&#2&
#2&
Xor
Or
Nor
Xnor
!#2&
#||!#2&
!#&
!#||#2&
Nand
1>0&

Each of these evaluates to a function, so you can use them like

#&&!#2&[True, False]
Xor[True, False]

Ah, if only integers were truthy/falsy in Mathematica, those four longer ones could have been shortened considerably.


Body:
Julia, <s>65</s> 63 bytes

x\y=0>1
&
>
x\y=x
<
x\y=y
$
|
x\y=!x>y
==
x\y=!y
^
x\y=!x
<=
x\y=!x|!y
x\y=0<1

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


答:
Labyrinth, 85 bytes

Thanks to Sp3000 for saving 2 bytes.

```<code>!@
??&!@
??~&!@
?!@
?~?&!@
??!@
??$!@
??|!@
??|#$!@
??$#$!@
?#?$!@
?#?$|!@
?#$!@
?#$?|!@
??&#$!@
1!@
</code>```

All of these are full programs, reading two integers 0 or 1 from STDIN (using any non-digit separator), and printing the result as 0 or 1 to STDOUT.

Try it online! (Not a test suite, so you'll have to try different programs and inputs manually.)

As for explanations, these are all rather straightforward. All programs are linear, and the commands in use do the following:

```<code>?   Read integer from STDIN and push.
!   Pop integer and write to STDOUT.
@   Terminate program.
&   Bitwise AND of top two stack items.
|   Bitwise OR of top two stack items.
$   Bitwise XOR of top two stack items.
~   Bitwise NOT of top stack item.
#   Push stack depth (which is always 1 when I use it in the above programs).
1   On an empty stack, this pushes 1.
</code>```

Note that I'm using # is always used to combine it with $, i.e. to compute XOR 1, or in other words for logical negation. Only in a few cases was I able to use ~ instead, because the subsequent & discards all the unwanted bits from the resulting -1 or -2.

Body:
Labyrinth, 85 bytes

Thanks to Sp3000 for saving 2 bytes.

!@
??&!@
??~&!@
?!@
?~?&!@
??!@
??$!@
??|!@
??|#$!@
??$#$!@
?#?$!@
?#?$|!@
?#$!@
?#$?|!@
??&#$!@
1!@

All of these are full programs, reading two integers 0 or 1 from STDIN (using any non-digit separator), and printing the result as 0 or 1 to STDOUT.

Try it online! (Not a test suite, so you'll have to try different programs and inputs manually.)

As for explanations, these are all rather straightforward. All programs are linear, and the commands in use do the following:

?   Read integer from STDIN and push.
!   Pop integer and write to STDOUT.
@   Terminate program.
&   Bitwise AND of top two stack items.
|   Bitwise OR of top two stack items.
$   Bitwise XOR of top two stack items.
~   Bitwise NOT of top stack item.
#   Push stack depth (which is always 1 when I use it in the above programs).
1   On an empty stack, this pushes 1.

Note that I'm using # is always used to combine it with $, i.e. to compute XOR 1, or in other words for logical negation. Only in a few cases was I able to use ~ instead, because the subsequent & discards all the unwanted bits from the resulting -1 or -2.


答:
Mathematica, 16 bytes

```<code>Equal@@Sort//@#&
</code>```

An unnamed function which expects a list containing both sets, e.g.

```<code>Equal@@Sort//@#& @ {{{}, {{}}}, {{{}}, {}}}
</code>```

We use //@ (MapAll) to sort the sets at every level and then assert at the results are equal.

Title: Are the two sets equal

Body:
{}is the empty set. You may use () or [] if you choose.

We aren't going to rigorously define "set", but sets all satisfy the following properties:

Sets follow the usual mathematical structure. Here are some important points:

Sets are not ordered.

No set contains itself.

Elements are either in a set or not, this is boolean. Therefore set elements cannot have multiplicities (i.e. an element cannot be in a set multiple times.)

Elements of a set are also sets and {} is the only primitive element.

Task

Write a program/function that determines whether two sets are equal.

Input

Two valid sets via stdin or function argument.  The input format is loose within reason.

Some valid inputs are:

```<code>{} {{}}
{{},{{}}} {{{{{},{{}}}}}}
{{},{{},{{}}}} {{{},{{}}},{{{{{},{{}}}}}}}
</code>```

Invalid inputs:

```<code>{{} {}              Brackets will always be balanced.
{{},{}} {}          Set contains the same element twice
</code>```

Output

A truthy value if the inputs are equal, falsy otherwise.

Test cases

Your submission should answer correctly for all valid inputs, not just for the test cases. These may be updated at any point.

Truthy:

```<code>{} {}
{{},{{}}} {{{}},{}}
{{},{{},{{{}},{}}}} {{{{},{{}}},{}},{}}
</code>```

Falsy:

```<code>{} {{}}
{{},{{},{{{}},{}}}} {{{{}}},{},{{}}}
{{},{{}},{{{}}},{{},{{}}}} {}
</code>```

Scoring

code-golf

Additional Rules

An additional rule has been added banning unordered iterable types altogether. They are too common and trivialize this challenge far too much. Feel free to leave answers that violate this in place, please just make an indication that they were made before the rule change.

Body:
Mathematica, 16 bytes

Equal@@Sort//@#&

An unnamed function which expects a list containing both sets, e.g.

Equal@@Sort//@#& @ {{{}, {{}}}, {{{}}, {}}}

We use //@ (MapAll) to sort the sets at every level and then assert at the results are equal.


问:
Denominator of harmonic series
Earlier, we did the pseudofactorial of a number, which is the LCM of the numbers from 1 to n.

It would be useful in adding fractions together.

However, we find that the denominator of 1/1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6 is 20 instead of the pseudofactorial of 6, which is 60.

Your task is to find the denominator of 1/1 + 1/2 + ... + 1/n given positive integer n.

Testcases

```<code> n result
 1 1
 2 2
 3 6
 4 12
 5 60
 6 20
 7 140
 8 280
 9 2520
10 2520
11 27720
12 27720
13 360360
14 360360
15 360360
16 720720
17 12252240
18 4084080
19 77597520
20 15519504
21 5173168
22 5173168
23 118982864
24 356948592
25 8923714800
26 8923714800
27 80313433200
28 80313433200
29 2329089562800
30 2329089562800
</code>```

List for n from 1 to 200.

List for n from 1 to 1000.

List for n from 1 to 10000.

References

Obligatory OEIS A002805 (thanks to @FryAmTheEggman)

Leaderboard

var QUESTION_ID=82815,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

```

答:
Mathematica, 26 bytes

```<code>Denominator@Tr[1/Range@#]&
</code>```

An unnamed function taking n as input and returning the denominator. Uses the standard trick of abusing Tr (trace) to sum the list of reciprocals.

Title: Denominator of harmonic series

Body:
Mathematica, 26 bytes

Denominator@Tr[1/Range@#]&

An unnamed function taking n as input and returning the denominator. Uses the standard trick of abusing Tr (trace) to sum the list of reciprocals.


答:
Prolog, <s>147</s> 145 bytes

Gained 2 bytes thanks to @SQB

```<code>a(a,a).       % 0000 false
b(1,1).       % 0001 P and Q
c(1,0).       % 0010 P and not Q
d(1,_).       % 0011 P
e(0,1).       % 0100 not P and Q
f(_,1).       % 0101 Q
g(P,Q):-P\=Q. % 0110 P xor Q
h(1,_).       % 0111 P or Q
h(0,1).
i(0,0).       % 1000 not P and not Q
j(P,P).       % 1001 P == Q
k(_,0).       % 1010 not Q
m(P,Q):-P>=Q. % 1011 P or not Q
n(0,_).       % 1100 not P
r(P,Q):-P=<Q. % 1101 not P or Q
s(0,_).       % 1110 not P or not Q
s(1,0).
t(_,_).       % 1111 true
</code>```

Query x(P,Q). with x being the appropriate letter and P and Q set to either 0 or 1.

Returns true or false.

SWISH example including tests - enter runTest. to run.

Body:
Prolog, <s>147</s> 145 bytes

Gained 2 bytes thanks to @SQB

a(a,a).       % 0000 false
b(1,1).       % 0001 P and Q
c(1,0).       % 0010 P and not Q
d(1,_).       % 0011 P
e(0,1).       % 0100 not P and Q
f(_,1).       % 0101 Q
g(P,Q):-P\=Q. % 0110 P xor Q
h(1,_).       % 0111 P or Q
h(0,1).
i(0,0).       % 1000 not P and not Q
j(P,P).       % 1001 P == Q
k(_,0).       % 1010 not Q
m(P,Q):-P>=Q. % 1011 P or not Q
n(0,_).       % 1100 not P
r(P,Q):-P=<Q. % 1101 not P or Q
s(0,_).       % 1110 not P or not Q
s(1,0).
t(_,_).       % 1111 true

Query x(P,Q). with x being the appropriate letter and P and Q set to either 0 or 1.

Returns true or false.

SWISH example including tests - enter runTest. to run.


问:
Double-duty quine: quine!dlroW ,olleH
Write a program that will output its own source code when run, and nothing else. Seems easy, right?

The catch is that when the source code is reversed, your program must output "Hello, World!" exactly, without the quotes.

This is code-golf, so lowest byte count wins.

Edit: Your quine must be a proper quine.

答:
Python 2, 70 bytes

_='_=%r;print _%%_#"dlroW ,olleH"tnirp';print _%_#"!dlroW ,olleH"tnirp
```

Title: Double-duty quine: quine!dlroW ,olleH


答:
Retina, <s>62</s> 39 bytes

23 bytes thanks to @MartinEnder!

```<code>0000 false              1 byte : 2
0001 p and q            2 bytes: 11
0010 p and not q        2 bytes: 10
0011 p                  2 bytes: ^1
0100 not p and q        2 bytes: 01
0101 q                  2 bytes: 1$
0110 xor                5 bytes: 01|10
0111 p or q             1 byte : 1
1000 not p and not q    2 bytes: 00
1001 xnor               5 bytes: (.)\1
1010 not q              2 bytes: 0$
1011 p or not q         5 bytes: ^1|0$
1100 not p              2 bytes: ^0
1101 not p or q         5 bytes: ^0|1$
1110 not p or not q     1 byte : 0
1111 true               0 bytes:
</code>```

Takes input as PQ.

Outputs an integer between 0 to 3. 0 is falsey, others are truthy.

Explanation

They are all just regexes.

For example, 01|10 just matches 01 or 10.

In 0000, 2 will never be in the input, so it never matches.

In 1111, it matches the empty string, which there are 4.

Body:
Retina, <s>62</s> 39 bytes

23 bytes thanks to @MartinEnder!

0000 false              1 byte : 2
0001 p and q            2 bytes: 11
0010 p and not q        2 bytes: 10
0011 p                  2 bytes: ^1
0100 not p and q        2 bytes: 01
0101 q                  2 bytes: 1$
0110 xor                5 bytes: 01|10
0111 p or q             1 byte : 1
1000 not p and not q    2 bytes: 00
1001 xnor               5 bytes: (.)\1
1010 not q              2 bytes: 0$
1011 p or not q         5 bytes: ^1|0$
1100 not p              2 bytes: ^0
1101 not p or q         5 bytes: ^0|1$
1110 not p or not q     1 byte : 0
1111 true               0 bytes:

Takes input as PQ.

Outputs an integer between 0 to 3. 0 is falsey, others are truthy.

Explanation

They are all just regexes.

For example, 01|10 just matches 01 or 10.

In 0000, 2 will never be in the input, so it never matches.

In 1111, it matches the empty string, which there are 4.


答:
J, 27 bytes

Some credits to the official page.

```<code>0000 false              0:
0001 p and q            *
0010 p and not q        >
0011 p                  [
0100 not p and q        <
0101 q                  ]
0110 xor                ~:
0111 p or q             +.
1000 not p and not q    +:
1001 xnor               =
1010 not q              1-]
1011 p or not q         >:
1100 not p              1-[
1101 not p or q         !
1110 not p or not q     *:
1111 true               1:
</code>```

I am still not sure which values are truthy/falsey in J.

If -1 is truthy, xor can be golfed to - (subtraction).

Body:
J, 27 bytes

Some credits to the official page.

0000 false              0:
0001 p and q            *
0010 p and not q        >
0011 p                  [
0100 not p and q        <
0101 q                  ]
0110 xor                ~:
0111 p or q             +.
1000 not p and not q    +:
1001 xnor               =
1010 not q              1-]
1011 p or not q         >:
1100 not p              1-[
1101 not p or q         !
1110 not p or not q     *:
1111 true               1:

I am still not sure which values are truthy/falsey in J.

If -1 is truthy, xor can be golfed to - (subtraction).


答:
JavaScript (ES6), 42 bytes

```<code>f=(a,b,g=a=>0+a.map(g).sort()+1)=>g(a)==g(b)
</code>```

Accepts input using []s e.g. f([[],[[]]],[[[]],[]]). Works by converting the arrays to strings and then sorting them from the inside out. 0 and 1 are used because they're shorter than '[' and ']', so for example g([[[]],[]]) is 001,00111 which represents [[],[[]]].

Title: Are the two sets equal

Body:
JavaScript (ES6), 42 bytes

f=(a,b,g=a=>0+a.map(g).sort()+1)=>g(a)==g(b)

Accepts input using []s e.g. f([[],[[]]],[[[]],[]]). Works by converting the arrays to strings and then sorting them from the inside out. 0 and 1 are used because they're shorter than '[' and ']', so for example g([[[]],[]]) is 001,00111 which represents [[],[[]]].


答:
APL (NARS2000), 4 bytes

```<code>≡⍦
</code>```

⍦ is the multiset operator, which modifies functions to treat their arguments as sets instead of lists

≡ is the equivalence function, which returns a Boolean indicating if the arguments are completely equivalent in value and shape

Regarding the additional rule: Note that this answer does not use any unordered set datatype, but just normal lists (which may contain multiple identical elements). It just treats them as sets.

The byte count is 4 because NARS2000 uses UCS-2 exclusively.

Title: Are the two sets equal

Body:
APL (NARS2000), 4 bytes

≡⍦

⍦ is the multiset operator, which modifies functions to treat their arguments as sets instead of lists

≡ is the equivalence function, which returns a Boolean indicating if the arguments are completely equivalent in value and shape

Regarding the additional rule: Note that this answer does not use any unordered set datatype, but just normal lists (which may contain multiple identical elements). It just treats them as sets.

The byte count is 4 because NARS2000 uses UCS-2 exclusively.

ContentLicense: CC BY-SA 4.0


答:
Brachylog, 8 bytes

```<code>{p:1a.}.
</code>```

This expects brackets in Input and Output.

For example:

```<code>?- run_from_atom('{p:1a.}.', [[]:[[]]], [[[]]:[]]).
true .
</code>```

Explanation

```<code>{     }.   True if the predicate inside brackets is true with input Input and output Output

 p          Unify an implicit variable with a permutation of Input
  :1a       Apply this same predicate to each element of that implicit variable
     .      True if Output can be unified with the resulting list
</code>```

Title: Are the two sets equal

Body:
Brachylog, 8 bytes

{p:1a.}.

This expects brackets in Input and Output.

For example:

?- run_from_atom('{p:1a.}.', [[]:[[]]], [[[]]:[]]).
true .

Explanation

{     }.   True if the predicate inside brackets is true with input Input and output Output

 p          Unify an implicit variable with a permutation of Input
  :1a       Apply this same predicate to each element of that implicit variable
     .      True if Output can be unified with the resulting list


问:
The Ever Amplifying Zigzag
Write a program or function that takes in a positive integer N and outputs the first N numbers of this amplifying zigzag pattern, using only the lines needed:

```<code>                                         26
                                       25  27                                      .
         10                          24      28                                  .
        9  11                      23          29                              .
 2     8     12                  22              30                          44
1 3   7        13              21                  31                      43
   4 6           14          20                      32                  42
    5              15      19                          33              41
                     16  18                              34          40
                       17                                  35      39
                                                             36  38
                                                               37
</code>```

So, if N is 1 the output is

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

If N is 2, the output is

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

If N is 3 the output is

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

If N is 4 the output is

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

If N is 10 the output is

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

If N is 19 the output is

```<code>         10
        9  11
 2     8     12
1 3   7        13
   4 6           14
    5              15      19
                     16  18
                       17
</code>```

and so on.

Notes

Each peak or trough of the zigzag reaches its point one more line away from the line with the 1 on it than the previous peak or trough.

N is not limited to 44. The zigzag grows in the same pattern and larger N should be supported.

Numbers with multiple digits should only "touch" at their corners, as depicted. Make sure this works when N is 100 and above.

There should be no empty (or space only) lines in the output except one optional trailing newline.

Any line may have any amount of trailing spaces.

Scoring

The shortest code in bytes wins. Tiebreaker is earlier answer.

答:
MATLAB, 148 bytes

```<code>n=input('');k=fix(n^.5);m=0;w=1;d=-1;for l=1:n;s=num2str(l);m(k+1,w:w+nnz(s)-1)=s;w=w+nnz(s);k=k+d;d=d*(-1)^(l^.5==fix(l^.5));end;[m(any(m,2),:),'']
</code>```

Note that the spaces are missing in Octave, as MATLAB prints the the character indexed with 0 as a space, while octave does just omit that character.

Explanation:

```<code>n=input('');
k=fix(n^.5);                    %caculate starting height
m=0;w=1;d=-1;                   %initialize counters and output matrix
for l=1:n;
    s=num2str(l);
    m(k+1,w:w+nnz(s)-1)=s;      %insert current index as a string
    w=w+nnz(s);                 %current horizontal position
    k=k+d;                      %current vertical position
    d=d*(-1)^(l^.5==fix(l^.5)); %if we reached a square number, change direction
end
[m(any(m,2),:),'']              %delete all zero rows
</code>```

Title: The Ever Amplifying Zigzag

Body:
MATLAB, 148 bytes

n=input('');k=fix(n^.5);m=0;w=1;d=-1;for l=1:n;s=num2str(l);m(k+1,w:w+nnz(s)-1)=s;w=w+nnz(s);k=k+d;d=d*(-1)^(l^.5==fix(l^.5));end;[m(any(m,2),:),'']

Note that the spaces are missing in Octave, as MATLAB prints the the character indexed with 0 as a space, while octave does just omit that character.

Explanation:

n=input('');
k=fix(n^.5);                    %caculate starting height
m=0;w=1;d=-1;                   %initialize counters and output matrix
for l=1:n;
    s=num2str(l);
    m(k+1,w:w+nnz(s)-1)=s;      %insert current index as a string
    w=w+nnz(s);                 %current horizontal position
    k=k+d;                      %current vertical position
    d=d*(-1)^(l^.5==fix(l^.5)); %if we reached a square number, change direction
end
[m(any(m,2),:),'']              %delete all zero rows


答:
SETL, 1 byte

```<code>=
</code>```

Takes sets as left and right arguments.

Note that this does NOT adhere the added rule which prohibits unordered set datatypes.

Title: Are the two sets equal

Body:
SETL, 1 byte

=

Takes sets as left and right arguments.

Note that this does NOT adhere the added rule which prohibits unordered set datatypes.


问:
The handshake problem
The handshake problem is the classic problem that for n people in a room, if they all shake hands, what's the total number of handshakes that occur.

You code should take an input of any number and output the number of handshakes, both in base ten.

Also the code should not let non-integers through. You should output a falsey in this case. The only expected inputs are positive whole integers and positive real numbers - you don't need to worry about complex numbers or strings as inputs.
This should mean that you should expect n >= 0

Test cases

```<code>(N:handshakes)
0:0
10:45
20:190
10.5:0
1337:893116
</code>```

Normal golfing rules apply and shortest code wins.
If your code isn't self explanatory, please explain.

Jelly and 05AB1E are the winners, both at 2 bytes

答:
ArnoldC, 266 bytes

ArnoldC has no concept of non-integers, so it is impossible to enter one.

```<code>LISTEN TO ME VERY CAREFULLY f
I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE n
GIVE THESE PEOPLE AIR
HEY CHRISTMAS TREE r
YOU SET US UP 0
GET TO THE CHOPPER r
HERE IS MY INVITATION n
GET DOWN 1
YOU'RE FIRED n
HE HAD TO SPLIT 2
ENOUGH TALK
I'LL BE BACK r
HASTA LA VISTA, BABY
</code>```

Explanations:

```<code>DeclareMethod f
        MethodArguments n
        NonVoidMethod
        DeclareInt r
        SetInitialValue 0
            AssignVariable r
                   SetValue n
                   MinusOperator 1
                   MultiplicationOperator n
                   DivisionOperator 2
            EndAssignVariable
        Return r
EndMethodDeclaration
</code>```

Title: The handshake problem

Body:
ArnoldC, 266 bytes

ArnoldC has no concept of non-integers, so it is impossible to enter one.

LISTEN TO ME VERY CAREFULLY f
I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE n
GIVE THESE PEOPLE AIR
HEY CHRISTMAS TREE r
YOU SET US UP 0
GET TO THE CHOPPER r
HERE IS MY INVITATION n
GET DOWN 1
YOU'RE FIRED n
HE HAD TO SPLIT 2
ENOUGH TALK
I'LL BE BACK r
HASTA LA VISTA, BABY

Explanations:

DeclareMethod f
        MethodArguments n
        NonVoidMethod
        DeclareInt r
        SetInitialValue 0
            AssignVariable r
                   SetValue n
                   MinusOperator 1
                   MultiplicationOperator n
                   DivisionOperator 2
            EndAssignVariable
        Return r
EndMethodDeclaration


问:
Simplify a Date
This is similar to simplifying fractions, but with Dates!

The input of your program must be of the form mm/dd
For example

```<code>3/4 //March 4
12/15 //December 15
1/1 // January 1
</code>```

We assume that the input will be valid such that the months have these numbers of days in them:

```<code>January 31
February 28
March 31
April 30
May 31
June 30
July 31
August 31
September 30
October 31
November 30
December 31
</code>```

Your program's job is to take the assumed valid input, and iteratively (or recursively) simplify the date, and at each iteration (including the 0th), output the date with the full name of the month as written above.

For example:

Given an input of:

```<code>12/18
</code>```

Would output

```<code>December 18
June 9
February 3
</code>```

An input that is already simplified only outputs itself:

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

Outputs:

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

The month names cannot come from a function in your language. The strings can be obfuscated, computed, however you like, but you cannot use a standard function like GetMonthString(4) or something, you either have to write that function, or find a way to output the month names as described.

I cannot think of any cases where the simplified date produces an illegal date, but if ever you produce an illegal date along the way, output:

```<code>Illegal Date
</code>```

But if you are sure this cannot happen, you do not need to have code covering this case. The dates outputted just always need to be valid according to what was described above (it goes without saying that months and days start at 1).

The algorithm:

At each iteration you divide by the smallest number that divides numerator and denominator.

That is, you find all the numbers such that, dividing both the numerator and denominator by this number produces a new numerator and denominator that are both integers (common factors). Select the smallest one and individually divide the numerator and denominator to produce a new fraction.
If the only number you can divide by is 1, then you have simplified as much as possible and you stop.

I hope this is clear.

Any language is allowed. This is Code Golf, shortest code wins!

答:
TSQL 296 bytes

Not being allowed to use the standard datename cost me alot of bytes, however to save a few bytes, I used the first 3 characters of the default date description(with the format mon dd yyyy hh:miAM (or PM)) and added the rest of the month name.

Golfed:

```<code>use master
DECLARE @ varchar(5) = '12/2'

DECLARE @m int=month('2000/'+@),@d INT=day('2000/'+@)WHILE @m>0BEGIN PRINT left(dateadd(d,@m*29,0),3)+choose(@m,'uary','uary','ch','il','','e','y','ust','tember','ober','ember','ember')+' '+LEFT(@d,2)SELECT @m/=min(n),@d/=min(n)FROM(SELECT number FROM spt_values)x(n)WHERE @m%n+@d%n=0 and n>1 END
</code>```

Try it online

Ungolfed:

```<code>use master
DECLARE @ varchar(5) = '12/2'

DECLARE @m int=month('2000/'+@),@d INT=day('2000/'+@)
WHILE @m>0
BEGIN
PRINT
 left(dateadd(d,@m*29,0),3)
 +choose(@m,'uary','uary','ch','il','','e','y','ust',
  'tember','ober','ember','ember')+' '+LEFT(@d,2)
SELECT @m/=min(n),@d/=min(n)
FROM
(
  SELECT number
  FROM spt_values
)x(n)
WHERE
  @m%n+@d%n=0
  and n>1
END
</code>```

Title: Simplify a Date

Body:
TSQL 296 bytes

Not being allowed to use the standard datename cost me alot of bytes, however to save a few bytes, I used the first 3 characters of the default date description(with the format mon dd yyyy hh:miAM (or PM)) and added the rest of the month name.

Golfed:

use master
DECLARE @ varchar(5) = '12/2'

DECLARE @m int=month('2000/'+@),@d INT=day('2000/'+@)WHILE @m>0BEGIN PRINT left(dateadd(d,@m*29,0),3)+choose(@m,'uary','uary','ch','il','','e','y','ust','tember','ober','ember','ember')+' '+LEFT(@d,2)SELECT @m/=min(n),@d/=min(n)FROM(SELECT number FROM spt_values)x(n)WHERE @m%n+@d%n=0 and n>1 END

Try it online

Ungolfed:

use master
DECLARE @ varchar(5) = '12/2'

DECLARE @m int=month('2000/'+@),@d INT=day('2000/'+@)
WHILE @m>0
BEGIN
PRINT
 left(dateadd(d,@m*29,0),3)
 +choose(@m,'uary','uary','ch','il','','e','y','ust',
  'tember','ober','ember','ember')+' '+LEFT(@d,2)
SELECT @m/=min(n),@d/=min(n)
FROM
(
  SELECT number
  FROM spt_values
)x(n)
WHERE
  @m%n+@d%n=0
  and n>1
END


问:
Define a field with 256 elements
A field in mathematics is a set of numbers, with addition and multiplication operations defined on it, such that they satisfy certain axioms (described in Wikipedia; see also below).

A finite field can have pn elements, where p is a prime number, and n is a natural number. In this challenge, let's take p = 2 and n = 8, so let's make a field with 256 elements.

The elements of the field should be consecutive integers in a range that contains 0 and 1:

-128 ... 127

0 ... 255

or any other such range

Define two functions (or programs, if that is easier), a(x,y) for abstract "addition", and m(x,y) for abstract "multiplication", such that they satisfy the field axioms:

Consistency: a(x,y) and m(x,y) produce the same result when called with same arguments

Closedness: The result of a and m is an integer in the relevant range

Associativity: for any x, y and z in the range, a(a(x,y),z) is equal to a(x,a(y,z)); the same for m

Commutativity: for any x and y in the range, a(x,y) is equal to a(y,x); the same for m

Distributivity: for any x, y and z in the range, m(x,a(y,z)) is equal to a(m(x,y),m(x,z))

Neutral elements: for any x in the range, a(0,x) is equal to x, and m(1,x) is equal to x

Negation: for any x in the range, there exists such y that a(x,y) is 0

Inverse: for any x≠0 in the range, there exists such y that m(x,y) is 1

The names a and m are just examples; you can use other names, or unnamed functions. The score of your answer is the sum of byte-lengths for a and m.

If you use a built-in function, please also describe in words which result it produces (e.g. provide a multiplication table).

答:
IA-32 machine code, 22 bytes

"Multiplication", 18 bytes:

```<code>33 c0 92 d1 e9 73 02 33 d0 d0 e0 73 02 34 1b 41
e2 f1
</code>```

"Addition", 4 bytes:

```<code>92 33 c1 c3
</code>```

This stretches rules a bit: the "multiplication" code lacks function exit code; it relies on the "addition" code being in memory right afterwards, so it can "fall-through". I did it to decrease code size by 1 byte.

Source code (can be assembled by ml of MS Visual Studio):

```<code>    TITLE   x

PUBLIC @m@8
PUBLIC @a@8

_TEXT   SEGMENT USE32
@m@8    PROC
    xor eax, eax;
    xchg eax, edx;
myloop:
    shr ecx, 1
    jnc sk1
    xor edx, eax
sk1:
    shl al, 1
    jnc sk2
    xor al, 1bh
sk2:
    inc ecx
    loop myloop
@m@8 endp

@a@8 proc
    xchg eax, edx;
    xor eax, ecx
    ret
@a@8    ENDP
_text ENDS
END
</code>```

The algorithm is the standard one, involving the usual polynomial x^8 + x^4 + x^3 + x + 1, represented by the hexadecimal number 1b. The "multiplication" code accumulates the result in edx. When done, it falls through to the addition code, which moves it to eax (conventional register to hold return value); the xor with ecx is a no-op, because at that point ecx is cleared.

One peculiar feature is the loop. Instead of checking for zero

```<code>cmp ecx, 0
jne myloop
</code>```

it uses the dedicated loop instruction. But this instruction decreases the loop "counter" before comparing it to 0. To compensate for this, the code increases it before using the loop instruction.

Title: Define a field with 256 elements

Body:
IA-32 machine code, 22 bytes

"Multiplication", 18 bytes:

33 c0 92 d1 e9 73 02 33 d0 d0 e0 73 02 34 1b 41
e2 f1

"Addition", 4 bytes:

92 33 c1 c3

This stretches rules a bit: the "multiplication" code lacks function exit code; it relies on the "addition" code being in memory right afterwards, so it can "fall-through". I did it to decrease code size by 1 byte.

Source code (can be assembled by ml of MS Visual Studio):

    TITLE   x

PUBLIC @m@8
PUBLIC @a@8

_TEXT   SEGMENT USE32
@m@8    PROC
    xor eax, eax;
    xchg eax, edx;
myloop:
    shr ecx, 1
    jnc sk1
    xor edx, eax
sk1:
    shl al, 1
    jnc sk2
    xor al, 1bh
sk2:
    inc ecx
    loop myloop
@m@8 endp

@a@8 proc
    xchg eax, edx;
    xor eax, ecx
    ret
@a@8    ENDP
_text ENDS
END

The algorithm is the standard one, involving the usual polynomial x^8 + x^4 + x^3 + x + 1, represented by the hexadecimal number 1b. The "multiplication" code accumulates the result in edx. When done, it falls through to the addition code, which moves it to eax (conventional register to hold return value); the xor with ecx is a no-op, because at that point ecx is cleared.

One peculiar feature is the loop. Instead of checking for zero

cmp ecx, 0
jne myloop

it uses the dedicated loop instruction. But this instruction decreases the loop "counter" before comparing it to 0. To compensate for this, the code increases it before using the loop instruction.


问:
Calculate the relativistic velocity
In special relativity, the velocity of a moving object relative to another object that is moving in the opposite direction is given by the formula:

\begin{align}s = \frac{v+u}{1+vu/c^2}.\end{align}

```<code>s = ( v + u ) / ( 1 + v * u / c ^ 2)
</code>```

In this formula, \$v\$ and \$u\$ are the magnitudes of the velocities of the objects, and \$c\$ is the speed of light (which is approximately \$3.0 \times 10^8 \,\mathrm m/\mathrm s\$, a close enough approximation for this challenge).

For example, if one object was moving at v = 50,000 m/s, and another object was moving at u = 60,000 m/s, the velocity of each object relative to the other would be approximately s = 110,000 m/s. This is what you would expect under Galilean relativity (where velocities simply add). However, if v = 50,000,000 m/s and u = 60,000,000 m/s, the relative velocity would be approximately 106,451,613 m/s, which is significantly different than the 110,000,000 m/s predicted by Galilean relativity.

The Challenge

Given two integers v and u such that 0 <= v,u < c, calculate the relativistic additive velocity, using the above formula, with c = 300000000. Output must be either a decimal value or a reduced fraction. The output must be within 0.001 of the actual value for a decimal value, or exact for a fraction.

Test Cases

Format: v, u -> exact fraction (float approximation)

```<code>50000, 60000 -> 3300000000000/30000001 (109999.99633333346)
50000000, 60000000 -> 3300000000/31 (106451612.90322581)
20, 30 -> 7500000000000000/150000000000001 (49.999999999999666)
0, 20051 -> 20051 (20051.0)
299999999, 299999999 -> 53999999820000000000000000/179999999400000001 (300000000.0)
20000, 2000000 -> 4545000000000/2250001 (2019999.1022226212)
2000000, 2000000 -> 90000000000/22501 (3999822.2301231055)
1, 500000 -> 90000180000000000/180000000001 (500000.9999972222)
1, 50000000 -> 90000001800000000/1800000001 (50000000.972222224)
200000000, 100000000 -> 2700000000/11 (245454545.45454547)
</code>```

答:
dc, 21 bytes

```<code>svddlv+rlv*9/I16^/1+/
</code>```

This assumes that the precision has already been set, e.g. with 20k.  Add 3 bytes if you can't make that assumption.

A more accurate version is

```<code>svdlv+9I16^*dsc*rlv*lc+/
</code>```

at 24 bytes.

Both of them are reasonably faithful transcriptions of the formula, with the only notable golfing being the use of 9I16^* for c².

Title: Calculate the relativistic velocity

Body:
dc, 21 bytes

svddlv+rlv*9/I16^/1+/

This assumes that the precision has already been set, e.g. with 20k.  Add 3 bytes if you can't make that assumption.

A more accurate version is

svdlv+9I16^*dsc*rlv*lc+/

at 24 bytes.

Both of them are reasonably faithful transcriptions of the formula, with the only notable golfing being the use of 9I16^* for c².


问:
Obfuscated Hello World
Create the shortest possible obfuscated program that displays the text "Hello World".

In order to be considered an obfuscated program, it must meet at least two of the following requirements:

Does not contain the characters: h, l, w and d in any case

Does not contain the characters: e, o, r, 0, and 1 in any case

Does not contain the characters: 2 or 7

Input:

none

Output:

Hello World

Leaderboard

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

/* Configuration */

var QUESTION_ID = 307; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 48934; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });

  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (/ b.lang) return 1;
    if (a.lang < b.lang) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

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

```

答:
Tellurium, 16 bytes

```<code>µUryyb Jbeyq~r^
</code>```

This basically encodes "Uryyb Jbeyq" with ROT-13 (Hello World) and displays the result.

Title: Obfuscated Hello World

Body:
Tellurium, 16 bytes

µUryyb Jbeyq~r^

This basically encodes "Uryyb Jbeyq" with ROT-13 (Hello World) and displays the result.


答:
dc, 18 bytes

```<code>[d/]sqdX0!=qd1-*2/
</code>```

Explanation

```<code>[d/]sq
</code>```

Store in register q a macro that replaces top of stack with 1 (by dividing by itself).

```<code>dX0!=q
</code>```

If there are any fraction digits, then execute the macro.

```<code>d1-*2/
</code>```

Compute ½n(n-1).  If we started with 1 (either as input or because a non-integer value was entered) the result will be 0.

Title: The handshake problem

Body:
The handshake problem is the classic problem that for n people in a room, if they all shake hands, what's the total number of handshakes that occur.

You code should take an input of any number and output the number of handshakes, both in base ten.

Also the code should not let non-integers through. You should output a falsey in this case. The only expected inputs are positive whole integers and positive real numbers - you don't need to worry about complex numbers or strings as inputs.
This should mean that you should expect n >= 0

Test cases

```<code>(N:handshakes)
0:0
10:45
20:190
10.5:0
1337:893116
</code>```

Normal golfing rules apply and shortest code wins.
If your code isn't self explanatory, please explain.

Jelly and 05AB1E are the winners, both at 2 bytes

Body:
dc, 18 bytes

[d/]sqdX0!=qd1-*2/

Explanation

[d/]sq

Store in register q a macro that replaces top of stack with 1 (by dividing by itself).

dX0!=q

If there are any fraction digits, then execute the macro.

d1-*2/

Compute ½n(n-1).  If we started with 1 (either as input or because a non-integer value was entered) the result will be 0.


答:
Python 3, 22 bytes

```<code>lambda z:sum(range(z))
</code>```

Makes use of Python's standard library. Raises an error whenever the function is fed with a non-integer.

Title: The handshake problem

Body:
Python 3, 22 bytes

lambda z:sum(range(z))

Makes use of Python's standard library. Raises an error whenever the function is fed with a non-integer.


答:
Python, 215 bytes

```<code>lambda a,b:0
int.__mul__
lambda a,b:a>b
lambda a,b:a
lambda a,b:a<b
lambda a,b:b
int.__xor__
int.__or__
lambda a,b:not a|b
lambda a,b:a==b
lambda a,b:1-b
lambda a,b:a>=b
lambda a,b:1-a
lambda a,b:a<=b
lambda a,b:1-a*b
lambda a,b:1
</code>```

Ideone it!

Body:
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:
Python, 215 bytes

lambda a,b:0
int.__mul__
lambda a,b:a>b
lambda a,b:a
lambda a,b:a<b
lambda a,b:b
int.__xor__
int.__or__
lambda a,b:not a|b
lambda a,b:a==b
lambda a,b:1-b
lambda a,b:a>=b
lambda a,b:1-a
lambda a,b:a<=b
lambda a,b:1-a*b
lambda a,b:1

Ideone it!


答:
05AB1E, <s>31</s> <s>27</s> 26 bytes

First input is p.

Second input is q.

```<code>0000 false              0          # ignore input, output 0 (false)
0001 p and q            &          # p and q
0010 p and not q        s±&        # (not q) and p
0011 p                  ¹          # p
0100 not p and q        ±&         # (not p) and q
0101 q                  ²          # q
0110 xor                ^          # p xor q
0111 p or q             ~          # p or q
1000 not p and not q    +_         # (p + q) == 0
1001 eq                 Q          # p == q
1010 not q              ²_         # not q
1011 p or not q         s_~        # (not q) or p
1100 not p              _          # not p
1101 not p or q         _~         # (not p) or q
1110 not p or not q     +2‹        # (p + q) < 2
1111 true               1          # ignore input, output 1 (true)
</code>```

Saved 4 bytes thanks to Adnan

Saved 1 byte thanks to Magic Octopus Urn

Body:
05AB1E, <s>31</s> <s>27</s> 26 bytes

First input is p.

Second input is q.

0000 false              0          # ignore input, output 0 (false)
0001 p and q            &          # p and q
0010 p and not q        s±&        # (not q) and p
0011 p                  ¹          # p
0100 not p and q        ±&         # (not p) and q
0101 q                  ²          # q
0110 xor                ^          # p xor q
0111 p or q             ~          # p or q
1000 not p and not q    +_         # (p + q) == 0
1001 eq                 Q          # p == q
1010 not q              ²_         # not q
1011 p or not q         s_~        # (not q) or p
1100 not p              _          # not p
1101 not p or q         _~         # (not p) or q
1110 not p or not q     +2‹        # (p + q) < 2
1111 true               1          # ignore input, output 1 (true)

Saved 4 bytes thanks to Adnan

Saved 1 byte thanks to Magic Octopus Urn


答:
TI-Basic, <s>108</s> 66 bytes

With no arguments, Input gets input into X and Y.

```<code>0000 false            1 0
0001 and              4 Input :XY
0010 x and not y      5 Input :Xnot(Y
0011 x                3 Input :X
0100 not x and y      5 Input :Ynot(X
0101 y                3 Input :Y
0110 xor              5 Input :X-Y
0111 or               5 Input :X+Y
1000 nor              6 Input :not(X+Y
1001 xnor             5 Input :X=Y
1010 not y            4 Input :not(Y
1011 x or not y       5 Input :X≥Y
1100 not x            4 Input :not(X
1101 not x or y       5 Input :Y≤X
1110 nand             5 Input :not(XY
1111 true             1 1
</code>```

Body:
TI-Basic, <s>108</s> 66 bytes

With no arguments, Input gets input into X and Y.

0000 false            1 0
0001 and              4 Input :XY
0010 x and not y      5 Input :Xnot(Y
0011 x                3 Input :X
0100 not x and y      5 Input :Ynot(X
0101 y                3 Input :Y
0110 xor              5 Input :X-Y
0111 or               5 Input :X+Y
1000 nor              6 Input :not(X+Y
1001 xnor             5 Input :X=Y
1010 not y            4 Input :not(Y
1011 x or not y       5 Input :X≥Y
1100 not x            4 Input :not(X
1101 not x or y       5 Input :Y≤X
1110 nand             5 Input :not(XY
1111 true             1 1


问:
Leyland Numbers
Given a natural number \$n\$, return the \$n\$-th Leyland number.

Leyland Number

Leyland numbers are positive integers \$k\$ of the form

$$k = x^y + y^x$$

Where \$x\$ and \$y\$ are integers strictly greater than 1.

They are enumerated in ascending order.

EDIT: @DigitalTrauma suggested I include following "definition":

Imagine we throw \$x^y+y^x\$ in a bag for all possible values of \$x\$ and \$y\$, and avoid throwing in duplicates. Then we sort that bag. The sorted bag is our sequence.

Details

You may use 0 or 1 based indexing, whatever suits you best.

Your program must be able to output at least all Leyland numbers less than the maximum of signed 32-bit integers. (The last Leyland number below this limit is 1996813914, at index 82.)

Test cases

The first few terms are following:

```<code>8, 17, 32, 54, 57, 100, 145, 177, 320, 368, 512, 593, 945, 1124
</code>```

A076980 in OEIS, except for the first entry. Note that because of that additional first entry, the indices on OEIS are shifted by one.

More can be found in the OEIS b-file

答:
Pyth, 17 bytes

0-indexed.

```<code>@{Sms^M_Bd^}2+2Q2
</code>```

Try it online! (Please, keep it at 100.)

How it works

```<code>@{Sms^M_Bd^}2+2Q2
@{Sms^M_Bd^}2+2Q2Q  implicit filling. Input:Q

           }2+2Q    Yield the array [2,3,4,...,Q+2]
          ^     2   Cartesian square: yield all the
                    pairs formed by the above array.
   m     d          Map the following to all of those pairs (e.g. [2,3]):
       _B               Create [[2,3],[3,2]]
     ^M                 Reduce by exponent to each array:
                        create [8,9]
    s                   Sum:   17     (Leyland number generated)
  S                 Sort the generated numbers
 {                  Remove duplicate
@                Q  Find the Q-th element.
</code>```

Slower version

1-indexed.

```<code>e.ffqZs^M_BT^}2Z2
</code>```

Try it online! (Please, keep it at 3.)

Title: Leyland Numbers

Body:
Pyth, 17 bytes

0-indexed.

@{Sms^M_Bd^}2+2Q2

Try it online! (Please, keep it at 100.)

How it works

@{Sms^M_Bd^}2+2Q2
@{Sms^M_Bd^}2+2Q2Q  implicit filling. Input:Q

           }2+2Q    Yield the array [2,3,4,...,Q+2]
          ^     2   Cartesian square: yield all the
                    pairs formed by the above array.
   m     d          Map the following to all of those pairs (e.g. [2,3]):
       _B               Create [[2,3],[3,2]]
     ^M                 Reduce by exponent to each array:
                        create [8,9]
    s                   Sum:   17     (Leyland number generated)
  S                 Sort the generated numbers
 {                  Remove duplicate
@                Q  Find the Q-th element.

Slower version

1-indexed.

e.ffqZs^M_BT^}2Z2

Try it online! (Please, keep it at 3.)


答:
Factor with load-all, 12 bytes

```<code>[ iota sum ]
</code>```

Same as this answer.

Title: The handshake problem

Body:
Factor with load-all, 12 bytes

[ iota sum ]

Same as this answer.


答:
Stack Cats, 67 + 64 = 131 bytes

Note that the +64 is from applying the -nm flags to each program. -n indicates numeric I/O, and -m mirrors the source code across the last character - not all submissions need these flags technically, but for consistency and simplicity I'm scoring them all the same way.

```<code>-2 -2 -3 -3     !I                0 0 0 0     <I!+
-4 -4 -4  1     |!T*I             0 0 0 1     [>I=I_
-4 -4  3 -2     *I*_              0 0 1 0     :I*=I:
-2 -2  3  3     T*I               0 0 1 1     [<!>X
-2  1 -2 -2     _*T*I             0 1 0 0     *|!TI:
-2  1 -3  1     !-|_I             0 1 0 1     <!I!>X
-2  3  3 -2     ^T*I              0 1 1 0     ^:]<_I
-2  3  3  3     -_T*I             0 1 1 1     *I<-I!
 2 -3 -3 -3     -*|_I             1 0 0 0     ^{!:}I_
 2 -3 -3  2     _|*I              1 0 0 1     _|[<I!:
 1 -2  1 -2     :]I*:             1 0 1 0     _!:|]X
 1 -2  1  1     *I\<X             1 0 1 1     *>I>!I
 2  2 -3 -3     -*I               1 1 0 0     I^:!
 2  2 -3  2     _*I_              1 1 0 1     |I|^:!
 1  2  2 -1     |!:^I             1 1 1 0     -I*<*I
 1  1  1  1     *<X               1 1 1 1     +I+
</code>```

() in Stack Cats checks whether an element is positive or nonpositive (i.e. 0 or negative), so we're using that for truthy/falsy respectively. The second column is just for interest, and lists the best gates with 0/1s as outputs (with total score 90).

Input is delimiter-separated bits via STDIN. Try it online!

Stack Cats is a reversible esoteric language, where programs have reflective symmetry. Given a snippet f (e.g. >[[(!-)/), the mirror image (e.g. \(-!)]]<) computes the inverse f^-1. As such, even length programs do nothing (or get stuck in an infinite loop), and the only non-trivial programs have odd length, computing f g f^-1 where g is the centre operator.

Since half the source code is always redundant, it can be left out, and running the code with the -m flag indicates that the source code should be mirrored over the last character to retrieve the actual source code. For example, the program *<X is actually *<X>*, which is symmetrical.

Golfing in Stack Cats is highly unintuitive, so the above programs had to be found by brute force. Most of them are surprisingly complex, but I'll explain a few and add to this answer when I have time. For now, some explanations and alternative solutions for the 0/1 versions can be found on the Github repository here.

Body:
Stack Cats, 67 + 64 = 131 bytes

Note that the +64 is from applying the -nm flags to each program. -n indicates numeric I/O, and -m mirrors the source code across the last character - not all submissions need these flags technically, but for consistency and simplicity I'm scoring them all the same way.

-2 -2 -3 -3     !I                0 0 0 0     <I!+
-4 -4 -4  1     |!T*I             0 0 0 1     [>I=I_
-4 -4  3 -2     *I*_              0 0 1 0     :I*=I:
-2 -2  3  3     T*I               0 0 1 1     [<!>X
-2  1 -2 -2     _*T*I             0 1 0 0     *|!TI:
-2  1 -3  1     !-|_I             0 1 0 1     <!I!>X
-2  3  3 -2     ^T*I              0 1 1 0     ^:]<_I
-2  3  3  3     -_T*I             0 1 1 1     *I<-I!
 2 -3 -3 -3     -*|_I             1 0 0 0     ^{!:}I_
 2 -3 -3  2     _|*I              1 0 0 1     _|[<I!:
 1 -2  1 -2     :]I*:             1 0 1 0     _!:|]X
 1 -2  1  1     *I\<X             1 0 1 1     *>I>!I
 2  2 -3 -3     -*I               1 1 0 0     I^:!
 2  2 -3  2     _*I_              1 1 0 1     |I|^:!
 1  2  2 -1     |!:^I             1 1 1 0     -I*<*I
 1  1  1  1     *<X               1 1 1 1     +I+

() in Stack Cats checks whether an element is positive or nonpositive (i.e. 0 or negative), so we're using that for truthy/falsy respectively. The second column is just for interest, and lists the best gates with 0/1s as outputs (with total score 90).

Input is delimiter-separated bits via STDIN. Try it online!

Stack Cats is a reversible esoteric language, where programs have reflective symmetry. Given a snippet f (e.g. >[[(!-)/), the mirror image (e.g. \(-!)]]<) computes the inverse f^-1. As such, even length programs do nothing (or get stuck in an infinite loop), and the only non-trivial programs have odd length, computing f g f^-1 where g is the centre operator.

Since half the source code is always redundant, it can be left out, and running the code with the -m flag indicates that the source code should be mirrored over the last character to retrieve the actual source code. For example, the program *<X is actually *<X>*, which is symmetrical.

Golfing in Stack Cats is highly unintuitive, so the above programs had to be found by brute force. Most of them are surprisingly complex, but I'll explain a few and add to this answer when I have time. For now, some explanations and alternative solutions for the 0/1 versions can be found on the Github repository here.


答:
PowerShell v2+, <s>84</s> <s>73</s> 68 bytes

```<code>(2..30|%{2..($x=$_)|%{"$x*"*$_+'1+'+"$_*"*$x+1|iex}}|sort)[$args[0]]
</code>```

Saved 11 bytes thanks to @Neil ... saved additional 5 bytes by reorganizing how the iex expression is evaluated.

Naïve method, we simply double-for loop from x=2..30 and y=2..x. Each loop we put x^y + y^x on the pipeline. The 30 was chosen experimentally to ensure that we covered all cases less than 2^31-1 ;-). We pipe those to Sort-Object to order them ascending. Output is zero-indexed based on the input $args[0].

Yes, there are a lot of extraneous entries generated here -- this algorithm actually generates 435 Leyland numbers -- but things above index 81 are not guaranteed to be accurate and in order (there may be some that are skipped).

Examples

```<code>PS C:\Tools\Scripts\golfing> .\leyland-numbers.ps1 54
14352282

PS C:\Tools\Scripts\golfing> .\leyland-numbers.ps1 33
178478

PS C:\Tools\Scripts\golfing> .\leyland-numbers.ps1 77
1073792449
</code>```

Title: Leyland Numbers

Body:
Given a natural number \$n\$, return the \$n\$-th Leyland number.

Leyland Number

Leyland numbers are positive integers \$k\$ of the form

$$k = x^y + y^x$$

Where \$x\$ and \$y\$ are integers strictly greater than 1.

They are enumerated in ascending order.

EDIT: @DigitalTrauma suggested I include following "definition":

Imagine we throw \$x^y+y^x\$ in a bag for all possible values of \$x\$ and \$y\$, and avoid throwing in duplicates. Then we sort that bag. The sorted bag is our sequence.

Details

You may use 0 or 1 based indexing, whatever suits you best.

Your program must be able to output at least all Leyland numbers less than the maximum of signed 32-bit integers. (The last Leyland number below this limit is 1996813914, at index 82.)

Test cases

The first few terms are following:

```<code>8, 17, 32, 54, 57, 100, 145, 177, 320, 368, 512, 593, 945, 1124
</code>```

A076980 in OEIS, except for the first entry. Note that because of that additional first entry, the indices on OEIS are shifted by one.

More can be found in the OEIS b-file

Body:
PowerShell v2+, <s>84</s> <s>73</s> 68 bytes

(2..30|%{2..($x=$_)|%{"$x*"*$_+'1+'+"$_*"*$x+1|iex}}|sort)[$args[0]]

Saved 11 bytes thanks to @Neil ... saved additional 5 bytes by reorganizing how the iex expression is evaluated.

Naïve method, we simply double-for loop from x=2..30 and y=2..x. Each loop we put x^y + y^x on the pipeline. The 30 was chosen experimentally to ensure that we covered all cases less than 2^31-1 ;-). We pipe those to Sort-Object to order them ascending. Output is zero-indexed based on the input $args[0].

Yes, there are a lot of extraneous entries generated here -- this algorithm actually generates 435 Leyland numbers -- but things above index 81 are not guaranteed to be accurate and in order (there may be some that are skipped).

Examples

PS C:\Tools\Scripts\golfing> .\leyland-numbers.ps1 54
14352282

PS C:\Tools\Scripts\golfing> .\leyland-numbers.ps1 33
178478

PS C:\Tools\Scripts\golfing> .\leyland-numbers.ps1 77
1073792449


答:
Haskell, <s>99</s> <s>98</s> <s>96</s> <s>95</s> 94 bytes

It is probably easily outgolfed, but that was the best I was able to come up with.

```<code>import Data.List
f n|n<2=[]|n>1=sort.nub$f(n-1)++[x^n+n^x|x<-[2..n]]
g n=(f.toInteger$n+3)!!n
</code>```

Title: Leyland Numbers

Body:
Haskell, <s>99</s> <s>98</s> <s>96</s> <s>95</s> 94 bytes

It is probably easily outgolfed, but that was the best I was able to come up with.

import Data.List
f n|n<2=[]|n>1=sort.nub$f(n-1)++[x^n+n^x|x<-[2..n]]
g n=(f.toInteger$n+3)!!n


答:
05AB1E, <s>20</s> 19 bytes

0-indexed

```<code>ÝÌ2ãvyÂ`ms`m+}){Ù¹è
</code>```

Explained

```<code>ÝÌ                     # range(2,N+2)
  2ã                   # get all pairs of numbers in the range
    v                  # for each pair
     yÂ`ms`m+          # push x^y+y^x
             }         # end loop
              ){Ù      # wrap to list, sort and remove duplicates
                 ¹è    # get Nth element of list
</code>```

Try it online

Saved 1 byte thanks to @Adnan

Title: Leyland Numbers

Body:
05AB1E, <s>20</s> 19 bytes

0-indexed

ÝÌ2ãvyÂ`ms`m+}){Ù¹è

Explained

ÝÌ                     # range(2,N+2)
  2ã                   # get all pairs of numbers in the range
    v                  # for each pair
     yÂ`ms`m+          # push x^y+y^x
             }         # end loop
              ){Ù      # wrap to list, sort and remove duplicates
                 ¹è    # get Nth element of list

Try it online

Saved 1 byte thanks to @Adnan


答:
JavaScript (Firefox 42-57), 94 bytes

```<code>n=>[for(x of Array(32).keys())for(y of Array(x+1).keys())if(y>1)x**y+y**x].sort((x,y)=>x-y)[n]
</code>```

Needs Firefox 42 because it uses both array comprehensions and exponentiation ([for(..of..)] and **).

Title: Leyland Numbers

Body:
JavaScript (Firefox 42-57), 94 bytes

n=>[for(x of Array(32).keys())for(y of Array(x+1).keys())if(y>1)x**y+y**x].sort((x,y)=>x-y)[n]

Needs Firefox 42 because it uses both array comprehensions and exponentiation ([for(..of..)] and **).


答:
Java 10, <s>225</s> <s>221</s> <s>219</s> <s>216</s> <s>206</s> <s>204</s> <s>193</s> <s>192</s> <s>130</s> 129 bytes

n->{var S=new java.util.TreeSet();for(int i=56,t;i<840;)S.add(Math.pow(i/28,t=i%28+2)+Math.pow(t,i++/28));return S.toArray()[n];}
```
<p>0-indexed</p>
<p>-2 bytes (221 → 219) saved by replacing <code>1996813915</code> with <code>(1L<<31)</code> thanks to <em>@LeakyNun</em>.<br />
-3 bytes (219 → 216) thanks to <em>@LeakyNun</em> and <em>@Frozn</em> with something I forgot myself..<br />
-10 bytes (216 → 206) by changing Java 7 to 8.<br />
-2 bytes (206 → 204) by replacing <code>ArrayList</code> with <code>Vector</code> thanks to <em>@TAsk</em>.<br />
-11 bytes (204 → 193) by removing <code>s<(1L<<31)&</code>, since the question states "<em><strong>at least</strong> all Leyland numbers less than the maximum of signed 32-bit integers</em>".<br />
-1 byte (193 → 192) by changing <code>Vector</code> to <code>Stack</code>.<br />
-62 bytes (192 → 130) by switching to Java 10 and using <code>var</code>; removing the <code>Collection.sort</code>, <code>import java.util.*;</code>, if-statement and temp-long <code>s</code> by using a <code>java.util.TreeSet</code> (which is a set of unique values and sorts automatically); and using <code>Double</code> and <code>Object</code> return-type instead of <code>Long</code> so we can remove the <code>(int)(...)</code> cast and <code><Long></code>.<br />
-1 byte (130 → 129) thanks to <em>@ceilingcat</em> by changing the two nested <code>[2,30]</code> loops to a single <code>[56,840]</code> loop.</p>
<p>Try it here</p>
<p><strong>Explanation:</strong></p>
<pre class="lang-java prettyprint-override"><code>n->{                             // Method with integer parameter and Object return-type
  var S=new java.util.TreeSet(); //  Create a sorted Set, initially empty
  for(int i=56,t;i<840)          //  Loop `i` in the range [56,840]
    t.add(                       //   Add to the Set:
      Math.pow(i/28,             //    `i` integer-divided by 28
               t=i%28+2)         //    to the power `i` modulo-28 + 2
      +Math.pow(t,               //    And add `i` modulo-28 + 2
                i++/28));        //    to the power `i` integer-divided by 28
                                 //    (and increase `i` by 1 afterwards with `i++`)
  return S.toArray()             //  Convert the sorted Set to an Object-array
           [n];}                 //  And return the value at the input-integer index
</code>```

Title: Leyland Numbers

Body:
Java 10, <s>225</s> <s>221</s> <s>219</s> <s>216</s> <s>206</s> <s>204</s> <s>193</s> <s>192</s> <s>130</s> 129 bytes

n->{var S=new java.util.TreeSet();for(int i=56,t;i<840;)S.add(Math.pow(i/28,t=i%28+2)+Math.pow(t,i++/28));return S.toArray()[n];}

0-indexed

-2 bytes (221 → 219) saved by replacing 1996813915 with (1L<<31) thanks to @LeakyNun.

-3 bytes (219 → 216) thanks to @LeakyNun and @Frozn with something I forgot myself..

-10 bytes (216 → 206) by changing Java 7 to 8.

-2 bytes (206 → 204) by replacing ArrayList with Vector thanks to @TAsk.

-11 bytes (204 → 193) by removing s<(1L<<31)&, since the question states "at least all Leyland numbers less than the maximum of signed 32-bit integers".

-1 byte (193 → 192) by changing Vector to Stack.

-62 bytes (192 → 130) by switching to Java 10 and using var; removing the Collection.sort, import java.util.*;, if-statement and temp-long s by using a java.util.TreeSet (which is a set of unique values and sorts automatically); and using Double and Object return-type instead of Long so we can remove the (int)(...) cast and <Long>.

-1 byte (130 → 129) thanks to @ceilingcat by changing the two nested [2,30] loops to a single [56,840] loop.

Try it here

Explanation:

n->{                             // Method with integer parameter and Object return-type
  var S=new java.util.TreeSet(); //  Create a sorted Set, initially empty
  for(int i=56,t;i<840)          //  Loop `i` in the range [56,840]
    t.add(                       //   Add to the Set:
      Math.pow(i/28,             //    `i` integer-divided by 28
               t=i%28+2)         //    to the power `i` modulo-28 + 2
      +Math.pow(t,               //    And add `i` modulo-28 + 2
                i++/28));        //    to the power `i` integer-divided by 28
                                 //    (and increase `i` by 1 afterwards with `i++`)
  return S.toArray()             //  Convert the sorted Set to an Object-array
           [n];}                 //  And return the value at the input-integer index


问:
Integer square root of integer
Problem:

In your choice of language, write the shortest function that returns the floor of the square root of an unsigned 64-bit integer.

Test cases:

Your function must work correctly for all inputs, but here are a few which help illustrate the idea:

```<code>               INPUT ⟶ OUTPUT

                   0 ⟶  0
                   1 ⟶  1
                   2 ⟶  1
                   3 ⟶  1
                   4 ⟶  2
                   8 ⟶  2
                   9 ⟶  3
                  15 ⟶  3
                  16 ⟶  4
               65535 ⟶ 255
               65536 ⟶ 256
18446744073709551615 ⟶ 4294967295
</code>```

Rules:

You can name your function anything you like. (Unnamed, anonymous, or lambda functions are fine, as long as they are somehow callable.)

Character count is what matters most in this challenge, but runtime is also important. I'm sure you could scan upwards iteratively for the answer in O(√n) time with a very small character count, but O(log(n)) time would really be better (that is, assuming an input value of n, not a bit-length of n).

You will probably want to implement the function using purely integer and/or boolean artithmetic. However, if you really want to use floating-point calculations, then that is fine so long as you call no library functions. So, simply saying return (n>0)?(uint32_t)sqrtl(n):-1; in C is off limits even though it would produce the correct result. If you're using floating-point arithmetic, you may use *, /, +, -, and exponentiation (e.g., ** or ^ if it's a built-in operator in your language of choice, but only exponentiation of powers not less than 1). This restriction is to prevent "cheating" by calling sqrt() or a variant or raising a value to the ½ power.

If you're using floating-point operations (see #3), you aren't required that the return type be integer; only that that the return value is an integer, e.g., floor(sqrt(n)), and be able to hold any unsigned 32-bit value.

If you're using C/C++, you may assume the existence of unsigned 64-bit and 32-bit integer types, e.g., uint64_t and uint32_t as defined in stdint.h. Otherwise, just make sure your integer type is capable of holding any 64-bit unsigned integer.

If your langauge does not support 64-bit integers (for example, Brainfuck apparently only has 8-bit integer support), then do your best with that and state the limitation in your answer title. That said, if you can figure out how to encode a 64-bit integer and correctly obtain the square root of it using 8-bit primitive arithmetic, then more power to you!

Have fun and get creative!

答:
Tellurium(non-competing), 8 bytes

```<code>@s|Iqg^`
</code>```

This defines a function named s that converts input to an integer (I), calculates the square root (q) and rounds it to the floor (g)

The function can be called using =s.

Alternatively, 7 bytes

```<code>{Iqg^}f
</code>```

This one defines an anonymous function that can be called using ä.

Title: Integer square root of integer

Body:
Tellurium(non-competing), 8 bytes

@s|Iqg^`

This defines a function named s that converts input to an integer (I), calculates the square root (q) and rounds it to the floor (g)

The function can be called using =s.

Alternatively, 7 bytes

{Iqg^}f

This one defines an anonymous function that can be called using ä.


答:
MATL, <s>16</s> <s>15</s> 13 bytes

```<code>Q:Qt!^t!+uSG)
</code>```

Output is 1-based.

Try it online!

Explanation

```<code>Q    % Take input n. Add 1
:Q   % Range [2 ... n+1]. This is enough to be used as x and y
t!   % Duplicate and transpose
^    % Power, element-wise with broadcast. Gives 2D, square array with x^y
     % for all pairs of x and y
t!   % Duplicate and transpose. Gives square array with y^x
+    % Add, element-wise
u    % Keep unique elements. This linearizes (flattens) the 2D array
S    % Sort
G)   % Get the n-th entry. Implicitly display
</code>```

Title: Leyland Numbers

Body:
MATL, <s>16</s> <s>15</s> 13 bytes

Q:Qt!^t!+uSG)

Output is 1-based.

Try it online!

Explanation

Q    % Take input n. Add 1
:Q   % Range [2 ... n+1]. This is enough to be used as x and y
t!   % Duplicate and transpose
^    % Power, element-wise with broadcast. Gives 2D, square array with x^y
     % for all pairs of x and y
t!   % Duplicate and transpose. Gives square array with y^x
+    % Add, element-wise
u    % Keep unique elements. This linearizes (flattens) the 2D array
S    % Sort
G)   % Get the n-th entry. Implicitly display


Title: Leyland Numbers

Body:
J, <s>38</s> 31 bytes

0-indexed.

<s>[{[:(#~~:)@/:~@,/[:(+|:)[:^/~2+i.@>:@]</s>
((#~~:)/:~,/(+|:)^/~2+i.29x){~[

Usage

>> f =: ((#~~:)/:~,/(+|:)^/~2+i.29x){~[
>> f 81
<< 1996813914


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

```<code>r=range(2,32);f=lambda n:sorted({x**y+y**x for x in r for y in r})[n]
</code>```

0-indexed.

https://repl.it/C2SA

Title: Leyland Numbers

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

r=range(2,32);f=lambda n:sorted({x**y+y**x for x in r for y in r})[n]

0-indexed.

https://repl.it/C2SA


答:
Jelly, 14 bytes

2 bytes thanks to Dennis.

```<code>R‘*€¹$+Z$FṢQị@
</code>```

Try it online! (Takes ~ 1s for 82 for me) (O(n^2) time)

Original 16-byte answer

```<code>2r30*€¹$+Z$FṢQị@
</code>```

Try it online! (Takes < 1s for me) (Constant time)

Title: Leyland Numbers

Body:
Jelly, 14 bytes

2 bytes thanks to Dennis.

R‘*€¹$+Z$FṢQị@

Try it online! (Takes ~ 1s for 82 for me) (O(n^2) time)

Original 16-byte answer

2r30*€¹$+Z$FṢQị@

Try it online! (Takes < 1s for me) (Constant time)