答:
Shoes (Ruby) Rev C 184 bytes

12 bytes saved by transferring responsibility for checking if a particular half-line should be drawn from the main program to the drawing method. The main program still has to check if the whole line is completely blocked, though.

```<code>Shoes.app{t=[]
d=->p,q{t[p]&&t[q]||line(p/6*8,p%6*14,q/6*8,q%6*14)}
%w{1I IW WM M5 5' '1 =A P. R,}.shuffle.map{|i|b=i.sum/2
c=b*2-a=i.ord
t[a]&&t[c]||(d[a,b]
d[b,c]
t[a]=t[b]=t[c]=1)}}
</code>```

Shoes (Ruby) <s>205</s> ... Rev B 196  bytes

Shoes is a ruby-based tool for building GUI's etc. It's the first time I've used it. mothereff.in/byte-counter counts my submission as 196 bytes, but for some reason Shoes counts it as 202.

Also, Ruby lets you do things like t[a=i.ord] but strangely, it seems not to work as expected with Shoes.

```<code>Shoes.app{t=[]
d=->p,q{line(p/6*8,p%6*14,q/6*8,q%6*14)}
%w{1I IW WM M5 5' '1 =A P. R,}.shuffle.map{|i|b=i.sum/2
c=b*2-a=i.ord
t[a]&&t[c]||(t[a]&&t[b]||d[a,b]
t[b]&&t[c]||d[b,c]
t[a]=t[b]=t[c]=1)}}
</code>```

Explanation

I don't consider the parts of the line outside the hexagon. I only draw the part that needs to be drawn. The important thing is whether the lines cross the intersections (If we only draw the parts that need to be drawn, this means they begin / end at the intersections.)

The basic rule is that if both endpoints of a line have been visited, the line is blocked and should not be drawn. As the lines are drawn in two halves, we also have to check if the midpoint has been visited to see if each half should be drawn or not.

I keep track of which points have been visited in the array t[]. This ends up containing an entry for each physical coordinate on the grid below. There is no separate 13-element logical array. By the end, t[] may have 87 elements, though only up to 13 will contain useful data.

Internally, the coordinates of the endpoints of the lines are given by a single number z, where z%6 is the y coordinate and z/6 is the x coordinate. In this system the hexagon is flattened. When the lines are plotted, the x scale is multiplied by 8 and the y scale is multiplied by 14, which is a very close rational approximation to the correct ratio: 14/8=1.75 vs sqrt(3)=1.732.

The internal coordinate system is shown below, with a few sample outputs.

Ungolfed

```<code>Shoes.app{
  t=[]                                          #Empty array for status tracking
  d=->p,q{line(p/6*8,p%6*14,q/6*8,q%6*14)}      #Drawing method. Convert p and q into x,y pairs, scale and draw line.
  %w{1I IW WM M5 5' '1 =A P. R,}.shuffle.map{|i|#take an array of the coordinates of the endpoints of each line, shuffle, then for each line
    b=i.sum/2                                   #b = midpoint of line, convert ASCII sum to number (average of the two coordinates)
    a=i.ord                                     #a = first endpoint of line, convert ASCII to number (no need to write i[0].ord)
    c=b*2-a                                     #c = second endpoint of line (calculating is shorter than writing i[1].ord)
    t[a]&&t[c]||(                               #if both endpoints have already been visited, line is completely blocked, do nothing. ELSE
      t[a]&&t[b]||d[a,b]                        #if first endpoint and midpoint have not both been visited, draw first half of line
      t[b]&&t[c]||d[b,c]                        #if second endpoint and midpoint have not both been visited, draw second half of line
      t[a]=t[b]=t[c]=1                          #mark all three points of the line as visited
    )
  }
}
</code>```

More Sample outputs

These were done with an older version of the program. The only difference is that the positioning of the hexaglyph in the window is now slightly different.

Title: Draw a random hexa-glyph

Body:
The above image is called a hexa-glyph.  Hexa-glyphs are some cool patterns I made up while doodling during my DiffEq class.  Here's how you make one:

Consider the following set of points, shaped like a regular hexagram.  The inner hexagon is what will contain the final glyph, while the outer 6 points form a star and are where we will start drawing our lines.

From the outer six points, randomly select a pair.  For efficiency, there should be at least one other point between the two selected points (otherwise, it would have no effect on the final figure).  Then, from each of the two points, cast a ray towards the other.  This ray is blocked by previous lines.

Repeat this process until all 9 edges have been formed, as shown in the next few images.

Here is an example of rays being blocked.  The ends of the ray segment are still visible, but the middle portion is occluded by the first two segments we drew.

These two rays are also "blocked," but this doesn't cause any visible difference because they are blocked by the same other line.

Fast-forwarding until all 9 lines are drawn.  If you want a more detailed explanation of these skipped steps, I can expound.

Finally, remove the points of the star.  To make it look prettier, the thick dots are also removed.

The challenge

You challenge is to output a visual representation of a random hexa-glyph.  This is code-golf, fewest bytes wins.

All possible hexa-glyphs should appear with some positive probability. Different hexa-glyphs are generated by changing the order in which the 9 edges are drawn.

Furthermore, all images output by your program must be valid hexa-glyphs. Certain patterns (like a complete outline of the inner hexagon) cannot possibly appear as a hexa-glyph, and so you program mustn't output these.

The output should be a graphical image (printed to screen or file).

The hexagon must be regular, but can appear in any orientation.

Reflections / rotations are not considered unique.  (This might make requirement 1 easier to follow).

Body:
Shoes (Ruby) Rev C 184 bytes

12 bytes saved by transferring responsibility for checking if a particular half-line should be drawn from the main program to the drawing method. The main program still has to check if the whole line is completely blocked, though.

Shoes.app{t=[]
d=->p,q{t[p]&&t[q]||line(p/6*8,p%6*14,q/6*8,q%6*14)}
%w{1I IW WM M5 5' '1 =A P. R,}.shuffle.map{|i|b=i.sum/2
c=b*2-a=i.ord
t[a]&&t[c]||(d[a,b]
d[b,c]
t[a]=t[b]=t[c]=1)}}

Shoes (Ruby) <s>205</s> ... Rev B 196  bytes

Shoes is a ruby-based tool for building GUI's etc. It's the first time I've used it. mothereff.in/byte-counter counts my submission as 196 bytes, but for some reason Shoes counts it as 202.

Also, Ruby lets you do things like t[a=i.ord] but strangely, it seems not to work as expected with Shoes.

Shoes.app{t=[]
d=->p,q{line(p/6*8,p%6*14,q/6*8,q%6*14)}
%w{1I IW WM M5 5' '1 =A P. R,}.shuffle.map{|i|b=i.sum/2
c=b*2-a=i.ord
t[a]&&t[c]||(t[a]&&t[b]||d[a,b]
t[b]&&t[c]||d[b,c]
t[a]=t[b]=t[c]=1)}}

Explanation

I don't consider the parts of the line outside the hexagon. I only draw the part that needs to be drawn. The important thing is whether the lines cross the intersections (If we only draw the parts that need to be drawn, this means they begin / end at the intersections.)

The basic rule is that if both endpoints of a line have been visited, the line is blocked and should not be drawn. As the lines are drawn in two halves, we also have to check if the midpoint has been visited to see if each half should be drawn or not.

I keep track of which points have been visited in the array t[]. This ends up containing an entry for each physical coordinate on the grid below. There is no separate 13-element logical array. By the end, t[] may have 87 elements, though only up to 13 will contain useful data.

Internally, the coordinates of the endpoints of the lines are given by a single number z, where z%6 is the y coordinate and z/6 is the x coordinate. In this system the hexagon is flattened. When the lines are plotted, the x scale is multiplied by 8 and the y scale is multiplied by 14, which is a very close rational approximation to the correct ratio: 14/8=1.75 vs sqrt(3)=1.732.

The internal coordinate system is shown below, with a few sample outputs.

Ungolfed

Shoes.app{
  t=[]                                          #Empty array for status tracking
  d=->p,q{line(p/6*8,p%6*14,q/6*8,q%6*14)}      #Drawing method. Convert p and q into x,y pairs, scale and draw line.
  %w{1I IW WM M5 5' '1 =A P. R,}.shuffle.map{|i|#take an array of the coordinates of the endpoints of each line, shuffle, then for each line
    b=i.sum/2                                   #b = midpoint of line, convert ASCII sum to number (average of the two coordinates)
    a=i.ord                                     #a = first endpoint of line, convert ASCII to number (no need to write i[0].ord)
    c=b*2-a                                     #c = second endpoint of line (calculating is shorter than writing i[1].ord)
    t[a]&&t[c]||(                               #if both endpoints have already been visited, line is completely blocked, do nothing. ELSE
      t[a]&&t[b]||d[a,b]                        #if first endpoint and midpoint have not both been visited, draw first half of line
      t[b]&&t[c]||d[b,c]                        #if second endpoint and midpoint have not both been visited, draw second half of line
      t[a]=t[b]=t[c]=1                          #mark all three points of the line as visited
    )
  }
}

More Sample outputs

These were done with an older version of the program. The only difference is that the positioning of the hexaglyph in the window is now slightly different.


问:
The Arithmetic Derivative
The derivative of a function is a cornerstone of mathematics, engineering, physics, biology, chemistry, and a large number of other sciences as well. Today we're going to be calculating something only tangentially related: the arithmetic derivative.

Definition

The arithmetic derivative a(n) or n' is defined here (A003415) by a number of properties that are similar to the derivative of a function.

a(0) = a(1) = 0,

a(p) = 1, where p is any prime, and

a(mn) = m*a(n) + n*a(m).

The third rule is based on the product rule for differentiation of functions: for functions f(x) and g(x), (fg)' = f'g + fg'. So with numbers, (ab)' = a'b + ab'.

Also of note, since the arithmetic derivative can be extended to the negative numbers via this simple relation, a(-n) = -a(n), the input may be negative.

Rules

Write a program or function that, given any integer n, returns the arithmetic derivative of n.

Inputs will be -230 < n < 230, to avoid problems with integer sizes and numbers too large to factor in a reasonable amount of time. Your algorithm should still be able to theoretically calculate the arithmetic derivative of numbers outside this range.

Built-ins for symbolic math, prime factorization and differentiation are allowed.

Examples

```<code>> a(1)
0
> a(7)
1
> a(14)   # a(7)*2 + a(2)*7 = 1*2 + 1*7 = 9
9
> a(-5)   # a(-5) = -a(5) = -1
-1
> a(8)    # a(8) = a(2**3) = 3*2**2 = 12
12
> a(225)  # a(225) = a(9)*25 + a(25)*9 = 6*25 + 10*9 = 150 + 90 = 240
240
> a(299792458)  # a(299792458) = a(2)*149896229 + a(7)*42827494 + a(73)*4106746 + a(293339)*1022 = 1*149896229 + 1*42827494 + 1*4106746 + 1*1022 = 149896229 + 42827494 + 4106746 + 1022 = 196831491
196831491
</code>```

As always, if the problem is unclear, please let me know. Good luck and good golfing!

答:
J, <s>30</s> <s>27</s> 19 chars

