问:
4-way intersection generator
Here is an ASCII-art of a 4-way intersection:

```<code>     |  |  |
     |     |
     |  |  |
     |     |
     |  |  |
-----+-----+-----
     |     |
- - -|     |- - -
     |     |
-----+-----+-----
     |  |  |
     |     |
     |  |  |
     |     |
     |  |  |
</code>```

(Note how the horizontal roads are 3 rows tall, while the vertical roads are 5 columns wide. This is for aesthetic reasons, because of the rectangular font.)

Your challenge is to produce this ASCII art. However, as I'm sure you all know, not every intersection has a road travelling off in every single direction. This particular intersection goes NESW, but some intersections might go, for example, NW:

```<code>     |  |  |
     |     |
     |  |  |
     |     |
     |  |  |
-----+-----+
     |     |
- - -|     |
     |     |
-----+-----+
</code>```

Or it might go SWE:

```<code>-----+-----+-----
     |     |
- - -|     |- - -
     |     |
-----+-----+-----
     |  |  |
     |     |
     |  |  |
     |     |
     |  |  |
</code>```

Or it may even go E, just a single direction (although you can hardly call this an intersection, but try to avoid being overly pedantic):

```<code>     +-----+-----
     |     |
     |     |- - -
     |     |
     +-----+-----
</code>```

You need to write a program or function that can easily generate any of these combinations. More specifically, your challenge is to write a program or function that takes a string of directions, consisting of NESW, as input, and outputs or returns this ASCII art of an intersection with roads pointing in those directions. These directions may appear in any order, but the input will not contain any characters except for N, E, S, or W. If you like, you may request inputs to be lowercase instead, but you must specify this in your answer. You may also assume that all inputs will contain at least one direction.

The last example had leading spaces on each line, because there is no road going west. If you do not have a road going west, these leading spaces are optional. This:

```<code>+-----+-----
|     |
|     |- - -
|     |
+-----+-----
</code>```

Would also be an acceptable output. Similarly, if N or S is gone, empty lines in there place are optional. One trailing newline is allowed, and trailing spaces are allowed as long as the output is visually the same.

You may take input and output in any reasonable format, such as STDIN/STDOUT, command line args, files, function arguments/return values, etc.

As usual, this is code-golf, so try to get the shortest possible answer in whatever language you happen to use!

Sample IO:

```<code>NESW:

     |  |  |
     |     |
     |  |  |
     |     |
     |  |  |
-----+-----+-----
     |     |
- - -|     |- - -
     |     |
-----+-----+-----
     |  |  |
     |     |
     |  |  |
     |     |
     |  |  |

NS:

|  |  |
|     |
|  |  |
|     |
|  |  |
+-----+
|     |
|     |
|     |
+-----+
|  |  |
|     |
|  |  |
|     |
|  |  |

S:

+-----+
|     |
|     |
|     |
+-----+
|  |  |
|     |
|  |  |
|     |
|  |  |

EW:

-----+-----+-----
     |     |
- - -|     |- - -
     |     |
-----+-----+-----

SE:
+-----+-----
|     |
|     |- - -
|     |
+-----+-----
|  |  |
|     |
|  |  |
|     |
|  |  |
</code>```

Title: 4-way intersection generator

Body:
GolfScript, 154 bytes

{a?1+}:x;'-'5*:e;' '5*:b;"+"e+"+"+:f;{b'|'b'|'b n}:k;{'W'x{e}{b}if\'E'x{e}{}if n}:y;{x{b"|  |  |
"+:c k c k c}{}if}:z;1/:a;'N'z f y k'|'b+'|'+ y k f y'S'z

Try it online!


问:
All Binary Combinations to Decimal
Disclaimer

This question is not a duplicate of this question. I'm not counting specific digits, as we already have those set in the initial parameters. This question is focusing on the decimal numbers that can be constructed from the binary strings based on the digits provided.

Challenge

Given two integers X and Y, representing the number of zeroes (0) and ones (1) respectively, calculate all the possible decimal equivalents that can be determined from creating binary strings using only the zeroes and ones provided, and display them as output.

Example 1:

Input: 0 1

Output: 1

Explanation: Only one 1 to account for, which can only be converted one way.

Example 2:

Input: 1 1

Output: 1,2

Explanation: 01 converts to 1, 10 converts to 2.

Example 3:

Input: 3 2

Output: 3,5,6,9,10,12,17,18,20,24

Explanation: Three 0s and two 1s make 00011 (3), 00101 (5), 00110 (6), 01001 (9), 01010 (10), 01100 (12), 10001 (17), 10010 (18), 10100 (20), 11000 (24)

Limitations and Rules

I will only expect your code to work where 0 < X + Y <= 16 so the maximum number in the output could only occur from 16 1s, i.e. parameters 0 and 16.

As a result of the above limitation, the range of numbers we'd expect in the output are from 0 and 65535.

I will accept functions or code, so long as the resulting output is provided, whether this be a comma separated list, an array, list outputted to STDOUT, etc. The only criteria I must stress about the output is that it must be sorted.

This is code golf, minimum bytes will receive maximum glory.

We will not tolerate silly loopholes

答:
Perl 6, <s> 64 62 </s> 49 bytes

{(0 x$^a~1 x$^b).comb.permutations.map({:2(.join)}).sort.squish}
```

<pre class="lang-perl6 prettyprint-override"><code>{[~](0,1 Zx@_).comb.permutations.map({:2(.join)}).sort.squish}
</code>```

{(^2**($^x+$^y)).grep:{.base(2).comb('1')==$y}}
```

<h2>Explanation:</h2>

<pre class="lang-perl6 prettyprint-override"><code># bare block lambda with two placeholder parameters ｢$^x｣ and ｢$^y｣
{
  # Range of possible values
  # from 0 up to and excluding 2 to the power of $x+$y
  ( ^ 2 ** ( $^x + $^y ) )

  # find only those which
  .grep:

  # bare block lambda with implicit parameter of ｢$_｣
  {

    # convert to base 2
    # ( implicit method call on ｢$_｣ )
    .base(2)

    # get a list of 1s
    .comb('1')

    # is the number of elements the same
    ==

    # as the second argument to the outer block
    $y
  }
}
</code>```

say {(0..2**($^x+$^y)).grep:{.base(2).comb('1')==$y}}(3,2)
# (3 5 6 9 10 12 17 18 20 24)
```

ContentLicense: CC BY-SA 3.0

Title: All Binary Combinations to Decimal

Body:
Perl 6, <s> 64 62 </s> 49 bytes

{(0 x$^a~1 x$^b).comb.permutations.map({:2(.join)}).sort.squish}

{[~](0,1 Zx@_).comb.permutations.map({:2(.join)}).sort.squish}

{(^2**($^x+$^y)).grep:{.base(2).comb('1')==$y}}

Explanation:

# bare block lambda with two placeholder parameters ｢$^x｣ and ｢$^y｣
{
  # Range of possible values
  # from 0 up to and excluding 2 to the power of $x+$y
  ( ^ 2 ** ( $^x + $^y ) )

  # find only those which
  .grep:

  # bare block lambda with implicit parameter of ｢$_｣
  {

    # convert to base 2
    # ( implicit method call on ｢$_｣ )
    .base(2)

    # get a list of 1s
    .comb('1')

    # is the number of elements the same
    ==

    # as the second argument to the outer block
    $y
  }
}

say {(0..2**($^x+$^y)).grep:{.base(2).comb('1')==$y}}(3,2)
# (3 5 6 9 10 12 17 18 20 24)


问:
Cambridge Transposition
I'm sure most, if not all, of you have come across this at some point or another:

Aoccdrnig to a rscheeachr at Cmabrigde Uinervtisy, it deosn't mttaer
in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is
taht the frist and lsat ltteer be at the rghit pclae. The rset can be
a toatl mses and you can sitll raed it wouthit porbelm. Tihs is
bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the
wrod as a wlohe.

Create a program that inputs any amount of text. For testing purposes, use the unscrambled version of the above text, found below.

The program must then randomly transpose the letters of each word with a length of 4 or more letters, except the first and last letter of each word.

All other formatting must remain the same (capitalization and punctuation, etc.).

Testing text:

According to a researcher at Cambridge University, it doesn't matter
in what order the letters in a word are, the only important thing is
that the first and last letter be at the right place. The rest can be
a total mess and you can still read it without problem. This is
because the human mind does not read every letter by itself but the
word as a whole.

As usual, this is a code-golf. Shortest code wins.

答:
Ruby - 50 48 chars, plus -p command line parameter.

```<code>gsub(/(?<=\w)\w+(?=\w)/){[*$&.chars].shuffle*''}
</code>```

Thanks @primo for -2 char.

Test

```<code>➜  codegolf git:(master) ruby -p 9261-cambridge-transposition.rb < 9261.in
Acdrcinog to a racreseher at Cagribmde Ursvetniiy, it dsoen't mttaer in waht odrer the leertts in a word are, the olny ionarpmtt tnhig is that the fsirt and last letetr be at the rghit pcale. The rset can be a taotl mses and you can slitl raed it wthiuot perlbom. Tihs is buaecse the hmuan mind does not raed ervey lteetr by ietlsf but the word as a wlhoe.
</code>```

ContentLicense: CC BY-SA 4.0

Title: Cambridge Transposition

Body:
Ruby - 50 48 chars, plus -p command line parameter.

gsub(/(?<=\w)\w+(?=\w)/){[*$&.chars].shuffle*''}

Thanks @primo for -2 char.

Test

➜  codegolf git:(master) ruby -p 9261-cambridge-transposition.rb < 9261.in
Acdrcinog to a racreseher at Cagribmde Ursvetniiy, it dsoen't mttaer in waht odrer the leertts in a word are, the olny ionarpmtt tnhig is that the fsirt and last letetr be at the rghit pcale. The rset can be a taotl mses and you can slitl raed it wthiuot perlbom. Tihs is buaecse the hmuan mind does not raed ervey lteetr by ietlsf but the word as a wlhoe.


Title: 4-way intersection generator

Body:
Here is an ASCII-art of a 4-way intersection:

```<code>     |  |  |
     |     |
     |  |  |
     |     |
     |  |  |
-----+-----+-----
     |     |
- - -|     |- - -
     |     |
-----+-----+-----
     |  |  |
     |     |
     |  |  |
     |     |
     |  |  |
</code>```

(Note how the horizontal roads are 3 rows tall, while the vertical roads are 5 columns wide. This is for aesthetic reasons, because of the rectangular font.)

Your challenge is to produce this ASCII art. However, as I'm sure you all know, not every intersection has a road travelling off in every single direction. This particular intersection goes NESW, but some intersections might go, for example, NW:

```<code>     |  |  |
     |     |
     |  |  |
     |     |
     |  |  |
-----+-----+
     |     |
- - -|     |
     |     |
-----+-----+
</code>```

Or it might go SWE:

```<code>-----+-----+-----
     |     |
- - -|     |- - -
     |     |
-----+-----+-----
     |  |  |
     |     |
     |  |  |
     |     |
     |  |  |
</code>```

Or it may even go E, just a single direction (although you can hardly call this an intersection, but try to avoid being overly pedantic):

```<code>     +-----+-----
     |     |
     |     |- - -
     |     |
     +-----+-----
</code>```

You need to write a program or function that can easily generate any of these combinations. More specifically, your challenge is to write a program or function that takes a string of directions, consisting of NESW, as input, and outputs or returns this ASCII art of an intersection with roads pointing in those directions. These directions may appear in any order, but the input will not contain any characters except for N, E, S, or W. If you like, you may request inputs to be lowercase instead, but you must specify this in your answer. You may also assume that all inputs will contain at least one direction.

The last example had leading spaces on each line, because there is no road going west. If you do not have a road going west, these leading spaces are optional. This:

```<code>+-----+-----
|     |
|     |- - -
|     |
+-----+-----
</code>```

Would also be an acceptable output. Similarly, if N or S is gone, empty lines in there place are optional. One trailing newline is allowed, and trailing spaces are allowed as long as the output is visually the same.

You may take input and output in any reasonable format, such as STDIN/STDOUT, command line args, files, function arguments/return values, etc.

As usual, this is code-golf, so try to get the shortest possible answer in whatever language you happen to use!

Sample IO:

```<code>NESW:

     |  |  |
     |     |
     |  |  |
     |     |
     |  |  |
-----+-----+-----
     |     |
- - -|     |- - -
     |     |
-----+-----+-----
     |  |  |
     |     |
     |  |  |
     |     |
     |  |  |

NS:

|  |  |
|     |
|  |  |
|     |
|  |  |
+-----+
|     |
|     |
|     |
+-----+
|  |  |
|     |
|  |  |
|     |
|  |  |

S:

+-----+
|     |
|     |
|     |
+-----+
|  |  |
|     |
|  |  |
|     |
|  |  |

EW:

-----+-----+-----
     |     |
- - -|     |- - -
     |     |
-----+-----+-----

SE:
+-----+-----
|     |
|     |- - -
|     |
+-----+-----
|  |  |
|     |
|  |  |
|     |
|  |  |
</code>```

Body:
Python 3, 186 bytes

S=' -- -  -- -  --'
lambda d:'\n'.join(S[r//4:15*('W'in d):3]+'||+  -  -| -  -  -||+'[r%4::3]+S[r//4:15*('E'in d):3]for r in[0,1,0,1,0,6,1,9,1,6,0,1,0,1,0][5-5*('N'in d):10+5*('S'in d)])

An anonymous lambda called with a string of directions, e.g. 'NWS'

Explanation to follow


问:
Print multiplication tables by input
In this challenge you've to print multiplication tables by input, Here are some examples:

```<code>Input: 2

Output:
0 2  4 6 8  10  12  14  16  18  20

Input: 20

Output: 20 40 60 80 100 120 140 160 180 200
</code>```

Rules

The shortest code in bytes wins.

This challenge is a code-golf, It follows code-golf general rules (code-golf)

If, just if, your code can't print number, you can use letters, Here is an example:

Input: B

Output: B D F H J L N P R T

You can choose to start from 0 or your number (like 20). You can choose if put spaces or don't. The challenge is free, just take an input and print multiplication tables.

Your output must list the first 10 members of the times table for the given number. You may leave out 0*n.

答:
Perl 6, 10 bytes

{$_ X*^11}
```
<h2>Explanation:</h2>
<pre class="lang-perl6 prettyprint-override"><code>{
  # the input
  $_

  # crossed using &infix:<*>
  X[*]

  # a Range from 0 to 11 excluding 11
  # ( short for ｢0 ..^ 11｣ )
  ^11
}
</code>```

say {$_ X*^11}(20)
# (0 20 40 60 80 100 120 140 160 180 200)
```

Title: Print multiplication tables by input

Body:
Perl 6, 10 bytes

{$_ X*^11}

Explanation:

{
  # the input
  $_

  # crossed using &infix:<*>
  X[*]

  # a Range from 0 to 11 excluding 11
  # ( short for ｢0 ..^ 11｣ )
  ^11
}

say {$_ X*^11}(20)
# (0 20 40 60 80 100 120 140 160 180 200)


问:
RGB Gradients Generation
The Challenge

Given the two uppercase hexadecimal strings (both 6 characters long, XXXXXX and YYYYYY) representing RGB values (ranging from 000000 to FFFFFF inclusive), and a positive non-zero integer N, display a linear transition of the N+2 colors generated from XXXXXX to YYYYYY that would result in a color gradient.

Example

Input

```<code>FF3762
F08800
9
</code>```

Output

Please note in our example, I've requested 9 interim steps between the two colors, therefore 11 lines will be displayed from initial color to the final color

```<code>FF3762
FD3F58
FC474E
FA4F44
F9573A
F75F31
F66727
F46F1D
F37713
F17F09
F08800
</code>```

Caveats

While I've gone with a simple linear process of deriving the integer values for the interim colors before converting them back into hexadecimal, your methods may vary. Please consider the various ways one could round up/down your numbers accordingly.

Testing

To make this interesting, I've provided a snippet to allow testing of your code, inclusive of a button to provide you with two random colors to test your code against. Displaying your results is optional, but it's encouraged!

c1=()=>('00000'+(Math.random()*(1<<24)|0).toString(16)).slice(-6);

$("#col").click(function(){
  alert("Your two colors are: "+c1()+" and "+c1()+".");
});

$("#colors").blur(function(){
  $("#test").empty();
 var colArr = $("#colors").val().split("\n");
 for(c in colArr){
   $("#test").append('
'+colArr[c]+'
')
  }

});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.tester{height: 20px;
width: 60px;padding: 4px;border: 1px solid black;}</code>```

<button id="col">Your two colors</button>

<textarea id="colors"></textarea>

```

1) You can access two random colors for your test by clicking on the "Your two colors" button.
2) The number of interim steps will be the same as the number of characters in your PPCG username inclusive of spaces, in the case of "WallyWest" it would be 9 (as per my example above).
3) Run your code with the two colors and the number and once you have your generated list, you have the option of pasting your output into the textarea and tabbing away from it to get your generated color gradient.

