答:
CJam, 75 bytes

```<code>lq3e4Vc*@{"-<[],.+>"#"T1$T=(t T(:T; { _T=}g \0+(@T@t _T=o "_'(')er+S/=}%s~@
</code>```

Try it online: string reverser, Hello World.

Explanation

Takes code on the first line of STDIN and input on all lines below it.

```<code>l            Read a line from STDIN (the program) and push it.
 q           Read the rest of STDIN (the input) and push it.
  3e4Vc*     Push a list of 30000 '\0' characters.
        @    Rotate the stack so the program is on top.

{               }%   Apply this to each character in prog:
 "-<[],.+>"#         Map '-' to 0, '<' to 1, ... and everything else to -1.
            ...=     Push a magical list and index from it.

s~       Concatenate the results and evaluate the resulting string as CJam code.
  @      Rotate the top three elements again -- but there are only two, so the
         program terminates.
</code>```

What about that magical list?

```<code>"T1$T=(t T(:T; { _T=}g \0+(@T@t _T=o "  Space-separated CJam snippets.
                                        (Note the final space! We want an empty
                                        string at the end of the list.)
_'(')er+                                Duplicate, change (s to )s, append.
        S/                              Split over spaces.
</code>```

The resulting list is as follows:

```<code>T1$T=(t    (-)
T(:T;      (<)
{          ([)
_T=}g      (])
\0+(@T@t   (,)
_T=o       (.)
T1$T=)t    (+)
T):T;      (>)
{          (unused)
_T=}g      (unused)
\0+(@T@t   (unused)
_T=o       (unused)
           (all other characters)
</code>```

We generate the snippets for + and > from those for - and <, simply by changing left parens (CJam’s “decrement”) into right parens (CJam’s “increment”).

ContentLicense: CC BY-SA 4.0

Title: Interpret brainfuck

Body:
Write the shortest program in your favourite language to interpret a brainfuck program. The program is read from a file. Input and output are standard input and standard output.

Cell size: 8bit unsigned. Overflow is undefined.

Array size: 30000 bytes (not circled)

Bad commands are not part of the input

Comments begin with # and extend to the end of line Comments are everything not in +-.,[]<>

no EOF symbol

A very good test can be found here. It reads a number and then prints the prime numbers up to that number. To prevent link rot, here is a copy of the code:

```<code>compute prime numbers
to use type the max number then push Alt 1 0
===================================================================
======================== OUTPUT STRING ============================
===================================================================
>++++++++[<++++++++>-]<++++++++++++++++.[-]
>++++++++++[<++++++++++>-]<++++++++++++++.[-]
>++++++++++[<++++++++++>-]<+++++.[-]
>++++++++++[<++++++++++>-]<+++++++++.[-]
>++++++++++[<++++++++++>-]<+.[-]
>++++++++++[<++++++++++>-]<+++++++++++++++.[-]
>+++++[<+++++>-]<+++++++.[-]
>++++++++++[<++++++++++>-]<+++++++++++++++++.[-]
>++++++++++[<++++++++++>-]<++++++++++++.[-]
>+++++[<+++++>-]<+++++++.[-]
>++++++++++[<++++++++++>-]<++++++++++++++++.[-]
>++++++++++[<++++++++++>-]<+++++++++++.[-]
>+++++++[<+++++++>-]<+++++++++.[-]
>+++++[<+++++>-]<+++++++.[-]

===================================================================
======================== INPUT NUMBER  ============================
===================================================================
+                          cont=1
[
 -                         cont=0
 >,
 ======SUB10======
 ----------

 [                         not 10
  <+>                      cont=1
  =====SUB38======
  ----------
  ----------
  ----------
  --------

  >
  =====MUL10=======
  [>+>+<<-]>>[<<+>>-]<     dup

  >>>+++++++++
  [
   <<<
   [>+>+<<-]>>[<<+>>-]<    dup
   [<<+>>-]
   >>-
  ]
  <<<[-]<
  ======RMOVE1======
  <
  [>+<-]
 ]
 <
]
>>[<<+>>-]<<

===================================================================
======================= PROCESS NUMBER  ===========================
===================================================================

==== ==== ==== ====
numd numu teid teiu
==== ==== ==== ====

>+<-
[
 >+
 ======DUP======
 [>+>+<<-]>>[<<+>>-]<

 >+<--

 >>>>>>>>+<<<<<<<<   isprime=1

 [
  >+

  <-

  =====DUP3=====
  <[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<<<

  =====DUP2=====
  >[>>+>+<<<-]>>>[<<<+>>>-]<<< <

  >>>

  ====DIVIDES=======
  [>+>+<<-]>>[<<+>>-]<   DUP i=div

  <<
  [
    >>>>>+               bool=1
    <<<
    [>+>+<<-]>>[<<+>>-]< DUP
    [>>[-]<<-]           IF i THEN bool=0
    >>
    [                    IF i=0
      <<<<
      [>+>+<<-]>>[<<+>>-]< i=div
      >>>
      -                  bool=0
    ]
    <<<
    -                    DEC i
    <<
    -
  ]

  +>>[<<[-]>>-]<<
  >[-]<                  CLR div
  =====END DIVIDES====

  [>>>>>>[-]<<<<<<-]     if divides then isprime=0

  <<

  >>[-]>[-]<<<
 ]

 >>>>>>>>
 [
  -
  <<<<<<<[-]<<

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

  >>

  ===================================================================
  ======================== OUTPUT NUMBER  ===========================
  ===================================================================
  [>+<-]>

  [
   ======DUP======
   [>+>+<<-]>>[<<+>>-]<

   ======MOD10====
   >+++++++++<
   [
    >>>+<<              bool= 1
    [>+>[-]<<-]         bool= ten==0
    >[<+>-]             ten = tmp
    >[<<++++++++++>>-]  if ten=0 ten=10
    <<-                 dec ten
    <-                  dec num
   ]
   +++++++++            num=9
   >[<->-]<             dec num by ten

   =======RROT======
      [>+<-]
   <  [>+<-]
   <  [>+<-]
   >>>[<<<+>>>-]
   <

   =======DIV10========
   >+++++++++<
   [
    >>>+<<                bool= 1
    [>+>[-]<<-]           bool= ten==0
    >[<+>-]               ten = tmp
    >[<<++++++++++>>>+<-] if ten=0 ten=10  inc div
    <<-                   dec ten
    <-                    dec num
   ]
   >>>>[<<<<+>>>>-]<<<<   copy div to num
   >[-]<                  clear ten

   =======INC1=========
   <+>
  ]

  <
  [
   =======MOVER=========
   [>+<-]

   =======ADD48========
   +++++++[<+++++++>-]<->

   =======PUTC=======
   <.[-]>

   ======MOVEL2========
   >[<<+>>-]<

   <-
  ]

  >++++[<++++++++>-]<.[-]

  ===================================================================
  =========================== END FOR ===============================
  ===================================================================

  >>>>>>>
 ]
 <<<<<<<<

 >[-]<
  [-]
 <<-
]

======LF========

++++++++++.[-]
@
</code>```

Example run:

```<code>$ python2 bf.py PRIME.BF
Primes up to: 100
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
</code>```

Body:
CJam, 75 bytes

lq3e4Vc*@{"-<[],.+>"#"T1$T=(t T(:T; { _T=}g \0+(@T@t _T=o "_'(')er+S/=}%s~@

Try it online: string reverser, Hello World.

Explanation

Takes code on the first line of STDIN and input on all lines below it.

l            Read a line from STDIN (the program) and push it.
 q           Read the rest of STDIN (the input) and push it.
  3e4Vc*     Push a list of 30000 '\0' characters.
        @    Rotate the stack so the program is on top.

{               }%   Apply this to each character in prog:
 "-<[],.+>"#         Map '-' to 0, '<' to 1, ... and everything else to -1.
            ...=     Push a magical list and index from it.

s~       Concatenate the results and evaluate the resulting string as CJam code.
  @      Rotate the top three elements again -- but there are only two, so the
         program terminates.

What about that magical list?

"T1$T=(t T(:T; { _T=}g \0+(@T@t _T=o "  Space-separated CJam snippets.
                                        (Note the final space! We want an empty
                                        string at the end of the list.)
_'(')er+                                Duplicate, change (s to )s, append.
        S/                              Split over spaces.

The resulting list is as follows:

