答:
Pyth, <s>60</s> <s>53</s> <s>52</s> <s>46</s> <s>42</s> <s>39</s> <s>38</s> <s>36</s> <s>34</s> <s>32</s> 31 bytes

39: It is now on par with the bug-fixed version of Jelly, and I have out-golfed Dennis' competing version!

38: I have out-golfed Dennis!

36: I have out-golfed Dennis again!

34: Even lower than his bug-fixed version!

31: 32 -> 31 thanks to Dennis.

```
<s>J1K.u+N=J_WsI@Y2JtQZjsM.t.e++*]*dl`hkabhSK`hk*]*dl`hkabeSKKd</s>
<s>J1K.u+N=J_WsI@Y2JtQZjsM.t.eX*]*dl`hkhaeSKhSKabhSKhkKd</s>
<s>J1K.u+N=J_WsI@Y2JtQZ=-RhSKKjsM.t.eX*]*dl`hkheSKbhkKd</s>
<s>J1K.u+N=J_WsI@Y2JtQQj-#dsMC.eX*]*dl`hkheSKbhkK</s>
<s>J1j-#dsMC.eX*]*dl`hkyQ+Qbhkm=+Z=J_WsI@td2J</s>
<s>J1j-#dsMCmX*]*;l`hdyQ+Q=+Z=J_WsI@td2Jhd</s>
<s>J1j-#dsMCmX*]*;l`hdyQ+Q=+Z=J_WsI@td2Jh</s>
<s>J1j-#dsMCmX*]*;l`hdyQ+Q=+Z=@_BJsI@td2h</s>
<s>j-#dsMCmX*]*;l`hdyQ+Q=+Zsty%s@td2 2h</s>
<s>j-#dsMCmX*]*;l`hdyQ+Q=+Z@_B1.E@d2h</s>
<s>JQj-#dsMCmX*]*;l`hdyQ=+J@_B1.E@d2h</s>
<s>JyQj-#dsMCmX*]*;l`hdJ=+Q@_B1.E@d2h</s>
<s>j-#dsMCmX*]*;l`hdyQ=+Q@_B1.E@d2h</s>
j-#dsMCmX*]*;l`hdyQ=+Q^_1.E@d2h
```

Try it online!

How it works

```<code>j-#dsMCmX*]*;l`hdyQ=+Q^_1.E@d2h      input: Q
j-#dsMCmX*]*;l`hdyQ=+Q^_1.E@d2hdQ    implicit filling arguments

       m                        Q    for each number d from 0 to Q-1:
                           @d2           yield the square root of d.
                         .E              yield its ceiling.
                      ^_1                raise -1 to that power. this
                                         yields the desired direction.
                   =+Q                   increment Q by this amount.

               hd                        yield d+1.
              `                          yield its string representation.
             l                           yield its length.
           *;                            repeat " " for that number of times
          ]                              yield a list containing the string above.
         *       yQ                      repeat the list for Q*2 times.
                                         the Q has changed, but Q*2 is
                                         an overshoot that is high
                                         enough, so we don't have to
                                         worry about it.

        X                                in that list, replace the
                                         element with index being the
                                         number generated above
                              hd         with d+1.

      C                              transpose the resulting array.
    sM                               flatten each element.
 -#d                                 remove lines containing only spaces.
                                     (filter on truthiness of set difference with space)
j                                    join by newlines.
</code>```

Title: The Ever Amplifying Zigzag

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

Body:
Pyth, <s>60</s> <s>53</s> <s>52</s> <s>46</s> <s>42</s> <s>39</s> <s>38</s> <s>36</s> <s>34</s> <s>32</s> 31 bytes

39: It is now on par with the bug-fixed version of Jelly, and I have out-golfed Dennis' competing version!

38: I have out-golfed Dennis!

36: I have out-golfed Dennis again!

34: Even lower than his bug-fixed version!

31: 32 -> 31 thanks to Dennis.

<s>J1K.u+N=J_WsI@Y2JtQZjsM.t.e++*]*dl`hkabhSK`hk*]*dl`hkabeSKKd</s>
<s>J1K.u+N=J_WsI@Y2JtQZjsM.t.eX*]*dl`hkhaeSKhSKabhSKhkKd</s>
<s>J1K.u+N=J_WsI@Y2JtQZ=-RhSKKjsM.t.eX*]*dl`hkheSKbhkKd</s>
<s>J1K.u+N=J_WsI@Y2JtQQj-#dsMC.eX*]*dl`hkheSKbhkK</s>
<s>J1j-#dsMC.eX*]*dl`hkyQ+Qbhkm=+Z=J_WsI@td2J</s>
<s>J1j-#dsMCmX*]*;l`hdyQ+Q=+Z=J_WsI@td2Jhd</s>
<s>J1j-#dsMCmX*]*;l`hdyQ+Q=+Z=J_WsI@td2Jh</s>
<s>J1j-#dsMCmX*]*;l`hdyQ+Q=+Z=@_BJsI@td2h</s>
<s>j-#dsMCmX*]*;l`hdyQ+Q=+Zsty%s@td2 2h</s>
<s>j-#dsMCmX*]*;l`hdyQ+Q=+Z@_B1.E@d2h</s>
<s>JQj-#dsMCmX*]*;l`hdyQ=+J@_B1.E@d2h</s>
<s>JyQj-#dsMCmX*]*;l`hdJ=+Q@_B1.E@d2h</s>
<s>j-#dsMCmX*]*;l`hdyQ=+Q@_B1.E@d2h</s>
j-#dsMCmX*]*;l`hdyQ=+Q^_1.E@d2h

Try it online!

How it works

j-#dsMCmX*]*;l`hdyQ=+Q^_1.E@d2h      input: Q
j-#dsMCmX*]*;l`hdyQ=+Q^_1.E@d2hdQ    implicit filling arguments

       m                        Q    for each number d from 0 to Q-1:
                           @d2           yield the square root of d.
                         .E              yield its ceiling.
                      ^_1                raise -1 to that power. this
                                         yields the desired direction.
                   =+Q                   increment Q by this amount.

               hd                        yield d+1.
              `                          yield its string representation.
             l                           yield its length.
           *;                            repeat " " for that number of times
          ]                              yield a list containing the string above.
         *       yQ                      repeat the list for Q*2 times.
                                         the Q has changed, but Q*2 is
                                         an overshoot that is high
                                         enough, so we don't have to
                                         worry about it.

        X                                in that list, replace the
                                         element with index being the
                                         number generated above
                              hd         with d+1.

      C                              transpose the resulting array.
    sM                               flatten each element.
 -#d                                 remove lines containing only spaces.
                                     (filter on truthiness of set difference with space)
j                                    join by newlines.


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

答:
Python, 37 50, 46, 32, 26  bytes

```<code>lambda a:a%1==0and a*~-a/2
</code>```

Making use of the fact that the solution of the handshake problem is (N-1) + (N-2) ... 2 + 1 for N people. The most problematic is the falsey value when a non-int is given.

Big thanks to Leaky Nun and Martin Ender!

ContentLicense: CC BY-SA 3.0

Title: The handshake problem

Body:
Python, 37 50, 46, 32, 26  bytes

lambda a:a%1==0and a*~-a/2

Making use of the fact that the solution of the handshake problem is (N-1) + (N-2) ... 2 + 1 for N people. The most problematic is the falsey value when a non-int is given.

Big thanks to Leaky Nun and Martin Ender!


答:
Jelly, 2 bytes

```<code>c2
</code>```

Try it online!

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:
Jelly, 2 bytes

c2

Try it online!


答:
Pyth, 7 bytes

```
<s>?sIQ.cQ2Z</s>
.x.cQ2Z
```

Test suite.

Title: The handshake problem

Body:
Pyth, 7 bytes

<s>?sIQ.cQ2Z</s>
.x.cQ2Z

Test suite.


答:
05AB1E, 2 bytes

Code:

```<code>2c
</code>```

Try it online!.

Title: The handshake problem

Body:
05AB1E, 2 bytes

Code:

2c

Try it online!.


问:
Partition of a positive integer N
Find the number of partitions of a positive integer n. Hope someone uses the explicit finite formula for the partition function defined in Jan Hendrik Brunier and Ken Ono paper here.

```<code>Sample Input
8
Sample Output
22
</code>```

N is less than or equal to 1000.
Write the complete program. More than anything I would like to see the different approaches.

答:
Java Solution

```<code> public class IntegerPartition {
        public static void main(String[] args) {
            int n = 8; //set integer here!!
            int[][] a = new int[n + 1][n + 1];
            int i, j, k;
            for (i = 0; i < a.length; i++) {
                a[i][0] = 0;
                a[0][i] = 1;
            }
            for (i = 1; i < a.length; i++) {
                a[i][1] = 1;
                for (j = 2; j < a[0].length; j++) {
                    k = i - j;
                    if (k < 0)
                        a[i][j] = a[i][j - 1];
                    else
                        a[i][j] = a[i][j - 1] + a[k][j];
                }
            }
            i--;
            int answer = a[i][i - 1];
            System.out.println(answer + 1);
        }
    }
