问:
Encode an image inside of the source
The golf challenge is to encode and compress the following image inside a source file.

To do this you need to write 3 functions: red, green, and blue which accept x/y coordinates of the image and return the corresponding R/G/B pixel value between 0-255.

Here is the C/C++ test code:

```<code>#include <stdio.h>
#include "your_file"
int main() {
  int x, y;
  for(y = 0; y < 32; ++y)
  for(x = 0; x < 32; ++x)
    printf("%i %i %i\n", red(x, y), blue(x, y), green(x, y));
}
</code>```

And the output: http://pastebin.com/A770ckxL (you can use this to generate your image data)

Rules & details:

This is a golf

Only your code/file is golfed - the test code is separate

The character set used is ASCII, however control characters in strings may only be used if escaped (like '\n' and '\r', etc)

Everything must be contained inside the source - no file loading

Your output must match the example output. This means loseless compression.

Languages:

The problem was written with C/C++ in mind, but I'm removing those restrictions. With that said, I'll still recommend using them.

答:
PHP (5.4) - 822

I've done this deliberately not using any of the built-in compression functions. This solution is not finished, I'm not sure if I've given up, I can see areas for improvement but I can't find the time/willpower to refactor the whole thing at the moment, so I'm posting what I have so far.

Newlines + comments to be removed for 822 bytes.