T1$T=(t    (-)
T(:T;      (<)
{          ([)
_T=}g      (])
\0+(@T@t   (,)
_T=o       (.)
T1$T=)t    (+)
T):T;      (>)
{          (unused)
_T=}g      (unused)
\0+(@T@t   (unused)
_T=o       (unused)
           (all other characters)

We generate the snippets for + and > from those for - and <, simply by changing left parens (CJam’s “decrement”) into right parens (CJam’s “increment”).


问:
Falsify brief truths
Find the longest run of true in a list of booleans. Return the same list, with all other trues falsified.

Input, output

A list; any usual format (e.g., a delimited list as a string).

Details

True and false can be anything your language typically uses for those values, or the integers 1 and 0. If you use single characters, the list can be a concatenation (e.g., 10001).

If there's a tie for longest run, keep all tying runs true, and falsify all shorter runs.

Examples

```<code>input ↦ output
1,0,1,0,1 ↦ 1,0,1,0,1
1,1,0,1,1,0,1 ↦ 1,1,0,1,1,0,0
1,1,0,1,1,1,0,1,1 ↦ 0,0,0,1,1,1,0,0,0
1,1,1 ↦ 1,1,1
0,0,1 ↦ 0,0,1
0,0 ↦ 0,0
1,1,1,0,0,0,1,1,1,1,0,1,0,0,1,1,0,1,1,1,1,0,0,1,0 ↦ 0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0
</code>```

(directly from https://stackoverflow.com/q/37447114)

答:
J, 25 bytes

```<code>[:(}.=>./)@;0<@(*#);.1@,]
</code>```

This is a monadic verb that takes and returns a 0-1 array. Use it like this:

```<code>   f =: [:(}.=>./)@;0<@(*#);.1@,]
   f 1 1 0 1 1 1 0 1 1
0 0 0 1 1 1 0 0 0
</code>```

Explanation

```<code>[:(}.=>./)@;0<@(*#);.1@,]  Input is y.
            0          ,]  Prepend 0 to y, and
                   ;.1@    cut the result along occurrences of 0,
                           so that each piece begins with a 0.
               (*#)        Multiply each piece element-wise by its length,
             <@            and put it in a box.
                           Without the boxing, the pieces would go in a 0-padded array.
           ;               Join the pieces back together.
                           Now all runs of 1 have been replaced by runs of (1+length of run).
[:(      )@                Apply verb in parentheses:
   }.                        remove the prepended 0,
     =                       form the 0-1 array of equality with
      >./                    the maximum value.
</code>```

ContentLicense: CC BY-SA 3.0

Title: Falsify brief truths

Body:
J, 25 bytes

[:(}.=>./)@;0<@(*#);.1@,]

This is a monadic verb that takes and returns a 0-1 array. Use it like this:

   f =: [:(}.=>./)@;0<@(*#);.1@,]
   f 1 1 0 1 1 1 0 1 1
0 0 0 1 1 1 0 0 0

Explanation

[:(}.=>./)@;0<@(*#);.1@,]  Input is y.
            0          ,]  Prepend 0 to y, and
                   ;.1@    cut the result along occurrences of 0,
                           so that each piece begins with a 0.
               (*#)        Multiply each piece element-wise by its length,
             <@            and put it in a box.
                           Without the boxing, the pieces would go in a 0-padded array.
           ;               Join the pieces back together.
                           Now all runs of 1 have been replaced by runs of (1+length of run).
[:(      )@                Apply verb in parentheses:
   }.                        remove the prepended 0,
     =                       form the 0-1 array of equality with
      >./                    the maximum value.


问:
Alternating Sign Sequence

Introduction

The sign of a number is either a +, or a - for every non-zero integer. Zero itself is signless (+0 is the same as -0). In the following sequence, we are going to alternate between the positive sign, the zero and the negative sign. The sequence starts with 1, so we write 1 with a positive sign, with zero (this one is weird, but we just multiply the number by 0) and the negative sign:

```<code>1, 0, -1
</code>```

The next number is 2, and we do the same thing again:

```<code>2, 0, -2
</code>```

The sequence eventually is:

```<code>1, 0, -1, 2, 0, -2, 3, 0, -3, 4, 0, -4, 5, 0, -5, 6, 0, -6, 7, 0, -7, ...
</code>```

Or a more readable form:

```<code>a(0) = 1
a(1) = 0
a(2) = -1
a(3) = 2
a(4) = 0
a(5) = -2
a(6) = 3
a(7) = 0
a(8) = -3
a(9) = 4
...
</code>```

The Task

Given a non-negative integer n, output the nth term of the above sequence. You can choose if you use the zero-indexed or one-indexed version.

Test cases:

Zero-indexed:

```<code>a(0) = 1
a(11) = -4
a(76) = 0
a(134) = -45
a(296) = -99
</code>```

Or if you prefer one-indexed:

```<code>a(1) = 1
a(12) = -4
a(77) = 0
a(135) = -45
a(297) = -99
</code>```

This is code-golf, so the submission with the smallest number of bytes wins!

答:
Python 2, 24 bytes

lambda n:(n/3+1)*(1-n%3)
```

<h2>Full program:</h2>

<pre class="lang-python prettyprint-override"><code>a=lambda n:(n/3+1)*(1-n%3)

print(a(0))   #   1
print(a(11))  #  -4
print(a(76))  #   0
print(a(134)) # -45
print(a(296)) # -99
</code>```

Title: Alternating Sign Sequence

Body:
Python 2, 24 bytes

lambda n:(n/3+1)*(1-n%3)

Full program:

a=lambda n:(n/3+1)*(1-n%3)

print(a(0))   #   1
print(a(11))  #  -4
print(a(76))  #   0
print(a(134)) # -45
print(a(296)) # -99


答:
JavaScript ES6, 18 bytes

n=>-~(n/3)*(1-n%3)
```

<p>Turned out very similar to @LeakyNun's answer but I didn't see his until after I posted mine.</p>

<h2>Explanation and Ungolfed</h2>

<p><code>-~</code> is shorthand for <code>Math.ceil</code>, or rounding up:</p>

<pre class="lang-javascript prettyprint-override"><code>n =>               // input in var `n`
    Math.ceil(n/3) // Get every 3rd number 1,1,1,2,2,2, etc.
    *
    (1-n%3)        // 1, 0, -1, 1, 0, -1, ...
</code>```

function f(n){n=i.value;o.value=-~(n/3)*(1-n%3);}```
<pre class="snippet-code-html lang-html prettyprint-override"><code>Input: <input id=i oninput="f()"/><br /><br />
Output: <input id=o readable/></code>```

Title: Alternating Sign Sequence

Body:
Introduction

The sign of a number is either a +, or a - for every non-zero integer. Zero itself is signless (+0 is the same as -0). In the following sequence, we are going to alternate between the positive sign, the zero and the negative sign. The sequence starts with 1, so we write 1 with a positive sign, with zero (this one is weird, but we just multiply the number by 0) and the negative sign:

```<code>1, 0, -1
</code>```

The next number is 2, and we do the same thing again:

```<code>2, 0, -2
</code>```

The sequence eventually is:

```<code>1, 0, -1, 2, 0, -2, 3, 0, -3, 4, 0, -4, 5, 0, -5, 6, 0, -6, 7, 0, -7, ...
</code>```

Or a more readable form:

```<code>a(0) = 1
a(1) = 0
a(2) = -1
a(3) = 2
a(4) = 0
a(5) = -2
a(6) = 3
a(7) = 0
a(8) = -3
a(9) = 4
...
</code>```

The Task

Given a non-negative integer n, output the nth term of the above sequence. You can choose if you use the zero-indexed or one-indexed version.

Test cases:

Zero-indexed:

```<code>a(0) = 1
a(11) = -4
a(76) = 0
a(134) = -45
a(296) = -99
</code>```

Or if you prefer one-indexed:

```<code>a(1) = 1
a(12) = -4
a(77) = 0
a(135) = -45
a(297) = -99
</code>```

This is code-golf, so the submission with the smallest number of bytes wins!

Body:
JavaScript ES6, 18 bytes

n=>-~(n/3)*(1-n%3)

Turned out very similar to @LeakyNun's answer but I didn't see his until after I posted mine.

Explanation and Ungolfed

-~ is shorthand for Math.ceil, or rounding up:

n =>               // input in var `n`
    Math.ceil(n/3) // Get every 3rd number 1,1,1,2,2,2, etc.
    *
    (1-n%3)        // 1, 0, -1, 1, 0, -1, ...

function f(n){n=i.value;o.value=-~(n/3)*(1-n%3);}

Input: <input id=i oninput="f()"/><br /><br />
Output: <input id=o readable/>


答:
Pyke, <s>8</s> 7 bytes (old version)

```<code>3.DeRt*
</code>```

Try it here!
 - Note that link probably won't last for long

```<code>3.D      - a,b = divmod(input, 3)
   e     - a = ~a -(a+1)
     t   - b -= 1
      *  - a = a*b
         - implicit output a
</code>```

Newest version

```<code>3.DhRt*_
</code>```

Try it here!

```<code>3.D      - a,b = divmod(input, 3)
   h     - a+=1
     t   - b-=1
      *  - a = a*b
       _ - a = -a
         - implicit output a
</code>```

Title: Alternating Sign Sequence

Body:
Pyke, <s>8</s> 7 bytes (old version)

3.DeRt*

Try it here!
 - Note that link probably won't last for long

3.D      - a,b = divmod(input, 3)
   e     - a = ~a -(a+1)
     t   - b -= 1
      *  - a = a*b
         - implicit output a

Newest version

3.DhRt*_

Try it here!

3.D      - a,b = divmod(input, 3)
   h     - a+=1
     t   - b-=1
      *  - a = a*b
       _ - a = -a
         - implicit output a


答:
Jelly, 7 bytes

```<code>+6d3’PN
</code>```

Zero-indexed.
Test cases here.

Explanation:

```<code>+6      Add 6:     x+6
d3      Divmod:    [(x+6)/3, (x+6)%3]
’       Decrement: [(x+6)/3-1, (x+6)%3-1]
P       Product    ((x+6)/3-1) * ((x+6)%3-1)
</code>```

Title: Alternating Sign Sequence

Body:
Jelly, 7 bytes

+6d3’PN

Zero-indexed.
Test cases here.

Explanation:

+6      Add 6:     x+6
d3      Divmod:    [(x+6)/3, (x+6)%3]
’       Decrement: [(x+6)/3-1, (x+6)%3-1]
P       Product    ((x+6)/3-1) * ((x+6)%3-1)


答:
Retina, 45 bytes

```<code>.+
11$&$*
(111)+(1)*
$#2$#1
T`d`+0-`^.
^0.+
0
</code>```

Try it online!

Test suite.

Takes input/output in base-ten. 1-indexed.

Unary input, base-ten output, 1-indexed: 40 bytes

```<code>$
11
(111)+(1)*
$#2$#1
T`d`+0-`^.
^0.+
0
</code>```

Try it online!

Test suite.

Title: Alternating Sign Sequence

Body:
Retina, 45 bytes

.+
11$&$*
(111)+(1)*
$#2$#1
T`d`+0-`^.
^0.+
0

Try it online!

Test suite.

Takes input/output in base-ten. 1-indexed.

Unary input, base-ten output, 1-indexed: 40 bytes

$
11
(111)+(1)*
$#2$#1
T`d`+0-`^.
^0.+
0

Try it online!

<a href="http://retina.tryitonline.net/#code=JShgJAoxMQooMTExKSsoMSkqCiQjMiQjMQpUYGRgKzAtYF4uCl4wLisKMA&input=MQoxMTExMTExMTExMTEKMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTEKMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExCjExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMQ" rel="nofollow noreferrer">Test suite.


答:
MATL, <s> 15 </s> 12 bytes

```<code>3/XkG3X\2-*_
</code>```

This uses one based indexing.

Try it online! or verify test cases

Explanation:

```<code>    G          #Input
     3X\       #Modulus, except multiples of 3 give 3 instead of 0
        2-     #Subtract 2, giving -1, 0 or 1
3/Xk           #Ceiling of input divided by 3.
          *    #Multiply
           _   #Negate
</code>```

Title: Alternating Sign Sequence

Body:
MATL, <s> 15 </s> 12 bytes

3/XkG3X\2-*_

This uses one based indexing.

Try it online! or verify test cases

Explanation:

    G          #Input
     3X\       #Modulus, except multiples of 3 give 3 instead of 0
        2-     #Subtract 2, giving -1, 0 or 1
3/Xk           #Ceiling of input divided by 3.
          *    #Multiply
           _   #Negate


答:
Perl 6, <s> 26 </s> 23 bytes

<s>{({|(++$,0,--$)}...*)[$_]}</s>
{($_ div 3+1)*(1-$_%3)}```

<p>( The shorter one was translated from other answers )</p>

<h2>Explanation (of the first one):</h2>

<pre class="lang-perl6 prettyprint-override"><code>{ # bare block with implicit parameter ｢$_｣
  (

    # start of sequence generator

    { # bare block
      |(  # slip ( so that it flattens into the outer sequence )
        ++$, # incrementing anon state var =>  1, 2, 3, 4, 5, 6
        0,   # 0                           =>  0, 0, 0, 0, 0, 0
        --$  # decrementing anon state var => -1,-2,-3,-4,-5,-6
      )
    }
    ...  # repeat
    *    # indefinitely

    # end of sequence generator

  )[ $_ ] # get the nth one (zero based)
}
</code>```

Test:

#! /usr/bin/env perl6
use v6.c;
use Test;

# store it lexically
my &alt-seq-sign = {({|(++$,0,--$)}...*)[$_]}
my &short-one = {($_ div 3+1)*(1-$_%3)}

my @tests = (
    0 =>   1,
   11 =>  -4,
   76 =>   0,
  134 => -45,
  296 => -99,
  15..^30  => (6,0,-6,7,0,-7,8,0,-8,9,0,-9,10,0,-10)
);

plan @tests * 2 - 1;

for @tests {
  is alt-seq-sign( .key ), .value, 'alt-seq-sign  ' ~ .gist;

  next if .key ~~ Range; # doesn't support Range as an input
  is short-one(    .key ), .value, 'short-one     ' ~ .gist;
}
```

<pre class="lang-none prettyprint-override"><code>1..11
ok 1 - alt-seq-sign  0 => 1
ok 2 - short-one     0 => 1
ok 3 - alt-seq-sign  11 => -4
ok 4 - short-one     11 => -4
ok 5 - alt-seq-sign  76 => 0
ok 6 - short-one     76 => 0
ok 7 - alt-seq-sign  134 => -45
ok 8 - short-one     134 => -45
ok 9 - alt-seq-sign  296 => -99
ok 10 - short-one     296 => -99
ok 11 - alt-seq-sign  15..^30 => (6 0 -6 7 0 -7 8 0 -8 9 0 -9 10 0 -10)
</code>```

Title: Alternating Sign Sequence

Body:
Perl 6, <s> 26 </s> 23 bytes

<s>{({|(++$,0,--$)}...*)[$_]}</s>
{($_ div 3+1)*(1-$_%3)}

( The shorter one was translated from other answers )

Explanation (of the first one):

{ # bare block with implicit parameter ｢$_｣
  (

    # start of sequence generator

    { # bare block
      |(  # slip ( so that it flattens into the outer sequence )
        ++$, # incrementing anon state var =>  1, 2, 3, 4, 5, 6
        0,   # 0                           =>  0, 0, 0, 0, 0, 0
        --$  # decrementing anon state var => -1,-2,-3,-4,-5,-6
      )
    }
    ...  # repeat
    *    # indefinitely

    # end of sequence generator

  )[ $_ ] # get the nth one (zero based)
}

Test:

#! /usr/bin/env perl6
use v6.c;
use Test;

# store it lexically
my &alt-seq-sign = {({|(++$,0,--$)}...*)[$_]}
my &short-one = {($_ div 3+1)*(1-$_%3)}

my @tests = (
    0 =>   1,
   11 =>  -4,
   76 =>   0,
  134 => -45,
  296 => -99,
  15..^30  => (6,0,-6,7,0,-7,8,0,-8,9,0,-9,10,0,-10)
);

plan @tests * 2 - 1;

for @tests {
  is alt-seq-sign( .key ), .value, 'alt-seq-sign  ' ~ .gist;

  next if .key ~~ Range; # doesn't support Range as an input
  is short-one(    .key ), .value, 'short-one     ' ~ .gist;
}

1..11
ok 1 - alt-seq-sign  0 => 1
ok 2 - short-one     0 => 1
ok 3 - alt-seq-sign  11 => -4
ok 4 - short-one     11 => -4
ok 5 - alt-seq-sign  76 => 0
ok 6 - short-one     76 => 0
ok 7 - alt-seq-sign  134 => -45
ok 8 - short-one     134 => -45
ok 9 - alt-seq-sign  296 => -99
ok 10 - short-one     296 => -99
ok 11 - alt-seq-sign  15..^30 => (6 0 -6 7 0 -7 8 0 -8 9 0 -9 10 0 -10)


答:
J, <s>19</s> 15 bytes

```<code>>.@(%&3)*1-3|<:
</code>```

Probably need to golf this further...

1-indexed.

Ungolfed:

```<code>>> choose_sign      =: 1-3|<:      NB. 1-((n-1)%3)
>> choose_magnitude =: >.@(%&3)    NB. ceil(n/3)
>> f                =: choose_sign * choose_magnitude
>> f 1 12 77
<< 1 _4 0
</code>```

Where >> means input (STDIN) and << means output (STDOUT).

Title: Alternating Sign Sequence

Body:
J, <s>19</s> 15 bytes

>.@(%&3)*1-3|<:

Probably need to golf this further...

1-indexed.

Ungolfed:

>> choose_sign      =: 1-3|<:      NB. 1-((n-1)%3)
>> choose_magnitude =: >.@(%&3)    NB. ceil(n/3)
>> f                =: choose_sign * choose_magnitude
>> f 1 12 77
<< 1 _4 0

Where >> means input (STDIN) and << means output (STDOUT).


答:
Batch, <s>30</s> 29 bytes

```<code>@cmd/cset/a(1+%1/3)*(1-%1%%3)
</code>```

The cmd/c makes set/a echo the result of the calculation. Edit: Saved 1 byte by removing the unnecessary space.

Title: Alternating Sign Sequence

Body:
Batch, <s>30</s> 29 bytes

@cmd/cset/a(1+%1/3)*(1-%1%%3)

The cmd/c makes set/a echo the result of the calculation. Edit: Saved 1 byte by removing the unnecessary space.


答:
J,  27 bytes

Whilst not the golfiest, I like it better, as it uses an agenda.

```<code>>.@(>:%3:)*1:`0:`_1:@.(3|])
</code>```

Here is the tree decomposition of it:

```<code>         ┌─ >.
  ┌─ @ ──┤    ┌─ >:
  │      └────┼─ %
  │           └─ 3:
  ├─ *
──┤           ┌─ 1:
  │      ┌────┼─ 0:
  │      │    └─ _1:
  └─ @. ─┤
         │    ┌─ 3
         └────┼─ |
              └─ ]
</code>```

This is very similar to Kenny's J answer, in that it chooses the magnitude and sign, but it's different in that I use an agenda to choose the sign.

Title: Alternating Sign Sequence

Body:
J,  27 bytes

Whilst not the golfiest, I like it better, as it uses an agenda.

>.@(>:%3:)*1:`0:`_1:@.(3|])

Here is the tree decomposition of it:

         ┌─ >.
  ┌─ @ ──┤    ┌─ >:
  │      └────┼─ %
  │           └─ 3:
  ├─ *
──┤           ┌─ 1:
  │      ┌────┼─ 0:
  │      │    └─ _1:
  └─ @. ─┤
         │    ┌─ 3
         └────┼─ |
              └─ ]

This is very similar to Kenny's J answer, in that it chooses the magnitude and sign, but it's different in that I use an agenda to choose the sign.


答:
MATL, 8 bytes

```<code>_3&\wq*_
</code>```

This solution uses 1-based indexing into the sequence.

Try it Online

Modified version showing all test cases

Explanation

```<code>        % Implicitly grab the input
_       % Negate the input
3&\     % Compute the modulus with 3. The second output is floor(N/3). Because we negated
        % the input, this is the equivalent of ceil(input/3)
w       % Flip the order of the outputs
q       % Subtract 1 from the result of mod to turn [0 1 2] into [-1 0 1]
*       % Take the product with ceil(input/3)
_       % Negate the result so that the sequence goes [N 0 -N] instead of [-N 0 N]
        % Implicitly display the result
</code>```

Title: Alternating Sign Sequence

Body:
MATL, 8 bytes

_3&\wq*_

This solution uses 1-based indexing into the sequence.

Try it Online

Modified version showing all test cases

Explanation

        % Implicitly grab the input
_       % Negate the input
3&\     % Compute the modulus with 3. The second output is floor(N/3). Because we negated
        % the input, this is the equivalent of ceil(input/3)
w       % Flip the order of the outputs
q       % Subtract 1 from the result of mod to turn [0 1 2] into [-1 0 1]
*       % Take the product with ceil(input/3)
_       % Negate the result so that the sequence goes [N 0 -N] instead of [-N 0 N]
        % Implicitly display the result


答:
Jelly, 8 bytes

```<code>ŒPIE$ÐfṪ
</code>```

Try it online! or verify all test cases.

How it works

```<code>ŒPIE$ÐfṪ  Main link. Argument: A (list of integers)

ŒP        Powerset; generate all sublists of A, sorted by length.
     Ðf   Filter the powerset by the link to the left:
    $       Combine the two atoms to the left into a monadic link.
  I           Compute all increments.
   E          Test whether they're all equal.
          This returns all arithmetic subsequences, sorted by length.
       Ṫ  Tail; extract the last sequence.
</code>```

Title: Longest arithmetic subsequence

Body:
Given a non empty finite sequence of integers, return an arithmetic subsequence of maximal length.

If there are multiple of the same maximal length, any of them can be returned.

Definitions:

An arithmetic sequence is a sequence \$a(1),a(2),a(3),a(4),...\$ such that there is a constant \$c\$ such that \$a(m+1)-a(m) = c\$ for all \$m\$. In other words: The difference between two subsequent terms is constant.

Given a sequence \$b(1),b(2),b(3),b(4),...\$ a subsequence is a sequence \$b(s(1)),b(s(2)),b(s(3)),b(s(4)),...\$ where \$1 <= s(1)\$ and \$s(m) < s(m+1)\$ for all \$m\$. In other words: Take the original sequence and remove as many entries as you want.

Examples

```<code>Input                     Output
[4,1,2,3,6,5]             [1,3,5] or [1,2,3]
[5,4,2,-1,-2,-4,-4]       [5,2,-1,-4]
[1,2,1,3,1,4,1,5,1]       [1,1,1,1,1] or [1,2,3,4,5]
[1]                       [1]
</code>```

Some longer test cases:

```<code>Length: 25
Input: [-9,0,5,15,-1,4,17,-3,20,13,15,9,0,-6,11,17,17,9,26,11,5,11,3,16,25]
Output: [15,13,11,9] or [17,13,9,5]

Length: 50
Input: [35,7,37,6,6,33,17,33,38,30,38,12,37,49,44,5,19,19,35,30,40,19,11,5,39,11,20,28,12,33,25,8,40,6,15,12,27,5,21,6,6,40,15,31,49,22,35,38,22,33]
Output: [6,6,6,6,6] or [39,33,27,21,15]

Length: 100
Input: [6,69,5,8,53,10,82,82,73,15,66,52,98,65,81,46,44,83,9,14,18,40,84,81,7,40,53,42,66,63,30,44,2,99,17,11,38,20,49,34,96,93,6,74,27,43,55,95,42,99,31,71,67,54,70,67,18,13,100,18,4,57,89,67,20,37,47,99,16,86,65,38,20,43,49,13,59,23,39,59,26,30,62,27,83,99,74,35,59,11,91,88,82,27,60,3,43,32,17,18]
Output: [6,18,30,42,54] or [8,14,20,26,32] or [46,42,38,34,30] or [83,63,43,23,3] or [14,17,20,23,26] or [7,17,27,37,47] or [71,54,37,20,3]
</code>```

Background

I got this idea when I recalled the Green-Tao-Theorem from 2004, which states that the sequence of primes contains finite arithmetic sequences of arbitrary length.

Body:
Jelly, 8 bytes

ŒPIE$ÐfṪ

Try it online! or verify all test cases.

How it works

ŒPIE$ÐfṪ  Main link. Argument: A (list of integers)

ŒP        Powerset; generate all sublists of A, sorted by length.
     Ðf   Filter the powerset by the link to the left:
    $       Combine the two atoms to the left into a monadic link.
  I           Compute all increments.
   E          Test whether they're all equal.
          This returns all arithmetic subsequences, sorted by length.
       Ṫ  Tail; extract the last sequence.


答:
Pyth, <s>12</s> 11 bytes

```<code>ef!P{-VTtTy
</code>```

Test suite.

```<code>          y  powerset of implicit input, generate all subsequences
ef       T   find the last subsequence (sorted increasing in length) where...
       Tt      bifurcate over tail, giving [1,2,3,4,5] [2,3,4,5]
     -V        vectorize over -, giving differences of each consecutive pair
    {          dedup (remove duplicate elements)
   P           pop, resulting in [] if all differences were equal
  !            boolean not, resulting in True if all differences were equal
</code>```

Thanks to @LeakyNun for a byte!

Title: Longest arithmetic subsequence

Body:
Pyth, <s>12</s> 11 bytes

ef!P{-VTtTy

Test suite.

          y  powerset of implicit input, generate all subsequences
ef       T   find the last subsequence (sorted increasing in length) where...
       Tt      bifurcate over tail, giving [1,2,3,4,5] [2,3,4,5]
     -V        vectorize over -, giving differences of each consecutive pair
    {          dedup (remove duplicate elements)
   P           pop, resulting in [] if all differences were equal
  !            boolean not, resulting in True if all differences were equal

Thanks to @LeakyNun for a byte!


答:
MATL, <s>19</s> <s>18</s> <s>17</s> <s>16</s> 18 bytes

1 byte saved (and 2  bytes added back) thanks to Luis!

```<code>"GX@XN!"@dun2<?vx@
</code>```

A fairly naive approach which brute force checks all ordered permutations of the input. Obviously this can take a while for longer sequences. To save a byte, I have started with the smallest sub-sequences (length = 1) and worked up to the larger sequences (length = N).

Try it Online!

Explanation

```<code>                % Impilicitly grab input array (N)
"               % For each value in this array
    G           % Explicitly grab the input
    X@          % Loop index, will be [1, 2, ... length(N)] as we iterate
    XN          % Determine all permutations of k elements (nchoosek). The output is
                % each k-length permutation of the input as a different row. Order doesn't
                % matter so the result is always ordered the same as the input
    !           % Take the transpose so each k-length permutation is a column
    "           % For each column
        d       % Compute the difference between successive elements
        un      % Determine the number of unique differences
        2<?     % If there are fewer than 2 unique values
            vx  % Vertically concatenate everything on the stack so far and delete it
            @   % Push the current permuatation to the stack
                % Implicit end of if statement
                % Implicit end of for loop
                % Implicit end of for loop
                % Implicitly display the stack
</code>```

Title: Longest arithmetic subsequence

Body:
MATL, <s>19</s> <s>18</s> <s>17</s> <s>16</s> 18 bytes

1 byte saved (and 2  bytes added back) thanks to Luis!

"GX@XN!"@dun2<?vx@

A fairly naive approach which brute force checks all ordered permutations of the input. Obviously this can take a while for longer sequences. To save a byte, I have started with the smallest sub-sequences (length = 1) and worked up to the larger sequences (length = N).

Try it Online!

Explanation

                % Impilicitly grab input array (N)
"               % For each value in this array
    G           % Explicitly grab the input
    X@          % Loop index, will be [1, 2, ... length(N)] as we iterate
    XN          % Determine all permutations of k elements (nchoosek). The output is
                % each k-length permutation of the input as a different row. Order doesn't
                % matter so the result is always ordered the same as the input
    !           % Take the transpose so each k-length permutation is a column
    "           % For each column
        d       % Compute the difference between successive elements
        un      % Determine the number of unique differences
        2<?     % If there are fewer than 2 unique values
            vx  % Vertically concatenate everything on the stack so far and delete it
            @   % Push the current permuatation to the stack
                % Implicit end of if statement
                % Implicit end of for loop
                % Implicit end of for loop
                % Implicitly display the stack


问:
Create output twice the length of the code

The Challenge

Write a complete program that writes twice as many bytes to standard output as the length of the program.

Rules

The program must write ASCII characters to the standard output.

The contents of the output doesn't matter.

The output, measured in bytes, must be exactly twice the length of the program, also measured in bytes, unless you fulfill the bonus.

Any trailing newline is included in the output's byte count.

Bonus

Your program can optionally take a number, n, as input. If so, the output must be exactly n * program length bytes. You can assume that n will always be a positive integer. If no input is provided, n must default to 2.

If you do this,  you can subtract 25 bytes from your score.

Shortest program wins.

Restrictions

No standard loopholes.

The program must be at least 1 byte long.

No adding unnecessary whitespace to the source code to change its length. Similarly, comments don't count.

Unless you fulfill the bonus, the program must accept no input. If you do fulfill the bonus, the integer must be the only input.

Lowest score (program length in bytes - bonus) wins.

The shortest answer for each language wins for that language.

Leaderboards

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

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

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

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

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

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

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

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

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Java, 85

```<code>class A{public static void main(String[]s){for(A a:new A[170])System.out.println();}}
</code>```

Body:
Java, 85

class A{public static void main(String[]s){for(A a:new A[170])System.out.println();}}


问:
Palindrome Hello, World
Your task is to create a program that prints "Greetings, Planet!" exactly to the console. Seems simple enough, right? Well, here's the trick. The code must be a palindrome, meaning it reads from right to left the same as in left to right.
Standard loopholes are NOT allowed.

答:
APL, 41 bytes

```<code>'Greetings, Planet!'⍝'!tenalP ,sgniteerG'
</code>```

In APL, the last value is printed and the lamp character (⍝) start a comment.

Title: Palindrome Hello, World

Body:
APL, 41 bytes

'Greetings, Planet!'⍝'!tenalP ,sgniteerG'

In APL, the last value is printed and the lamp character (⍝) start a comment.


问:
List of primes under a million
This is my first code golf question, and a very simple one at that, so I apologise in advance if I may have broken any community guidelines.

The task is to print out, in ascending order, all of the prime numbers less than a million. The output format should be one number per line of output.

The aim, as with most code golf submissions, is to minimise code size. Optimising for runtime is also a bonus, but is a secondary objective.

答:
Pyth, 9 bytes

```<code>V^T6IP_NN
</code>```

Try it online!

Explanation:

```<code>V   : Iterate over all numbers from 0 to ...
^T6 : 10^6
I   : If ...
P_N : number is prime ...
N   : print number
</code>```

Title: List of primes under a million

Body:
Pyth, 9 bytes

V^T6IP_NN

Try it online!

Explanation:

V   : Iterate over all numbers from 0 to ...
^T6 : 10^6
I   : If ...
P_N : number is prime ...
N   : print number


答:
Python 2, <s>124</s> <s>115</s> <s>98</s> 97 bytes

p=[[]]
for n in input():p+=[x+[n][:2>len(x)or n-x[-1]==x[1]-x[0]]for x in p]
print max(p,key=len)
```

<p>Very slow and memory intensive. Test it on Ideone.</p>

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

<pre class="lang-python prettyprint-override"><code>p={()}
for n in input():p|={x+(n,)[:2>len(x)or n-x[-1]==x[1]-x[0]]for x in p}
print max(p,key=len)
</code>```

This completes all test cases instantly. Test it on Ideone.

Title: Longest arithmetic subsequence

Body:
Python 2, <s>124</s> <s>115</s> <s>98</s> 97 bytes

p=[[]]
for n in input():p+=[x+[n][:2>len(x)or n-x[-1]==x[1]-x[0]]for x in p]
print max(p,key=len)

Very slow and memory intensive. Test it on Ideone.

Alternate version, 98 bytes

p={()}
for n in input():p|={x+(n,)[:2>len(x)or n-x[-1]==x[1]-x[0]]for x in p}
print max(p,key=len)

This completes all test cases instantly. Test it on Ideone.


问:
"Hello, World!"
So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most interesting code golf in the common languages, finding the shortest solution in certain esolangs can be a serious challenge. For instance, to my knowledge it is not known whether the shortest possible Brainfuck solution has been found yet.

Furthermore, while all of <s>Wikipedia</s> (the Wikipedia entry has been deleted but there is a copy at archive.org
), esolangs and Rosetta Code have lists of "Hello, World!" programs, none of these are interested in having the shortest for each language (there is also this GitHub repository). If we want to be a significant site in the code golf community, I think we should try and create the ultimate catalogue of shortest "Hello, World!" programs (similar to how our basic quine challenge contains some of the shortest known quines in various languages). So let's do this!

The Rules

Each submission must be a full program.

The program must take no input, and print Hello, World! to STDOUT (this exact byte stream, including capitalization and punctuation) plus an optional trailing newline, and nothing else.

The program must not write anything to STDERR.

If anyone wants to abuse this by creating a language where the empty program prints Hello, World!, then congrats, they just paved the way for a very boring answer.

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

Submissions are scored in bytes, in an appropriate (pre-existing) encoding, usually (but not necessarily) UTF-8. Some languages, like Folders, are a bit tricky to score - if in doubt, please ask on Meta.

This is not about finding the language with the shortest "Hello, World!" program. This is about finding the shortest "Hello, World!" program in every language. Therefore, I will not mark any answer as "accepted".

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

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

For inspiration, check the Hello World Collection.

The Catalogue

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

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

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

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

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

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

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

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

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

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

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

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

    var lang = a.language;
    lang = jQuery(''+lang+'').text();

    languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;
    if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) return -1;
    return 0;
  });

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
APL, 15 bytes

```<code>'Hello, World!'
</code>```

In APL, the last value is printed, so the hello world is obvious.

Title: "Hello, World!"

Body:
APL, 15 bytes

'Hello, World!'

In APL, the last value is printed, so the hello world is obvious.


问:
Is the gas lighter than air?
Air balloons need a gas that is lighter than air. However, hydrogen is flammable, while helium is not sustainable, so we need a replacement! You must write code that determines whether any given gas is lighter than air.

Input: a molecular chemical formula of a gas (ASCII)

Output: true if the gas is lighter than air; false otherwise (see here for consensus on what can be used as true and false).

If the chemical formula doesn't represent a gas (at standard conditions), or if it's a nonsense, any behavior is acceptable.

That is to say, you can assume the following:

The input is a valid chemical formula

The input is a molecular chemical formula: all element symbols are mentioned only once, and there are no parentheses

The chemical substance exists at normal conditions

The chemical substance is a gas at normal conditions

As a special case, H2O (water vapor) is considered a gas, because you can mix a significant quantity of it with air at standard conditions.

Whether or not a gas is lighter than air can be determined by calculating its molar mass:

Extract the chemical element symbols from the formula. Their atomic masses are given by the following table:

H - 1

He - 4

B - 11

C - 12

N - 14

O - 16

F - 19

Ne - 20

Others - greater values

Calculate the molar mass, which is the sum of all the atomic masses. If the molar mass is less than 29, the gas is lighter than air.

Test cases:

```
H2      true
He      true
B2H6    true
CH4     true
C2H2    true
C2H4    true
HCN     true
N2      true
NH3     true
H2O     true
CO      true
HF      true
Ne      true
O2      false
C2H6    false
C4H10   false
H2S     false
COH2    false
CO2     false
SiH4    false
NO      false
BN      behavior nor specified: not a gas
HBO2    behavior nor specified: not a gas
F2O     behavior nor specified: incorrect formula
CH3     behavior nor specified: incorrect formula
HCOOH   behavior nor specified: not a molecular formula
B(OH)3  behavior nor specified: not a molecular formula
XYZ     behavior nor specified: nonsense
```

(Note: this is meant to be an enumeration of all possible inputs that generate true. If I forgot some, I'll add it. In any case, Wikipedia is the answer for questions like "Does substance X exist?", "Is it a gas?")

A related (but different) question: calculate the molar mass

答:
Python, 235 Bytes

```<code>import re
a={"H":1,"He":4,"B":11,"C":12,"N":14,"O":16,"F":19,"Ne":20}
try:print(str(29>sum([int(p[1])*a[p[0]] for p in [c if c[1]!="" else (c[0],"1") for c in re.findall(r'([A-Z][a-z]*)(\d*)',input())]])).lower())
except:print("false")
</code>```

Explanation:

```<code>import re # For the Regex
a={...} # Defining masses
try... except: # Catches unexpected elements and return false
re.findall(r'([A-Z][a-z]*)(\d*)',input()) # Group capture of the elements (credit to Draxx)
c if c[1]!="" else (c[0],"1") for c in # Sometimes, they may not have numbers after them, thus, if else!
int(p[1])*a[p[0]] # Mass of each elements
str(29>sum(...)).lower() # Boolean whether the statement is true/false translated to lower case string
</code>```

Or, taking the MattPutnam way of doing things...

Python, 71 Bytes

```<code>lambda n:n in"H2 He B2H6 CH4 C2H2 C2H4 HCN N2 NH3 H2O CO HF Ne".split()
</code>```

(Credit to @Lynn)

Title: Is the gas lighter than air?

Body:
Python, 235 Bytes

import re
a={"H":1,"He":4,"B":11,"C":12,"N":14,"O":16,"F":19,"Ne":20}
try:print(str(29>sum([int(p[1])*a[p[0]] for p in [c if c[1]!="" else (c[0],"1") for c in re.findall(r'([A-Z][a-z]*)(\d*)',input())]])).lower())
except:print("false")

Explanation:

import re # For the Regex
a={...} # Defining masses
try... except: # Catches unexpected elements and return false
re.findall(r'([A-Z][a-z]*)(\d*)',input()) # Group capture of the elements (credit to Draxx)
c if c[1]!="" else (c[0],"1") for c in # Sometimes, they may not have numbers after them, thus, if else!
int(p[1])*a[p[0]] # Mass of each elements
str(29>sum(...)).lower() # Boolean whether the statement is true/false translated to lower case string

Or, taking the MattPutnam way of doing things...

Python, 71 Bytes

lambda n:n in"H2 He B2H6 CH4 C2H2 C2H4 HCN N2 NH3 H2O CO HF Ne".split()

(Credit to @Lynn)


答:
GolfScript, 41 bytes

```<code>"Greetings, Planet!"#"!tenalP ,sgniteerG"
</code>```

Try it online !

Title: Palindrome Hello, World

Body:
Your task is to create a program that prints "Greetings, Planet!" exactly to the console. Seems simple enough, right? Well, here's the trick. The code must be a palindrome, meaning it reads from right to left the same as in left to right.
Standard loopholes are NOT allowed.

Body:
GolfScript, 41 bytes

"Greetings, Planet!"#"!tenalP ,sgniteerG"

Try it online !


答:
Pyth, 10 bytes

```<code>*h/Q3-1%Q3
</code>```

Try it online!

Explanation:

```<code>*     : Multiply following two arguments
h/Q3  : 1 + Input/3
-1%Q3 : 1 - Input%3
</code>```

Note: I've assumed the zero-indexed sequence.

Title: Alternating Sign Sequence

Body:
Introduction

The sign of a number is either a +, or a - for every non-zero integer. Zero itself is signless (+0 is the same as -0). In the following sequence, we are going to alternate between the positive sign, the zero and the negative sign. The sequence starts with 1, so we write 1 with a positive sign, with zero (this one is weird, but we just multiply the number by 0) and the negative sign:

```<code>1, 0, -1
</code>```

The next number is 2, and we do the same thing again:

```<code>2, 0, -2
</code>```

The sequence eventually is:

```<code>1, 0, -1, 2, 0, -2, 3, 0, -3, 4, 0, -4, 5, 0, -5, 6, 0, -6, 7, 0, -7, ...
</code>```

Or a more readable form:

```<code>a(0) = 1
a(1) = 0
a(2) = -1
a(3) = 2
a(4) = 0
a(5) = -2
a(6) = 3
a(7) = 0
a(8) = -3
a(9) = 4
...
</code>```

The Task

Given a non-negative integer n, output the nth term of the above sequence. You can choose if you use the zero-indexed or one-indexed version.

Test cases:

Zero-indexed:

```<code>a(0) = 1
a(11) = -4
a(76) = 0
a(134) = -45
a(296) = -99
</code>```

Or if you prefer one-indexed:

```<code>a(1) = 1
a(12) = -4
a(77) = 0
a(135) = -45
a(297) = -99
</code>```

This is code-golf, so the submission with the smallest number of bytes wins!

Body:
Pyth, 10 bytes

*h/Q3-1%Q3

Try it online!

Explanation:

*     : Multiply following two arguments
h/Q3  : 1 + Input/3
-1%Q3 : 1 - Input%3

Note: I've assumed the zero-indexed sequence.


答:
Haystack, 43 bytes

```<code>"Greetings, Planet!"o|o"!tenalP, sgniteerG"
</code>```

Here's how this two-dimensional program works:

"Greetings, Planet!" pushes a string whose content is Greetings, Planet! to the stack.

o prints everything in the stack.

| is the needle. The program ends because it found the needle in the haystack!

o"!tenalP, sgniteerG" isn't executed as the needle is found before reaching there.

Hello World example(s) from shebang

Title: Palindrome Hello, World

Body:
Haystack, 43 bytes

"Greetings, Planet!"o|o"!tenalP, sgniteerG"

Here's how this two-dimensional program works:

"Greetings, Planet!" pushes a string whose content is Greetings, Planet! to the stack.

o prints everything in the stack.

| is the needle. The program ends because it found the needle in the haystack!

o"!tenalP, sgniteerG" isn't executed as the needle is found before reaching there.

Hello World example(s) from shebang


问:
Shortest code to produce infinite output
Write the shortest code you can that produces an infinite output.

That's all. You code will only be disqualified if it stops producing output at some point. As always in code golf, the shortest code wins.

Here's a list of answers that I think are really clever, so they can get credit:

The comma is both code and data

Infinite errors (that counts)

Infinite warnings (that also counts)

What's Marbelous?

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
APL, 4 bytes

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

This code must be put in a function, since the →(goto) operator has only sense in a function.

Body:
APL, 4 bytes

1
→1

This code must be put in a function, since the →(goto) operator has only sense in a function.


Title: Alternating Sign Sequence

Body:
Bash, 28 25 Bytes

echo $[(1+$1/3)*(1-$1%3)]


Title: Alternating Sign Sequence

Body:
GNU Coreutils, 27 Bytes

echo "(1+$1/3)*(1-$1%3)"|bc


答:
MATLAB / Octave, 27 bytes

```<code>@(n)ceil(n/3)*(mod(-n,3)-1)
</code>```

This creates an anonymous function that can be called using ans(n). This solution uses 1-based indexing.

All test cases

Title: Alternating Sign Sequence

Body:
MATLAB / Octave, 27 bytes

@(n)ceil(n/3)*(mod(-n,3)-1)

This creates an anonymous function that can be called using ans(n). This solution uses 1-based indexing.

All test cases


问:
Generate an infinite group of infinite galaxies
Here is the challenge as proposed by @trichoplax thanks to him for consolidating my post and standarizing it to PPCG common-rules.

A galaxy is a group of numbers where each one is mapped to another via a precise function f either a symbolic one or mathematical, a structure of numbers sharing some common points with this challenge i got inspired from with an exception that a galaxy sequence is not cyclic, but holds in a black hole, where more than one number can be mapped to it.

A black hole is a specific unique number from a galaxy where all numbers (not individually) are mapped transitively to it, by repeating a function f infinitely over an infinite far number in a same galaxy, or just once if a number is the closest in the same galaxy, for example if the function is the ceiling of the square root then a black hole for the biggest galaxy so far excluding only the number 1 is 2, because mapping the closest number 3 or the infinite repetitively leads to the same number.

Task

Conceive a universe of an infinite number of distinct galaxies where all galaxies encompass an infinite number of integers.

Note that the example of ceiling of square root is banned for two reasons:

The galaxy {1} is finite.

There is a finite number of galaxies.

A valid example, is dividing by the smallest prime factor. This gives an infinite number of infinite galaxies.

```<code>2*2*3*5*5*7, 2*3*5*5*7, 3*5*5*7, 5*5*7, 5*7, 7, 7*5*5*5, 7*5*5*5....
5*5*7*11, 5*7*11, 11*7*7*7... , ....
...
</code>```

Or one galaxy as a tree:

```<code>2*2*5 - 2*5 \
             \
2*3*5 - 3*5 - 5
3*3*5 /       |
             /
2*5*5 - 5*5 /
3*5*5 /
</code>```

Each galaxy consists of all numbers that share the same largest prime factor, and the function takes them all step by step towards the black hole which is that prime factor.

Note also, you may choose any domain of integers as long as the range is infinite, i mean you can exclude a range of numbers that makes the rest still boundless like {1,0} from last example.

Your program takes any integer input via a function's dimension , STDIN, and outputs an integer as the image mapped from this preimage, otherwise prints "error" or any string prespecified for an outputless range of enteries.

For the same example:

(IN/OUTPUT)

```<code>   20
   10

   15
   5

   77
   11

   0
   'undefined'

   1
   'undefined'
</code>```

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

I would have really liked to add a bonus-score for anyone who succeeds to find a function generating a universe without trees, alas, bonuses for code-golf are excluded.

答:
matlab (156)

```<code>a=input('');if find(num2str(a)=='0')a,return,end,b=char(num2str(a)-1);c=str2num(b);if find(b=='0')if(find(num2str(c)=='0')&c)c,else 10^nnz(b)+c,end,else c,end
</code>```

I declare my self the winner of that imaginary score because i am the first who finds a universe of galaxies without trees.

Domain is decimal numbers with two or more significant digits. and not a difference bteween two arbitray digits squals to 9 .

Black holes are numbers which have significant zeros, either in the extreme bottom, or between two strictly positive digits 12300131 , 123400 , 10 , ....

The function is decrementing all decimal digits of that number by 1, if we stumble upon a significant zero we declare a blackhole, if non-significant zero at the head of this number, precede it with 1 then the result topped by unsignificant zeos.

There is no trees in that galaxy except the blackhole which absorbs an infinite tree-less streams of finite numbers.

Body:
matlab (156)

a=input('');if find(num2str(a)=='0')a,return,end,b=char(num2str(a)-1);c=str2num(b);if find(b=='0')if(find(num2str(c)=='0')&c)c,else 10^nnz(b)+c,end,else c,end

I declare my self the winner of that imaginary score because i am the first who finds a universe of galaxies without trees.

Domain is decimal numbers with two or more significant digits. and not a difference bteween two arbitray digits squals to 9 .

Black holes are numbers which have significant zeros, either in the extreme bottom, or between two strictly positive digits 12300131 , 123400 , 10 , ....

The function is decrementing all decimal digits of that number by 1, if we stumble upon a significant zero we declare a blackhole, if non-significant zero at the head of this number, precede it with 1 then the result topped by unsignificant zeos.

There is no trees in that galaxy except the blackhole which absorbs an infinite tree-less streams of finite numbers.


答:
INXW63CTMNZGS4DU, 42 bytes

```<code>"Greetings, Planet!"#"!tenalP, sgniteerG"
</code>```

A trailing newline is needed at the end

The # character start a comment, and the last value is printed, so this program print "Greetings, Planet!"

Title: Palindrome Hello, World

Body:
INXW63CTMNZGS4DU, 42 bytes

"Greetings, Planet!"#"!tenalP, sgniteerG"

A trailing newline is needed at the end

The # character start a comment, and the last value is printed, so this program print "Greetings, Planet!"


答:
Mathematica 26 bytes

With 4 bytes saved thanks to Martin Ender.

```<code>⎡#/3⎤(-#~Mod~3-1)&
</code>```

Uses the same approach as Suever.

Title: Alternating Sign Sequence

Body:
Mathematica 26 bytes

With 4 bytes saved thanks to Martin Ender.

⎡#/3⎤(-#~Mod~3-1)&

Uses the same approach as Suever.


答:
Pyth, 2 bytes

```<code>hP
</code>```

Domain: integers ≥ 2.  Function: smallest prime factor.  Black holes: primes.

(This seems too simple but seems to satisfy the challenge as far as I can tell.  Is the challenge missing some requirement?  For example, perhaps the function is supposed to be surjective?)

Title: Generate an infinite group of infinite galaxies

Body:
Here is the challenge as proposed by @trichoplax thanks to him for consolidating my post and standarizing it to PPCG common-rules.

A galaxy is a group of numbers where each one is mapped to another via a precise function f either a symbolic one or mathematical, a structure of numbers sharing some common points with this challenge i got inspired from with an exception that a galaxy sequence is not cyclic, but holds in a black hole, where more than one number can be mapped to it.

A black hole is a specific unique number from a galaxy where all numbers (not individually) are mapped transitively to it, by repeating a function f infinitely over an infinite far number in a same galaxy, or just once if a number is the closest in the same galaxy, for example if the function is the ceiling of the square root then a black hole for the biggest galaxy so far excluding only the number 1 is 2, because mapping the closest number 3 or the infinite repetitively leads to the same number.

Task

Conceive a universe of an infinite number of distinct galaxies where all galaxies encompass an infinite number of integers.

Note that the example of ceiling of square root is banned for two reasons:

The galaxy {1} is finite.

There is a finite number of galaxies.

A valid example, is dividing by the smallest prime factor. This gives an infinite number of infinite galaxies.

```<code>2*2*3*5*5*7, 2*3*5*5*7, 3*5*5*7, 5*5*7, 5*7, 7, 7*5*5*5, 7*5*5*5....
5*5*7*11, 5*7*11, 11*7*7*7... , ....
...
</code>```

Or one galaxy as a tree:

```<code>2*2*5 - 2*5 \
             \
2*3*5 - 3*5 - 5
3*3*5 /       |
             /
2*5*5 - 5*5 /
3*5*5 /
</code>```

Each galaxy consists of all numbers that share the same largest prime factor, and the function takes them all step by step towards the black hole which is that prime factor.

Note also, you may choose any domain of integers as long as the range is infinite, i mean you can exclude a range of numbers that makes the rest still boundless like {1,0} from last example.

Your program takes any integer input via a function's dimension , STDIN, and outputs an integer as the image mapped from this preimage, otherwise prints "error" or any string prespecified for an outputless range of enteries.

For the same example:

(IN/OUTPUT)

```<code>   20
   10

   15
   5

   77
   11

   0
   'undefined'

   1
   'undefined'
</code>```

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

I would have really liked to add a bonus-score for anyone who succeeds to find a function generating a universe without trees, alas, bonuses for code-golf are excluded.

Body:
Pyth, 2 bytes

hP

Domain: integers ≥ 2.  Function: smallest prime factor.  Black holes: primes.

(This seems too simple but seems to satisfy the challenge as far as I can tell.  Is the challenge missing some requirement?  For example, perhaps the function is supposed to be surjective?)


答:
Brainfuck, 26 bytes

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

Do 4*4*2+1 (33, !) and the final loop is a infinite loop that only print the current memory cell (!).

Title: Shortest code to produce infinite output

Body:
Write the shortest code you can that produces an infinite output.

That's all. You code will only be disqualified if it stops producing output at some point. As always in code golf, the shortest code wins.

Here's a list of answers that I think are really clever, so they can get credit:

The comma is both code and data

Infinite errors (that counts)

Infinite warnings (that also counts)

What's Marbelous?

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Brainfuck, 26 bytes

++++[>++++<-]>[>++<-]>+[.]

Do 4*4*2+1 (33, !) and the final loop is a infinite loop that only print the current memory cell (!).


Title: Create output twice the length of the code

Body:
The Challenge

Write a complete program that writes twice as many bytes to standard output as the length of the program.

Rules

The program must write ASCII characters to the standard output.

The contents of the output doesn't matter.

The output, measured in bytes, must be exactly twice the length of the program, also measured in bytes, unless you fulfill the bonus.

Any trailing newline is included in the output's byte count.

Bonus

Your program can optionally take a number, n, as input. If so, the output must be exactly n * program length bytes. You can assume that n will always be a positive integer. If no input is provided, n must default to 2.

If you do this,  you can subtract 25 bytes from your score.

Shortest program wins.

Restrictions

No standard loopholes.

The program must be at least 1 byte long.

No adding unnecessary whitespace to the source code to change its length. Similarly, comments don't count.

Unless you fulfill the bonus, the program must accept no input. If you do fulfill the bonus, the integer must be the only input.

Lowest score (program length in bytes - bonus) wins.

The shortest answer for each language wins for that language.

Leaderboards

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

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

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

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

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

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

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

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

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
APL, 3 bytes

1e5

Print 100000...


答:
Pyth, <s>5</s> 4 bytes, no trees

I am working under the assumption that the author intended for the function to be surjective, and for “no trees” to mean that only black holes have multiple preimages. (Technically, a tree with only one branch is still a tree.)

```<code>ahxt
</code>```

Domain: positive integers.  Function: f(x) = |((x − 1) XOR x) + 1 − x|.  Black holes: powers of 2.  Galaxies:

1 ← 3 ← 5 ← 7 ← 9 ← 11 ← ⋯,

2 ← 6 ← 10 ← 14 ← 18 ← 22 ← ⋯,

4 ← 12 ← 20 ← 28 ← 36 ← 44 ← ⋯,

8 ← 24 ← 40 ← 56 ← 72 ← 88 ← ⋯,

⋮

Body:
Pyth, <s>5</s> 4 bytes, no trees

I am working under the assumption that the author intended for the function to be surjective, and for “no trees” to mean that only black holes have multiple preimages. (Technically, a tree with only one branch is still a tree.)

ahxt

Domain: positive integers.  Function: f(x) = |((x − 1) XOR x) + 1 − x|.  Black holes: powers of 2.  Galaxies:

1 ← 3 ← 5 ← 7 ← 9 ← 11 ← ⋯,

2 ← 6 ← 10 ← 14 ← 18 ← 22 ← ⋯,

4 ← 12 ← 20 ← 28 ← 36 ← 44 ← ⋯,

8 ← 24 ← 40 ← 56 ← 72 ← 88 ← ⋯,

⋮


问:
Is this figure connected?
You are given a list of (x,y) grid coordinates.  Your function should decide whether the figure obtained by coloring in the squares of the grid with the given coordinates is connected or not.

Squares adjacent diagonally are not considered connected.

Example input:

```<code>(0,0),(1,0),(2,0),(3,0),(3,1),(3,2),(2,2),
(1,2),(0,2),(0,3),(0,4),(1,4),(2,4),(3,4)
</code>```

which looks like:

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

Output:

```<code>YES
</code>```

Example input:

```<code>(0,0),(1,0),(2,0),(0,1),(0,2),(2,2),(3,2),(4,2),(0,3),
(4,3),(0,4),(1,4),(2,4),(4,4),(4,5),(2,6),(3,6),(4,6)
</code>```

which looks like:

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

Output:

```<code>NO
</code>```

Your function must take as input a list of pairs of integers (e.g. in C++, maybe vector<pair<int,int>>) and return a boolean.  You may not assume any particular ordering of the input points.  The coordinates will be between 0 and 99 inclusive.

Smallest code wins.

ContentLicense: CC BY-SA 2.5

Title: Is this figure connected?

Body:
Perl - 150

sub f{$m[pop][pop]++while@_;for$i(0..@m){for$j(0..9){$_.=$m[$i][$j]||0}$_.="3"}s/1/2/;for$n(0..99){s/(?<=2)1|1(?=2)|1(?=.{10}2)|(?<=2.{10})1/2/}!m/1/}

Works for 10 columns. For more I'd need another character.

Expands the color of one square a lot of times with one regex. Building the string takes a lot more space than I'd like it to.

Ungolfed:

sub f{
    $m[pop][pop]++ while @_;
    for $i (0..@m) {
        for $j (0..9) {
            $_ .= $m[$i][$j] || 0
        }
        $_ .= "3";
    }
    s/1/2/;
    for$n(0..99) {
        s/(?<=2)1|1(?=2)|1(?=.{10}2)|(?<=2.{10})1/2/
    }
    !m/1/
}

print f((0,0),(1,0),(2,0),(3,0),(3,1),(3,2),(2,2), (1,2),(0,2),(0,3),(0,4),(1,4),(2,4),(3,4)) ? YES : NO;


答:
Haystack, 6 bytes (non-competing, the language came 2 years after the challenge)

```<code>>"a"o<
</code>```

This will print a [infinity] times.

If the above code gives a syntax error because of the lack of | (that character is the needle. The ultimate goal of all Haystack programs is to find the needle in the haystack), one can simply append it to the end:

```<code>>"a"o<|
</code>```

Body:
Haystack, 6 bytes (non-competing, the language came 2 years after the challenge)

>"a"o<

This will print a [infinity] times.

If the above code gives a syntax error because of the lack of | (that character is the needle. The ultimate goal of all Haystack programs is to find the needle in the haystack), one can simply append it to the end:

>"a"o<|


答:
C, 20 bytes (competing according to the challenge's creator)

Suppose the following code is contained in e.c:

```<code>int i;
#include"e.c"
</code>```

In a machine with infinite system resources, GCC will create an infinitely big temporary file trying to resolve a recursive #inclusion.

Body:
C, 20 bytes (competing according to the challenge's creator)

Suppose the following code is contained in e.c:

int i;
#include"e.c"

In a machine with infinite system resources, GCC will create an infinitely big temporary file trying to resolve a recursive #inclusion.