My example is shown here:

I must admit, that looks pretty awesome!

Please note: As I mentioned, showing your testing of your output using the snippet is optional, but it's encouraged! :)

Output

The list output must be in the form of N+2 sets of 6 digit hex numbers separated by line feeds (\n) as shown in my example above. Output can be in the form of separate lines, space/comma separated list, an array or whatever is best suited for your language... (Thanks @nimi for the heads up) Please remember, that if you plan on testing your code with the snippet, however you separate each "color" is up to you.

Rules

This is code-golf, so the shortest solution in bytes will be crowned the winner. No loopholes, naturally. Input must accept the two strings and a number (which as I said will be equivalent to the number of letters in your username on PPCG, thus your resulting output will always be a minimum of three lines long.

答:
MATL, 31 bytes

```<code>2+1yhjjh2e!1ZA3e!b:1&Ynk8W5Y2Za
</code>```

This uses linear interpolation with rounding down. Input format is

```<code>9
FF3762
F08800
</code>```

Try it online!

Graphical output, 31 bytes

```<code>2+1yhjjh2e!1ZA3e!b:t2YG1&Ynk2ZG
</code>```

This is the result for inputs

```<code>5
FF3762
F08800
</code>```

Try it in MATL Online! The interpreter is currently experimental. If you don't get any output refresh the page and press "Run" again.

Title: RGB Gradients Generation

Body:
MATL, 31 bytes

2+1yhjjh2e!1ZA3e!b:1&Ynk8W5Y2Za

This uses linear interpolation with rounding down. Input format is

9
FF3762
F08800

Try it online!

Graphical output, 31 bytes

2+1yhjjh2e!1ZA3e!b:t2YG1&Ynk2ZG

This is the result for inputs

5
FF3762
F08800

Try it in MATL Online! The interpreter is currently experimental. If you don't get any output refresh the page and press "Run" again.


问:
Highlight the Bounding Box, Part II: Hexagonal Grid
You're given a hexagonal grid of the characters . and #, like this:

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

Your task is to fill the entire axis-aligned bounding box of the # with further #:

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

The axis-aligned bounding box is the smallest convex hexagonal shape which contains all the #. Note that in the case of the hexagonal grid, there are three axes to consider (W/E, SW/NE, NW/SE):

Here is another example to show that in some cases, one or more sides will contain only one #:

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

You can either view these as hexagons with degenerate sides, or you can draw the bounding box around them, like I have done above, in which case they are still hexagons:

Too hard? Try Part I!

Rules

You may use any two distinct non-space printable ASCII characters (0x21 to 0x7E, inclusive), in place of # and .. I'll continue referring to them as # and . for the remainder of the specification though.

Input and output may either be a single linefeed-separated string or a list of strings (one for each line), but the format has to be consistent.

You may assume that the input contains at least one # and all lines are the same length. Note that there are two different "kinds" of lines (starting with a space or a non-space) - you may not assume that the input always starts with the same type. You may assume that the bounding box always fits inside the grid you are given.

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

You may use any programming language, but note that these loopholes are forbidden by default.

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

Test Cases

Each test case has input and output next to each other.

```<code>#    #

 . .      . .
# . #    # # #
 . .      . .

 . #      . #
. . .    . # .
 # .      # .

 # .      # .
. . .    . # .
 . #      . #

 # .      # .
# . .    # # .
 . #      # #

 . #      # #
# . .    # # #
 . #      # #

. . #    . # #
 . .      # #
# . .    # # .

# . .    # # .
 . .      # #
. . #    . # #

. . . . . . . .         . . . . . . . .
 . . # . # . . .         . . # # # . . .
. . . . . . . .         . . . # # . . .
 . . . # . . . .         . . . # . . . .

. . . . . . . .         . . . . . . . .
 . . # . . . # .         . . # # # # # .
. . . . . . . .         . . . # # # # .
 . . . # . . . .         . . . # # # . .

. . . . . . . .         . . . . . . . .
 . # . . . . . .         . # # # # . . .
. . . . . # . .         . . # # # # . .
 . . . . . . . .         . . . . . . . .

. . . . . . . .         . . . . . . . .
 . # . . . . . .         . # # # # . . .
. . . . . # . .         . . # # # # . .
 . . # . . . . .         . . # # # . . .

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

答:
Perl, <s>128</s> 126 bytes

Includes +6 for -0F\n

Run with input on STDIN. Use 1 for filled, 0 for empty.
Lines do not have to be padded with spaces at the end:

```<code>perl -M5.010 hexafill.pl
 0 0 0 0 0 0 0 0
0 0 1 1 1 1 0 0
 0 1 1 1 1 1 0 0
0 0 1 1 1 1 1 0
 0 0 1 1 1 1 0 0
0 0 0 0 0 0 0 0
^D
</code>```

hexafill.pl

```<code>#!/usr/bin/perl -0F\n
$-=map{s%$=%$=^!map{/$/;grep{pos=$`;$=?$_|="!"x$`.1:!/\b.*\G./}${--$@}}@F-$-+pos,$-+pos,$-%eeg;--$-;$=||say}@F while$=--
</code>```

Uses cube coordinates. Determine maximum and minimum during the $= == 1 loop and fills coordinates between these bounds during the $= == 0 loop. The first 58 loops are pointless and are only there to fill $- with the number of lines

Body:
Perl, <s>128</s> 126 bytes

Includes +6 for -0F\n

Run with input on STDIN. Use 1 for filled, 0 for empty.
Lines do not have to be padded with spaces at the end:

perl -M5.010 hexafill.pl
 0 0 0 0 0 0 0 0
0 0 1 1 1 1 0 0
 0 1 1 1 1 1 0 0
0 0 1 1 1 1 1 0
 0 0 1 1 1 1 0 0
0 0 0 0 0 0 0 0
^D

hexafill.pl

#!/usr/bin/perl -0F\n
$-=map{s%$=%$=^!map{/$/;grep{pos=$`;$=?$_|="!"x$`.1:!/\b.*\G./}${--$@}}@F-$-+pos,$-+pos,$-%eeg;--$-;$=||say}@F while$=--

Uses cube coordinates. Determine maximum and minimum during the $= == 1 loop and fills coordinates between these bounds during the $= == 0 loop. The first 58 loops are pointless and are only there to fill $- with the number of lines


问:
Stringsplode the String!
The challenge is relatively simple, but will hopefully lead to some wonderfully creative answers. The task is to take a string as an input (via command line, function parameter etc.) and output/return a stringsploded version of it.

A stringsploded version of a string is its first letter followed by its first 2 letters, followed by its first 3 letters,... until you finally output the complete word.

You are guaranteed that the input will consist of printable ASCII characters and that the input will all be on one line (no new line characters).

Here are examples to clarify what stringsplosions are:

```<code>Input                 Output
==================================================================
"Code"       ---->   "CCoCodCode"
"name"       ---->   "nnanamname"
"harambe"    ---->   "hhaharharaharamharambharambe"
"sp aces?"   ---->   "sspsp sp asp acsp acesp acessp aces?"
"1234"       ---->   "1121231234"
"ss"         ---->   "sss"
</code>```

This is code golf so shortest code wins + up votes for interesting uses of your respective language.

Good luck!

答:
MATL, 8 bytes

```<code>"GX@:)v!
</code>```

This uses a different approach from @Suever's answer.

Try it online!

Explanation

```<code>        % Implicit input: string
"       % For each. This repeats as many times as chars in the input string
  G     %   Push input again
  X@    %   Push iteration index, k (varies from 1 to input length)
  :)    %   Get k first chars from input
  v!    %   Concatenate all stack contents horizontally
        % Implicit end
        % Implicit display
