问:
Determine the original sequence
Write a program that will determine the original sequence given five variations. The original sequence will be contain n unique elements in any order. A variation is made by making a copy of the original sequence and choosing a random item from the copy and inserting it at any random location in the sequence (this could be the same index it was originally at). Also, each item can only be chosen once so that the five variations will each operate on a different item.

Input

```<code>5          # number of items
1 2 3 4 5  # unknown
2 1 3 4 5  # 3,4,5 candidate
3 1 2 4 5  # 4,5 candidate
4 1 2 3 5  # 1,2 candidate
5 1 2 3 4  # 1,2,3 candidate
           # 1,2,3 + 3,4,5 = 1,2,3,4,5
</code>```

Output

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

In case it's not clear what I meant, here is Python code to generate an example

```<code>from random import shuffle,randint

n = 5 # can be any number
a = range(1, n+1)
shuffle(a)
s = set()
#print str(a[0])+"".join(" "+str(x) for x in a[1:]) #debug (print orig sequence)
for run in xrange(5):
    c = list(a)
    i = randint(0, n-1)
    while c[i] in s:
        i = randint(0, n-1)
    t = c.pop(i)
    s.add(t)
    c.insert(randint(0, n-1), t)
    print str(c[0])+"".join(" "+str(x) for x in c[1:])
</code>```

Keep in mind, the numbers aren't necessarily consecutive or all positive. The shortest wins.

Longer Example

Here's how the five variations are generated. Each is just one step away from the original.

```<code>6 3 4 5 7 1 2 # original

6 4 5 7 3 1 2 # 3 moved to index 3
3 6 4 5 7 1 2 # 6 moved to index 1
6 3 4 5 1 2 7 # 7 moved to index 6
6 3 4 7 1 5 2 # 5 moved to index 5
6 3 2 4 5 7 1 # 2 moved to index 2
</code>```

Contiguous subsequences of the original will remain in each variation.

```<code>6 4 5 7 3 1 2
3 6 4 5 7 1 2
          x x # (1, 2) is a candidate

6 4 5 7 3 1 2
6 3 4 5 1 2 7
x             # (6) is a candidate but we can ignore it since one item
              # doesn't tell us much

6 4 5 7 3 1 2
6 3 4 7 1 5 2
x     x     x

6 4 5 7 3 1 2
6 3 2 4 5 7 1
x

3 6 4 5 7 1 2
6 3 4 5 1 2 7
    x x       # (4, 5)

3 6 4 5 7 1 2
6 3 4 7 1 5 2
    x

3 6 4 5 7 1 2
6 3 2 4 5 7 1

6 3 4 5 1 2 7
6 3 4 7 1 5 2
x x x         # (6, 3, 4)

6 3 4 5 1 2 7
6 3 2 4 5 7 1
x x           # (6, 3)

6 3 4 7 1 5 2
6 3 2 4 5 7 1
x x           # (6, 3)
</code>```

Merging the candidates together we realize the sequence has

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

We can get the rest by realizing that by inserting an item, the sequence may be shifted by one in either direction, so repeat the above except using a unshifted sequence.

```<code>4 5 7 3 1 2
3 6 4 5 7 1 2

4 5 7 3 1 2
6 3 4 5 1 2 7
        x x   # (1, 2)

4 5 7 3 1 2
6 3 4 7 1 5 2
        x

4 5 7 3 1 2
6 3 2 4 5 7 1

6 4 5 7 1 2
6 3 4 5 1 2 7
x       x x   # (1, 2)

6 4 5 7 1 2
6 3 4 7 1 5 2
x     x x     # (7, 1) something new!

6 4 5 7 1 2
6 3 2 4 5 7 1
x

3 4 5 1 2 7
6 3 4 7 1 5 2

3 4 5 1 2 7
6 3 2 4 5 7 1
          x

3 4 7 1 5 2
6 3 2 4 5 7 1
        x
</code>```

Merging those with our previous results give us

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

Now do the same again except unshifting the other.

```<code>6 4 5 7 3 1 2
6 4 5 7 1 2
x x x x       # (6, 4, 5, 7)

6 4 5 7 3 1 2
3 4 5 1 2 7
  x x         # (4, 5)

6 4 5 7 3 1 2
3 4 7 1 5 2
  x

6 4 5 7 3 1 2
3 2 4 5 7 1

3 6 4 5 7 1 2
3 4 5 1 2 7
x

3 6 4 5 7 1 2
3 4 7 1 5 2
x

3 6 4 5 7 1 2
3 2 4 5 7 1
x   x x x x   # (4, 5, 7, 1)

6 3 4 5 1 2 7
3 4 7 1 5 2

6 3 4 5 1 2 7
3 2 4 5 7 1
    x x       # (4, 5)

6 3 4 7 1 5 2
3 2 4 5 7 1
    x
</code>```

Merging those with our previous gives us

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

Each candidate gives the "general" order of the original sequence. For example (6, 4, 5, 7) just says "6 before 4 before 5 before 7" but doesn't say anything about numbers that max exist between say 6 and 4. However, we have (6, 3, 4, 5) which lets us know a 3 exists between 6 and 4 so when we merge the two candidates, we end up with (6, 3, 4, 5, 7).

Additional example

Input

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

Output

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

Doing it similar to the above, we get candidates

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

Some are obviously self-contained, so simplifying we get

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

Then one is an obvious extension of the other, so we get

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

The first lets us know 5 goes before 6 and the other two say (3, 4) go after both 5 and 6, so we get

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

If you noticed, each of the items in a candidate can represent a vertex and an edge going from one item to another. Putting them all together will allow you to make a DAG.
This is just the way I do it, there may be other and better ways to do it.

答:
GolfScript, 44 characters

```<code>n/{~]}%:^0=.,{{{.3$?\2$?>}^%$2={\}*}*]}*" "*
</code>```

The solution can be tested online.

The algorithm is based on the fact, that the order in which two items can be may be reversed mostly twice: once when the first item is moved and once when the second is. Thus, in at least 3 out of the five cases the original order is preserved.

```<code>n/          # Split the input into lines
{~]}%       # and evaluate each line.
:^          # We now have an array of arrays
            # which we save to variable ^
0=          # Take the first item of this list
.,{{        # We now sort this list of items using bubble-sort
            # The following lines calculate the comparator
    {       #   For each line in the input
      .3$?  #     Determine position of first item
      \2$?  #     Determine position of second item
      >     #     Is first before/after second?
    }^%     #   End for each
    $2=     #   Take the middle element of the list.
            #   (i.e. was first item most of the time
            #   positioned after the second)
    {\}*    #   Swap if it was the case.
}*]}*       # End of bubble-sort loops
" "*        # Format output
</code>```

Title: Determine the original sequence

Body:
GolfScript, 44 characters

n/{~]}%:^0=.,{{{.3$?\2$?>}^%$2={\}*}*]}*" "*

The solution can be tested online.

The algorithm is based on the fact, that the order in which two items can be may be reversed mostly twice: once when the first item is moved and once when the second is. Thus, in at least 3 out of the five cases the original order is preserved.

n/          # Split the input into lines
{~]}%       # and evaluate each line.
:^          # We now have an array of arrays
            # which we save to variable ^
0=          # Take the first item of this list
.,{{        # We now sort this list of items using bubble-sort
            # The following lines calculate the comparator
    {       #   For each line in the input
      .3$?  #     Determine position of first item
      \2$?  #     Determine position of second item
      >     #     Is first before/after second?
    }^%     #   End for each
    $2=     #   Take the middle element of the list.
            #   (i.e. was first item most of the time
            #   positioned after the second)
    {\}*    #   Swap if it was the case.
}*]}*       # End of bubble-sort loops
" "*        # Format output


问:
Jolly Jumper Sequence
A sequence of n > 0 integers is called a jolly jumper if the absolute values of the difference between successive elements take on all the values 1 through n-1.

So the sequence [4,1,2,4] has absolute differences [3,1,2] which is equivalent to the set [1,2,3] (1 to n-1 where n is the length of original sequence) so it is therefore a jolly jumper.

Sequences have length n>0.

Assume n=1 is a jolly jumper.

Easy mode: Don't worry about stdin/stdout. Just a function that accepts arguments however and returns something that indicates jolly or not

Hard mode: Input on stdin (space separated), and output is "Jolly" / "Not jolly". Capitalization matters.

This is code golf.

EDIT: Sequences can contain negative integers and input on stdin is space separated.

```<code>$ jolly 2 -1 0 2
Jolly

$ jolly 19 22 24 25
Jolly

$ jolly 19 22 24 21
Not jolly
</code>```

答:
C, 119(hard), 97(easy)

```<code>b,c,a[];main(k){while(~scanf("%d",a+c))k=c++;for(c=k;b<c*c;)k-abs(a[b%c]-a[b++%c+1])?:k--;puts(k?"Not jolly":"Jolly");}
</code>```

The easy solution reads the input from the arguments and returns a 0 as exit code if the input is a jolly jumper sequence:

```<code>i,k;main(int c,char**a){for(k=c-=2,a++;i<c*c;)k-abs(atoi(a[i%c])-atoi(a[i++%c+1]))?:k--;exit(k);}
</code>```

ContentLicense: CC BY-SA 3.0

Title: Jolly Jumper Sequence

Body:
C, 119(hard), 97(easy)

b,c,a[];main(k){while(~scanf("%d",a+c))k=c++;for(c=k;b<c*c;)k-abs(a[b%c]-a[b++%c+1])?:k--;puts(k?"Not jolly":"Jolly");}

The easy solution reads the input from the arguments and returns a 0 as exit code if the input is a jolly jumper sequence:

i,k;main(int c,char**a){for(k=c-=2,a++;i<c*c;)k-abs(atoi(a[i%c])-atoi(a[i++%c+1]))?:k--;exit(k);}


问:
Program that outputs a program that outputs a program ... that outputs "Hello!"

Challenge

Write the shortest program P such that

P takes any positive integer n as input, and outputs a program string P1

executing P1 (with no input) outputs a program string P2,

executing P2 (with no input) outputs a program string P3,

...

executing Pn (with no input) outputs exactly "Hello!" (without the quotes).

Schematically:

                P(n) → P1 → P2 → ... → Pn → Hello!

Criteria

I/O is via stdin/stdout.

Program length is measured in bytes.

Programs consist only of ASCII printable characters.

There must be no duplicates among the programs P, P1,...,Pn.