```<code>// Colour map
$c=[0,16354410,4671418,6379596,7783255,5295994,5390379,3435360,9975021,5131894];

// Optimised RLE map
$r=array_merge(array_diff(range(10,89),[27,40,47,56,59,60,63,66,67,70,73,75,76,77,79,80,83,86]),[92,94,99,105,107,112,118,145]);

// Image data (base 70)
$e="CDsF<Fd]WPX<F0^VE0240GX02Fd;d_F0EFN0?;<onFE0H;2>0I404h0NZ@;>0460640>20<0E05050Q@;0GI0Gd`0H@?0eMqCjY?:51Z0QJjYu[ZD>0>:H:50Wk?;:PQ05M0ErDH;`]E0270707?DHg2VW[?DHg<MW[?c0;F032DN:<7:?0V0DX<0E0^K5:D01CXW0X<K7Ub:d03I3<A?Cp0^023I3<A?:T0Ta<>3I420A050B0Bt2G0=GAHbS0\:8i08Hbf9S0iAH9FBf09S>0YAH9=09IaLoAQO9IBA0ABiKQF09@CA03CP04K:H0ObAXK080AQIFT0B08XS:AHRm090BOlHI0";

// Expand image data
for($i=0;$i<352;$i++){$b=$r[ord($e[$i])-48];$l=(int)($b/10);while($l--)$d[]=$c[$b%10];}

// Colour retrieval functions
function red($x,$y){global$d;return$d[$x+$y*32]&0xff;}
function green($x,$y){global$d;return$d[$x+$y*32]>>8;}
function blue($x,$y){global$d;return($d[$x+$y*32]>>8)&0xff;}
</code>```

Test stub:

```<code>for ($y=0;$y<32;$y++) {
    for ($x=0;$x<32;$x++) {
        printf("%d %d %d\n", red($x, $y), blue($x, $y), green($x, $y));
    }
}
</code>```

The compression of the image data itself is pretty good, but the functions to retrieve RGB values take up 1/4 of the code.

I'm using a custom base70 + run length encoding mechanism.

There are 10 unique colours

Colours have run lengths between 1 and 14 (12 used).

There are 120 possible combinations.

There are only 70 unique run/colour combinations actually used.

The encoded image data references the array index of an RLE, which in turn indexes the array of colours. I'm not sure how much overhead this adds or subtracts over directly referencing the colours.

Sine there are 10 colours (0 to 9), RLEs are stored as run_length * 10 + colour_index. Giving a range of encodings between 10 and 145 without experimenting with optimisations based on colour ordering. (i.e. I could make the range 19 to 140 by moving colours 0 to 5, 5 to 9, and 9 to 0 - but this may have other knock-on effects)

A previous answer states their encoded data is 472 bytes. My encoded image data is 352 bytes, but the intermediate RLE / colour map (which is not binary encoded) is a further 129 bytes, putting the total at 481. (as well as additional overhead for joining up the two). However I suspect my method might scale better for larger images.

TODO:

Investigate binary encoding of RLE map

Find a way of reducing the size of the functions. global is a bitch, but can't access character indexes on constants.

Experiment with colour index ordering to see if RLE map size can be reduced with longer sequential runs of numbers

Potential 64bit specific optimisations of colour map? (r0 << 56 | r1 << 48 | ...)?

Experiment with vertical RLE to see if it results in a more compact set of encodings.

Area encoding?

Title: Encode an image inside of the source

Body:
PHP (5.4) - 822

I've done this deliberately not using any of the built-in compression functions. This solution is not finished, I'm not sure if I've given up, I can see areas for improvement but I can't find the time/willpower to refactor the whole thing at the moment, so I'm posting what I have so far.

Newlines + comments to be removed for 822 bytes.

// Colour map
$c=[0,16354410,4671418,6379596,7783255,5295994,5390379,3435360,9975021,5131894];

// Optimised RLE map
$r=array_merge(array_diff(range(10,89),[27,40,47,56,59,60,63,66,67,70,73,75,76,77,79,80,83,86]),[92,94,99,105,107,112,118,145]);

// Image data (base 70)
$e="CDsF<Fd]WPX<F0^VE0240GX02Fd;d_F0EFN0?;<onFE0H;2>0I404h0NZ@;>0460640>20<0E05050Q@;0GI0Gd`0H@?0eMqCjY?:51Z0QJjYu[ZD>0>:H:50Wk?;:PQ05M0ErDH;`]E0270707?DHg2VW[?DHg<MW[?c0;F032DN:<7:?0V0DX<0E0^K5:D01CXW0X<K7Ub:d03I3<A?Cp0^023I3<A?:T0Ta<>3I420A050B0Bt2G0=GAHbS0\:8i08Hbf9S0iAH9FBf09S>0YAH9=09IaLoAQO9IBA0ABiKQF09@CA03CP04K:H0ObAXK080AQIFT0B08XS:AHRm090BOlHI0";

// Expand image data
for($i=0;$i<352;$i++){$b=$r[ord($e[$i])-48];$l=(int)($b/10);while($l--)$d[]=$c[$b%10];}

// Colour retrieval functions
function red($x,$y){global$d;return$d[$x+$y*32]&0xff;}
function green($x,$y){global$d;return$d[$x+$y*32]>>8;}
function blue($x,$y){global$d;return($d[$x+$y*32]>>8)&0xff;}

Test stub:

for ($y=0;$y<32;$y++) {
    for ($x=0;$x<32;$x++) {
        printf("%d %d %d\n", red($x, $y), blue($x, $y), green($x, $y));
    }
}

The compression of the image data itself is pretty good, but the functions to retrieve RGB values take up 1/4 of the code.

I'm using a custom base70 + run length encoding mechanism.

There are 10 unique colours

Colours have run lengths between 1 and 14 (12 used).

There are 120 possible combinations.

There are only 70 unique run/colour combinations actually used.

The encoded image data references the array index of an RLE, which in turn indexes the array of colours. I'm not sure how much overhead this adds or subtracts over directly referencing the colours.

Sine there are 10 colours (0 to 9), RLEs are stored as run_length * 10 + colour_index. Giving a range of encodings between 10 and 145 without experimenting with optimisations based on colour ordering. (i.e. I could make the range 19 to 140 by moving colours 0 to 5, 5 to 9, and 9 to 0 - but this may have other knock-on effects)

A previous answer states their encoded data is 472 bytes. My encoded image data is 352 bytes, but the intermediate RLE / colour map (which is not binary encoded) is a further 129 bytes, putting the total at 481. (as well as additional overhead for joining up the two). However I suspect my method might scale better for larger images.

TODO:

Investigate binary encoding of RLE map

Find a way of reducing the size of the functions. global is a bitch, but can't access character indexes on constants.

Experiment with colour index ordering to see if RLE map size can be reduced with longer sequential runs of numbers

Potential 64bit specific optimisations of colour map? (r0 << 56 | r1 << 48 | ...)?

Experiment with vertical RLE to see if it results in a more compact set of encodings.

Area encoding?


问:
PKCS#7 padding validation
In cryptography, PKCS#7 padding is a padding scheme which adds a number of bytes N ≥ 1, where the value of each added byte is equal to N.

For example, Hello, World!, which has 13 bytes, is the following in hex:

```<code>48 65 6C 6C 6F 2C 20 57 6F 72 6C 64 21
</code>```

If we choose to PKCS#7 pad to length 16, then the result is:

```<code>48 65 6C 6C 6F 2C 20 57 6F 72 6C 64 21 03 03 03
</code>```

And if we choose to pad to length 20, then the result is:

```<code>48 65 6C 6C 6F 2C 20 57 6F 72 6C 64 21 07 07 07 07 07 07 07
</code>```

Note that in the first example we add three 03 bytes, and in the second we add seven 07 bytes.

Your task will be to validate whether a string (or integer array) has correct PKCS#7 padding. That is, if the last byte of the input string is N, then your program should check that the last N bytes of the string are equal to N.

Input

A single nonempty ASCII string containing characters between code points 1 and 127 inclusive. If you wish, you may take input as an array of integers instead.

Output

A truthy value if the input string has valid PKCS#7 padding, otherwise a falsy value.

Both functions and full programs are acceptable. This is code-golf, so the aim is to minimise the number of bytes in your code.

Test cases

The integer array version of inputs is presented here — the string version would have unprintable characters for many of the following test cases:

Truthy:

```<code>[1]
[1, 1]
[2, 1]
[2, 2]
[5, 6, 5, 3, 3, 3]
[1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2]
[95, 115, 80, 32, 71, 7, 122, 49, 13, 7, 7, 7, 7, 7, 7, 7, 7]
[27, 33, 54, 65, 97, 33, 52, 55, 60, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
[15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]
</code>```

Falsy:

```<code>[2]
[1, 2]
[5, 5, 5, 5]
[5, 6, 5, 4, 4, 4]
[3, 3, 3, 94, 3, 3]
[1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 127]
[50, 39, 94, 105, 49, 29, 74, 102, 2, 106, 44, 7, 7, 7, 7, 7, 7]
[26, 27, 59, 25, 122, 110, 20, 30, 114, 6, 9, 62, 121, 42, 22, 60, 33, 12]
</code>```

答:
Retina, 34 bytes

Byte count assumes ISO 8859-1 encoding.

```<code>.+
$*
\b(1(1)*)(?<-2>¶\1)*$(?(2)!)
</code>```

Input is a linefeed-separated list of integers. Prints 0 or 1.

Try it online! (The first line enables a test suite, where there is one space-separated test case per line.)

An alternative idea that ends up at 35 bytes and prints 0 or a positive integer:

```<code>.+
$*
\b(?=(1+)(¶\1)*$)(?<-2>1)*1\b
</code>```

ContentLicense: CC BY-SA 3.0

Title: PKCS#7 padding validation

Body:
Retina, 34 bytes

Byte count assumes ISO 8859-1 encoding.

.+
$*
\b(1(1)*)(?<-2>¶\1)*$(?(2)!)

Input is a linefeed-separated list of integers. Prints 0 or 1.

<a href="http://retina.tryitonline.net/#code=JShTYFxzCi4rCiQqClxiKDEoMSkqKSg_PC0yPsK2XDEpKiQoPygyKSEp&input=MQoxIDEKMiAxCjIgMgo1IDYgNSAzIDMgMwoxIDEgMiAyIDEgMSAyIDIgMSAxIDIgMgo5NSAxMTUgODAgMzIgNzEgNyAxMjIgNDkgMTMgNyA3IDcgNyA3IDcgNyA3CjI3IDMzIDU0IDY1IDk3IDMzIDUyIDU1IDYwIDEgMTAgMTAgMTAgMTAgMTAgMTAgMTAgMTAgMTAgMTAKMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUgMTUKMgoxIDIKNSA1IDUgNQo1IDYgNSA0IDQgNAozIDMgMyA5NCAzIDMKMSAyIDEgMiAxIDIgMSAyIDEgMiAxIDIKMSAxIDEgMSAxIDEgMSAxIDEgMSAxIDEgMSAxIDEgMSAxIDEgMSAxMjcKNTAgMzkgOTQgMTA1IDQ5IDI5IDc0IDEwMiAyIDEwNiA0NCA3IDcgNyA3IDcgNwoyNiAyNyA1OSAyNSAxMjIgMTEwIDIwIDMwIDExNCA2IDkgNjIgMTIxIDQyIDIyIDYwIDMzIDEy" rel="nofollow">Try it online! (The first line enables a test suite, where there is one space-separated test case per line.)

An alternative idea that ends up at 35 bytes and prints 0 or a positive integer:

.+
$*
\b(?=(1+)(¶\1)*$)(?<-2>1)*1\b


答:
Jelly, 5 bytes

```<code>ŒgṪṫṪ
</code>```

Input is an array of code points, output is a non-empty array (truthy) or an empty array (falsy).

Try it online! or verify all test cases.

How it works

```<code>ŒgṪṫṪ  Main link. Argument: A (array)

Œg     Group all runs of consecutive, equal integers.
  Ṫ    Tail; yield the last run. It should consist of n or more occurrences of n.
    Ṫ  Tail; yield n, the last element of A.
   ṫ   Dyadic tail; discard everything after the n-th element of the last run.
       If the last run was long enough, this will yield a non-empty array (truthy);
       if not, the result will be an empty array (falsy).
</code>```

Title: PKCS#7 padding validation

Body:
In cryptography, PKCS#7 padding is a padding scheme which adds a number of bytes N ≥ 1, where the value of each added byte is equal to N.

For example, Hello, World!, which has 13 bytes, is the following in hex:

```<code>48 65 6C 6C 6F 2C 20 57 6F 72 6C 64 21
</code>```

If we choose to PKCS#7 pad to length 16, then the result is:

```<code>48 65 6C 6C 6F 2C 20 57 6F 72 6C 64 21 03 03 03
</code>```

And if we choose to pad to length 20, then the result is:

```<code>48 65 6C 6C 6F 2C 20 57 6F 72 6C 64 21 07 07 07 07 07 07 07
</code>```

Note that in the first example we add three 03 bytes, and in the second we add seven 07 bytes.

Your task will be to validate whether a string (or integer array) has correct PKCS#7 padding. That is, if the last byte of the input string is N, then your program should check that the last N bytes of the string are equal to N.

Input

A single nonempty ASCII string containing characters between code points 1 and 127 inclusive. If you wish, you may take input as an array of integers instead.

Output

A truthy value if the input string has valid PKCS#7 padding, otherwise a falsy value.

Both functions and full programs are acceptable. This is code-golf, so the aim is to minimise the number of bytes in your code.

Test cases

The integer array version of inputs is presented here — the string version would have unprintable characters for many of the following test cases:

Truthy:

```<code>[1]
[1, 1]
[2, 1]
[2, 2]
[5, 6, 5, 3, 3, 3]
[1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2]
[95, 115, 80, 32, 71, 7, 122, 49, 13, 7, 7, 7, 7, 7, 7, 7, 7]
[27, 33, 54, 65, 97, 33, 52, 55, 60, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
[15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]
</code>```

Falsy:

```<code>[2]
[1, 2]
[5, 5, 5, 5]
[5, 6, 5, 4, 4, 4]
[3, 3, 3, 94, 3, 3]
[1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 127]
[50, 39, 94, 105, 49, 29, 74, 102, 2, 106, 44, 7, 7, 7, 7, 7, 7]
[26, 27, 59, 25, 122, 110, 20, 30, 114, 6, 9, 62, 121, 42, 22, 60, 33, 12]
</code>```

Body:
Jelly, 5 bytes

ŒgṪṫṪ

Input is an array of code points, output is a non-empty array (truthy) or an empty array (falsy).

Try it online! or <a href="http://jelly.tryitonline.net/#code=xZJn4bmq4bmr4bmqCjEgMMOHP8K14oKs4oKsRw&input=&args=W1sKIFsxXSwKIFsxLCAxXSwKIFsyLCAxXSwKIFsyLCAyXSwKIFs1LCA2LCA1LCAzLCAzLCAzXSwKIFsxLCAxLCAyLCAyLCAxLCAxLCAyLCAyLCAxLCAxLCAyLCAyXSwKIFs5NSwgMTE1LCA4MCwgMzIsIDcxLCA3LCAxMjIsIDQ5LCAxMywgNywgNywgNywgNywgNywgNywgNywgN10sCiBbMjcsIDMzLCA1NCwgNjUsIDk3LCAzMywgNTIsIDU1LCA2MCwgMSwgMTAsIDEwLCAxMCwgMTAsIDEwLCAxMCwgMTAsIDEwLCAxMCwgMTBdLAogWzE1LCAxNSwgMTUsIDE1LCAxNSwgMTUsIDE1LCAxNSwgMTUsIDE1LCAxNSwgMTUsIDE1LCAxNSwgMTUsIDE1LCAxNSwgMTUsIDE1LCAxNV0KXSxbCiBbMl0sCiBbMSwgMl0sCiBbNSwgNSwgNSwgNV0sCiBbNSwgNiwgNSwgNCwgNCwgNF0sCiBbMywgMywgMywgOTQsIDMsIDNdLAogWzEsIDIsIDEsIDIsIDEsIDIsIDEsIDIsIDEsIDIsIDEsIDJdLAogWzEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEyN10sCiBbNTAsIDM5LCA5NCwgMTA1LCA0OSwgMjksIDc0LCAxMDIsIDIsIDEwNiwgNDQsIDcsIDcsIDcsIDcsIDcsIDddLAogWzI2LCAyNywgNTksIDI1LCAxMjIsIDExMCwgMjAsIDMwLCAxMTQsIDYsIDksIDYyLCAxMjEsIDQyLCAyMiwgNjAsIDMzLCAxMl0KXV0" rel="nofollow">verify all test cases.

How it works

ŒgṪṫṪ  Main link. Argument: A (array)

Œg     Group all runs of consecutive, equal integers.
  Ṫ    Tail; yield the last run. It should consist of n or more occurrences of n.
    Ṫ  Tail; yield n, the last element of A.
   ṫ   Dyadic tail; discard everything after the n-th element of the last run.
       If the last run was long enough, this will yield a non-empty array (truthy);
       if not, the result will be an empty array (falsy).


答:
Pyth, 5 bytes

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

RLE  on input, take the last pair and check if the number of repeats is greater or equal than the value.

Try it online: Demonstration or Test Suite

Title: PKCS#7 padding validation

Body:
Pyth, 5 bytes

gFer8

RLE  on input, take the last pair and check if the number of repeats is greater or equal than the value.

Try it online: <a href="http://pyth.herokuapp.com/?code=gFer8&input=%5B95%2C%20115%2C%2080%2C%2032%2C%2071%2C%207%2C%20122%2C%2049%2C%2013%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%5D&test_suite_input=%5B1%5D%0A%5B1%2C%201%5D%0A%5B2%2C%201%5D%0A%5B2%2C%202%5D%0A%5B5%2C%206%2C%205%2C%203%2C%203%2C%203%5D%0A%5B1%2C%201%2C%202%2C%202%2C%201%2C%201%2C%202%2C%202%2C%201%2C%201%2C%202%2C%202%5D%0A%5B95%2C%20115%2C%2080%2C%2032%2C%2071%2C%207%2C%20122%2C%2049%2C%2013%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%5D%0A%5B27%2C%2033%2C%2054%2C%2065%2C%2097%2C%2033%2C%2052%2C%2055%2C%2060%2C%201%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%5D%0A%5B15%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%5D%0A%5B2%5D%0A%5B1%2C%202%5D%0A%5B5%2C%205%2C%205%2C%205%5D%0A%5B5%2C%206%2C%205%2C%204%2C%204%2C%204%5D%0A%5B3%2C%203%2C%203%2C%2094%2C%203%2C%203%5D%0A%5B1%2C%202%2C%201%2C%202%2C%201%2C%202%2C%201%2C%202%2C%201%2C%202%2C%201%2C%202%5D%0A%5B1%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%20127%5D%0A%5B50%2C%2039%2C%2094%2C%20105%2C%2049%2C%2029%2C%2074%2C%20102%2C%202%2C%20106%2C%2044%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%5D%0A%5B26%2C%2027%2C%2059%2C%2025%2C%20122%2C%20110%2C%2020%2C%2030%2C%20114%2C%206%2C%209%2C%2062%2C%20121%2C%2042%2C%2022%2C%2060%2C%2033%2C%2012%5D&debug=0">Demonstration or <a href="http://pyth.herokuapp.com/?code=gFer8&input=%5B95%2C%20115%2C%2080%2C%2032%2C%2071%2C%207%2C%20122%2C%2049%2C%2013%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%5D&test_suite=1&test_suite_input=%5B1%5D%0A%5B1%2C%201%5D%0A%5B2%2C%201%5D%0A%5B2%2C%202%5D%0A%5B5%2C%206%2C%205%2C%203%2C%203%2C%203%5D%0A%5B1%2C%201%2C%202%2C%202%2C%201%2C%201%2C%202%2C%202%2C%201%2C%201%2C%202%2C%202%5D%0A%5B95%2C%20115%2C%2080%2C%2032%2C%2071%2C%207%2C%20122%2C%2049%2C%2013%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%5D%0A%5B27%2C%2033%2C%2054%2C%2065%2C%2097%2C%2033%2C%2052%2C%2055%2C%2060%2C%201%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%5D%0A%5B15%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%5D%0A%5B2%5D%0A%5B1%2C%202%5D%0A%5B5%2C%205%2C%205%2C%205%5D%0A%5B5%2C%206%2C%205%2C%204%2C%204%2C%204%5D%0A%5B3%2C%203%2C%203%2C%2094%2C%203%2C%203%5D%0A%5B1%2C%202%2C%201%2C%202%2C%201%2C%202%2C%201%2C%202%2C%201%2C%202%2C%201%2C%202%5D%0A%5B1%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%20127%5D%0A%5B50%2C%2039%2C%2094%2C%20105%2C%2049%2C%2029%2C%2074%2C%20102%2C%202%2C%20106%2C%2044%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%5D%0A%5B26%2C%2027%2C%2059%2C%2025%2C%20122%2C%20110%2C%2020%2C%2030%2C%20114%2C%206%2C%209%2C%2062%2C%20121%2C%2042%2C%2022%2C%2060%2C%2033%2C%2012%5D&debug=0">Test Suite


问:
The Letter A without A
Your task is to display the letter "A" alone, without anything else, except any form of trailing newlines if you cannot avoid them, doing so in a program and/or snippet. Code that returns (instead of printing) is allowed.

Both the lowercase and uppercase versions of the letter "A" are acceptable (that is, unicode U+0061 or unicode U+0041. Other character encodings that aren't Unicode are allowed, but either way, the resulting output of your code must be the latin letter "A", and not any lookalikes or homoglyphs)

You must not use any of the below characters in your code, regardless of the character encoding that you pick:

"A", whether uppercase or lowercase.

"U", whether lowercase or uppercase.

X, whether uppercase or lowercase.

+

&

#

0

1

4

5

6

7

9

Cheating, loopholes, etc, are not allowed.

Since this is code-golf, the shortest solution, in bytes, that follows all the rules, is the winner.

Validity Checker

This Stack Snippet checks to make sure your code doesn't use the restricted characters. It might not work properly for some character encodings.

var t = prompt("Input your code.");

if (/[AaUuXx+&#0145679]/.test(t)) {
  alert("Contains a disallowed character!");
} else {
  alert("No disallowed characters");
}```
</div>
</div>
</p>

<p><em>This Stack Snippet that makes sure you don't have a disallowed character is also available on JSFiddle.</em></p>

<h3>Leaderboard</h3>

<p><div class="snippet" data-lang="js" data-hide="true" data-console="false" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var QUESTION_ID=90349,OVERRIDE_USER=58717;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});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;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>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;</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}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td>Link</td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td>Link</td></tr></tbody> </table></code>```

答:
Verbosy, 13 bytes

```<code>~` /3 ^3 \3 o
</code>```

Verbosy is actually a language I wrote (see the link). Hopefully that's allowed...

Explanation:

~`: set <code>Current</code> to the <code>` character.

/3: put the ` character into slot 3

^3: increment the character in slot 3 by 1

\3: put the character in slot 3 into Current

o: prints Current

Title: The Letter A without A

Body:
Verbosy, 13 bytes

~` /3 ^3 \3 o

Verbosy is actually a language I wrote (see the link). Hopefully that's allowed...

Explanation:

~`: set <code>Current</code> to the <code>` character.

/3: put the ` character into slot 3

^3: increment the character in slot 3 by 1

\3: put the character in slot 3 into Current

o: prints Current


答:
Batch, 101 bytes

```<code>@for %%a in (%*)do @set/an=%%a,c=0
@for %%a in (%*)do @set/ac+=1,c*=!(n-%%a)
@if %c% geq %n% echo 1
</code>```

Takes input as command-line parameters, loops over them all so that it can get the last one into n, loops over them all again to count the run of trailing ns, finally printing 1 if the count is at least equal to n. Alternatively if printing 0 or a non-zero value is acceptable, then for 93 bytes, change the last line to @cmd/cset/ac/n.

Title: PKCS#7 padding validation

Body:
Batch, 101 bytes

@for %%a in (%*)do @set/an=%%a,c=0
@for %%a in (%*)do @set/ac+=1,c*=!(n-%%a)
@if %c% geq %n% echo 1

Takes input as command-line parameters, loops over them all so that it can get the last one into n, loops over them all again to count the run of trailing ns, finally printing 1 if the count is at least equal to n. Alternatively if printing 0 or a non-zero value is acceptable, then for 93 bytes, change the last line to @cmd/cset/ac/n.


答:
Pyke, 7 bytes

```<code>eQ>}lt!
</code>```

Try it here!

Title: PKCS#7 padding validation

Body:
Pyke, 7 bytes

eQ>}lt!

Try it here!


答:
Javascript (ES5), 89 bytes

```<code>function(b){for(var d=b[b.length-1],c=0;c<d;c++)if(b[b.length-c-1]!=d)return!1;return!0};
</code>```

Ungolfed:

```<code>function a(arr){
var b=arr[arr.length-1];
for(var i=0;i<b;i++){
    if(arr[arr.length-i-1]!=b)return false;
}
return true;
}
</code>```

Title: PKCS#7 padding validation

Body:
Javascript (ES5), 89 bytes

function(b){for(var d=b[b.length-1],c=0;c<d;c++)if(b[b.length-c-1]!=d)return!1;return!0};

Ungolfed:

function a(arr){
var b=arr[arr.length-1];
for(var i=0;i<b;i++){
    if(arr[arr.length-i-1]!=b)return false;
}
return true;
}


问:
How can I get a repdigit?
In honor of how much rep I had several hours ago, when I first thought of this challenge:

Numbers like this that are made up of a single digit repeating are called repdigits. Repdigits are fun! Every body would be more happy if the amount of rep they had was a repdigit¹, but I am impatient, so you need to help me find out the fastest way to get to a repdigit.

Here is your challenge:

Given a positive integers representing reputation, output the minimum amount of rep they need to gain to get to a repdigit. For example, at the time of writing this challenge, user Martin Ender had 102,856 rep. The nearest rep-digit is 111,111, so he would need to gain: 8255 rep to be at a repdigit.

Since people dislike losing rep, we will only consider non-negative changes. This means that, for example, if someone is at 12 rep, rather than losing 1 rep, the solution is to gain 10 rep. This allows '0' to be a valid output, since anyone who has 111 rep is already at a repdigit.

Input and output can be in any reasonable format, and since it is impossible to have less than 1 rep on any Stack Exchange site, you can assume no inputs will be less than 1.

One cornercase to note:

If a user has less than 10 rep, they are already at a repdigit, and so they also need '0'.

Test IO:

```<code>#Input      #Ouput
8           0
100         11
113         109
87654321    1234567
42          2
20000       2222
11132       11090
</code>```

Standard loopholes apply, and the shortest solution in bytes wins!

答:
GNU sed, 223 + 1(r flag) = 224 bytes

s/$/:0%/
:;y/:%/%:/
/^(.)\1*%/{s/.*%(.*):/\1/;q}
:f;s/9(@*:)/@\1/;tf
s/8(@*:)/9\1/;s/7(@*:)/8\1/
s/6(@*:)/7\1/;s/5(@*:)/6\1/
s/4(@*:)/5\1/;s/3(@*:)/4\1/
s/2(@*:)/3\1/;s/1(@*:)/2\1/
s/0(@*:)/1\1/;s/(^|%)(@*:)/\11\2/
y/@/0/;t
```

<p><strong>Run:</strong></p>

<pre class="lang-sh prettyprint-override"><code>sed -rf repdigit.sed <<< "112"
</code>```

Output:

110
```

This is a pure sed solution, the arithmetic is simulated using regular expressions only. The algorithm works as follows:

the pattern space format is set to ^current_reputation:needed_reputation%$

in each iteration of the main loop the separators are switched:

a) %: applies the increment to needed_reputation

b) :% applies the increment to current_reputation

if the current_reputation is a "repdigit", the needed_reputation is printed and the program ends

Title: How can I get a repdigit?

Body:
GNU sed, 223 + 1(r flag) = 224 bytes

s/$/:0%/
:;y/:%/%:/
/^(.)\1*%/{s/.*%(.*):/\1/;q}
:f;s/9(@*:)/@\1/;tf
s/8(@*:)/9\1/;s/7(@*:)/8\1/
s/6(@*:)/7\1/;s/5(@*:)/6\1/
s/4(@*:)/5\1/;s/3(@*:)/4\1/
s/2(@*:)/3\1/;s/1(@*:)/2\1/
s/0(@*:)/1\1/;s/(^|%)(@*:)/\11\2/
y/@/0/;t

Run:

sed -rf repdigit.sed <<< "112"

Output:

110

This is a pure sed solution, the arithmetic is simulated using regular expressions only. The algorithm works as follows:

the pattern space format is set to ^current_reputation:needed_reputation%$

in each iteration of the main loop the separators are switched:

a) %: applies the increment to needed_reputation

b) :% applies the increment to current_reputation

if the current_reputation is a "repdigit", the needed_reputation is printed and the program ends


答:
Python, 188 bytes

This is a further shortened version of my winning submission for CodeSprint Sudoku, modified for command line input instead of stdin (as per the OP):

```<code>def f(s):
 x=s.find('0')
 if x<0:print s;exit()
 [c in[(x-y)%9*(x/9^y/9)*(x/27^y/27|x%9/3^y%9/3)or s[y]for y in range(81)]or f(s[:x]+c+s[x+1:])for c in'%d'%5**18]
import sys
f(sys.argv[1])
</code>```

If you're using Python 2, '%d'%5**18 can be replaced with `5**18` to save 3 bytes.

To make it run faster, you can replace '%d'%5**18 with any permutation of '123456789' at a cost of 1 byte.

If you want it to accept the input on stdin instead, you can replace import sys;f(sys.argv[1]) with f(raw_input()), bringing it down to 177 bytes.

```<code>def f(s):
 x=s.find('0')
 if x<0:print s;exit()
 [c in[(x-y)%9*(x/9^y/9)*(x/27^y/27|x%9/3^y%9/3)or s[y]for y in range(81)]or f(s[:x]+c+s[x+1:])for c in'%d'%5**18]
f(raw_input())
</code>```

EDIT: Here's a link to a more detailed walkthrough.

ContentLicense: CC BY-SA 2.5

Title: Implement a Brute Force Sudoku Solver

Body:
Implement the shortest Sudoku solver using guessing. Since I have received a few request I have added this as an alternative question for those wishing to implement a brute force sudoku solver.

Sudoku Puzzle:

```<code> | 1 2 3 | 4 5 6 | 7 8 9
-+-----------------------
A|   3   |     1 |
B|     6 |       |   5
C| 5     |       | 9 8 3
-+-----------------------
D|   8   |     6 | 3   2
E|       |   5   |
F| 9   3 | 8     |   6
-+-----------------------
G| 7 1 4 |       |     9
H|   2   |       | 8
I|       | 4     |   3
</code>```

Answer:

```<code> | 1 2 3 | 4 5 6 | 7 8 9
-+-----------------------
A| 8 3 2 | 5 9 1 | 6 7 4
B| 4 9 6 | 3 8 7 | 2 5 1
C| 5 7 1 | 2 6 4 | 9 8 3
-+-----------------------
D| 1 8 5 | 7 4 6 | 3 9 2
E| 2 6 7 | 9 5 3 | 4 1 8
F| 9 4 3 | 8 1 2 | 7 6 5
-+-----------------------
G| 7 1 4 | 6 3 8 | 5 2 9
H| 3 2 9 | 1 7 5 | 8 4 6
I| 6 5 8 | 4 2 9 | 1 3 7
</code>```

Rules:

Assume all mazes are solvable by logic only.

All input will be 81 characters long. Missing characters will be 0.

Output the solution as a single string.

The "grid" may be stored internally however you wish.

The solution must using a brute force guessing solution.

Solutions should solve within a reasonable time limit.

Example I/O:

```<code>>sudoku.py "030001000006000050500000983080006302000050000903800060714000009020000800000400030"
832591674496387251571264983185746392267953418943812765714638529329175846658429137
</code>```

Body:
Python, 188 bytes

This is a further shortened version of my winning submission for CodeSprint Sudoku, modified for command line input instead of stdin (as per the OP):

def f(s):
 x=s.find('0')
 if x<0:print s;exit()
 [c in[(x-y)%9*(x/9^y/9)*(x/27^y/27|x%9/3^y%9/3)or s[y]for y in range(81)]or f(s[:x]+c+s[x+1:])for c in'%d'%5**18]
import sys
f(sys.argv[1])

If you're using Python 2, '%d'%5**18 can be replaced with `5**18` to save 3 bytes.

To make it run faster, you can replace '%d'%5**18 with any permutation of '123456789' at a cost of 1 byte.

If you want it to accept the input on stdin instead, you can replace import sys;f(sys.argv[1]) with f(raw_input()), bringing it down to 177 bytes.

def f(s):
 x=s.find('0')
 if x<0:print s;exit()
 [c in[(x-y)%9*(x/9^y/9)*(x/27^y/27|x%9/3^y%9/3)or s[y]for y in range(81)]or f(s[:x]+c+s[x+1:])for c in'%d'%5**18]
f(raw_input())

EDIT: Here's a link to a more detailed walkthrough.


问:
Brainf*ck Loop Problem
I have a problem for a cyber club that asks you to print:

```<code>ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#"!
</code>```

Using Brainf**k in 29 bytes or less without using the ',' character.

I have a working code:

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

However my loop is too long, sending me 16 bytes over the limit.

Is there a more efficient way to set the second and third cell to 58 and 90 so I can run my second loop? Or is there a better way to do this all together that I am just not seeing?

答:
34 bytes

Saved you 11 bytes, but still 5 bytes too long...

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

I've spent hours already, hopefully someone can improve on this.

Title: Brainf*ck Loop Problem

Body:
34 bytes

Saved you 11 bytes, but still 5 bytes too long...

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

I've spent hours already, hopefully someone can improve on this.


Title: How can I get a repdigit?

Body:
In honor of how much rep I had several hours ago, when I first thought of this challenge:

Numbers like this that are made up of a single digit repeating are called repdigits. Repdigits are fun! Every body would be more happy if the amount of rep they had was a repdigit¹, but I am impatient, so you need to help me find out the fastest way to get to a repdigit.

Here is your challenge:

Given a positive integers representing reputation, output the minimum amount of rep they need to gain to get to a repdigit. For example, at the time of writing this challenge, user Martin Ender had 102,856 rep. The nearest rep-digit is 111,111, so he would need to gain: 8255 rep to be at a repdigit.

Since people dislike losing rep, we will only consider non-negative changes. This means that, for example, if someone is at 12 rep, rather than losing 1 rep, the solution is to gain 10 rep. This allows '0' to be a valid output, since anyone who has 111 rep is already at a repdigit.

Input and output can be in any reasonable format, and since it is impossible to have less than 1 rep on any Stack Exchange site, you can assume no inputs will be less than 1.

One cornercase to note:

If a user has less than 10 rep, they are already at a repdigit, and so they also need '0'.

Test IO:

```<code>#Input      #Ouput
8           0
100         11
113         109
87654321    1234567
42          2
20000       2222
11132       11090
</code>```

Standard loopholes apply, and the shortest solution in bytes wins!

Body:
C, 84 bytes

d,n,l,f;F(i){for(n=0;1;){l=i+n++;d=l%10;f=0;while(l/=10)f|=l%10-d;if(!f)return--n;}}

Test main:

int main() {
  printf("%d\n", F(8));
  printf("%d\n", F(100));
  printf("%d\n", F(113));
  printf("%d\n", F(87654321));
  printf("%d\n", F(47));
  printf("%d\n", F(20000));
  printf("%d\n", F(11132));
}


答:
30 bytes

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

Try it online!

85 and 171 are fairly easy to generate in brainfuck (modular inverses of 3 and -3). 85 is pretty close to 90, and 171 is pretty close to 177 (59·3), which is used here. With a bit of hackery, I'm able to produce 88 and 176 instead.

Still one byte short of the target, though.

Other suggestions

In general, it's shorter to iterate over a list, multiplying by a constant, rather than the other way. This is especially true for 3 or more values. For example, this:

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

can be written as:

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

There were only two inner values, so it's not much of an improvement in this case. In fact, just refactoring is one byte shorter:

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

Multiplying 30 by 2 and 3, rather than 10 by 6 and 9. With Martin Büttner's suggestion, this is already down to 38 bytes, without much change to the original:

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

Title: Brainf*ck Loop Problem

Body:
I have a problem for a cyber club that asks you to print:

```<code>ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#"!
</code>```

Using Brainf**k in 29 bytes or less without using the ',' character.

I have a working code:

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

However my loop is too long, sending me 16 bytes over the limit.

Is there a more efficient way to set the second and third cell to 58 and 90 so I can run my second loop? Or is there a better way to do this all together that I am just not seeing?

Body:
30 bytes

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

Try it online!

85 and 171 are fairly easy to generate in brainfuck (modular inverses of 3 and -3). 85 is pretty close to 90, and 171 is pretty close to 177 (59·3), which is used here. With a bit of hackery, I'm able to produce 88 and 176 instead.

Still one byte short of the target, though.

Other suggestions

In general, it's shorter to iterate over a list, multiplying by a constant, rather than the other way. This is especially true for 3 or more values. For example, this:

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

can be written as:

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

There were only two inner values, so it's not much of an improvement in this case. In fact, just refactoring is one byte shorter:

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

Multiplying 30 by 2 and 3, rather than 10 by 6 and 9. With Martin Büttner's suggestion, this is already down to 38 bytes, without much change to the original:

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


答:
Vim, 2 Keystrokes

vim -u NONE then run the following (-u NONE turns off customization)

```<code>i<up>
</code>```

When vim is run in compatible mode the arrow keys are don't get interpreted properly. <up> gets interpreted <esc>OA which leave the following in insert mode. Which would leave (with a couple of trailing newlines)

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

i starts insert mode.

<up> exits insert mode, opens a line above and enters A into the buffer

Example of people encountering this in the wild. https://stackoverflow.com/questions/6987317/while-moving-the-cursor-across-a-vim-process-open-in-a-tmux-session-every-now-a/6988748#6988748

Title: The Letter A without A

Body:
Your task is to display the letter "A" alone, without anything else, except any form of trailing newlines if you cannot avoid them, doing so in a program and/or snippet. Code that returns (instead of printing) is allowed.

Both the lowercase and uppercase versions of the letter "A" are acceptable (that is, unicode U+0061 or unicode U+0041. Other character encodings that aren't Unicode are allowed, but either way, the resulting output of your code must be the latin letter "A", and not any lookalikes or homoglyphs)

You must not use any of the below characters in your code, regardless of the character encoding that you pick:

"A", whether uppercase or lowercase.

"U", whether lowercase or uppercase.

X, whether uppercase or lowercase.

+

&

#

0

1

4

5

6

7

9

Cheating, loopholes, etc, are not allowed.

Since this is code-golf, the shortest solution, in bytes, that follows all the rules, is the winner.

Validity Checker

This Stack Snippet checks to make sure your code doesn't use the restricted characters. It might not work properly for some character encodings.

var t = prompt("Input your code.");

if (/[AaUuXx+&#0145679]/.test(t)) {
  alert("Contains a disallowed character!");
} else {
  alert("No disallowed characters");
}```
</div>
</div>
</p>

<p><em>This Stack Snippet that makes sure you don't have a disallowed character is also available on JSFiddle.</em></p>

<h3>Leaderboard</h3>

<p><div class="snippet" data-lang="js" data-hide="true" data-console="false" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var QUESTION_ID=90349,OVERRIDE_USER=58717;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});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;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>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;</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}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td>Link</td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td>Link</td></tr></tbody> </table></code>```

Body:
Vim, 2 Keystrokes

vim -u NONE then run the following (-u NONE turns off customization)

i<up>

When vim is run in compatible mode the arrow keys are don't get interpreted properly. <up> gets interpreted <esc>OA which leave the following in insert mode. Which would leave (with a couple of trailing newlines)

A

i starts insert mode.

<up> exits insert mode, opens a line above and enters A into the buffer

Example of people encountering this in the wild. https://stackoverflow.com/questions/6987317/while-moving-the-cursor-across-a-vim-process-open-in-a-tmux-session-every-now-a/6988748#6988748


问:
This isn't rocket science
Write a program or function that takes in a single-line string. You can assume it only contains printable ASCII. Print or return a string of an ASCII art rocket such as

```<code>  |
 /_\
 |E|
 |a|
 |r|
 |t|
 |h|
 |_|
