答:
J, <s>66</s> 65 bytes

Uses the fact that f(m) = 2*(ord(m[0])+ord(m[-1]))//len(m) is a valid function in the limited domain of the 12 months:

```<code>>/@:('7/HEäWa<+0'&i.@(3 :'u:<.(#>y)%~+:+/3&u:({.>y),({:>y)')"0)"1
</code>```

Usage:

```<code>   bigger =: >/@:('7/HEäWa<+0'&i.@(3 :'u:<.(#>y)%~+:+/3&u:({.>y),({:>y)')"0)"1
   bigger ('May'; 'March')
1
   bigger ('May'; 'June')
0
</code>```

(By no means is this the best idea, but I didn't want steal anyone's ranking trick!)

Here is a shorter version using @atlasologist's method:

J, 63 bytes

```<code>m=:[:}.3{.]
[:>/(12 2$'anebarprayunulugepctovec')i.([:m[),:[:m]
</code>```

Usage:

```<code>   bigger =: [:>/(12 2$'anebarprayunulugepctovec')i.([:m[),:[:m]
   'January' bigger 'May'
0
   'June' bigger 'May'
1
</code>```

And a much shorter version using @Dennis's clever method:

J, 34 bytes

```<code>>&:('ubMAanlseov'&i.@:{.@:(10&|.))
</code>```

Title: Sort the months of the year

Body:
Write a function or program that takes string inputs, fully-spelled, English month names in title case: January, February, March, etc. (null/CR/LF terminated OK, delimited with some non-alpha character if you so choose) and either

compares two inputs, returning a Truthy value if the second input is greater (in month order) than the first. Equal values result in a Falsey value

or sorts an arbitrary sequence (list, delimited string, etc.) of them in chronological order

(The crux of the challenge is defining a method/expression that gives the correct lexicographical sort. Some languages might have a shorter answer with one or the other)

You cannot use any internal time parsing methods (e.g. strptime) to translate the month name into a number or a pre-canned mapping of month names. Use properties of the strings themselves, a parsimonious look-up table you define, or something clever.

Example

Functioning examples, though the first is prohibited by the rules...

```<code>import datetime
def is_later_month(a, b):
    '''
    Example of prohibited code because it relies on language
    features about how to parse month names
    '''
    return datetime.strptime(a, '%B') < datetime.strptime(b, '%B')
</code>```

The below versions are OK though, because we code that info

```<code>months = {
    'January':  1, 'February':  2, 'March':      3,
    'April':    4, 'May':       5, 'June':       6,
    'July':     7, 'August':    8, 'September':  9,
    'October': 10, 'November': 11, 'December':  12,
}
def is_later_month(a, b):
    """
    Returns True/False when comparing two months.
    """
    return months[a] < months[b]
</code>```

Or you could do a sorting function

```<code>months = {'as above...'}
def sort_months(l):
    """
    Sorts list and returns it. Different input and output than the above,
    but equally valid. Sorting versus comparing might be shorter in your
    favorite language.
    """
    return sorted(l, key=lambda x: months[x])
</code>```

Example tests

```<code>assert is_later_month('January', 'February')
assert is_later_month('January', 'December')
assert is_later_month('November', 'December')
assert not is_later_month('July', 'July')
assert not is_later_month('October', 'September')
</code>```

Body:
J, <s>66</s> 65 bytes

Uses the fact that f(m) = 2*(ord(m[0])+ord(m[-1]))//len(m) is a valid function in the limited domain of the 12 months:

>/@:('7/HEäWa<+0'&i.@(3 :'u:<.(#>y)%~+:+/3&u:({.>y),({:>y)')"0)"1

Usage:

   bigger =: >/@:('7/HEäWa<+0'&i.@(3 :'u:<.(#>y)%~+:+/3&u:({.>y),({:>y)')"0)"1
   bigger ('May'; 'March')
1
   bigger ('May'; 'June')
0

(By no means is this the best idea, but I didn't want steal anyone's ranking trick!)

Here is a shorter version using @atlasologist's method:

J, 63 bytes

m=:[:}.3{.]
[:>/(12 2$'anebarprayunulugepctovec')i.([:m[),:[:m]

Usage:

   bigger =: [:>/(12 2$'anebarprayunulugepctovec')i.([:m[),:[:m]
   'January' bigger 'May'
0
   'June' bigger 'May'
1

And a much shorter version using @Dennis's clever method:

J, 34 bytes

>&:('ubMAanlseov'&i.@:{.@:(10&|.))


问:
Cryptographic quine variant
Create a program that prints the MD5 sum of its source in the form:

```<code>MD5 sum of my source is: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
</code>```

No cheating - you can't just read the source file and compute its sum. The program must not read any external information.

Of course you can use a MD5 library available for your language.

答:
Python 157 149

```<code>r='r=%r;import md5;print "MD5 sum of my source is: "+md5.new(r%%r).hexdigest()';import md5;print "MD5 sum of my source is: "+md5.new(r%r).hexdigest()
</code>```

Output:

```<code>MD5 sum of my source is: bb74dfc895c13ab991c4336e75865426
</code>```

Verification at ideone

ContentLicense: CC BY-SA 3.0

Title: Cryptographic quine variant

Body:
Python 157 149

r='r=%r;import md5;print "MD5 sum of my source is: "+md5.new(r%%r).hexdigest()';import md5;print "MD5 sum of my source is: "+md5.new(r%r).hexdigest()

Output:

MD5 sum of my source is: bb74dfc895c13ab991c4336e75865426

Verification at ideone


答:
Python 2, <s>1033</s> <s>1007</s> <s>924</s> <s>879</s> <s>829</s> <s>787</s> <s>713</s> <s>699</s> <s>692</s> <s>691</s> <s>688</s> <s>687</s> <s>672</s> <s>670</s> <s>664</s> <s>659</s> <s>654</s> <s>648</s> <s>643</s> <s>642</s> <s>630</s> <s>625</s> <s>623</s> <s>620</s> <s>570</s> <s>560</s> <s>554</s> <s>545</s> <s>518</s> <s>514</s> <s>513</s> <s>510</s> <s>505</s> <s>492</s> <s>476</s> <s>454</s> <s>451</s> 443 bytes

6 bytes saved thanks to Riley

6 bytes saved thanks to Adnan

Since this question is over a year old and still has no answers I thought I'd give it a try.

n,i,o,u="\nI _";R=lambda x:range(1,x-1)
b=open(i).read()
s=b.split(n)
z=max(map(len,s))+3
a=[list(i+x.ljust(z,i))for x in[i]+s+[i]]
for x in R(len(a))*len(b):
 A=a[x];B=a[x+1];C=a[x-1]
 for y in R(z):
    D=A[y-1:y+2];k=B[y];j=A[y+1]
    if(i in[C[y],k]+D+(k==u)*B[y-1:y+2]or"V"==j)&(A[y]==o):A[y]=i
    if"|"==A[y]==C[y]:A[y]={i:"|",j:">",A[y-1]:"<"}[i]
    if[u]*3==D:A[y],B[y]={i:u+k,C[y]:"^"+k,k:" V"}[i]
print n.join(`y`[2::5]for y in a).replace(i,o)
```
<p>Try it online!</p>
<p>The program reads the table a file named <code>I</code> and prints the table with its chairs to <code>std::out</code>.  I was not sure about a bunch of the edge cases so I took my best judgement (whatever took the least effort) but it seems to pass all the test cases.  Some of the outputs don't match exactly but they all have the same number of chairs.</p>
<h2>Explanation</h2>
<p>The first line pretty simply sets up some definitions that will save us bytes in the future:</p>
<p><em>(I will unpack these macros for readability in future lines)</em></p>
<pre class="lang-python prettyprint-override"><code>n,i,o="\nI ";R=lambda x:range(1,x-1)
</code>```

Then we will open a file named I because we already have a variable that is short for that so it saves a few bytes.

b=open("I").read().split("\n")
```
<p>We split along newlines to create a list of strings (The rows of the image)</p>
<pre class="lang-python prettyprint-override"><code>s=b.split(n)
</code>```

I then find the length of the longest line so that I can pad all lines to that length.  (I also add 3 because we need a bit of additional padding)

 z=max(map(len,s))+3
```
<p>Then we perform the actual padding and create a border of <code>I</code> characters around the edge.  This is because we will need to tell the difference between the inside and the outside of the shape later on.  We will also change the data type from a list of strings to a list of list of characters (length 1 strings).</p>
<pre class="lang-python prettyprint-override"><code>a=[list("I"+x.ljust(z,"I"))for x in["I"]+s+["I"]]
</code>```

The next line is just another byte saving definition.

(I will also unpack this one)

B=R(len(a))
```
<p>Now we want to spread <code>I</code> characters to everywhere outside of the shape.  We can do this with a pseudo-cellular automaton.  Each <code>I</code> will spread to any adjacent <code> </code> characters.  We could loop until the automaton stabilizes however this cannot take more iterations than there are characters so we just loop through every character in <code>b</code> (the original input)</p>
<pre class="lang-python prettyprint-override"><code>for _ in b:
</code>```

For each iteration we want to pass over every character in the 2D list (excluding the outermost padding)

 for x in range(1,len(a)-1):
    A=a[x]  #<--Another definition I will fill in for clarity
    for y in range(1,z-1):
```
<p>For each position we run the following code:</p>
<pre class="lang-python prettyprint-override"><code>if("I" in[a[x+1][y],a[x-1][y]]+a[x][y-1:y+2])&(a[x][y]==" "):a[x][y]=" "
</code>```

Lets break this down.

We have an if with two conditions separated by a & (bitwise and)

The first one simply checks if there is an I in any of the adjacent cells and the second one just checks if the current cell is a " ".  If we pass those conditions we set the current cell to be an I.

Now that we have determined the outside and inside of the shape we can start to place the chairs around the table.

Once again we loop through all of the cells (and set some more shorthands)

for x in range(1,len(a)-1):
 A=a[x]
 for y in range(1,z-1):
        k=a[x+1][y]

```
<p>Now here's my favorite part.  If you have trudged through my boring, mostly definition based, golfing so far I am going to reward you with a nice tidbit of clever golfing (if I do say so myself).</p>
<p>A little background in python:</p>
<p>In Python if you attempt to assign an dictionary key twice it asigns the latter one.  For example</p>
<pre class="lang-python prettyprint-override"><code>>>> {1:"a",1:"b"}[1]
'b'
</code>```

We will abuse this property to assign the current cell to a particular character.

The first condition is

if["_"]*3==a[x][y-1:y+2]:a[x][y],a[x+1][y]={"I":"_"+a[x+1][y],a[x-1][y]:"^ ",a[x+1][y]:" V"}["I"]
```
<p>If the cell is in the middle of an edge of 3 <code>_</code> characters we will reassign the current cell and the cell below it.  We will assign it to the result of indexing an overloaded dictionary by <code>I</code>.  We first set our default with the pair <code>"I":"_"+a[x+1][y]</code> this means if there is no change we will assign the two cells back to their original values.  Next we add the pair <code>a[x-1][y]:"^ "</code>.  This wont do anything (important) unless the cell above the current one (<code>a[x-1][y]</code>) is filled with an <code>I</code>.  If it has an <code>I</code> in it it will override the default telling us to place a chair at the current cell.  Next we move on to the cell below the current cell if that cell is <code>I</code> we again override to place an upwards facing chair below the current spot.</p>
<p>The next condition is a tad simpler</p>
<pre class="lang-python prettyprint-override"><code>if"|"==a[x][y]==a[x-1][y]:a[x][y]={"I":"|",A[y+1]:">",A[y-1]:"<"}["I"]
</code>```

We check if the current cell and the cell above it are both |.  If so we set up a dictionary.

The first pair in the dictionary "I":"|" sets the default.  Since we are going to access the key I if I does not get reassigned it will default back to | (the character it already is) and do nothing.

We the add the two keys A[y+1]:">",A[y-1]:"<" If either of the two cells to the left and right are I then it will reassign the current cell to a chair pointing in the direction of the outside.

Now we just have to output.  However we can't just print,  there are a couple of housekeeping things we have to do first.  We have to convert back to a string and remove all of the Is we created.  This is done in one line.

print "\n".join(`y`[2::5]for y in a).replace("I"," ")
```

Title: Given a table, place in the chairs

Body:
Challenge

You will be given a table as input, drawn with ASCII | and _. Your task is to set the chairs around it.

Example

Input:

```<code> ____
|    |
|    |
|    |
|    |
|____|
</code>```

Output:

```<code> _^_^_
<     >
|     |
<     >
|     |
<_ _ _>
  v v
</code>```

Those chairs are made of <> and v^.

Another example:

The line must have as many chairs as possible in it.

```<code>  _____
 |     |_____
 |           |
 |           |
 |           |
 |      _____|
 |_____|

  _^_^_
 <     |_^_^_
 |           >
 <           |
 |           |
 <      _ _ _>
 |_ _ _| v v
   v v
</code>```

There must be spaces between every chair. And >_^_^_< is invalid, it should be |_^_^_|.

```<code>  _____       _____
 |     |_____|     |
 |                 |
 |                 |
 |                 |
 |      ___________|
 |_____|

  _^_^_       _^_^_
 <     |_^_^_|     >
 |                 |
 <                 >
 |                 |
 <      _ _ _ _ _ _>
 |_ _ _| v v v v v
   v v
</code>```

No chairs may be on the inside of a "donut".

```<code>  _________________
 |      _____      |
 |     |     |     |
 |     |     |     |
 |     |_____|     |
 |_________________|

  _^_^_^_^_^_^_^_^_
 <      _____      >
 |     |     |     |
 <     |     |     >
 |     |_____|     |
 <_ _ _ _ _ _ _ _ _>
   v v v v v v v v
</code>```

^ and v prioritise < and >. No chair on it's own (it has to have at least one | or _ in the row).

```<code>  _________________
 |      _____      |
 |     |     |     |
 |     |     |_____|
 |     |_____
 |___________|

  _^_^_^_^_^_^_^_^_
 <      _ _ _      >
 |     | v v |     |
 <     >     <_ _ _>
 |     |_^_^_  v v
 <_ _ _ _ _ _|
   v v v v v
</code>```

This is code golf, so shortest code wins.

Body:
Python 2, <s>1033</s> <s>1007</s> <s>924</s> <s>879</s> <s>829</s> <s>787</s> <s>713</s> <s>699</s> <s>692</s> <s>691</s> <s>688</s> <s>687</s> <s>672</s> <s>670</s> <s>664</s> <s>659</s> <s>654</s> <s>648</s> <s>643</s> <s>642</s> <s>630</s> <s>625</s> <s>623</s> <s>620</s> <s>570</s> <s>560</s> <s>554</s> <s>545</s> <s>518</s> <s>514</s> <s>513</s> <s>510</s> <s>505</s> <s>492</s> <s>476</s> <s>454</s> <s>451</s> 443 bytes

6 bytes saved thanks to Riley

6 bytes saved thanks to Adnan

Since this question is over a year old and still has no answers I thought I'd give it a try.

n,i,o,u="\nI _";R=lambda x:range(1,x-1)
b=open(i).read()
s=b.split(n)
z=max(map(len,s))+3
a=[list(i+x.ljust(z,i))for x in[i]+s+[i]]
for x in R(len(a))*len(b):
 A=a[x];B=a[x+1];C=a[x-1]
 for y in R(z):
    D=A[y-1:y+2];k=B[y];j=A[y+1]
    if(i in[C[y],k]+D+(k==u)*B[y-1:y+2]or"V"==j)&(A[y]==o):A[y]=i
    if"|"==A[y]==C[y]:A[y]={i:"|",j:">",A[y-1]:"<"}[i]
    if[u]*3==D:A[y],B[y]={i:u+k,C[y]:"^"+k,k:" V"}[i]
print n.join(`y`[2::5]for y in a).replace(i,o)

<a href="https://tio.run/nexus/python2#lVTNb5swFD/Xf4XlSYsdnEi02gXmSU1z2bWHXqiXmjadTAhEkEgk8/72zObTQKJ272A/P36/5/dlQjaZTABcVQIUrKTZVxcE2mLZh2Q15muj5aIBlHrHrqCqF0QvKNWsqsF3bMtjB1bX2RB2VFXf21Lrozk3MdlUO@dO1CBnBW2Msq8BavWxqCu@FQDgQoMu96bsTxPIoAVDrT6DrlKDdZzlGD4Kvefbgo9Hqh96C7fyawdjHLuq4XZabTvV/8BHlWmGsoXXXRxUXg22Bn7F7QdwqwifgCs4GO7@U7Tgdn/G8HbUwYWuqN4D6Y0quPwQFNA/mXNCJU3pgaHn5CdcIf@RxWIbvglYeJlIfq@xS4uZS8CXkKW7dYIlmWdr8YYJyFk4z3ex3OOEgBPbigJvxQ7H64TmhDh3QLAglvkeS6eYx9FBaycqCXlPM1hAmQSSO7mjVw4aE3w0dCwImZo9JB6A90wEBfcXZnNc7j8YZeZyAA3rWLFOGnmzZPfBceZ6R@eW@xu2CI7cj4xN08CNfMfS3PqgzXTDnaWDN4wdyHTRktIMPSHGIvIVaxZnLCVeqUhDR0p/q@zGR/Xlj/S0nUYe@oFoeT330Hf0V6dlOMGBT@8YW5ZguqgZB2dDSxfoF9LqxkPwqaLsMpnsYTKPUpngl@NLcOt533ibqDDF38XidY1118j5/A8" rel="nofollow noreferrer">Try it online!

The program reads the table a file named I and prints the table with its chairs to std::out.  I was not sure about a bunch of the edge cases so I took my best judgement (whatever took the least effort) but it seems to pass all the test cases.  Some of the outputs don't match exactly but they all have the same number of chairs.

Explanation

The first line pretty simply sets up some definitions that will save us bytes in the future:

(I will unpack these macros for readability in future lines)

n,i,o="\nI ";R=lambda x:range(1,x-1)

Then we will open a file named I because we already have a variable that is short for that so it saves a few bytes.

b=open("I").read().split("\n")

We split along newlines to create a list of strings (The rows of the image)

s=b.split(n)

I then find the length of the longest line so that I can pad all lines to that length.  (I also add 3 because we need a bit of additional padding)

 z=max(map(len,s))+3

Then we perform the actual padding and create a border of I characters around the edge.  This is because we will need to tell the difference between the inside and the outside of the shape later on.  We will also change the data type from a list of strings to a list of list of characters (length 1 strings).

a=[list("I"+x.ljust(z,"I"))for x in["I"]+s+["I"]]

The next line is just another byte saving definition.

(I will also unpack this one)

B=R(len(a))

Now we want to spread I characters to everywhere outside of the shape.  We can do this with a pseudo-cellular automaton.  Each I will spread to any adjacent   characters.  We could loop until the automaton stabilizes however this cannot take more iterations than there are characters so we just loop through every character in b (the original input)

for _ in b:

For each iteration we want to pass over every character in the 2D list (excluding the outermost padding)

 for x in range(1,len(a)-1):
    A=a[x]  #<--Another definition I will fill in for clarity
    for y in range(1,z-1):

For each position we run the following code:

if("I" in[a[x+1][y],a[x-1][y]]+a[x][y-1:y+2])&(a[x][y]==" "):a[x][y]=" "

Lets break this down.

We have an if with two conditions separated by a & (bitwise and)

The first one simply checks if there is an I in any of the adjacent cells and the second one just checks if the current cell is a " ".  If we pass those conditions we set the current cell to be an I.

Now that we have determined the outside and inside of the shape we can start to place the chairs around the table.

Once again we loop through all of the cells (and set some more shorthands)

for x in range(1,len(a)-1):
 A=a[x]
 for y in range(1,z-1):
        k=a[x+1][y]

Now here's my favorite part.  If you have trudged through my boring, mostly definition based, golfing so far I am going to reward you with a nice tidbit of clever golfing (if I do say so myself).

A little background in python:

In Python if you attempt to assign an dictionary key twice it asigns the latter one.  For example

>>> {1:"a",1:"b"}[1]
'b'

We will abuse this property to assign the current cell to a particular character.

The first condition is

if["_"]*3==a[x][y-1:y+2]:a[x][y],a[x+1][y]={"I":"_"+a[x+1][y],a[x-1][y]:"^ ",a[x+1][y]:" V"}["I"]

If the cell is in the middle of an edge of 3 _ characters we will reassign the current cell and the cell below it.  We will assign it to the result of indexing an overloaded dictionary by I.  We first set our default with the pair "I":"_"+a[x+1][y] this means if there is no change we will assign the two cells back to their original values.  Next we add the pair a[x-1][y]:"^ ".  This wont do anything (important) unless the cell above the current one (a[x-1][y]) is filled with an I.  If it has an I in it it will override the default telling us to place a chair at the current cell.  Next we move on to the cell below the current cell if that cell is I we again override to place an upwards facing chair below the current spot.

The next condition is a tad simpler

if"|"==a[x][y]==a[x-1][y]:a[x][y]={"I":"|",A[y+1]:">",A[y-1]:"<"}["I"]

We check if the current cell and the cell above it are both |.  If so we set up a dictionary.

The first pair in the dictionary "I":"|" sets the default.  Since we are going to access the key I if I does not get reassigned it will default back to | (the character it already is) and do nothing.

We the add the two keys A[y+1]:">",A[y-1]:"<" If either of the two cells to the left and right are I then it will reassign the current cell to a chair pointing in the direction of the outside.

Now we just have to output.  However we can't just print,  there are a couple of housekeeping things we have to do first.  We have to convert back to a string and remove all of the Is we created.  This is done in one line.

print "\n".join(`y`[2::5]for y in a).replace("I"," ")


问:
Lemon-Limify a String
Write a program or function that takes in a nonempty single-line string. You may assume it only contains printable ASCII excluding space.

Print or return an ASCII art lozenge shape similar to a lemon or lime made from the prefixes of the string.

Suppose the input string is n letters long. Then, such a shape consists of 2n − 1 columns of ASCII art stitched together, each consisting of 2n − 1 lines. Counting from 1, the k-th column is f(k) = min(k, 2n − k) characters wide, and contains f(k) copies of the first f(k) characters of input, centered vertically, with single blank lines separating the copies.

For example, if the input is Lemon, the output should be:

```<code>          Lemon
      Lemo     Lemo
   Lem    Lemon    Lem
 Le   Lemo     Lemo   Le
L  Lem    Lemon    Lem  L
 Le   Lemo     Lemo   Le
   Lem    Lemon    Lem
      Lemo     Lemo
          Lemon
</code>```

If the input is lime the output should be:

```<code>      lime
   lim    lim
 li   lime   li
l  lim    lim  l
 li   lime   li
   lim    lim
      lime
</code>```

And the same pattern is followed for other inputs:

```<code>a

a

Be

 Be
B  B
 Be

/\

 /\
/  /
 /\

cat

   cat
 ca   ca
c  cat  c
 ca   ca
   cat

|||

   |||
 ||   ||
|  |||  |
 ||   ||
   |||

.__.

      .__.
   .__    .__
 ._   .__.   ._
.  .__    .__  .
 ._   .__.   ._
   .__    .__
      .__.

$tring

               $tring
          $trin      $trin
      $tri     $tring     $tri
   $tr    $trin      $trin    $tr
 $t   $tri     $tring     $tri   $t
$  $tr    $trin      $trin    $tr  $
 $t   $tri     $tring     $tri   $t
   $tr    $trin      $trin    $tr
      $tri     $tring     $tri
          $trin      $trin
               $tring
</code>```

Lines in the output may have trailing spaces and there may be one optional trailing newline.

The shortest code in bytes wins.

答:
JavaScript, <s>187</s> 178 bytes

A bitwise approach. Function m defines a mask by starting at 2 ** length, e.g. 00100 in binary, and defining m(n) = m(n-1) << 1 | m(n-1) >> 1 for the first half. Interestingly the second half can be defined as m(n) = m(n-1) << 1 & m(n-1) >> 1. (though the program instead opts to define m(n) = m(2 * length - 1) for the second half) From here these masks can be used to determine whether a word or space should appear by checking 2 ** column & m(row). Of course in JavaScript it's shorter to write 2 ** something with 1 << something...

note: written while tired. <s>May</s> Almost surely does have mistakes.

```<code>s=>{m=n=>n?n>l?m(2*l-n):(p=m(n-1))>>1|p<<1:1<<l
for(r=0;r/2<=(l=s.length-1);r++){for(i=1,o="";i/2-1<l;i++)o+=(1<<i-1&m(r)?s:" ".repeat(i)).slice(0,i>l?2*l+2-i:i)
console.log(o)}}
</code>```

Title: Lemon-Limify a String

Body:
JavaScript, <s>187</s> 178 bytes

A bitwise approach. Function m defines a mask by starting at 2 ** length, e.g. 00100 in binary, and defining m(n) = m(n-1) << 1 | m(n-1) >> 1 for the first half. Interestingly the second half can be defined as m(n) = m(n-1) << 1 & m(n-1) >> 1. (though the program instead opts to define m(n) = m(2 * length - 1) for the second half) From here these masks can be used to determine whether a word or space should appear by checking 2 ** column & m(row). Of course in JavaScript it's shorter to write 2 ** something with 1 << something...

note: written while tired. <s>May</s> Almost surely does have mistakes.

s=>{m=n=>n?n>l?m(2*l-n):(p=m(n-1))>>1|p<<1:1<<l
for(r=0;r/2<=(l=s.length-1);r++){for(i=1,o="";i/2-1<l;i++)o+=(1<<i-1&m(r)?s:" ".repeat(i)).slice(0,i>l?2*l+2-i:i)
console.log(o)}}


问:
Tips for golfing in JavaScript
What general tips do you have for golfing in JavaScript? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to JavaScript (e.g. "remove comments" is not an answer).

Note: Also see Tips for Golfing in ECMAScript 6 and above

答:
2 to a power

If for some reason you need to calculate 2 to the nth power,

1<<n is shorter than Math.pow(2,n).

If you needed to calculate 2 to the n+1th power,

2<<n is even shorter than 1<<n+1

Likewise for 4<<n for n+2, 8<<n for n+3, 16<<n for n+4, etc.

(sorry if this is too obvious)

Title: Tips for golfing in JavaScript


问:
Print an alphabet wave
You are to print this exact text:

```<code>ABABABABABABABABABABABABAB
BCBCBCBCBCBCBCBCBCBCBCBCBC
CDCDCDCDCDCDCDCDCDCDCDCDCD
DEDEDEDEDEDEDEDEDEDEDEDEDE
EFEFEFEFEFEFEFEFEFEFEFEFEF
FGFGFGFGFGFGFGFGFGFGFGFGFG
GHGHGHGHGHGHGHGHGHGHGHGHGH
HIHIHIHIHIHIHIHIHIHIHIHIHI
IJIJIJIJIJIJIJIJIJIJIJIJIJ
JKJKJKJKJKJKJKJKJKJKJKJKJK
KLKLKLKLKLKLKLKLKLKLKLKLKL
LMLMLMLMLMLMLMLMLMLMLMLMLM
MNMNMNMNMNMNMNMNMNMNMNMNMN
NONONONONONONONONONONONONO
OPOPOPOPOPOPOPOPOPOPOPOPOP
PQPQPQPQPQPQPQPQPQPQPQPQPQ
QRQRQRQRQRQRQRQRQRQRQRQRQR
RSRSRSRSRSRSRSRSRSRSRSRSRS
STSTSTSTSTSTSTSTSTSTSTSTST
TUTUTUTUTUTUTUTUTUTUTUTUTU
UVUVUVUVUVUVUVUVUVUVUVUVUV
VWVWVWVWVWVWVWVWVWVWVWVWVW
WXWXWXWXWXWXWXWXWXWXWXWXWX
XYXYXYXYXYXYXYXYXYXYXYXYXY
YZYZYZYZYZYZYZYZYZYZYZYZYZ
ZAZAZAZAZAZAZAZAZAZAZAZAZA
</code>```

Specs

You can print all lowercase instead of all uppercase. However, case must be consistent throughout the output.

You may print one extra trailing linefeed.

Scoring

Since this is an alphabet wave that fluctuates to a small extent, your code should also be small in terms of byte-count. In fact, the smallest code in terms of byte-count wins.

答:
Python 2.7, 65 bytes

Python 2 alternative using a recursive function

```<code>def l(a=0):
 print(chr(a+65)+chr(-~a%26+65))*13
 if a<25:l(-~a)
</code>```

Title: Print an alphabet wave

Body:
Python 2.7, 65 bytes

Python 2 alternative using a recursive function

def l(a=0):
 print(chr(a+65)+chr(-~a%26+65))*13
 if a<25:l(-~a)


问:
Can you outgolf me? (Cops section)

Cops section

The robbers section can be found here.

Thanks to FryAmTheEggman, Peter Taylor, Nathan Merrill, xnor, Dennis, Laikoni and Mego for their contributions.

Challenge

Your task is to write 2 different programs (full programs/functions/etc.) in the same language and the same version (e.g. Python 3.5 ≠ Python 3.4, so that is not allowed), and when given n (using STDIN/function arguments/etc.), compute a(n) where a is an OEIS sequence of your choice. One of those programs is shorter than the other. You only need to submit the longer program of the two. The other one needs to be saved in case of not being cracked after 7 days. Your submission is cracked when your program has been outgolfed (whether it is by 1 byte or more).

For example, if the task you chose was to perform 2 × n, this could be a valid submission (in Python 2):

Python 2, 16 bytes, score = 15 / 16 = 0.9375

```<code>print(2*input())
</code>```

Computes A005843, (offset = 0).

If your submission has been cracked, then you need to state that in your header like so:

Python 2, 16 bytes, score = 15 / 16 = 0.9375, [cracked] + link

```<code>print(2*input())
</code>```

Computes A005843, (offset = 0).

Offset

This can be found on every OEIS page. For example, for A005843, the offset is 0,2. We only need to use the first one, which is 0. This means that the function is defined for all numbers ≥ 0.

In other words, the function OEIS(n) starts with n = 0. Your program needs to work for all cases given by OEIS.

More information can be found here.

Scoring

The score you get for your submission is equal to the following formula:

Score = Length (in bytes) of secret code ÷ Length (in bytes) of public code

The example above has the score 15 ÷ 16 = 0.9375.

The submission with the lowest score wins. Only submissions that have posted their solution will be eligible for winning.

Rules

The task you need to do is an OEIS sequence of your choice.

Given n, output OEIS(n). Deviation is not allowed, so you need to produce the exact same sequence (when given n, you need to output OEIS(n)).

Submissions that are not cracked within a period of 7 days are considered safe after the solution has been posted (submissions older than 7 days that do not have their solution posted are still vulnerable in being cracked).

In your submission, you need to post the following things: language name, byte count, full code, so no pastebin links etc. (to prevent answers like Unary), OEIS sequence, score with lengths of both programs and additionally, the encoding that is used.

Note: the same sequence cannot be posted twice in the same language. (For example, if the sequence A005843 has been done in Pyth, you cannot use Pyth again for that same sequence.)

Input and output are both in decimal (base 10)

Leaderboard

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

Uncracked submissions

 Language	 Score	 User

Sort by: score creation

Safe submissions

 Language	 Score	 User

```

Note

This challenge is finished. The final winner is feersum with his Seed answer. Congratulations! :).

You can still submit new cops, but be aware that they are no longer competing.

答:
Stack Cats, 14 bytes, score = 13 / 14 = 0.929 [cracked]

That's 10 bytes of code, plus 4 for the arguments  -nm.

Computes A017053. In case OEIS is down, that's a(n) = 7n + 6, starting at n = 0.

```<code>![_-_:-_-_
</code>```

The full code (usable without -m argument) is ![_-_:-_-_-_-:_-_]!

The hidden solution was

```<code>!]|{_+:}_
</code>```

Title: Can you outgolf me? (Cops section)

Body:
Stack Cats, 14 bytes, score = 13 / 14 = 0.929 [cracked]

That's 10 bytes of code, plus 4 for the arguments  -nm.

Computes A017053. In case OEIS is down, that's a(n) = 7n + 6, starting at n = 0.

![_-_:-_-_

The full code (usable without -m argument) is ![_-_:-_-_-_-:_-_]!

The hidden solution was

!]|{_+:}_


问:
Showcase of Languages

Notes

This thread is open and unlocked only because the community decided to make an exception. Please do not use this question as evidence that you can ask similar questions here. Please do not create additional showcase questions.

This is no longer a popularity-contest, nor are snippet lengths limited by the vote tally. If you know this thread from before, please make sure you familiarize yourself with the changes.

This thread is dedicated to showing off interesting, useful, obscure, and/or unique features your favorite programming languages have to offer. This is neither a challenge nor a competition, but a collaboration effort to showcase as many programming languages as possible as well as possible.

How this works

All answers should include the name of the programming language at the top of the post, prefixed by a #.

Answers may contain one (and only one) factoid, i.e., a couple of sentences without code that describe the language.

Aside from the factoid, answers should consist of snippets of code, which can (but don't have to be) programs or functions.

The snippets do not need to be related. In fact, snippets that are too related may be redundant.

Since this is not a contest, all programming languages are welcome, whenever they were created.

Answers that contain more than a handful of code snippets should use a Stack Snippet to collapse everything except the factoid and one of the snippets.

Whenever possible, there should be only one answer per programming language. This is a community wiki, so feel free to add snippets to any answer, even if you haven't created it yourself. There is a Stack Snippet for compressing posts, which should mitigate the effect of the 30,000 character limit.

Answers that predate these guidelines should be edited. Please help updating them as needed.

Current answers, sorted alphabetically by language name

$.ajax({type:"GET",url:"https://api.stackexchange.com/2.2/questions/44680/answers?site=codegolf&filter=withbody",success:function(data){for(var i=0;i<data.items.length;i++){var temp=document.createElement('p');temp.innerHTML = data.items[i].body.split("\n")[0];$('#list').append('
' + temp.innerText || temp.textContent + '');}}})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><base href="http://codegolf.stackexchange.com"><ul id="list"></ul></code>```

答:
Coffeescript

Description:

Coffeescript is a language that compiles into Javascript. It's much less verbose than JS (and about the same as ES6), which makes it friendlier for code-golfing.

Factoid:

Coffeescript doesn't require brackets with function calls.

Length 1 Snippet:

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

The = sign means a lot of things in Coffeescript - it can assign both functions and variables in one fell swoop, much like Javascript.

Length 2 Snippet:

```<code>**
</code>```

This is the power sign, which is used like this: a**b. It replaces JS's Math.pow(a,b), which saves 11 bytes.

Length 3 Snippet:

```<code>(n)
</code>```

This is an argument in CoffeeScript, and is used like so:

```<code>{function name} = (arg1, arg2...) ->
</code>```

(This is basically the same as JS, but I just wanted to show off functions - because they're so different).

Length 4 Snippet:

```<code>0..5
</code>```

For-loops are different in CoffeeScript. This snippet, when put into this context:

```<code>for a in[0..5]
</code>```

Is the same as JavaScript's

```<code>for (a=0, a<5, a++)
</code>```

and Python's

```<code>for a in range(5)
</code>```

As you can see, this snippet shows the byte-saving powers of CS.

Length 5 Snippet:

```<code>n=->1
</code>```

Yay, a full function!

This snippet creates a function, n, with no arguments, which outputs 1.

Length 6 Snippet:

```<code>if n<1
</code>```

This is an if statement, in CS. Notice the lack of a colon, or curly brackets (yes, no curly brackets!). This compares n, and checks if it's less than 1.

Simple enough.

Length 7 Snippet:

```<code>**
</code>```0

This is a class declaration in CoffeeScript. Despite there being no support for classes in JavaScript, there's classes in CS - and they work exactly the way you expect them to.

Title: Showcase of Languages

Body:
Coffeescript

Description:

Coffeescript is a language that compiles into Javascript. It's much less verbose than JS (and about the same as ES6), which makes it friendlier for code-golfing.

Factoid:

Coffeescript doesn't require brackets with function calls.

Length 1 Snippet:

=

The = sign means a lot of things in Coffeescript - it can assign both functions and variables in one fell swoop, much like Javascript.

Length 2 Snippet:

**

This is the power sign, which is used like this: a**b. It replaces JS's Math.pow(a,b), which saves 11 bytes.

Length 3 Snippet:

(n)

This is an argument in CoffeeScript, and is used like so:

{function name} = (arg1, arg2...) ->

(This is basically the same as JS, but I just wanted to show off functions - because they're so different).

Length 4 Snippet:

0..5

For-loops are different in CoffeeScript. This snippet, when put into this context:

for a in[0..5]

Is the same as JavaScript's

for (a=0, a<5, a++)

and Python's

for a in range(5)

As you can see, this snippet shows the byte-saving powers of CS.

Length 5 Snippet:

n=->1

Yay, a full function!

This snippet creates a function, n, with no arguments, which outputs 1.

Length 6 Snippet:

if n<1

This is an if statement, in CS. Notice the lack of a colon, or curly brackets (yes, no curly brackets!). This compares n, and checks if it's less than 1.

Simple enough.

Length 7 Snippet:

class A

This is a class declaration in CoffeeScript. Despite there being no support for classes in JavaScript, there's classes in CS - and they work exactly the way you expect them to.


问:
Input ∩ Source Code

Intro

The challenge is to create a program/function that prints the intersection of its own source code and a given string input. This is code golf and to be more precise:

Let I be the input set

{"a","b","c"}

Let S be the source code set

{"b","f"}

Then the intersection is what they share

I ∩ S = {"b"}

Input

Input is flexible. It should be able to handle the character encoding used for the source code.

Output

Output is flexible. It should be the set of characters that the input and source code share. Also, sets are unordered collections of distinct objects. In summary:

Output is flexible:

Could be any data structure (string or otherwise)

Could unordered

Could have a trailing \n

Should be distinct

Restriction

Similar to quine challenges, the program/function may not read its own source code and 0-byte solutions are not allowed.

Examples

#1

```<code>functor x(I){ return I ∩ self; }

Inputs                                Outputs
------                                -------
enter preformatted text here      ->  {"e","n","t","r","f","o","x"}

["Albrt"," Einstin"]              ->  {"l","r","t","n","s"}
</code>```

#2

```<code>(_)->_&"(_)->&\"\\"

Inputs                                Outputs
------                                -------
"Security at the expense of       ->  "
usability comes at the expense
of security."

(0____0)                          ->  (_)
</code>```

#3

```<code>ಠa益длф

Inputs                                Outputs
------                                -------
Far out in the uncharted backwaters ->"a"
of the unfashionable end of the
Western Spiral arm of the Galaxy lies
a small unregarded yellow sun.
Orbiting this at a distance of roughly
ninety-eight million miles is an
utterly insignificant little blue-green
planet whose ape-descended life forms
are so amazingly primitive that they
still think digital watches are a pretty
neat idea.

(ノಠ益ಠ)ノ彡┻━┻                      ->"ಠ益"
</code>```

Test Cases

```<code>Albert Einstein

\__( O__O)_/

!@#$%^&*()_+{}|:"<>?

1234567890-=[]\;',./

(ノಠ益ಠ)ノ彡┻━┻

“¤>%,oỊȤʠ“ØụĊ5D³ṃṠɼQ»j;Ç;“;}¶”

┬──┬ ノ( ゜-゜ノ)

Far out in the uncharted backwaters of the unfashionable end of the Western Spiral arm of the Galaxy lies a small unregarded yellow sun. Orbiting this at a distance of roughly ninety-eight million miles is an utterly insignificant little blue-green planet whose ape-descended life forms are so amazingly primitive that they still think digital watches are a pretty neat idea.
</code>```

Update

[16-08-10]: sets are unordered collections of distinct objects

[16-08-10]: trailing newline is acceptable

答:
Brachylog, 23 bytes

```<code>:{e.~e":{}e~\"fd\."}fd.
</code>```

Try it online!

Explanation

```<code>:{                 }f      Find all chars that verify the predicate below
                     d.    Remove duplicates and output

  e.                       Take a char from the input ; this is our output…
    ~e":{}e~\"fd\."        … if that char is in the string :{}e~"fd. (the first \ is here
                               to escape the ")
</code>```

Title: Input ∩ Source Code

Body:
Brachylog, 23 bytes

:{e.~e":{}e~\"fd\."}fd.

Try it online!

Explanation

:{                 }f      Find all chars that verify the predicate below
                     d.    Remove duplicates and output

  e.                       Take a char from the input ; this is our output…
    ~e":{}e~\"fd\."        … if that char is in the string :{}e~"fd. (the first \ is here
                               to escape the ")


问:
Sort the months of the year
Write a function or program that takes string inputs, fully-spelled, English month names in title case: January, February, March, etc. (null/CR/LF terminated OK, delimited with some non-alpha character if you so choose) and either

compares two inputs, returning a Truthy value if the second input is greater (in month order) than the first. Equal values result in a Falsey value

or sorts an arbitrary sequence (list, delimited string, etc.) of them in chronological order

(The crux of the challenge is defining a method/expression that gives the correct lexicographical sort. Some languages might have a shorter answer with one or the other)

You cannot use any internal time parsing methods (e.g. strptime) to translate the month name into a number or a pre-canned mapping of month names. Use properties of the strings themselves, a parsimonious look-up table you define, or something clever.

Example

Functioning examples, though the first is prohibited by the rules...

```<code>import datetime
def is_later_month(a, b):
    '''
    Example of prohibited code because it relies on language
    features about how to parse month names
    '''
    return datetime.strptime(a, '%B') < datetime.strptime(b, '%B')
</code>```

The below versions are OK though, because we code that info

```<code>months = {
    'January':  1, 'February':  2, 'March':      3,
    'April':    4, 'May':       5, 'June':       6,
    'July':     7, 'August':    8, 'September':  9,
    'October': 10, 'November': 11, 'December':  12,
}
def is_later_month(a, b):
    """
    Returns True/False when comparing two months.
    """
    return months[a] < months[b]
</code>```

Or you could do a sorting function

```<code>months = {'as above...'}
def sort_months(l):
    """
    Sorts list and returns it. Different input and output than the above,
    but equally valid. Sorting versus comparing might be shorter in your
    favorite language.
    """
    return sorted(l, key=lambda x: months[x])
</code>```

Example tests

```<code>assert is_later_month('January', 'February')
assert is_later_month('January', 'December')
assert is_later_month('November', 'December')
assert not is_later_month('July', 'July')
assert not is_later_month('October', 'September')
</code>```

答:
Jelly, 15 bytes

```<code>Oḅ32 354*%991µÞ
</code>```

No online interpreter link here because this is one slow submission. The program uses the hashing function 354^(input interpreted as base 32 int) % 991 as the sort key, which happens to give outputs in the right order. The program won't finish any time soon because the results of the exponentiation are giant - for "September", a number with 0.24 quadrillion digits needs to be calculated!

Jelly explanation:

```<code>              Þ         Sort by...
             µ          Monadic link consisting of...

O                       Convert month string to code points
 ḅ32                    Take base 32
     354*               Perform 354 to the power of the result
         %991           Take modulo 991
</code>```

Python proof of concept script - note the use of pow for modular exponentiation, which is much more efficient:

import random

def base_convert(string, base):
    total = 0

    for c in string:
        total = total * base + ord(c)

    return total

def month_hash(month):
    return pow(354, base_convert(month, 32), 991)

months = ["January", "February", "March", "April", "May", "June", "July",
    "August", "September", "October", "November", "December"]
random.shuffle(months)

print(months)
print(sorted(months, key=month_hash))
```

Title: Sort the months of the year

Body:
Jelly, 15 bytes

Oḅ32 354*%991µÞ

No online interpreter link here because this is one slow submission. The program uses the hashing function 354^(input interpreted as base 32 int) % 991 as the sort key, which happens to give outputs in the right order. The program won't finish any time soon because the results of the exponentiation are giant - for "September", a number with 0.24 quadrillion digits needs to be calculated!

Jelly explanation:

              Þ         Sort by...
             µ          Monadic link consisting of...

O                       Convert month string to code points
 ḅ32                    Take base 32
     354*               Perform 354 to the power of the result
         %991           Take modulo 991

Python proof of concept script - note the use of pow for modular exponentiation, which is much more efficient:

import random

def base_convert(string, base):
    total = 0

    for c in string:
        total = total * base + ord(c)

    return total

def month_hash(month):
    return pow(354, base_convert(month, 32), 991)

months = ["January", "February", "March", "April", "May", "June", "July",
    "August", "September", "October", "November", "December"]
random.shuffle(months)

print(months)
print(sorted(months, key=month_hash))


问:
Output a shuffled deck using random input

Input/Output:

Input: A uniformly random, infinitely long, string of '0's and '1's, taken from stdin.  The string is assumed to be truly random, not pseudo-random.  It is uniform in that each character is equally likely to be a '0' or '1'.

Careful! The input is infinitely long, so you can't store it all in memory using a function like raw_input() in python.  If I'm not mistaken, golfscript will fail with infinite input, since it pushes the entire input onto the stack prior to running.

Output: A uniformly random shuffled standard deck, without jokers.  It is uniform in that all orderings are equally likely.

Each card in the output is it's rank, A, 2-9, T, J, Q or K concatenated with it's suit, c, d, h or s.  For example, the 10 of spades is Ts

The cards of the deck should be separated by spaces.

You may not use built-in random libraries or functions because they are not truly random, only pseudo-random.

Example input

You may use the following python script to pipe input into your program:

```<code>import sys, random
try:
    while True:
        sys.stdout.write(str(random.randint(0,1)))
except IOError:
    pass
</code>```

If you save the script as rand.py, test your program with python rand.py | your_program

In python 3 it runs as expected, but in python 2.7 I get an error message after my program's output, but only after everything's done, so just ignore the error message.

Example output:

Here's how the deck should be printed if it happened to be shuffled into a sorted order:

```<code>Ac 2c 3c 4c 5c 6c 7c 8c 9c Tc Jc Qc Kc Ad 2d 3d 4d 5d 6d 7d 8d 9d Td Jd Qd Kd Ah 2h 3h 4h 5h 6h 7h 8h 9h Th Jh Qh Kh As 2s 3s 4s 5s 6s 7s 8s 9s Ts Js Qs Ks
</code>```

Scoring:

This is a code golf.  Shortest code wins.

Example program:

Here is a python 2.7 solution, not golfed.

```<code>import sys
def next():
    return int(sys.stdin.read(1))==1
def roll(n):
    if n==1:
        return 0
    if n%2==0:
        r=roll(n/2)
        if next():
            r+=n/2
        return r
    else:
        r=n
        while(r==n):
            r=roll(n+1)
        return r
deck = [rank+suit for suit in 'cdhs' for rank in 'A23456789TJQK']
while len(deck)>0:
    print deck.pop(roll(len(deck))),
</code>```

答:
PHP, 158 chars

Newlines have been added to stop the code block gaining scrollbars, they can safely be removed.

```<code>for($i=52,$x='shdcKQJT98765432A';$i--;$c[]=$x[4+$i%13].$x[$i/13]);
while(ord($i=fgetc(STDIN)))$c[$i]^=$c[$a]^=$c[$i]^=$c[$a=2+($a+++$i)%50];
die(join(' ',$c));
</code>```

Before I get told to add a <?php, let it be known you can invoke PHP without this tag quite easily, using: cat golf.php | php -a

De-golfed and commented:

```<code>// Abuse of the for construct to save a bit of space, and to make things more obscure looking in general.
for (
    // Card suit and number are reversed because we're using a decrementor to count
    // down from 52, instead of up to 52
    $i = 52,
    $x = 'shdcKQJT98765432A';
    // Condition AND per-loop decrement
    $i--;
    // Add a new element to the array comprising of $i mod 13 + 4 (to skip suit ids)
    // followed by simply $i divided by 13 to pick a suit id.
    $c[] =
        $x[4 + $i % 13] .
        $x[$i / 13]
);

while(

    // Assignment inside the condition, a single character from input.
    ord($i = fgetc(STDIN))
)
    // In-place swap. Shorter than using a single letter temporary variable.
    // This is the pseudo-random shuffle.
    $c[$i] ^=
    $c[$a] ^=
    $c[$i] ^=
    $c[
        // We use the input (0 or 1) to identify one of two swap locations at the
        // start of the array. The input is also added to an accumulator (to make
        // the increments "random") that represents a swap destination.
        $a = 2 + ($a++ + $i) % 50
    ];

// Dramatic way of doing "echo" in the same space.
die(
    join(' ', $c)
);
</code>```

There are two expected errors, that do not affect the output of the program.

The first is because $a is not initialised, but the NULL is converted to 0 and the program continues.

The second is because the character stream seems to get a newline from somewhere, even if it's not supplied (good ol' PHP), and that is an undefined index in the array. It's the last character of input, and does not affect output.

Body:
PHP, 158 chars

Newlines have been added to stop the code block gaining scrollbars, they can safely be removed.

for($i=52,$x='shdcKQJT98765432A';$i--;$c[]=$x[4+$i%13].$x[$i/13]);
while(ord($i=fgetc(STDIN)))$c[$i]^=$c[$a]^=$c[$i]^=$c[$a=2+($a+++$i)%50];
die(join(' ',$c));

Before I get told to add a <?php, let it be known you can invoke PHP without this tag quite easily, using: cat golf.php | php -a

De-golfed and commented:

// Abuse of the for construct to save a bit of space, and to make things more obscure looking in general.
for (
    // Card suit and number are reversed because we're using a decrementor to count
    // down from 52, instead of up to 52
    $i = 52,
    $x = 'shdcKQJT98765432A';
    // Condition AND per-loop decrement
    $i--;
    // Add a new element to the array comprising of $i mod 13 + 4 (to skip suit ids)
    // followed by simply $i divided by 13 to pick a suit id.
    $c[] =
        $x[4 + $i % 13] .
        $x[$i / 13]
);

while(

    // Assignment inside the condition, a single character from input.
    ord($i = fgetc(STDIN))
)
    // In-place swap. Shorter than using a single letter temporary variable.
    // This is the pseudo-random shuffle.
    $c[$i] ^=
    $c[$a] ^=
    $c[$i] ^=
    $c[
        // We use the input (0 or 1) to identify one of two swap locations at the
        // start of the array. The input is also added to an accumulator (to make
        // the increments "random") that represents a swap destination.
        $a = 2 + ($a++ + $i) % 50
    ];

// Dramatic way of doing "echo" in the same space.
die(
    join(' ', $c)
);

There are two expected errors, that do not affect the output of the program.

The first is because $a is not initialised, but the NULL is converted to 0 and the program continues.

The second is because the character stream seems to get a newline from somewhere, even if it's not supplied (good ol' PHP), and that is an undefined index in the array. It's the last character of input, and does not affect output.


问:
Is it a Proth number?
A Proth number, named after François Proth, is a number that can be expressed as

$$N = k \times 2^n + 1$$

Where \$k\$ is an odd positive integer and \$n\$ is a positive integer such that \$2^n > k\$. Let's use a more concrete example. Take 3. 3 is a Proth number because it can be written as

$$ 3 = (1 \times 2^1) + 1 $$

and \$2^1 > 1\$ is satisfied. 5 Is also a Proth number because it can be written as

$$ 5 = (1 \times 2^2) + 1 $$

and \$2^2 > 1\$ is satisfied. However, 7 is not a Proth number because the only way to write it in the form \$N = k \times 2^n + 1\$ is

$$ 7 = (3 \times 2^1) + 1 $$

and \$2^1 > 3\$ is not satisfied.

Your challenge is fairly simple: you must write a program or function that, given a positive integer, determines if it is a Proth number or not. You may take input in any reasonable format, and should output a truthy value if it is a Proth number and a falsy value if it is not. If your language has any "Proth-number detecting" functions, you may use them.

Test IO

Here are the first 46 Proth numbers up to 1000. (A080075)

```<code>3, 5, 9, 13, 17, 25, 33, 41, 49, 57, 65, 81, 97, 113, 129, 145, 161, 177, 193, 209, 225, 241, 257, 289, 321, 353, 385, 417, 449, 481, 513, 545, 577, 609, 641, 673, 705, 737, 769, 801, 833, 865, 897, 929, 961, 993
</code>```

Every other valid input should give a falsy value.

As usual, this is code-golf, so standard loopholes apply, and the shortest answer in bytes wins!

Number theory fun-fact side-note:

The largest known prime that is not a Mersenne Prime is \$19249 \times 2^{13018586} + 1\$, which just so happens to also be a Proth number!

答:
Cjam, 11 bytes

Like many of us, piggybacking off of Dennis's excellent solution:

```<code>qi_(_W*&2#<
</code>```

Try it online

ContentLicense: CC BY-SA 4.0

Title: Is it a Proth number?

Body:
Cjam, 11 bytes

Like many of us, piggybacking off of Dennis's excellent solution:

qi_(_W*&2#<

Try it online


答:
Java 8 lambda, <s>152</s> <s>142</s> 140 characters

Quite short:

```<code>s->s.chars().mapToObj(i->(char)i).filter(c->"COSTab\"\\cefh(i)j+l-mn.oprstuv>".contains(""+c)).collect(java.util.stream.Collectors.toSet())
</code>```

Or ungolfed over here:

```<code>public class Q89400 {

    static Set<Character> inAndQuine(String in) {
        return in.chars()
                .mapToObj(i->(char)i)
                .filter(c->"COSTab\"\\cefh(i)j+l-mn.oprstuv>".contains(""+c))
                .collect(java.util.stream.Collectors.toSet());

    }
}
</code>```

Of course the ungolfed solution is wrong, as it doesn't match the curly brackets and some more characters, it's just their for the sake of completeness.

The function takes input as a String and returns a java.util.Set<Character> containing the characters which are present in both input and source.

Updates

It turned out that the solution wasn't working. I thought String#contains tests for a regex match but it is just a literal matching. I added some escaping to quote the characters like . but this wasn't necessary but ruined everything instead. Now without this escaping we save some characters and now it actually works :)

Thanks to @NonlinearFruit for reminding me of using one-character variables.

Title: Input ∩ Source Code

Body:
Intro

The challenge is to create a program/function that prints the intersection of its own source code and a given string input. This is code golf and to be more precise:

Let I be the input set

{"a","b","c"}

Let S be the source code set

{"b","f"}

Then the intersection is what they share

I ∩ S = {"b"}

Input

Input is flexible. It should be able to handle the character encoding used for the source code.

Output

Output is flexible. It should be the set of characters that the input and source code share. Also, sets are unordered collections of distinct objects. In summary:

Output is flexible:

Could be any data structure (string or otherwise)

Could unordered

Could have a trailing \n

Should be distinct

Restriction

Similar to quine challenges, the program/function may not read its own source code and 0-byte solutions are not allowed.

Examples

#1

```<code>functor x(I){ return I ∩ self; }

Inputs                                Outputs
------                                -------
enter preformatted text here      ->  {"e","n","t","r","f","o","x"}

["Albrt"," Einstin"]              ->  {"l","r","t","n","s"}
</code>```

#2

```<code>(_)->_&"(_)->&\"\\"

Inputs                                Outputs
------                                -------
"Security at the expense of       ->  "
usability comes at the expense
of security."

(0____0)                          ->  (_)
</code>```

#3

```<code>ಠa益длф

Inputs                                Outputs
------                                -------
Far out in the uncharted backwaters ->"a"
of the unfashionable end of the
Western Spiral arm of the Galaxy lies
a small unregarded yellow sun.
Orbiting this at a distance of roughly
ninety-eight million miles is an
utterly insignificant little blue-green
planet whose ape-descended life forms
are so amazingly primitive that they
still think digital watches are a pretty
neat idea.

(ノಠ益ಠ)ノ彡┻━┻                      ->"ಠ益"
</code>```

Test Cases

```<code>Albert Einstein

\__( O__O)_/

!@#$%^&*()_+{}|:"<>?

1234567890-=[]\;',./

(ノಠ益ಠ)ノ彡┻━┻

“¤>%,oỊȤʠ“ØụĊ5D³ṃṠɼQ»j;Ç;“;}¶”

┬──┬ ノ( ゜-゜ノ)

Far out in the uncharted backwaters of the unfashionable end of the Western Spiral arm of the Galaxy lies a small unregarded yellow sun. Orbiting this at a distance of roughly ninety-eight million miles is an utterly insignificant little blue-green planet whose ape-descended life forms are so amazingly primitive that they still think digital watches are a pretty neat idea.
</code>```

Update

[16-08-10]: sets are unordered collections of distinct objects

[16-08-10]: trailing newline is acceptable

Body:
Java 8 lambda, <s>152</s> <s>142</s> 140 characters

Quite short:

s->s.chars().mapToObj(i->(char)i).filter(c->"COSTab\"\\cefh(i)j+l-mn.oprstuv>".contains(""+c)).collect(java.util.stream.Collectors.toSet())

Or ungolfed over here:

public class Q89400 {

    static Set<Character> inAndQuine(String in) {
        return in.chars()
                .mapToObj(i->(char)i)
                .filter(c->"COSTab\"\\cefh(i)j+l-mn.oprstuv>".contains(""+c))
                .collect(java.util.stream.Collectors.toSet());

    }
}

Of course the ungolfed solution is wrong, as it doesn't match the curly brackets and some more characters, it's just their for the sake of completeness.

The function takes input as a String and returns a java.util.Set<Character> containing the characters which are present in both input and source.

Updates

It turned out that the solution wasn't working. I thought String#contains tests for a regex match but it is just a literal matching. I added some escaping to quote the characters like . but this wasn't necessary but ruined everything instead. Now without this escaping we save some characters and now it actually works :)

Thanks to @NonlinearFruit for reminding me of using one-character variables.


答:
R, <s>52</s> 50 bytes

```<code>x=scan()-1;n=0;while(!x%%2){x=x/2;n=n+1};2^(2*n)>x
</code>```

The program begins by dividing N-1 (called here P and x) by 2 as long as possible in order to find the 2^npart of the equation, leaving k=(N-1)/2^n, and then computes wether or not k is inferior to 2^n, using the fact that 2^n>x/2^n <=> (2^n)²>x <=> 2^2n>x

Title: Is it a Proth number?

Body:
A Proth number, named after François Proth, is a number that can be expressed as

$$N = k \times 2^n + 1$$

Where \$k\$ is an odd positive integer and \$n\$ is a positive integer such that \$2^n > k\$. Let's use a more concrete example. Take 3. 3 is a Proth number because it can be written as

$$ 3 = (1 \times 2^1) + 1 $$

and \$2^1 > 1\$ is satisfied. 5 Is also a Proth number because it can be written as

$$ 5 = (1 \times 2^2) + 1 $$

and \$2^2 > 1\$ is satisfied. However, 7 is not a Proth number because the only way to write it in the form \$N = k \times 2^n + 1\$ is

$$ 7 = (3 \times 2^1) + 1 $$

and \$2^1 > 3\$ is not satisfied.

Your challenge is fairly simple: you must write a program or function that, given a positive integer, determines if it is a Proth number or not. You may take input in any reasonable format, and should output a truthy value if it is a Proth number and a falsy value if it is not. If your language has any "Proth-number detecting" functions, you may use them.

Test IO

Here are the first 46 Proth numbers up to 1000. (A080075)

```<code>3, 5, 9, 13, 17, 25, 33, 41, 49, 57, 65, 81, 97, 113, 129, 145, 161, 177, 193, 209, 225, 241, 257, 289, 321, 353, 385, 417, 449, 481, 513, 545, 577, 609, 641, 673, 705, 737, 769, 801, 833, 865, 897, 929, 961, 993
</code>```

Every other valid input should give a falsy value.

As usual, this is code-golf, so standard loopholes apply, and the shortest answer in bytes wins!

Number theory fun-fact side-note:

The largest known prime that is not a Mersenne Prime is \$19249 \times 2^{13018586} + 1\$, which just so happens to also be a Proth number!

Body:
R, <s>52</s> 50 bytes

x=scan()-1;n=0;while(!x%%2){x=x/2;n=n+1};2^(2*n)>x

The program begins by dividing N-1 (called here P and x) by 2 as long as possible in order to find the 2^npart of the equation, leaving k=(N-1)/2^n, and then computes wether or not k is inferior to 2^n, using the fact that 2^n>x/2^n <=> (2^n)²>x <=> 2^2n>x


问:
Help Sam understand chess
For this challenge, you will be writing a program or function which outputs (or prints) (in a reasonable format, i.e single string or an array of lines) a chess board which indicates all the possible moves of a piece given an empty board.

There are 5 chess pieces (for this challenge a pawn may be ignored):

Bishop (Moves diagonally any number of squares)

Rook (Moves orthogonally any number of squares)

Queen (Moves diagonally or orthogonally any number of squares)

KNight (Moves in an L shape, i.e. two in one dimension, and one in the other)

King (Moves one step orthogonally or diagonally)

Your submission will take in three inputs: the row of the chess piece, the column of the chess piece, and the type of piece (as a character or integer).

Say we call drawBoard(4,4,'N') for the Knight using 0-indexing, the output will be as follows:

```<code>........
........
...M.M..
..M...M.
....N...
..M...M.
...M.M..
........
</code>```

where the '.' and 'M' can be replaced accordingly with printable ascii characters of your choice.

Sample outputs as follows for other piece types. (Note all of these are called with input of 4,4 and are 0-indexed).

King:

```<code>........
........
........
...mmm..
...mKm..
...mmm..
........
........
</code>```

Rook:

```<code>....m...
....m...
....m...
....m...
mmmmRmmm
....m...
....m...
....m...
</code>```

Sam does not mind 1-based indexing, or even indexing following chess algebraic notation. However, your code must be as small as possible so Sam has enough space to think about his chess with the code next to him.

Sam has also realized that outputs will be accepted regardless of trailing or preceding whitespace (before and after input and each line)

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

f=
(x,y,p)=>`${1e8}`.repeat(8).replace(/./g,c=>+c?(i=x*x--,z=y,`
`):i+(j=z*z--)?`.*`[+!{K:i+j>3,N:i+j-5,R:i*j,B:b=i-j,Q:b*i*j}[p]]:p)
;```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div onchange=if(+x.value&&+y.value&&p.value)o.textContent=f(x.value,y.value,p.value)><input id=x type=number placeholder=X><input id=y type=number placeholder=Y><select id=p><option value=>Piece<option value=B>Bishop<option value=K>King<option value=N>Knight<option value=Q>Queen<option value=R>Rook</select><div><pre id=o>``````

Note: Outputs one leading newline.

Explanation: Builds and scans though the string 100000000100000000100000000100000000100000000100000000100000000100000000. Each 1 indicates a new line where the relative coordinate x is decremented and the relative coordinate z is reset. Each 0 indicates a new square where the relative coordinate z is decremented. (y is reserved to reset z.) Then uses the fact that many of the moves can be categorised by the squares i and j of the relative coordinates (before they were decremented):

(initial square) i + j == 0

B: i == j

K: i + j < 3

N: i + j == 5

Q: i == j || !i || !j

R: !i || !j

Because - is shorter than == it's golfier to compute the negation and invert it later. (This lets me use the cute '.*'[] expression although it's actually the same length as a boring ?: expression.) * is also golfier than &&.

Title: Help Sam understand chess

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

f=
(x,y,p)=>`${1e8}`.repeat(8).replace(/./g,c=>+c?(i=x*x--,z=y,`
`):i+(j=z*z--)?`.*`[+!{K:i+j>3,N:i+j-5,R:i*j,B:b=i-j,Q:b*i*j}[p]]:p)
;

<div onchange=if(+x.value&&+y.value&&p.value)o.textContent=f(x.value,y.value,p.value)><input id=x type=number placeholder=X><input id=y type=number placeholder=Y><select id=p><option value=>Piece<option value=B>Bishop<option value=K>King<option value=N>Knight<option value=Q>Queen<option value=R>Rook</select><div><pre id=o></pre>

Note: Outputs one leading newline.

Explanation: Builds and scans though the string 100000000100000000100000000100000000100000000100000000100000000100000000. Each 1 indicates a new line where the relative coordinate x is decremented and the relative coordinate z is reset. Each 0 indicates a new square where the relative coordinate z is decremented. (y is reserved to reset z.) Then uses the fact that many of the moves can be categorised by the squares i and j of the relative coordinates (before they were decremented):

(initial square) i + j == 0

B: i == j

K: i + j < 3

N: i + j == 5

Q: i == j || !i || !j

R: !i || !j

Because - is shorter than == it's golfier to compute the negation and invert it later. (This lets me use the cute '.*'[] expression although it's actually the same length as a boring ?: expression.) * is also golfier than &&.


问:
List of possible birth years of living humans
The Challenge

Output a list of years that starts with the current year and ends 120 years ago. The birth year of every living human would be included in this list.

Details

The list should be in descending order.

Every built-in function to manipulate arrays and/or lists is allowed.

Shortest code in bytes wins.

When run this year 2016, the output would be

2016, 2015, ..., 1897, 1896

When run next year 2017, the output would be

2017, 2016, ..., 1898, 1897

Etc.

Update

Some have asked about the format of the list. As most have guessed, it doesn't matter. Insert any separator between the numbers. Intuitively most inserted a comma or space or both, newline or output an array.

Quasi superhumans like Jeanne Calment are an exception to the rule stated in my question.

答:
Dyalog APL, <s>11</s> 10 bytes

120↑⌽⍳⊃⎕ts
```
<p><code>120↑</code> take 120 elements</p>
<p><code>⌽</code> of the reversed</p>
<p><code>⍳</code> indices until</p>
<p><code>⊃</code> the first element of</p>
<p><code>⎕TS</code> TimeStamp in the format [YYYY, M, D, h, m, s, t]</p>
<p>TryAPL online!</p>
<hr />
<p>Old version:</p>
<pre class="lang-apl prettyprint-override"><code>(⊃⎕TS)-⍳120
</code>```

⊃⎕TS first element of [YYYY, M, D, h, m, s, t]

- minus

⍳120 [0, 1, 2, ..., 118, 119]

Requires ⎕IO←0, which is default on many systems.

TryAPL online!

Body:
Dyalog APL, <s>11</s> 10 bytes

120↑⌽⍳⊃⎕ts

120↑ take 120 elements

⌽ of the reversed

⍳ indices until

⊃ the first element of

⎕TS TimeStamp in the format [YYYY, M, D, h, m, s, t]

TryAPL online!

Old version:

(⊃⎕TS)-⍳120

⊃⎕TS first element of [YYYY, M, D, h, m, s, t]

- minus

⍳120 [0, 1, 2, ..., 118, 119]

Requires ⎕IO←0, which is default on many systems.

TryAPL online!


答:
Python 2, <s>64 62</s> 54 bytes

```<code>import time
n=time.gmtime()[0]
exec'print n;n-=1;'*121
</code>```

@KarlKastor thanks for 8 bytes!

Title: List of possible birth years of living humans

Body:
The Challenge

Output a list of years that starts with the current year and ends 120 years ago. The birth year of every living human would be included in this list.

Details

The list should be in descending order.

Every built-in function to manipulate arrays and/or lists is allowed.

Shortest code in bytes wins.

When run this year 2016, the output would be

2016, 2015, ..., 1897, 1896

When run next year 2017, the output would be

2017, 2016, ..., 1898, 1897

Etc.

Update

Some have asked about the format of the list. As most have guessed, it doesn't matter. Insert any separator between the numbers. Intuitively most inserted a comma or space or both, newline or output an array.

Quasi superhumans like Jeanne Calment are an exception to the rule stated in my question.

Body:
Python 2, <s>64 62</s> 54 bytes

import time
n=time.gmtime()[0]
exec'print n;n-=1;'*121

@KarlKastor thanks for 8 bytes!


答:
05AB1E, <s>8</s> 7 bytes

Code:

```<code>žg120Ý-
</code>```

Explanation:

```<code>žg         # Get the current year.
  120Ý     # Create the list [0, 1, ..., 119, 120].
      -    # Substract, which leaves [year - 0, year - 1, ..., year - 120].
</code>```

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

Body:
05AB1E, <s>8</s> 7 bytes

Code:

žg120Ý-

Explanation:

žg         # Get the current year.
  120Ý     # Create the list [0, 1, ..., 119, 120].
      -    # Substract, which leaves [year - 0, year - 1, ..., year - 120].

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


答:
PowerShell, 26 24 bytes

@TimmyD improved version:

```<code>0..120|%{(date).Year-$_}
</code>```

Was:

```<code>($d=(date).year)..($d-120)
</code>```

where date runs Get-Date

Body:
PowerShell, 26 24 bytes

@TimmyD improved version:

0..120|%{(date).Year-$_}

Was:

($d=(date).year)..($d-120)

where date runs Get-Date


问:
Hello World 0.0!

 source: Dilbert, September 8, 1992

I'm hoping to add a new twist on the classic "Hello World!" program.

Code a program that outputs Hello World! without:

String/Character literals

Numbers (any base)

Pre-built functions that return "Hello World!"

RegEx literals

With the exceptions of "O"† and 0.

†"O" is capitalized, "o" is not acceptable.

Title: Hello World 0.0!

Body:
C, 190 189 204

a,b,c,h,e,l,o;i[4],*j=i;main(_){o=*"O";a=_+_+_;b=_<<a;c=b*a+b;h=(o>>_)^o;o^=c;e=h-a;l=o-h+e;*j++=h-c|e<<b|l<<b+b|l<<c-b;*j++=o|c<<b|o+b-c<<b+b|o<<c-b;*j=o+a|l<<b|e-_<<b+b|c+_<<c-b;puts(i);}

Must be run with exactly zero command line arguments since it depends on argc being equal to 1.

no preprocessor macros

Might be system endian dependant (involves cast from integer array to char array)

Not memory safe

a,b,c,h,e,l,o;   // variables
i[],m,*j=i;      // array and pointer

main(_)          // if no arguments are given _ will be 1
{
    o=*"O";      // our one legal string constant
    a=_+_+_;     // a = 3
    b=_<<a;      // b = 8
    c=b*a+b;     // c = 32
    h=(o>>_)^o;  // h = 'h'
    o^=c;        // o = 'o'
    e=h-a;       // e = 'e'
    l=o-h+e;     // l = 'l'
    *j++=h-c|e<<b|l<<b+b|l<<c-b;     // j[0] = 'H' | 'e' << 8 | 'l' << 16 | 'l' << 24
    *j++=o|c<<b|o+b-c<<b+b|o<<c-b;   // j[1] = 'o' | ' ' << 8 | 'W' << 16 | 'o' << 24
    *j=o+a|l<<b|e-_<<b+b|c+_<<c-b;   // j[2] = 'r' | 'l' << 8 | 'd' << 16 | '!' << 24

    puts(i);     // puts("Hello World!\0\0\0\0")
}

Revisions:

a,b,c,h,e,l,o;i[9],*j=i;main(_){o=*"O";a=_<<_|_;b=_<<a;c=_<<b-a;h=(o>>_)^o;o^=c;e=h-a;l=o-h+e;*j++=h^c|e<<b|l<<b<<b|l<<(c-b);*j++=o|c<<b|(o+b^c)<<b<<b|o<<(c-b);*j=o+a|l<<b|e-_<<b<<b|c+_<<(c-b);printf(i);} /* original */
a,b,c,h,e,l,o;i[4],*j=i;main(_){o=*"O";a=_+_+_;b=_<<a;c=b*a+b;h=(o>>_)^o;o^=c;e=h-a;l=o-h+e;*j++=h-c|e<<b|l<<b+b|l<<c-b;*j++=o|c<<b|o+b-c<<b+b|o<<c-b;*j=o+a|l<<b|e-_<<b+b|c+_<<c-b;puts(i);} /* golfed better */
a,b,c,h,e,l,o;i[],m,*j=i;main(_){o=*"O";a=_+_+_;b=_<<a;c=b*a+b;h=(o>>_)^o;o^=c;e=h-a;l=o-h+e;*j++=h-c|e<<b|l<<b+b|l<<c-b;*j++=o|c<<b|o+b-c<<b+b|o<<c-b;*j=o+a|l<<b|e-_<<b+b|c+_<<c-b;puts(i);} /* removed illegal numeric literal in array size */


答:
Pyth, <s>11</s> <s>9</s> 8 bytes

```<code>-L.d3C\y
</code>```

Works by mapping over the range [0...120] and subtracting every number from the current year. The range is built implicitly by using 121 as the map argument. To avoid a separating whitespace between .d3 and 121 we get this number by converting y to it's codepoint.

Thanks to @FryAmTheEggman for coming up with this approach!

Try it here!

Old 9-byte solution:

```<code>_>121S.d3
</code>```

Try it here!

Builds the range [1...<current year>] and only takes the last 121 elements of it.

Body:
Pyth, <s>11</s> <s>9</s> 8 bytes

-L.d3C\y

Works by mapping over the range [0...120] and subtracting every number from the current year. The range is built implicitly by using 121 as the map argument. To avoid a separating whitespace between .d3 and 121 we get this number by converting y to it's codepoint.

Thanks to @FryAmTheEggman for coming up with this approach!

Try it here!

Old 9-byte solution:

_>121S.d3

Try it here!

Builds the range [1...<current year>] and only takes the last 121 elements of it.


Body:
Perl, 33 bytes

say+(gmtime)[5]-$_+1900for 0..120

Run with -M5.010 or -E :

perl -E 'say+(gmtime)[5]-$_+1900for 0..120'


Body:
BASH + coreutils, <s>35</s> 33 bytes

x=`date +%Y`;seq $x -1 $((x-120))


答:
R, <s>47</s> 39 bytes

```<code>as.double(substr(Sys.Date(),1,4))-0:120
</code>```

If only someone invented a UTF-8 implementation of R with conveniently abbreviated frequently used system functions...

UPD: shaved off 7 (!) bytes owing to plannapus, who suggested subrtacting a 0:120 vector rather than counting from a to (a-120) and 1 byte grâce à user5957401, who noticed that double would work as well as numeric. Old version:

```<code>a=as.numeric(format(Sys.Date(),"%Y"));a:(a-120)
</code>```

Body:
R, <s>47</s> 39 bytes

as.double(substr(Sys.Date(),1,4))-0:120

If only someone invented a UTF-8 implementation of R with conveniently abbreviated frequently used system functions...

UPD: shaved off 7 (!) bytes owing to plannapus, who suggested subrtacting a 0:120 vector rather than counting from a to (a-120) and 1 byte grâce à user5957401, who noticed that double would work as well as numeric. Old version:

a=as.numeric(format(Sys.Date(),"%Y"));a:(a-120)


Body:
php, 73 66 58 42 bytes

<?=implode(', ',range($j=date(Y),$j-120));

Output:

2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008, 2007, 2006,
  2005, 2004, 2003, 2002, 2001, 2000, 1999, 1998, 1997, 1996, 1995,
  1994, 1993, 1992, 1991, 1990, 1989, 1988, 1987, 1986, 1985, 1984,
  1983, 1982, 1981, 1980, 1979, 1978, 1977, 1976, 1975, 1974, 1973,
  1972, 1971, 1970, 1969, 1968, 1967, 1966, 1965, 1964, 1963, 1962,
  1961, 1960, 1959, 1958, 1957, 1956, 1955, 1954, 1953, 1952, 1951,
  1950, 1949, 1948, 1947, 1946, 1945, 1944, 1943, 1942, 1941, 1940,
  1939, 1938, 1937, 1936, 1935, 1934, 1933, 1932, 1931, 1930, 1929,
  1928, 1927, 1926, 1925, 1924, 1923, 1922, 1921, 1920, 1919, 1918,
  1917, 1916, 1915, 1914, 1913, 1912, 1911, 1910, 1909, 1908, 1907,
  1906, 1905, 1904, 1903, 1902, 1901, 1900, 1899, 1898, 1897, 1896

If we don't need to separate with ,, then 58 57 41 bytes:

<?=implode(' ',range($j=date(Y),$j-120));

Thanks to insertusernamehere for saving 16 bytes


答:
AngularJS + Lodash, 274 bytes

angular.module('x',[]).controller('x',['$scope',function(x){x.x=_.range(9,new Date().getFullYear()+1).slice(-121).reverse()}])```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src=//goo.gl/M5LvGe></script><script src=//goo.gl/opljJl></script><select ng-app=x ng-controller=x multiple><option ng-repeat="x in x">{{x}}</code>```

Output

Body:
AngularJS + Lodash, 274 bytes

angular.module('x',[]).controller('x',['$scope',function(x){x.x=_.range(9,new Date().getFullYear()+1).slice(-121).reverse()}])

<script src=//goo.gl/M5LvGe></script><script src=//goo.gl/opljJl></script><select ng-app=x ng-controller=x multiple><option ng-repeat="x in x">{{x}}

Output


答:
MATL, 10 bytes

```<code>1&Z'0:120-
</code>```

Try it online!

```<code>1&Z'      % Push first component of "clock" vector, which is year
0:120     % Literal vector [0, 1, 2, ..., 120]
-         % Subtract element-wise. Implicitly display
</code>```

Body:
MATL, 10 bytes

1&Z'0:120-

Try it online!

1&Z'      % Push first component of "clock" vector, which is year
0:120     % Literal vector [0, 1, 2, ..., 120]
-         % Subtract element-wise. Implicitly display


答:
Ruby, 39 36 bytes

```<code>t=Time.new.year;t.downto(t-120).to_a
</code>```

Old:

```<code>t=Time.new.year;(t-120..t).to_a.reverse
</code>```

Should be obvious.

Body:
Ruby, 39 36 bytes

t=Time.new.year;t.downto(t-120).to_a

Old:

t=Time.new.year;(t-120..t).to_a.reverse

Should be obvious.


问:
Smile! Just smile
It's well known that Brainf*ck is very bad at Kolmogorov-complexity problems, for example, it requires around 100 characters just to print "Hello world".

However, there might be texts where Brainf*ck is just very good at.

Your task is now to write a program that takes no input, and it displays the following:

```<code>☺
</code>```

That is, a smiley face (ASCII 1, if you browser does not render it).

Brainf*ck can do it in 2 characters.

```<code>+.
</code>```

Try to find a language that beats it!

We assume your console can actually display that character (or your font has it, etc.).

Shortest code wins. If there are more of the same length, the first wins, but I'll upvote the others as well.

EDIT: I'm very sorry, I did not think the first post arrives this soon. A quick edit: the language has to be Turing-complete!

答:
PHP (1)

```<code>☺
</code>```

Technically this is a valid PHP file (a web server will happily serve it).

Title: Smile! Just smile

Body:
PHP (1)

☺

Technically this is a valid PHP file (a web server will happily serve it).


答:
Vitsy + *sh <s>+ JavaScript</s>, <s>33</s> <s>26</s> <s>21</s> 18 bytes

Vitsy doesn't have native time/date retrieval, so I had to use shell and eval for this one.

Thanks to @Caleb for helping me shear off another 3 bytes!

```<code>'Y%+ etad',Dca*-HZ

'Y%+ etad'               Push the string 'date +"%Y"' to the stack.
          ,              Execute through shell.
           Dca*-         Dupe n, push n - 120.
                H        Pop x, y, push range(x, y) to the stack.
                 Z       Output all stack as characters.
</code>```

You can't try this one online, because it uses both shell AND eval.

Output is as character codes.

Body:
Vitsy + *sh <s>+ JavaScript</s>, <s>33</s> <s>26</s> <s>21</s> 18 bytes

Vitsy doesn't have native time/date retrieval, so I had to use shell and eval for this one.

Thanks to @Caleb for helping me shear off another 3 bytes!

'Y%+ etad',Dca*-HZ

'Y%+ etad'               Push the string 'date +"%Y"' to the stack.
          ,              Execute through shell.
           Dca*-         Dupe n, push n - 120.
                H        Pop x, y, push range(x, y) to the stack.
                 Z       Output all stack as characters.

You can't try this one online, because it uses both shell AND eval.

Output is as character codes.


答:
JavaScript (ES6), 65 bytes

[...Array(1+- -Date().substr(11,4)).keys()].slice(-121).reverse()

You're welcome to improve and shorten it...

Thanks to @Yay295 for the fix. I was 1 year off.


答:
Mathematica/Wolfram Language, 28 bytes

```<code>Date[][[1]]-#&/@Range[0,120]
</code>```

Body:
Mathematica/Wolfram Language, 28 bytes

Date[][[1]]-#&/@Range[0,120]


问:
Print a 10 by 10 grid of asterisks

Background

This is a standard textbook example to demonstrate for loops.

This is one of the first programs I learnt when I started learning programming ~10 years ago.

Task

You are to print this exact text:

```<code>**********
**********
**********
**********
**********
**********
**********
**********
**********
**********
</code>```

Specs

You may have extra trailing newlines.

You may have extra trailing spaces (U+0020) at the end of each line, including the extra trailing newlines.

Scoring

This is code-golf. Shortest answer in bytes wins.

答:
Fourier, 22 bytes

```<code>10(10(~X42aX^~X)aN^~N)
</code>```

Try it on FourIDE!

Title: Print a 10 by 10 grid of asterisks

Body:
Fourier, 22 bytes

10(10(~X42aX^~X)aN^~N)

Try it on FourIDE!


答:
R, 34 bytes

```<code>(format(Sys.Date(),"%Y"):0)[1:121]
</code>```

See here on an online interpreter.

Edit Could be reduced to 33 bytes by using substr.

```<code>(substr(Sys.Date(),1,4):0)[1:121]
</code>```

but technically this solution will only work until the 9999-12-31.

Body:
The Challenge

Output a list of years that starts with the current year and ends 120 years ago. The birth year of every living human would be included in this list.

Details

The list should be in descending order.

Every built-in function to manipulate arrays and/or lists is allowed.

Shortest code in bytes wins.

When run this year 2016, the output would be

2016, 2015, ..., 1897, 1896

When run next year 2017, the output would be

2017, 2016, ..., 1898, 1897

Etc.

Update

Some have asked about the format of the list. As most have guessed, it doesn't matter. Insert any separator between the numbers. Intuitively most inserted a comma or space or both, newline or output an array.

Quasi superhumans like Jeanne Calment are an exception to the rule stated in my question.

Body:
R, 34 bytes

(format(Sys.Date(),"%Y"):0)[1:121]

See here on an online interpreter.

Edit Could be reduced to 33 bytes by using substr.

(substr(Sys.Date(),1,4):0)[1:121]

but technically this solution will only work until the 9999-12-31.


答:
Python 2, 62 bytes

```<code>import time
for n in range(121):print int(time.ctime()[-4:])-n
</code>```

And at 64 bytes:

```<code>for n in range(121):print int(__import__("time").ctime()[-4:])-n
</code>```

Body:
Python 2, 62 bytes

import time
for n in range(121):print int(time.ctime()[-4:])-n

And at 64 bytes:

for n in range(121):print int(__import__("time").ctime()[-4:])-n


答:
Java <s>75</s> 74 bytes

```<code>public void possible(){
  for(int i=0;i<120;){
    System.out.println(new Date().getYear()-i++);
  }
}
</code>```

Golfed :

```<code>void p(){for(int i=0;i<120;)System.out.println(new Date().getYear()-i++);}
</code>```

1 byte off. Thanks to @LeakyNun

Body:
Java <s>75</s> 74 bytes

public void possible(){
  for(int i=0;i<120;){
    System.out.println(new Date().getYear()-i++);
  }
}

Golfed :

void p(){for(int i=0;i<120;)System.out.println(new Date().getYear()-i++);}

1 byte off. Thanks to @LeakyNun


答:
CJam, <s>14</s> <s>12</s> 11 bytes

Saved 2 bytes thanks to Sp3000 and 1 byte thanks to Martin Ender

```<code>et0=121,f-p
</code>```

Try it online!

Explanation

```<code>et0=         e# Push the current year
    121,     e# Push the range 0, 1, ..., 120
        f-   e# For each item in the range, subtract it from current year
          p  e# Print the array
</code>```

Body:
CJam, <s>14</s> <s>12</s> 11 bytes

Saved 2 bytes thanks to Sp3000 and 1 byte thanks to Martin Ender

et0=121,f-p

Try it online!

Explanation

et0=         e# Push the current year
    121,     e# Push the range 0, 1, ..., 120
        f-   e# For each item in the range, subtract it from current year
          p  e# Print the array


答:
JavaScript, <s>55</s> <s>52</s> <s>50</s> 49 bytes

```<code>for(a=d=s=Date().substr(11,4);d-->s-120;)a+=" "+d
</code>```

+9 bytes to alert the data (not necessary if you run this in a console).

```<code>for(a=d=s=Date().substr(11,4);d-->s-120;)a+=" "+d;alert(a)
</code>```

-4 bytes if the delimiter isn't necessary.

```<code>for(a=d=s=Date().substr(11,4);d-->s-120;)a+=d
</code>```

for (a = d = s = Date().substr(11, 4); d --> s - 120; )
    a += " " + d;
console.log(a);```

Body:
JavaScript, <s>55</s> <s>52</s> <s>50</s> 49 bytes

for(a=d=s=Date().substr(11,4);d-->s-120;)a+=" "+d

+9 bytes to alert the data (not necessary if you run this in a console).

for(a=d=s=Date().substr(11,4);d-->s-120;)a+=" "+d;alert(a)

-4 bytes if the delimiter isn't necessary.

for(a=d=s=Date().substr(11,4);d-->s-120;)a+=d

for (a = d = s = Date().substr(11, 4); d --> s - 120; )
    a += " " + d;
console.log(a);


问:
Shortest code that raises a SIGSEGV
Write the shortest code that raises a  Segmentation Fault (SIGSEGV) in any programming language.</p>

答:
Perl ( < 5.14 ), 9 chars

```<code>/(?{??})/
</code>```

In 5.14 the regex engine was made reentrant so that it could not be crashed in this way, but 5.12 and earlier will segfault if you try this.

Title: Shortest code that raises a SIGSEGV

Body:
Perl ( < 5.14 ), 9 chars

/(?{??})/

In 5.14 the regex engine was made reentrant so that it could not be crashed in this way, but 5.12 and earlier will segfault if you try this.


答:
C#, 107 bytes

My first attempt at a submission to PPCG

Golfed:

```<code>var l="";int i=0,j=0;for(;i<26;i++){for(;j<26;j++)l+=(char)(((j%2)+i)%26+65);Console.WriteLine(l);l="";j=0;}
</code>```

Ungolfed:

```<code>var l="";
int i=0,j=0;
for(;i<26;i++){
    for(;j<26;j++)l+=(char)(((j%2)+i)%26+65);
        Console.WriteLine(l);
    l="";j=0;
}
</code>```

Pretty sure this adheres to standards! Would love to hear any potential improvements.

Title: Print an alphabet wave

Body:
You are to print this exact text:

```<code>ABABABABABABABABABABABABAB
BCBCBCBCBCBCBCBCBCBCBCBCBC
CDCDCDCDCDCDCDCDCDCDCDCDCD
DEDEDEDEDEDEDEDEDEDEDEDEDE
EFEFEFEFEFEFEFEFEFEFEFEFEF
FGFGFGFGFGFGFGFGFGFGFGFGFG
GHGHGHGHGHGHGHGHGHGHGHGHGH
HIHIHIHIHIHIHIHIHIHIHIHIHI
IJIJIJIJIJIJIJIJIJIJIJIJIJ
JKJKJKJKJKJKJKJKJKJKJKJKJK
KLKLKLKLKLKLKLKLKLKLKLKLKL
LMLMLMLMLMLMLMLMLMLMLMLMLM
MNMNMNMNMNMNMNMNMNMNMNMNMN
NONONONONONONONONONONONONO
OPOPOPOPOPOPOPOPOPOPOPOPOP
PQPQPQPQPQPQPQPQPQPQPQPQPQ
QRQRQRQRQRQRQRQRQRQRQRQRQR
RSRSRSRSRSRSRSRSRSRSRSRSRS
STSTSTSTSTSTSTSTSTSTSTSTST
TUTUTUTUTUTUTUTUTUTUTUTUTU
UVUVUVUVUVUVUVUVUVUVUVUVUV
VWVWVWVWVWVWVWVWVWVWVWVWVW
WXWXWXWXWXWXWXWXWXWXWXWXWX
XYXYXYXYXYXYXYXYXYXYXYXYXY
YZYZYZYZYZYZYZYZYZYZYZYZYZ
ZAZAZAZAZAZAZAZAZAZAZAZAZA
</code>```

Specs

You can print all lowercase instead of all uppercase. However, case must be consistent throughout the output.

You may print one extra trailing linefeed.

Scoring

Since this is an alphabet wave that fluctuates to a small extent, your code should also be small in terms of byte-count. In fact, the smallest code in terms of byte-count wins.

Body:
C#, 107 bytes

My first attempt at a submission to PPCG

Golfed:

var l="";int i=0,j=0;for(;i<26;i++){for(;j<26;j++)l+=(char)(((j%2)+i)%26+65);Console.WriteLine(l);l="";j=0;}

Ungolfed:

var l="";
int i=0,j=0;
for(;i<26;i++){
    for(;j<26;j++)l+=(char)(((j%2)+i)%26+65);
        Console.WriteLine(l);
    l="";j=0;
}

Pretty sure this adheres to standards! Would love to hear any potential improvements.


答:
Python 2, 67 bytes

```<code>from datetime import*;for i in range(121):print date.today().year-i
</code>```

Thanks to Sp3000 for removing one byte

Body:
Python 2, 67 bytes

from datetime import*;for i in range(121):print date.today().year-i

Thanks to Sp3000 for removing one byte


答:
Pyke, 6 bytes

```<code>wC7m-
</code>```

Try it here!

```<code>w     - 121
   m- - for i in range(^):
 C7   -  current_year-i
</code>```

(After w, the codepoint for 153 is present but it isn't printable)

Body:
Pyke, 6 bytes

wC7m-

Try it here!

w     - 121
   m- - for i in range(^):
 C7   -  current_year-i

(After w, the codepoint for 153 is present but it isn't printable)


问:
Fix my IPv4 address's missing periods
Sometimes when I'm typing out an IPv4 address, I get all the numbers right, but I forget to type one or more periods. I'd like to have a program (or function) that takes my broken IPv4 address and outputs all possible valid placements of the missing periods.

Input

The input will always be a string that is a transformation of a valid IPv4 address (see particulars below). It will always have been transformed solely by the elimination of one or more period characters.

You submission does not need to handle inputs outside of this format.

Output

A collection or list, in no particular order or format, of strings representing all valid IPv4 addresses that can be created from the input by the insertion of period characters into the input.

The output may be a language-native list or other ordered or unordered collection type.

Alternatively, it may be a string sequence of IPv4 address delimited in some clear way.

If you use a single-character delimiter to delimit your string, periods and digits are not allowed as that single-character delimiter. I realize that, unlike numbers, periods as delimiters are not ambiguous (since every fourth period would necessarily be a delimiter) but for the sake of readability, I am disallowing it.

IPv4 address format

While IPv4 addresses are really just a sequence of four binary octets, this challenge uses a restricted dotted decimal format.

An IPv4 address is a four decimal values separated by three periods.

Each of the four values are in the range 0 to 255, inclusive.

Leading zeros are not allowed in any number value. (Standalone one-character 0 is allowed; any other number beginning with a zero is not: 052, 00, etc.)

Test Cases

Input is on the first line, output on second line (here, structured as a comma-separated list of quoted strings, separated by commas, surrounded by [ ], but you may use any reasonable format or structure, as specified above). Some examples have notes on a third line to highlight the application of a particular rule.

```<code>192.168.1234
["192.168.1.234", "192.168.12.34", "192.168.123.4"]

192.1681234
["192.16.81.234", "192.168.1.234", "192.168.12.34", "192.168.123.4"]
(Note: 192.1681.2.34 (etc.) is illegal because 1681 is greater than 255)

1921681.234
["19.216.81.234", "192.16.81.234", "192.168.1.234"]

1921681234
["19.216.81.234", "192.16.81.234", "192.168.1.234", "192.168.12.34", "192.168.123.4"]

192.168.1204
["192.168.1.204", "192.168.120.4"]
(Note: 192.168.12.04 is illegal because of leading zero)

192.168.123
["1.92.168.123", "19.2.168.123", "192.1.68.123", "192.16.8.123", "192.168.1.23", "192.168.12.3"]

192.168.256
["192.168.2.56", "192.168.25.6"]
(Note: Any combination that would leave 256 intact is illegal)

120345
["1.20.3.45", "1.20.34.5", "1.203.4.5", "12.0.3.45", "12.0.34.5", "120.3.4.5"]
(Note: 12.03.4.5 (etc.) is illegal due to leading zero.)

012345
["0.1.23.45", "0.1.234.5", "0.12.3.45", "0.12.34.5", "0.123.4.5"]
(Note: the first segment must be 0, because `01` or `012` would be illegal.)

000123
["0.0.0.123"]
</code>```

(I made these examples by hand, so please alert me to any mistakes you may find.)

答:
Python 3, 232 bytes

import re,itertools as t,ipaddress as k
R=range
i=input()
for d in R(5):
 for p in t.combinations(R(len(i)),d):
  n=i;o=0
  for a in p:n=n[:a+o]+'.'+n[a+o:];o+=1
  try:k.ip_address(n);print(n*(not re.search(r'\D?0\d',n)))
  except:0
```

<p>Pretty simple: We place periods everywhere and print if the IP address with the periods placed is valid. We check the validity of the IP adresses by (ab)using <code>ipaddress.ip_address</code>, which raises an exception if the input is not a valid IP address. The challenge defines some additional rules that <code>ip_address</code> doesn't handle (namely, that there can be no leading zeroes), so we check for those too with a regular expression, then print.</p>

<p>Outputs each solution on a new line, mixed with an arbitrary number of blank lines.</p>

<p>Example run:</p>

```$ echo 012345 | python fixip.py
0.1.23.45
0.1.234.5
0.12.3.45
0.12.34.5
0.123.4.5

$ echo 000123 | python fixip.py
0.0.0.123

_
```

<p>Here's my older, 248-byte Python 2 solution. The second and third indent levels are <code>\t</code> (raw tab) and <code>\t</code> <code></code> (raw tab plus space) respectively. This plays <em>really</em> badly with Markdown, so the tabs have been replaced by two spaces.</p>

<pre class="lang-py prettyprint-override"><code>import socket,re,itertools as t
R=range
i=input()
for d in R(5):
 for p in t.combinations(R(len(i)),d):
  n=i;o=0
  for a in p:n=n[:a+o]+'.'+n[a+o:];o+=1
  try:
   socket.inet_aton(n)
   if n.count('.')==3and not re.search(r'\D?0\d',n):print n
  except:0
</code>```

Requires the input surrounded with quotes (e.g. "123.456.789"). Outputs each generated IP address on a new line.

Saved 9 bytes thanks to @grawity!

Title: Fix my IPv4 address's missing periods

Body:
Python 3, 232 bytes

import re,itertools as t,ipaddress as k
R=range
i=input()
for d in R(5):
 for p in t.combinations(R(len(i)),d):
  n=i;o=0
  for a in p:n=n[:a+o]+'.'+n[a+o:];o+=1
  try:k.ip_address(n);print(n*(not re.search(r'\D?0\d',n)))
  except:0

Pretty simple: We place periods everywhere and print if the IP address with the periods placed is valid. We check the validity of the IP adresses by (ab)using ipaddress.ip_address, which raises an exception if the input is not a valid IP address. The challenge defines some additional rules that ip_address doesn't handle (namely, that there can be no leading zeroes), so we check for those too with a regular expression, then print.

Outputs each solution on a new line, mixed with an arbitrary number of blank lines.

Example run:

$ echo 012345 | python fixip.py
0.1.23.45
0.1.234.5
0.12.3.45
0.12.34.5
0.123.4.5

$ echo 000123 | python fixip.py
0.0.0.123

_

Here's my older, 248-byte Python 2 solution. The second and third indent levels are \t (raw tab) and \t  (raw tab plus space) respectively. This plays really badly with Markdown, so the tabs have been replaced by two spaces.

import socket,re,itertools as t
R=range
i=input()
for d in R(5):
 for p in t.combinations(R(len(i)),d):
  n=i;o=0
  for a in p:n=n[:a+o]+'.'+n[a+o:];o+=1
  try:
   socket.inet_aton(n)
   if n.count('.')==3and not re.search(r'\D?0\d',n):print n
  except:0

Requires the input surrounded with quotes (e.g. "123.456.789"). Outputs each generated IP address on a new line.

Saved 9 bytes thanks to @grawity!


答:
JavaScript (ES6), <s>147</s> <s>141</s> 135 bytes

f=(s,n=0)=>(a=s.split`.`)[3]?a.every(s=>s==`0`|s[0]>0&s<256)?s+' ':'':[...s].map((_,i)=>i>n?f(s.slice(0,i)+`.`+s.slice(i),i):``).join`````
<pre class="snippet-code-html lang-html prettyprint-override"><code><input placeholder=Input oninput=o.textContent=f(this.value)><div id=o style=font-family:monospace;width:1em>Output</code>```

Edit: saved 6 bytes thanks to @apsillers. Saved another 6 bytes by copying @YOU's validity test.

Title: Fix my IPv4 address's missing periods

Body:
Sometimes when I'm typing out an IPv4 address, I get all the numbers right, but I forget to type one or more periods. I'd like to have a program (or function) that takes my broken IPv4 address and outputs all possible valid placements of the missing periods.

Input

The input will always be a string that is a transformation of a valid IPv4 address (see particulars below). It will always have been transformed solely by the elimination of one or more period characters.

You submission does not need to handle inputs outside of this format.

Output

A collection or list, in no particular order or format, of strings representing all valid IPv4 addresses that can be created from the input by the insertion of period characters into the input.

The output may be a language-native list or other ordered or unordered collection type.

Alternatively, it may be a string sequence of IPv4 address delimited in some clear way.

If you use a single-character delimiter to delimit your string, periods and digits are not allowed as that single-character delimiter. I realize that, unlike numbers, periods as delimiters are not ambiguous (since every fourth period would necessarily be a delimiter) but for the sake of readability, I am disallowing it.

IPv4 address format

While IPv4 addresses are really just a sequence of four binary octets, this challenge uses a restricted dotted decimal format.

An IPv4 address is a four decimal values separated by three periods.

Each of the four values are in the range 0 to 255, inclusive.

Leading zeros are not allowed in any number value. (Standalone one-character 0 is allowed; any other number beginning with a zero is not: 052, 00, etc.)

Test Cases

Input is on the first line, output on second line (here, structured as a comma-separated list of quoted strings, separated by commas, surrounded by [ ], but you may use any reasonable format or structure, as specified above). Some examples have notes on a third line to highlight the application of a particular rule.

```<code>192.168.1234
["192.168.1.234", "192.168.12.34", "192.168.123.4"]

192.1681234
["192.16.81.234", "192.168.1.234", "192.168.12.34", "192.168.123.4"]
(Note: 192.1681.2.34 (etc.) is illegal because 1681 is greater than 255)

1921681.234
["19.216.81.234", "192.16.81.234", "192.168.1.234"]

1921681234
["19.216.81.234", "192.16.81.234", "192.168.1.234", "192.168.12.34", "192.168.123.4"]

192.168.1204
["192.168.1.204", "192.168.120.4"]
(Note: 192.168.12.04 is illegal because of leading zero)

192.168.123
["1.92.168.123", "19.2.168.123", "192.1.68.123", "192.16.8.123", "192.168.1.23", "192.168.12.3"]

192.168.256
["192.168.2.56", "192.168.25.6"]
(Note: Any combination that would leave 256 intact is illegal)

120345
["1.20.3.45", "1.20.34.5", "1.203.4.5", "12.0.3.45", "12.0.34.5", "120.3.4.5"]
(Note: 12.03.4.5 (etc.) is illegal due to leading zero.)

012345
["0.1.23.45", "0.1.234.5", "0.12.3.45", "0.12.34.5", "0.123.4.5"]
(Note: the first segment must be 0, because `01` or `012` would be illegal.)

000123
["0.0.0.123"]
</code>```

(I made these examples by hand, so please alert me to any mistakes you may find.)

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

f=(s,n=0)=>(a=s.split`.`)[3]?a.every(s=>s==`0`|s[0]>0&s<256)?s+' ':'':[...s].map((_,i)=>i>n?f(s.slice(0,i)+`.`+s.slice(i),i):``).join``

<input placeholder=Input oninput=o.textContent=f(this.value)><div id=o style=font-family:monospace;width:1em>Output

Edit: saved 6 bytes thanks to @apsillers. Saved another 6 bytes by copying @YOU's validity test.


答:
Oracle SQL 11.2, 111 bytes

SELECT LISTAGG(TO_CHAR(SYSDATE,'YYYY')-LEVEL+1,', ')WITHIN GROUP(ORDER BY LEVEL)FROM DUAL CONNECT BY LEVEL<122;
```