</code>```

Title: Stringsplode the String!

Body:
MATL, 8 bytes

"GX@:)v!

This uses a different approach from @Suever's answer.

Try it online!

Explanation

        % Implicit input: string
"       % For each. This repeats as many times as chars in the input string
  G     %   Push input again
  X@    %   Push iteration index, k (varies from 1 to input length)
  :)    %   Get k first chars from input
  v!    %   Concatenate all stack contents horizontally
        % Implicit end
        % Implicit display


问:
Faux Source Code
Output one random character for each character of source code (as illustrated below). The probability of each character is its frequency in the original source code. Thus the output will be fake source code resembling a quine.

Specification

Restrictions

Standard quine constrains apply. No empty programs or functions. Also no reading your own source.

Output

The number of characters output should be exactly the number of characters in the source code

Each output character should be randomly choosen

The probability of choosing any character is equal to (occurrences in source) / (length of source)

This means that even a unary solution needs to 'randomly' choose 1 with probability 1. Which is to say that the output can't be hard coded.

Winning

This is code golf, so fewest bytes wins

Example

```<code>Program           Frequency           Probability           Possible Output
-------           ---------           -----------           ---------------
 a@!@              a - 1               a - 25%               @@a@
                   ! - 1               ! - 25%
                   @ - 2               @ - 50%
</code>```

```<code>Program           Frequency           Probability           Possible Output
-------           ---------           -----------           ---------------
caBaDBcDaBDB       a - 3               a - 25%               aaaBBBBccDDD
                   B - 4               B - 33%
                   c - 2               c - 17%
                   D - 3               D - 25%
</code>```

答:
Jelly, 44 bytes

I hope I have interpreted all the rules correctly (I'm not quite sure what the "carry payload" thing is in meta or if it's even relevant to this challenge).

```<code>“ẋ2;8220Ọ;8221ỌXµ44Ð¡Ḋ”ẋ2;8220Ọ;8221ỌXµ44Ð¡Ḋ
</code>```

Test it out at TryItOnline

This constructs a string from which to choose characters. The initial string has all the character used except the open and close quotes. It then doubles that string and concatenates one of each of the open and close quotes from ordinals (hence the need to double the other characters). Lastly it repeatedly picks random characters from the composed string to the length of the program.

Title: Faux Source Code

Body:
Jelly, 44 bytes

I hope I have interpreted all the rules correctly (I'm not quite sure what the "carry payload" thing is in meta or if it's even relevant to this challenge).

“ẋ2;8220Ọ;8221ỌXµ44Ð¡Ḋ”ẋ2;8220Ọ;8221ỌXµ44Ð¡Ḋ

Test it out at TryItOnline

This constructs a string from which to choose characters. The initial string has all the character used except the open and close quotes. It then doubles that string and concatenates one of each of the open and close quotes from ordinals (hence the need to double the other characters). Lastly it repeatedly picks random characters from the composed string to the length of the program.


答:
Japt, 22 bytes

```<code>"+Q ²£ZgMqB"+Q ²£ZgMqB
</code>```

Test it online!

How it works

```<code>"+Q ²£ZgMqB"+Q ²£ZgMqB  // Implicit: B = 11
"+Q ²£ZgMqB"            // Take this string.
            +Q          // Append a quotation mark.
               ²        // Double the result.
                £       // Replace each char in the result Z with
                 Zg     //  the char in Z at index
                   MqB  //   random integer in the range [0, 11).
                        // Implicit: output last expression
</code>```

Title: Faux Source Code

Body:
Output one random character for each character of source code (as illustrated below). The probability of each character is its frequency in the original source code. Thus the output will be fake source code resembling a quine.

Specification

Restrictions

Standard quine constrains apply. No empty programs or functions. Also no reading your own source.

Output

The number of characters output should be exactly the number of characters in the source code

Each output character should be randomly choosen

The probability of choosing any character is equal to (occurrences in source) / (length of source)

This means that even a unary solution needs to 'randomly' choose 1 with probability 1. Which is to say that the output can't be hard coded.

Winning

This is code golf, so fewest bytes wins

Example

```<code>Program           Frequency           Probability           Possible Output
-------           ---------           -----------           ---------------
 a@!@              a - 1               a - 25%               @@a@
                   ! - 1               ! - 25%
                   @ - 2               @ - 50%
</code>```

```<code>Program           Frequency           Probability           Possible Output
-------           ---------           -----------           ---------------
caBaDBcDaBDB       a - 3               a - 25%               aaaBBBBccDDD
                   B - 4               B - 33%
                   c - 2               c - 17%
                   D - 3               D - 25%
</code>```

Body:
Japt, 22 bytes

"+Q ²£ZgMqB"+Q ²£ZgMqB

Test it online!

How it works

"+Q ²£ZgMqB"+Q ²£ZgMqB  // Implicit: B = 11
"+Q ²£ZgMqB"            // Take this string.
            +Q          // Append a quotation mark.
               ²        // Double the result.
                £       // Replace each char in the result Z with
                 Zg     //  the char in Z at index
                   MqB  //   random integer in the range [0, 11).
                        // Implicit: output last expression


答:
PHP, <s>71</s> <s>140</s> <s>110</s> <s>124</s> <s>140</s> 120 bytes

```<code>for($i=2*$n=strlen($s='for($i=2*$n=strlen($s=.chr(39));$i--;)echo$s[rand(0,$n-1)];'.chr(39));$i--;)echo$s[rand(0,$n-1)];
</code>```

run with php -d

creates a string containing the code without the quotation marks

and concatenates the quotation mark once using ord

(same probability as if I would double the string and add two quotes);

then loops over twice the length of the string to get random characters from it.

Can possibly be golfed further, but my attempts on eval where futile so far.

I will probably not go deeper here.

Title: Faux Source Code

Body:
PHP, <s>71</s> <s>140</s> <s>110</s> <s>124</s> <s>140</s> 120 bytes

for($i=2*$n=strlen($s='for($i=2*$n=strlen($s=.chr(39));$i--;)echo$s[rand(0,$n-1)];'.chr(39));$i--;)echo$s[rand(0,$n-1)];

run with php -d

creates a string containing the code without the quotation marks

and concatenates the quotation mark once using ord

(same probability as if I would double the string and add two quotes);

then loops over twice the length of the string to get random characters from it.

Can possibly be golfed further, but my attempts on eval where futile so far.

I will probably not go deeper here.


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

{S:g/.?/{$/.prematch}/}  # <-- the Perl 5 entry as a Perl 6 lambda
{[R~] m:ex/^.*/}
{[~] m:ex/^.*?/}
```
<h1>Explanation:</h1>
<pre class="lang-perl6 prettyprint-override"><code># bare block lambda with implicit parameter ｢$_｣
{
  # list reduce using string concatenation operator
  [~]

  # the input implicitly matched against
  m

  # in all possible ways
  :exhaustive

  /
    ^   # must match from the beginning
    .   # any character
    *?  # any number of times non-greedily
  /
}
</code>```

The m:ex/^.*?/ part produces a list of Match values (｢｣,｢C｣,｢Co｣,｢Cod｣,｢Code｣).

The other option m:ex/^.*/ produces the Match values in exactly the opposite order, so they have to be combined in reverse using the R meta operator.

Title: Stringsplode the String!

Body:
The challenge is relatively simple, but will hopefully lead to some wonderfully creative answers. The task is to take a string as an input (via command line, function parameter etc.) and output/return a stringsploded version of it.

A stringsploded version of a string is its first letter followed by its first 2 letters, followed by its first 3 letters,... until you finally output the complete word.

You are guaranteed that the input will consist of printable ASCII characters and that the input will all be on one line (no new line characters).

Here are examples to clarify what stringsplosions are:

```<code>Input                 Output
==================================================================
"Code"       ---->   "CCoCodCode"
"name"       ---->   "nnanamname"
"harambe"    ---->   "hhaharharaharamharambharambe"
"sp aces?"   ---->   "sspsp sp asp acsp acesp acessp aces?"
"1234"       ---->   "1121231234"
"ss"         ---->   "sss"
</code>```

This is code golf so shortest code wins + up votes for interesting uses of your respective language.

Good luck!

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

{S:g/.?/{$/.prematch}/}  # <-- the Perl 5 entry as a Perl 6 lambda
{[R~] m:ex/^.*/}
{[~] m:ex/^.*?/}

Explanation:

# bare block lambda with implicit parameter ｢$_｣
{
  # list reduce using string concatenation operator
  [~]

  # the input implicitly matched against
  m

  # in all possible ways
  :exhaustive

  /
    ^   # must match from the beginning
    .   # any character
    *?  # any number of times non-greedily
  /
}

The m:ex/^.*?/ part produces a list of Match values (｢｣,｢C｣,｢Co｣,｢Cod｣,｢Code｣).

The other option m:ex/^.*/ produces the Match values in exactly the opposite order, so they have to be combined in reverse using the R meta operator.


问:
Sort a list of numbers
About Code-Bowling:

In golf, you try to get the lowest score (smallest application, most elegant, etc). In Bowling, you try to get the highest score. So if you follow, the goal of a Code-Bowling challenge is to make the biggest, most bastardized, hardest to maintain piece of code that still meets the requirements of the challenge. However, there's no point in making source longer just for the sake of it. It needs to seem like that added length was from design and not just padding.

The Challenge:

Create a program that sorts a list of numbers in ascending order.

Example:

Input: 1, 4, 7, 2, 5

Output: 1, 2, 4, 5, 7

Code: Obviously this wouldn't be a good answer, since there aren't many WTFs in there

```<code>function doSort(array $input) {
    sort($input);
    return $input;
}
</code>```

Rules:

There are no real rules.  As long as the program functions, have at it!

Remember: This is code-bowling, not golf.  The objective is to make the worst, most bastardized code that you can!  Bonus points for code that looks good, but is actually deceptively evil...

答:
Ruby Metasort

```<code>#I know Ruby has a built-in method to order an array,
#but I can't remember what it is.  Oh well, metaprogramming to the rescue!
#I'll just try all of the available methods, and see which one works.