/___\
 VvV
</code>```

with the input string written from top to bottom on the fuselage. In this case the input was Earth. The height of the rocket (including flames) is always the length of the string plus five.

Each line in the output may have up to two trailing spaces and there may be a single optional trailing newline. The shortest code in bytes wins.

More Examples:

```<code>[empty string]

  |
 /_\
 |_|
/___\
 VvV

a

  |
 /_\
 |a|
 |_|
/___\
 VvV

|0

  |
 /_\
 |||
 |0|
 |_|
/___\
 VvV

\/\

  |
 /_\
 |\|
 |/|
 |\|
 |_|
/___\
 VvV

 _ _ [note trailing space]

  |
 /_\
 | |
 |_|
 | |
 |_|
 | |
 |_|
/___\
 VvV

    [4 spaces]

  |
 /_\
 | |
 | |
 | |
 | |
 |_|
/___\
 VvV

SPACEY

  |
 /_\
 |S|
 |P|
 |A|
 |C|
 |E|
 |Y|
 |_|
/___\
 VvV
</code>```

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
R, 101 bytes

This is an improvement on Frédéric's answer. I eliminated the variable definition, the for-loop, and the need for the sep="" argument.

```<code>cat("  |\n /_\\\n",sapply(strsplit(scan(,""),""),function(x)paste0("|",x,"|\n")),"|_|\n/___\\\n VvV")
</code>```

Ungolfed:

```<code>cat("  |\n /_\\\n",                      # Print top of rocket
    sapply(
      strsplit(scan(,""),""),            # Take stdin and convert to list of chars
      function(x)paste0("|",x,"|\n")),   # Print letters
    ,"|_|\n/___\\\n VvV")                # Print bottom and FLAMES