EDIT: Programs P, P1,...,Pn are meant to be source code, and "executing the program" refers to whatever processing produces the output (i.e., interpretation, compilation & execution, etc.).

答:
Common Lisp, 68 characters

```<code>(do((n(read)(1- n))(s'(princ"Hello!")`(print',s)))((= 0 n)(eval s)))
</code>```

```<code>(do ((n (read) (1- n))
     (s '(princ "Hello!") `(print ',s)))
    ((= 0 n) (eval s)))
</code>```

The only non-straightforward thing: it generates one more level of program than needed and evaluates it, because eval is one character shorter than print.

Body:
Common Lisp, 68 characters

(do((n(read)(1- n))(s'(princ"Hello!")`(print',s)))((= 0 n)(eval s)))

(do ((n (read) (1- n))
     (s '(princ "Hello!") `(print ',s)))
    ((= 0 n) (eval s)))

The only non-straightforward thing: it generates one more level of program than needed and evaluates it, because eval is one character shorter than print.


答:
APL (<s>50</s> <s>49</s> 47, hard)

```<code>'Not jolly' 'Jolly'[1+K[⍋K←¯1↓|Z-1⌽Z]≡¯1↓⍳⍴Z←⎕]
</code>```

Easy (24):

```<code>{K[⍋K←¯1↓|⍵-1⌽⍵]≡¯1↓⍳⍴⍵}
</code>```

The function takes an array and returns 0 or 1.

Title: Jolly Jumper Sequence

Body:
A sequence of n > 0 integers is called a jolly jumper if the absolute values of the difference between successive elements take on all the values 1 through n-1.

So the sequence [4,1,2,4] has absolute differences [3,1,2] which is equivalent to the set [1,2,3] (1 to n-1 where n is the length of original sequence) so it is therefore a jolly jumper.

Sequences have length n>0.

Assume n=1 is a jolly jumper.

Easy mode: Don't worry about stdin/stdout. Just a function that accepts arguments however and returns something that indicates jolly or not

Hard mode: Input on stdin (space separated), and output is "Jolly" / "Not jolly". Capitalization matters.

This is code golf.

EDIT: Sequences can contain negative integers and input on stdin is space separated.

```<code>$ jolly 2 -1 0 2
Jolly

$ jolly 19 22 24 25
Jolly

$ jolly 19 22 24 21
Not jolly
</code>```

Body:
APL (<s>50</s> <s>49</s> 47, hard)

'Not jolly' 'Jolly'[1+K[⍋K←¯1↓|Z-1⌽Z]≡¯1↓⍳⍴Z←⎕]

Easy (24):

{K[⍋K←¯1↓|⍵-1⌽⍵]≡¯1↓⍳⍴⍵}

The function takes an array and returns 0 or 1.


问:
Tips for golfing in Postscript?
As one of the less popular languages, it's difficult to find literature on the avant garde of postscript hackery. So what discoveries have the golfers here made to exploit the stack model (or other features) to overcome Postscript's inherent verbosity?</p>

答:
Replace hexstrings with ASCII85

Probably old news, but I just learned it. :)

You can do it using the postscript interpreter interactively with an encoding filter and cut-and-paste. But I'm going to show how to use dc to do it "by hand".

So, here's a hex string. We split it into 4-byte chunks.

```<code>95 20 6e d8   d0 59 49 35   50 74 ba c5   08 2d
</code>```

Firing up dc, we input these as 32-bit (unsigned) big-endian-byte-order numbers. Then mod-off base-85 digits (there should be 5 until you get to 0).

```0> dc
16i
95206ED8
Ai
d85%n85/
82
d85%n85/
83
d85%n85/
82
d85%n85/
78
d85%n85/
47
d85%n85/
0
```

Padding the last chunk with 00 00, yields (decimal), omitting the same number of bytes that we padded.

```<code>47 78 82 83 82   66 81 72 79 83   25 72 82 25 69  2 53 30 [2 53]
</code>```

Add 33 to shift into the printable range of ASCII and poof! ASCII85.

  80 111 115 116 115 99 114 105 112 116 58 105 115 58 102 35 86 63

 which decodes to:
  Postscript:is:f#V?

  %%%Oops! should say 'fun'! I screwed up somewhere. :)

Wrap it in <~ ... ~>, and Level-2 Postscript can access 8-bit data, cheaper than hex.

Title: Tips for golfing in Postscript?

Body:
Replace hexstrings with ASCII85

Probably old news, but I just learned it. :)

You can do it using the postscript interpreter interactively with an encoding filter and cut-and-paste. But I'm going to show how to use dc to do it "by hand".

So, here's a hex string. We split it into 4-byte chunks.

95 20 6e d8   d0 59 49 35   50 74 ba c5   08 2d

Firing up dc, we input these as 32-bit (unsigned) big-endian-byte-order numbers. Then mod-off base-85 digits (there should be 5 until you get to 0).

0> dc
16i
95206ED8
Ai
d85%n85/
82
d85%n85/
83
d85%n85/
82
d85%n85/
78
d85%n85/
47
d85%n85/
0

Padding the last chunk with 00 00, yields (decimal), omitting the same number of bytes that we padded.

47 78 82 83 82   66 81 72 79 83   25 72 82 25 69  2 53 30 [2 53]

Add 33 to shift into the printable range of ASCII and poof! ASCII85.

  80 111 115 116 115 99 114 105 112 116 58 105 115 58 102 35 86 63

 which decodes to:
  Postscript:is:f#V?

  %%%Oops! should say 'fun'! I screwed up somewhere. :)

Wrap it in <~ ... ~>, and Level-2 Postscript can access 8-bit data, cheaper than hex.


问:
Comparing powers.
Compare two numbers N1 = abc, N2 = def by constructing a function f(a,b,c,d,e,f) that:

returns 1 if N1 > N2

returns -1 if N1 < N2

Note: You are not required to return any value for any other relation between N1 and N2. e.g. when they are equal or when their relation is undefined (complex numbers).

other constrains:

all numbers are integers

a,b,c,d,e,f may be positive or negative but not zero.

|a|,|d| < 1000

|b|,|c|,|e|,|f| < 1010

running time less than few seconds

Examples:

```<code>f(100,100,100,50,100,100) = 1
f(-100,100,100,50,100,100) = 1
f(-100,99,100,50,100,100) = -1
f(100,-100,-100, -1, 3, 100) = 1
f(535, 10^9, 10^8, 443, 10^9, 10^9) = -1
</code>```

This is code golf. Shortest code wins.

答:
Python (99)

```<code>from math import*
from numpy import*
l=log
def f(a,b,c,d,e,f):return sign(l(a)*l(b)*c-l(d)*l(e)*f)
</code>```

ContentLicense: CC BY-SA 2.5

Title: Comparing powers.

Body:
Python (99)

from math import*
from numpy import*
l=log
def f(a,b,c,d,e,f):return sign(l(a)*l(b)*c-l(d)*l(e)*f)


问:
Compress data with context free grammars
It is possible to compress some kinds of data, such as human text or source code, with straight-line grammars. You basically create a grammar whose language has exactly one word – the uncompressed data. In this task, you have to write a program that implements this method of data compession.

Input

The input is a string of not more than 65535 bytes length. It is guaranteed, that the input matches the regular expression [!-~]+ (i.e. at least one printable ASCII character excluding whitespace).

An example input is

abcabcbcbcabcacacabcabab

Output

The output is a set of rules that form a grammar that describes exactly one word (the input). Each nonterminal is denoted by a decimal number greater than 9. The start symbol is symbol number ten. An example output corresponding to the example input is given below; its syntax is described further below:

```<code>10=11 11 12 12 11 13 13 11 14 14
11=a 12
12=b c
13=a c
14=a b
</code>```

Each rule has the form <nonterminal>=<symbol> <symbol> ... with an arbitrary whitespace-separated number of symbols on the right side. Each output that obeys the following restrictions and derives exactly the input string is valid.

Restrictions

In order to stop people from doing strange things, a number of restrictions are taking place:

Each nonterminal must appear at least twice on the right side of a rule. For instance, the following grammar for the input abcabc is illegal because rule 12 appears only once:

```<code>  10=12
  11=a b c
  12=11 11
</code>```

No sequence of two adjacent symbols may appear more than once in all right-hand sides of all rules, except if they overlap. For instance, the following grammar for the input abcabcbc is illegal since the sequence bc appears twice:

```<code>  10=11 11 b c
  11=a b c
</code>```

A valid grammar would be:

```<code>  10=11 11 12
  11=a 12
  12=b c
</code>```

Your program must terminate in less than one minute for each valid input that is not longer than 65535 bytes.

As usual, you may not use any facility of your language or any library function that makes the solution trivial or implements a large part of it.

Sample input

Generate sample input with the following C program.

```<code>#include <stdlib.h>
#include <stdio.h>

int main(int argc, char **argv) {
  unsigned int i,j = 0,k;

  if (argc != 3
     || 2 != sscanf(argv[1],"%u",&i)
      + sscanf(argv[2],"%u",&k)) {
    fprintf(stderr,"Usage: %s seed length\n",argv[0]);
    return EXIT_FAILURE;
  }

  srand(i);

  while(j < k) {
    i = rand() & 0x7f;
    if (i > 34 && i != 127) j++, putchar(i);
  }

  return EXIT_SUCCESS;
}
</code>```

The sample input generated by the program above will usually not result in good compression results. Consider using human text or source code as example input.

Winning criteria

This is code golf; the program with the shortest source code wins. For extra credit, write a program that reconstructs the input from the output.

答:
GolfScript, 111 108 characters

```<code>1/{.}{:^1<{^1$/,2>.{;,)^<.0?)!}*}do-1<.,1>{^1$/[10):10]*0+\+}{;^}if(\}while][0]%.,,]zip{))9+`"="+\~" "*+}%n*
</code>```

This is a quite clumsy approach using GolfScript. The second version performs much better than the initial one. It is much longer than the intended code but my implementation had nested do-loops and this caused issues with the interpreter.

Examples:

```<code>> abcba
10=a b c b a

> abcabcbc
10=11 11 12
11=a 12
12=b c

> abcabcbcbcabcacacabcabab
10=11 12 12 13 14 14 c 11 15
11=15 13
12=c b
13=14 b
14=c a
15=a b
</code>```

ContentLicense: CC BY-SA 4.0

Body:
GolfScript, 111 108 characters

1/{.}{:^1<{^1$/,2>.{;,)^<.0?)!}*}do-1<.,1>{^1$/[10):10]*0+\+}{;^}if(\}while][0]%.,,]zip{))9+`"="+\~" "*+}%n*