#check whether an array is ordered
def is_in_order? arr
  arr.is_a?(Array) && (0...(arr.size-1)).all? {|i| arr[i]<arr[i+1]}
end

Array.instance_methods.each do |meth|
  begin
    possibly_ordered_array = ARGV.map(&:to_i).send(meth)
    #have to check both that the new array is ordered, and that it's still the same size,
    #so that methods that change the array's elements don't create false positives.
    if is_in_order?(possibly_ordered_array) && possibly_ordered_array.size == ARGV.size
      puts possibly_ordered_array.join(", ")
      exit 0 #success!
    end
  rescue
    #method needed an argument or something
  end
end

exit 1 #could not order the array
</code>```

ContentLicense: CC BY-SA 2.5

Title: Sort a list of numbers

Body:
Ruby Metasort

#I know Ruby has a built-in method to order an array,
#but I can't remember what it is.  Oh well, metaprogramming to the rescue!
#I'll just try all of the available methods, and see which one works.

#check whether an array is ordered
def is_in_order? arr
  arr.is_a?(Array) && (0...(arr.size-1)).all? {|i| arr[i]<arr[i+1]}
end

Array.instance_methods.each do |meth|
  begin
    possibly_ordered_array = ARGV.map(&:to_i).send(meth)
    #have to check both that the new array is ordered, and that it's still the same size,
    #so that methods that change the array's elements don't create false positives.
    if is_in_order?(possibly_ordered_array) && possibly_ordered_array.size == ARGV.size
      puts possibly_ordered_array.join(", ")
      exit 0 #success!
    end
  rescue
    #method needed an argument or something
  end
end

exit 1 #could not order the array


答:
Japt, 5 bytes

```<code>Uå+ q
</code>```

Test it online!

How it works

```<code>       // Implicit: U = input string
Uå+    // Cumulative-reduce the input by addition.
       // This returns an array of all prefixes.
    q  // Join with the empty string.
       // Implicit: output last expression
</code>```

Title: Stringsplode the String!

Body:
Japt, 5 bytes

Uå+ q

Test it online!

How it works

       // Implicit: U = input string
Uå+    // Cumulative-reduce the input by addition.
       // This returns an array of all prefixes.
    q  // Join with the empty string.
       // Implicit: output last expression


答:
Java 7, 74 bytes

```<code>String h(String a){int l=a.length();return l>1?h(a.substring(0,l-1))+a:a;}
</code>```

or

```<code>String j(String a){return a.isEmpty()?a:j(a.substring(0,a.length()-1))+a;}
</code>```

Recursive version of Geobits answer.

Title: Stringsplode the String!

Body:
Java 7, 74 bytes

String h(String a){int l=a.length();return l>1?h(a.substring(0,l-1))+a:a;}

or

String j(String a){return a.isEmpty()?a:j(a.substring(0,a.length()-1))+a;}

Recursive version of Geobits answer.


问:
Bitflip and negate
Given an integer, make an expression that produces it from 0 using unary negation - and bitwise complement ~ (~n = -n-1), with the operators applied right to left.

```<code>...
-3  = ~-~-~0
-2  = ~-~0
-1  = ~0
 0  = 0
 1  = -~0
 2  = -~-~0
 3  = -~-~-~0
...
</code>```

Your expression must be as short as possible, which means no redundant parts of ~~, --, -0, or 00. Output or print the expression as a string or a sequence of characters.

var QUESTION_ID=92598,OVERRIDE_USER=20260;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/92598/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

```

答:
Perl 6, 25 bytes

{substr '-~'x.abs~0,0>$_}
```

<h1>Explanation:</h1>

<pre class="lang-perl6 prettyprint-override"><code>{
  substr
    # string repeat ｢-~｣ by the absolute value of the input
    '-~' x .abs

    # concatenate 0 to that
    ~ 0

    ,

    # ignore the first character of the string if it is negative
    0 > $_
}
</code>```

Title: Bitflip and negate

Body:
Perl 6, 25 bytes

{substr '-~'x.abs~0,0>$_}

Explanation:

{
  substr
    # string repeat ｢-~｣ by the absolute value of the input
    '-~' x .abs

    # concatenate 0 to that
    ~ 0

    ,

    # ignore the first character of the string if it is negative
    0 > $_
}


答:
JavaScript (ES6), <s>33</s> 31 bytes

```<code>f=x=>x<0?"~"+f(~x):x&&"-"+f(-x)
</code>```

Recursion < built-ins < loops (at least in this case). Basically unevaluates the input:

if it's less than 0, flip it and add a ~ to the string;

if it's more than 0, negate it and add a - to the string;

if it's exactly 0, return 0.

Takes advantage of this pattern:

```<code> 0         = 0
-1 = ~( 0) = ~0
+1 = -(-1) = -~0
-2 = ~(+1) = ~-~0
+2 = -(-2) = -~-~0
-3 = ~(+2) = ~-~-~0
+3 = -(-3) = -~-~-~0
etc.
</code>```

Title: Bitflip and negate

Body:
Given an integer, make an expression that produces it from 0 using unary negation - and bitwise complement ~ (~n = -n-1), with the operators applied right to left.

```<code>...
-3  = ~-~-~0
-2  = ~-~0
-1  = ~0
 0  = 0
 1  = -~0
 2  = -~-~0
 3  = -~-~-~0
...
</code>```

Your expression must be as short as possible, which means no redundant parts of ~~, --, -0, or 00. Output or print the expression as a string or a sequence of characters.

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
JavaScript (ES6), <s>33</s> 31 bytes

f=x=>x<0?"~"+f(~x):x&&"-"+f(-x)

Recursion < built-ins < loops (at least in this case). Basically unevaluates the input:

if it's less than 0, flip it and add a ~ to the string;

if it's more than 0, negate it and add a - to the string;

if it's exactly 0, return 0.

Takes advantage of this pattern:

 0         = 0
-1 = ~( 0) = ~0
+1 = -(-1) = -~0
-2 = ~(+1) = ~-~0
+2 = -(-2) = -~-~0
-3 = ~(+2) = ~-~-~0
+3 = -(-3) = -~-~-~0
etc.


答:
Pyth, 16 Bytes

```<code>smO+N"m1NOs+6"16
</code>```

try it online!

Contains each char twice therefore the probability is the same as if each was only in there once.

```<code>smO+N"m1NOs+6"16     #
   +N"m1NOs+6"       # Add a quotation mark to the string: "m1NOs+6
  O                  # random choice from the string
 m            16     # do this 16 times.
s                    # join the list into a string
</code>```

Title: Faux Source Code

Body:
Pyth, 16 Bytes

smO+N"m1NOs+6"16

try it online!

Contains each char twice therefore the probability is the same as if each was only in there once.

smO+N"m1NOs+6"16     #
   +N"m1NOs+6"       # Add a quotation mark to the string: "m1NOs+6
  O                  # random choice from the string
 m            16     # do this 16 times.
s                    # join the list into a string


答:
Jelly, <s>14</s> 12 bytes

-2 bytes thanks to @Dennis (return 0 rather than concatenate "0", making this a full program only.)

```<code>0>‘
A⁾-~ẋṫÇ0
</code>```

Test it at TryItOnline

How?

```<code>0>‘      - link 1 takes an argument, the input
0>       - greater than 0? 1 if true 0 if false
  ‘      - increment

A⁾-~ẋṫÇ0 - main link takes an argument, the input
      Ç  - y = result of previous link as a monad
A        - x = absolute value of input
 ⁾-~     - the string "-~"
    ẋ    - repeat the sting x times
     ṫ   - tail repeatedString[y:] (y will be 1 or 2, Jelly lists are 1-based)
       0 - implicit print then return 0
</code>```

Title: Bitflip and negate

Body:
Jelly, <s>14</s> 12 bytes

-2 bytes thanks to @Dennis (return 0 rather than concatenate "0", making this a full program only.)

0>‘
A⁾-~ẋṫÇ0

Test it at TryItOnline

How?

0>‘      - link 1 takes an argument, the input
0>       - greater than 0? 1 if true 0 if false
  ‘      - increment

A⁾-~ẋṫÇ0 - main link takes an argument, the input
      Ç  - y = result of previous link as a monad
A        - x = absolute value of input
 ⁾-~     - the string "-~"
    ẋ    - repeat the sting x times
     ṫ   - tail repeatedString[y:] (y will be 1 or 2, Jelly lists are 1-based)
       0 - implicit print then return 0


问:
Can you outgolf me? (Robbers section)

Robbers section

The cops section can be found here.

Challenge

Your task is to outgolf the submissions of the cops in the same language and the same version (for example, Python 3.5 ≠ Python 3.4, so that is not allowed). A submission is outgolfed when the length in bytes is shorter than the original submission. You only need to golf off at least 1 byte in order to crack a submission. E.g. if the task was to perform 2 × n, and the submission was the following:

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

You could outgolf the cop by doing the following:

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