</code>```

ContentLicense: CC BY-SA 2.5

Title: Partition of a positive integer N

Body:
Java Solution

 public class IntegerPartition {
        public static void main(String[] args) {
            int n = 8; //set integer here!!
            int[][] a = new int[n + 1][n + 1];
            int i, j, k;
            for (i = 0; i < a.length; i++) {
                a[i][0] = 0;
                a[0][i] = 1;
            }
            for (i = 1; i < a.length; i++) {
                a[i][1] = 1;
                for (j = 2; j < a[0].length; j++) {
                    k = i - j;
                    if (k < 0)
                        a[i][j] = a[i][j - 1];
                    else
                        a[i][j] = a[i][j - 1] + a[k][j];
                }
            }
            i--;
            int answer = a[i][i - 1];
            System.out.println(answer + 1);
        }
    }


答:
MATL, 3 bytes

```<code>2Xn
</code>```

Try it online!

The code computes the binomial coefficient "n choose 2", where n is the input. For non-integer input no output is produced.

```<code>       % Take input implicitly
2      % Push 2
Xn     % n-choose-k
       % Display implicitly
</code>```

Title: The handshake problem

Body:
MATL, 3 bytes

2Xn

Try it online!

The code computes the binomial coefficient "n choose 2", where n is the input. For non-integer input no output is produced.

       % Take input implicitly
2      % Push 2
Xn     % n-choose-k
       % Display implicitly


答:
CJam, 7 bytes

```<code>ri_(*2/
</code>```

Computes n*(n−1), where n is the input. For non-integer input it produces no output.

Try it online!

```<code>r     e# Read input
i     e# Convert to integer
_     e# Duplicate
(     e# Subtract 1
*     e# Multiply
2/    e# Divide by 2.
      e# Implicit display
</code>```

Title: The handshake problem

Body:
CJam, 7 bytes

ri_(*2/

Computes n*(n−1), where n is the input. For non-integer input it produces no output.

Try it online!

r     e# Read input
i     e# Convert to integer
_     e# Duplicate
(     e# Subtract 1
*     e# Multiply
2/    e# Divide by 2.
      e# Implicit display


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

答:
Matlab, 24 bytes

```<code>@(u,v)(u+v)/(1+v*u/9e16)
</code>```

Anonymous function that takes two inputs. Nothing fancy, just submitted for completeness.

ContentLicense: CC BY-SA 4.0

Title: Calculate the relativistic velocity

Body:
Matlab, 24 bytes

@(u,v)(u+v)/(1+v*u/9e16)

Anonymous function that takes two inputs. Nothing fancy, just submitted for completeness.


答:
Oracle SQL 11.2, 39 bytes

SELECT (:v+:u)/(1+:v*:u/9e16)FROM DUAL;
```

Title: Calculate the relativistic velocity

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


答:
CJam, 16 Bytes

```<code>q~_:+\:*9.e16/)/
</code>```

I'm still sure there are bytes to be saved here

Title: Calculate the relativistic velocity

Body:
CJam, 16 Bytes

q~_:+\:*9.e16/)/

I'm still sure there are bytes to be saved here


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

答:
TSQL(sqlserver 2016) <s>310</s> <s>294</s> 280 bytes

What a wonderful opportunity to write ugly code:

Golfed:

```<code>DECLARE @ varchar(max)= '5,5,5'
DECLARE @a varchar(20) = '125'

,@ varchar(max)='';WITH D as(SELECT @a a UNION ALL SELECT STUFF(a,charindex(',',a),1,value)FROM STRING_SPLIT('*,+,./,-,',',')x,d WHERE a like'%,%')SELECT @+=a+','''+REPLACE(a,'.','')+'''),('FROM D WHERE a not like'%,%'EXEC('SELECT y FROM(values('+@+'null,null))g(x,y)WHERE x='+@b)
</code>```

Try it online

Readable:(insertion of decimal point(.) and removal of the same is necessary in order for sql to accept that 4/5 is not 0 - well removal is for the people testing it)

```<code>DECLARE @a varchar(max)= '5,5,5'
DECLARE @b varchar(20) = '5'

,@ varchar(max)=''
;WITH D as
(
  SELECT @a a
  UNION ALL
  SELECT STUFF(a,charindex(',',a),1,value)
  FROM STRING_SPLIT('*,+,./,-,',',')x,d
  WHERE a like'%,%'
)
SELECT @+=a+','''+REPLACE(a,',','')+'''),('
FROM D
WHERE a not like'%,%'

EXEC('SELECT y FROM(values('+@+'null,null))g(x,y)WHERE x='+@b)
</code>```

This solution can also handle these types of input:

Input :[1,2,3,4,5] 0 Output : 12-3-4-5

Title: Find operations required to get result

Body:
TSQL(sqlserver 2016) <s>310</s> <s>294</s> 280 bytes

What a wonderful opportunity to write ugly code:

Golfed:

DECLARE @ varchar(max)= '5,5,5'
DECLARE @a varchar(20) = '125'

,@ varchar(max)='';WITH D as(SELECT @a a UNION ALL SELECT STUFF(a,charindex(',',a),1,value)FROM STRING_SPLIT('*,+,./,-,',',')x,d WHERE a like'%,%')SELECT @+=a+','''+REPLACE(a,'.','')+'''),('FROM D WHERE a not like'%,%'EXEC('SELECT y FROM(values('+@+'null,null))g(x,y)WHERE x='+@b)

Try it online

Readable:(insertion of decimal point(.) and removal of the same is necessary in order for sql to accept that 4/5 is not 0 - well removal is for the people testing it)

DECLARE @a varchar(max)= '5,5,5'
DECLARE @b varchar(20) = '5'

,@ varchar(max)=''
;WITH D as
(
  SELECT @a a
  UNION ALL
  SELECT STUFF(a,charindex(',',a),1,value)
  FROM STRING_SPLIT('*,+,./,-,',',')x,d
  WHERE a like'%,%'
)
SELECT @+=a+','''+REPLACE(a,',','')+'''),('
FROM D
WHERE a not like'%,%'

EXEC('SELECT y FROM(values('+@+'null,null))g(x,y)WHERE x='+@b)

This solution can also handle these types of input:

Input :[1,2,3,4,5] 0 Output : 12-3-4-5


答:
PowerShell v2+, 33 bytes

```<code>param($n)$n*($n-1)/2*($n-is[int])
</code>```

Full program. 20 bytes to compute n(n-1)/2 and 13 bytes to validate input. Uses the -is operator, so requires V2 or newer.

Title: The handshake problem

Body:
PowerShell v2+, 33 bytes

param($n)$n*($n-1)/2*($n-is[int])

Full program. 20 bytes to compute n(n-1)/2 and 13 bytes to validate input. Uses the -is operator, so requires V2 or newer.


答:
CJam, 5 bytes

```<code>ri,1b
</code>```

Prints nothing (except to STDERR) for non-integer input.

Try it online!

Explanation

```<code>ri  e# Read input and try to convert to integer N.
,   e# Turn into range [0 1 2 ... n-1].
1b  e# Sum the list by treating it as base-1 digits. We do this instead of
    e# a simple reduction (:+) because the latter fails for empty lists.
</code>```

Title: The handshake problem

Body:
CJam, 5 bytes

ri,1b

Prints nothing (except to STDERR) for non-integer input.

Try it online!

Explanation

ri  e# Read input and try to convert to integer N.
,   e# Turn into range [0 1 2 ... n-1].
1b  e# Sum the list by treating it as base-1 digits. We do this instead of
    e# a simple reduction (:+) because the latter fails for empty lists.


答:
Mathematica, 19 bytes

```<code>#(#-1)/2/._Real->0&
</code>```

This first computes the result using the explicit formula n(n-1)/2 but then replaces it with 0 if the that gives a floating-point result.

Just for fun, some alternatives to computing the result (minus the input validation) are:

```<code>#~Binomial~2
Tr@Range@#-#
n~Sum~{n,#-1}
PolygonalNumber@#-#
</code>```

Title: The handshake problem

Body:
Mathematica, 19 bytes

#(#-1)/2/._Real->0&

This first computes the result using the explicit formula n(n-1)/2 but then replaces it with 0 if the that gives a floating-point result.

Just for fun, some alternatives to computing the result (minus the input validation) are:

#~Binomial~2
Tr@Range@#-#
n~Sum~{n,#-1}
PolygonalNumber@#-#


答:
J, <s>14</s> 8 bytes

```<code>2&!*]=<.
</code>```

6 bytes saved thanks to miles!

Explaination:

```<code>2&!      NB. Binomial coefficient of 2 and the argument
   *     NB. Times...
    ]=<. NB. argument == floor(argument)
</code>```

Previous solution: -:@(*<:)*(=<.)

Title: The handshake problem

Body:
J, <s>14</s> 8 bytes

2&!*]=<.

6 bytes saved thanks to miles!

Explaination:

2&!      NB. Binomial coefficient of 2 and the argument
   *     NB. Times...
    ]=<. NB. argument == floor(argument)

Previous solution: -:@(*<:)*(=<.)


答:
Dyalog APL, 11 bytes

```<code>+÷1+9E16÷⍨×
</code>```

The fraction of the sum and [the increment of the divides of ninety quadrillion and the product]:

```<code>┌─┼───┐
+ ÷ ┌─┼──────┐
    1 + ┌────┼──┐
        9E16 ÷⍨ ×

</code>```

÷⍨ is "divides", as in "ninety quadrillion divides n" i.e equivalent to n divided by ninety quadrillion.

Title: Calculate the relativistic velocity

Body:
Dyalog APL, 11 bytes

+÷1+9E16÷⍨×

The fraction of the sum and [the increment of the divides of ninety quadrillion and the product]:

┌─┼───┐
+ ÷ ┌─┼──────┐
    1 + ┌────┼──┐
        9E16 ÷⍨ ×

÷⍨ is "divides", as in "ninety quadrillion divides n" i.e equivalent to n divided by ninety quadrillion.


答:
JavaScript ES6, 16

n=>n%1?0:~-n*n/2
```

<p><em>Test</em></p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>f=n=>n%1?0:~-n*n/2

function test()
{
  var i=I.value
  O.textContent=f(i)
}  </code>```

<input id=I oninput=test()>```

Title: The handshake problem

Body:
JavaScript ES6, 16

n=>n%1?0:~-n*n/2

Test

f=n=>n%1?0:~-n*n/2

function test()
{
  var i=I.value
  O.textContent=f(i)
}

<input id=I oninput=test()><span id=O></span>


答:
Dyalog APL, 9 bytes

```<code>2∘!×(|=⌊)
</code>```

The chose-2 times (whether the abs equals the floor).

Title: The handshake problem

Body:
Dyalog APL, 9 bytes

2∘!×(|=⌊)

The chose-2 times (whether the abs equals the floor).


答:
Jelly, 9 bytes

```<code>÷3ȷ8P‘÷@S
</code>```

Try it online! Alternatively, if you prefer fractions, you can execute the same code with M.

How it works

```<code>÷3ȷ8P‘÷@S  Main link. Argument: [u, v]

÷3ȷ8       Divide u and v by 3e8.
    P      Take the product of the quotients, yielding uv ÷ 9e16.
     ‘     Increment, yielding 1 + uv ÷ 9e16.
        S  Sum; yield u + v.
      ÷@   Divide the result to the right by the result to the left.
</code>```

Title: Calculate the relativistic velocity

Body:
Jelly, 9 bytes

÷3ȷ8P‘÷@S

Try it online! Alternatively, if you prefer fractions, you can execute the same code with M.

How it works

÷3ȷ8P‘÷@S  Main link. Argument: [u, v]

÷3ȷ8       Divide u and v by 3e8.
    P      Take the product of the quotients, yielding uv ÷ 9e16.
     ‘     Increment, yielding 1 + uv ÷ 9e16.
        S  Sum; yield u + v.
      ÷@   Divide the result to the right by the result to the left.


答:
Julia, 22 bytes

u\v=(u+v)/(1+u*v/9e16)
```

Try it online!

Title: Calculate the relativistic velocity

Body:
Julia, 22 bytes

u\v=(u+v)/(1+u*v/9e16)

Try it online!


答:
R, 28 bytes

Returns 0 if the input, x, is not an integer

```<code>x=scan();(x%%1==0)*x*(x-1)/2
</code>```

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:
R, 28 bytes

Returns 0 if the input, x, is not an integer

x=scan();(x%%1==0)*x*(x-1)/2


问:
Is my emoji dry?
This is my pet emoji, Billy:

```<code>-_-
</code>```

Emojis don't like to be in the rain, so Billy is sad... Let's draw him an umbrella to make him feel better!

```<code>  /\
 /  \
/    \

  -_-
</code>```

This is good, he is entirely covered by his umbrella! Here is an example where only part of him is covered:

```<code>  /\
 /  \
/    \

     -_-
</code>```

In this case, sections 2 and 3 of his body are exposed to the rain.

Umbrellas come in many shapes and sizes, but they're always made up from a series of ascending slashes / followed by a series of descending backslashes \. For example, these are all valid umbrellas:

```<code>  /\
 /  \
/    \

/\

    /\
   /  \
  /    \
 /      \
/        \
</code>```

And these are not:

```<code>/   \

\/

  \
 / \
/   \

 0\
/  \

//\\
/  \
</code>```

You need to determine which parts of my emoji are exposed to the rain.

Clarifications

Your program (or function) will take a 2d string as input. This can be in whatever format is most convenient or natural to your language. An array of strings, an array of arrays of characters, a string with newlines in it etc.

You must output which sections of the emoji are exposed to the rain. This can be zero-indexed or one-indexed, as long as you make this clear. Output can be in any reasonable format. If the entire emoji is protected from the rain, output nothing (or an empty array).

You can assume that all inputs will have a valid umbrella, and the same emoji: -_-. The emoji will always be on the last line of the input, however their might be several empty lines between the umbrella and the emoji.

Everything that isn't part of the umbrella or the emoji will be a space   character or newline.

The input will be padded with spaces so that the length of each line is the same.

Standard loopholes apply, and the shortest answer in bytes wins!

Test IO:

All of the sample cases will use one-indexing.

```<code>  /\
 /  \
/    \

  -_-

Outputs: []

----------------

   /\
  /  \

     -_-

Outputs: [2, 3]

----------------

    /\
   -_-

Outputs: [1]

----------------

     /\
    /  \
   /    \
  /      \
 /        \
/          \

               -_-

Outputs: [1, 2, 3]
</code>```

答:
JavaScript (ES6), <s>117</s> 112 bytes

```<code>s=>s.map(r=>r.map((c,i)=>~'-_'[o='indexOf'](c)&&!s.some(a=>~'/\\'[o](a[i]))?i-r[o]('-'):-1)).pop().filter(n=>~n)
</code>```

Accepts a ragged array of <s>strings</s> arrays of characters, and returns 0-indexed results.

```<code>s=>s.map(     // for each row
  r=>         // row
    r.map(    // for each character
      (c,i)=> // character, index
        ~'-_'[o='indexOf'](c) // if character is part of emoji
        &&                    // and
        !s.some(              // none of the rows have umbrella in this column
          a=>~'/\\'[o](a[i])
        )
        ? // then return 0-index of emoji
          i-r[o]('-')
        : // else return -1
          -1
  )
)
.pop()         // get last element of string array
.filter(n=>~n) // filter out -1s
</code>```

Demo

f=s=>s.map(r=>r.map((c,i)=>~'-_'[x='indexOf'](c)&&!s.some(a=>~'/\\'[x](a[i]))?i-r[x]('-'):-1)).pop().filter(n=>~n)
i.oninput=()=>o.value=f(i.value.split`\n`.map(r=>r.split``))
i.oninput()```
<pre class="snippet-code-html lang-html prettyprint-override"><code><textarea rows=6 cols=20 id=i>
   /\
  /  \

     -_-</textarea>
<br/>
<input readonly id=o></code>```

Title: Is my emoji dry?

Body:
JavaScript (ES6), <s>117</s> 112 bytes

s=>s.map(r=>r.map((c,i)=>~'-_'[o='indexOf'](c)&&!s.some(a=>~'/\\'[o](a[i]))?i-r[o]('-'):-1)).pop().filter(n=>~n)

Accepts a ragged array of <s>strings</s> arrays of characters, and returns 0-indexed results.

s=>s.map(     // for each row
  r=>         // row
    r.map(    // for each character
      (c,i)=> // character, index
        ~'-_'[o='indexOf'](c) // if character is part of emoji
        &&                    // and
        !s.some(              // none of the rows have umbrella in this column
          a=>~'/\\'[o](a[i])
        )
        ? // then return 0-index of emoji
          i-r[o]('-')
        : // else return -1
          -1
  )
)
.pop()         // get last element of string array
.filter(n=>~n) // filter out -1s

Demo

f=s=>s.map(r=>r.map((c,i)=>~'-_'[x='indexOf'](c)&&!s.some(a=>~'/\\'[x](a[i]))?i-r[x]('-'):-1)).pop().filter(n=>~n)
i.oninput=()=>o.value=f(i.value.split`\n`.map(r=>r.split``))
i.oninput()

<textarea rows=6 cols=20 id=i>
   /\
  /  \

     -_-</textarea>
<br/>
<input readonly id=o>


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

答:
Jelly, 59 bytes

```<code>ṣ”/VµÆDf/2ị:@µÐĿị1¦€“£ṢtẒ⁽ẹ½MḊxɲȧėAṅ ɓaṾ¥D¹ṀẏD8÷ṬØ»ṣ⁶¤j€⁶j⁷
</code>```

Try it online!

How it works

```<code>ṣ”/VµÆDf/2ị:@µÐĿị1¦€“...»ṣ⁶¤j€⁶j⁷  Main link. Argument: mm/dd

ṣ”/                                Split at slashes.
   V                               Eval each chunk, yielding [m, d] (integers).
    µ                              Begin a new, monadic chain. Argument: [m, d]
             µÐĿ                   Execute the chain to the left until the results
                                   are no longer unique. Yield the list of all
                                   intermediate results.
     ÆD                              Compute the divisors of each number.
       f/                            Intersect them.
         2ị                          Select the one at index 2. If there is only
                                     one divisor, ị wraps around and selects 1.
           :@                        Divide [m, d] by this common divisor.
                        ¤            Combine the links to the left into a chain.
                 “...»                 Yield the month's name, space-separated.
                      ṣ⁶               Split at spaces.
                €                    For each pair...
             ị                          index into the month's names...
              1¦                        for the first element.
                         j⁶€         Join each pair, separating by spaces.
                            j⁷       Join, separating by linefeeds.
</code>```

Title: Simplify a Date

Body:
Jelly, 59 bytes

ṣ”/VµÆDf/2ị:@µÐĿị1¦€“£ṢtẒ⁽ẹ½MḊxɲȧėAṅ ɓaṾ¥D¹ṀẏD8÷ṬØ»ṣ⁶¤j€⁶j⁷

Try it online!

How it works

ṣ”/VµÆDf/2ị:@µÐĿị1¦€“...»ṣ⁶¤j€⁶j⁷  Main link. Argument: mm/dd

ṣ”/                                Split at slashes.
   V                               Eval each chunk, yielding [m, d] (integers).
    µ                              Begin a new, monadic chain. Argument: [m, d]
             µÐĿ                   Execute the chain to the left until the results
                                   are no longer unique. Yield the list of all
                                   intermediate results.
     ÆD                              Compute the divisors of each number.
       f/                            Intersect them.
         2ị                          Select the one at index 2. If there is only
                                     one divisor, ị wraps around and selects 1.
           :@                        Divide [m, d] by this common divisor.
                        ¤            Combine the links to the left into a chain.
                 “...»                 Yield the month's name, space-separated.
                      ṣ⁶               Split at spaces.
                €                    For each pair...
             ị                          index into the month's names...
              1¦                        for the first element.
                         j⁶€         Join each pair, separating by spaces.
                            j⁷       Join, separating by linefeeds.


答:
Brainfuck, <s>22</s> 21 bytes

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

Try it online! Note, that brainfuck takes input and output through ASCII, so to enter a "49", you enter ascii value 49, e.g. 1. Brainfuck has no concept of non-integers, so it is impossible to enter one.

Title: The handshake problem

Body:
Brainfuck, <s>22</s> 21 bytes

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

Try it online! Note, that brainfuck takes input and output through ASCII, so to enter a "49", you enter ascii value 49, e.g. 1. Brainfuck has no concept of non-integers, so it is impossible to enter one.


答:
APL, 31 bytes

```<code>{(⍳3)∩,(~∨⌿⍵∊'/\')/+\+\'-_-'⍷⍵}
</code>```

This takes a character matrix as input.

Tests:

```<code>      t1 t2 t3 t4
┌──────┬────────┬──────┬─────────────────┐
│  /\  │   /\   │    /\│     /\          │
│ /  \ │  /  \  │   -_-│    /  \         │
│/    \│        │      │   /    \        │
│      │     -_-│      │  /      \       │
│  -_- │        │      │ /        \      │
│      │        │      │/          \     │
│      │        │      │                 │
│      │        │      │                 │
│      │        │      │                 │
│      │        │      │                 │
│      │        │      │              -_-│
└──────┴────────┴──────┴─────────────────┘
      {(⍳3)∩,(~∨⌿⍵∊'/\')/+\+\'-_-'⍷⍵} ¨ t1 t2 t3 t4
┌┬───┬─┬─────┐
││2 3│1│1 2 3│
└┴───┴─┴─────┘
</code>```

Explanation:

'-_-'⍷⍵: in a matrix of zeroes the size of the input, mark the position of the beginning of '-_-' in the input with a 1.

+\+\: Running sum over rows. The first one makes 0 0 0 1 0 0 ... into 0 0 0 1 1 1 ..., the second one then makes it into 0 0 0 1 2 3 ....

⍵∊'/\': mark all occurrences of '/' and '\' in the input with 1s.

∨⌿: or over columns. This marks with an 1 all positions on the last row that are covered by the umbrella.

~: not, because we need the opposite

(...)/...: Select all uncovered columns from the running sum matrix from earlier

,: Get a list of all values in the resulting matrix.

(⍳3)∩: Intersection between that and 1 2 3 (this gets rid of any selected 0s or higher values, which would be spaces).

Title: Is my emoji dry?

Body:
This is my pet emoji, Billy:

```<code>-_-
</code>```

Emojis don't like to be in the rain, so Billy is sad... Let's draw him an umbrella to make him feel better!

```<code>  /\
 /  \
/    \

  -_-
</code>```

This is good, he is entirely covered by his umbrella! Here is an example where only part of him is covered:

```<code>  /\
 /  \
/    \

     -_-
</code>```

In this case, sections 2 and 3 of his body are exposed to the rain.

Umbrellas come in many shapes and sizes, but they're always made up from a series of ascending slashes / followed by a series of descending backslashes \. For example, these are all valid umbrellas:

```<code>  /\
 /  \
/    \

/\

    /\
   /  \
  /    \
 /      \
/        \
</code>```

And these are not:

```<code>/   \

\/

  \
 / \
/   \

 0\
/  \

//\\
/  \
</code>```

You need to determine which parts of my emoji are exposed to the rain.

Clarifications

Your program (or function) will take a 2d string as input. This can be in whatever format is most convenient or natural to your language. An array of strings, an array of arrays of characters, a string with newlines in it etc.

You must output which sections of the emoji are exposed to the rain. This can be zero-indexed or one-indexed, as long as you make this clear. Output can be in any reasonable format. If the entire emoji is protected from the rain, output nothing (or an empty array).

You can assume that all inputs will have a valid umbrella, and the same emoji: -_-. The emoji will always be on the last line of the input, however their might be several empty lines between the umbrella and the emoji.

Everything that isn't part of the umbrella or the emoji will be a space   character or newline.

The input will be padded with spaces so that the length of each line is the same.

Standard loopholes apply, and the shortest answer in bytes wins!

Test IO:

All of the sample cases will use one-indexing.

```<code>  /\
 /  \
/    \

  -_-

Outputs: []

----------------

   /\
  /  \

     -_-

Outputs: [2, 3]

----------------

    /\
   -_-

Outputs: [1]

----------------

     /\
    /  \
   /    \
  /      \
 /        \
/          \

               -_-

Outputs: [1, 2, 3]
</code>```

Body:
APL, 31 bytes

{(⍳3)∩,(~∨⌿⍵∊'/\')/+\+\'-_-'⍷⍵}

This takes a character matrix as input.

Tests:

      t1 t2 t3 t4
┌──────┬────────┬──────┬─────────────────┐
│  /\  │   /\   │    /\│     /\          │
│ /  \ │  /  \  │   -_-│    /  \         │
│/    \│        │      │   /    \        │
│      │     -_-│      │  /      \       │
│  -_- │        │      │ /        \      │
│      │        │      │/          \     │
│      │        │      │                 │
│      │        │      │                 │
│      │        │      │                 │
│      │        │      │                 │
│      │        │      │              -_-│
└──────┴────────┴──────┴─────────────────┘
      {(⍳3)∩,(~∨⌿⍵∊'/\')/+\+\'-_-'⍷⍵} ¨ t1 t2 t3 t4
┌┬───┬─┬─────┐
││2 3│1│1 2 3│
└┴───┴─┴─────┘

Explanation:

'-_-'⍷⍵: in a matrix of zeroes the size of the input, mark the position of the beginning of '-_-' in the input with a 1.

+\+\: Running sum over rows. The first one makes 0 0 0 1 0 0 ... into 0 0 0 1 1 1 ..., the second one then makes it into 0 0 0 1 2 3 ....

⍵∊'/\': mark all occurrences of '/' and '\' in the input with 1s.

∨⌿: or over columns. This marks with an 1 all positions on the last row that are covered by the umbrella.

~: not, because we need the opposite

(...)/...: Select all uncovered columns from the running sum matrix from earlier

,: Get a list of all values in the resulting matrix.

(⍳3)∩: Intersection between that and 1 2 3 (this gets rid of any selected 0s or higher values, which would be spaces).


答:
T-SQL, 38 bytes

DECLARE @U REAL=2000000, @ REAL=2000000;
PRINT FORMAT((@U+@)/(1+@*@U/9E16),'g')
```

Try it online!

Straightforward formula implementation.

Title: Calculate the relativistic velocity

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

Body:
T-SQL, 38 bytes

DECLARE @U REAL=2000000, @ REAL=2000000;
PRINT FORMAT((@U+@)/(1+@*@U/9E16),'g')

Try it online!

Straightforward formula implementation.


问:
Excludivisible numbers
Given an integer N, output the Nth positive number K with the following property in decimal base:

For each digit I at position P of K, the number formed from K by removing the Pth digit (i.e. I) is divisible by I.

Example and remarks

324 is such a number:

3 divides 24

2 divides 34

4 divides 32

Note 1: we assume that the empty number is divisible by anything, like 0. Therefore 1, 2, 3, 4, 5, 6, 7, 8 and 9 are valid.

Note 2: K cannot contain the digit 0, since you cannot divide by 0.

Inputs and outputs

You may take the input as a function argument, through STDIN, etc.

You may return the output from a function, through STDOUT, etc.

You may index those numbers starting from 0 (in which case N >= 0) or from 1 (in which case N > 0), whichever suits you more.

Test cases

Those examples are indexed from 0, so if you indexed from 1, then add 1 to the numbers in the N column.

```<code>N    Output
0    1
4    5
8    9
15   77
16   88
23   155
42   742
47   1113
121  4244
144  6888
164  9999
</code>```

Scoring

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

答:
Python 2, 93 bytes

n=input();r=0
while n:r+=1;k=t=1;exec't&=(r/k/10*k+r%k)%(r/k%10or r)<1;k*=10;'*r;n-=t
print r
```

<p><em>Very</em> inefficient. Input is 1-indexed. Test it on Ideone.</p>

<h3>Alternate version, 100 bytes</h3>

<p>The above code performs roughly <strong>10<sup>x</sup></strong> divisibility tests where only <strong>x</strong> are required. At the cost of only <strong>7 extra bytes</strong>, efficiency can be improved dramatically, either by replacing <code>*r</code> with <code>*len(`r`)</code> or by refactoring the code as follows.</p>

<pre class="lang-python prettyprint-override"><code>n=input();r=0
while n:
 r+=1;k=t=1
 for _ in`r`:t&=(r/k/10*k+r%k)%(r/k%10or r)<1;k*=10
 n-=t
print r
</code>```

This handles all test cases with ease, even on Ideone.

Title: Excludivisible numbers

Body:
Python 2, 93 bytes

n=input();r=0
while n:r+=1;k=t=1;exec't&=(r/k/10*k+r%k)%(r/k%10or r)<1;k*=10;'*r;n-=t
print r

Very inefficient. Input is 1-indexed. Test it on Ideone.

Alternate version, 100 bytes

The above code performs roughly 10x divisibility tests where only x are required. At the cost of only 7 extra bytes, efficiency can be improved dramatically, either by replacing *r with *len(`r`) or by refactoring the code as follows.

n=input();r=0
while n:
 r+=1;k=t=1
 for _ in`r`:t&=(r/k/10*k+r%k)%(r/k%10or r)<1;k*=10
 n-=t
print r

This handles all test cases with ease, even on Ideone.


Title: Find operations required to get result

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

Body:
JavaScript (ES6), <s>165</s> 147 bytes

a=>o=>(c=[],i=c=>{for(j=0;!((c[j]?++c[j]:c[j]=1)%5);)c[j++]=0},eval(`while(eval(e=(a+'').replace(/,/g,(_,j)=>'+-*/'.charAt(c[~-j/2])))!=o)i(c);e`))

Nested eval... lovely.

f=a=>o=>(c=[],i=c=>{for(j=0;!((c[j]?++c[j]:c[j]=1)%5);)c[j++]=0},eval(`while(eval(e=(a+'').replace(/,/g,(_,j)=>'+-*/'.charAt(c[~-j/2])))!=o)i(c);e`))
console.log(f([5,5,5,5,5])(100))
console.log(f([1,2,3,4,5])(0))
console.log(f([3,4])(0.75))
console.log(f([3,4,5,6])(339))


答:
Desmos, 11 bytes

```<code>.5nn-.5n
n=1
</code>```

Try it here

Ungolfed formula:

Title: The handshake problem

Body:
Desmos, 11 bytes

.5nn-.5n
n=1

Try it here

Ungolfed formula:


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

答:
Hoon, 22 bytes

```<code>[dif pro]:(ga 8 283 3)
</code>```

Hoon already has a function ++ga that creates Galois Fields, for use in the AES implementation. This returns a tuple of two functions, instead of using two programs.

Operates in the domain [0...255]

Testsuite:

```<code>=+  f=(ga 8 283 3)
=+  n=(gulf 0 255)

=+  a=dif:f
=+  m=pro:f

=+  %+  turn  n
    |=  x/@
    ?>  =((a 0 x) x)
    ?>  =((m 1 x) x)
    ~&  outer+x

    %+  turn  n
      |=  y/@
      ?>  =((a x y) (a y x))
      ?>  &((lte 0 (a x y)) (lte (a x y) 255))
      ?>  &((lte 0 (m x y)) (lte (m x y) 255))

      %+  turn  n
        |=  z/@
        ?>  =((a (a x y) z) (a x (a y z)))
        ?>  =((m x (a y z)) (a (m x y) (m x z)))
        ~
"ok"
</code>```

Posting a multiplication table would be gigantic, so here are some random testcases:

```<code>20x148=229
61x189=143
111x239=181
163x36=29
193x40=1
</code>```

Title: Define a field with 256 elements

Body:
Hoon, 22 bytes

[dif pro]:(ga 8 283 3)

Hoon already has a function ++ga that creates Galois Fields, for use in the AES implementation. This returns a tuple of two functions, instead of using two programs.

Operates in the domain [0...255]

Testsuite:

=+  f=(ga 8 283 3)
=+  n=(gulf 0 255)

=+  a=dif:f
=+  m=pro:f

=+  %+  turn  n
    |=  x/@
    ?>  =((a 0 x) x)
    ?>  =((m 1 x) x)
    ~&  outer+x

    %+  turn  n
      |=  y/@
      ?>  =((a x y) (a y x))
      ?>  &((lte 0 (a x y)) (lte (a x y) 255))
      ?>  &((lte 0 (m x y)) (lte (m x y) 255))

      %+  turn  n
        |=  z/@
        ?>  =((a (a x y) z) (a x (a y z)))
        ?>  =((m x (a y z)) (a (m x y) (m x z)))
        ~
"ok"

Posting a multiplication table would be gigantic, so here are some random testcases:

20x148=229
61x189=143
111x239=181
163x36=29
193x40=1


答:
Hoon, 30 bytes

```<code>|=
n/@
(div (mul n (dec n)) 2)
</code>```

Just compute (n * (n-1))/2.
Hoon is strongly typed, so you can't call this function with a float or negative number.

Title: The handshake problem

Body:
Hoon, 30 bytes

|=
n/@
(div (mul n (dec n)) 2)

Just compute (n * (n-1))/2.
Hoon is strongly typed, so you can't call this function with a float or negative number.


答:
Haskell, 24 bytes

As a single function that can provide either a floating point or fractional number, depending on the context in which it's used...

```<code>r u v=(u+v)/(1+v*u/9e16)
</code>```

Example usage in REPL:

```<code>*Main> r 20 30
49.999999999999666
*Main> default (Rational)
*Main> r 20 30
7500000000000000 % 150000000000001
</code>```

Title: Calculate the relativistic velocity

Body:
Haskell, 24 bytes

As a single function that can provide either a floating point or fractional number, depending on the context in which it's used...

r u v=(u+v)/(1+v*u/9e16)

Example usage in REPL:

*Main> r 20 30
49.999999999999666
*Main> default (Rational)
*Main> r 20 30
7500000000000000 % 150000000000001


问:
What is the smallest positive base 10 integer that can be printed by a program shorter (in characters) than itself?
I think the question as above is clear, but just in case:

Write a full program (not just a function) which prints a positive base 10 integer, optionally followed by a single newline.

Qualifying programs will be those whose output is longer (in bytes) than the source code of the program, measured in bytes (assuming ASCII or UTF-8 encoding for the program source code).

I.e. the code must be shorter than the number of digits in the resulting number.

Leading zeros are disallowed under all circumstances. Counting leading zeroes trivialises the problem; ignoring leading zeros unnecessarily complicates the question.

The winning program will be the qualifying program which prints the integer with the smallest magnitude.

Leaderboard snippet

var QUESTION_ID = 67921;
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
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) { if (data.has_more) getComments(); else if (more_answers) getAnswers(); else process(); } }); }
getAnswers();
var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*)(?:,|[-\u2013] ).*?([\d,^!e+]+)(?=\:?[^\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.replace(/([^\n<]*)<\/sup>/g, "^$1").replace(/\(\d+(?:\^\d+,)? [\w\s]+\)/g, "").replace(/floor\(10\^(\d+)\/9\)/g, "$1 ones").replace(/(\d+) ones/g, function (_, x) { return Array(+x + 1).join(1); }).match(SCORE_REG); if (match) valid.push({ user: getAuthorName(a), size: +match[2].replace(/,/g, "").replace(/(\d+)\s*\^\s*(\d+)/, function (_, a, b) { return Math.pow(a, b); }).replace(/(\d+)!/, function (_, n) { for (var i = 1, j = 1; i <= n; i++) j *= i; return j; }), language: match[1], link: a.share_link, }); else console.log(body); }); 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; lang = jQuery(''+lang+'').text(); languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang.toLowerCase(), user: a.user, size: a.size, link: a.link}; }); var langs = []; for (var lang in languages) if (languages.hasOwnProperty(lang)) langs.push(languages[lang]); langs.sort(function (a, b) { if (a.lang_raw > b.lang_raw) return 1; if (a.lang_raw < b.lang_raw) 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-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<style>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; }</style>
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">
<div id="language-list"> <h2>Shortest Solution by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr> </thead> <tbody id="languages"> </tbody> </table> </div> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr> </thead> <tbody id="answers"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td>Link</td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td>Link</td></tr> </tbody> </table></code>```

Body:
Desmos, 6561

9^4

equals 6561

previous answer, 1048576

2^{20}

equals 1048576


答:
Python, <s>195</s> 186 bytes

Here's an atrocious way of doing it.

```<code>def x(i,r):
 t=""
 from random import choice as c
 while True:
  for j in i:
   t+=str(j)
   if c([0,1]):t+="."+c("+-/*")
  t=t.strip("+-*/.")+"."
  v=eval(t)
  if v == r:print t
  t=""
</code>```

The function x accepts an argument of a list and a result - x([1,2,3,4,5], 15) for example.

The program begins a loop where we begin randomly selecting if we should append "+", "-", "*", or "/" between each number, or if we should concatenate them together. This seemed like a more concise option than actually going through permutations and trying every combination to find every result, and although it takes longer to run and is much less efficient. (Fortunately that's not a concern in this context!)

It also appends "." to each number to avoid doing integer-rounded operations like 6/4 = 1. It then evals our expression and determines if the result equal to what we are expecting, and if so, outputs the expression.

This program never exits - it will keep continually outputting results until killed.

EDIT 1: Remove unnecessary newlines where one-line if statements can be used.

Title: Find operations required to get result

Body:
Python, <s>195</s> 186 bytes

Here's an atrocious way of doing it.

def x(i,r):
 t=""
 from random import choice as c
 while True:
  for j in i:
   t+=str(j)
   if c([0,1]):t+="."+c("+-/*")
  t=t.strip("+-*/.")+"."
  v=eval(t)
  if v == r:print t
  t=""

The function x accepts an argument of a list and a result - x([1,2,3,4,5], 15) for example.

The program begins a loop where we begin randomly selecting if we should append "+", "-", "*", or "/" between each number, or if we should concatenate them together. This seemed like a more concise option than actually going through permutations and trying every combination to find every result, and although it takes longer to run and is much less efficient. (Fortunately that's not a concern in this context!)

It also appends "." to each number to avoid doing integer-rounded operations like 6/4 = 1. It then evals our expression and determines if the result equal to what we are expecting, and if so, outputs the expression.

This program never exits - it will keep continually outputting results until killed.

EDIT 1: Remove unnecessary newlines where one-line if statements can be used.


问:
Send a cosmic call
The cosmic call is a message sent into space in 1999 and 2003.
It's made of 23 127*127px monochrome bitmap images, as detailed here.

Your mission is to write a program that displays the entire 127*2921px message, either as a text (made of zeros, ones and line breaks) or as an image (drawn on screen or saved on disk). There will be two categories of winners: one for text output and one for image output.

All the tricks are permitted, except common loopholes.

It is allowed to output the 23 pages separately.

It is allowed to write up to 23 programs (like, one for each page) and sum their size to determine your score.

It is allowed to use up to 23 binary files alongside your program(s). Their weight is counted in your score.

The shortest code (in byte) wins.

At 1 bit per pixel, the image contains 127*127*23/8 = 46370 bytes + 7 bits of data. (warning: it's not allowed to output an extra zero if you store pixel values into 46371 bytes)

Trailing newline/space is allowed for the text output.

Visual output can not contain any black pixel besides the black pixels of the cosmic call. It can be drawn in one column (ordered correctly), or split in 23 images, or animated (like a gif), also ordered correctly.

Attachment: the text output, and the image output to reproduce:

答:
Python 3, 64513 bytes

Use only ASCII !

http://pastebin.com/PMLb4Xti

Old version, 64529 bytes:
http://pastebin.com/nteYkUtM

Title: Send a cosmic call


答:
AWK, 1e21

I didn't see an AWK answer, so here's mine.

Since a 'full program' was requested, this is the best I could come up with (full program is a bit fuzzy in AWK).

```<code>awk '{$0=1e21}1'<<<1
</code>```

If we don't consider how the program is called as part of the program, then the score could be dropped to about 1e13 using:

```<code> '{$0=1e13}1'
</code>```

Title: What is the smallest positive base 10 integer that can be printed by a program shorter (in characters) than itself?

Body:
I think the question as above is clear, but just in case:

Write a full program (not just a function) which prints a positive base 10 integer, optionally followed by a single newline.

Qualifying programs will be those whose output is longer (in bytes) than the source code of the program, measured in bytes (assuming ASCII or UTF-8 encoding for the program source code).

I.e. the code must be shorter than the number of digits in the resulting number.

Leading zeros are disallowed under all circumstances. Counting leading zeroes trivialises the problem; ignoring leading zeros unnecessarily complicates the question.

The winning program will be the qualifying program which prints the integer with the smallest magnitude.

Leaderboard snippet

var QUESTION_ID = 67921;
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
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) { if (data.has_more) getComments(); else if (more_answers) getAnswers(); else process(); } }); }
getAnswers();
var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*)(?:,|[-\u2013] ).*?([\d,^!e+]+)(?=\:?[^\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.replace(/([^\n<]*)<\/sup>/g, "^$1").replace(/\(\d+(?:\^\d+,)? [\w\s]+\)/g, "").replace(/floor\(10\^(\d+)\/9\)/g, "$1 ones").replace(/(\d+) ones/g, function (_, x) { return Array(+x + 1).join(1); }).match(SCORE_REG); if (match) valid.push({ user: getAuthorName(a), size: +match[2].replace(/,/g, "").replace(/(\d+)\s*\^\s*(\d+)/, function (_, a, b) { return Math.pow(a, b); }).replace(/(\d+)!/, function (_, n) { for (var i = 1, j = 1; i <= n; i++) j *= i; return j; }), language: match[1], link: a.share_link, }); else console.log(body); }); 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; lang = jQuery(''+lang+'').text(); languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang.toLowerCase(), user: a.user, size: a.size, link: a.link}; }); var langs = []; for (var lang in languages) if (languages.hasOwnProperty(lang)) langs.push(languages[lang]); langs.sort(function (a, b) { if (a.lang_raw > b.lang_raw) return 1; if (a.lang_raw < b.lang_raw) 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-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<style>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; }</style>
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">
<div id="language-list"> <h2>Shortest Solution by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr> </thead> <tbody id="languages"> </tbody> </table> </div> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr> </thead> <tbody id="answers"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td>Link</td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td>Link</td></tr> </tbody> </table></code>```

Body:
AWK, 1e21

I didn't see an AWK answer, so here's mine.

Since a 'full program' was requested, this is the best I could come up with (full program is a bit fuzzy in AWK).

awk '{$0=1e21}1'<<<1

If we don't consider how the program is called as part of the program, then the score could be dropped to about 1e13 using:

 '{$0=1e13}1'


答:
Matlab, 61 23 bytes

```<code>@(x)~mod(x,1)*x*(x-1)/2
</code>```

Improvements courtesy Luis Mendo.

Old answer:

@(x)eval('if isnumeric(x) disp((mod(x,1)==0)*x*(x-1)/2);end')

An anonymous function that calls eval. Matlab considers all numbers entered to be doubles unless you explicitly tell it otherwise, so testing for integerness via built-in isn't really an option unless you want to condition your input heavily-- thus the isnumeric and the mod1.

As well, Matlab doesn't allow conditional statements in anonymous functions, so you have to kludge around that by way of an eval statement that evaluates a string. So fun.

The "falsey" output is that it doesn't print anything at all for nonnumerics and prints 0 for a non-integer numeric. For a valid input, it will print the result.

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:
Matlab, 61 23 bytes

@(x)~mod(x,1)*x*(x-1)/2

Improvements courtesy Luis Mendo.

Old answer:

@(x)eval('if isnumeric(x) disp((mod(x,1)==0)*x*(x-1)/2);end')

An anonymous function that calls eval. Matlab considers all numbers entered to be doubles unless you explicitly tell it otherwise, so testing for integerness via built-in isn't really an option unless you want to condition your input heavily-- thus the isnumeric and the mod1.

As well, Matlab doesn't allow conditional statements in anonymous functions, so you have to kludge around that by way of an eval statement that evaluates a string. So fun.

The "falsey" output is that it doesn't print anything at all for nonnumerics and prints 0 for a non-integer numeric. For a valid input, it will print the result.


答:
ForceLang, 116 bytes

```<code>def r io.readnum()
set s set
s u r
s v r
s w u+v
s c 3e8
s u u.mult v.mult c.pow -2
s u 1+u
io.write w.mult u.pow -1
</code>```

Title: Calculate the relativistic velocity

Body:
ForceLang, 116 bytes

def r io.readnum()
set s set
s u r
s v r
s w u+v
s c 3e8
s u u.mult v.mult c.pow -2
s u 1+u
io.write w.mult u.pow -1


答:
TI-Basic, 21 bytes

```<code>Prompt U,V:(U+V)/(1+UV/9ᴇ16
</code>```

Title: Calculate the relativistic velocity

Body:
TI-Basic, 21 bytes

Prompt U,V:(U+V)/(1+UV/9ᴇ16


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

```

答:
Hoon, 95 bytes

```<code>|=
@
=+
n=(gulf 1 +<)
=+
f=(roll n mul)
(div f d:(egcd f (roll (turn n |=(@ (div f +<))) add)))
</code>```

Create list [1...n], fold over it with ++mul for the factorial, create list [n!/1, n!/2, ... n!/n] and sum it, find GCD of n! and the list, and divide the factorial by that number.

There's probably a much easier way to calculate the denominator, but I can't figure it out :/

Title: Denominator of harmonic series

Body:
Hoon, 95 bytes

|=
@
=+
n=(gulf 1 +<)
=+
f=(roll n mul)
(div f d:(egcd f (roll (turn n |=(@ (div f +<))) add)))

Create list [1...n], fold over it with ++mul for the factorial, create list [n!/1, n!/2, ... n!/n] and sum it, find GCD of n! and the list, and divide the factorial by that number.

There's probably a much easier way to calculate the denominator, but I can't figure it out :/


Title: Define a field with 256 elements

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

Body:
Mathematica 155 bytes

f[y_]:=Total[x^Reverse@Range[0,Log[2,y]]*RealDigits[y,2][[1]]];o[q_,c_,d_]:=FromDigits[Reverse@Mod[CoefficientList[PolynomialMod[q[f@c,f@d],f@283],x],2],2]

Implementation

(*
  in: o[Times, 202, 83]    out: 1
  in: o[Plus, 202, 83]     out: 153
*)

addition check:

(*
  in: BitXor[202, 83]      out: 153
*)

More:

(*
  in: o[Times, #, #2] & @@@ {{20, 148}, {61, 189}, {111, 239}, {163, 36}, {193, 40}}
  out: {229, 143, 181, 29, 1}
*)

NB Should be able to use any of {283, 285, 299, 301, 313, 319, 333, 351, 355, 357, 361, 369, 375, 379, 391, 395, 397, 415, 419, 425, 433, 445, 451, 463, 471, 477, 487, 499, 501, 505} in place of 283.


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

答:
CJam, 11 bytes

```<code>q']/"]$"*~=
</code>```

Try it here.

CJam, 13 bytes

```<code>q~L{{j}%$}j:=
</code>```

Try it here.

Title: Are the two sets equal

Body:
CJam, 11 bytes

q']/"]$"*~=

Try it here.

CJam, 13 bytes

q~L{{j}%$}j:=

Try it here.


答:
Pyth, 9 bytes

```<code>LSyMbqyEy
</code>```

Input format: use [] instead of {}.

Test suite

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:
Pyth, 9 bytes

LSyMbqyEy

Input format: use [] instead of {}.

<a href="https://pyth.herokuapp.com/?code=LSyMbqyEy&test_suite=1&test_suite_input=%5B%5D%0A%5B%5D%0A%5B%5B%5D%2C%5B%5B%5D%5D%5D%0A%5B%5B%5B%5D%5D%2C%5B%5D%5D%0A%5B%5B%5D%2C%5B%5B%5D%2C%5B%5B%5B%5D%5D%2C%5B%5D%5D%5D%5D%0A%5B%5B%5B%5B%5D%2C%5B%5B%5D%5D%5D%2C%5B%5D%5D%2C%5B%5D%5D%0A%5B%5D%0A%5B%5B%5D%5D%0A%5B%5B%5D%2C%5B%5B%5D%2C%5B%5B%5B%5D%5D%2C%5B%5D%5D%5D%5D%0A%5B%5B%5B%5B%5D%5D%5D%2C%5B%5D%2C%5B%5B%5D%5D%5D%0A%5B%5B%5D%2C%5B%5B%5D%5D%2C%5B%5B%5B%5D%5D%5D%2C%5B%5B%5D%2C%5B%5B%5D%5D%5D%5D%0A%5B%5D&debug=0&input_size=2" rel="nofollow">Test suite


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

```

答:
APL, 22 20 18 bytes

The true and false entries are complete programs, and the other 14 are functions. (Thanks to Adám.)

```<code>0000 false              0 (complete program)
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 eq                 =
1010 not q              ~⊢
1011 p or not q         ≥
1100 not p              ~⊣
1101 not p or q         ≤
1110 not p or not q     ⍲
1111 true               1 (complete program)
</code>```

Try it here.

Body:
APL, 22 20 18 bytes

The true and false entries are complete programs, and the other 14 are functions. (Thanks to Adám.)

0000 false              0 (complete program)
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 eq                 =
1010 not q              ~⊢
1011 p or not q         ≥
1100 not p              ~⊣
1101 not p or q         ≤
1110 not p or not q     ⍲
1111 true               1 (complete program)

Try it here.


答:
Jelly, 6 bytes

```<code>ß€Ṣ
ÇE
</code>```

Try it online! or verify all test cases.

How it works

```<code>ÇE   Main link. Argument: [s, t] (pair of set arrays)

Ç    Apply the helper link to [s, t].
 E   Check if the elements of the resulting pair are equal.

ß€Ṣ  Helper link. Argument: u (set array)

ß€   Recursively map this link over u.
  Ṣ  Sort the result.
</code>```

Title: Are the two sets equal

Body:
Jelly, 6 bytes

ß€Ṣ
ÇE

Try it online! or verify all test cases.

How it works

ÇE   Main link. Argument: [s, t] (pair of set arrays)

Ç    Apply the helper link to [s, t].
 E   Check if the elements of the resulting pair are equal.

ß€Ṣ  Helper link. Argument: u (set array)

ß€   Recursively map this link over u.
  Ṣ  Sort the result.


答:
, 7 chars / 9 bytes

```<code>ѨƾꞨî,Ꞩí
</code>```

Try it here (ES6 browsers only).

Explanation

```<code>         // implicit: î=input1,í=input2
  Ꞩî,Ꞩí // apply the Set method to both inputs
Ѩƾ      // check if the Sets are equal
        // implicit output
</code>```

Title: Are the two sets equal

Body:
, 7 chars / 9 bytes

ѨƾꞨî,Ꞩí

Try it here (ES6 browsers only).

Explanation

         // implicit: î=input1,í=input2
  Ꞩî,Ꞩí // apply the Set method to both inputs
Ѩƾ      // check if the Sets are equal
        // implicit output


答:
Python 2, 49 bytes

```<code>f=lambda x:sorted(map(f,x))
lambda a,b:f(a)==f(b)
</code>```

For example, calling the anonymous function g:

```<code>>>> g( [[],[[]]] , [[[]],[]] )
True
</code>```

Title: Are the two sets equal

Body:
Python 2, 49 bytes

f=lambda x:sorted(map(f,x))
lambda a,b:f(a)==f(b)

For example, calling the anonymous function g:

>>> g( [[],[[]]] , [[[]],[]] )
True


答:
Hoon, 246 bytes

```<code>=+
x=0
|=
n/@
=+
k=<x>
=+
%+
levy
%+
turn
(gulf 0 (dec (lent k)))
|=
a/@
=+
(trim +(a) k)
=+
(rash (snag a p) dit)
?:
=(- 0)
|
=(0 (mod (fall (rust (weld (scag a p) q) dem) x) -))
(curr test &)
?:
=(- &)
?:
=(0 n)
x
$(n (dec n), x +(x))
$(x +(x))
</code>```

Ungolfed:

```<code>=+  x=0
|=  n/@
=+  k=<x>
=+  %+  levy
  %+  turn  (gulf 0 (dec (lent k)))
  |=  a/@
  =+  (trim +(a) k)
  =+  (rash (snag a p) dit)
  ?:  =(- 0)
    |
  =(0 (mod (fall (rust (weld (scag a p) q) dem) x) -))
(curr test &)
?:  =(- &)
  ?:  =(0 n)
    x
  $(n (dec n), x +(x))
$(x +(x))
</code>```

This...is really terrible. I feel dirty for posting this.

Set k to the string form of the current number, map over the list [0...(length k)-1] splitting the string at that index (a). Get the a character, parse it to a number, and if it's 0 return no. Get the prefix of a and weld it to the other half of the split, parse to a number, check if the index divides it evenly.

++levy returns yes iff calling the function on all the elements of the list is also yes. In this case, the function ++test curried with yes, so it checks that all of the characters in k work.

If we're at the 0th value, we return the current number, or else we recurse with n decremented (and increment x)

Title: Excludivisible numbers

Body:
Given an integer N, output the Nth positive number K with the following property in decimal base:

For each digit I at position P of K, the number formed from K by removing the Pth digit (i.e. I) is divisible by I.

Example and remarks

324 is such a number:

3 divides 24

2 divides 34

4 divides 32

Note 1: we assume that the empty number is divisible by anything, like 0. Therefore 1, 2, 3, 4, 5, 6, 7, 8 and 9 are valid.

Note 2: K cannot contain the digit 0, since you cannot divide by 0.

Inputs and outputs

You may take the input as a function argument, through STDIN, etc.

You may return the output from a function, through STDOUT, etc.

You may index those numbers starting from 0 (in which case N >= 0) or from 1 (in which case N > 0), whichever suits you more.

Test cases

Those examples are indexed from 0, so if you indexed from 1, then add 1 to the numbers in the N column.

```<code>N    Output
0    1
4    5
8    9
15   77
16   88
23   155
42   742
47   1113
121  4244
144  6888
164  9999
</code>```

Scoring

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

Body:
Hoon, 246 bytes

=+
x=0
|=
n/@
=+
k=<x>
=+
%+
levy
%+
turn
(gulf 0 (dec (lent k)))
|=
a/@
=+
(trim +(a) k)
=+
(rash (snag a p) dit)
?:
=(- 0)
|
=(0 (mod (fall (rust (weld (scag a p) q) dem) x) -))
(curr test &)
?:
=(- &)
?:
=(0 n)
x
$(n (dec n), x +(x))
$(x +(x))

Ungolfed:

=+  x=0
|=  n/@
=+  k=<x>
=+  %+  levy
  %+  turn  (gulf 0 (dec (lent k)))
  |=  a/@
  =+  (trim +(a) k)
  =+  (rash (snag a p) dit)
  ?:  =(- 0)
    |
  =(0 (mod (fall (rust (weld (scag a p) q) dem) x) -))
(curr test &)
?:  =(- &)
  ?:  =(0 n)
    x
  $(n (dec n), x +(x))
$(x +(x))

This...is really terrible. I feel dirty for posting this.

Set k to the string form of the current number, map over the list [0...(length k)-1] splitting the string at that index (a). Get the a character, parse it to a number, and if it's 0 return no. Get the prefix of a and weld it to the other half of the split, parse to a number, check if the index divides it evenly.

++levy returns yes iff calling the function on all the elements of the list is also yes. In this case, the function ++test curried with yes, so it checks that all of the characters in k work.

If we're at the 0th value, we return the current number, or else we recurse with n decremented (and increment x)