This is a quite clumsy approach using GolfScript. The second version performs much better than the initial one. It is much longer than the intended code but my implementation had nested do-loops and this caused issues with the interpreter.

Examples:

> abcba
10=a b c b a

> abcabcbc
10=11 11 12
11=a 12
12=b c

> abcabcbcbcabcacacabcabab
10=11 12 12 13 14 14 c 11 15
11=15 13
12=c b
13=14 b
14=c a
15=a b


问:
Recreate an xkcd graph procedurally with your favorite plotting tool
Lately there have been quite a number of questions regarding the recreation of xkcd-style graphs like the following one (1064) in various languages.

Your goal is to recreate any existing xkcd comic as close to the original as possible. The comic has to have at least one simple graph or pie chart or similar element.

The highest voted answer wins, not sooner than 10 days after the first valid answer.

Your entry must contain code that displays an xkcd-comic as described above in a graphing language, making at least some use of its plotting tool (Mathematica, MatLab, etc.)

the comic must not be stored as an image, it has to be generated procedulally

there must not be any link whatsoever to the original website, or a mirror of it, or its contents on your hard drive, etc.

Votes should evaluate the similarity of the results to the original, and to a lesser extent, the beauty of the solution. No code golf here, but a solution as short and simple as possible is expected.

答:
Here's a stab.

Postscript

[Count deleted because this isn't a golf question.]

Added a "style" section to make it look more hand-drawn.

Edit: Helvetica responds better than Courier. Tweaked and enhanced this "style" section. And added comments.

```<code>%!

%futz with a coordinate pair
/f { 2 { rand 100 mod 100 div 1.47 mul
        dup .4 mul sub add
        exch } repeat } def

/op 2 array def %original point
/cp 2 array def %current point
/setcp { 2 copy cp astore pop } def %set current point
/difcp { cp aload pop %x' y' x y   %diff between cp and point on stack
    3 2 roll exch sub %x' x y'-y
    3 1 roll sub %y'-y x'-x
    exch %dx dy
} def
/scale2 { /n exch def  %scale two values
    n mul exch n mul exch
} def
/add2 {
    3 2 roll add
    3 1 roll add exch
} def
%futz with a path
/fpath {
    2 {
    %flattenpath
    % replace lines with curves
    [ { setcp cp op copy pop /moveto cvx }
        {
            %cp aload pop 4 2 roll 2 copy
            2 copy difcp %x3 y3 x30 y30
            2 copy 1 4 div scale2 %x3 y3 x30 y30 (1/3)x30 (1/3)y30
            cp aload pop add2 %x3 y3 x30 y30 x1 y1
            4 2 roll 3 4 div scale2 %x3 y3 x1 y1 (2/3)x30 (2/3)y30
            cp aload pop add2 %x3 y3 x1 y1 x2 y3
            6 4 roll %x1 y1 x2 y2 x3 y3
            setcp
            /curveto cvx }
        { setcp /curveto cvx }
        { op cp copy pop /closepath cvx } pathforall ] cvx newpath exec
    % chop the curves
    flattenpath
    % futz all the points
    [ { f
        /moveto cvx }
        { f
            /lineto cvx }
        { %f
            f 6 2 roll
            f 6 2 roll
            f 6 2 roll
            2 copy
            /curveto cvx
            3 1 roll
            3{f}repeat /lineto cvx % extra triple-futz'd line after each curve
        }
        { /closepath cvx } pathforall ] cvx newpath exec
    } repeat
} def

%futz with strokes
/oldstroke /stroke load def
/stroke { fpath oldstroke } def

%futz with fills
/oldfill /fill load def
/fill { fpath oldfill } def

%make sure rectstroke doesn't bypass being futzed with
/rectstroke {
    4 2 roll moveto
    1 index 0 rlineto
    0 exch rlineto
    neg 0 rlineto
    closepath
    stroke
} def

%futz with strings
%by making sure show uses our futz'd fill
/show { gsave currentpoint newpath moveto dup
    false charpath 1{fpath}repeat fill grestore stringwidth rmoveto } def

%fatter lines
1 setlinejoin %round joins
currentlinewidth 1.9 mul setlinewidth
%chop curves very small so there's lots of points for futzing
currentflat 6 div setflat

/Helvetica 10 selectfont

<<
/in{72 mul}
>>begin
1 in 1 in translate

0 0 6 in 4 in rectstroke
1 in 3 in moveto (WALKING BACK TO MY) show
1 in 2.8 in moveto (FRONT DOOR AT NIGHT:) show

36 3.5 in moveto
0 -2.8 in rlineto
5 in 0 rlineto
3.45 in .55 in moveto
0 20 rlineto
4.05 in .55 in moveto
0 20 rlineto
2.7 in .40 in moveto
(YARD  STEPS DOOR  INSIDE ) show
0 .05 in rmoveto
.4 in 0 rlineto
currentpoint
stroke
moveto
-10 3 rlineto
0 -6 rlineto fill

2.6 in .45 in moveto
-2 in 0 rlineto
currentpoint
stroke
moveto
10 3 rlineto
0 -6 rlineto fill

(FEAR) .9 in 2.3 in moveto show
(THAT THERE'S) .9 in 2.1 in moveto show
(SOMETHING) .9 in 1.9 in moveto show
(BEHIND ME) .9 in 1.7 in moveto show
1.8 in 1.86 in moveto
2 -26 rlineto
stroke

(FORWARD) 2.2 in 2.1 in moveto show
(SPEED) 2.2 in 1.9 in moveto show
2.75 in 2 in moveto
3 -13 rlineto
stroke

(EMBARRASSMENT) 4.5 in 2.5 in moveto show
4.6 in 2.65 in moveto
-2 20
-5 22
-27 25 rcurveto
stroke

.6 setgray %gray
40 1.6 in moveto
2.7 in 0
2.9 in 20
3.2 in 1.5 in rcurveto
10 20
20 20
30 0 rcurveto
15 -1.7 in
30 -1.8 in
1.4 in -2 in rcurveto
stroke

0 0 1 setrgbcolor %blue
40 1.2 in moveto
.9 in 27
.8 in 20
1.4 in 21 rcurveto
1 in -20
1.2 in 6
1.3 in 1.6 in rcurveto
    10 20
    20 20
    30 0 rcurveto
15 -1.8 in
30 -1.9 in
1.8 in -2.1 in rcurveto
stroke

1 0 0 setrgbcolor %red
40 .9 in moveto
3.3 in 0
3.5 in 20
3.6 in 1.5 in rcurveto
10 72
20 80
30 80 rcurveto
.7 in -10
.3 in -35
1.1 in -40 rcurveto
stroke

%thank you for scrolling all the way down to here. :)
</code>```

Body:
Here's a stab.

Postscript

[Count deleted because this isn't a golf question.]

Added a "style" section to make it look more hand-drawn.

Edit: Helvetica responds better than Courier. Tweaked and enhanced this "style" section. And added comments.

%!

%futz with a coordinate pair
/f { 2 { rand 100 mod 100 div 1.47 mul
        dup .4 mul sub add
        exch } repeat } def

/op 2 array def %original point
/cp 2 array def %current point
/setcp { 2 copy cp astore pop } def %set current point
/difcp { cp aload pop %x' y' x y   %diff between cp and point on stack
    3 2 roll exch sub %x' x y'-y
    3 1 roll sub %y'-y x'-x
    exch %dx dy
} def
/scale2 { /n exch def  %scale two values
    n mul exch n mul exch
} def
/add2 {
    3 2 roll add
    3 1 roll add exch
} def
%futz with a path
/fpath {
    2 {
    %flattenpath
    % replace lines with curves
    [ { setcp cp op copy pop /moveto cvx }
        {
            %cp aload pop 4 2 roll 2 copy
            2 copy difcp %x3 y3 x30 y30
            2 copy 1 4 div scale2 %x3 y3 x30 y30 (1/3)x30 (1/3)y30
            cp aload pop add2 %x3 y3 x30 y30 x1 y1
            4 2 roll 3 4 div scale2 %x3 y3 x1 y1 (2/3)x30 (2/3)y30
            cp aload pop add2 %x3 y3 x1 y1 x2 y3
            6 4 roll %x1 y1 x2 y2 x3 y3
            setcp
            /curveto cvx }
        { setcp /curveto cvx }
        { op cp copy pop /closepath cvx } pathforall ] cvx newpath exec
    % chop the curves
    flattenpath
    % futz all the points
    [ { f
        /moveto cvx }
        { f
            /lineto cvx }
        { %f
            f 6 2 roll
            f 6 2 roll
            f 6 2 roll
            2 copy
            /curveto cvx
            3 1 roll
            3{f}repeat /lineto cvx % extra triple-futz'd line after each curve
        }
        { /closepath cvx } pathforall ] cvx newpath exec
    } repeat
} def

%futz with strokes
/oldstroke /stroke load def
/stroke { fpath oldstroke } def

%futz with fills
/oldfill /fill load def
/fill { fpath oldfill } def

%make sure rectstroke doesn't bypass being futzed with
/rectstroke {
    4 2 roll moveto
    1 index 0 rlineto
    0 exch rlineto
    neg 0 rlineto
    closepath
    stroke
} def

%futz with strings
%by making sure show uses our futz'd fill
/show { gsave currentpoint newpath moveto dup
    false charpath 1{fpath}repeat fill grestore stringwidth rmoveto } def

%fatter lines
1 setlinejoin %round joins
currentlinewidth 1.9 mul setlinewidth
%chop curves very small so there's lots of points for futzing
currentflat 6 div setflat

/Helvetica 10 selectfont

<<
/in{72 mul}
>>begin
1 in 1 in translate

0 0 6 in 4 in rectstroke
1 in 3 in moveto (WALKING BACK TO MY) show
1 in 2.8 in moveto (FRONT DOOR AT NIGHT:) show

36 3.5 in moveto
0 -2.8 in rlineto
5 in 0 rlineto
3.45 in .55 in moveto
0 20 rlineto
4.05 in .55 in moveto
0 20 rlineto
2.7 in .40 in moveto
(YARD  STEPS DOOR  INSIDE ) show
0 .05 in rmoveto
.4 in 0 rlineto
currentpoint
stroke
moveto
-10 3 rlineto
0 -6 rlineto fill

2.6 in .45 in moveto
-2 in 0 rlineto
currentpoint
stroke
moveto
10 3 rlineto
0 -6 rlineto fill

(FEAR) .9 in 2.3 in moveto show
(THAT THERE'S) .9 in 2.1 in moveto show
(SOMETHING) .9 in 1.9 in moveto show
(BEHIND ME) .9 in 1.7 in moveto show
1.8 in 1.86 in moveto
2 -26 rlineto
stroke

(FORWARD) 2.2 in 2.1 in moveto show
(SPEED) 2.2 in 1.9 in moveto show
2.75 in 2 in moveto
3 -13 rlineto
stroke

(EMBARRASSMENT) 4.5 in 2.5 in moveto show
4.6 in 2.65 in moveto
-2 20
-5 22
-27 25 rcurveto
stroke

.6 setgray %gray
40 1.6 in moveto
2.7 in 0
2.9 in 20
3.2 in 1.5 in rcurveto
10 20
20 20
30 0 rcurveto
15 -1.7 in
30 -1.8 in
1.4 in -2 in rcurveto
stroke

0 0 1 setrgbcolor %blue
40 1.2 in moveto
.9 in 27
.8 in 20
1.4 in 21 rcurveto
1 in -20
1.2 in 6
1.3 in 1.6 in rcurveto
    10 20
    20 20
    30 0 rcurveto
15 -1.8 in
30 -1.9 in
1.8 in -2.1 in rcurveto
stroke

1 0 0 setrgbcolor %red
40 .9 in moveto
3.3 in 0
3.5 in 20
3.6 in 1.5 in rcurveto
10 72
20 80
30 80 rcurveto
.7 in -10
.3 in -35
1.1 in -40 rcurveto
stroke

%thank you for scrolling all the way down to here. :)


问:
Turing Machine Simulator
Write a Turing machine simulator.

For simplicity we can assume statuses as integer, symbols as char, blank symbol equals whitespace

5-tuple in the form of current state, input symbol, next state, output symbol, direction (left or right) the order is not mandatory but specify if you swap it

The machine must stop when an unknown state is reached, no other halt condition allowed.

The tape is infinite in both directions and you can always read an empty character.

Input: the initial tape, an initial state and a program. you are free to read the data from anywhere in the format you like

Output: the tape after the execution of the program

Required: an example program that run on top of your simulator

This is a code-colf so the shortest code win.

I'll post an implementation and some example programs in the next few hours.

答:
GolfScript, 92 characters

```<code>~:m;n\+{:^.n?)>1<]m{2<1$=},.{~2>~^n/~1>[@\+]n*1$%n/~\1$1<+[\1>.!{;" "}*]n*\%@}{;;^0}if}do n-
</code>```

The Turing machine in GolfScript became much longer than intended. Still playing around with different representations of the tape.

First line of the input is the original state, second line the initial tape, followed by an array of transitions (with order current state, input symbol, next state, direction, output symbol).

Example (also available online)

```<code>> 0
> '101'
> [[0 '0' 0 1 '0']
>  [0 '1' 0 1 '1']
>  [0 ' ' 1 -1 ' ']
>  [1 '0' 2 1 '1']
>  [1 '1' 3 -1 '0']
>  [3 '0' 2 1 '1']
>  [3 ' ' 2 1 '1']
>  [3 '1' 3 -1 '0']]

110
</code>```

Title: Turing Machine Simulator

Body:
GolfScript, 92 characters

~:m;n\+{:^.n?)>1<]m{2<1$=},.{~2>~^n/~1>[@\+]n*1$%n/~\1$1<+[\1>.!{;" "}*]n*\%@}{;;^0}if}do n-