Or even this (since lambda's are allowed):

```<code>lambda x:2*x
</code>```

Post this with the following header:

```<code>##{language name}, <s>{prev byte count}</s> {byte count}, {cop's submission + link}
</code>```

For example:

Python 2, <s>16</s> 12 bytes, Adnan (+ link to submission)

```<code>lambda x:2*x
</code>```

Computes A005843, (offset = 0).

In that case, you have cracked the submission.

Scoring

The person with who cracked the most submissions is the winner.

Rules

The crack submission must be in the same language as the cop submission.

The same input should result into the same output (so a(2) = 4 should remain 4).

For languages such as Python, you can import libraries that are standard included within the language. (So, no numpy/sympy etc.)

Input and output are both in decimal (base 10).

Note

This challenge is finished. The winner of the Robbers section is feersum. The final scores for the CnR are shown below:

feersum: 16 cracks

Dennis: 12 cracks

Leaky Nun: 6 cracks

Lynn: 4 cracks

miles: 3 cracks

Martin Ender: 2 cracks

Emigna: 2 cracks

jimmy23013: 1 crack

Sp3000: 1 crack

randomra: 1 crack

alephalpha: 1 crack

nimi: 1 crack

Destructible Watermelon: 1 crack

Dom Hastings: 1 crack

答:
Haskell, <s>15</s> 14 bytes, xnor

```<code>until odd succ
</code>```

I spent a fruitless couple of hours learning to decipher "pointless" syntax... until I found this instead.

Or for a less mellifluous 13 bytes, until odd(+1).

Title: Can you outgolf me? (Robbers section)

Body:
Haskell, <s>15</s> 14 bytes, xnor

until odd succ

I spent a fruitless couple of hours learning to decipher "pointless" syntax... until I found this instead.

Or for a less mellifluous 13 bytes, until odd(+1).


答:
Pyke, 35 bytes

```<code>35F\";"\\+3322 5**F;H)s"\"2*+2* H)s
</code>```

Try it here!

To check: remove the final H and the resulting string contains the right number of each character (with the extra H)

This does NOT use a generalised quine or in fact a quine at all. It relies on being able to create a string containing all the characters in the source. It should be able to do it for any code but each character logarithmically increases code size. The only number of times a character is allowed in the source is 2 or 7

Title: Faux Source Code

Body:
Pyke, 35 bytes

35F\";"\\+3322 5**F;H)s"\"2*+2* H)s

Try it here!

To check: remove the final H and the resulting string contains the right number of each character (with the extra H)

This does NOT use a generalised quine or in fact a quine at all. It relies on being able to create a string containing all the characters in the source. It should be able to do it for any code but each character logarithmically increases code size. The only number of times a character is allowed in the source is 2 or 7


答:
Jelly, 10 bytes

```<code>A⁾-~ẋḊẋ¡N0
</code>```

This is a full program. Try it online!

How it works

```<code>A⁾-~ẋḊẋ¡N0  Main link. Argument: n

A           Take the absolute value of n.
 ⁾-~ẋ       Repeat the string "-~" that many times. Result: s
       ¡    Conditional application:
     Ḋ        Dequeue; remove the first element of s...
      ẋ N     if s, repeated -n times, is non-empty.
         0  Print the previous return value. Set the return value to 0.
            (implicit) Print the final return value.
</code>```

Title: Bitflip and negate

Body:
Jelly, 10 bytes

A⁾-~ẋḊẋ¡N0

This is a full program. Try it online!

How it works

A⁾-~ẋḊẋ¡N0  Main link. Argument: n

A           Take the absolute value of n.
 ⁾-~ẋ       Repeat the string "-~" that many times. Result: s
       ¡    Conditional application:
     Ḋ        Dequeue; remove the first element of s...
      ẋ N     if s, repeated -n times, is non-empty.
         0  Print the previous return value. Set the return value to 0.
            (implicit) Print the final return value.


答:
Lua, 58

```<code>u=''for s in io.read():gmatch('.')do u=u..s io.write(u)end
</code>```

Saved 5 Bytes thanks to manatwork

I love using lua's gmatch and gsub for golfing.

Simply takes io.read(), gmatch's it for any single character, iterating through the entire string.
it assigns the variable st, which slowly builds the entire string as lua iterates, and at every iteration, writes the contents of st.

Title: Stringsplode the String!

Body:
Lua, 58

u=''for s in io.read():gmatch('.')do u=u..s io.write(u)end

Saved 5 Bytes thanks to manatwork

I love using lua's gmatch and gsub for golfing.

Simply takes io.read(), gmatch's it for any single character, iterating through the entire string.
it assigns the variable st, which slowly builds the entire string as lua iterates, and at every iteration, writes the contents of st.


问:
“HHeelllloo,, EEaarrtthh!!”
Much like this challenge, write a program or function that takes no input and prints or returns the string

```<code>Hello, Earth!
</code>```

with an optional trailing newline.

The catch is that your program must be an even number of characters long, and each two character chunk of your program must consist of identical characters.

For example, a valid program might look like

```<code>AAbb==11++♥♥

[[--  2222]]
</code>```

because every two character chunk (AA, bb, ==, 11, etc.) is made of two identical characters (even the newlines).

A program such as

```<code>AAbB==11++♥♥

[[--  2222]]
</code>```

would not be valid because the bB chunk is not made of identical characters.

The only exception to the rule is that \r\n should be treated a single, generic "newline" character since replacing it with \r\r\n\n wouldn't work or make sense for some languages and systems.

The shortest code in bytes wins. The example is 30 bytes long (not 15, not 13).

Title: “HHeelllloo,, EEaarrtthh!!”

Body:
Lenguage, 1354616599400377002855073561913010716386821416114463012 bytes

It's 1354616599400377002855073561913010716386821416114463012 zeroes:

0000000000000000000000000000000000000000000000000000000000000000000000000000000000...00000000

It's this BF program:

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

Converted into binary:

001110001001001001001001001010000011111010001100001110001010000000000000000011111010000000100000000000000000000000100100000000000100110001010000000000000000011111010000100001001001001001001001001001001001001100000000110001010000000011111010000100000110001001001001001001010000011111010100001001110001001001010000011111010001001001100000000100001001001001001001001001001001001001100001001110001001001010000011111010001100

Converted into a decimal number:

1354616599400377002855073561913010716386821416114463012

With that many zeroes. Hooray for lenguage!


问:
Count to 100 in Danish
Print all the numbers from 0-100 in the right order using the Danish way of counting

How they count

Like English, they have dedicated words for 0-20, 30, 40 and 100

Instead of saying twenty-one and twenty-two, they say one and twenty and two and twenty

Starting with fifty they say multiples of 10 as n*20

```<code>50 = half third times twenty = half way to the 3rd multiple of 20
60 = three times twenty
70 = half fourth times twenty
80 = four times twenty
90 = half fifth times twenty
</code>```

So for instance, 55 would be five and half third times twenty.

Expected output

```<code>zero
one
two
three
four
five
six
seven
eight
nine
ten
eleven
twelve
thirteen
fourteen
fifteen
sixteen
seventeen
eighteen
nineteen
twenty
one and twenty
two and twenty
three and twenty
four and twenty
five and twenty
six and twenty
seven and twenty
eight and twenty
nine and twenty
thirty
one and thirty
two and thirty
three and thirty
four and thirty
five and thirty
six and thirty
seven and thirty
eight and thirty
nine and thirty
forty
one and forty
two and forty
three and forty
four and forty
five and forty
six and forty
seven and forty
eight and forty
nine and forty
half third times twenty
one and half third times twenty
two and half third times twenty
three and half third times twenty
four and half third times twenty
five and half third times twenty
six and half third times twenty
seven and half third times twenty
eight and half third times twenty
nine and half third times twenty
three times twenty
one and three times twenty
two and three times twenty
three and three times twenty
four and three times twenty
five and three times twenty
six and three times twenty
seven and three times twenty
eight and three times twenty
nine and three times twenty
half fourth times twenty
one and half fourth times twenty
two and half fourth times twenty
three and half fourth times twenty
four and half fourth times twenty
five and half fourth times twenty
six and half fourth times twenty
seven and half fourth times twenty
eight and half fourth times twenty
nine and half fourth times twenty
four times twenty
one and four times twenty
two and four times twenty
three and four times twenty
four and four times twenty
five and four times twenty
six and four times twenty
seven and four times twenty
eight and four times twenty
nine and four times twenty
half fifth times twenty
one and half fifth times twenty
two and half fifth times twenty
three and half fifth times twenty
four and half fifth times twenty
five and half fifth times twenty
six and half fifth times twenty
seven and half fifth times twenty
eight and half fifth times twenty
nine and half fifth times twenty
one hundred
</code>```

Rules

You may use any separator to separate the numbers

Due to a typo in the original specification, you may use forth instead of fourth.

You may write a function or write to std-out

Standard loopholes apply

This is codegolf; shortest code in bytes win!

答:
PHP, <s>397</s> <s>375</s> <s>372</s> <s>381</s> <s>386</s> 365 bytes

This was too funny to be ignored. It can possibly be golfed further.

```<code>zero_<?=join(_,$a=[one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen,seventeen,eighteen,nineteen])._;foreach([twenty,thirty,forty]as$t)for($i=-2;$i++<8;)echo($i<0?'':$c[]="$a[$i] and ").$t._;foreach([third,three,fourth,four,fifth]as$k=>$t)for($i=-2;$i++<8;)echo$c[$i],($k&1?'':'half '),"$t times twenty_";?>one hundred
</code>```

It uses underscore as the separator

10 to 19 are still hardcoded; any way to compute them doesn´t give as much as the join.

Title: Count to 100 in Danish

Body:
PHP, <s>397</s> <s>375</s> <s>372</s> <s>381</s> <s>386</s> 365 bytes

This was too funny to be ignored. It can possibly be golfed further.

zero_<?=join(_,$a=[one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen,seventeen,eighteen,nineteen])._;foreach([twenty,thirty,forty]as$t)for($i=-2;$i++<8;)echo($i<0?'':$c[]="$a[$i] and ").$t._;foreach([third,three,fourth,four,fifth]as$k=>$t)for($i=-2;$i++<8;)echo$c[$i],($k&1?'':'half '),"$t times twenty_";?>one hundred

It uses underscore as the separator

10 to 19 are still hardcoded; any way to compute them doesn´t give as much as the join.


答:
Jelly, 13 bytes

```<code>“;⁾vṾWṁ$X€”vṾ
</code>```

Try it online!

How it works

```<code>“;⁾vṾWṁ$X€”vṾ  Main link. No arguments.

“;⁾vṾWṁ$X€”    Set the argument and return value to the string s := ';⁾vṾWṁ$X€'.
            Ṿ  Uneval; construct a string representation of s.
               This yields r := '“;⁾vṾWṁ$X€”'.
           v   Dyadic eval; evaluate s with argument r.

 ;⁾vṾWṁ$X€     Evaluated link (s). Argument: r

  ⁾vṾ          Yield 'vṾ'.
 ;             Concatenate r with 'vṾ'.
               This yields t := '“;⁾vṾWṁ$X€”vṾ', i.e., the original source code.
       $       Combine the previous two links into a monadic chain.
     W           Wrap; yield ['“;⁾vṾWṁ$X€”vṾ'].
      ṁ          Mold; repeat ['“;⁾vṾWṁ$X€”vṾ'] once for each charcter in t.
        X€     Random each; select a character, uniformly at random, of each
               of the 13 repetitions of t.
</code>```

Title: Faux Source Code

Body:
Output one random character for each character of source code (as illustrated below). The probability of each character is its frequency in the original source code. Thus the output will be fake source code resembling a quine.

Specification

Restrictions

Standard quine constrains apply. No empty programs or functions. Also no reading your own source.

Output

The number of characters output should be exactly the number of characters in the source code

Each output character should be randomly choosen

The probability of choosing any character is equal to (occurrences in source) / (length of source)

This means that even a unary solution needs to 'randomly' choose 1 with probability 1. Which is to say that the output can't be hard coded.

Winning

This is code golf, so fewest bytes wins

Example

```<code>Program           Frequency           Probability           Possible Output
-------           ---------           -----------           ---------------
 a@!@              a - 1               a - 25%               @@a@
                   ! - 1               ! - 25%
                   @ - 2               @ - 50%
</code>```