Thanks to @Dennis for chopping off 3 characters.

Thanks to @Zgarb for chopping off 8 characters.

```<code>0:`(*[:+/%@q:@|)@.*
</code>```

Try it online!

Sample input:

```<code>0:`(*[:+/%@q:@|)@.* _8
_12

0:`(*[:+/%@q:@|)@.* 0
0

0:`(*[:+/%@q:@|)@.* 8
12
</code>```

How it works:

```<code>0:`(*[:+/%@q:@|)@.* N
XX`YYYYYYYYYYYYY@.Z   if Z then Y else X end
0:                        X:  return 0
                  Z       Z:  signum(N)
   (*[:+/%@q:@|)          Y:  N*add_all(reciprocal_all(all_prime_factors(abs(N))))
                              N
    *                          *
      [:+/                      add_all(                                         )
          %@                            reciprocal_all(                         )
            q:@                                       all_prime_factors(      )
               |                                                        abs( )
                                                                            N
</code>```

ContentLicense: CC BY-SA 4.0

Title: The Arithmetic Derivative

Body:
J, <s>30</s> <s>27</s> 19 chars

Thanks to @Dennis for chopping off 3 characters.

Thanks to @Zgarb for chopping off 8 characters.

0:`(*[:+/%@q:@|)@.*

Try it online!

Sample input:

0:`(*[:+/%@q:@|)@.* _8
_12

0:`(*[:+/%@q:@|)@.* 0
0

0:`(*[:+/%@q:@|)@.* 8
12

How it works:

0:`(*[:+/%@q:@|)@.* N
XX`YYYYYYYYYYYYY@.Z   if Z then Y else X end
0:                        X:  return 0
                  Z       Z:  signum(N)
   (*[:+/%@q:@|)          Y:  N*add_all(reciprocal_all(all_prime_factors(abs(N))))
                              N
    *                          *
      [:+/                      add_all(                                         )
          %@                            reciprocal_all(                         )
            q:@                                       all_prime_factors(      )
               |                                                        abs( )
                                                                            N

ContentLicense: CC BY-SA 3.0


问:
Optimal solution to go to opposite corner of a rectangle
Your job is to write a program that finds the optimal number of moves it takes to get from the lower-left corner of a rectangle to the upper-right corner directly opposite.

Your program will accept input as an ordered pair (width, height). These will be the dimensions of the rectangle you will work with. Your program will create an ASCII-art of the solution (use . for empty square and # for part of the solution, X for starting square) and count the number of moves it takes to reach the endpoint. Diagonal moves are not allowed. If there are multiple solutions, choose one to output.

The shortest program in bytes wins.

Example

Input: (4, 5)

Output:

```<code>..##
..#.
.##.
.#..
X#..
</code>```

Move count: 7

Body:
Python, 48.

lambda w,h:('.'*(w-1)+'#\n')*(h-1)+'X'+'#'*(w-1)

To use it, add f= before the line above and call it like this:

f(4, 5)

Result:

...#
...#
...#
...#
X###


答:
MATL, 12 bytes

```<code>|1>?GtYf/s}0
</code>```

Try it online!

Explanation

Consider an integer a with |a|>1, and let the (possibly repeated) prime factors of |a| be f1, ..., fn. Then the desired result is a·(1/f1 + ... + 1/fn).

```<code>|1>     % take input's absolute value. Is it greater than 1?
?       % if so:
  Gt    %   push input twice
  Yf    %   prime factors. For negative input uses its absolute value
  /     %   divide element-wise
  s     %   sum of the array
}       % else:
  0     %   push 0
</code>```

Title: The Arithmetic Derivative

Body:
The derivative of a function is a cornerstone of mathematics, engineering, physics, biology, chemistry, and a large number of other sciences as well. Today we're going to be calculating something only tangentially related: the arithmetic derivative.

Definition

The arithmetic derivative a(n) or n' is defined here (A003415) by a number of properties that are similar to the derivative of a function.

a(0) = a(1) = 0,

a(p) = 1, where p is any prime, and

a(mn) = m*a(n) + n*a(m).

The third rule is based on the product rule for differentiation of functions: for functions f(x) and g(x), (fg)' = f'g + fg'. So with numbers, (ab)' = a'b + ab'.

Also of note, since the arithmetic derivative can be extended to the negative numbers via this simple relation, a(-n) = -a(n), the input may be negative.

Rules

Write a program or function that, given any integer n, returns the arithmetic derivative of n.

Inputs will be -230 < n < 230, to avoid problems with integer sizes and numbers too large to factor in a reasonable amount of time. Your algorithm should still be able to theoretically calculate the arithmetic derivative of numbers outside this range.

Built-ins for symbolic math, prime factorization and differentiation are allowed.

Examples

```<code>> a(1)
0
> a(7)
1
> a(14)   # a(7)*2 + a(2)*7 = 1*2 + 1*7 = 9
9
> a(-5)   # a(-5) = -a(5) = -1
-1
> a(8)    # a(8) = a(2**3) = 3*2**2 = 12
12
> a(225)  # a(225) = a(9)*25 + a(25)*9 = 6*25 + 10*9 = 150 + 90 = 240
240
> a(299792458)  # a(299792458) = a(2)*149896229 + a(7)*42827494 + a(73)*4106746 + a(293339)*1022 = 1*149896229 + 1*42827494 + 1*4106746 + 1*1022 = 149896229 + 42827494 + 4106746 + 1022 = 196831491
196831491
</code>```

As always, if the problem is unclear, please let me know. Good luck and good golfing!

Body:
MATL, 12 bytes

|1>?GtYf/s}0

Try it online!

Explanation

Consider an integer a with |a|>1, and let the (possibly repeated) prime factors of |a| be f1, ..., fn. Then the desired result is a·(1/f1 + ... + 1/fn).

|1>     % take input's absolute value. Is it greater than 1?
?       % if so:
  Gt    %   push input twice
  Yf    %   prime factors. For negative input uses its absolute value
  /     %   divide element-wise
  s     %   sum of the array
}       % else:
  0     %   push 0


答:
Haskell, <s>203</s> 90 bytes

Thanks @nimi!

I still have no idea when what indentations cause what interpretation, this is the shortest I managed so far, and as always, I'm sure it can be golfed a lot more. I'm going to try again in the evening.

```<code>n#(x:_)|y<-div n x=x*a y+y*a x;_#_=1
a n|n<0= -a(-n)|n<2=0|1<2=n#[i|i<-[2..n-1],mod n i<1]
</code>```

Title: The Arithmetic Derivative

Body:
Haskell, <s>203</s> 90 bytes

Thanks @nimi!

I still have no idea when what indentations cause what interpretation, this is the shortest I managed so far, and as always, I'm sure it can be golfed a lot more. I'm going to try again in the evening.

n#(x:_)|y<-div n x=x*a y+y*a x;_#_=1
a n|n<0= -a(-n)|n<2=0|1<2=n#[i|i<-[2..n-1],mod n i<1]


问:
Print your code backwards - reverse quine
Write a program that prints its own source code out backwards, in other words an eniuq.

Scoring:

+50 if you use pull data from the Internet.

+25 if you read your own source code.

+1 point per character

Lowest score wins.

Rules:

No using other files (e.g. reverse.txt)

Minimum code length is two characters.

Your program cannot be a palindrome.

Body:
JavaScript, <s>53</s> <s>50</s> <s>46</s> 43 bytes

<s>

q=_=>("q="+q+";q()").split("").reverse().join("");q()

</s>
<s>

(q=_=>`(q=${q})()`.split("").reverse().join(""))()

</s>
<s>

(q=_=>`(q=${q})()`.split``.reverse().join``)()

</s>

(q=_=>[...`(q=${q})()`].reverse().join``)()

Please help me shorten this up.


问:
Find the shortest way to advance a counter to a certain number
I have a counter. It's a small device that looks like this:

The display goes from 0000 to 9999. It has a little push-button at the top that increases the count by 1, and a little knob at the right whose purpose is to reset the counter back to 0.

Now, the thing about the little knob is that if you turn it backwards, you can make it increase any digit that you want once you turn it forwards again. So if I push the counter button 10 times so that the counter shows 0010, I can then turn the knob backwards until i hear a tiny click, then turn it forwards again and make it go straight to 0090.

But, the knob will always increase all occurrences of the same digit by 1 every time it pushes numbers forward. So if the counter shows 6060, you can only make it increase to 7070, not to 6070 or 7060. Also, the knob will roll 9s over to 0 without carrying, so 0990 will advance to 0000 instead of 1000 or 1100.

I want to know the most efficient way to set the counter to a certain number. Your task is to write a program or function that will determine the shortest sequence of button pushes and knob advancements required to do so.

Your program will take as input a 4-digit number from 0000 to 9999, and return a series of steps in the following format:

```<code>> 0001
C
> 0093
C12345678C12345678CCC
> 1000
C12345678C12345678C12345678C12345678C12345678C12345678C12345678C
> 9999
012345678
</code>```

Where C stands for "push the counter button" and any digit D from 0 to 9 stands for "use the knob to advance all occurrences of D by 1".

Your program must produce a valid sequence of steps for all possible four-digit combinations, and will be scored by the total number of steps required for all 10,000 cases. In the case of a tie (most likely when the optimal algorithm is found), the shorter code will win.

答:
JavaScript (ES6), 327763 steps (optimum, 184 bytes)

A Breadth First Search, not so smart and not so fast.

t=>eval("for(k=[],s=[['0000',i='']];[u,p]=s[i++],u-t;k[v=(1+u-~0+'').slice(-4)]=k[v]||s.push([v,p+'C']))[...u].map(x=>k[v=[...u].map(y=>x-y?y:-~x%10).join``]=k[v]||s.push([v,p+x]));p")
```

<p><strong>Less golfed</strong></p>

<pre class="lang-js prettyprint-override"><code>t=>{
  k=[]; // mark values already found to reduce search
  for( i=0, s=[['0000','']];
       [u,p]=s[i++], // u: current code, p:current steps
       u != t; // exit if target found
     )
  {
     // try all digits present in current code
     [...u].map(x=> {
       v=[...u].map(y=>x-y?y:-~x%10).join`` // apply digit x to u
       if (!k[v]) // check if value v not found already
          k[v] = s.push([v,p+x]));
     })
     v=(1+u-~0+'').slice(-4); // try operator C
     if (!k[v]) // check if value v not found already
       k[v] = s.push([v,p+'C']))
  }
  return p
}
</code>```

Test

f=t=>eval("for(k=[],s=[['0000',i='']];[u,p]=s[i++],u-t;k[v=(1+u-~0+'').slice(-4)]=k[v]||s.push([v,p+'C']))[...u].map(x=>k[v=[...u].map(y=>x-y?y:-~x%10).join``]=k[v]||s.push([v,p+x]));p")

function SingleTest()
{
  var i=S.value
  if (/^\d{4}$/.test(i)) X.value=f(i)
  else X.value='invalid input'
}

SingleTest()

function LongTest()
{
  var i=0,v,r,t=0

  var step=_=>{
    v = ('000'+i).slice(-4);
    r = f(v);
    t+= r.length
    V.value = v;
    R.value = r;
    T.value = t;
    ++i;
    if(i<10000) setTimeout(step, 0)
  }

  step()
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>#V,#T,#S { width:5em }
#R,#X { width: 25em }</code>```

Single Test <input id=S value='0093'><button onclick="SingleTest()">-></button><input readonly id=X>

Long test (0000 ... 9999) <button onclick="LongTest()">Go</button>(i mean long, runtime 1 hour)

<input readonly id=V>
<input readonly id=R>
Total steps:<input readonly id=T>```

Body:
JavaScript (ES6), 327763 steps (optimum, 184 bytes)

A Breadth First Search, not so smart and not so fast.

t=>eval("for(k=[],s=[['0000',i='']];[u,p]=s[i++],u-t;k[v=(1+u-~0+'').slice(-4)]=k[v]||s.push([v,p+'C']))[...u].map(x=>k[v=[...u].map(y=>x-y?y:-~x%10).join``]=k[v]||s.push([v,p+x]));p")

Less golfed

t=>{
  k=[]; // mark values already found to reduce search
  for( i=0, s=[['0000','']];
       [u,p]=s[i++], // u: current code, p:current steps
       u != t; // exit if target found
     )
  {
     // try all digits present in current code
     [...u].map(x=> {
       v=[...u].map(y=>x-y?y:-~x%10).join`` // apply digit x to u
       if (!k[v]) // check if value v not found already
          k[v] = s.push([v,p+x]));
     })
     v=(1+u-~0+'').slice(-4); // try operator C
     if (!k[v]) // check if value v not found already
       k[v] = s.push([v,p+'C']))
  }
  return p
}

Test

f=t=>eval("for(k=[],s=[['0000',i='']];[u,p]=s[i++],u-t;k[v=(1+u-~0+'').slice(-4)]=k[v]||s.push([v,p+'C']))[...u].map(x=>k[v=[...u].map(y=>x-y?y:-~x%10).join``]=k[v]||s.push([v,p+x]));p")

function SingleTest()
{
  var i=S.value
  if (/^\d{4}$/.test(i)) X.value=f(i)
  else X.value='invalid input'
}

SingleTest()

function LongTest()
{
  var i=0,v,r,t=0

  var step=_=>{
    v = ('000'+i).slice(-4);
    r = f(v);
    t+= r.length
    V.value = v;
    R.value = r;
    T.value = t;
    ++i;
    if(i<10000) setTimeout(step, 0)
  }

  step()
}

#V,#T,#S { width:5em }
#R,#X { width: 25em }

Single Test <input id=S value='0093'><button onclick="SingleTest()">-></button><input readonly id=X><hr>
Long test (0000 ... 9999) <button onclick="LongTest()">Go</button>(i mean <i>long</i>, runtime 1 hour)<br>
<input readonly id=V>
<input readonly id=R>
Total steps:<input readonly id=T>


答:
Ruby, <s>87</s> <s>66</s> <s>80</s> <s>75</s> <s>70</s> 68 bytes

This answer is based on Luis Mendo's MATL answer, wythagoras's Python answer, and the idea that the arithmetic derivative of a number m is equal to m·(1/p1 + 1/p2 + ... + 1/pn) where p1...pn is every prime factor of n to multiplicity.

->n{s=0;(2...m=n.abs).map{|d|(m/=d;s+=n/d)while m%d<1};m<2?0:s+0**s}
```

<p>This function is called in the following way:</p>

<pre class="lang-ruby prettyprint-override"><code>> a=->n{s=0;(2...m=n.abs).map{|d|(m/=d;s+=n/d)while m%d<1};m<2?0:s+0**s}
> a[299792458]
196831491
</code>```

Ungolfing:

def a(n)
  s = 0
  m = n.abs
  (2...m).each do |z|
    while m%d == 0
      m /= d
      s += n / d
    end
  end
  if s == 0
    if n > 1
      s += 1 # if s is 0, either n is prime and the while loop added nothing, so add 1
             # or n.abs < 2, so return 0 anyway
             # 0**s is used in the code because it returns 1 if s == 0 and 0 for all other s
    end
  end
  return s
end
```

Title: The Arithmetic Derivative

Body:
Ruby, <s>87</s> <s>66</s> <s>80</s> <s>75</s> <s>70</s> 68 bytes

This answer is based on Luis Mendo's MATL answer, wythagoras's Python answer, and the idea that the arithmetic derivative of a number m is equal to m·(1/p1 + 1/p2 + ... + 1/pn) where p1...pn is every prime factor of n to multiplicity.

->n{s=0;(2...m=n.abs).map{|d|(m/=d;s+=n/d)while m%d<1};m<2?0:s+0**s}

This function is called in the following way:

> a=->n{s=0;(2...m=n.abs).map{|d|(m/=d;s+=n/d)while m%d<1};m<2?0:s+0**s}
> a[299792458]
196831491

Ungolfing:

def a(n)
  s = 0
  m = n.abs
  (2...m).each do |z|
    while m%d == 0
      m /= d
      s += n / d
    end
  end
  if s == 0
    if n > 1
      s += 1 # if s is 0, either n is prime and the while loop added nothing, so add 1
             # or n.abs < 2, so return 0 anyway
             # 0**s is used in the code because it returns 1 if s == 0 and 0 for all other s
    end
  end
  return s
end


答:
Python 2, <s>87</s> <s>78</s> <s>76</s> 74 bytes

a=b=input()
d=2
s=0
while d<=abs(b):
    if a%d==0:
        a=a/d
        s+=b/d
    else:
        d+=1
print s
```

<p>Improvements thanks to @Maltysen: </p>

<pre class="lang-python prettyprint-override"><code>a=b=input()
d=2
s=0
while d<=abs(b):
    if a%d==0:a/=d;s+=b/d
    else:d+=1
print s
</code>```

Further improvement by two bytes:

a=b=input()
d=2
s=0
while abs(a)>1:
    if a%d<1:a/=d;s+=b/d
    else:d+=1
print s
```

<p>Further improvement thanks to @xnor:</p>

<pre class="lang-python prettyprint-override"><code>a=b=input()
d=2
s=0
while a*a>1:
    if a%d<1:a/=d;s+=b/d
    else:d+=1
print s
</code>```

Explanation

The arithmetic derivative of a is equal to a times the sum of the reciprocals of the prime factors of a. No exception for 1 is needed since the sum of the reciprocals of the prime factors of 1 is zero.

Title: The Arithmetic Derivative

Body:
Python 2, <s>87</s> <s>78</s> <s>76</s> 74 bytes

a=b=input()
d=2
s=0
while d<=abs(b):
    if a%d==0:
        a=a/d
        s+=b/d
    else:
        d+=1
print s

Improvements thanks to @Maltysen:

a=b=input()
d=2
s=0
while d<=abs(b):
    if a%d==0:a/=d;s+=b/d
    else:d+=1
print s

Further improvement by two bytes:

a=b=input()
d=2
s=0
while abs(a)>1:
    if a%d<1:a/=d;s+=b/d
    else:d+=1
print s

Further improvement thanks to @xnor:

a=b=input()
d=2
s=0
while a*a>1:
    if a%d<1:a/=d;s+=b/d
    else:d+=1
print s

Explanation

The arithmetic derivative of a is equal to a times the sum of the reciprocals of the prime factors of a. No exception for 1 is needed since the sum of the reciprocals of the prime factors of 1 is zero.


问:
Go to opposite corner of rectangle in all directions - Harder
This is essentially the same thing as this question, except harder. You are again to write a program that gets from the lower-left corner of a rectangle to the upper-right corner. However, this time diagonal moves are allowed.

The program will accept an ordered pair (width, height), and use these as the dimensions for a rectangle. Your program will then create an ASCII-art of the solution (use . for an empty square, # for part of the solution, and X for starting square) and count the number of moves it takes to reach the endpoint.

Example

Input: (5, 6)

Output:

```<code>....#
....#
...#.
..#..
.#...
X....
Move count: 5
</code>```

Shortest answer in bytes wins!

答:
Pyth, <s>46</s> <s>45</s> 44 bytes

```<code>eSKtMQjsM_mm?sJ,kd?q#J.umtWbbNeSKK\#\.\XhQeQ
</code>```

Try it here.

Explanation:

```<code>move-count-printing:

  K     assign K to...
     Q  the input, a 2-length array...
   tM   with each element decremented
eS      take the max and output it (this is the number of moves)

main path-finding logic:

    mm                     hQeQ  map over x-values and y-values...
        J,kd                     assign J to [x,y]
      ?s                         if both x and y are NOT zero (sum is truthy)...
            ?q#J[...]              if [x,y] is present in [...] (see below)...
                     \#            ... put a # at this position in the output
                       \.          ... else, put a . at this position
                         \X      ... else, put the X here (at [0,0])
jsM_                             reverse and output in the proper format

the [...] part in the code above, which finds positions where #s go:

.u      eSKK  cumulative reduce on <number of moves> elements, starting at K,
                which is [max_x, max_y] as assigned at the beginning
  m    N      map over x and y...
   tWbb       decrement, only if the value is > 0
</code>```

Body:
Pyth, <s>46</s> <s>45</s> 44 bytes

eSKtMQjsM_mm?sJ,kd?q#J.umtWbbNeSKK\#\.\XhQeQ

Try it here.

Explanation:

move-count-printing:

  K     assign K to...
     Q  the input, a 2-length array...
   tM   with each element decremented
eS      take the max and output it (this is the number of moves)

main path-finding logic:

    mm                     hQeQ  map over x-values and y-values...
        J,kd                     assign J to [x,y]
      ?s                         if both x and y are NOT zero (sum is truthy)...
            ?q#J[...]              if [x,y] is present in [...] (see below)...
                     \#            ... put a # at this position in the output
                       \.          ... else, put a . at this position
                         \X      ... else, put the X here (at [0,0])
jsM_                             reverse and output in the proper format

the [...] part in the code above, which finds positions where #s go:

.u      eSKK  cumulative reduce on <number of moves> elements, starting at K,
                which is [max_x, max_y] as assigned at the beginning
  m    N      map over x and y...
   tWbb       decrement, only if the value is > 0


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

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

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

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

Does not contain the characters: 2 or 7

Input:

none

Output:

Hello World

Leaderboard

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

  });

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}</code>```

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Title: Obfuscated Hello World

Body:
JavaScript, <s>77</s> <s>70</s> 69 characters

This satisfies conditions number 2 and 3.
<s>

"H"+([]+![])[4]+"ll"+([]+{})[+!![]]+" W"+([]+{})[+!![]]+([]+!![])[+!![]]+"ld"

</s>
<s>

a=!![];b=([]+{});c=b[+a];"H"+([]+![])[4]+"ll"+c+" W"+c+([]+a)[+a]+"ld"

</s>

a=!![];b=([]+{});c=b[+a];`H${([]+![])[4]}ll${c} W${c}${([]+a)[+a]}ld`

Please help me shorten this up.


答:
JavaScript (ES6), 132

Edit 2 bytes saved thx @Neil

(w,h)=>[...Array(--h)].map((_,i)=>R(w-i)+'#'+R(i),--w,R=(n,c='.')=>c.repeat(n>w?w:n>0&&n)).join`
`+`
x${R(w-h,'#')+R(h)}
`+(h>w?h:w)
```

<p><strong>Test</strong></p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>f=(w,h)=>[...Array(--h)].map((_,i)=>R(w-i)+'#'+R(i),--w,R=(n,c='.')=>c.repeat(n>w?w:n>0&&n)).join`
`+`
x${R(w-h,'#')+R(h)}
`+(h>w?h:w)

function test() {
  var w,h
  [w,h]=I.value.match(/\d+/g)
  O.textContent=f(w,h)
}

test()</code>```

Test <input id=I value="4 5"><button onclick="test()">-></button>

```</code>```

Title: Go to opposite corner of rectangle in all directions - Harder

Body:
This is essentially the same thing as this question, except harder. You are again to write a program that gets from the lower-left corner of a rectangle to the upper-right corner. However, this time diagonal moves are allowed.

The program will accept an ordered pair (width, height), and use these as the dimensions for a rectangle. Your program will then create an ASCII-art of the solution (use . for an empty square, # for part of the solution, and X for starting square) and count the number of moves it takes to reach the endpoint.

Example

Input: (5, 6)

Output:

```<code>....#
....#
...#.
..#..
.#...
X....
Move count: 5
</code>```

Shortest answer in bytes wins!

Body:
JavaScript (ES6), 132

Edit 2 bytes saved thx @Neil

(w,h)=>[...Array(--h)].map((_,i)=>R(w-i)+'#'+R(i),--w,R=(n,c='.')=>c.repeat(n>w?w:n>0&&n)).join`
`+`
x${R(w-h,'#')+R(h)}
`+(h>w?h:w)

Test

f=(w,h)=>[...Array(--h)].map((_,i)=>R(w-i)+'#'+R(i),--w,R=(n,c='.')=>c.repeat(n>w?w:n>0&&n)).join`
`+`
x${R(w-h,'#')+R(h)}
`+(h>w?h:w)

function test() {
  var w,h
  [w,h]=I.value.match(/\d+/g)
  O.textContent=f(w,h)
}

test()

Test <input id=I value="4 5"><button onclick="test()">-></button>
<pre id=O></pre>


答:
MATL, 38 bytes

```<code>'.#X'!iSPXytf0)Jh1w(tzqDQI1()Gd0<?!]XP
</code>```

Try it online!

Explanation

Let m and n be the sorted inputs, such that m is greater than or equal to n. The code initially builds an mxn matrix as follows:

Value 2 along the main diagonal, and on the lower part of the last column. This corresponds to character #. The number of these entries minus 1 is the move count.

Value 3 at entry (1,1), corresponding to the X.

The remaining entries contain 1, corresponding to character .

If needed, the matrix is now transposed so that it has the desired shape. Note that the first dimension of a matrix is its height, not width, so it corresponds to the second input.

The matrix is then flipped upside down so that X appears at the bottom of the first column, and its entries are used as indices into the string '.#X' to produce the desired 2D char array.

```<code>'.#X'    % push this string
!        % transpose into a column
i        % input array
SP       % sort it in non-increasing order
Xy       % identity matrix with that size: fill diagonal with 1, rest entries are 0
tf0)     % linear index of last 1
Jh       % append 1j (imaginary unit): linear index of lowest part of last column
1w(      % fill those entries with 1
tzq      % duplicate. Number of nonzero entries minus 1: this is the move count
D        % display move count (and remove it from the stack)
Q        % add 1. Matrix now contains values 1 and 2
I1(      % set first entry (in linear order) to value 3
)        % use matrix as index into the initial string. Gives 2D char array
Gd0<     % push input array again. Is it decreasing?
?        % if so
  !      %   transpose char array
]        % end
XP       % flip upside down. Implicitly display
</code>```

Body:
MATL, 38 bytes

'.#X'!iSPXytf0)Jh1w(tzqDQI1()Gd0<?!]XP

Try it online!

Explanation

Let m and n be the sorted inputs, such that m is greater than or equal to n. The code initially builds an mxn matrix as follows:

Value 2 along the main diagonal, and on the lower part of the last column. This corresponds to character #. The number of these entries minus 1 is the move count.

Value 3 at entry (1,1), corresponding to the X.

The remaining entries contain 1, corresponding to character .

If needed, the matrix is now transposed so that it has the desired shape. Note that the first dimension of a matrix is its height, not width, so it corresponds to the second input.

The matrix is then flipped upside down so that X appears at the bottom of the first column, and its entries are used as indices into the string '.#X' to produce the desired 2D char array.

'.#X'    % push this string
!        % transpose into a column
i        % input array
SP       % sort it in non-increasing order
Xy       % identity matrix with that size: fill diagonal with 1, rest entries are 0
tf0)     % linear index of last 1
Jh       % append 1j (imaginary unit): linear index of lowest part of last column
1w(      % fill those entries with 1
tzq      % duplicate. Number of nonzero entries minus 1: this is the move count
D        % display move count (and remove it from the stack)
Q        % add 1. Matrix now contains values 1 and 2
I1(      % set first entry (in linear order) to value 3
)        % use matrix as index into the initial string. Gives 2D char array
Gd0<     % push input array again. Is it decreasing?
?        % if so
  !      %   transpose char array
]        % end
XP       % flip upside down. Implicitly display


答:
Mathematica 10.0, 39 bytes

```<code>Tr[If[#>1,#2/#,0]&@@@FactorInteger@#]#&
</code>```

Title: The Arithmetic Derivative

Body:
Mathematica 10.0, 39 bytes

Tr[If[#>1,#2/#,0]&@@@FactorInteger@#]#&


问:
Read a crossword
Inspired by this question about packing into this format.

Occasionally I see a completed crossword and being as I am, I can't be bothered to find out what the solutions to the clues actually were.

Input:

A 2D string (any format, newline separated, 2d list etc.)

Blank squares will be represented with a  (space character)

Every other square will be in the lower case alphabet.

You may assume that the input will be padded with spaces to form a rectangle

Output:

Each word found

You must search for words along and down

Words will be at least two letters long

If there are duplicate words, you have to output them for each time they appear

You don't have to do any validation

Words may be outputted in any order

No strict formatting rules

Test cases:

```<code>word
e e
step
t d

word, step, west, reed
---
pies
 not
  no
wasp

pies, not, no, wasp, in, eons, stop
---
igloo
    n
word

igloo, word, on
</code>```

答:
CJam, 14 bytes

```<code>{_z+S*S%{,(},}
</code>```

An unnamed block that expects a list of (padded) strings on top of the stack and leaves a list of words instead.

Test it here.

Explanation

```<code>_z    e# Duplicate and transpose the grid.
+     e# Append the transpose to the original grid.
S*    e# Join all lines by spaces to ensure that we don't get words
      e# spanning multiple lines.
S%    e# Split around spaces, discarding empty segments.
{,(}, e# Filter: keep only those strings with length 2 or greater.
</code>```

Title: Read a crossword

Body:
CJam, 14 bytes

{_z+S*S%{,(},}

An unnamed block that expects a list of (padded) strings on top of the stack and leaves a list of words instead.

Test it here.

Explanation

_z    e# Duplicate and transpose the grid.
+     e# Append the transpose to the original grid.
S*    e# Join all lines by spaces to ensure that we don't get words
      e# spanning multiple lines.
S%    e# Split around spaces, discarding empty segments.
{,(}, e# Filter: keep only those strings with length 2 or greater.


答:
Pyth - <s>10</s> 8 bytes

Lovin' the implicit input! Should bring it on par with Jelly for most things (Except Dennis' golfing skills).

```<code>*scL1P.a
</code>```

Test Suite.

```<code>*             Times the input, implicitly (This also adds the sign back in)
 s            Sum
  cL1         Reciprocal mapped over lit
   P          Prime factorization
    .a        Absolute value of input, implicitly
</code>```

Title: The Arithmetic Derivative

Body:
Pyth - <s>10</s> 8 bytes

Lovin' the implicit input! Should bring it on par with Jelly for most things (Except Dennis' golfing skills).

*scL1P.a

Test Suite.

*             Times the input, implicitly (This also adds the sign back in)
 s            Sum
  cL1         Reciprocal mapped over lit
   P          Prime factorization
    .a        Absolute value of input, implicitly


答:
Pyke, 9 bytes

```<code>,+Fdc#t(s
</code>```

Try it here!

Or 7 bytes prettified

```<code>,+Fdc#t
</code>```

Try it here!

Title: Read a crossword

Body:
Inspired by this question about packing into this format.

Occasionally I see a completed crossword and being as I am, I can't be bothered to find out what the solutions to the clues actually were.

Input:

A 2D string (any format, newline separated, 2d list etc.)

Blank squares will be represented with a  (space character)

Every other square will be in the lower case alphabet.

You may assume that the input will be padded with spaces to form a rectangle

Output:

Each word found

You must search for words along and down

Words will be at least two letters long

If there are duplicate words, you have to output them for each time they appear

You don't have to do any validation

Words may be outputted in any order

No strict formatting rules

Test cases:

```<code>word
e e
step
t d

word, step, west, reed
---
pies
 not
  no
wasp

pies, not, no, wasp, in, eons, stop
---
igloo
    n
word

igloo, word, on
</code>```

Body:
Pyke, 9 bytes

,+Fdc#t(s

Try it here!

Or 7 bytes prettified

,+Fdc#t

Try it here!


答:
Pyth, 18 bytes

```<code>Lm:d"\S\S+"1byQyCQ
</code>```

Try it online!

Sample input:

```<code>["pies"," not","  no","wasp"," t  "]
</code>```

Sample output:

```<code>[['pies'], ['not'], ['no'], ['wasp'], []]
[[], ['in', 'at'], ['eons'], ['stop']]
</code>```

How it works:

```<code>Lm:d"\S\S+"1byQyCQ                                 The "1" here is mode
                    assign('Q',eval_input())       "1" which means show
                    @memoized                      all matches
L                   def y(b):                               v
 m:d"\S\S+"1b           return map(lambda d:regex(d,"\S\S+",1),b)
             yQ     imp_print(y(Q))
               yCQ  imp_print(y(transpose(Q)))
</code>```

Title: Read a crossword

Body:
Pyth, 18 bytes

Lm:d"\S\S+"1byQyCQ

Try it online!

Sample input:

["pies"," not","  no","wasp"," t  "]

Sample output:

[['pies'], ['not'], ['no'], ['wasp'], []]
[[], ['in', 'at'], ['eons'], ['stop']]

How it works:

Lm:d"\S\S+"1byQyCQ                                 The "1" here is mode
                    assign('Q',eval_input())       "1" which means show
                    @memoized                      all matches
L                   def y(b):                               v
 m:d"\S\S+"1b           return map(lambda d:regex(d,"\S\S+",1),b)
             yQ     imp_print(y(Q))
               yCQ  imp_print(y(transpose(Q)))


答:
Pyth - <s>11</s> <s>10</s> <s>8</s> 7 bytes

saved one bytes thanks to @issacg.

```<code>t#cjsCB
</code>```

Try it online here.

```<code>t#               Filter by if len > 1
 c               Chop by whitespace by default
  j              Join by newlines
   sCB           Input, implicit and its transpose in one list
</code>```

Title: Read a crossword

Body:
Pyth - <s>11</s> <s>10</s> <s>8</s> 7 bytes

saved one bytes thanks to @issacg.

t#cjsCB

Try it online here.

t#               Filter by if len > 1
 c               Chop by whitespace by default
  j              Join by newlines
   sCB           Input, implicit and its transpose in one list


答:
Python, 59 bytes

f=lambda n,p=2:+(n*n>1)and(n%p and f(n,p+1)or p*f(n/p)+n/p)
```

A recursive function. On large inputs, it runs out of stack depth on typical systems unless you run it with something like Stackless Python.

The recursive definition is implemented directly, counting up to search for candidate prime factors. Since f(prime)=1, if n has a prime p as a factor, we have f(n) == p*f(n/p)+n/p.

Title: The Arithmetic Derivative

Body:
The derivative of a function is a cornerstone of mathematics, engineering, physics, biology, chemistry, and a large number of other sciences as well. Today we're going to be calculating something only tangentially related: the arithmetic derivative.

Definition

The arithmetic derivative a(n) or n' is defined here (A003415) by a number of properties that are similar to the derivative of a function.

a(0) = a(1) = 0,

a(p) = 1, where p is any prime, and

a(mn) = m*a(n) + n*a(m).

The third rule is based on the product rule for differentiation of functions: for functions f(x) and g(x), (fg)' = f'g + fg'. So with numbers, (ab)' = a'b + ab'.

Also of note, since the arithmetic derivative can be extended to the negative numbers via this simple relation, a(-n) = -a(n), the input may be negative.

Rules

Write a program or function that, given any integer n, returns the arithmetic derivative of n.

Inputs will be -230 < n < 230, to avoid problems with integer sizes and numbers too large to factor in a reasonable amount of time. Your algorithm should still be able to theoretically calculate the arithmetic derivative of numbers outside this range.

Built-ins for symbolic math, prime factorization and differentiation are allowed.

Examples

```<code>> a(1)
0
> a(7)
1
> a(14)   # a(7)*2 + a(2)*7 = 1*2 + 1*7 = 9
9
> a(-5)   # a(-5) = -a(5) = -1
-1
> a(8)    # a(8) = a(2**3) = 3*2**2 = 12
12
> a(225)  # a(225) = a(9)*25 + a(25)*9 = 6*25 + 10*9 = 150 + 90 = 240
240
> a(299792458)  # a(299792458) = a(2)*149896229 + a(7)*42827494 + a(73)*4106746 + a(293339)*1022 = 1*149896229 + 1*42827494 + 1*4106746 + 1*1022 = 149896229 + 42827494 + 4106746 + 1022 = 196831491
196831491
</code>```

As always, if the problem is unclear, please let me know. Good luck and good golfing!

Body:
Python, 59 bytes

f=lambda n,p=2:+(n*n>1)and(n%p and f(n,p+1)or p*f(n/p)+n/p)

A recursive function. On large inputs, it runs out of stack depth on typical systems unless you run it with something like Stackless Python.

The recursive definition is implemented directly, counting up to search for candidate prime factors. Since f(prime)=1, if n has a prime p as a factor, we have f(n) == p*f(n/p)+n/p.


答:
Haskell, 59 bytes

n%p|n*n<2=0|mod n p>0=n%(p+1)|r<-div n p=r+p*r%2
(%2)
```

Implements the recursive definition directly, with an auxiliary variable p that counts up to search for potential prime factors, starting from 2. The last line is the main function, which plugs p=2 to the binary function defined in the first line.

The function checks each case in turn:

If n*n<2, then n is one of -1,0,1, and the result is 0.

If n is not a multiple of p, then increment p and continue.

Otherwise, express n=p*r, and by the "derivative" property, the result is r*a(p)+p*a(r), which simplifies to r+p*a(r) because p is prime.

The last case saves bytes by binding r in a guard, which also avoids the 1>0 for the boilerplate otherwise. If r could be bound earlier, the second condition mod n p>0 could be checked as r*p==n, which is 3 bytes shorter, but I don't see how to do that.

Title: The Arithmetic Derivative

Body:
Haskell, 59 bytes

n%p|n*n<2=0|mod n p>0=n%(p+1)|r<-div n p=r+p*r%2
(%2)

Implements the recursive definition directly, with an auxiliary variable p that counts up to search for potential prime factors, starting from 2. The last line is the main function, which plugs p=2 to the binary function defined in the first line.

The function checks each case in turn:

If n*n<2, then n is one of -1,0,1, and the result is 0.

If n is not a multiple of p, then increment p and continue.

Otherwise, express n=p*r, and by the "derivative" property, the result is r*a(p)+p*a(r), which simplifies to r+p*a(r) because p is prime.

The last case saves bytes by binding r in a guard, which also avoids the 1>0 for the boilerplate otherwise. If r could be bound earlier, the second condition mod n p>0 could be checked as r*p==n, which is 3 bytes shorter, but I don't see how to do that.


问:
How many sides does this polygon have?
So in 1st grade math, you learn the names of polygons. Three sides is a triangle, 4 is a square, and 5 is a pentagon. However, in 1st grade honors, you go a bit further.

Your challenge

There is a naming system for polygons above a few sides, so arbitrarily large polygons have a name.

Your task is to write a program or a function that accepts the name of a polygon as input and outputs the number of sides it has.

The names of polygons are defined as in the left column of this wikipedia article with a few exceptions.

Three sided polygons will be called a triangle instead of a trigon and 4 sided polygons will be a square instead of a tetragon (assume that all the polygons are regular). Otherwise, the names in the article will be used.

Rules

Input will be a string value.

The program should print the result to STDOUT (or it should return an integer).

Only polygons between 3 and 99 will be inputted.

Your program must satisfy all test cases.

No standard loopholes.

The program doesn't need to do anything for invalid/out of range inputs.

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

Test cases

```<code>3   triangle
4   square
5   pentagon
10  decagon
11  hendecagon
12  dodecagon
13  triskaidecagon
20  icosagon
21  icosikaihenagon
22  icosikaidigon
34  triacontakaitetragon
35  triacontakaipentagon
36  triacontakaihexagon
47  tetracontakaiheptagon
48  tetracontakaioctagon
49  tetracontakaienneagon
64  hexacontakaitetragon
80  octacontagon
81  octacontakaihenagon
99  enneacontakaienneagon
</code>```

Leaderboards

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```
</div>
</div>
</p>

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

```# Language Name, N bytes
```

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

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

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

```# Perl, 43 + 2 (-p flag) = 45 bytes
```

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

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

Title: How many sides does this polygon have?

Body:
Cinnamon Gum, 430 bytes

0000000: 6c4c ce85 0d04 4108 05d0 6e36 9e5b 379a  lL....A...n6.[7.
0000010: 5977 f7f2 6f02 8410 fdbc 11fe 75f4 f9d2  Yw..o.......u...
0000020: 4eb5 e5c1 b9df f951 5b3e 6cf5 72e5 edba  N......Q[>l.r...
0000030: 5801 74f5 8729 3469 238c 602d 29c5 502f  X.t..)4i#.`-).P/
0000040: 4b8d 3181 aa2e 3139 b6b9 bac8 e440 b5ca  K.1...19.....@..
0000050: e082 5977 8e79 2fe2 c155 5f47 ae89 f76b  ..Yw.y/..U_G...k
0000060: a21e 5ab8 8f26 eaa5 85fb 694a a02f d713  ..Z..&....iJ./..
0000070: b36b 63ee cdb1 294c e408 553d 822b 701d  .kc...)L..U=.+p.
0000080: 249e 0836 47f3 c5b0 3a5a a07e ff88 4245  $..6G...:Z.~..BE
0000090: 1b5f 8bc4 d692 2916 c2fa 6809 98fd 79b9  ._....)...h...y.
00000a0: f2ef 9e0d 32ff 9baa 8b43 3982 288a a121  ....2....C9.(..!
00000b0: 35d4 c3fc 03b3 3f4b cbd2 1d3a 43ad d77f  5.....?K...:C...
00000c0: 1ef2 9fe1 bc44 1ce7 b862 39e1 8ee7 a43a  .....D...b9....:
00000d0: a653 ceb8 4eab 633b e38c efec d7f7 0060  .S..N.c;.......`
00000e0: dc04 0be3 a143 8c57 1563 1c67 2123 3c48  .....C.W.c.g!#<H
00000f0: 19c9 6066 94bb 9cd1 0c86 c6b8 4b1a fbf5  ..`f........K...
0000100: f546 9a37 c1d2 7ce8 48f3 a54a 9ac7 59d2  .F.7..|.H..J..Y.
0000110: 0c0f 9266 7a40 9ae5 2e69 b607 a439 ee92  ...fz@...i...9..
0000120: e67e fe6a 81d6 cd59 ce7a c87f cc7a 8928  .~.j...Y.z...z.(
0000130: eb50 8dac a0db 5849 17b1 8a6c 6135 5dc0  .P....XI...la5].
0000140: 1ab2 7db5 5fff 4100 fb26 58d8 0f1d 62bf  ..}._.A..&X...b.
0000150: 5419 fb28 1bd9 a1c1 ca4e 0633 bbd4 edec  T..(.....N.3....
0000160: 6630 b447 ddd2 decf bf56 a073 7396 739e  f0.G.....V.ss.s.
0000170: bf0c 735e 22ca 3954 2327 e836 4ed2 459c  ..s^".9T#'.6N.E.
0000180: 225b 384d 1770 866c dfec d785 02e0 de04  "[8M.p.l........
0000190: 0bf7 a143 dc97 2ae3 1e65 2337 3458 b9c9  ...C..*..e#74X..
00001a0: 60e6 96ba 9ddb 0c86 eea8 5bba fb1f       `.........[...

This is a hexdump of the source code; you can reverse it using xxd -r.

<a href="http://cinnamon-gum.tryitonline.net/#code=MDAwMDAwMDogNmM0YyBjZTg1IDBkMDQgNDEwOCAwNWQwIDZlMzYgOWU1YiAzNzlhICBsTC4uLi5BLi4ubjYuWzcuCjAwMDAwMTA6IDU5NzcgZjdmMiA2ZjAyIDg0MTAgZmRiYyAxMWZlIDc1ZjQgZjlkMiAgWXcuLm8uLi4uLi4udS4uLgowMDAwMDIwOiA0ZWI1IGU1YzEgYjlkZiBmOTUxIDViM2UgNmNmNSA3MmU1IGVkYmEgIE4uLi4uLi5RWz5sLnIuLi4KMDAwMDAzMDogNTgwMSA3NGY1IDg3MjkgMzQ2OSAyMzhjIDYwMmQgMjljNSA1MDJmICBYLnQuLik0aSMuYC0pLlAvCjAwMDAwNDA6IDRiOGQgMzE4MSBhYTJlIDMxMzkgYjZiOSBiYWM4IGU0NDAgYjVjYSAgSy4xLi4uMTkuLi4uLkAuLgowMDAwMDUwOiBlMDgyIDU5NzcgOGU3OSAyZmUyIGMxNTUgNWY0NyBhZTg5IGY3NmIgIC4uWXcueS8uLlVfRy4uLmsKMDAwMDA2MDogYTIxZSA1YWI4IDhmMjYgZWFhNSA4NWZiIDY5NGEgYTAyZiBkNzEzICAuLlouLiYuLi4uaUouLy4uCjAwMDAwNzA6IGIzNmIgNjNlZSBjZGIxIDI5NGMgZTQwOCA1NTNkIDgyMmIgNzAxZCAgLmtjLi4uKUwuLlU9LitwLgowMDAwMDgwOiAyNDllIDA4MzYgNDdmMyBjNWIwIDNhNWEgYTA3ZSBmZjg4IDQyNDUgICQuLjZHLi4uOloufi4uQkUKMDAwMDA5MDogMWI1ZiA4YmM0IGQ2OTIgMjkxNiBjMmZhIDY4MDkgOThmZCA3OWI5ICAuXy4uLi4pLi4uaC4uLnkuCjAwMDAwYTA6IGYyZWYgOWUwZCAzMmZmIDliYWEgOGI0MyAzOTgyIDI4OGEgYTEyMSAgLi4uLjIuLi4uQzkuKC4uIQowMDAwMGIwOiAzNWQ0IGMzZmMgMDNiMyAzZjRiIGNiZDIgMWQzYSA0M2FkIGQ3N2YgIDUuLi4uLj9LLi4uOkMuLi4KMDAwMDBjMDogMWVmMiA5ZmUxIGJjNDQgMWNlNyBiODYyIDM5ZTEgOGVlNyBhNDNhICAuLi4uLkQuLi5iOS4uLi46CjAwMDAwZDA6IGE2NTMgY2ViOCA0ZWFiIDYzM2IgZTM4YyBlZmVjIGQ3ZjcgMDA2MCAgLlMuLk4uYzsuLi4uLi4uYAowMDAwMGUwOiBkYzA0IDBiZTMgYTE0MyA4YzU3IDE1NjMgMWM2NyAyMTIzIDNjNDggIC4uLi4uQy5XLmMuZyEjPEgKMDAwMDBmMDogMTljOSA2MDY2IDk0YmIgOWNkMSAwYzg2IGM2YjggNGIxYSBmYmY1ICAuLmBmLi4uLi4uLi5LLi4uCjAwMDAxMDA6IGY1NDYgOWEzNyBjMWQyIDdjZTggNDhmMyBhNTRhIDlhYzcgNTlkMiAgLkYuNy4ufC5ILi5KLi5ZLgowMDAwMTEwOiAwYzBmIDkyNjYgN2E0MCA5YWU1IDJlNjkgYjYwNyBhNDM5IGVlOTIgIC4uLmZ6QC4uLmkuLi45Li4KMDAwMDEyMDogZTY3ZSBmZTZhIDgxZDYgY2Q1OSBjZTdhIGM4N2YgY2M3YSA4OTI4ICAufi5qLi4uWS56Li4uei4oCjAwMDAxMzA6IGViNTAgOGRhYyBhMGRiIDU4NDkgMTdiMSA4YTZjIDYxMzUgNWRjMCAgLlAuLi4uWEkuLi5sYTVdLgowMDAwMTQwOiAxYWIyIDdkYjUgNWZmZiA0MTAwIGZiMjYgNThkOCAwZjFkIDYyYmYgIC4ufS5fLkEuLiZYLi4uYi4KMDAwMDE1MDogNTQxOSBmYjI4IDFiZDkgYTFjMSBjYTRlIDA2MzMgYmJkNCBlZGVjICBULi4oLi4uLi5OLjMuLi4uCjAwMDAxNjA6IDY2MzAgYjQ0NyBkZGQyIGRlY2YgYmY1NiBhMDczIDczOTYgNzM5ZSAgZjAuRy4uLi4uVi5zcy5zLgowMDAwMTcwOiBiZjBjIDczNWUgMjJjYSAzOTU0IDIzMjcgZTgzNiA0ZWQyIDQ1OWMgIC4uc14iLjlUIycuNk4uRS4KMDAwMDE4MDogMjI1YiAzODRkIDE3NzAgODY2YyBkZmVjIGQ3ODUgMDJlMCBkZTA0ICAiWzhNLnAubC4uLi4uLi4uCjAwMDAxOTA6IDBiZjcgYTE0MyBkYzk3IDJhZTMgMWU2NSAyMzM3IDM0NTggYjljOSAgLi4uQy4uKi4uZSM3NFguLgowMDAwMWEwOiA2MGU2IDk2YmEgOWRkYiAwYzg2IGVlYTggNWJiYSBmYjFmICAgICAgIGAuLi4uLi4uLi5bLi4u&input=ZW5uZWFjb250YWthaWVubmVhZ29u" rel="nofollow noreferrer">Try it online.


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

-1 byte by @Dennis

```<code>ÆfḟṠ³:S
</code>```

Uses the same formula everyone else does. However, there's a little trick to deal with 0.

```<code>o¬AÆfİS×     Main link. Inputs: n
o¬             Logical OR of n with its logical NOT
               That is, 0 goes to 1 and everything else goes to itself.
  A            Then take the absolute value
   Æf          get its list of prime factors
     İ         divide 1 by those
      S        sum
       ×       and multiply by the input.
</code>```

Try it here.

Title: The Arithmetic Derivative

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

-1 byte by @Dennis

ÆfḟṠ³:S

Uses the same formula everyone else does. However, there's a little trick to deal with 0.

o¬AÆfİS×     Main link. Inputs: n
o¬             Logical OR of n with its logical NOT
               That is, 0 goes to 1 and everything else goes to itself.
  A            Then take the absolute value
   Æf          get its list of prime factors
     İ         divide 1 by those
      S        sum
       ×       and multiply by the input.

Try it here.


Title: Read a crossword

Body:
JavaScript (ES6), 83 bytes

s=>(s+` `+[...(t=s.split`
`)[0]].map((_,i)=>t.map(t=>t[i]).join``)).match(/\w\w+/g)


问:
Shortest code for key-logger
Okay, I propose a shortest-key-logger challenge. As explained by the gentleman at "Are key-logger questions allowed?", strict rules have to be imposed in order to make this challenge valid for PPCG.

The key-logger has to run on Windows, Linux or Mac OSX (any programming language is welcome).

Upon execution, it has to show the message: "I'm gonna log you" (either in a console or using GUI).

The keys that are relevant for logging in this challenge are letters (case is not important) and numbers, all others such as symbols, control keys and whitespace are optional and can be ignored.

All relevant key presses that occur during runtime (even when the application is not in focus) have to be saved in a log file that can be read and verified using any text editor (even an esoteric one, as long as I can verify it using that text editor).

Anyone up for it? Whatdayatink?

答:
Bash, 90 bytes

This works on Ubuntu, and requires evtest. It picks a device that is a keyboard, and saves evtest's output to the file l. If you want a more formatted output, I can do that with more bytes.

```<code>echo I\'m gonna log you
sudo evtest /dev/input/by-path/`ls /dev/input/by-path/|grep kbd`>l
</code>```

Title: Shortest code for key-logger

Body:
Bash, 90 bytes

This works on Ubuntu, and requires evtest. It picks a device that is a keyboard, and saves evtest's output to the file l. If you want a more formatted output, I can do that with more bytes.

echo I\'m gonna log you
sudo evtest /dev/input/by-path/`ls /dev/input/by-path/|grep kbd`>l


答:
Haskell, 58 bytes

```<code>import Data.List
f x=[w|w@(_:_:_)<-words=<<x++transpose x]
</code>```

Usage example: f ["pies"," not","  no","wasp"] -> ["pies", "not", "no", "wasp", "in", "eons", "stop"].

How it works: split each of the lines of the input and the transposition of it at spaces it into a single list words. Keep those that match (_:_:_), i.e. have at least two letters.

Title: Read a crossword

Body:
Haskell, 58 bytes

import Data.List
f x=[w|w@(_:_:_)<-words=<<x++transpose x]

Usage example: f ["pies"," not","  no","wasp"] -> ["pies", "not", "no", "wasp", "in", "eons", "stop"].

How it works: split each of the lines of the input and the transposition of it at spaces it into a single list words. Keep those that match (_:_:_), i.e. have at least two letters.


问:
The plus-minus sequence

The plus-minus sequence

The plus-minus sequence is one that starts with two seeds, a(0) and b(0). Each iteration of this sequence is the addition and subtraction of the previous two members of the sequence. That is, a(N) = a(N-1) + b(N-1) and b(N) = a(N-1) - b(N-1).

Objective Produce the plus-minus sequence, in infinitude or the first K steps given K. You may do this using an infinite output program, a generator, or a function/program that gives the first K steps. The output order does not matter, so long as it is consistent. (I.e., b(K) a(K) or a(K) b(K), with some non-numeric, non-newline separator in between.) The output must start with the input.

Test cases

For inputs 10 2 (of a(0) b(0), this is a possible output for the first K approach (or a subsection of the infinite approach):

```<code>10     2
12     8
20     4
24     16
40     8
48     32
80     16
96     64
160    32
192    128
320    64
384    256
640    128
768    512
1280   256
1536   1024
2560   512
3072   2048
5120   1024
6144   4096
10240  2048
12288  8192
20480  4096
24576  16384
40960  8192
49152  32768
81920  16384
98304  65536
</code>```

For inputs 2 20 10 (a(0) b(0) k):

```<code>2     20
22   -18
4     40
44   -36
8     80
88   -72
16    160
176  -144
32    320
352  -288
</code>```

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

Catalog

The Stack Snippet at the bottom of this post generates the catalog from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
Reng v.3.2, 9 bytes  (self-answer, non-competing)

```<code>ii¤ææö±2.
</code>```

Takes two inputs (a b) and outputs b a. Try it here!

i takes input twice, ¤ duplicates the stack, æ prints a number and a space (and does so twice, there being two), ö prints a newline, ± does what you might expect, and 2. skips the next two characters, wrapping around the input getting characters.

Title: The plus-minus sequence

Body:
Reng v.3.2, 9 bytes  (self-answer, non-competing)

ii¤ææö±2.

Takes two inputs (a b) and outputs b a. Try it here!

i takes input twice, ¤ duplicates the stack, æ prints a number and a space (and does so twice, there being two), ö prints a newline, ± does what you might expect, and 2. skips the next two characters, wrapping around the input getting characters.


Title: The plus-minus sequence

Body:
The plus-minus sequence

The plus-minus sequence is one that starts with two seeds, a(0) and b(0). Each iteration of this sequence is the addition and subtraction of the previous two members of the sequence. That is, a(N) = a(N-1) + b(N-1) and b(N) = a(N-1) - b(N-1).

Objective Produce the plus-minus sequence, in infinitude or the first K steps given K. You may do this using an infinite output program, a generator, or a function/program that gives the first K steps. The output order does not matter, so long as it is consistent. (I.e., b(K) a(K) or a(K) b(K), with some non-numeric, non-newline separator in between.) The output must start with the input.

Test cases

For inputs 10 2 (of a(0) b(0), this is a possible output for the first K approach (or a subsection of the infinite approach):

```<code>10     2
12     8
20     4
24     16
40     8
48     32
80     16
96     64
160    32
192    128
320    64
384    256
640    128
768    512
1280   256
1536   1024
2560   512
3072   2048
5120   1024
6144   4096
10240  2048
12288  8192
20480  4096
24576  16384
40960  8192
49152  32768
81920  16384
98304  65536
</code>```

For inputs 2 20 10 (a(0) b(0) k):

```<code>2     20
22   -18
4     40
44   -36
8     80
88   -72
16    160
176  -144
32    320
352  -288
</code>```

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

Catalog

The Stack Snippet at the bottom of this post generates the catalog from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

Body:
Haskell, 19 bytes

a#b=a:b:(a+b)#(a-b)

Produces an infinite sequence of numbers. Usage example:

Prelude> take 20 $ 2#20

[2,20,22,-18,4,40,44,-36,8,80,88,-72,16,160,176,-144,32,320,352,-288]


问:
Golf you a quine for great good!
Using your language of choice, golf a quine.

A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output.

No cheating -- that means that you can't just read the source file and print it. Also, in many languages, an empty file is also a quine: that isn't considered a legit quine either.

No error quines -- there is already a separate challenge for error quines.

Points for:

Smallest code (in bytes)

Most obfuscated/obscure solution

Using esoteric/obscure languages

Successfully using languages that are difficult to golf in

The following Stack Snippet can be used to get a quick view of the current score in each language, and thus to know which languages have existing answers and what sort of target you have to beat:

var QUESTION_ID=69;
var OVERRIDE_USER=98;

var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk";var answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,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:!0,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=!1;comment_page=1;getComments()}})}
function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(data){data.items.forEach(function(c){if(c.owner.user_id===OVERRIDE_USER)
answers_hash[c.post_id].comments.push(c)});if(data.has_more)getComments();else if(more_answers)getAnswers();else process()}})}
getAnswers();var SCORE_REG=(function(){var headerTag=String.raw `h\d`
var score=String.raw `\-?\d+\.?\d*`
var normalText=String.raw `[^\n<>]*`
var strikethrough=String.raw `<s>${normalText}</s>|<strike>${normalText}</strike>|<del>${normalText}</del>`
var noDigitText=String.raw `[^\n\d<>]*`
var htmlTag=String.raw `<[^\n<>]+>`
return new RegExp(String.raw `<${headerTag}>`+String.raw `\s*([^\n,]*[^\s,]),.*?`+String.raw `(${score})`+String.raw `(?=`+String.raw `${noDigitText}`+String.raw `(?:(?:${strikethrough}|${htmlTag})${noDigitText})*`+String.raw `</${headerTag}>`+String.raw `)`)})();var OVERRIDE_REG=/^Override\s*header:\s*/i;function getAuthorName(a){return a.owner.display_name}
function process(){var valid=[];answers.forEach(function(a){var body=a.body;a.comments.forEach(function(c){if(OVERRIDE_REG.test(c.body))
body='
'+c.body.replace(OVERRIDE_REG,'')+'
'});var match=body.match(SCORE_REG);if(match)
valid.push({user:getAuthorName(a),size:+match[2],language:match[1],link:a.share_link,})});valid.sort(function(a,b){var aB=a.size,bB=b.size;return aB-bB});var languages={};var place=1;var lastSize=null;var lastPlace=1;valid.forEach(function(a){if(a.size!=lastSize)
lastPlace=place;lastSize=a.size;++place;var answer=jQuery("#answer-template").html();answer=answer.replace("{{PLACE}}",lastPlace+".").replace("{{NAME}}",a.user).replace("{{LANGUAGE}}",a.language).replace("{{SIZE}}",a.size).replace("{{LINK}}",a.link);answer=jQuery(answer);jQuery("#answers").append(answer);var lang=a.language;lang=jQuery(''+a.language+'').text().toLowerCase();languages[lang]=languages[lang]||{lang:a.language,user:a.user,size:a.size,link:a.link,uniq:lang}});var langs=[];for(var lang in languages)
if(languages.hasOwnProperty(lang))
langs.push(languages[lang]);langs.sort(function(a,b){if(a.uniq>b.uniq)return 1;if(a.uniq<b.uniq)return-1;return 0});for(var i=0;i<langs.length;++i)
{var language=jQuery("#language-template").html();var lang=langs[i];language=language.replace("{{LANGUAGE}}",lang.lang).replace("{{NAME}}",lang.user).replace("{{SIZE}}",lang.size).replace("{{LINK}}",lang.link);language=jQuery(language);jQuery("#languages").append(language)}}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list{padding:10px;float:left}#language-list{padding:10px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

  <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/primary.css?v=f52df912b654">

Winners by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

 ```

答:
Fuzzy Octo Guacamole, 4 bytes

```<code>_UNK
</code>```

I am not kidding.  Due to a suggestion by @ConorO'Brien, K prints _UNK.  The _UN does nothing really, but actually sets the temp var to 0, pushes 0, and pushes None.

The K prints "_UNK", and that is our quine.

Title: Golf you a quine for great good!

Body:
Fuzzy Octo Guacamole, 4 bytes

_UNK

I am not kidding.  Due to a suggestion by @ConorO'Brien, K prints _UNK.  The _UN does nothing really, but actually sets the temp var to 0, pushes 0, and pushes None.

The K prints "_UNK", and that is our quine.


问:
Clean the muddy quartata-fish
This challenge is in honor of the Rookie of the Year category winners of Best of PPCG 2015: muddyfish (for I'm not the language you're looking for!) and quartata (for Implement a Truth-Machine).
Congratulations!

Background

In the deepest trenches of the ocean, there lives a rare and elusive square-shaped fish called the quartata-fish.
It looks like the glider from the Game of Life cellular automaton.
Here are two quartata-fish of different sizes:

```<code>-o-
--o
ooo

--oo--
--oo--
----oo
----oo
oooooo
oooooo
</code>```

You have managed to snap a photo of the quartata-fish, but the fish is rather hard to see since it's covered in mud.
Now you'll have to write a program to clean up the photo.

Input

Your input is a rectangular 2D grid of the characters .-o#, given as a newline-separated string.
If you want, you can use pipes | instead of newlines as the separators, and you may assume one trailing and/or preceding separator.

The input will contain exactly one quartata-fish of some side-length 3*n, where n ≥ 1 is a positive integer, surrounded by periods . that represent the ocean floor.
The fish will always be in the orientation depicted above.
Overlaid on this grid, there will be exactly one non-empty rectangular region of hashes #, which represents a blob of mud.
The blob may cover the quartata-fish partially or entirely.
An example input would be

```<code>............
..--oo--....
..--oo--....
..---#####..
..---#####..
..ooo#####..
..oooooo....
</code>```

Output

Your output shall be generated from the input by replacing all the hashes with the characters .-o, so that the grid contains exactly one quartata-fish.
There will always be a unique way to perform this replacement properly; in particular, the blob of mud will cover the fish entirely only if its size is 3×3.
The output shall use the same separator as the input.
For the above input, the correct output would be

```<code>............
..--oo--....
..--oo--....
..----oo....
..----oo....
..oooooo....
..oooooo....
</code>```

Rules and scoring

You can write a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.
There are no time bounds: if your submission would eventually halt given unlimited time and resources, you're fine.

Test cases

```<code>Input:
.......
...-o-.
...--o.
##.ooo.
##.....
Output:
.......
...-o-.
...--o.
...ooo.
.......

Input:
...-o-.
...-#o.
...ooo.
.......
Output:
...-o-.
...--o.
...ooo.
.......

Input:
.........
.###.....
.###.....
.ooo.....
Output:
.........
.-o-.....
.--o.....
.ooo.....

Input:
.....
.###.
.###.
.###.
Output:
.....
.-o-.
.--o.
.ooo.

Input:
......
......
......
...###
...###
...###
Output:
......
......
......
...-o-
...--o
...ooo

Input:
###o--....
###o--....
###-oo....
###-oo....
###ooo....
###ooo....
###.......
Output:
--oo--....
--oo--....
----oo....
----oo....
oooooo....
oooooo....
..........

Input:
............
..--oo--....
..--oo--....
..---#####..
..---#####..
..ooo#####..
..oooooo....
Output:
............
..--oo--....
..--oo--....
..----oo....
..----oo....
..oooooo....
..oooooo....

Input:
...--oo--....
.#########...
.#########...
.#########...
...oooooo....
...oooooo....
.............
.............
Output:
...--oo--....
...--oo--....
...----oo....
...----oo....
...oooooo....
...oooooo....
.............
.............

Input:
..............
..............
.########.....
.########.....
.########-....
.########-....
.########o....
.########o....
.########o....
.########o....
.########.....
..............
Output:
..............
..............
..............
..............
....--oo--....
....--oo--....
....----oo....
....----oo....
....oooooo....
....oooooo....
..............
..............

Input:
.................
.................
..---ooo---......
..--#########....
..--#########....
..--#########....
..--#########....
..--#########....
..oo#########....
..oo#########....
..oo#########....
....#########....
Output:
.................
.................
..---ooo---......
..---ooo---......
..---ooo---......
..------ooo......
..------ooo......
..------ooo......
..ooooooooo......
..ooooooooo......
..ooooooooo......
.................

Input:
.........................
.........................
....----oooo----.........
....----########.........
....----########.........
....----########.........
....----########.........
....----########.........
....----########.........
....----########.........
....oooo########.........
....oooo########.........
....oooooooooooo.........
....oooooooooooo.........
.........................
Output:
.........................
.........................
....----oooo----.........
....----oooo----.........
....----oooo----.........
....----oooo----.........
....--------oooo.........
....--------oooo.........
....--------oooo.........
....--------oooo.........
....oooooooooooo.........
....oooooooooooo.........
....oooooooooooo.........
....oooooooooooo.........
.........................
</code>```

答:
Python 2, <s>433</s> 411 bytes

```<code>import re;i,o,l,j=input(),range,lambda s,r:s.replace(*r),"".join;i=l(l(l(i,".1"),"#."),"| ");s=o(len(i))
for x in s:
 for y in s:
    for q in s:
     r=map(list,l(l(i,"o."),"-.").split(" "))
     try:
        for v in o(q):r[x+v][y:y+q]=["".join(c*(q/3)for c in b)for b in["-o-","--o","ooo"]][3*v/q]
        m=re.match(i," ".join(j(i)for i in r))
     except:0
     if sum("-"in p for p in r)and m:print"|".join(l(j(i),"1.")for i in r);_
</code>```

Exits with a NameError. Takes input pipe separated.

I'm mixing tabs and spaces here. SE doesn't render tabs properly.

```<code>'###o--....|###o--....|###-oo....|###-oo....|###ooo....|###ooo....|###.......'
 --oo--....|--oo--....|----oo....|----oo....|oooooo....|oooooo....|..........

'.....|.###.|.###.|.###.'
 .....|.-o-.|.--o.|.ooo.

'...-o-.|...-#o.|...ooo.|.......'
 ...-o-.|...--o.|...ooo.|.......
</code>```

(Note extra spaces at the start are for prettiness only and aren't actually printed)

Title: Clean the muddy quartata-fish

Body:
Python 2, <s>433</s> 411 bytes

import re;i,o,l,j=input(),range,lambda s,r:s.replace(*r),"".join;i=l(l(l(i,".1"),"#."),"| ");s=o(len(i))
for x in s:
 for y in s:
    for q in s:
     r=map(list,l(l(i,"o."),"-.").split(" "))
     try:
        for v in o(q):r[x+v][y:y+q]=["".join(c*(q/3)for c in b)for b in["-o-","--o","ooo"]][3*v/q]
        m=re.match(i," ".join(j(i)for i in r))
     except:0
     if sum("-"in p for p in r)and m:print"|".join(l(j(i),"1.")for i in r);_

Exits with a NameError. Takes input pipe separated.

I'm mixing tabs and spaces here. SE doesn't render tabs properly.

'###o--....|###o--....|###-oo....|###-oo....|###ooo....|###ooo....|###.......'
 --oo--....|--oo--....|----oo....|----oo....|oooooo....|oooooo....|..........

'.....|.###.|.###.|.###.'
 .....|.-o-.|.--o.|.ooo.

'...-o-.|...-#o.|...ooo.|.......'
 ...-o-.|...--o.|...ooo.|.......

(Note extra spaces at the start are for prettiness only and aren't actually printed)


答:
Python 2, 31 bytes

def f(a,b):print a,b;f(a+b,a-b)
```

Prints forever. Well, eventually you exceed the recursion limit, but that's a system limitation.

Title: The plus-minus sequence

Body:
Python 2, 31 bytes

def f(a,b):print a,b;f(a+b,a-b)

Prints forever. Well, eventually you exceed the recursion limit, but that's a system limitation.


Title: The plus-minus sequence

Body:
Pyth, <s>10</s> 9 bytes

Thanks to @isaacg for 1 byte.

#=Q,s
Q-F

Prints an infinite sequence of pairs.

$ pyth plusminus.p <<< "[10,2]" | head -n 15
[10, 2]
[12, 8]
[20, 4]
[24, 16]
[40, 8]
[48, 32]
[80, 16]
[96, 64]
[160, 32]
[192, 128]
[320, 64]
[384, 256]
[640, 128]
[768, 512]
[1280, 256]


答:
Batch, 54 bytes

```<code>@echo %1 %2
@set/aa=%1+%2
@set/ab=%1-%2
@%0 %a% %b%
</code>```

Note that CMD.EXE is limited to 32-bit signed integers, so it will quickly overflow and print garbage and error messages.

Title: The plus-minus sequence

Body:
Batch, 54 bytes

@echo %1 %2
@set/aa=%1+%2
@set/ab=%1-%2
@%0 %a% %b%

Note that CMD.EXE is limited to 32-bit signed integers, so it will quickly overflow and print garbage and error messages.


答:
MATL, 10 bytes

```<code>`tDtswPdhT
</code>```

This version will  output an infinite number of elements in the plus-minus sequence.

Try it Online!
(stop it after running due to infinite loop)

Explanation

```<code>    % Implicitly grab input as a two-element array [a,b]
`   % do...while loop
tD  % Duplicate and display the top of the stack
ts  % Duplicate [a,b] and add them together
w   % Swap the top two elements on the stack
P   % Swap the order of b and a in preparation for diff
d   % Compute the difference between b and a
h   % Horizontally concatenate [a+b, a-b]
T   % Explicit TRUE to make it an infinite loop
    % Implicit end of the do...while loop
</code>```

Title: The plus-minus sequence

Body:
MATL, 10 bytes

`tDtswPdhT

This version will  output an infinite number of elements in the plus-minus sequence.

Try it Online!
(stop it after running due to infinite loop)

Explanation

    % Implicitly grab input as a two-element array [a,b]
`   % do...while loop
tD  % Duplicate and display the top of the stack
ts  % Duplicate [a,b] and add them together
w   % Swap the top two elements on the stack
P   % Swap the order of b and a in preparation for diff
d   % Compute the difference between b and a
h   % Horizontally concatenate [a+b, a-b]
T   % Explicit TRUE to make it an infinite loop
    % Implicit end of the do...while loop


问:
Simple cat program
One of the most common standard tasks (especially when showcasing esoteric programming languages) is to implement a "cat program": read all of STDIN and print it to STDOUT. While this is named after the Unix shell utility cat it is of course much less powerful than the real thing, which is normally used to print (and concatenate) several files read from disc.

Task

You should write a full program which reads the contents of the standard input stream and writes them verbatim to the standard output stream. If and only if your language does not support standard input and/or output streams (as understood in most languages), you may instead take these terms to mean their closest equivalent in your language (e.g. JavaScript's prompt and alert). These are the only admissible forms of I/O, as any other interface would largely change the nature of the task and make answers much less comparable.

The output should contain exactly the input and nothing else. The only exception to this rule is constant output of your language's interpreter that cannot be suppressed, such as a greeting, ANSI color codes or indentation. This also applies to trailing newlines. If the input does not contain a trailing newline, the output shouldn't include one either! (The only exception being if your language absolutely always prints a trailing newline after execution.)

Output to the standard error stream is ignored, so long as the standard output stream contains the expected output. In particular, this means your program can terminate with an error upon hitting the end of the stream (EOF), provided that doesn't pollute the standard output stream. If you do this, I encourage you to add an error-free version to your answer as well (for reference).

As this is intended as a challenge within each language and not between languages, there are a few language specific rules:

If it is at all possible in your language to distinguish null bytes in the standard input stream from the EOF, your program must support null bytes like any other bytes (that is, they have to be written to the standard output stream as well).

If it is at all possible in your language to support an arbitrary infinite input stream (i.e. if you can start printing bytes to the output before you hit EOF in the input), your program has to work correctly in this case. As an example yes | tr -d \\n | ./my_cat should print an infinite stream of ys. It is up to you how often you print and flush the standard output stream, but it must be guaranteed to happen after a finite amount of time, regardless of the stream (this means, in particular, that you cannot wait for a specific character like a linefeed before printing).

Please add a note to your answer about the exact behaviour regarding null-bytes, infinite streams, and extraneous output.

Additional rules

This is not about finding the language with the shortest solution for this (there are some where the empty program does the trick) - this is about finding the shortest solution in every language. Therefore, no answer will be marked as accepted.

Submissions in most languages will be scored in bytes in an appropriate preexisting encoding, usually (but not necessarily) UTF-8.

Some languages, like Folders, are a bit tricky to score. If in doubt, please ask on Meta.

Feel free to use a language (or language version) even if it's newer than this challenge. Languages specifically written to submit a 0-byte answer to this challenge are fair game but not particularly interesting.

Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language.

Also note that languages do have to fulfil our usual criteria for programming languages.

If your language of choice is a trivial variant of another (potentially more popular) language which already has an answer (think BASIC or SQL dialects, Unix shells or trivial Brainfuck derivatives like Headsecks or Unary), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

Unless they have been overruled earlier, all standard code-golf rules apply, including the http://meta.codegolf.stackexchange.com/q/1061.

As a side note, please don't downvote boring (but valid) answers in languages where there is not much to golf; these are still useful to this question as it tries to compile a catalogue as complete as possible. However, do primarily upvote answers in languages where the author actually had to put effort into golfing the code.

Catalogue

The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
Jelly, 1 byte

```<code>¹
</code>```

Simply the identity function.

Title: Simple cat program

Body:
Jelly, 1 byte

¹

Simply the identity function.


答:
Julia, <s>72</s> 43 bytes

n->n^2>1?sum(p->n÷/(p...),factor(n^2))/2:0
```

This is an anonymous function that accepts an integer and returns a float. To call it, assign it to a variable.

For an input integer n, if n2 ≤ 1 return 0. Otherwise obtain the prime factorization of n2 as a Dict, then for each prime/exponent pair, divide the prime by its exponent, then divide n by the result. This is just computing n x / p, where p is the prime factor and x is its exponent, which is the same as summing n / p, x times. We sum the resulting array and divide that by 2, since we've summed twice as much as we need. That's due to the fact that we're factoring n2 rather than n. (Doing that is a byte shorter than factoring |n|.)

Saved 29 bytes thanks to Dennis!

Title: The Arithmetic Derivative

Body:
The derivative of a function is a cornerstone of mathematics, engineering, physics, biology, chemistry, and a large number of other sciences as well. Today we're going to be calculating something only tangentially related: the arithmetic derivative.

Definition

The arithmetic derivative a(n) or n' is defined here (A003415) by a number of properties that are similar to the derivative of a function.

a(0) = a(1) = 0,

a(p) = 1, where p is any prime, and

a(mn) = m*a(n) + n*a(m).

The third rule is based on the product rule for differentiation of functions: for functions f(x) and g(x), (fg)' = f'g + fg'. So with numbers, (ab)' = a'b + ab'.

Also of note, since the arithmetic derivative can be extended to the negative numbers via this simple relation, a(-n) = -a(n), the input may be negative.

Rules

Write a program or function that, given any integer n, returns the arithmetic derivative of n.

Inputs will be -230 < n < 230, to avoid problems with integer sizes and numbers too large to factor in a reasonable amount of time. Your algorithm should still be able to theoretically calculate the arithmetic derivative of numbers outside this range.

Built-ins for symbolic math, prime factorization and differentiation are allowed.

Examples

```<code>> a(1)
0
> a(7)
1
> a(14)   # a(7)*2 + a(2)*7 = 1*2 + 1*7 = 9
9
> a(-5)   # a(-5) = -a(5) = -1
-1
> a(8)    # a(8) = a(2**3) = 3*2**2 = 12
12
> a(225)  # a(225) = a(9)*25 + a(25)*9 = 6*25 + 10*9 = 150 + 90 = 240
240
> a(299792458)  # a(299792458) = a(2)*149896229 + a(7)*42827494 + a(73)*4106746 + a(293339)*1022 = 1*149896229 + 1*42827494 + 1*4106746 + 1*1022 = 149896229 + 42827494 + 4106746 + 1022 = 196831491
196831491
</code>```

As always, if the problem is unclear, please let me know. Good luck and good golfing!

Body:
Julia, <s>72</s> 43 bytes

n->n^2>1?sum(p->n÷/(p...),factor(n^2))/2:0

This is an anonymous function that accepts an integer and returns a float. To call it, assign it to a variable.

For an input integer n, if n2 ≤ 1 return 0. Otherwise obtain the prime factorization of n2 as a Dict, then for each prime/exponent pair, divide the prime by its exponent, then divide n by the result. This is just computing n x / p, where p is the prime factor and x is its exponent, which is the same as summing n / p, x times. We sum the resulting array and divide that by 2, since we've summed twice as much as we need. That's due to the fact that we're factoring n2 rather than n. (Doing that is a byte shorter than factoring |n|.)

Saved 29 bytes thanks to Dennis!