The Turing machine in GolfScript became much longer than intended. Still playing around with different representations of the tape.

First line of the input is the original state, second line the initial tape, followed by an array of transitions (with order current state, input symbol, next state, direction, output symbol).

Example (also available online)

> 0
> '101'
> [[0 '0' 0 1 '0']
>  [0 '1' 0 1 '1']
>  [0 ' ' 1 -1 ' ']
>  [1 '0' 2 1 '1']
>  [1 '1' 3 -1 '0']
>  [3 '0' 2 1 '1']
>  [3 ' ' 2 1 '1']
>  [3 '1' 3 -1 '0']]

110


问:
Calculate ISBN-13 check digit
Write a function which, given the first 12 digits of an ISBN-13 code, will calculate the entire ISBN via calculating and appending an appropriate check digit.

Your function's input is a string containing the first 12 digits of the ISBN. Its output is a string containing all 13 digits.

Formal specification

Write a function which, when given a string s consisting entirely of exactly 12 decimal digits (and no other characters), returns a string t with the following properties:

t consists of exactly 13 decimal digits (and no other characters);

s is a prefix of t;

the sum of all digits in odd positions in t (i.e. the first, third, fifth, etc.), plus three times the sum of all digits in even positions in t (i.e. the second, fourth, sixth, etc), is a multiple of 10.

Example / test case

Input

978030640615

Output

9780306406157

Victory condition

As a code-golf challenge, the shortest answer wins.

答:
Clojure 264 -> 241 characters:

```<code>(defn s [a b] (let [c (count a)] (if (= 0 c) b (s (rest a) (+ b (* (if (= 0 (m c 2)) 1 3) (first a)))))))
(defn m [a b] (let [f (mod a b)] (if (= f 10) 0 f)))
(defn c [a] (str a (m (- 10 (m (s (map #(read-string %) (map str a)) 0) 10)) 10)))
</code>```

Usage

```<code>(c "978030640615")
</code>```

Non minified:

```<code>(defn sum [collection total]
  (let [len (count collection)]
    (if (= 0 len)
         total
         (sum (rest collection)
           (+ total
            (* (if (= 0 (mod len 2)) 1 3)
             (first collection)))))))

(defn mods [a b]
  (let [f (mod a b)]
    (if (= f 10)
      0
      f)))

(defn create [isbn]
  (str isbn
       (mods (- 10 (mods (sum (map #(read-string %) (map str isbn)) 0) 10)) 10)))
</code>```

Usage:

```<code>(create "978030640615")
</code>```

New to Clojure so I have to believe that can be knocked down.

Title: Calculate ISBN-13 check digit

Body:
Clojure 264 -> 241 characters:

(defn s [a b] (let [c (count a)] (if (= 0 c) b (s (rest a) (+ b (* (if (= 0 (m c 2)) 1 3) (first a)))))))
(defn m [a b] (let [f (mod a b)] (if (= f 10) 0 f)))
(defn c [a] (str a (m (- 10 (m (s (map #(read-string %) (map str a)) 0) 10)) 10)))

Usage

(c "978030640615")

Non minified:

(defn sum [collection total]
  (let [len (count collection)]
    (if (= 0 len)
         total
         (sum (rest collection)
           (+ total
            (* (if (= 0 (mod len 2)) 1 3)
             (first collection)))))))

(defn mods [a b]
  (let [f (mod a b)]
    (if (= f 10)
      0
      f)))

(defn create [isbn]
  (str isbn
       (mods (- 10 (mods (sum (map #(read-string %) (map str isbn)) 0) 10)) 10)))

Usage:

(create "978030640615")

New to Clojure so I have to believe that can be knocked down.


问:
Ode-cay Olf-gay
Write a program which accepts a sentence into stdin, and writes that sentence to stdout in pig latin.

Here are some test cases which your program should handle:

```<code>Input:
    Read your script
Output:
    ead-Ray our-yay ipt-scray
</code>```

Hyphenation is mandatory. Note that multiple consonants at the start of the word must all be moved to the end. Capitalization of the output does not matter; Ead-ray or ead-ray are also valid translations of Read

```<code>Input:
    An utterance is allowed an opening vowel
Output:
    An-way utterance-way is-way allowed-way an-way opening-way owel-vay
</code>```

Words starting with vowels have -way appended in their pig latin form (don't forget to handle capital opening vowels)

```<code>Input:
    sky
    -skyay
</code>```

Words consisting entirely of consonants should have a hyphen prepended, and ay appended

Punctuation is undefined; I don't care if leading or trailing punctuation ends up inside the pig latin word.

This is code golf; the shortest program by character count wins. I've written a solution myself which handles all these cases which I shall post as a response.

答:
Cojure - 376 characters

Obviously not winning this one, but figured I'd take a shot at it.

Minified:

```<code>(defn n [a b] (reduce #(and % %2) (map #(= (.indexOf a %) -1) (map string/lower-case (rest b)))))
(defn t [a] (let [vowels ["a" "e" "i" "o" "u"] x "ay"] (if (> (.indexOf vowels (string/lower-case (first a))) -1) (str a "-way") (if (n vowels a) (str a x) (str (reduce str (rest a)) "-" (first a) x)))))
(defn ay-ya [a] (reduce str (map #(str (t %) " ") (string/split a #" "))))
</code>```

Actual:

```<code>(defn no-vowel [a b]
    (reduce #(and % %2) (map #(= (.indexOf a %) -1) (map string/lower-case (rest b)))))

(defn transform [text]
  (let [vowels ["a" "e" "i" "o" "u"]]
    (if (> (.indexOf vowels (string/lower-case (first text))) -1)
        (str text "-way")
        (if (no-vowel vowels text)
          (str text "ay")
          (str (reduce str (rest text)) "-" (first text) "ay")))))

(defn ay-ya [text]
    (reduce str
        (map #(str (transform %) " ")
             (clojure.string/split text #" "))))
</code>```

Title: Ode-cay Olf-gay

Body:
Cojure - 376 characters

Obviously not winning this one, but figured I'd take a shot at it.

Minified:

(defn n [a b] (reduce #(and % %2) (map #(= (.indexOf a %) -1) (map string/lower-case (rest b)))))
(defn t [a] (let [vowels ["a" "e" "i" "o" "u"] x "ay"] (if (> (.indexOf vowels (string/lower-case (first a))) -1) (str a "-way") (if (n vowels a) (str a x) (str (reduce str (rest a)) "-" (first a) x)))))
(defn ay-ya [a] (reduce str (map #(str (t %) " ") (string/split a #" "))))

Actual:

(defn no-vowel [a b]
    (reduce #(and % %2) (map #(= (.indexOf a %) -1) (map string/lower-case (rest b)))))

(defn transform [text]
  (let [vowels ["a" "e" "i" "o" "u"]]
    (if (> (.indexOf vowels (string/lower-case (first text))) -1)
        (str text "-way")
        (if (no-vowel vowels text)
          (str text "ay")
          (str (reduce str (rest text)) "-" (first text) "ay")))))

(defn ay-ya [text]
    (reduce str
        (map #(str (transform %) " ")
             (clojure.string/split text #" "))))


问:
Sum of positive integers.

Problem:

Given a set of integers, find the sum of all positive integers in it.

Input:

t – number of test cases [t < 1000]

On each of next t lines, an integer N [-1000 ≤ N ≤ 1000]

Output

The program should output the sum of all the positive integers.

Check your code in online judge

Score

Score is equal to size of source code of your program except symbols with ASCII code ≤ 32.

Here is the best score list: Python Best Scores (Best score is 29)

答:
excel, 27

```<code>=SUM(INDIRECT("A2:A"&1+A1))
</code>```

count t in A1, rest of data a2 and down

Title: Sum of positive integers.

Body:
excel, 27

=SUM(INDIRECT("A2:A"&1+A1))

count t in A1, rest of data a2 and down


问:
Print the amount of ones in a binary number without using bitwise operators

Description

Given a number, print the amount of 1s it has in binary representation.

Input

A number >= 0 in base 10 that won't exceed the highest number your language is able to handle.

Output

The amount of 1s in binary representation.

Winning condition

The shortest code wins.

Disallowed

Bitwise operators. Other operators, like addition and multiplication, are allowed.

Built-in base conversion functions.

Examples

```<code>Input:     Ouput:

56432      8

Input:     Output:

45781254   11

Input:     Output:

0          0
</code>```

答:
excel, 35

```<code>=LEN(A1)-LEN(SUBSTITUTE(A1,"1",""))
</code>```

Body:
excel, 35

=LEN(A1)-LEN(SUBSTITUTE(A1,"1",""))


问:
Implement glob Matcher
Implement a function of pattern and string to be matched, return true if the pattern matches the WHOLE string, otherwise false.

Our glob pattern syntax is:

? matches any one character

+ matches one or more characters

* matches zero or more characters

\ escapes

Rules:

No eval, no converting into regular expression, no calling a system glob function.

I/O are not required: you can just write a function

Shortest wins

Examples:

```<code>glob('abc', 'abc') => true
glob('abc', 'abcdef') => false IMPORTANT!
glob('a??', 'aww') => true
glob('a*b', 'ab') => true
glob('a*b', 'agwijgwbgioeb') => true
glob('a*?', 'a') => false
glob('?*', 'def') => true
glob('5+', '5ggggg') => true
glob('+', '') => false
glob('a\*b', 'a*b') => true
</code>```

Here is a tip to get started: http://en.wikipedia.org/wiki/Backtracking

答:
Overly Verbose Python (384 367 Characters)

```<code>t=lambda a:a[1:]
h=lambda a:a[0]
n=lambda p,s:s and(h(p)==h(s)and m(t(p),t(s)))
def m(p,s):
 if not p:
  return not s
 else:
  return {
   '?':lambda p,s:s and m(t(p),t(s)),
   '+':lambda p,s:s and(m(p,t(s))or m(t(p),t(s))),
   '*':lambda p,s:m(t(p),s)or(s and m(p,t(s))),
   '\\':lambda p,s:n(t(p),s),
  }.get(h(p),n)(p,s)
glob=lambda p,s:not not m(p,s)
</code>```

It's not the shortest, but it's nice and functional. The dispatch dict thing in the middle could presumably be rewritten as a disjunction over (h(p) == '?') and (? lambda body) type things. Defining that h operator costs me some characters for no benefit, but its nice to have a keyword for head.

I'd like to have a crack at golfscripting it later if time permits.

edit: removed unnecessary third branch in '*' case after reading user300's ruby answer

Title: Implement glob Matcher

Body:
Overly Verbose Python (384 367 Characters)

t=lambda a:a[1:]
h=lambda a:a[0]
n=lambda p,s:s and(h(p)==h(s)and m(t(p),t(s)))
def m(p,s):
 if not p:
  return not s
 else:
  return {
   '?':lambda p,s:s and m(t(p),t(s)),
   '+':lambda p,s:s and(m(p,t(s))or m(t(p),t(s))),
   '*':lambda p,s:m(t(p),s)or(s and m(p,t(s))),
   '\\':lambda p,s:n(t(p),s),
  }.get(h(p),n)(p,s)
glob=lambda p,s:not not m(p,s)

It's not the shortest, but it's nice and functional. The dispatch dict thing in the middle could presumably be rewritten as a disjunction over (h(p) == '?') and (? lambda body) type things. Defining that h operator costs me some characters for no benefit, but its nice to have a keyword for head.

I'd like to have a crack at golfscripting it later if time permits.

edit: removed unnecessary third branch in '*' case after reading user300's ruby answer


问:
Hello World in 1024 characters
In exactly 1024 characters, no more, no less:

Must print Hello World.

Must not use unnecessary whitespace.

Must not use comments.

Judging should favor creativity and/or humor over simple obfuscation when voting up answers.

The earliest I will select an answer is the 11th (Sunday) of November (2012). I'm seeing some awesome entries so far, can't wait to see what else people come up with.

Title: Hello World in 1024 characters

Body:
brainfuck

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

This is 1024 characters, excluding the whitespace I added to make a nice 64*16 block.

The strategy is as follows:

Fill the first few bytes with characters "Hello World", except each byte is 5 too small.  This is done in all but the last 16 characters.  The first byte is left blank in order to not have the pointer go out of bounds later.

Bring the pointer back to the start, adding 5 to each byte using [+++++<]

Go through the characters, print them and zero the byte using >[.[-]>]


答:
dc – 26 chars

This is rather long, mostly due to the lack of loop constructs in dc.

```<code>0?[d2%rsi+li2/d0<x]dsxx+p
</code>```

Keeps adding up the modulo 2 of the number and dividing the number by to until it reaches zero. Can handle arbitrarily long integers.

Example:

```<code>$ dc -e '0?[d2%rsi+li2/d0<x]dsxx+p' <<< 127
7
$ dc countones.dc <<< 1273434547453452352342346734573465732856238472384263456458235374653784538469120235
138
</code>```

Title: Print the amount of ones in a binary number without using bitwise operators

Body:
Description

Given a number, print the amount of 1s it has in binary representation.

Input

A number >= 0 in base 10 that won't exceed the highest number your language is able to handle.

Output

The amount of 1s in binary representation.

Winning condition

The shortest code wins.

Disallowed

Bitwise operators. Other operators, like addition and multiplication, are allowed.

Built-in base conversion functions.

Examples

```<code>Input:     Ouput:

56432      8

Input:     Output:

45781254   11

Input:     Output:

0          0
</code>```

Body:
dc – 26 chars

This is rather long, mostly due to the lack of loop constructs in dc.

0?[d2%rsi+li2/d0<x]dsxx+p

Keeps adding up the modulo 2 of the number and dividing the number by to until it reaches zero. Can handle arbitrarily long integers.

Example:

$ dc -e '0?[d2%rsi+li2/d0<x]dsxx+p' <<< 127
7
$ dc countones.dc <<< 1273434547453452352342346734573465732856238472384263456458235374653784538469120235
138


问:
Move platforms!

The Challenge

Given either a string (may have newlines), or a two dimensional array, and a positive integer n, output the position of the platforms n turns after the
initial position.

U, D, R, L are platforms.

^, v, >, < are arrows that change the directions of the platforms.

U, D, R, L move up, down, right and left, respectively. When an arrow is in front of a platform, it changes the direction.

Affects platform:

```<code>R<
</code>```

```<code>D
^
</code>```

```<code>v
U
</code>```

```<code>>L
</code>```

```<code>>L
 <
</code>```

(top arrow will affect top L, but bottom arrow won't affect top L)

Won't affect:

```<code> <
R
</code>```

```<code>>
 L
</code>```

```<code>v
 U
</code>```

```<code>D
 ^
</code>```

```<code><R
</code>```

(R is going right, so < won't affect the R)

For example, if this was the string:

```<code>D
^
</code>```0

The platform R would move right until it's nearly touching the arrow:

```<code>D
^
</code>```1

After, it would change the direction and start going left:

```<code>D
^
</code>```2

(even though now it's going left, the letter won't change.)

There are some cases when the platform won't move, such as

```<code>>R<
</code>```

or

```<code>v
U
^
</code>```

Last example:

```<code>v   >
D    Rv
   ^U
^    <
</code>```

After one turn,

```<code>v   >
    U v
D  ^ R
^    <
</code>```

After one turn,

```<code>v   >
D    Uv
   ^R
^    <
</code>```

And one more turn:

```<code>v   >
    R v
D  ^ U
^    <
</code>```

You can assume that the platforms, after n turns, won't overlap, that the platforms won't go out of bounds, and that a platform won't touch an arrow that's pointing to the same direction as the platform.

Test Cases

```<code>Input:
">R   <", 4
Output:
">  R <"

Input:
">R   <", 6
Output:
">R   <"

Input:
">R<", 29
Output:
">R<"

Input:
"v
 U
 ^", 5
Output:
"v
 U
 ^"

Input:
"v

 D
 ^", 1
Output:
"v
 D

 ^"

Input:
"v

 D
 ^", 4
Output:
"v

 D
 ^"

Input:
"v   >
 D    Rv
    ^U
 ^    < ", 2
Output:
"v   >
 D    Uv
    ^R
 ^    <

Input:
">RL<", 3
Output:
">LR<"

Input:
">L  R<", 4
Output:
"> RL <"

Input:
"> RR<
 >L  R <", 6
Ouput:
">RR <
 > RL  <"

Input:
"R   <", 4
Output:
"  R <"

Input:
"R   <", 6
Ouput:
"R   <"
</code>```

Rules

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

Standard loopholes are disallowed.

答:
C#, 1245 bytes

```<code>(i,n)=>{string q="RlherLHEfquDFQUd",D="><v^",H="Rlhe",E="LrHE",X="Dufq",Y="UdFQ",S="#v<>";Func<string,char,int>I=(v,L)=>v.IndexOf(L);Func<char,int,char>z=(y,m)=>q[I(q,y)+m*4];Func<string,char,bool>_=(s,F)=>s.Contains(F);var g=((i as char[][])??((string)i).Split('\n').Select(f=>f.ToCharArray())).ToList();int w=g[0].Length,h=g.Count,u;g=g.Select((r,o)=>r.Select((t,p)=>'R'==t&&w>p+1&&0<=(u=I(D,r[p+1]))?z(t,u):'L'==t&&0<=p-1&&0<=(u=I(D,r[p-1]))?z(t,-1+u):'D'==t&&h>o+1&&0<=(u=I(D,g[o+1][p]))?z(t,-2+u):'U'==t&&0<=o-1&&0<=(u=I(S,g[o-1][p]))?z(t,-u):t).ToArray()).ToList();for(var j=0;j<n;j++){bool L,R,T,B;g=g.Select((r,o)=>r.Select((t,p)=>_(D,t)?t:(R=0<=p-1)&&_(H,r[p-1])?w>p+1&&0<=(u=I(D,r[p+1]))?z(r[p-1],u):r[p-1]:(L=w>p+1)&&_(E,r[p+1])?0<=p-1&&0<=(u=I(D,r[p-1]))?z(r[p+1],-1+u):r[p+1]:(B=0<=o-1)&&_(X,g[o-1][p])?h>o+1&&0<=(u=I(D,g[o+1][p]))?z(g[o-1][p],-2+u):g[o-1][p]:(T=h>o+1)&&_(Y,g[o+1][p])?0<=o-1&&0<=(u=I(S,g[o-1][p]))?z(g[o+1][p],-u):g[o+1][p]:(L&&_(H,t)&&!_(D,r[p+1]))||(R&&_(E,t)&&!_(D,r[p-1]))||(B&&_(Y,t)&&!_(D,g[o-1][p]))||(T&&_(X,t)&&!_(D,g[o+1][p]))?' ':t).ToArray()).ToList();}return string.Join("\n",g.Select(s=>new string(s))).ToUpper().Replace("H","U").Replace("E","D").Replace("F","R").Replace("Q","L").Replace("V","v");};
</code>```

It seemed simpler at first, but then I just kept writing more code. :D

LINQ to enumerate and update the board, changing the character to indicate the direction it's moving. The characters are reverted back before returning. Also assumes that the board is square (so had to modify some of the multi-line test cases to fit this restriction).

Expanded:

```<code>// Casts to Func<object, int, string> so as to accept both string and char[][] input
(i, n) =>{
    // Shorten constants/functions
    string q = "RlherLHEfquDFQUd", D = "><v^", H = "Rlhe", E = "LrHE", X = "Dufq", Y = "UdFQ",S="#v<>";
    Func<string, char, int> I = (v, L) => v.IndexOf(L);
    Func<char, int, char> z = (y, m) => q[I(q,y) + m * 4]; // Updates the direction of the platform
    Func<string, char, bool> _ = (s, F) => s.Contains(F);

    // Convert either string or char[][] input into common format
    var g = ((i as char[][]) ?? ((string)i).Split('\n').Select(f => f.ToCharArray())).ToList();

    // Get board dimensions
    int w = g[0].Length,h = g.Count,u;

    // Update platforms to reflect the direction they're initially moving
    g = g.Select((r, o) => r.Select((t, p) =>
        'R' == t &&w>p+1&&0<=(u=I(D,r[p+1]))?z(t,u):
        'L' == t &&0<=p-1&&0<=(u= I(D, r[p-1]))?z(t,-1+u):
        'D' == t &&h>o+1&&0<=(u= I(D, g[o+1][p]))?z(t,-2+u):
        'U' == t &&0<=o-1&&0<=(u= I(S,g[o-1][p]))?z(t,-u):t
    ).ToArray()).ToList();

    // Go through each timestep
    for (var j=0;j<n;j++)
    {
        bool L,R,T,B;
        g = g.Select((r, o) => r.Select((t, p) =>
            // Don't change <>^v characters
            _(D,t) ? t :

            // Move platforms going right
            (R=0 <= p - 1) && _(H,r[p-1]) ? w > p+1 && 0<=(u= I(D, r[p+1])) ? z(r[p-1],u) : r[p - 1] :

            // Move platforms going left
            (L=w > p + 1) && _(E,r[p+1]) ? 0 <= p-1 && 0<=(u= I(D, r[p-1])) ? z(r[p+1],-1+u) : r[p + 1] :

            // Move platforms going down
            (B=0 <= o - 1) && _(X,g[o-1][p]) ? h > o+1 && 0<=(u= I(D, g[o+1][p])) ? z(g[o - 1][p],-2+u) : g[o-1][p] :

            // Move platforms going up
            (T=h > o + 1) && _(Y,g[o+1][p]) ? 0<=o-1&&0<=(u= I(S, g[o-1][p]))?z(g[o + 1][p],-u) :g[o+1][p]:

            // Erase platforms that moved
            (L&&_(H,t)&&!_(D,r[p+1]))||
            (R&&_(E,t)&&!_(D,r[p-1]))||
            (B&&_(Y,t)&&!_(D,g[o-1][p]))||
            (T&&_(X,t)&&!_(D,g[o+1][p]))
            ? ' ':

            // Maintain whatever character this was
            t
            ).ToArray()).ToList();
    }

    // Replace direction characters with platform label and join into string return value.
    return string.Join("\n",g.Select(s=>new string(s))).ToUpper().Replace("H", "U").Replace("E", "D").Replace("F", "R").Replace("Q", "L").Replace("V", "v");
};
</code>```

Title: Move platforms!

Body:
C#, 1245 bytes

(i,n)=>{string q="RlherLHEfquDFQUd",D="><v^",H="Rlhe",E="LrHE",X="Dufq",Y="UdFQ",S="#v<>";Func<string,char,int>I=(v,L)=>v.IndexOf(L);Func<char,int,char>z=(y,m)=>q[I(q,y)+m*4];Func<string,char,bool>_=(s,F)=>s.Contains(F);var g=((i as char[][])??((string)i).Split('\n').Select(f=>f.ToCharArray())).ToList();int w=g[0].Length,h=g.Count,u;g=g.Select((r,o)=>r.Select((t,p)=>'R'==t&&w>p+1&&0<=(u=I(D,r[p+1]))?z(t,u):'L'==t&&0<=p-1&&0<=(u=I(D,r[p-1]))?z(t,-1+u):'D'==t&&h>o+1&&0<=(u=I(D,g[o+1][p]))?z(t,-2+u):'U'==t&&0<=o-1&&0<=(u=I(S,g[o-1][p]))?z(t,-u):t).ToArray()).ToList();for(var j=0;j<n;j++){bool L,R,T,B;g=g.Select((r,o)=>r.Select((t,p)=>_(D,t)?t:(R=0<=p-1)&&_(H,r[p-1])?w>p+1&&0<=(u=I(D,r[p+1]))?z(r[p-1],u):r[p-1]:(L=w>p+1)&&_(E,r[p+1])?0<=p-1&&0<=(u=I(D,r[p-1]))?z(r[p+1],-1+u):r[p+1]:(B=0<=o-1)&&_(X,g[o-1][p])?h>o+1&&0<=(u=I(D,g[o+1][p]))?z(g[o-1][p],-2+u):g[o-1][p]:(T=h>o+1)&&_(Y,g[o+1][p])?0<=o-1&&0<=(u=I(S,g[o-1][p]))?z(g[o+1][p],-u):g[o+1][p]:(L&&_(H,t)&&!_(D,r[p+1]))||(R&&_(E,t)&&!_(D,r[p-1]))||(B&&_(Y,t)&&!_(D,g[o-1][p]))||(T&&_(X,t)&&!_(D,g[o+1][p]))?' ':t).ToArray()).ToList();}return string.Join("\n",g.Select(s=>new string(s))).ToUpper().Replace("H","U").Replace("E","D").Replace("F","R").Replace("Q","L").Replace("V","v");};

It seemed simpler at first, but then I just kept writing more code. :D

LINQ to enumerate and update the board, changing the character to indicate the direction it's moving. The characters are reverted back before returning. Also assumes that the board is square (so had to modify some of the multi-line test cases to fit this restriction).

Expanded:

// Casts to Func<object, int, string> so as to accept both string and char[][] input
(i, n) =>{
    // Shorten constants/functions
    string q = "RlherLHEfquDFQUd", D = "><v^", H = "Rlhe", E = "LrHE", X = "Dufq", Y = "UdFQ",S="#v<>";
    Func<string, char, int> I = (v, L) => v.IndexOf(L);
    Func<char, int, char> z = (y, m) => q[I(q,y) + m * 4]; // Updates the direction of the platform
    Func<string, char, bool> _ = (s, F) => s.Contains(F);

    // Convert either string or char[][] input into common format
    var g = ((i as char[][]) ?? ((string)i).Split('\n').Select(f => f.ToCharArray())).ToList();

    // Get board dimensions
    int w = g[0].Length,h = g.Count,u;

    // Update platforms to reflect the direction they're initially moving
    g = g.Select((r, o) => r.Select((t, p) =>
        'R' == t &&w>p+1&&0<=(u=I(D,r[p+1]))?z(t,u):
        'L' == t &&0<=p-1&&0<=(u= I(D, r[p-1]))?z(t,-1+u):
        'D' == t &&h>o+1&&0<=(u= I(D, g[o+1][p]))?z(t,-2+u):
        'U' == t &&0<=o-1&&0<=(u= I(S,g[o-1][p]))?z(t,-u):t
    ).ToArray()).ToList();

    // Go through each timestep
    for (var j=0;j<n;j++)
    {
        bool L,R,T,B;
        g = g.Select((r, o) => r.Select((t, p) =>
            // Don't change <>^v characters
            _(D,t) ? t :

            // Move platforms going right
            (R=0 <= p - 1) && _(H,r[p-1]) ? w > p+1 && 0<=(u= I(D, r[p+1])) ? z(r[p-1],u) : r[p - 1] :

            // Move platforms going left
            (L=w > p + 1) && _(E,r[p+1]) ? 0 <= p-1 && 0<=(u= I(D, r[p-1])) ? z(r[p+1],-1+u) : r[p + 1] :

            // Move platforms going down
            (B=0 <= o - 1) && _(X,g[o-1][p]) ? h > o+1 && 0<=(u= I(D, g[o+1][p])) ? z(g[o - 1][p],-2+u) : g[o-1][p] :

            // Move platforms going up
            (T=h > o + 1) && _(Y,g[o+1][p]) ? 0<=o-1&&0<=(u= I(S, g[o-1][p]))?z(g[o + 1][p],-u) :g[o+1][p]:

            // Erase platforms that moved
            (L&&_(H,t)&&!_(D,r[p+1]))||
            (R&&_(E,t)&&!_(D,r[p-1]))||
            (B&&_(Y,t)&&!_(D,g[o-1][p]))||
            (T&&_(X,t)&&!_(D,g[o+1][p]))
            ? ' ':

            // Maintain whatever character this was
            t
            ).ToArray()).ToList();
    }

    // Replace direction characters with platform label and join into string return value.
    return string.Join("\n",g.Select(s=>new string(s))).ToUpper().Replace("H", "U").Replace("E", "D").Replace("F", "R").Replace("Q", "L").Replace("V", "v");
};


问:
Unsorted majorization of two lists

Definition

A vector a containing n elements is said to
majorize or
dominate a vector b with n
elements iff for all values k such that 1 ≤ k ≤ n, the sum of the first
element of a↓ through the kth element of a↓ is
greater than or equal to the sum of the first through kth elements of
b↓, where v↓ represents the vector v sorted in
descending order.

That is,

```<code>                          a_1 >= b_1
                    a_1 + a_2 >= b_1 + b_2
              a_1 + a_2 + a_3 >= b_1 + b_2 + b_3
                              ...
      a_1 + a_2 + ... + a_n-1 >= b_1 + b_2 + ... + b_n-1
a_1 + a_2 + ... + a_n-1 + a_n >= b_1 + b_2 + ... + b_n-1 + b_n
</code>```

where a and b are sorted in descending order.

For the purpose of this challenge, we will be using a slight generalization of
majorization: we will say a list is an unsorted majorization of another if
all of the above inequalities are true without sorting a and b. (This is,
of course, mathematically useless, but makes the challenge more interesting.)

Challenge

Given an input of two distinct lists a and b of integers in the range 0
through 255 (inclusive), both lists of length n ≥ 1, output whether the first
list unsorted-majorizes the second (a > b), the second unsorted-majorizes
the first (b > a), or neither.

You may optionally require the length of the two lists to be provided as input.
The output must always be one of three distinct values, but the values
themselves may be whatever you want (please specify which values represent a
> b, b > a, and neither in your answer).

Test cases for a > b:

```<code>[255] [254]
[3,2,1] [3,1,2]
[6,1,5,2,7] [2,5,4,3,7]
</code>```

Test cases for b > a:

```<code>[9,1] [10,0]
[6,5,4] [7,6,5]
[0,1,1,2,1,2] [0,1,2,1,2,1]
</code>```

Test cases for no majorization:

```<code>[200,100] [150,250]
[3,1,4] [2,3,3]
[9,9,9,9,9,0] [8,8,8,8,8,9]
</code>```

答:
Javascript (using external library-Enumerable) (123 bytes)

```<code>(a,b)=>(z=(c,d)=>_.Range(1,c.length).All(x=>_.From(c).Take(x).Sum()>=_.From(d).Take(x).Sum()))(a,b)==z(b,a)?0:(z(a,b)?1:-1)
</code>```

Link to lib: https://github.com/mvegh1/Enumerable

Code explanation: Pass in vector a and b, create global function z. z will begin by creating an array of integers from 1, for a count of a.length. .All will verify that the predicate is true for every member belonging to a. That predicate says to load a as an enumerable, take a count of that enumerable equivalent to the current iteration value of that range we made, and sum that up. Check if that >= the same logic from array "b". So, we call z in the order of (a,b), and compare that to the order of (b,a)...if equal we return 0 to signify there is no major. Otherwise, we return 1 if (a,b) is true, else -1

Title: Unsorted majorization of two lists

Body:
Javascript (using external library-Enumerable) (123 bytes)

(a,b)=>(z=(c,d)=>_.Range(1,c.length).All(x=>_.From(c).Take(x).Sum()>=_.From(d).Take(x).Sum()))(a,b)==z(b,a)?0:(z(a,b)?1:-1)

Link to lib: https://github.com/mvegh1/Enumerable

Code explanation: Pass in vector a and b, create global function z. z will begin by creating an array of integers from 1, for a count of a.length. .All will verify that the predicate is true for every member belonging to a. That predicate says to load a as an enumerable, take a count of that enumerable equivalent to the current iteration value of that range we made, and sum that up. Check if that >= the same logic from array "b". So, we call z in the order of (a,b), and compare that to the order of (b,a)...if equal we return 0 to signify there is no major. Otherwise, we return 1 if (a,b) is true, else -1


答:
Julia, 30 bytes

```<code>a^b=sum(sign(cumsum(a-b))∪0)
</code>```

Saved 4 bytes thanks to @Dennis!

Title: Unsorted majorization of two lists

Body:
Definition

A vector a containing n elements is said to
majorize or
dominate a vector b with n
elements iff for all values k such that 1 ≤ k ≤ n, the sum of the first
element of a↓ through the kth element of a↓ is
greater than or equal to the sum of the first through kth elements of
b↓, where v↓ represents the vector v sorted in
descending order.

That is,

```<code>                          a_1 >= b_1
                    a_1 + a_2 >= b_1 + b_2
              a_1 + a_2 + a_3 >= b_1 + b_2 + b_3
                              ...
      a_1 + a_2 + ... + a_n-1 >= b_1 + b_2 + ... + b_n-1
a_1 + a_2 + ... + a_n-1 + a_n >= b_1 + b_2 + ... + b_n-1 + b_n
</code>```

where a and b are sorted in descending order.

For the purpose of this challenge, we will be using a slight generalization of
majorization: we will say a list is an unsorted majorization of another if
all of the above inequalities are true without sorting a and b. (This is,
of course, mathematically useless, but makes the challenge more interesting.)

Challenge

Given an input of two distinct lists a and b of integers in the range 0
through 255 (inclusive), both lists of length n ≥ 1, output whether the first
list unsorted-majorizes the second (a > b), the second unsorted-majorizes
the first (b > a), or neither.

You may optionally require the length of the two lists to be provided as input.
The output must always be one of three distinct values, but the values
themselves may be whatever you want (please specify which values represent a
> b, b > a, and neither in your answer).

Test cases for a > b:

```<code>[255] [254]
[3,2,1] [3,1,2]
[6,1,5,2,7] [2,5,4,3,7]
</code>```

Test cases for b > a:

```<code>[9,1] [10,0]
[6,5,4] [7,6,5]
[0,1,1,2,1,2] [0,1,2,1,2,1]
</code>```

Test cases for no majorization:

```<code>[200,100] [150,250]
[3,1,4] [2,3,3]
[9,9,9,9,9,0] [8,8,8,8,8,9]
</code>```

Body:
Julia, 30 bytes

a^b=sum(sign(cumsum(a-b))∪0)

Saved 4 bytes thanks to @Dennis!


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

```

答:
reticular, 17 bytes

```<code>"Hello, World!"p;
</code>```

This has a trailing newline.

This doesn't:

```<code>"Hello, World!"o;
</code>```

Title: "Hello, World!"

Body:
reticular, 17 bytes

"Hello, World!"p;

This has a trailing newline.

This doesn't:

"Hello, World!"o;


问:
Turtles All the Way Down
Write a program or function that takes in a positive integer and prints or returns a stack of that many ASCII-art turtles, where each turtle is larger than the one above it.

Specifically, if the input is 1, the output should be:

```<code> __
/,,\o
</code>```

If the input is 2:

```<code>  __
o/,,\
 ____
/,__,\o
</code>```

If the input is 3:

```<code>   __
  /,,\o
  ____
o/,__,\
 ______
/,____,\o
</code>```

If the input is 4:

```<code>    __
  o/,,\
   ____
  /,__,\o
  ______
o/,____,\
 ________
/,______,\o
</code>```

If the input is 5:

```<code>     __
    /,,\o
    ____
  o/,__,\
   ______
  /,____,\o
  ________
o/,______,\
 __________
/,________,\o
</code>```

And so on in the same pattern for larger inputs.

Note that:

The head (the o) of the bottom turtle is always on the right. The heads of the turtles above then alternate back and forth.

No lines may have trailing spaces.

Superfluous leading spaces are not allowed. (i.e. the back of the bottom turtle should be at the start of the line.)

A single optional trailing newline is allowed.

The shortest code in bytes wins.

答:
V, <s>57, 53</s> 49 bytes

```<code>i ³_
/,_,\oÀñHyjí_/___
ëPhjI ñdjí___
òkk$x^PXkk
</code>```

Since this contains unprintable characters, here is a hexdump:

```<code>00000000: 6920 b35f 0a2f 2c5f 2c5c 6f1b c0f1 4879  i ._./,_,\o...Hy
00000010: 6aed 5f2f 5f5f 5f0a eb50 1668 6a49 20f1  j._/___..P.hjI .
00000020: 646a ed5f 5f5f 0af2 6b6b 2478 5e50 586b  dj.___..kk$x^PXk
00000030: 6b                                       k
</code>```

Try it online!

Explanation:

```<code>i ³_\n/,_,\o<esc>       "Insert the original turtle with one extra underscore

Àñ                      "Arg1 times:
  Hyj                   "  Go the the beginning of the file, and yank a turtle
     í_/___             "  Extend the lenght of every turtle by two
ëP                      "  Move to the beginning of the file again, and paste the turtle we yanked
  <C-v>hjI              "  Move this turtle one to the right
           ñ            "Stop looping.

dj                      "Delete a turtle (since we have one too many)
  í___                  "Make every turtle shorter (since they are all too long)

ò                       "Recursively:
 kk                     "  Move up two lines
   $x                   "  Delete the last character on this line (an 'o')
     ^P                 "  And paste this 'o' at the beginning of the line
       X                "  Remove one space
        kk              "  Move up two lines again
</code>```

Title: Turtles All the Way Down

Body:
V, <s>57, 53</s> 49 bytes

i ³_
/,_,\oÀñHyjí_/___
ëPhjI ñdjí___
òkk$x^PXkk

Since this contains unprintable characters, here is a hexdump:

00000000: 6920 b35f 0a2f 2c5f 2c5c 6f1b c0f1 4879  i ._./,_,\o...Hy
00000010: 6aed 5f2f 5f5f 5f0a eb50 1668 6a49 20f1  j._/___..P.hjI .
00000020: 646a ed5f 5f5f 0af2 6b6b 2478 5e50 586b  dj.___..kk$x^PXk
00000030: 6b                                       k

Try it online!

Explanation:

i ³_\n/,_,\o<esc>       "Insert the original turtle with one extra underscore

Àñ                      "Arg1 times:
  Hyj                   "  Go the the beginning of the file, and yank a turtle
     í_/___             "  Extend the lenght of every turtle by two
ëP                      "  Move to the beginning of the file again, and paste the turtle we yanked
  <C-v>hjI              "  Move this turtle one to the right
           ñ            "Stop looping.

dj                      "Delete a turtle (since we have one too many)
  í___                  "Make every turtle shorter (since they are all too long)

ò                       "Recursively:
 kk                     "  Move up two lines
   $x                   "  Delete the last character on this line (an 'o')
     ^P                 "  And paste this 'o' at the beginning of the line
       X                "  Remove one space
        kk              "  Move up two lines again


答:
Ruby, <s>72</s> 59 bytes

Returns 1 for a>b, -1 for a<b, 0 for neither.

-13 bytes from cribbing the sum trick off of @Dennis in their Python answer

Try it online!

```<code>->a,b{x=y=0;a.zip(b).map{|i,j|(x+=i)<=>y+=j}.uniq.inject:+}
</code>```

Title: Unsorted majorization of two lists

Body:
Ruby, <s>72</s> 59 bytes

Returns 1 for a>b, -1 for a<b, 0 for neither.

-13 bytes from cribbing the sum trick off of @Dennis in their Python answer

Try it online!

->a,b{x=y=0;a.zip(b).map{|i,j|(x+=i)<=>y+=j}.uniq.inject:+}


问:
Smallest sum (and largest difference) of two 3-digit integers
Given six unique non-negative integers, print the two 3-digit integers comprised of those numbers that sum to the smallest amount.

Additionally,

If there is more than one set of numbers that meets the smallest-sum requirement, print the two that have the greatest difference. For example, 269 + 157 = 267 + 159 = 426; however, 269 - 157 > 267 - 159, so the first set should be printed.

Print the numbers on the same line largest -> smallest, separated by a single space.

Zero (0) cannot be used as a leading number.

Inputs will always be digits.

Testcases

```<code>input        | output
2 6 5 1 9 7  | 269 157
1 9 5 0 8 3  | 359 108
1 2 3 4 5 6  | 246 135
</code>```

Scoring

As this is code golf, shortest entry wins.

Body:
Ruby, 113 bytes

Try it online!

->a{(a.permutation(6).map{|c|c[0]*c[3]>0?[eval(c[0,3]*''),eval(c[3,3]*'')]:p}-[p]).min_by{|x,y|[x+y,-(x-y).abs]}}


答:
Python 2, 73 bytes

a,=b,=r={0}
for x,y in zip(*input()):a+=x;b+=y;r|={cmp(a,b)}
print sum(r)
```

Test it on Ideone.

Title: Unsorted majorization of two lists

Body:
Python 2, 73 bytes

a,=b,=r={0}
for x,y in zip(*input()):a+=x;b+=y;r|={cmp(a,b)}
print sum(r)

Test it on Ideone.


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

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

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

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

Points for:

Smallest code (in bytes)

Most obfuscated/obscure solution

Using esoteric/obscure languages

Successfully using languages that are difficult to golf in

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

var QUESTION_ID=69;
var OVERRIDE_USER=98;

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

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

Winners by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

 ```

答:
reticular, 9 bytes

```<code>"'34'coo;
</code>```

This captures the string '34'coo;, then wraps around. After that, the number 34 is pushed the stack, converted to a character with c, finally being outputted with o. The next o outputs the captured string, and ; terminates the program.

Other quines:

```<code>"'34'c~O;
"6@P2*c~O;
</code>```

Title: Golf you a quine for great good!

Body:
reticular, 9 bytes

"'34'coo;

This captures the string '34'coo;, then wraps around. After that, the number 34 is pushed the stack, converted to a character with c, finally being outputted with o. The next o outputs the captured string, and ; terminates the program.

Other quines:

"'34'c~O;
"6@P2*c~O;


问:
A newly discovered number: bleen!
"The Nobel Prize in mathematics was awarded to a California professor who has discovered a new number! The number is bleen, which he claims belongs between 6 and 7."  --George Carlin

In this challenge, you will print all Integers, inclusive, within the given input range.  Print numbers ascending or descending according to their input order.  That is, for input [n1, n2], print ascending if n1 < n2, descending if n1 > n2.

Since bleen is now an Integer number it may be used as input.  It must also be included in the output, between 6 and 7 where applicable.  Also note that -bleen exists between -7 and -6.

Input

Two Integers [n1, n2] in the range [-10, 10], inclusive, via your programming language's input of choice.

(Input may also contain bleen and -bleen!)

Output

Print all Integers starting at n1 and ending with n2, including the newly discovered bleen between 6 and 7.  Output can be a range of character separated numbers in some form your language supports - that is, comma or space separated.  One trailing space of output is okay.

Examples

```<code>Input:  1 10
Output: 1 2 3 4 5 6 bleen 7 8 9 10

Input:  -9 -4
Output: -9 -8 -7 -bleen -6 -5 -4

Input:  -8 bleen
Output: -8 -7 -bleen -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 bleen

Input:  9 1
Output: 9 8 7 bleen 6 5 4 3 2 1

Input:  2 -bleen
Output: 2 1 0 -1 -2 -3 -4 -5 -6 -bleen

Input:  -bleen 0
Output: -bleen -6 -5 -4 -3 -2 -1 0

Input:  bleen bleen
Output: bleen

Input:  2 2
Output: 2
</code>```

Additional notes

You may write a program or function and use any standard method of receiving input and providing output.

You may use any programming language, but standard loopholes are not allowed.

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

答:
Java, 271 bytes

```<code>int p(String w){if(w.contains("b"))return w.length()<6?7:-7;int i=Integer.decode(w);return i<-6?i-1:i>6?i+1:i;}void b(String s,String f){Integer l=p(s),r=p(f);for(r+=l<r?1:-1;l!=r;l-=l.compareTo(r))System.out.print(l==-7?"-bleen ":l==7?"bleen ":l+(l<-7?1:l<7?0:-1)+" ");}
</code>```

Ungolfed with test cases:

```<code>class Bleen {
     static int p(String w) {
         if(w.contains("b"))
             return w.length() < 6 ? 7 : -7;
         int i = Integer.decode(w);
         return i < -6 ? i-1 : i>6 ? i+1 : i;
     }

     static void b(String s, String f) {
         Integer l = p(s), r = p(f);
         for(r += l<r ? 1 : -1; l != r; l -= l.compareTo(r))
             System.out.print(l == -7 ? "-bleen " : l == 7 ? "bleen ": l+(l < -7 ? 1 : l<7 ? 0 : -1)+" ");
     }

     public static void main(String[] args) {
         b("1","10"); System.out.println();
         b("-9","-4"); System.out.println();
         b("-8", "bleen"); System.out.println();
         b("9", "1"); System.out.println();
         b("2", "-bleen"); System.out.println();
         b("-bleen", "0"); System.out.println();
         b("bleen", "bleen"); System.out.println();
         b("2", "2"); System.out.println();
     }
}
</code>```

Call b(start, end). Because the parameters are strings, it takes a lot of space to convert those into ints. Essentially the program treats 7 & -7 as bleen and -bleen.

Title: A newly discovered number: bleen!

Body:
Java, 271 bytes

int p(String w){if(w.contains("b"))return w.length()<6?7:-7;int i=Integer.decode(w);return i<-6?i-1:i>6?i+1:i;}void b(String s,String f){Integer l=p(s),r=p(f);for(r+=l<r?1:-1;l!=r;l-=l.compareTo(r))System.out.print(l==-7?"-bleen ":l==7?"bleen ":l+(l<-7?1:l<7?0:-1)+" ");}

Ungolfed with test cases:

class Bleen {
     static int p(String w) {
         if(w.contains("b"))
             return w.length() < 6 ? 7 : -7;
         int i = Integer.decode(w);
         return i < -6 ? i-1 : i>6 ? i+1 : i;
     }

     static void b(String s, String f) {
         Integer l = p(s), r = p(f);
         for(r += l<r ? 1 : -1; l != r; l -= l.compareTo(r))
             System.out.print(l == -7 ? "-bleen " : l == 7 ? "bleen ": l+(l < -7 ? 1 : l<7 ? 0 : -1)+" ");
     }

     public static void main(String[] args) {
         b("1","10"); System.out.println();
         b("-9","-4"); System.out.println();
         b("-8", "bleen"); System.out.println();
         b("9", "1"); System.out.println();
         b("2", "-bleen"); System.out.println();
         b("-bleen", "0"); System.out.println();
         b("bleen", "bleen"); System.out.println();
         b("2", "2"); System.out.println();
     }
}

Call b(start, end). Because the parameters are strings, it takes a lot of space to convert those into ints. Essentially the program treats 7 & -7 as bleen and -bleen.


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

```

答:
Python, 24-25= 0  -1 bytes

```<code>print'a'*int(input())*24
</code>```

It takes input, converts it to an integer, multiplies it by 24 (the length of my code) and multiplies the character a by it

Thanks to @EamonOlive for reducing 1 byte

Body:
Python, 24-25= 0  -1 bytes

print'a'*int(input())*24

It takes input, converts it to an integer, multiplies it by 24 (the length of my code) and multiplies the character a by it

Thanks to @EamonOlive for reducing 1 byte


Title: Turtles All the Way Down

Body:
Write a program or function that takes in a positive integer and prints or returns a stack of that many ASCII-art turtles, where each turtle is larger than the one above it.

Specifically, if the input is 1, the output should be:

```<code> __
/,,\o
</code>```

If the input is 2:

```<code>  __
o/,,\
 ____
/,__,\o
</code>```

If the input is 3:

```<code>   __
  /,,\o
  ____
o/,__,\
 ______
/,____,\o
</code>```

If the input is 4:

```<code>    __
  o/,,\
   ____
  /,__,\o
  ______
o/,____,\
 ________
/,______,\o
</code>```

If the input is 5:

```<code>     __
    /,,\o
    ____
  o/,__,\
   ______
  /,____,\o
  ________
o/,______,\
 __________
/,________,\o
</code>```

And so on in the same pattern for larger inputs.

Note that:

The head (the o) of the bottom turtle is always on the right. The heads of the turtles above then alternate back and forth.

No lines may have trailing spaces.

Superfluous leading spaces are not allowed. (i.e. the back of the bottom turtle should be at the start of the line.)

A single optional trailing newline is allowed.

The shortest code in bytes wins.

Body:
Cheddar, 105 bytes

n->(|>n).map(i->(1-i%2)*"o"+"\\,"+(n-i-1)*"__"+",/"+i%2*"o"+i/2*"  "+"\n"+(n-i)*"__"+(i+1)*" ").vfuse.rev