```<code>Program           Frequency           Probability           Possible Output
-------           ---------           -----------           ---------------
caBaDBcDaBDB       a - 3               a - 25%               aaaBBBBccDDD
                   B - 4               B - 33%
                   c - 2               c - 17%
                   D - 3               D - 25%
</code>```

Body:
Jelly, 13 bytes

“;⁾vṾWṁ$X€”vṾ

Try it online!

How it works

“;⁾vṾWṁ$X€”vṾ  Main link. No arguments.

“;⁾vṾWṁ$X€”    Set the argument and return value to the string s := ';⁾vṾWṁ$X€'.
            Ṿ  Uneval; construct a string representation of s.
               This yields r := '“;⁾vṾWṁ$X€”'.
           v   Dyadic eval; evaluate s with argument r.

 ;⁾vṾWṁ$X€     Evaluated link (s). Argument: r

  ⁾vṾ          Yield 'vṾ'.
 ;             Concatenate r with 'vṾ'.
               This yields t := '“;⁾vṾWṁ$X€”vṾ', i.e., the original source code.
       $       Combine the previous two links into a monadic chain.
     W           Wrap; yield ['“;⁾vṾWṁ$X€”vṾ'].
      ṁ          Mold; repeat ['“;⁾vṾWṁ$X€”vṾ'] once for each charcter in t.
        X€     Random each; select a character, uniformly at random, of each
               of the 13 repetitions of t.


答:
Cheddar, 20 bytes

```<code>n->(|>11).map(n&(*))
</code>```

Yay for functional \o/

I don't think this needs explanation but if you'd like to me add one just ask :)

Title: Print multiplication tables by input

Body:
In this challenge you've to print multiplication tables by input, Here are some examples:

```<code>Input: 2

Output:
0 2  4 6 8  10  12  14  16  18  20

Input: 20

Output: 20 40 60 80 100 120 140 160 180 200
</code>```

Rules

The shortest code in bytes wins.

This challenge is a code-golf, It follows code-golf general rules (code-golf)

If, just if, your code can't print number, you can use letters, Here is an example:

Input: B

Output: B D F H J L N P R T

You can choose to start from 0 or your number (like 20). You can choose if put spaces or don't. The challenge is free, just take an input and print multiplication tables.

Your output must list the first 10 members of the times table for the given number. You may leave out 0*n.

Body:
Cheddar, 20 bytes

n->(|>11).map(n&(*))

Yay for functional \o/

I don't think this needs explanation but if you'd like to me add one just ask :)


问:
Greater than less than greater than something fishy
Given a length N string of less-than and greater-than signs (<, >), insert the integers 0 through N at the start and end and in between each pair of signs such that all the inequalities are satisfied. Output the resulting string. If there are multiple valid outputs, output any one (and just one) of them.

For example

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

has 7 characters so all the numbers from 0 to 7 inclusive must be inserted. A valid output is

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

because all the inequalities taken one at a time

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

are true.

If desired, the output may have spaces surrounding the signs, e.g. 2 < 3 < 4 > 1 < 5 > 0 < 6 < 7.

The shortest code in bytes wins.

Test Cases

The first line after an empty line is the input and the next line(s) are each valid output examples.

```<code>[empty string]
0

<
0<1

>
1>0

<<
0<1<2

<>
1<2>0

><
1>0<2
2>0<1

>>
2>1>0

<<<
0<1<2<3

><>
1>0<3>2

>><
3>2>0<1
3>1>0<2
2>1>0<3

>>>
3>2>1>0

>>><<<
3>2>1>0<4<5<6
6>3>1>0<2<4<5
4>2>1>0<3<5<6
4>3>1>0<2<5<6

<<><><<
2<3<4>1<5>0<6<7

>><><>>
7>6>0<5>1<4>3>2

<<<<<<<<<<<<<<
0<1<2<3<4<5<6<7<8<9<10<11<12<13<14

>><<<<><>><><<
6>5>4<7<8<9<10>3<11>2>1<12>0<13<14
14>5>4<7<8<9<10>3<11>2>1<12>0<13<6
</code>```

答:
><>, 26 + 4 = 30 bytes

```<code>l22pirv
1+$2po>:3%::2g:n$-
</code>```

Try it online! +4 bytes for the -s= flag - if just -s is okay (it would mean that the flag would need to be dropped entirely for empty input), then that would be +3 instead.

Assumes that STDIN input is empty so that i produces -1 (which it does on EOF). The program errors out trying to print this -1 as a char.

Uses the max-of-nums-so-far-for->, min-of-nums-so-far-for-< approach.

```<code>[Setup]
l22p         Place (length of stack) = (length of input) into position (2, 2) of
             the codebox. Codebox values are initialised to 0, so (0, 2) will
             contain the other value we need.
i            Push -1 due to EOF so that we error out later
r            Reverse the stack
v            Move down to the next line
>            Change IP direction to rightward

[Loop]
:3%          Take code point of '<' or '>' mod 3, giving 0 or 2 respectively
             (call this value c)
:            Duplicate
:2g          Fetch the value v at (c, 2)
:n           Output it as a number
$-1+         Calculate v-c+1 to update v
$2p          Place the updated value into (c, 2)
o            Output the '<' or '>' as a char (or error out here outputting -1)
</code>```

A program which exits cleanly and does not make the assumption about STDIN is 4 extra bytes:

```<code>l22p0rv
p:?!;o>:3%::2g:n$-1+$2
</code>```

Body:
><>, 26 + 4 = 30 bytes

l22pirv
1+$2po>:3%::2g:n$-

Try it online! +4 bytes for the -s= flag - if just -s is okay (it would mean that the flag would need to be dropped entirely for empty input), then that would be +3 instead.

Assumes that STDIN input is empty so that i produces -1 (which it does on EOF). The program errors out trying to print this -1 as a char.

Uses the max-of-nums-so-far-for->, min-of-nums-so-far-for-< approach.

[Setup]
l22p         Place (length of stack) = (length of input) into position (2, 2) of
             the codebox. Codebox values are initialised to 0, so (0, 2) will
             contain the other value we need.
i            Push -1 due to EOF so that we error out later
r            Reverse the stack
v            Move down to the next line
>            Change IP direction to rightward

[Loop]
:3%          Take code point of '<' or '>' mod 3, giving 0 or 2 respectively
             (call this value c)
:            Duplicate
:2g          Fetch the value v at (c, 2)
:n           Output it as a number
$-1+         Calculate v-c+1 to update v
$2p          Place the updated value into (c, 2)
o            Output the '<' or '>' as a char (or error out here outputting -1)

A program which exits cleanly and does not make the assumption about STDIN is 4 extra bytes:

l22p0rv
p:?!;o>:3%::2g:n$-1+$2


答:
JavaScript (ES6), <s>347</s> <s>336</s> <s>326</s> <s>325</s> 308 bytes

for(a=btoa`...`.split(i=0);i<101;i++)alert(i<13?a[i]:i<20?(a[i]||a[i-10])+"teen":i>99?"one hundred":(i%10?a[i%10]+" and ":"")+(i<30?"twenty":i<40?"thirty":i<50?"forty":(i%20>9?"half "+["third","forth","fifth"][i/20-2|0]:a[i/20|0])+" times twenty"))
```

<p>Before running, replace the <code>...</code> with the result of running this code:</p>

<pre class="lang-js prettyprint-override"><code>atob("zero0one0two0three0four0five0six0seven0eight0nine0ten0eleven0twelve0thir00fif000eigh")
</code>```

Or you could just use the uncompressed version:

for(a="zero0one0two0three0four0five0six0seven0eight0nine0ten0eleven0twelve0thir00fif000eigh".split(i=0);i<101;i++)alert(i<13?a[i]:i<20?(a[i]||a[i-10])+"teen":i>99?"one hundred":(i%10?a[i%10]+" and ":"")+(i<30?"twenty":i<40?"thirty":i<50?"forty":(i%20>9?"half "+["third","forth","fifth"][i/20-2|0]:a[i/20|0])+" times twenty"))
```

Still probably not optimal. 11 bytes saved in part by @Titus.

Title: Count to 100 in Danish

Body:
Print all the numbers from 0-100 in the right order using the Danish way of counting

How they count

Like English, they have dedicated words for 0-20, 30, 40 and 100

Instead of saying twenty-one and twenty-two, they say one and twenty and two and twenty

Starting with fifty they say multiples of 10 as n*20

```<code>50 = half third times twenty = half way to the 3rd multiple of 20
60 = three times twenty
70 = half fourth times twenty
80 = four times twenty
90 = half fifth times twenty
</code>```

So for instance, 55 would be five and half third times twenty.

Expected output

```<code>zero
one
two
three
four
five
six
seven
eight
nine
ten
eleven
twelve
thirteen
fourteen
fifteen
sixteen
seventeen
eighteen
nineteen
twenty
one and twenty
two and twenty
three and twenty
four and twenty
five and twenty
six and twenty
seven and twenty
eight and twenty
nine and twenty
thirty
one and thirty
two and thirty
three and thirty
four and thirty
five and thirty
six and thirty
seven and thirty
eight and thirty
nine and thirty
forty
one and forty
two and forty
three and forty
four and forty
five and forty
six and forty
seven and forty
eight and forty
nine and forty
half third times twenty
one and half third times twenty
two and half third times twenty
three and half third times twenty
four and half third times twenty
five and half third times twenty
six and half third times twenty
seven and half third times twenty
eight and half third times twenty
nine and half third times twenty
three times twenty
one and three times twenty
two and three times twenty
three and three times twenty
four and three times twenty
five and three times twenty
six and three times twenty
seven and three times twenty
eight and three times twenty
nine and three times twenty
half fourth times twenty
one and half fourth times twenty
two and half fourth times twenty
three and half fourth times twenty
four and half fourth times twenty
five and half fourth times twenty
six and half fourth times twenty
seven and half fourth times twenty
eight and half fourth times twenty
nine and half fourth times twenty
four times twenty
one and four times twenty
two and four times twenty
three and four times twenty
four and four times twenty
five and four times twenty
six and four times twenty
seven and four times twenty
eight and four times twenty
nine and four times twenty
half fifth times twenty
one and half fifth times twenty
two and half fifth times twenty
three and half fifth times twenty
four and half fifth times twenty
five and half fifth times twenty
six and half fifth times twenty
seven and half fifth times twenty
eight and half fifth times twenty
nine and half fifth times twenty
one hundred
</code>```

Rules

You may use any separator to separate the numbers

Due to a typo in the original specification, you may use forth instead of fourth.

You may write a function or write to std-out

Standard loopholes apply

This is codegolf; shortest code in bytes win!

Body:
JavaScript (ES6), <s>347</s> <s>336</s> <s>326</s> <s>325</s> 308 bytes

for(a=btoa`...`.split(i=0);i<101;i++)alert(i<13?a[i]:i<20?(a[i]||a[i-10])+"teen":i>99?"one hundred":(i%10?a[i%10]+" and ":"")+(i<30?"twenty":i<40?"thirty":i<50?"forty":(i%20>9?"half "+["third","forth","fifth"][i/20-2|0]:a[i/20|0])+" times twenty"))

Before running, replace the ... with the result of running this code:

atob("zero0one0two0three0four0five0six0seven0eight0nine0ten0eleven0twelve0thir00fif000eigh")

Or you could just use the uncompressed version:

for(a="zero0one0two0three0four0five0six0seven0eight0nine0ten0eleven0twelve0thir00fif000eigh".split(i=0);i<101;i++)alert(i<13?a[i]:i<20?(a[i]||a[i-10])+"teen":i>99?"one hundred":(i%10?a[i%10]+" and ":"")+(i<30?"twenty":i<40?"thirty":i<50?"forty":(i%20>9?"half "+["third","forth","fifth"][i/20-2|0]:a[i/20|0])+" times twenty"))

Still probably not optimal. 11 bytes saved in part by @Titus.


答:
APL 107

Unfortunately my APL interpreter does not support regexs so here's a home rolled version where the text to be scrambled is stored in the variable t:

```<code>⎕av[((~z)\(∊y)[∊(+\0,¯1↓n)+¨n?¨n←⍴¨y←(~z←×(~x)+(x>¯1↓0,x)+x>1↓(x←~53≤(∊(⊂⍳26)+¨65 97)⍳v←⎕av⍳,t),0)⊂v])+z×v]
</code>```

Essentially the code partitions the text into words based on the letters of the alphabet only and then into the letters between the first and last letters of those words. These letters are then scrambled and the whole character string reassembled.

Title: Cambridge Transposition

Body:
I'm sure most, if not all, of you have come across this at some point or another:

Aoccdrnig to a rscheeachr at Cmabrigde Uinervtisy, it deosn't mttaer
in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is
taht the frist and lsat ltteer be at the rghit pclae. The rset can be
a toatl mses and you can sitll raed it wouthit porbelm. Tihs is
bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the
wrod as a wlohe.

Create a program that inputs any amount of text. For testing purposes, use the unscrambled version of the above text, found below.

The program must then randomly transpose the letters of each word with a length of 4 or more letters, except the first and last letter of each word.

All other formatting must remain the same (capitalization and punctuation, etc.).

Testing text:

According to a researcher at Cambridge University, it doesn't matter
in what order the letters in a word are, the only important thing is
that the first and last letter be at the right place. The rest can be
a total mess and you can still read it without problem. This is
because the human mind does not read every letter by itself but the
word as a whole.

As usual, this is a code-golf. Shortest code wins.

Body:
APL 107

Unfortunately my APL interpreter does not support regexs so here's a home rolled version where the text to be scrambled is stored in the variable t:

⎕av[((~z)\(∊y)[∊(+\0,¯1↓n)+¨n?¨n←⍴¨y←(~z←×(~x)+(x>¯1↓0,x)+x>1↓(x←~53≤(∊(⊂⍳26)+¨65 97)⍳v←⎕av⍳,t),0)⊂v])+z×v]

Essentially the code partitions the text into words based on the letters of the alphabet only and then into the letters between the first and last letters of those words. These letters are then scrambled and the whole character string reassembled.


问:
Just repeat yourself
Write a program that outputs

```<code>Do not repeat yourself!
</code>```

Your program code must respect the following constraints :

its length must be an even number

each character that is in position 2n (where n is an integer > 0) must be equal to the character in position 2n-1. The second character of the program is equal to the first, the fourth is equal to the third, etc.

Newlines count as characters!

This is code-golf, so the shortest code wins!

Examples

HHeellllooWWoorrlldd is a valid program

123 or AAABBB or HHeello are incorrect

Verification

You can use this CJam script to verify that your source code is valid. Simply paste your code into the "Input" box and run the script.

答:
Jelly, 66 bytes

```<code>““DDoo  nn““oott  rreepp““eeaatt  yyoouurrss““eellff!!””ṛṛḷḷWWQQ€€
</code>```

Try it online!

Factoid

The program still works if you remove every second character.

Try it online!

How it works

```<code>““DDoo  nn““oott  rreepp““eeaatt  yyoouurrss““eellff!!”
</code>```

returns an array of string. The literal begins with a “, ends with a ”, and the strings are delimited internally by “. The result is

```<code>["", "DDoo  nn", "", "oott  rreepp", "", "eeaatt  yyoouurrss", "", "eellff!!"]
</code>```

The link's argument and the return value are set to this array of strings, then the remainder of the source code is executed.

```<code><literal>”ṛṛḷḷWWQQ€€  Argument/return value: A (string array)

         ”ṛ           Yield the character 'ṛ'.
           ṛ          Select the right argument of 'ṛ' and A: A.
            ḷ         Select the left argument of A and A: A.
              W       Wrap; yield [A].
             ḷ        Select the left argument of A and [A]: A.
               W      Wrap; yield [A].
                Q     Unique; deduplicate [A]. Yields [A].
                 Q€€  Unique each each; for each string s in A, deduplicate s.

</code>```

Title: Just repeat yourself

Body:
Jelly, 66 bytes

““DDoo  nn““oott  rreepp““eeaatt  yyoouurrss““eellff!!””ṛṛḷḷWWQQ€€

Try it online!

Factoid

The program still works if you remove every second character.

Try it online!

How it works

““DDoo  nn““oott  rreepp““eeaatt  yyoouurrss““eellff!!”

returns an array of string. The literal begins with a “, ends with a ”, and the strings are delimited internally by “. The result is

["", "DDoo  nn", "", "oott  rreepp", "", "eeaatt  yyoouurrss", "", "eellff!!"]

The link's argument and the return value are set to this array of strings, then the remainder of the source code is executed.

<literal>”ṛṛḷḷWWQQ€€  Argument/return value: A (string array)

         ”ṛ           Yield the character 'ṛ'.
           ṛ          Select the right argument of 'ṛ' and A: A.
            ḷ         Select the left argument of A and A: A.
              W       Wrap; yield [A].
             ḷ        Select the left argument of A and [A]: A.
               W      Wrap; yield [A].
                Q     Unique; deduplicate [A]. Yields [A].
                 Q€€  Unique each each; for each string s in A, deduplicate s.


答:
CJam, 8 bytes

Here's 4 separate ways to get 8 bytes

```<code>l_,),\f<
l{1$\+}*
l{+_}*co
Ll{+_}/;
</code>```

Credits to @MartinEnder for the last one. Online interpreter.

l_,),\f< creates the range [0 .. len(s)+1] then uses f< to slice for each number, producing all prefixes.

l{1$\+}* is a fold that duplicates the previous prefix and adds a char to it as it goes.

l{+_}*co is a bit weird - l{+_}* is also a fold but it produces the wrong prefixes, skipping the first and doubling the last (e.g. abcd -> ab/abc/abcd/abcd, slashes for clarity). We then use c to turn the last string into just its first character and output it with o, to get the first prefix.

Ll{+_}/; is a for-each loop that also duplicates the previous prefix and adds a char to it as it goes. We have an extra copy of the original string once the loop is over, which we pop with ;.

Title: Stringsplode the String!

Body:
The challenge is relatively simple, but will hopefully lead to some wonderfully creative answers. The task is to take a string as an input (via command line, function parameter etc.) and output/return a stringsploded version of it.

A stringsploded version of a string is its first letter followed by its first 2 letters, followed by its first 3 letters,... until you finally output the complete word.

You are guaranteed that the input will consist of printable ASCII characters and that the input will all be on one line (no new line characters).

Here are examples to clarify what stringsplosions are:

```<code>Input                 Output
==================================================================
"Code"       ---->   "CCoCodCode"
"name"       ---->   "nnanamname"
"harambe"    ---->   "hhaharharaharamharambharambe"
"sp aces?"   ---->   "sspsp sp asp acsp acesp acessp aces?"
"1234"       ---->   "1121231234"
"ss"         ---->   "sss"
</code>```

This is code golf so shortest code wins + up votes for interesting uses of your respective language.

Good luck!

Body:
CJam, 8 bytes

Here's 4 separate ways to get 8 bytes

l_,),\f<
l{1$\+}*
l{+_}*co
Ll{+_}/;

Credits to @MartinEnder for the last one. Online interpreter.

l_,),\f< creates the range [0 .. len(s)+1] then uses f< to slice for each number, producing all prefixes.

l{1$\+}* is a fold that duplicates the previous prefix and adds a char to it as it goes.

l{+_}*co is a bit weird - l{+_}* is also a fold but it produces the wrong prefixes, skipping the first and doubling the last (e.g. abcd -> ab/abc/abcd/abcd, slashes for clarity). We then use c to turn the last string into just its first character and output it with o, to get the first prefix.

Ll{+_}/; is a for-each loop that also duplicates the previous prefix and adds a char to it as it goes. We have an extra copy of the original string once the loop is over, which we pop with ;.


答:
Haskell, <s>308</s> <s>291</s> 285 bytes

```<code>w=words;q x=map(++x);m=w"thir four fif six seven eigh nine";t=w"zero one two three four five six seven eight nine ten eleven twelve"++q"teen"m++q"ty"(do b<-"twen":take 2m++q" times twen"["half third",t!!3,"half fourth",t!!4,"half fifth"];b:q b(q" and ".take 9$tail t))++["one hundred"]
</code>```

Readable version:

```<code>w   = words
m   = w "thir four fif six seven eigh nine"
q x = map (++x)

t = w "zero one two three four five six seven eight nine ten eleven twelve"
 ++ q "teen" m
 ++ q "ty" (do b <- "twen" : take 2 m
                     ++ q " times twen"
                          ["half third",t!!3,"half fourth",t!!4,"half fifth"]
               b:q b(q" and ".take 9$tail t)
           )
 ++ ["one hundred"]
</code>```

Also 285

```<code>w=words;m=w"thir four fif six seven eigh nine";x!l=map(++x)l
t  = w"zero one two three four five six seven eight nine ten eleven twelve"
  ++ "teen"!m
  ++ "ty"!(
  do x<-"twen":take 2m++" times twen"!
         ["half third",t!!3,"half fourth",t!!4,"half fifth"]
     x:x!(" and "!take 9(tail t)))
  ++ ["one hundred"]