</code>```

I'm sure that there is still some improvement possible.

Title: This isn't rocket science

Body:
R, 101 bytes

This is an improvement on Frédéric's answer. I eliminated the variable definition, the for-loop, and the need for the sep="" argument.

cat("  |\n /_\\\n",sapply(strsplit(scan(,""),""),function(x)paste0("|",x,"|\n")),"|_|\n/___\\\n VvV")

Ungolfed:

cat("  |\n /_\\\n",                      # Print top of rocket
    sapply(
      strsplit(scan(,""),""),            # Take stdin and convert to list of chars
      function(x)paste0("|",x,"|\n")),   # Print letters
    ,"|_|\n/___\\\n VvV")                # Print bottom and FLAMES

I'm sure that there is still some improvement possible.


答:
GolfScript, 61 51 bytes

My first code golf, I hope it is good enough.

```<code>"  |
 /_\\
"\1/.,{" |"\(\"|
"\}\*" |_|
/___\\
 VvV"
</code>```

Explanation

```<code>"  |\n /_\\\n"   # Push the rocket's head
\                # Swap the head with the user's string
1/               # The string is converted into an array
.,               # Push array length
{" |"\           # Push the rocket's body and swap
(\               # Array's first element cut out
"|\n"\           # Push rocket's body and swap
}\*              # Repeat for array length times
" |_|\n/___\\\n VvV" # Push rocket's bottom
</code>```

Try it online!

Title: This isn't rocket science

Body:
Write a program or function that takes in a single-line string. You can assume it only contains printable ASCII. Print or return a string of an ASCII art rocket such as

```<code>  |
 /_\
 |E|
 |a|
 |r|
 |t|
 |h|
 |_|
/___\
 VvV
</code>```

with the input string written from top to bottom on the fuselage. In this case the input was Earth. The height of the rocket (including flames) is always the length of the string plus five.

Each line in the output may have up to two trailing spaces and there may be a single optional trailing newline. The shortest code in bytes wins.

More Examples:

```<code>[empty string]

  |
 /_\
 |_|
/___\
 VvV

a

  |
 /_\
 |a|
 |_|
/___\
 VvV

|0

  |
 /_\
 |||
 |0|
 |_|
/___\
 VvV

\/\

  |
 /_\
 |\|
 |/|
 |\|
 |_|
/___\
 VvV

 _ _ [note trailing space]

  |
 /_\
 | |
 |_|
 | |
 |_|
 | |
 |_|
/___\
 VvV

    [4 spaces]

  |
 /_\
 | |
 | |
 | |
 | |
 |_|
/___\
 VvV

SPACEY

  |
 /_\
 |S|
 |P|
 |A|
 |C|
 |E|
 |Y|
 |_|
/___\
 VvV
</code>```

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
GolfScript, 61 51 bytes

My first code golf, I hope it is good enough.

"  |
 /_\\
"\1/.,{" |"\(\"|
"\}\*" |_|
/___\\
 VvV"

Explanation

"  |\n /_\\\n"   # Push the rocket's head
\                # Swap the head with the user's string
1/               # The string is converted into an array
.,               # Push array length
{" |"\           # Push the rocket's body and swap
(\               # Array's first element cut out
"|\n"\           # Push rocket's body and swap
}\*              # Repeat for array length times
" |_|\n/___\\\n VvV" # Push rocket's bottom

Try it online!


问:
Print a 10 by 10 grid of asterisks

Background

This is a standard textbook example to demonstrate for loops.

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

Task

You are to print this exact text:

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

Specs

You may have extra trailing newlines.

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

Scoring

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

答:
TI-Basic, 21 bytes

```<code>For(I,0,9
Disp "**********
End
</code>```

Title: Print a 10 by 10 grid of asterisks

Body:
TI-Basic, 21 bytes

For(I,0,9
Disp "**********
End


问:
Smallest palindrome divisible by the input
Given a positive integer N, output the smallest positive integer such that this number is a palindrome (i.e. is its own reverse) and is divisible by N.

The palindrome (i.e. the output) must not need a leading zero to be a palindrome, e.g. 080 is not the valid answer for 16.

The input will never be a multiple of 10, because of the previous reason.

Your program may take as much time as necessary, even if in practice it would be way too long to output the answer.

Inputs and outputs

You may take the input through STDIN, as a function argument, or anything similar.

You may print the output to STDOUT, return it from a function, or anything similar.

Inputs and outputs must be in the decimal base.

Test cases

```<code>N        Output
1        1
2        2
16       272
17       272
42       252
111      111
302      87278
1234     28382
</code>```

Scoring

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

Body:
C, not 83, 80 bytes

f(n,b,k,z){for(b=1;;){for(z=0,k=b*n;z+=k%10,k/=10;z*=10);if(b++*n==z)return z;}}

For say the true i had seen in one other puzzle one programmer use the same algo number=swapped(number) => number is palindrome. How is possible to edit barred
text?

#include <stdio.h>
main()
{unsigned  a[]={0,1,2,3,16,17,42,111,302,1234}, i;
 for(i=0;i<10;++i)
   printf("f(a[%u])=f(%u)=%u\n", i, a[i], f(a[i], 0, 0, 0));
 return 0;
}

/*
 f(a[0])=f(0)=0
 f(a[1])=f(1)=1
 f(a[2])=f(2)=2
 f(a[3])=f(3)=3
 f(a[4])=f(16)=272
 f(a[5])=f(17)=272
 f(a[6])=f(42)=252
 f(a[7])=f(111)=111
 f(a[8])=f(302)=87278
 f(a[9])=f(1234)=28382
 */


答:
Haskell, 49 bytes

```<code>f s|x<-(==last s)=x.length.fst.span x.reverse$s
</code>```

Try it on Ideone.

Shorter version which returns True for truthy and False or an exception for falsy:

```<code>((==).head>>=all).(head>>=take).reverse
</code>```

Title: PKCS#7 padding validation

Body:
In cryptography, PKCS#7 padding is a padding scheme which adds a number of bytes N ≥ 1, where the value of each added byte is equal to N.

For example, Hello, World!, which has 13 bytes, is the following in hex:

```<code>48 65 6C 6C 6F 2C 20 57 6F 72 6C 64 21
</code>```

If we choose to PKCS#7 pad to length 16, then the result is:

```<code>48 65 6C 6C 6F 2C 20 57 6F 72 6C 64 21 03 03 03
</code>```

And if we choose to pad to length 20, then the result is:

```<code>48 65 6C 6C 6F 2C 20 57 6F 72 6C 64 21 07 07 07 07 07 07 07
</code>```

Note that in the first example we add three 03 bytes, and in the second we add seven 07 bytes.

Your task will be to validate whether a string (or integer array) has correct PKCS#7 padding. That is, if the last byte of the input string is N, then your program should check that the last N bytes of the string are equal to N.

Input

A single nonempty ASCII string containing characters between code points 1 and 127 inclusive. If you wish, you may take input as an array of integers instead.

Output

A truthy value if the input string has valid PKCS#7 padding, otherwise a falsy value.

Both functions and full programs are acceptable. This is code-golf, so the aim is to minimise the number of bytes in your code.

Test cases

The integer array version of inputs is presented here — the string version would have unprintable characters for many of the following test cases:

Truthy:

```<code>[1]
[1, 1]
[2, 1]
[2, 2]
[5, 6, 5, 3, 3, 3]
[1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2]
[95, 115, 80, 32, 71, 7, 122, 49, 13, 7, 7, 7, 7, 7, 7, 7, 7]
[27, 33, 54, 65, 97, 33, 52, 55, 60, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
[15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]
</code>```

Falsy:

```<code>[2]
[1, 2]
[5, 5, 5, 5]
[5, 6, 5, 4, 4, 4]
[3, 3, 3, 94, 3, 3]
[1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 127]
[50, 39, 94, 105, 49, 29, 74, 102, 2, 106, 44, 7, 7, 7, 7, 7, 7]
[26, 27, 59, 25, 122, 110, 20, 30, 114, 6, 9, 62, 121, 42, 22, 60, 33, 12]
</code>```

Body:
Haskell, 49 bytes

f s|x<-(==last s)=x.length.fst.span x.reverse$s

Try it on Ideone.

Shorter version which returns True for truthy and False or an exception for falsy:

((==).head>>=all).(head>>=take).reverse


问:
Find whether a number is happy or not?
A happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers (or sad numbers). Given a number print whether it is happy or unhappy.

```<code>Sample Inputs
7
4
13

Sample Outputs
Happy
Unhappy
Happy
</code>```

Note: Your program should not take more than 10 secs for any number below 1,000,000,000.

答:
Common Lisp 138

```<code>(format t"~Aappy~%"(do((i(read)(loop for c across(prin1-to-string i)sum(let((y(digit-char-p c)))(* y y)))))((< i 5)(if(= i 1)"H""Unh"))))
</code>```

More readable:

```<code>(format t "~Aappy~%"
        (do
          ((i (read)
              (loop for c across (prin1-to-string i)
                    sum (let
                          ((y (digit-char-p c)))
                          (* y y)))))
          ((< i 5) (if (= i 1) "H" "Unh"))))
</code>```

Would be shorter to just return "Happy" or "Unhappy" right from the (do), but arguably that wouldn't count as a whole program

Title: Find whether a number is happy or not?

Body:
Common Lisp 138

(format t"~Aappy~%"(do((i(read)(loop for c across(prin1-to-string i)sum(let((y(digit-char-p c)))(* y y)))))((< i 5)(if(= i 1)"H""Unh"))))

More readable:

(format t "~Aappy~%"
        (do
          ((i (read)
              (loop for c across (prin1-to-string i)
                    sum (let
                          ((y (digit-char-p c)))
                          (* y y)))))
          ((< i 5) (if (= i 1) "H" "Unh"))))

Would be shorter to just return "Happy" or "Unhappy" right from the (do), but arguably that wouldn't count as a whole program


问:
Sylvester's sequence
Sylvester's sequence, OEIS A000058, is an integer sequence defined as follows:

Each member is the product of all previous members plus one.  The first member of the sequence is 2.

Task

Create a program to calculate the nth term of Sylvester's Sequence.  Standard input, output and loopholes apply.

Standard sequence rules apply.

This is code-golf, so the goal is to minimize the size of your source code as measured in bytes.

Test Cases

You may use either zero or one indexing. (Here I use zero indexing)

```<code>>>0
2
>>1
3
>>2
7
>>3
43
>>4
1807
</code>```

答:
Dyalog APL, 15 bytes

{×⍵:1+×/∇¨⍳⍵⋄2}
```

×⍵: if the argument is grater than zero:

  1+ one plus

  ×/ the product of

  ∇¨ this function applied to each of

  ⍳⍵ first n integers (beginning with zero)

⋄ else:

  2 return two

0-based indexing – needs ⎕IO←0.

TryAPL online!

ContentLicense: CC BY-SA 4.0

Title: Sylvester's sequence

Body:
Dyalog APL, 15 bytes

{×⍵:1+×/∇¨⍳⍵⋄2}

×⍵: if the argument is grater than zero:

  1+ one plus

  ×/ the product of

  ∇¨ this function applied to each of

  ⍳⍵ first n integers (beginning with zero)

⋄ else:

  2 return two

0-based indexing – needs ⎕IO←0.

TryAPL online!


答:
J, 13 bytes

```<code>#~@{:-:{:{.|.
</code>```

Takes the list as a single argument and outputs 1 if it is truthy and 0 if falsey.

Usage

```<code>   f =: #~@{:-:{:{.|.
   f 5 6 5 3 3 3
1
   f 5 6 5 4 4 4
0
</code>```

Explanation

```<code>#~@{:-:{:{.|.  Input: array A
           |.  Reverse A
       {:      Get the last value in A
         {.    Take that many values from the reverse of A
   {:          Get the last value in A
#~@            Make a list with that many copies of the last value
     -:        Test if the list of copies matches the sublist of A and return
</code>```

Title: PKCS#7 padding validation

Body:
J, 13 bytes

#~@{:-:{:{.|.

Takes the list as a single argument and outputs 1 if it is truthy and 0 if falsey.

Usage

   f =: #~@{:-:{:{.|.
   f 5 6 5 3 3 3
1
   f 5 6 5 4 4 4
0

Explanation

#~@{:-:{:{.|.  Input: array A
           |.  Reverse A
       {:      Get the last value in A
         {.    Take that many values from the reverse of A
   {:          Get the last value in A
#~@            Make a list with that many copies of the last value
     -:        Test if the list of copies matches the sublist of A and return


答:
Dyalog APL, 50 bytes

↑'/___\' ' VvV',⍨'  |' ' /_\',↓' ','|',⍨'|',⍪⍞,'_'
```
<p>OK, so it may not be the shortest submission, but it <em>is</em> the only one that carries the name of a real rocket manufacturer:</p>
<pre class="lang-apl prettyprint-override"><code>  |
 /_\
 |A|
 |P|
 |L|
 |_|
/___\
 VvV
</code>```

TryAPL online!

Title: This isn't rocket science

Body:
Dyalog APL, 50 bytes

↑'/___\' ' VvV',⍨'  |' ' /_\',↓' ','|',⍨'|',⍪⍞,'_'

OK, so it may not be the shortest submission, but it is the only one that carries the name of a real rocket manufacturer:

  |
 /_\
 |A|
 |P|
 |L|
 |_|
/___\
 VvV

TryAPL online!


Title: PKCS#7 padding validation

Body:
Javascript (ES6), <s>51</s> <s>47</s> 41 bytes

a=>(r=k=>a.pop()^n?k<2:r(k-1))(n=a.pop())

Examples:

let f =
a=>(r=k=>a.pop()^n?k<2:r(k-1))(n=a.pop())

console.log(f([5, 6, 5, 3, 3, 3]))
console.log(f([5, 6, 5, 4, 4, 4]))


答:
Elixir, 75 bytes

```<code>def f(p,a\\0),do: if'#{a+p}'|>Enum.reverse=='#{a+p}',do: a+p,else: f(p,a+p)
</code>```

Title: Smallest palindrome divisible by the input

Body:
Given a positive integer N, output the smallest positive integer such that this number is a palindrome (i.e. is its own reverse) and is divisible by N.

The palindrome (i.e. the output) must not need a leading zero to be a palindrome, e.g. 080 is not the valid answer for 16.

The input will never be a multiple of 10, because of the previous reason.

Your program may take as much time as necessary, even if in practice it would be way too long to output the answer.

Inputs and outputs

You may take the input through STDIN, as a function argument, or anything similar.

You may print the output to STDOUT, return it from a function, or anything similar.

Inputs and outputs must be in the decimal base.

Test cases

```<code>N        Output
1        1
2        2
16       272
17       272
42       252
111      111
302      87278
1234     28382
</code>```

Scoring

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

Body:
Elixir, 75 bytes

def f(p,a\\0),do: if'#{a+p}'|>Enum.reverse=='#{a+p}',do: a+p,else: f(p,a+p)


答:
Dyalog APL, 10 bytes

(⊃∧.=⊃↑⊢)⌽
```

⊃ Is the first

∧.= all-equal to

⊃ the first

↑ n taken from

⊢ the

⌽ reversed argument?

TryAPL online!

Title: PKCS#7 padding validation

Body:
Dyalog APL, 10 bytes

(⊃∧.=⊃↑⊢)⌽

⊃ Is the first

∧.= all-equal to

⊃ the first

↑ n taken from

⊢ the

⌽ reversed argument?

<a href="http://tryapl.org/?a=f%u2190%28%u2283%u2227.%3D%u2283%u2191%u22A2%29%u233D%20%u22C4%20f%A8%28%2C1%29%281%2C%201%29%282%2C%201%29%282%2C%202%29%285%2C%206%2C%205%2C%203%2C%203%2C%203%29%281%2C%201%2C%202%2C%202%2C%201%2C%201%2C%202%2C%202%2C%201%2C%201%2C%202%2C%202%29%2895%2C%20115%2C%2080%2C%2032%2C%2071%2C%207%2C%20122%2C%2049%2C%2013%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%29%2827%2C%2033%2C%2054%2C%2065%2C%2097%2C%2033%2C%2052%2C%2055%2C%2060%2C%201%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%2C%2010%29%2815%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%2C%2015%29%20%u22C4%20f%A8%28%2C2%29%281%2C%202%29%285%2C%205%2C%205%2C%205%29%285%2C%206%2C%205%2C%204%2C%204%2C%204%29%283%2C%203%2C%203%2C%2094%2C%203%2C%203%29%281%2C%202%2C%201%2C%202%2C%201%2C%202%2C%201%2C%202%2C%201%2C%202%2C%201%2C%202%29%281%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%201%2C%20127%29%2850%2C%2039%2C%2094%2C%20105%2C%2049%2C%2029%2C%2074%2C%20102%2C%202%2C%20106%2C%2044%2C%207%2C%207%2C%207%2C%207%2C%207%2C%207%29%2826%2C%2027%2C%2059%2C%2025%2C%20122%2C%20110%2C%2020%2C%2030%2C%20114%2C%206%2C%209%2C%2062%2C%20121%2C%2042%2C%2022%2C%2060%2C%2033%2C%2012%29&run" rel="nofollow noreferrer">TryAPL online!


问:
Output the Current Time

Challenge

You must output the current time continuously (until cancelled by an interrupt), once every second, by any of the following means:

It must be in 24-hour or AM/PM format.

If it is the former, it must be spaced out with colons (i.e. 15:47:36).

If it is the latter, it must be spaced out with colons and have the AM/PM following (i.e. 3:47:36 PM)

It may be pulled from the internet.

It may be the system time.

It must output any naturally accessible form of output which supports text that you choose.

Output may have extra information aside of the time in it, but you must guarantee one, and only one, output of time per second.

The continuous output must be a second apart - if you choose to wait until the second changes between outputs, that is fine. If you wait a second between each output, that is perfectly acceptable, despite the eventual loss of accuracy.

Since this is a catalog, languages created after this challenge are allowed to compete. Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language. Other than that, all the standard rules of code-golf must be obeyed. Submissions in most languages will be scored in bytes in an appropriate preexisting encoding (usually UTF-8).

Catalog

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

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

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

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

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

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

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

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

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

var QUESTION_ID=65020,OVERRIDE_USER=44713;function answersUrl(e){return"//api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"//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;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

```

答:
Elixir, 95 bytes

```<code>def f, do: 1000|>Stream.interval|>Enum.each(&(&1&&DateTime.utc_now|>DateTime.to_time|>IO.puts))
</code>```

Title: Output the Current Time

Body:
Elixir, 95 bytes

def f, do: 1000|>Stream.interval|>Enum.each(&(&1&&DateTime.utc_now|>DateTime.to_time|>IO.puts))


问:
Draw the Union Jack

Preface

There are many "draw x flag" challenges, and upon searching it turns out there are no challenges to draw the union Jack! I feel like this would be a harder flag to draw but it should still be possible.

Challenge

Draw the Union Jack. It can be outputted to a file in any freely available graphics file format or drawn onto the screen.

Code Golf rules apply, shortest code in bytes wins.

Standard loopholes apply.

No builtins for flag drawing allowed.

Dimensions shall be as below. Minimum size 600x300 pixels (or units if your language supports only scalable graphics.) Maximum error 1 pixel.

Colours shall be red, white and blue as defined by your language or its documentation, or #CC0000, #FFFFFF and #003399 per Wikipedia page.

答:
BBC BASIC

Rev B, 234 bytes

Instead of drawing one white and one red cross, we draw 100 progressively narrower crosses, switching from white background to red foreground at a coordinate of 60.

```<code>p=20761m=1049w=600h=300F.i=-1TO1V.29,w;h;18;4,m;134*i;0;m;w*i;-233;p;0;466;m;0;67*i;m;-466;h*i;p;932;0;18;1,m;511*i;h*i;25;89*i;0;29977;0;0;m;w*i;-h*i;28953;0;45*i;
N.F.c=-100TO0q=25881-c DIV60*512V.m;-c;-h;q;c;h;m;-w;-c;q;w;c;
N.
</code>```

Download interpreter free at http://www.bbcbasic.co.uk/bbcwin/bbcwin.html

Fully golfed, 249 bytes

Single byte VDU codes e.g 25,0 combined into double-byte little endian e.g 25; and maximum use of constants for common values. Keywords compressed to abbreviated form, e.g. FOR=>F. (interpreter expands automatically.)

```<code>p=20761q=26393r=25881m=1049c=100w=600h=300F.i=-1TO1V.29,w;h;18;4,m;134*i;0;m;w*i;-233;p;0;466;m;0;67*i;m;-466;h*i;p;932;0;18;1,m;511*i;h*i;25;89*i;0;29977;0;0;m;w*i;-h*i;28953;0;45*i;
N.V.m;-c;-h;q;c;h;2m;-w;-c;q;w;c;m;-60;-h;r;60;h;m;-w;-60;r;w;60;
</code>```

Semigolfed

Raw VDU codes. In BBC BASIC, characters can be sent to the VDU controller like VDU65 (prints an A.) There are certain special characters particular to the BBC for graphics. These must be followed by several other bytes to specify coordinates, etc. Here we use PLOT=>VDU25, GCOL=>VDU18, ORIGIN=>VDU29.

```<code>  c=100w=600h=300                                      :REM constants 100,width,height
  FORi=-1TO1                                           :REM loop -1 and 1 (0 draws nothing)
    VDU29,w;h;                                         :REM set origin (bring inside loop for golfing reasons)
    VDU18;4                                            :REM change to blue and draw triangles
    VDU25,4,134*i;0;25,4,w*i;-233;25,81,0;466;25,4,0;67*i;25,4,-466;h*i;25,81,932;0;
    VDU18;1                                            :REM change to red and draw parallelograms
    VDU25,4,511*i;h*i;25,0,89*i;0;25,117,0;0;25,4,w*i;-h*i;25,113,0;45*i;
  NEXT
  VDU25,4,-c;-h;25,103,c;h;25,4,-w;-c;25,103,w;c;      :REM draw white background rectangles
  VDU25,4,-60;-h;25,101,60;h;25,4,-w;-60;25,101,w;60;  :REM draw red foreground rectangles
</code>```

First we draw half the diagonal parts: 2 blue triangles and 2 red parallelograms. Then we change the scale from -1 to +1 and draw the other half. Finally we draw the horizontal and vertical parts on top: 2 white rectangles to form a white cross, then 2 red rectangles. The image after the first iteration of the loop is shown below, along with the final image.

Ungolfed code

BBC basic remembers the last 2 locations of the graphics cursor. PLOT81 draws a triangle between the new coordinates specified and these last two locations. PLOT113 and PLOT117 draw a parallelogram in a similar way: three corners of the parallelogram have to be given in the order they are found going round the perimeter. The last three bits of the PLOT code define whether the given coordinates are absolute or relative, and whether foreground or background colour is used. The more significant bits define what type of shape is drawn (point, line, triangle, parallelogram, rectangle, etc.)

```<code>  ORIGIN600,300       :REM move the origin (which will be centre of flag) away from the corner of the screen.

  FORi=-1TO1          :REM at scales of -1 and 1, plot half each of the diagonal parts (i=0 plots nothing).
    GCOL0,4             :REM blue foreground colour
    PLOT4,134*i,0       :REM absolute move to peak of upper/lower triangle
    PLOT4,600*i,-233    :REM absolute move to left hand corner
    PLOT81,0,466        :REM relative move to right hand corner, plotting triangle

    PLOT4,0,67*i        :REM absolute move to peak of left/right triangle
    PLOT4,-466,300*i    :REM absolute move to lower corner
    PLOT81,932,0        :REM relative move to upper corner, plotting triangle

    GCOL0,1             :REM red foreground colour
    PLOT4,511*i,300*i   :REM absolute move to long edge of flag
    PLOT0,89*i,0        :REM relative move to corner of flag (top right / bottom left)
    PLOT117,0,0         :REM absolute move to centre of flag, plotting parallelogram (stripe)
    PLOT4,600*i,-300*i  :REM absolute move to corner of flag (bottom right / top left)
    PLOT113,0,45*i      :REM relative move to short edge of flag, plotting parallelogram (stripe)
  NEXT                :REM diagonal parts completed, now plot vertical/horizontal parts on top.

  PLOT4,-100,-300     :REM move to bottom left of vertical white stripe
  PLOT103,100,300     :REM move to top right corner, plot it in background colour (white)
  PLOT4,-600,-100     :REM move to bottom left corner of horizontal white stripe
  PLOT103,600,100     :REM move to top right corner, plot it in background colour (white)

  PLOT4,-60,-300      :REM move to bottom left of vertical red stripe
  PLOT101,60,300      :REM move to top right corner, plot it in foreground colour (red)
  PLOT4,-600,-60      :REM move to bottom left corner of horizontal red stripe
  PLOT101,600,60      :REM move to top right corner, plot it in foreground colour (red)
</code>```

Title: Draw the Union Jack

Body:
BBC BASIC

Rev B, 234 bytes

Instead of drawing one white and one red cross, we draw 100 progressively narrower crosses, switching from white background to red foreground at a coordinate of 60.

p=20761m=1049w=600h=300F.i=-1TO1V.29,w;h;18;4,m;134*i;0;m;w*i;-233;p;0;466;m;0;67*i;m;-466;h*i;p;932;0;18;1,m;511*i;h*i;25;89*i;0;29977;0;0;m;w*i;-h*i;28953;0;45*i;
N.F.c=-100TO0q=25881-c DIV60*512V.m;-c;-h;q;c;h;m;-w;-c;q;w;c;
N.

Download interpreter free at http://www.bbcbasic.co.uk/bbcwin/bbcwin.html

Fully golfed, 249 bytes

Single byte VDU codes e.g 25,0 combined into double-byte little endian e.g 25; and maximum use of constants for common values. Keywords compressed to abbreviated form, e.g. FOR=>F. (interpreter expands automatically.)

p=20761q=26393r=25881m=1049c=100w=600h=300F.i=-1TO1V.29,w;h;18;4,m;134*i;0;m;w*i;-233;p;0;466;m;0;67*i;m;-466;h*i;p;932;0;18;1,m;511*i;h*i;25;89*i;0;29977;0;0;m;w*i;-h*i;28953;0;45*i;
N.V.m;-c;-h;q;c;h;2m;-w;-c;q;w;c;m;-60;-h;r;60;h;m;-w;-60;r;w;60;

Semigolfed

Raw VDU codes. In BBC BASIC, characters can be sent to the VDU controller like VDU65 (prints an A.) There are certain special characters particular to the BBC for graphics. These must be followed by several other bytes to specify coordinates, etc. Here we use PLOT=>VDU25, GCOL=>VDU18, ORIGIN=>VDU29.

  c=100w=600h=300                                      :REM constants 100,width,height
  FORi=-1TO1                                           :REM loop -1 and 1 (0 draws nothing)
    VDU29,w;h;                                         :REM set origin (bring inside loop for golfing reasons)
    VDU18;4                                            :REM change to blue and draw triangles
    VDU25,4,134*i;0;25,4,w*i;-233;25,81,0;466;25,4,0;67*i;25,4,-466;h*i;25,81,932;0;
    VDU18;1                                            :REM change to red and draw parallelograms
    VDU25,4,511*i;h*i;25,0,89*i;0;25,117,0;0;25,4,w*i;-h*i;25,113,0;45*i;
  NEXT
  VDU25,4,-c;-h;25,103,c;h;25,4,-w;-c;25,103,w;c;      :REM draw white background rectangles
  VDU25,4,-60;-h;25,101,60;h;25,4,-w;-60;25,101,w;60;  :REM draw red foreground rectangles

First we draw half the diagonal parts: 2 blue triangles and 2 red parallelograms. Then we change the scale from -1 to +1 and draw the other half. Finally we draw the horizontal and vertical parts on top: 2 white rectangles to form a white cross, then 2 red rectangles. The image after the first iteration of the loop is shown below, along with the final image.

Ungolfed code

BBC basic remembers the last 2 locations of the graphics cursor. PLOT81 draws a triangle between the new coordinates specified and these last two locations. PLOT113 and PLOT117 draw a parallelogram in a similar way: three corners of the parallelogram have to be given in the order they are found going round the perimeter. The last three bits of the PLOT code define whether the given coordinates are absolute or relative, and whether foreground or background colour is used. The more significant bits define what type of shape is drawn (point, line, triangle, parallelogram, rectangle, etc.)

  ORIGIN600,300       :REM move the origin (which will be centre of flag) away from the corner of the screen.

  FORi=-1TO1          :REM at scales of -1 and 1, plot half each of the diagonal parts (i=0 plots nothing).
    GCOL0,4             :REM blue foreground colour
    PLOT4,134*i,0       :REM absolute move to peak of upper/lower triangle
    PLOT4,600*i,-233    :REM absolute move to left hand corner
    PLOT81,0,466        :REM relative move to right hand corner, plotting triangle

    PLOT4,0,67*i        :REM absolute move to peak of left/right triangle
    PLOT4,-466,300*i    :REM absolute move to lower corner
    PLOT81,932,0        :REM relative move to upper corner, plotting triangle

    GCOL0,1             :REM red foreground colour
    PLOT4,511*i,300*i   :REM absolute move to long edge of flag
    PLOT0,89*i,0        :REM relative move to corner of flag (top right / bottom left)
    PLOT117,0,0         :REM absolute move to centre of flag, plotting parallelogram (stripe)
    PLOT4,600*i,-300*i  :REM absolute move to corner of flag (bottom right / top left)
    PLOT113,0,45*i      :REM relative move to short edge of flag, plotting parallelogram (stripe)
  NEXT                :REM diagonal parts completed, now plot vertical/horizontal parts on top.

  PLOT4,-100,-300     :REM move to bottom left of vertical white stripe
  PLOT103,100,300     :REM move to top right corner, plot it in background colour (white)
  PLOT4,-600,-100     :REM move to bottom left corner of horizontal white stripe
  PLOT103,600,100     :REM move to top right corner, plot it in background colour (white)

  PLOT4,-60,-300      :REM move to bottom left of vertical red stripe
  PLOT101,60,300      :REM move to top right corner, plot it in foreground colour (red)
  PLOT4,-600,-60      :REM move to bottom left corner of horizontal red stripe
  PLOT101,600,60      :REM move to top right corner, plot it in foreground colour (red)


问:
Render "Digital Clock Style" Numbers
Write the shortest program which will take a string of numbers (of up to at least 20 length) as input, and display the output using the standard digital clock style numbers.  For instance for input 81, a solution with ascii output would give:

```<code> _
|_|  |
|_|  |
</code>```

Graphical output is also acceptable, if it helps.

答:
APL (Dyalog) (45)

```<code>{3 3⍴' _|'[1+⍵⊤⍨9⍴3]}¨⎕UCS'ા8धगɯે૙ࣃଏ૽'[1+⍎¨⍞]
</code>```

The string, ા8धगɯે૙ࣃଏ૽, are the unicode characters 2750 56 2343 2327 623 2759 2777 2243 2831 2813 (however, you should be able to just copy and paste it). They encode the numbers. The program reads a line from the keyboard.

Explanation:

1+⍎¨⍞: read a line from the keyboard, parse each character as a digit, then add 1 to each number (APL arrays are 1-based by default).

⎕UCS'ા8धगɯે૙ࣃଏ૽'[...]: Select the characters belonging to the digits of the numbers you entered, and look up the Unicode values.

{...}¨: for each of these values, do:

1+⍵⊤⍨9⍴3: get the first 9 base-3 digits from the value as expressed in base-3, and add 1  (because the arrays ar 1-based).

' _|'[...]: select  a space, horizontal line, or vertical line depending on these digits

3 3⍴: format as a 3-by-3 box.

Title: Render "Digital Clock Style" Numbers

Body:
APL (Dyalog) (45)

{3 3⍴' _|'[1+⍵⊤⍨9⍴3]}¨⎕UCS'ા8धगɯે૙ࣃଏ૽'[1+⍎¨⍞]

The string, ા8धगɯે૙ࣃଏ૽, are the unicode characters 2750 56 2343 2327 623 2759 2777 2243 2831 2813 (however, you should be able to just copy and paste it). They encode the numbers. The program reads a line from the keyboard.

Explanation:

1+⍎¨⍞: read a line from the keyboard, parse each character as a digit, then add 1 to each number (APL arrays are 1-based by default).

⎕UCS'ા8धगɯે૙ࣃଏ૽'[...]: Select the characters belonging to the digits of the numbers you entered, and look up the Unicode values.

{...}¨: for each of these values, do:

1+⍵⊤⍨9⍴3: get the first 9 base-3 digits from the value as expressed in base-3, and add 1  (because the arrays ar 1-based).

' _|'[...]: select  a space, horizontal line, or vertical line depending on these digits

3 3⍴: format as a 3-by-3 box.


问:
Print every printable ASCII character without using it
In a programming language of your choice, write 95 programs, each of which outputs a different one of the 95 printable ASCII characters without that character occurring anywhere in the program.

For example, if your language was Python, your program that outputs the character P might be

```<code>print(chr(80))
</code>```

because P has ASCII code 80. This program is valid because P never appears in the source code. However, for the program that outputs lowercase p, something like

```<code>print(chr(112))
</code>```

would be invalid because, while it does print p, p is present in the code. A valid program could be

```<code>exec(chr(112)+'rint(chr(112))')
</code>```

which prints p but does not contain p.

Your goal is to make each of your 95 programs as short as possible. Your score is the sum of the character lengths of all your programs.

If for any reason you are unable to write valid programs for some characters, you may mark those characters as "Did Not Program" or DNP, and omit programs for them entirely. This way syntactically strict languages will be able to compete.

The winning answer is the answer that has the lowest score of the set of answers that have the fewest DNP's.

Rules

The source code of all of your programs may only contain printable ASCII plus tabs and newlines, all of which are counted as one character. (Because in a different encoding it would be easy to omit characters that don't exist!)

Note: This rule seems necessary but there are many languages with different encodings and I'm sure it'd be cool to see the answers for them. Therefore you can break this rule, you can use whatever characters you want, but then your answer becomes non-competitive, it cannot win.

The programs must be actual, full programs, according to your language's standard conventions. Functions and REPL snippets are not allowed.

Each program's output should go to stdout or your language's accepted alternative.

Programs should not prompt for or require input. (If prompting for input is inherent to your language, that's ok.)

Programs should be deterministic, finite in run time, and independent. e.g. it shouldn't matter if one is run in a folder separate from the other programs.

A program's output should be the precise printable ASCII character it corresponds to, optionally followed by a single trailing newline, nothing more, nothing less.

Be sure to include information on all 95 (ideally) programs in your answer, as well as your score and any DNP's. You don't have to list all programs that follow a simple pattern like "print(chr(80)), print(chr(81)), print(chr(82))..." but make sure you're sure they all would work and that your score is added correctly.

For reference, here are the 95 printable ASCII your programs must output:

```<code> !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
</code>```

Body:
Jelly (non-competitive), 406 bytes

32Ọ
33Ọ
34Ọ
35Ọ
36Ọ
37Ọ
38Ọ
39Ọ
40Ọ
41Ọ
42Ọ
43Ọ
44Ọ
45Ọ
46Ọ
47Ọ
48Ọ
49Ọ
50Ọ
51Ọ
52Ọ
49+4Ọ
54Ọ
55Ọ
56Ọ
57Ọ
58Ọ
59Ọ
60Ọ
61Ọ
62Ọ
63Ọ
64Ọ
65Ọ
66Ọ
67Ọ
68Ọ
69Ọ
70Ọ
71Ọ
72Ọ
73Ọ
74Ọ
75Ọ
76Ọ
77Ọ
78Ọ
79Ọ
80Ọ
81Ọ
82Ọ
83Ọ
84Ọ
85Ọ
86Ọ
87Ọ
88Ọ
89Ọ
90Ọ
91Ọ
92Ọ
93Ọ
94Ọ
95Ọ
96Ọ
97Ọ
98Ọ
99Ọ
³Ọ
101Ọ
102Ọ
103Ọ
104Ọ
105Ọ
106Ọ
107Ọ
108Ọ
109Ọ
110Ọ
111Ọ
112Ọ
113Ọ
114Ọ
115Ọ
116Ọ
117Ọ
118Ọ
119Ọ
120Ọ
121Ọ
122Ọ
123Ọ
124Ọ
125Ọ
126Ọ

This prints all characters from 32 - 126. The byte count is calculated with https://mothereff.in/byte-counter.

Try it online!


答:
><>, 60 bytes

```<code>'  |'a' /_\'av
a$v?(0:i'|| '<
'r\~'_'$a'/___\'a' VvV
 o>l?!;
</code>```

Pretty simple really. lots of strings, the newlines are annoying.

Try it online

```<code>  |
 /_\
 |>|
 |<|
 |>|
 |_|
/___\
 VvV
</code>```

Title: This isn't rocket science

Body:
Write a program or function that takes in a single-line string. You can assume it only contains printable ASCII. Print or return a string of an ASCII art rocket such as

```<code>  |
 /_\
 |E|
 |a|
 |r|
 |t|
 |h|
 |_|
/___\
 VvV
</code>```

with the input string written from top to bottom on the fuselage. In this case the input was Earth. The height of the rocket (including flames) is always the length of the string plus five.

Each line in the output may have up to two trailing spaces and there may be a single optional trailing newline. The shortest code in bytes wins.

More Examples:

```<code>[empty string]

  |
 /_\
 |_|
/___\
 VvV

a

  |
 /_\
 |a|
 |_|
/___\
 VvV

|0

  |
 /_\
 |||
 |0|
 |_|
/___\
 VvV

\/\

  |
 /_\
 |\|
 |/|
 |\|
 |_|
/___\
 VvV

 _ _ [note trailing space]

  |
 /_\
 | |
 |_|
 | |
 |_|
 | |
 |_|
/___\
 VvV

    [4 spaces]

  |
 /_\
 | |
 | |
 | |
 | |
 |_|
/___\
 VvV

SPACEY

  |
 /_\
 |S|
 |P|
 |A|
 |C|
 |E|
 |Y|
 |_|
/___\
 VvV
</code>```

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
><>, 60 bytes

'  |'a' /_\'av
a$v?(0:i'|| '<
'r\~'_'$a'/___\'a' VvV
 o>l?!;

Pretty simple really. lots of strings, the newlines are annoying.

Try it online

  |
 /_\
 |>|
 |<|
 |>|
 |_|
/___\
 VvV