</code>```

It might not look much different, but it represents hours of factorization that eventually brought me full circle. I think I have done this before..

Title: Count to 100 in Danish

Body:
Haskell, <s>308</s> <s>291</s> 285 bytes

w=words;q x=map(++x);m=w"thir four fif six seven eigh nine";t=w"zero one two three four five six seven eight nine ten eleven twelve"++q"teen"m++q"ty"(do b<-"twen":take 2m++q" times twen"["half third",t!!3,"half fourth",t!!4,"half fifth"];b:q b(q" and ".take 9$tail t))++["one hundred"]

Readable version:

w   = words
m   = w "thir four fif six seven eigh nine"
q x = map (++x)

t = w "zero one two three four five six seven eight nine ten eleven twelve"
 ++ q "teen" m
 ++ q "ty" (do b <- "twen" : take 2 m
                     ++ q " times twen"
                          ["half third",t!!3,"half fourth",t!!4,"half fifth"]
               b:q b(q" and ".take 9$tail t)
           )
 ++ ["one hundred"]

Also 285

w=words;m=w"thir four fif six seven eigh nine";x!l=map(++x)l
t  = w"zero one two three four five six seven eight nine ten eleven twelve"
  ++ "teen"!m
  ++ "ty"!(
  do x<-"twen":take 2m++" times twen"!
         ["half third",t!!3,"half fourth",t!!4,"half fifth"]
     x:x!(" and "!take 9(tail t)))
  ++ ["one hundred"]

It might not look much different, but it represents hours of factorization that eventually brought me full circle. I think I have done this before..


Title: Can you outgolf me? (Robbers section)

Body:
Robbers section

The cops section can be found here.

Challenge

Your task is to outgolf the submissions of the cops in the same language and the same version (for example, Python 3.5 ≠ Python 3.4, so that is not allowed). A submission is outgolfed when the length in bytes is shorter than the original submission. You only need to golf off at least 1 byte in order to crack a submission. E.g. if the task was to perform 2 × n, and the submission was the following:

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

You could outgolf the cop by doing the following:

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

Or even this (since lambda's are allowed):

```<code>lambda x:2*x
</code>```

Post this with the following header:

```<code>##{language name}, <s>{prev byte count}</s> {byte count}, {cop's submission + link}
</code>```

For example:

Python 2, <s>16</s> 12 bytes, Adnan (+ link to submission)

```<code>lambda x:2*x
</code>```

Computes A005843, (offset = 0).

In that case, you have cracked the submission.

Scoring

The person with who cracked the most submissions is the winner.

Rules

The crack submission must be in the same language as the cop submission.

The same input should result into the same output (so a(2) = 4 should remain 4).

For languages such as Python, you can import libraries that are standard included within the language. (So, no numpy/sympy etc.)

Input and output are both in decimal (base 10).

Note

This challenge is finished. The winner of the Robbers section is feersum. The final scores for the CnR are shown below:

feersum: 16 cracks

Dennis: 12 cracks

Leaky Nun: 6 cracks

Lynn: 4 cracks

miles: 3 cracks

Martin Ender: 2 cracks

Emigna: 2 cracks

jimmy23013: 1 crack

Sp3000: 1 crack

randomra: 1 crack

alephalpha: 1 crack

nimi: 1 crack

Destructible Watermelon: 1 crack

Dom Hastings: 1 crack

Body:
Woefully, <s>776</s> 759 bytes, Destructible Watermelon

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

I tried to read the source code for this language but it was too confusing. For one thing, ip[1] is a line number while ip[0] is the column number, while the cp coordinates are used the other way around. Yet, sometimes the value of cp is assigned to ip. I gave up on trying to understand what the program is doing and found a way to encode the identical sequence of instructions using fewer bars.


答:
Mathematica <s>251 238</s> 230 bytes

This now presents the output in the format of a list, to save 8 more bytes.

```<code>c@s_:=s<>" times twenty";f@n_:=Which[n<21∨{30,40,100}~MemberQ~n,IntegerName@n,n==50,c@"half third",n==60,c@"three",n==70,c@"half forth",n==80,c@"four",n==90,c@"half fifth",3>2,NumberExpand@n/.{t_,u_}:>f@u<>" plus "<>f@t];f/@0~Range~100
</code>```

Title: Count to 100 in Danish

Body:
Mathematica <s>251 238</s> 230 bytes

This now presents the output in the format of a list, to save 8 more bytes.

c@s_:=s<>" times twenty";f@n_:=Which[n<21∨{30,40,100}~MemberQ~n,IntegerName@n,n==50,c@"half third",n==60,c@"three",n==70,c@"half forth",n==80,c@"four",n==90,c@"half fifth",3>2,NumberExpand@n/.{t_,u_}:>f@u<>" plus "<>f@t];f/@0~Range~100


答:
JavaScript (ES6), 346 bytes

Only a small idea to ETHproductions' solution:
Replace f(..) with a[..] to be able to call f recursively to concat the output.

```<code>f=x=>(a="1one1two1three1four1five1six1seven1eight1nine1ten1eleven1twelve1thir11fif111eigh".split(1),x<1?"zero":f(x-1)+(x<13?a[x]:x<20?(a[x]||a[x-10])+"teen":x>99?"one hundred":(x%10?a[x%10]+" and ":"")+(x<50?"twen1thir1for".split(1)[x/10-2|0]+"ty":(x%20>9?"half "+"third1forth1fifth".split(1)[x/20-2.5|0]:a[x/20|0])+" times twenty")))+"\n"
f(100)
</code>```

Still far away from optimal...

Title: Count to 100 in Danish

Body:
JavaScript (ES6), 346 bytes

Only a small idea to ETHproductions' solution:
Replace f(..) with a[..] to be able to call f recursively to concat the output.

f=x=>(a="1one1two1three1four1five1six1seven1eight1nine1ten1eleven1twelve1thir11fif111eigh".split(1),x<1?"zero":f(x-1)+(x<13?a[x]:x<20?(a[x]||a[x-10])+"teen":x>99?"one hundred":(x%10?a[x%10]+" and ":"")+(x<50?"twen1thir1for".split(1)[x/10-2|0]+"ty":(x%20>9?"half "+"third1forth1fifth".split(1)[x/20-2.5|0]:a[x/20|0])+" times twenty")))+"\n"
f(100)

Still far away from optimal...


答:
PHP, <s>333</s> <s>328</s> 321 bytes

@ETHproductions´s expression ported to PHP and golfed down. I am surprised that PHP can beat JavaScript without any builtins.

I guess the mightiest builtins are the implicit typecasts:

I need no quotes for most of the strings, that alone is worth 12 bytes;

and it allows me to use an array directly instead of splitting a string.

the array indexing is implicitly typecasting any floats to integer, saving 6 bytes.

BUT: I need $s (21 of them) to tell PHP that it´s a variable.

So it´s still unclear where the 15 bytes actually come from. I didn´t golf away that much. Or did I? ETH caught up.

```<code><?$a=[zero,one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,'',fifteen,'','',eighteen];for($n=-1;$n++<99;)echo$n>19?($n%10?$a[$n%10].' and ':'').($n>49?($n%20>9?"half ".[third,forth,fifth][$n/20-2.5]:$a[$n/20]).' times twenty':[twen,thir,'for'][$n/10-2].ty):($a[$n]?:$a[$n%10].teen),_;?>one hundred
</code>```

Title: Count to 100 in Danish

Body:
PHP, <s>333</s> <s>328</s> 321 bytes

@ETHproductions´s expression ported to PHP and golfed down. I am surprised that PHP can beat JavaScript without any builtins.

I guess the mightiest builtins are the implicit typecasts:

I need no quotes for most of the strings, that alone is worth 12 bytes;

and it allows me to use an array directly instead of splitting a string.

the array indexing is implicitly typecasting any floats to integer, saving 6 bytes.

BUT: I need $s (21 of them) to tell PHP that it´s a variable.

So it´s still unclear where the 15 bytes actually come from. I didn´t golf away that much. Or did I? ETH caught up.

<?$a=[zero,one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,'',fifteen,'','',eighteen];for($n=-1;$n++<99;)echo$n>19?($n%10?$a[$n%10].' and ':'').($n>49?($n%20>9?"half ".[third,forth,fifth][$n/20-2.5]:$a[$n/20]).' times twenty':[twen,thir,'for'][$n/10-2].ty):($a[$n]?:$a[$n%10].teen),_;?>one hundred


问:
I'm not the language you're looking for!
Isn't it annoying when you find a piece of code and you don't know what language it was written in? This challenge attempts to somewhat solve this.

Challenge

You will have to write a program that when run in two different languages, will output the string:

This program wasn't written in <language program compiled/interpreted in>, it was built for <other language the program can be run in>!

In the output, language names should have official capitalization. eg: CJam, C++

Neither program should take any input from the user.

When run in both languages, output should be to stdout or equivalent.

There should be no output to stderr in either program.

You may use comments in either language.

Two different versions of the same language count as different languages.

If this is done, the program should output the major version number, and if running on two different minor versions, should report the minor version also.

You should not use prebuilt version functions (this includes variables that have already been evaluated at runtime).

Example output:

Perl and Ruby:

Perl: This program wasn't written in Perl, it was built for Ruby!

Ruby: This program wasn't written in Ruby, it was built for Perl!

Python and C:

Python: This program wasn't written in Python, it was built for C!

C: This program wasn't written in C, it was built for Python!

Python 2 and Python 3:

Python 2: This program wasn't written in Python 2, it was built for Python 3!

Python 3: This program wasn't written in Python 3, it was built for Python 2!

Python 2.4 and Python 2.7:

Python 2.4: This program wasn't written in Python 2.4, it was built for Python 2.7!

Python 2.7: This program wasn't written in Python 2.7, it was built for Python 2.4!

This is code golf so the shortest code in bytes wins.

答:
JavaScript / Python3, 119 bytes

```<code>i=1//2
d=['print','console.log']
s=['python','js']
eval(d[i])('this program is not '+s[i]+', it was built for '+s[1-i])
</code>```

Tested on Node.js v6.x and Python 3.5.1

The trick was to use Python's "floor division" operator which is the same as JavaScript's line comment //. This is how we swap 0 and 1 for i depending on the language.

This won't work on python2 because print was not a function until python3 and therefore cannot be evaluated using eval. It should work for almost any JavaScript VM.

Edit

Golfed 7 bytes by removing j variable and using s[1-i] instead of s[j].

Body:
JavaScript / Python3, 119 bytes

i=1//2
d=['print','console.log']
s=['python','js']
eval(d[i])('this program is not '+s[i]+', it was built for '+s[1-i])

Tested on Node.js v6.x and Python 3.5.1

The trick was to use Python's "floor division" operator which is the same as JavaScript's line comment //. This is how we swap 0 and 1 for i depending on the language.

This won't work on python2 because print was not a function until python3 and therefore cannot be evaluated using eval. It should work for almost any JavaScript VM.

Edit

Golfed 7 bytes by removing j variable and using s[1-i] instead of s[j].


答:
T-SQL, 87 bytes

```<code>select substring(replicate('-~',abs(x)),case when x<0then 2 else 1 end,x*x+1)+'0'from #
</code>```

The x*x+1 condition in substring is sufficient, since x^2+1>=2*abs(x) for all x.

As usually in SQL, the input is stored in a table:

```<code>create table # (x int)

insert into # values (0)
insert into # values (1)
insert into # values (-1)
insert into # values (2)
insert into # values (-2)
</code>```

Title: Bitflip and negate

Body:
Given an integer, make an expression that produces it from 0 using unary negation - and bitwise complement ~ (~n = -n-1), with the operators applied right to left.

```<code>...
-3  = ~-~-~0
-2  = ~-~0
-1  = ~0
 0  = 0
 1  = -~0
 2  = -~-~0
 3  = -~-~-~0
...
</code>```

Your expression must be as short as possible, which means no redundant parts of ~~, --, -0, or 00. Output or print the expression as a string or a sequence of characters.

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
T-SQL, 87 bytes

select substring(replicate('-~',abs(x)),case when x<0then 2 else 1 end,x*x+1)+'0'from #

The x*x+1 condition in substring is sufficient, since x^2+1>=2*abs(x) for all x.

As usually in SQL, the input is stored in a table:

create table # (x int)

insert into # values (0)
insert into # values (1)
insert into # values (-1)
insert into # values (2)
insert into # values (-2)