问:
Number Plate Golf: Recognition
See also: Parsing

Introduction

You're working on a government programming team, who have been programming the speed cameras. However, the group of people who have programmed the speed calculator have taken up too much space, so you have to make the number plate recognition software as small as possible.

Challenge

Given an image of a number plate, return the text on the plate.

Number plates

The following are all of the characters which your program must recognise:

ABCDEFG

H1JKLMN0

PQRSTUVW

XYZ01234

56789

Note

On British number plates, the characters for I (i) and 1 (one) are the same and the characters for O (o) and 0 (zero) are the same. For that reason, always assume characters are the numbers. I.e. the following number plate is 10 (one zero):

Examples

C0D3 GLF

B3T4 DCY

M1NUS 15

YET1CGN

Other rules

Internet access and OCR libraries and functions are disallowed.

The number plates will always look identical to the ones shown above. All number plates will be roughly same size (there will be some inaccuracies due to cropping method).

If you require lossless PNG versions of any number plates, I will supply them to you.

Scoring

The shortest program in bytes wins.

All number plates are screenshots of the search bar at this site

答:
C, 409 bytes (and I'm as surprised as anybody)

f(w,h,d,X,T,B,x,y,b,v,u,t,a)char*d;{for(x=X=0;++x<w;){for(y=b=h;y--;a=0)d[(y*w+x)*3+1]&224||(b=0,X||(X=x,T=B=y),T=y<T?y:T,B=y>B?y:B);if(X*b){for(B+=1-T,X=x-X,v=5;v--;)for(u=4;u--;a|=(b>X/4*(B/5)*.35)<<19-u*5-v)for(b=0,t=X/4;t--;)for(y=B/5;y--;)b+=!(d[((v*B/5+y+T)*w+x-X+u*X/4+t)*3+1]&224);X=!putchar("g------a----mj---et-u--6----7--8s4-c-x--q--d9xy5-0v--n-2-hw-k-----3---bf-----t-r---pzn-1---l"[a%101-7]);}}}
```

<p>Takes as input: the width (<code>w</code>) and height (<code>h</code>) of the image, followed by the packed RGB data as an array of <code>char</code>s (<code>d</code>). All the other function parameters are variable declarations in disguise. Ignores everything except the green channel, and applies a threshold of 32 as an initial pass.</p>

<p>Mostly the same as @DavidC's method, except this checks that at least 35% of each sample box is filled. Hopefully that makes it more robust to scale changes, but who knows.</p>

<p>I used a brute-force method to find out which resampling size and coverage percent to use for the best reliability (i.e. fewest cases of one character having multiple interpretations). It turned out that a 4x5 grid with 35% coverage was best. I then used a second brute-force method to calculate the best bit arrangement and modulo value to pack the character data into a short string — the low bit at the top-left, increasing in x then y, with the final value % 101 turned out best, giving this lookup table:</p>

```-------g------a----mj---et-u--6----7--8s4-c-x--q--d9xy5-0v--n-2-hw-k-----3---bf-----t-r---pzn-1---l--
```

<p>Subtracting 7 means the initial -'s can be removed, and the last 2 can be removed without any extra work. This removal means that certain invalid inputs could cause an invalid memory read, so it could segfault on particular images.</p>

<h3>Usage:</h3>

<p>To get the images into it, I wrote a wrapper using libpng. Also it turns out that despite the filename, the images in the question are actually jpegs (!), so you'll need to manually export them as pngs first.</p>

<pre class="lang-c prettyprint-override"><code>#include <png.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, const char *const *argv) {
    if(argc < 2) {
        fprintf(stderr, "Usage: %s <file.png>\n", argv[0]);
        return 1;
    }

    const char *file = argv[1];

    FILE *const fp = fopen(file, "rb");
    if(fp == NULL) {
        fprintf(stderr, "Failed to open %s for reading\n", file);
        return 1;
    }

    png_structp png_ptr = png_create_read_struct(
        PNG_LIBPNG_VER_STRING, NULL, NULL, NULL
    );

    if(!png_ptr) {
        fclose(fp);
        fprintf(stderr, "Failed to initialise LibPNG (A)\n");
        return 1;
    }

    png_infop info_ptr = png_create_info_struct(png_ptr);

    if(!info_ptr) {
        png_destroy_read_struct(&png_ptr, NULL, NULL);
        fclose(fp);
        fprintf(stderr, "Failed to initialise LibPNG (B)\n");
        return 1;
    }

    if(setjmp(png_jmpbuf(png_ptr))) {
        png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
        fclose(fp);
        fprintf(stderr, "Error while reading PNG\n");
        return 1;
    }

    png_init_io(png_ptr, fp);
    png_set_sig_bytes(png_ptr, 0);

    png_read_png(
        png_ptr, info_ptr,
        PNG_TRANSFORM_STRIP_16 |
        PNG_TRANSFORM_GRAY_TO_RGB |
        PNG_TRANSFORM_STRIP_ALPHA,
        NULL
    );
    const png_bytep *const rows = png_get_rows(png_ptr, info_ptr);
    const int w = png_get_image_width(png_ptr, info_ptr);
    const int h = png_get_image_height(png_ptr, info_ptr);
    unsigned char *const data = malloc(w*h*3 * sizeof(unsigned char));
    for(int y = 0; y < h; ++ y) {
        for(int x = 0; x < w; ++ x) {
            memcpy(&data[y*w*3], rows[y], w * 3 * sizeof(unsigned char));
        }
    }
    png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
    fclose(fp);

    f(w, h, (char*) data);

    free(data);

    return 0;
}
</code>```

Breakdown

f(                          // Function
    w,h,d,                  // Parameters: width, height, RGB data
    X,T,B,x,y,b,v,u,t,a     // Variables
)char*d;{                   // K&R syntax to save lots of type decls
  for(x=X=0;++x<w;){        // Loop through each column of the image:
    for(y=b=h;y--;a=0)      //  Loop through pixels in column:
      d[(y*w+x)*3+1]&224||( //   If green < 32: (char could be signed or unsigned)
        b=0,                //    This is not a blank line
        X||(X=x,T=B=y),     //    Start a new character if not already in one
        T=y<T?y:T,          //    Record top of character
        B=y>B?y:B           //    Record bottom of character
      );
    if(X*b){                //  If we just found the end of a character:
      // Check cell grid & record bits into "a"
      for(B+=1-T,X=x-X,v=5;v--;)
        for(u=4;u--;a|=(b>X/4*(B/5)*.35)<<19-u*5-v)
          // Calculate coverage of current cell
          for(b=0,t=X/4;t--;)
            for(y=B/5;y--;)
              b+=!(d[((v*B/5+y+T)*w+x-X+u*X/4+t)*3+1]&224);

      // Look up meaning of "a" in table & print, reset X to 0
      X=!putchar(
        "g------a----mj---et-u--6----7--8s4-c-x--q--d9x"
        "y5-0v--n-2-hw-k-----3---bf-----t-r---pzn-1---l"
        [a%101-7]
      );
    }
  }
}
```

Title: Number Plate Golf: Recognition

Body:
C, 409 bytes (and I'm as surprised as anybody)

f(w,h,d,X,T,B,x,y,b,v,u,t,a)char*d;{for(x=X=0;++x<w;){for(y=b=h;y--;a=0)d[(y*w+x)*3+1]&224||(b=0,X||(X=x,T=B=y),T=y<T?y:T,B=y>B?y:B);if(X*b){for(B+=1-T,X=x-X,v=5;v--;)for(u=4;u--;a|=(b>X/4*(B/5)*.35)<<19-u*5-v)for(b=0,t=X/4;t--;)for(y=B/5;y--;)b+=!(d[((v*B/5+y+T)*w+x-X+u*X/4+t)*3+1]&224);X=!putchar("g------a----mj---et-u--6----7--8s4-c-x--q--d9xy5-0v--n-2-hw-k-----3---bf-----t-r---pzn-1---l"[a%101-7]);}}}

Takes as input: the width (w) and height (h) of the image, followed by the packed RGB data as an array of chars (d). All the other function parameters are variable declarations in disguise. Ignores everything except the green channel, and applies a threshold of 32 as an initial pass.

Mostly the same as @DavidC's method, except this checks that at least 35% of each sample box is filled. Hopefully that makes it more robust to scale changes, but who knows.

I used a brute-force method to find out which resampling size and coverage percent to use for the best reliability (i.e. fewest cases of one character having multiple interpretations). It turned out that a 4x5 grid with 35% coverage was best. I then used a second brute-force method to calculate the best bit arrangement and modulo value to pack the character data into a short string — the low bit at the top-left, increasing in x then y, with the final value % 101 turned out best, giving this lookup table:

-------g------a----mj---et-u--6----7--8s4-c-x--q--d9xy5-0v--n-2-hw-k-----3---bf-----t-r---pzn-1---l--

Subtracting 7 means the initial -'s can be removed, and the last 2 can be removed without any extra work. This removal means that certain invalid inputs could cause an invalid memory read, so it could segfault on particular images.

Usage:

To get the images into it, I wrote a wrapper using libpng. Also it turns out that despite the filename, the images in the question are actually jpegs (!), so you'll need to manually export them as pngs first.

#include <png.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, const char *const *argv) {
    if(argc < 2) {
        fprintf(stderr, "Usage: %s <file.png>\n", argv[0]);
        return 1;
    }

    const char *file = argv[1];

    FILE *const fp = fopen(file, "rb");
    if(fp == NULL) {
        fprintf(stderr, "Failed to open %s for reading\n", file);
        return 1;
    }

    png_structp png_ptr = png_create_read_struct(
        PNG_LIBPNG_VER_STRING, NULL, NULL, NULL
    );

    if(!png_ptr) {
        fclose(fp);
        fprintf(stderr, "Failed to initialise LibPNG (A)\n");
        return 1;
    }

    png_infop info_ptr = png_create_info_struct(png_ptr);

    if(!info_ptr) {
        png_destroy_read_struct(&png_ptr, NULL, NULL);
        fclose(fp);
        fprintf(stderr, "Failed to initialise LibPNG (B)\n");
        return 1;
    }

    if(setjmp(png_jmpbuf(png_ptr))) {
        png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
        fclose(fp);
        fprintf(stderr, "Error while reading PNG\n");
        return 1;
    }

    png_init_io(png_ptr, fp);
    png_set_sig_bytes(png_ptr, 0);

    png_read_png(
        png_ptr, info_ptr,
        PNG_TRANSFORM_STRIP_16 |
        PNG_TRANSFORM_GRAY_TO_RGB |
        PNG_TRANSFORM_STRIP_ALPHA,
        NULL
    );
    const png_bytep *const rows = png_get_rows(png_ptr, info_ptr);
    const int w = png_get_image_width(png_ptr, info_ptr);
    const int h = png_get_image_height(png_ptr, info_ptr);
    unsigned char *const data = malloc(w*h*3 * sizeof(unsigned char));
    for(int y = 0; y < h; ++ y) {
        for(int x = 0; x < w; ++ x) {
            memcpy(&data[y*w*3], rows[y], w * 3 * sizeof(unsigned char));
        }
    }
    png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
    fclose(fp);

    f(w, h, (char*) data);

    free(data);

    return 0;
}

Breakdown

f(                          // Function
    w,h,d,                  // Parameters: width, height, RGB data
    X,T,B,x,y,b,v,u,t,a     // Variables
)char*d;{                   // K&R syntax to save lots of type decls
  for(x=X=0;++x<w;){        // Loop through each column of the image:
    for(y=b=h;y--;a=0)      //  Loop through pixels in column:
      d[(y*w+x)*3+1]&224||( //   If green < 32: (char could be signed or unsigned)
        b=0,                //    This is not a blank line
        X||(X=x,T=B=y),     //    Start a new character if not already in one
        T=y<T?y:T,          //    Record top of character
        B=y>B?y:B           //    Record bottom of character
      );
    if(X*b){                //  If we just found the end of a character:
      // Check cell grid & record bits into "a"
      for(B+=1-T,X=x-X,v=5;v--;)
        for(u=4;u--;a|=(b>X/4*(B/5)*.35)<<19-u*5-v)
          // Calculate coverage of current cell
          for(b=0,t=X/4;t--;)
            for(y=B/5;y--;)
              b+=!(d[((v*B/5+y+T)*w+x-X+u*X/4+t)*3+1]&224);

      // Look up meaning of "a" in table & print, reset X to 0
      X=!putchar(
        "g------a----mj---et-u--6----7--8s4-c-x--q--d9x"
        "y5-0v--n-2-hw-k-----3---bf-----t-r---pzn-1---l"
        [a%101-7]
      );
    }
  }
}


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

ContentLicense: CC BY-SA 3.0

Body:
Brainfuck, 1770 1710 1703  1686 bytes

60 bytes saved by Dennis

17 bytes saved by Sp3000

DNP: 46 (.)

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

All except 43, 45, 60, 62, 91 and 93 are shamelessly stolen from Esolangs.org


答:
CJam, 269 bytes

Each of the programs are in the form '<char - 1>) except for:

Space => S, 1 byte

' => 39c, 3 bytes

) => '*(, 3 bytes

0 => T, 1 byte

1 => X, 1 byte

2 => Y, 1 byte

3 => Z, 1 byte

4-9 => <num-1>), 2 bytes

Score is: 3 * 82 + 1 + 3 + 3 + 4 * 1 + 6 * 2 = 269

Title: Print every printable ASCII character without using it

Body:
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>```


答:
Dyalog APL, <s>527</s> 522 bytes

(non-competing because APL cannot really be written using ASCII only)

Most are in the format nn⊃⎕AV or nnn⊃⎕AV, the exceptions being:

⊃''     ⍝ space: extract one char from an empty string
⎕THIS   ⍝ hash: this namespace
⊃1↓⍕÷2  ⍝ period: the first char after stripping one char from 1÷2, i.e. 0.5
⊃⍬      ⍝ zero: extract one number from an empty numeric list
≢#      ⍝ one: tally the root namespace
⍴⍬⍬     ⍝ two: count two empty lists
⎕WX     ⍝ three: default "Window Expose" setting
×⍨2     ⍝ four: 2×2
6-1     ⍝ five: 6-1
!3      ⍝ six: 3!
6+1     ⍝ seven: 6+1
2*3     ⍝ eight: 2³
3*2     ⍝ nine: 3²
⊃⎕a     ⍝ A: first character (Dyalog system names are case insensitive)
2⊃⎕A    ⍝
⋮        ⍝  B-Y: n'th character
25⊃⎕A   ⍝
⊃⌽⎕A    ⍝ Z: last character
```
<p>Here is the entire list:</p>
<pre class="lang-apl prettyprint-override"><code>⊃''
205⊃⎕AV
216⊃⎕AV
⎕THIS
62⊃⎕AV
13⊃⎕AV
219⊃⎕AV
14⊃⎕AV
186⊃⎕AV
249⊃⎕AV
181⊃⎕AV
170⊃⎕AV
195⊃⎕AV
169⊃⎕AV
⊃1↓⍕÷2
157⊃⎕AV
⊃⍬
≢#
⍴⍬ ⍬
⎕WX
×⍨2
6-1
!3
6+1
2*3
3*2
241⊃⎕AV
194⊃⎕AV
161⊃⎕AV
163⊃⎕AV
165⊃⎕AV
173⊃⎕AV
232⊃⎕AV
⊃⎕a
2⊃⎕A
3⊃⎕A
4⊃⎕A
5⊃⎕A
6⊃⎕A
7⊃⎕A
8⊃⎕A
9⊃⎕A
10⊃⎕A
11⊃⎕A
12⊃⎕A
13⊃⎕A
14⊃⎕A
15⊃⎕A
16⊃⎕A
17⊃⎕A
18⊃⎕A
19⊃⎕A
20⊃⎕A
21⊃⎕A
22⊃⎕A
23⊃⎕A
24⊃⎕A
25⊃⎕A
26⊃⎕A
156⊃⎕AV
159⊃⎕AV
250⊃⎕AV
236⊃⎕AV
17⊃⎕AV
238⊃⎕AV
18⊃⎕AV
19⊃⎕AV
20⊃⎕AV
21⊃⎕AV
22⊃⎕AV
23⊃⎕AV
24⊃⎕AV
25⊃⎕AV
26⊃⎕AV
27⊃⎕AV
28⊃⎕AV
29⊃⎕AV
30⊃⎕AV
31⊃⎕AV
32⊃⎕AV
33⊃⎕AV
34⊃⎕AV
35⊃⎕AV
36⊃⎕AV
37⊃⎕AV
38⊃⎕AV
39⊃⎕AV
40⊃⎕AV
41⊃⎕AV
42⊃⎕AV
43⊃⎕AV
124⊃⎕AV
193⊃⎕AV
126⊃⎕AV
176⊃⎕AV
</code>```

Body:
Dyalog APL, <s>527</s> 522 bytes

(non-competing because APL cannot really be written using ASCII only)

Most are in the format nn⊃⎕AV or nnn⊃⎕AV, the exceptions being:

⊃''     ⍝ space: extract one char from an empty string
⎕THIS   ⍝ hash: this namespace
⊃1↓⍕÷2  ⍝ period: the first char after stripping one char from 1÷2, i.e. 0.5
⊃⍬      ⍝ zero: extract one number from an empty numeric list
≢#      ⍝ one: tally the root namespace
⍴⍬⍬     ⍝ two: count two empty lists
⎕WX     ⍝ three: default "Window Expose" setting
×⍨2     ⍝ four: 2×2
6-1     ⍝ five: 6-1
!3      ⍝ six: 3!
6+1     ⍝ seven: 6+1
2*3     ⍝ eight: 2³
3*2     ⍝ nine: 3²
⊃⎕a     ⍝ A: first character (Dyalog system names are case insensitive)
2⊃⎕A    ⍝
⋮        ⍝  B-Y: n'th character
25⊃⎕A   ⍝
⊃⌽⎕A    ⍝ Z: last character

Here is the entire list:

⊃''
205⊃⎕AV
216⊃⎕AV
⎕THIS
62⊃⎕AV
13⊃⎕AV
219⊃⎕AV
14⊃⎕AV
186⊃⎕AV
249⊃⎕AV
181⊃⎕AV
170⊃⎕AV
195⊃⎕AV
169⊃⎕AV
⊃1↓⍕÷2
157⊃⎕AV
⊃⍬
≢#
⍴⍬ ⍬
⎕WX
×⍨2
6-1
!3
6+1
2*3
3*2
241⊃⎕AV
194⊃⎕AV
161⊃⎕AV
163⊃⎕AV
165⊃⎕AV
173⊃⎕AV
232⊃⎕AV
⊃⎕a
2⊃⎕A
3⊃⎕A
4⊃⎕A
5⊃⎕A
6⊃⎕A
7⊃⎕A
8⊃⎕A
9⊃⎕A
10⊃⎕A
11⊃⎕A
12⊃⎕A
13⊃⎕A
14⊃⎕A
15⊃⎕A
16⊃⎕A
17⊃⎕A
18⊃⎕A
19⊃⎕A
20⊃⎕A
21⊃⎕A
22⊃⎕A
23⊃⎕A
24⊃⎕A
25⊃⎕A
26⊃⎕A
156⊃⎕AV
159⊃⎕AV
250⊃⎕AV
236⊃⎕AV
17⊃⎕AV
238⊃⎕AV
18⊃⎕AV
19⊃⎕AV
20⊃⎕AV
21⊃⎕AV
22⊃⎕AV
23⊃⎕AV
24⊃⎕AV
25⊃⎕AV
26⊃⎕AV
27⊃⎕AV
28⊃⎕AV
29⊃⎕AV
30⊃⎕AV
31⊃⎕AV
32⊃⎕AV
33⊃⎕AV
34⊃⎕AV
35⊃⎕AV
36⊃⎕AV
37⊃⎕AV
38⊃⎕AV
39⊃⎕AV
40⊃⎕AV
41⊃⎕AV
42⊃⎕AV
43⊃⎕AV
124⊃⎕AV
193⊃⎕AV
126⊃⎕AV
176⊃⎕AV


答:
MATL, <s>305, 302, 300</s> 297 bytes

Every single program looks like this:

```<code>33c
34c
35c
....
</code>```

Except for

Digits. Here are the programs for 0-9:

```<code>O
l
H
I
K
4Q
5Q
6Q
7Q
8Q
</code>```

'c'. This program is

```<code>'C'k
</code>```

space. This is

```<code>0c
</code>```

Since today I learned, that MATL treats character 0 as space. Thanks @LuisMendo!

You can use matl.tio to verify any of them.

For reference, here is all of them:

```<code>0c
33c
34c
35c
36c
37c
38c
39c
40c
41c
42c
43c
44c
45c
46c
47c
O
l
H
I
K
4Q
5Q
6Q
7Q
8Q
58c
59c
60c
61c
62c
63c
64c
65c
66c
67c
68c
69c
70c
71c
72c
73c
74c
75c
76c
77c
78c
79c
80c
81c
82c
83c
84c
85c
86c
87c
88c
89c
90c
91c
92c
93c
94c
95c
96c
97c
98c
'C'k
100c
101c
102c
103c
104c
105c
106c
107c
108c
109c
110c
111c
112c
113c
114c
115c
116c
117c
118c
119c
120c
121c
122c
123c
124c
125c
126c
</code>```

Body:
MATL, <s>305, 302, 300</s> 297 bytes

Every single program looks like this:

33c
34c
35c
....

Except for

Digits. Here are the programs for 0-9:

O
l
H
I
K
4Q
5Q
6Q
7Q
8Q

'c'. This program is

'C'k

space. This is

0c

Since today I learned, that MATL treats character 0 as space. Thanks @LuisMendo!

You can use matl.tio to verify any of them.

For reference, here is all of them:

0c
33c
34c
35c
36c
37c
38c
39c
40c
41c
42c
43c
44c
45c
46c
47c
O
l
H
I
K
4Q
5Q
6Q
7Q
8Q
58c
59c
60c
61c
62c
63c
64c
65c
66c
67c
68c
69c
70c
71c
72c
73c
74c
75c
76c
77c
78c
79c
80c
81c
82c
83c
84c
85c
86c
87c
88c
89c
90c
91c
92c
93c
94c
95c
96c
97c
98c
'C'k
100c
101c
102c
103c
104c
105c
106c
107c
108c
109c
110c
111c
112c
113c
114c
115c
116c
117c
118c
119c
120c
121c
122c
123c
124c
125c
126c


问:
Solving triangles with trigonometry
Time to dig up your old trigonometry notes from high school! The challenge is to solve the unknown sides and angles of different triangles. And as is customary in code golf, the smallest working code wins.

This is not a trivial problem; my reference implementation in python is currently down to 838 837 characters, but I'm sure you'll be able to golf solutions far smaller.

Additionally, if you're stuck, this section on Wikipedia should get you going: Triangle: Computing the sides and angles.

Input

The following triangle shows the names of the sides and angles used in this challenge. Note that sides are lowercase and angles are uppercase.

Input is given as six space-separated values, either on stdin or as command-line arguments (your choice). The six values correspond to the sides a, b, c and the angles A, B, C. The unknown sides are given as question marks (?). Both input and output angles has to be in radians. You may assume that the input values are correct (you don't have to validate anything). You may also assume that the input triangle is non-degenerate, and that all sides and angles are nonzero.

The following example input tells you that side a is 8, side b is 12 and angle A is 0.5 radians:

```<code>8 12 ? 0.5 ? ?
</code>```

Output

Output is given in the same format as the input - six space-separated numbers on stdout. The only exception is when it is not possible to solve the input triangle - then the string "No solution" must be written to stdout. If two solutions are possible, they are both outputted with a newline between them.

Following is the output for the above input:

```<code>8.0 12.0 16.0899264342 0.5 0.802561439714 1.83903121388
8.0 12.0 4.97205505116 0.5 2.33903121388 0.302561439714
</code>```

Output is not required to have a lot of precision, but at least a couple decimals is required.

Rules

Input is read from stdin or command-line arguments

Output is written to stdout

If two solutions are possible with the given input, output both

If there is too little information to get one or two clear solutions, consider it a "No solution" case

No built-in or pre-existing code may be used (of course you can use trig functions, but not "solveTriangle" or such)

Shortest code wins

Test cases

In   3 4 5 ? ? ?

Out 3.0 4.0 5.0 0.643501108793 0.927295218002 1.57079630572

In   ? 4 ? 0.64 0.92 1.57

Out 3.00248479301 4.0 5.02764025486 0.64 0.92 1.57

In   ? ? 5 ? 0.92 ?

Out No solution

In   ? ? 5 ? 0.92 1.57

Out 3.03226857833 3.97800936148 5.0 0.65159265359 0.92 1.57

In   8 12 ? 0.5 ? ?

Out (two solutions)

```<code>8.0 12.0 16.0899264342 0.5 0.802561439714 1.83903121388
8.0 12.0 4.97205505116 0.5 2.33903121388 0.302561439714
</code>```

In   8 12 ? ? .5 ?

Out 8.0 12.0 18.3912222133 0.325325285223 0.5 2.31626736837

Good luck!

Title: Solving triangles with trigonometry

Body:
Perl - 412 chars

As a perl one-liner, based off of Keith Randall's Python Solution:

use Math::Trig;@V=((map{tr/?/0/;$_}@ARGV),0);map{my@W;while(($a,$b,$c,$A,$B,$C,$R)=splice@V,0,7){$A||=pi-$B-$C if($B*$C);if($a){if($A){$R||=$a/sin$A;}else{if($b*$c){$A=acos(($b*$b+$c*$c-$a*$a)/2/$b/$c);}elsif($R){$N=asin($a/$R);push@W,$b,$c,$a,$B,$C,$N,$R;$A=pi-$N;}}}else{$a=$R*sin$A;}push@W,$b,$c,$a,$B,$C,$A,$R if($a*$b*$c>=0);}@V=@W;}(1..9);print($V[0]?join' ',map{(((6-$i++)%7)?$_:"\n")}@V:"No solution\n");

Here in a more readable form:

use Math::Trig;
@V = ( ( map { tr/?/0/; $_ } @ARGV ), 0 );
map {
    my @W;
    while ( ( $a, $b, $c, $A, $B, $C, $R ) = splice @V, 0, 7 ) {
        $A ||= pi- $B - $C
             if ( $B * $C );
        if ($a) {
            if ($A) { $R ||= $a / sin $A; }
            else {
                if ( $b * $c ) {
                    $A = acos(
                        ( $b * $b + $c * $c - $a * $a ) / 2 / $b / $c );
                } elsif ($R) {
                    $N = asin( $a / $R );
                    push @W, $b, $c, $a, $B, $C, $N, $R;
                    $A = pi- $N;
                }
            }
        } else {
            $a = $R * sin $A;
        }
        push @W, $b, $c, $a, $B, $C, $A, $R
            if ( $a * $b * $c >= 0 );
    }
    @V = @W;
} ( 1 .. 9 );

print( $V[0]
         ? join ' ', map { ( ( ( 6 - $i++ ) % 7 ) ? $_ : "\n" ) } @V
         : "No solution\n" );


答:
Python 2, <s>1075</s> <s>1065</s> <s>1043</s> <s>1040</s> 1039 bytes

Each program has the form print'\<octal char code>', except:

' → print"\47"

0 through 8 → print~-<N+1>

9 → print-~8

\ → print'%c'%92

i → exec'pr\151nt"\151"'

n → exec'pri\156t"\156"'

p → exec'\160rint"\160"'

r → exec'p\162int"\162"'

t → exec'prin\164"\164"'

For reference and ease of testing, here's the full list of programs, newline-separated.

print'\40'
print'\41'
print'\42'
print'\43'
print'\44'
print'\45'
print'\46'
print"\47"
print'\50'
print'\51'
print'\52'
print'\53'
print'\54'
print'\55'
print'\56'
print'\57'
print~-1
print~-2
print~-3
print~-4
print~-5
print~-6
print~-7
print~-8
print~-9
print-~8
print'\72'
print'\73'
print'\74'
print'\75'
print'\76'
print'\77'
print'\100'
print'\101'
print'\102'
print'\103'
print'\104'
print'\105'
print'\106'
print'\107'
print'\110'
print'\111'
print'\112'
print'\113'
print'\114'
print'\115'
print'\116'
print'\117'
print'\120'
print'\121'
print'\122'
print'\123'
print'\124'
print'\125'
print'\126'
print'\127'
print'\130'
print'\131'
print'\132'
print'\133'
print'%c'%92
print'\135'
print'\136'
print'\137'
print'\140'
print'\141'
print'\142'
print'\143'
print'\144'
print'\145'
print'\146'
print'\147'
print'\150'
exec'pr\151nt"\151"'
print'\152'
print'\153'
print'\154'
print'\155'
exec'pri\156t"\156"'
print'\157'
exec'\160rint"\160"'
print'\161'
exec'p\162int"\162"'
print'\163'
exec'prin\164"\164"'
print'\165'
print'\166'
print'\167'
print'\170'
print'\171'
print'\172'
print'\173'
print'\174'
print'\175'
print'\176'
```

<p>To test:</p>

```$ python printables.py | sed ':a;N;$!ba;s/\n//g'
 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
```

-1 bytes thanks to @Sp3000!

Body:
Python 2, <s>1075</s> <s>1065</s> <s>1043</s> <s>1040</s> 1039 bytes

Each program has the form print'\<octal char code>', except:

' → print"\47"

0 through 8 → print~-<N+1>

9 → print-~8

\ → print'%c'%92

i → exec'pr\151nt"\151"'

n → exec'pri\156t"\156"'

p → exec'\160rint"\160"'

r → exec'p\162int"\162"'

t → exec'prin\164"\164"'

For reference and ease of testing, here's the full list of programs, newline-separated.

print'\40'
print'\41'
print'\42'
print'\43'
print'\44'
print'\45'
print'\46'
print"\47"
print'\50'
print'\51'
print'\52'
print'\53'
print'\54'
print'\55'
print'\56'
print'\57'
print~-1
print~-2
print~-3
print~-4
print~-5
print~-6
print~-7
print~-8
print~-9
print-~8
print'\72'
print'\73'
print'\74'
print'\75'
print'\76'
print'\77'
print'\100'
print'\101'
print'\102'
print'\103'
print'\104'
print'\105'
print'\106'
print'\107'
print'\110'
print'\111'
print'\112'
print'\113'
print'\114'
print'\115'
print'\116'
print'\117'
print'\120'
print'\121'
print'\122'
print'\123'
print'\124'
print'\125'
print'\126'
print'\127'
print'\130'
print'\131'
print'\132'
print'\133'
print'%c'%92
print'\135'
print'\136'
print'\137'
print'\140'
print'\141'
print'\142'
print'\143'
print'\144'
print'\145'
print'\146'
print'\147'
print'\150'
exec'pr\151nt"\151"'
print'\152'
print'\153'
print'\154'
print'\155'
exec'pri\156t"\156"'
print'\157'
exec'\160rint"\160"'
print'\161'
exec'p\162int"\162"'
print'\163'
exec'prin\164"\164"'
print'\165'
print'\166'
print'\167'
print'\170'
print'\171'
print'\172'
print'\173'
print'\174'
print'\175'
print'\176'

To test:

$ python printables.py | sed ':a;N;$!ba;s/\n//g'
 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

-1 bytes thanks to @Sp3000!


问:
Javascript tips: 2 to the power of x multiplied by n
I'm new to ES6 and code-golfing. Here's the original function:

function puzzle(n, x) {
  return n * Math.pow(2, x);
}```
</div>
</div>
</p>

<p>And here's what I have so far:</p>

```let puzzle=(n,x)=>n*2<<(x-1)
```

But the solution requires lesser characters. I went through the 'Code Golfing with ES6' thread, but couldn't find a better way.
Any help/links would be appreciated.

答:
17 bytes:

```<code>puzzle=n=>x=>n<<x
</code>```

This uses the fact that 2 * 2^n = 2^(n + 1). Also, by our rules, using currying instead of taking multiple arguments the usual way is allowed. Also, I don't think the let is needed.

Body:
17 bytes:

puzzle=n=>x=>n<<x

This uses the fact that 2 * 2^n = 2^(n + 1). Also, by our rules, using currying instead of taking multiple arguments the usual way is allowed. Also, I don't think the let is needed.


答:
Ruby, 869 bytes

For the 63 characters @ through ~, we have a 10-byte solution:

```<code>$><<"\xxx"     (3 digit octal code)
$><<92.chr     (special case for \)
</code>```

For most (21) characters from space through ?, we have a 9-byte solution:

```<code>puts"\xx"     (2 digit octal code)
</code>```

There are eleven special cases left:

```<code>$><<34.chr    (10 bytes for ")
p$.           (3 bytes for 0)
p~-2          \
p~-3           \ (4 bytes for 1-8)
...            /
p~-9          /
p 1+8         (5 bytes for 9)
</code>```

In total, the score is 10×63 + 9×21 + 10 + 3 + 8×4 + 5 = 869.

Body:
Ruby, 869 bytes

For the 63 characters @ through ~, we have a 10-byte solution:

$><<"\xxx"     (3 digit octal code)
$><<92.chr     (special case for \)

For most (21) characters from space through ?, we have a 9-byte solution:

puts"\xx"     (2 digit octal code)

There are eleven special cases left:

$><<34.chr    (10 bytes for ")
p$.           (3 bytes for 0)
p~-2          \
p~-3           \ (4 bytes for 1-8)
...            /
p~-9          /
p 1+8         (5 bytes for 9)

In total, the score is 10×63 + 9×21 + 10 + 3 + 8×4 + 5 = 869.


答:
Brachylog, <s>546</s> 477 bytes

Credits to Fatalize for the code for @.

In the list below, the first character is the character to be printed (for easy reference).

```
  @S
! @Ht
" @P:2m
# @P:3m
$ @P:4m
% @P:5m
& @P:6m
' @P:7m
( @P:8m
) @P:9m
* @P:10m
+ @P:11m
, @H:5m
- @P:13m
. @P:14m
/ @P:15m
0 1-
1 0+
2 1+
3 2+
4 3+
5 4+
6 5+
7 6+
8 7+
9 8+
: @P@4bhbbbh
; @P:27m
< @P:28m
= @P:29m
> @P:30m
? @P:31m
@ "?":"A"ybh
A @Zt@u
B @Ch@u
C @P:35m
D @P:36m
E @P:37m
F @P:38m
G @P:39m
H @P:40m
I @P:41m
J @P:42m
K @P:43m
L @P:44m
M @P:45m
N @P:46m
O @P:47m
P @A:15m@u
Q @P:49m
R @P:50m
S @P:51m
T @P:52m
U @Vt@u
V @P:54m
W @Qt@u
X @P:56m
Y @Wt@u
Z @At@u
[ @P:59m
\ @P:60m
] @P:61m
^ @P:62m
_ @P:63m
` @P:64m
a @Vh
b @Ch
c @Dbh
d @A:3m
e @Vbh
f @A:5m
g @A:6m
h @A:7m
i @A:8m
j @A:9m
k @C:7m
l @C:8m
m @D@2ht
n @A:13m
o @H:4m
p @A:15m
q @Z:9m
r @Z:8m
s @Z:7m
t @Z:6m
u @Vt
v @Z:4m
w @Qt
x @Z:2m
y @Wt
z @At
{ @P:91m
| @P:92m
} @Prbh
~ @Pt
```

They are all predicates, so Z needs to be the argument to receive the output: Try it online!

Explanation

@P is this string:

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

which contains every printable ASCII.

Body:
Brachylog, <s>546</s> 477 bytes

Credits to Fatalize for the code for @.

In the list below, the first character is the character to be printed (for easy reference).

  @S
! @Ht
" @P:2m
# @P:3m
$ @P:4m
% @P:5m
& @P:6m
' @P:7m
( @P:8m
) @P:9m
* @P:10m
+ @P:11m
, @H:5m
- @P:13m
. @P:14m
/ @P:15m
0 1-
1 0+
2 1+
3 2+
4 3+
5 4+
6 5+
7 6+
8 7+
9 8+
: @P@4bhbbbh
; @P:27m
< @P:28m
= @P:29m
> @P:30m
? @P:31m
@ "?":"A"ybh
A @Zt@u
B @Ch@u
C @P:35m
D @P:36m
E @P:37m
F @P:38m
G @P:39m
H @P:40m
I @P:41m
J @P:42m
K @P:43m
L @P:44m
M @P:45m
N @P:46m
O @P:47m
P @A:15m@u
Q @P:49m
R @P:50m
S @P:51m
T @P:52m
U @Vt@u
V @P:54m
W @Qt@u
X @P:56m
Y @Wt@u
Z @At@u
[ @P:59m
\ @P:60m
] @P:61m
^ @P:62m
_ @P:63m
` @P:64m
a @Vh
b @Ch
c @Dbh
d @A:3m
e @Vbh
f @A:5m
g @A:6m
h @A:7m
i @A:8m
j @A:9m
k @C:7m
l @C:8m
m @D@2ht
n @A:13m
o @H:4m
p @A:15m
q @Z:9m
r @Z:8m
s @Z:7m
t @Z:6m
u @Vt
v @Z:4m
w @Qt
x @Z:2m
y @Wt
z @At
{ @P:91m
| @P:92m
} @Prbh
~ @Pt

They are all predicates, so Z needs to be the argument to receive the output: Try it online!

Explanation

@P is this string:

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

which contains every printable ASCII.


问:
The Piggyback Sequence
I made my own sequence recently (called the Piggyback sequence), and it works like this:

P(1), P(2) and P(3) = 1.

For all P(n) where n>3, the sequence works like this:

```<code>P(n) = P(n-3) + P(n-2)/P(n-1)
</code>```

So, continuing the sequence:

P(4) = 1 + 1/1 = 2

P(5) = 1 + 1/2 = 3/2
= 1.5

P(6) = 1 + 2/(3/2) = 7/3
= 2.33333...

P(7) = 2 + (3/2)/(7/3) = 37/14 = 2.6428571428...

P(8) = 3/2 + (7/3)/(37/14) = 529/222
= 2.3828828828...

Your task is, when given n, calculate P(n) either as a floating point number or an (im)proper fraction.

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

If anyone can find the name of the sequence, please edit the post accordingly.

Current leaders: MATL and Jelly (both at 15 bytes).

答:
C, 46 bytes

float P(n){return n<4?1:P(n-3)+P(n-2)/P(n-1);}
```

Ideone

Title: The Piggyback Sequence

Body:
C, 46 bytes

float P(n){return n<4?1:P(n-3)+P(n-2)/P(n-1);}

Ideone


问:
Alphabet triangle strikes again

Task

Your task is to print this exact text:

```<code>A
BCD
EFGHI
JKLMNOP
QRSTUVWXY
ZABCDEFGHIJ
KLMNOPQRSTUVW
XYZABCDEFGHIJKL
MNOPQRSTUVWXYZABC
DEFGHIJKLMNOPQRSTUV
WXYZABCDEFGHIJKLMNOPQ
RSTUVWXYZABCDEFGHIJKLMN
OPQRSTUVWXYZABCDEFGHIJKLM
NOPQRSTUVWXYZABCDEFGHIJKLMN
OPQRSTUVWXYZABCDEFGHIJKLMNOPQ
RSTUVWXYZABCDEFGHIJKLMNOPQRSTUV
WXYZABCDEFGHIJKLMNOPQRSTUVWXYZABC
DEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL
MNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW
XYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ
KLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXY
ZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOP
QRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI
JKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCD
EFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZA
BCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ
</code>```

Specs

You may do it in all-lowercase instead of all-uppercase.

Trailing newlines at the end of the triangle is allowed.

Trailing spaces after each line is allowed.

You must print to STDOUT instead of outputting an array of strings.

Scoring

This is code-golf. Program with lowest byte-count wins.

答:
Haskell, 67 bytes

```<code>_#53=[]
s#i=take i s:drop i s#(i+2)
mapM putStrLn$cycle['A'..'Z']#1
</code>```

A simple recursion over the length i of the line. In each step the next i chars are taken from an infinite repetition of the alphabet.

Title: Alphabet triangle strikes again

Body:
Haskell, 67 bytes

_#53=[]
s#i=take i s:drop i s#(i+2)
mapM putStrLn$cycle['A'..'Z']#1

A simple recursion over the length i of the line. In each step the next i chars are taken from an infinite repetition of the alphabet.


答:
Pyth, 20 bytes

```<code>L?<b4h0+y-b3cy-b2ytb
</code>```

Try it online!

Title: The Piggyback Sequence

Body:
I made my own sequence recently (called the Piggyback sequence), and it works like this:

P(1), P(2) and P(3) = 1.

For all P(n) where n>3, the sequence works like this:

```<code>P(n) = P(n-3) + P(n-2)/P(n-1)
</code>```

So, continuing the sequence:

P(4) = 1 + 1/1 = 2

P(5) = 1 + 1/2 = 3/2
= 1.5

P(6) = 1 + 2/(3/2) = 7/3
= 2.33333...

P(7) = 2 + (3/2)/(7/3) = 37/14 = 2.6428571428...

P(8) = 3/2 + (7/3)/(37/14) = 529/222
= 2.3828828828...

Your task is, when given n, calculate P(n) either as a floating point number or an (im)proper fraction.

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

If anyone can find the name of the sequence, please edit the post accordingly.

Current leaders: MATL and Jelly (both at 15 bytes).

Body:
Pyth, 20 bytes

L?<b4h0+y-b3cy-b2ytb

Try it online!


问:
Who's that Pokémon?
Input: an integer N between 1 and 151

Output: the Nth Pokemon.

Rules

You may use one data file.

You may not use any already made data decompression algorithms.  This includes libraries and other programs.

Your program may not access files other than itself and your data file.

Scoring

Your score is the sum of the length of your code and data file.

Helpful Stuff

Here's a list of the first 151 pokemon separated by semicolons to help you generate your data file.  Your output should exactly match the Nth entry of this line:

```<code>Bulbasaur;Ivysaur;Venusaur;Charmander;Charmeleon;Charizard;Squirtle;Wartortle;Blastoise;Caterpie;Metapod;Butterfree;Weedle;Kakuna;Beedrill;Pidgey;Pidgeotto;Pidgeot;Rattata;Raticate;Spearow;Fearow;Ekans;Arbok;Pikachu;Raichu;Sandshrew;Sandslash;Nidoran (f);Nidorina;Nidoqueen;Nidoran (m);Nidorino;Nidoking;Clefairy;Clefable;Vulpix;Ninetales;Jigglypuff;Wigglytuff;Zubat;Golbat;Oddish;Gloom;Vileplume;Paras;Parasect;Venonat;Venomoth;Diglett;Dugtrio;Meowth;Persian;Psyduck;Golduck;Mankey;Primeape;Growlith;Arcanine;Poliwag;Poliwhirl;Poliwrath;Abra;Kadabra;Alakazam;Machop;Machoke;Machamp;Bellsprout;Weepinbell;Victreebell;Tentacool;Tentacruel;Geodude;Graveler;Golem;Ponyta;Rapidash;Slowpoke;Slowbro;Magnemite;Magneton;Farfetch'd;Doduo;Dodrio;Seel;Dewgong;Grimer;Muk;Shellder;Cloyster;Gastly;Haunter;Gengar;Onix;Drowsee;Hypno;Krabby;Kingler;Voltorb;Electrode;Exeggute;Exeggutor;Cubone;Marowak;Hitmonlee;Hitmonchan;Lickitung;Koffing;Weezing;Rhyhorn;Rhydon;Chansey;Tangela;Kangaskhan;Horsea;Seadra;Goldeen;Seaking;Staryu;Starmie;Mr. Mime;Scyther;Jynx;Electabuzz;Magmar;Pinsir;Tauros;Magikarp;Gyarados;Lapras;Ditto;Eevee;Vaporeon;Jolteon;Flareon;Porygon;Omanyte;Omastar;Kabuto;Kabutops;Aerodactyl;Snorlax;Articuno;Zapdos;Moltres;Dratini;Dragonair;Dragonite;Mewtwo;Mew
</code>```

答:
PHP 919 (925) bytes

As with Peter Taylor's answer, I also cannot post my solution directly, so instead i'll post a program that generates it:

```<code><?php
$data = <<<EOD
PD9mb3IoJG89J5SWUHYPaY6dSs/pjsJBMS1pRDc1yZ3AUcQkNcnZsYIkJDXtpa4UB4mOMNH8zbDbcDhcKD
VYu89cFyjRlBm8GSjMiFSxCNHitpn8Kdi43B+XUkX2gVjN8LQEmEkF5D2zE9gbTD3z6djUJQAVFXwlXV/o
kVwnsV1rW5J9zpssN3JXdW5LjAS3DYTcBtV/YUdtoAfGC+ztsoc1LxQamD5lmQMaes37flJcGvg7CdkS+s
1bhZLjAQQtmL5tS3rN+2eS7LeROnX9nOCRRWhRQhFkBDSN0igwMUwem4BNYVrkxZuAzUEiRDG+KFODVqV0
KDAvpLM747wC0AwYUVkELsVsBA5vyThUQQtiKFRBK6EYnBC7oMiAkJtYbXOZk9scdPF3hTJEh7hhZ4yDEG
FHzJ1vSfxkDVkd8fz+u6ConHVH7Y3SHFtgq20M22ALpO40xMC9vmictX6lf+2VfqV1EBctRRwZ38RceT3E
G2l5PcTVTFahWEdGGYhjKSwy5lBYAn944VmhWNQRkvXDw5SAkpV/URm0SZPBOPweZUGwDlODERHEwt0VfK
X9WG+kp9tbe+d8oLvu1uw9+6ExyFwZe6LogoTF7oG3RCiUm0GTcJsmcyxJmdRR68Oi7P4NmQ6ZlwxE8djR
DtfANTjRZBOvWE281RLRDtPJY05E4k10BkvfCRwNLKssXh4GHB+SgBFEwsDbHsSxMdhmCBExsfvZKLzEEY
uZ26SXfutBOR1rezc8/XmT6HkcHciTBwTSxD1cJ+XBcmyjis2S7ClZLZJMTG2bngTs7VtCN3VSaQUAcuPQ
VR9yY0+ntSTcnhcdZ4n4JtzDwPHZJEl9pZJsONV96ad1jpV5eVhpldF8r7WcMeRd8hSxMXjVEcZEPZsdLg
SSd+4kNY7L7Bkbdy10VDVuJdtfGOyG7yydwJux2SFcAiz7QSIEa8BxAoQIFUFCRJt+G6KkoZ3d8fzBPZhO
xG2eaIwfvrGb54zZ7mgfGPA0Qp6I5NSund9SSw5MUD8M0wAmzywmSF2N/CZbw8V1JEZF42LIXJmLeIM5uU
wnOzc4OD4kbjspJGY9c3BsaXQonywkeC49Y2hyKDMxJiR2PSsrJGklOCUzPzgqJHZeb3JkKCRvWyRuKytd
KTokdj4+NSleiyk7ZWNob35zdHJ0cigkZlsrZmdldHMoU1RESU4pXXygLICEgYOCLNfY1tHfKTsNCg==
EOD;
print base64_decode($data);
?>
</code>```

Sample I/O:

```<code>$ php generator.php > out.php

$ echo 12 | php out.php
Butterfree

$ echo 32 | php out.php
Nidoran (m)

$ echo 83 | php out.php
Farfetch'd

$ echo 122 | php out.php
Mr. mime

$ echo 151 | php out.php
Mew
</code>```

How it works (spoiler):

This code operates on the observation that there are only 32 unique characters, including a separator - if you're not counting capitals. This immediately implies a 5:8 encoding; only 5 bits are needed to represent each byte.

I accomplish this in the following manner:

++$i%8%3

When this value is non-zero, a new byte is read, and when zero, the next byte is generated from the previously read bytes. The 3rd, 6th, and 8th byte are generated in this manner, and then the process repeats.

The bit distribution follows accordingly. If for example you wanted to produce the string:

abcdefgh

The bits for each are distributed among the 5 source bytes in the following fashion:

hccaaaaa|cccbbbbb|hffddddd|fffeeeee|hhhggggg

After generating c, only the top most bit of h remains, after generating f, the top two bits of h remain, and after reading g, h remains in its entirety (I save a few shift operations by using xored values instead, for example the value I load for the second byte is the value I want xor a<<3, but that's the gist of it).

This produces characters on the range of [0,31]. By xoring by any character on the range [96,127], all characters will be mapped to that range (I chose 116, because it resulted in the least amount of escape sequences). After that, it's a simple matter of translating the 5 characters that don't belong there with their appropriate replacements, and capitalizing the first letter. This code requires three bytes to do so: oring the (previously generated as such) bit inverted string with char 160, and then bit inverting back.  A small caveat: the second m in 'Mr. mime' is not capitalized by this method. This could be repaired by replacing the method described above with the ucwords() function, at the cost of 6 bytes, resulting in a code length of 925, instead of 919.

Title: Who's that Pokémon?

Body:
PHP 919 (925) bytes

As with Peter Taylor's answer, I also cannot post my solution directly, so instead i'll post a program that generates it:

<?php
$data = <<<EOD
PD9mb3IoJG89J5SWUHYPaY6dSs/pjsJBMS1pRDc1yZ3AUcQkNcnZsYIkJDXtpa4UB4mOMNH8zbDbcDhcKD
VYu89cFyjRlBm8GSjMiFSxCNHitpn8Kdi43B+XUkX2gVjN8LQEmEkF5D2zE9gbTD3z6djUJQAVFXwlXV/o
kVwnsV1rW5J9zpssN3JXdW5LjAS3DYTcBtV/YUdtoAfGC+ztsoc1LxQamD5lmQMaes37flJcGvg7CdkS+s
1bhZLjAQQtmL5tS3rN+2eS7LeROnX9nOCRRWhRQhFkBDSN0igwMUwem4BNYVrkxZuAzUEiRDG+KFODVqV0
KDAvpLM747wC0AwYUVkELsVsBA5vyThUQQtiKFRBK6EYnBC7oMiAkJtYbXOZk9scdPF3hTJEh7hhZ4yDEG
FHzJ1vSfxkDVkd8fz+u6ConHVH7Y3SHFtgq20M22ALpO40xMC9vmictX6lf+2VfqV1EBctRRwZ38RceT3E
G2l5PcTVTFahWEdGGYhjKSwy5lBYAn944VmhWNQRkvXDw5SAkpV/URm0SZPBOPweZUGwDlODERHEwt0VfK
X9WG+kp9tbe+d8oLvu1uw9+6ExyFwZe6LogoTF7oG3RCiUm0GTcJsmcyxJmdRR68Oi7P4NmQ6ZlwxE8djR
DtfANTjRZBOvWE281RLRDtPJY05E4k10BkvfCRwNLKssXh4GHB+SgBFEwsDbHsSxMdhmCBExsfvZKLzEEY
uZ26SXfutBOR1rezc8/XmT6HkcHciTBwTSxD1cJ+XBcmyjis2S7ClZLZJMTG2bngTs7VtCN3VSaQUAcuPQ
VR9yY0+ntSTcnhcdZ4n4JtzDwPHZJEl9pZJsONV96ad1jpV5eVhpldF8r7WcMeRd8hSxMXjVEcZEPZsdLg
SSd+4kNY7L7Bkbdy10VDVuJdtfGOyG7yydwJux2SFcAiz7QSIEa8BxAoQIFUFCRJt+G6KkoZ3d8fzBPZhO
xG2eaIwfvrGb54zZ7mgfGPA0Qp6I5NSund9SSw5MUD8M0wAmzywmSF2N/CZbw8V1JEZF42LIXJmLeIM5uU
wnOzc4OD4kbjspJGY9c3BsaXQonywkeC49Y2hyKDMxJiR2PSsrJGklOCUzPzgqJHZeb3JkKCRvWyRuKytd
KTokdj4+NSleiyk7ZWNob35zdHJ0cigkZlsrZmdldHMoU1RESU4pXXygLICEgYOCLNfY1tHfKTsNCg==
EOD;
print base64_decode($data);
?>

Sample I/O:

$ php generator.php > out.php

$ echo 12 | php out.php
Butterfree

$ echo 32 | php out.php
Nidoran (m)

$ echo 83 | php out.php
Farfetch'd

$ echo 122 | php out.php
Mr. mime

$ echo 151 | php out.php
Mew

How it works (spoiler):

This code operates on the observation that there are only 32 unique characters, including a separator - if you're not counting capitals. This immediately implies a 5:8 encoding; only 5 bits are needed to represent each byte.

I accomplish this in the following manner:

++$i%8%3

When this value is non-zero, a new byte is read, and when zero, the next byte is generated from the previously read bytes. The 3rd, 6th, and 8th byte are generated in this manner, and then the process repeats.

The bit distribution follows accordingly. If for example you wanted to produce the string:

abcdefgh

The bits for each are distributed among the 5 source bytes in the following fashion:

hccaaaaa|cccbbbbb|hffddddd|fffeeeee|hhhggggg

After generating c, only the top most bit of h remains, after generating f, the top two bits of h remain, and after reading g, h remains in its entirety (I save a few shift operations by using xored values instead, for example the value I load for the second byte is the value I want xor a<<3, but that's the gist of it).

This produces characters on the range of [0,31]. By xoring by any character on the range [96,127], all characters will be mapped to that range (I chose 116, because it resulted in the least amount of escape sequences). After that, it's a simple matter of translating the 5 characters that don't belong there with their appropriate replacements, and capitalizing the first letter. This code requires three bytes to do so: oring the (previously generated as such) bit inverted string with char 160, and then bit inverting back.  A small caveat: the second m in 'Mr. mime' is not capitalized by this method. This could be repaired by replacing the method described above with the ucwords() function, at the cost of 6 bytes, resulting in a code length of 925, instead of 919.


答:
Jelly, 10 bytes

```<code>26RḤ’RØAṁY
</code>```

Try it online!

How it works

```<code>26RḤ’RØAṁY  Main link. No Arguments.

26          Set the return value to 26.
  R         Range; yield [1, 2, ..., 25, 26].
   Ḥ        Unhalve; yield [2, 4, ..., 50, 52].
    ’       Decrement; yield [1, 3, ..., 49, 51].
     R      Range; yield [[1], [1, 2, 3], ..., [1, ..., 49], [1, ..., 51]].
      ØA    Yield the uppercase alphabet.
        ṁ   Mold the alphabet as the array of ranges. This repeats the uppercase
            letters over an over again, until all integers in the range arrays
            have been replaced with letters.
         Y  Join, separating by linefeeds.
</code>```

Title: Alphabet triangle strikes again

Body:
Task

Your task is to print this exact text:

```<code>A
BCD
EFGHI
JKLMNOP
QRSTUVWXY
ZABCDEFGHIJ
KLMNOPQRSTUVW
XYZABCDEFGHIJKL
MNOPQRSTUVWXYZABC
DEFGHIJKLMNOPQRSTUV
WXYZABCDEFGHIJKLMNOPQ
RSTUVWXYZABCDEFGHIJKLMN
OPQRSTUVWXYZABCDEFGHIJKLM
NOPQRSTUVWXYZABCDEFGHIJKLMN
OPQRSTUVWXYZABCDEFGHIJKLMNOPQ
RSTUVWXYZABCDEFGHIJKLMNOPQRSTUV
WXYZABCDEFGHIJKLMNOPQRSTUVWXYZABC
DEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL
MNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW
XYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ
KLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXY
ZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOP
QRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI
JKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCD
EFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZA
BCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ
</code>```

Specs

You may do it in all-lowercase instead of all-uppercase.

Trailing newlines at the end of the triangle is allowed.

Trailing spaces after each line is allowed.

You must print to STDOUT instead of outputting an array of strings.

Scoring

This is code-golf. Program with lowest byte-count wins.

Body:
Jelly, 10 bytes

26RḤ’RØAṁY

Try it online!

How it works

26RḤ’RØAṁY  Main link. No Arguments.

26          Set the return value to 26.
  R         Range; yield [1, 2, ..., 25, 26].
   Ḥ        Unhalve; yield [2, 4, ..., 50, 52].
    ’       Decrement; yield [1, 3, ..., 49, 51].
     R      Range; yield [[1], [1, 2, 3], ..., [1, ..., 49], [1, ..., 51]].
      ØA    Yield the uppercase alphabet.
        ṁ   Mold the alphabet as the array of ranges. This repeats the uppercase
            letters over an over again, until all integers in the range arrays
            have been replaced with letters.
         Y  Join, separating by linefeeds.


答:
BBC Basic, <s>422</s> 413 bytes

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

9 bytes saved thanks to Leaky Nun.

General form

```<code>V.<character code>
</code>```

32..99 excluding 12 special cases: 56x4= 224 bytes

100..126 : 27x5= 135 bytes

12 special cases : 54 bytes

Most numbers follow the general form, but I included them all here to show where the problem is.

First character is the character to be printed.

```<code>. VDU46       :REM Full form of the command used in general form: send character 46 to VDU)
V P.CHR$86    :REM short for PRINT CHR$(86)
0 V.48
1 V.49
2 V.50
3 V.51
4 V.52
5 P.1+4
6 V.54
7 V.55
8 V.56
9 V.57
</code>```

Body:
BBC Basic, <s>422</s> 413 bytes

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

9 bytes saved thanks to Leaky Nun.

General form

V.<character code>

32..99 excluding 12 special cases: 56x4= 224 bytes

100..126 : 27x5= 135 bytes

12 special cases : 54 bytes

Most numbers follow the general form, but I included them all here to show where the problem is.

First character is the character to be printed.

. VDU46       :REM Full form of the command used in general form: send character 46 to VDU)
V P.CHR$86    :REM short for PRINT CHR$(86)
0 V.48
1 V.49
2 V.50
3 V.51
4 V.52
5 P.1+4
6 V.54
7 V.55
8 V.56
9 V.57


答:
Ruby, 34 bytes

Since Ruby uses integer division by default, it turns out that it's shorter to use fractions instead. Golfing suggestions welcome.

```<code>f=->n{n<4?1r:f[n-3]+f[n-2]/f[n-1]}
</code>```

Title: The Piggyback Sequence

Body:
Ruby, 34 bytes

Since Ruby uses integer division by default, it turns out that it's shorter to use fractions instead. Golfing suggestions welcome.

f=->n{n<4?1r:f[n-3]+f[n-2]/f[n-1]}


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

<s>

{(0,1,1,1,*+*/*...*)[$_]}
```

<p></s></p>

<pre class="lang-perl6 prettyprint-override"><code>{(0,1,1,*+*/*...*)[$_]}
</code>```

Explanation:

# bare block lambda with implicit parameter ｢$_｣
{
  (
    # initial set-up
    # the ｢0｣ is for P(0) which isn't defined
    0, 1, 1, 1,

    # Whatever lambda implementing the algorithm
    * + * / *
    # { $^a + $^b / $^c }

    # keep using the lambda to generate new values until
    ...

    # Whatever (Forever)
    *

   # get the value indexed by the argument
  )[ $_ ]
}
```

<p>This returns a Rat (Rational) for inputs starting with 3 up until the result would start having a denominator bigger than can fit in a 64 bit integer, at which point it starts returning Nums (floating point).<br>
The last Rat it will return is <code>P(11) == 8832072277617 / 2586200337022</code></p>

<p>If you want it to return Rational numbers rather than floats you can swap it for the following which will return a FatRat instead.</p>

<pre class="lang-perl6 prettyprint-override"><code>{(0.FatRat,1,1,*+*/*...*)[$_]}
</code>```

Test:

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

my &piggyback = {(0,1,1,*+*/*...*)[$_]}
# */ # stupid highlighter no Perl will ever have C/C++ comments

my @test = (
  1, 1, 1, 2,
  3/2, 7/3, 37/14,
  529 / 222,
  38242 / 11109,
  66065507 / 19809356,
  8832072277617 / 2586200337022,
);

plan +@test;

for 1..* Z @test -> ($input,$expected) {
  cmp-ok piggyback($input), &[==], $expected, $expected.perl;
}
```

Title: The Piggyback Sequence

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

<s>

{(0,1,1,1,*+*/*...*)[$_]}

</s>

{(0,1,1,*+*/*...*)[$_]}

Explanation:

# bare block lambda with implicit parameter ｢$_｣
{
  (
    # initial set-up
    # the ｢0｣ is for P(0) which isn't defined
    0, 1, 1, 1,

    # Whatever lambda implementing the algorithm
    * + * / *
    # { $^a + $^b / $^c }

    # keep using the lambda to generate new values until
    ...

    # Whatever (Forever)
    *

   # get the value indexed by the argument
  )[ $_ ]
}

This returns a Rat (Rational) for inputs starting with 3 up until the result would start having a denominator bigger than can fit in a 64 bit integer, at which point it starts returning Nums (floating point).

The last Rat it will return is P(11) == 8832072277617 / 2586200337022

If you want it to return Rational numbers rather than floats you can swap it for the following which will return a FatRat instead.

{(0.FatRat,1,1,*+*/*...*)[$_]}

Test:

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

my &piggyback = {(0,1,1,*+*/*...*)[$_]}
# */ # stupid highlighter no Perl will ever have C/C++ comments

my @test = (
  1, 1, 1, 2,
  3/2, 7/3, 37/14,
  529 / 222,
  38242 / 11109,
  66065507 / 19809356,
  8832072277617 / 2586200337022,
);

plan +@test;

for 1..* Z @test -> ($input,$expected) {
  cmp-ok piggyback($input), &[==], $expected, $expected.perl;
}


问:
Can you outgolf me? (Robbers section)

Robbers section

The cops section can be found here.

Challenge

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

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

You could outgolf the cop by doing the following:

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

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

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

Post this with the following header:

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

For example:

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

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

Computes A005843, (offset = 0).

In that case, you have cracked the submission.

Scoring

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

Rules

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

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

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

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

Note

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

feersum: 16 cracks

Dennis: 12 cracks

Leaky Nun: 6 cracks

Lynn: 4 cracks

miles: 3 cracks

Martin Ender: 2 cracks

Emigna: 2 cracks

jimmy23013: 1 crack

Sp3000: 1 crack

randomra: 1 crack

alephalpha: 1 crack

nimi: 1 crack

Destructible Watermelon: 1 crack

Dom Hastings: 1 crack

答:
M, <s>18</s> 17 bytes, Dennis

Tragically, Dennis has missed a trivial modification this time. Only the first line is different.

```<code>Ḥrc
‘Ḥc0r$×Ç:‘+\S
</code>```

Title: Can you outgolf me? (Robbers section)

Body:
M, <s>18</s> 17 bytes, Dennis

Tragically, Dennis has missed a trivial modification this time. Only the first line is different.

Ḥrc
‘Ḥc0r$×Ç:‘+\S


问:
Score my golf round!
Since this SE community is about golfing, I thought a golf-related challenge would be appropriate.

Explanation

Normally, the objective of golf is to finish a hole (and consequently, the entire round) with the least amount of strokes. This is a simple version of golf: Play until you hole the ball and sum up your score. Finally subtract it from the total par and the resulting number indicates your score: 0 if you played exactly par, positive if you played worse and negative if you played better.

But in 1898 a guy named Dr. Frank Barney Gorton Stableford devised a new system of playing which was designed to be more forgiving. This system awards a number of points to a player, based on a relative rating per hole, called the stroke index (SI) which is based on a player rating called handicap. This limits the amount of points a player can lose per hole. Additionally, the handiccp ensures fair competition between players despite skill difference.

This format isn't used in professional golf, but can be found almost anywhere in amateur golf.

The scoring algorithm

For anyone unfamiliar with golf, the algorithm for scoring a hole based version is as follows.

Beginning with the hardest hole (rating 1) to the easiest one (rating 18), increase the stroke index of that hole by 1 and decrement the handicap. If you exhaust the handicap, stop. If you hit the easiest hole you wrap around to the hardest and continue. (Ex: stroke index for hcp 24 and [1..18]: [2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1]).

For every score on a hole, subtract it from the sum of par and stroke index and add 2 (formula: (par + stroke index) - achieved score + 2). These are the stableford points received for that hole. Note that you cannot receive less than 0 points.

Sum up all the points. The resulting total is the total number of stableford points.

Thus, reaching 36 points is equivalent to playing exactly one's handicap, and more points are better.

Rules

Your task will be to calculate the total number of stableford points of an arbitrary golf round on an arbitrary golf course given a handicap.

You will be given a list of difficulty ratings, a list of pars, a list of scores and the handicap to use. You may order these arguments as you wish, but please state how you order them.

You may write a function ot program, input can be taken either as command line argument or function argument.

Output may either be printed to STDOUT or the return value of a function.

You may assume the following about the input:

Every list will contain exactly 18 elements.

The lists are orderd by hole: First element = info for first hole, etc.

The handicap will be an integer between 0 and 54 inclusive.

Pars will be between 3 and 7.

The score is always a positive integer.

The difficulty rating list will always be a permutation of [1..18].

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

Examples

```<code>Input: hcp: 0
       difficulty: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]
       pars: [3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5]
       score: [3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5]
Output: 36

Input: hcp: 15
       difficulty: [9,3,1,13,11,17,15,7,5,18,14,10,4,6,12,16,8,2]
       pars: [4,4,4,3,5,4,3,4,4,4,3,4,4,4,5,3,5,4]
       score: [5,5,4,5,4,4,4,4,5,7,3,5,5,6,4,6,5,5]
Output: 38

Input: hcp: 28
       difficulty: [9,3,1,13,11,17,15,7,5,18,14,10,4,6,12,16,8,2]
       pars: [4,4,4,3,5,4,3,4,4,4,3,4,4,4,5,3,5,4]
       score: [5,5,5,6,3,7,3,6,5,8,4,6,7,8,4,7,6,5]
Outut: 37

Input: hcp: 54
       difficulty: [9,3,1,13,11,17,15,7,5,18,14,10,4,6,12,16,8,2]
       pars: [4,4,4,3,5,4,3,4,4,4,3,4,4,4,5,3,5,4]
       score: [9,10,9,10,9,10,9,10,9,10,9,10,9,10,9,10,9,10]
Output: 3
</code>```

Happy golfing!

答:
Python 3, 71 bytes

```<code>lambda h,d,p,s:sum(max(0,j+(h%18>=i)+h//18-k+2)for i,j,k in zip(d,p,s))
</code>```

An anonymous function that takes input via argument of a handicap h as an integer, and difficulties d, pars p and scores s as lists, and returns the overall score.

How it works

```<code>lambda h,d,p,s           Anonymous funtion with inputs handicap h, difficulties d, pars p
                         and scores s
for i,j,k in zip(d,p,s)  For each (difficulty, par, score) set (i, j, k):
  (h%18>=i)+h//18          Calculate the stroke index...
  j+...-k+2                ..calculate (par + stroke index) - score + 2...
  max(0,...)               ...and clamp negative values to zero
:sum(...)                Return the sum of the above over all holes, which is the overall
                         score
</code>```

Try it on Ideone

Title: Score my golf round!

Body:
Python 3, 71 bytes

lambda h,d,p,s:sum(max(0,j+(h%18>=i)+h//18-k+2)for i,j,k in zip(d,p,s))

An anonymous function that takes input via argument of a handicap h as an integer, and difficulties d, pars p and scores s as lists, and returns the overall score.

How it works

lambda h,d,p,s           Anonymous funtion with inputs handicap h, difficulties d, pars p
                         and scores s
for i,j,k in zip(d,p,s)  For each (difficulty, par, score) set (i, j, k):
  (h%18>=i)+h//18          Calculate the stroke index...
  j+...-k+2                ..calculate (par + stroke index) - score + 2...
  max(0,...)               ...and clamp negative values to zero
:sum(...)                Return the sum of the above over all holes, which is the overall
                         score

Try it on Ideone


答:
Cheddar, 31 bytes

```<code>n P->n<4?1:P(n-3)+P(n-2)/P(n-1)
</code>```

The ungolfed version is so clear imo you don't need explanation:

```<code>n P->
  n < 4 ? 1 : P(n-3) + P(n-2) / P(n-1)
</code>```

basically after the function arguments you can specify the variable to use which will be set to the function itself. Why? because this function will be tail-call-optimized, or at least should be.

Title: The Piggyback Sequence

Body:
Cheddar, 31 bytes

n P->n<4?1:P(n-3)+P(n-2)/P(n-1)

The ungolfed version is so clear imo you don't need explanation:

n P->
  n < 4 ? 1 : P(n-3) + P(n-2) / P(n-1)

basically after the function arguments you can specify the variable to use which will be set to the function itself. Why? because this function will be tail-call-optimized, or at least should be.


答:
Haskel, 32 bytes

```<code>(a#b)c=a:(b#c)(a+b/c)
((0#1)1!!)
</code>```

Usage example:  ((0#1)1!!) 7 -> 2.642857142857143. I start the sequence with 0, 1, 1 to fix !!'s 0-based indexing.

Edit: @xnor found a way to switch from 0-based to 1-based index, without changing the byte count.

Title: The Piggyback Sequence

Body:
Haskel, 32 bytes

(a#b)c=a:(b#c)(a+b/c)
((0#1)1!!)

Usage example:  ((0#1)1!!) 7 -> 2.642857142857143. I start the sequence with 0, 1, 1 to fix !!'s 0-based indexing.

Edit: @xnor found a way to switch from 0-based to 1-based index, without changing the byte count.


答:
JavaScript (ES6), <s>1083</s> 1068 bytes

General form:

```<code>alert`\xhex`
</code>```

Exceptions:

```<code>0 alert(9-9)
...
8 alert(9-1)
9 alert(8+1)
\ alert(atob`XA`)
` alert('\x60')
a \u0061lert`\x61`
e al\u0065rt`\x65`
l a\u006cert`\x6c`
r ale\u0072t`\x72`
t aler\u0074`\x74`
x alert`\u0078`
</code>```

Edit: Saved 15 bytes thanks to @GOTO0.

Body:
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:
JavaScript (ES6), <s>1083</s> 1068 bytes

General form:

alert`\xhex`

Exceptions:

0 alert(9-9)
...
8 alert(9-1)
9 alert(8+1)
\ alert(atob`XA`)
` alert('\x60')
a \u0061lert`\x61`
e al\u0065rt`\x65`
l a\u006cert`\x6c`
r ale\u0072t`\x72`
t aler\u0074`\x74`
x alert`\u0078`

Edit: Saved 15 bytes thanks to @GOTO0.


Body:
WolframAlpha, 368 bytes

General format:

u+<character code in hexadecimal>

Exceptions:

Character   Code
+           plus
0           1-1
1           0!
2           1+1
3           1+2
4           2+2
5           2+3
6           3!
7           3+4
8           4+4
9           4+5
u           U+75

Here is the full list:

u+20
u+21
u+22
u+23
u+24
u+25
u+26
u+27
u+28
u+29
u+2A
plus
u+2C
u+2D
u+2E
u+2F
1-1
0!
1+1
1+2
2+2
2+3
3!
3+4
4+4
4+5
u+3A
u+3B
u+3C
u+3D
u+3E
u+3F
u+40
u+41
u+42
u+43
u+44
u+45
u+46
u+47
u+48
u+49
u+4A
u+4B
u+4C
u+4D
u+4E
u+4F
u+50
u+51
u+52
u+53
u+54
u+55
u+56
u+57
u+58
u+59
u+5A
u+5B
u+5C
u+5D
u+5E
u+5F
u+60
u+61
u+62
u+63
u+64
u+65
u+66
u+67
u+68
u+69
u+6A
u+6B
u+6C
u+6D
u+6E
u+6F
u+70
u+71
u+72
u+73
u+74
U+75
u+76
u+77
u+78
u+79
u+7A
u+7B
u+7C
u+7D
u+7E


问:
Rand5() to Rand7()
You are provided with a function Rand5(). This function returns perfectly random (equal distribution) integers between 1 and 5.

Provide the function Rand7(), which uses Rand5() to produce perfectly random integers between 1 and 7.

答:
PostScript (46)

This uses binary token encoding, therefore, here is a hexdump:

```<code>00000000  2f 72 61 6e 64 37 7b 38  7b 92 38 37 92 61 7b 92  |/rand7{8{.87.a{.|
00000010  40 7d 69 66 92 75 32 7b  72 61 6e 64 35 7d 92 83  |@}if.u2{rand5}..|
00000020  35 92 6c 92 01 35 92 a9  7d 92 65 7d 92 33        |5.l..5..}.e}.3|
0000002e
</code>```

To try it out, you can also download it.

Here is the ungolfed and commented code, together with testing code.

```<code>% This is the actual rand7 procedure.
/rand7{
  8{                      % potentialResult
    % only if the random number is less than or equal to 7, we're done
    dup 7 le{             % result
      exit                % result
    }if                   % potentialResult
    pop                   % -/-
    2{rand5}repeat        % randomNumber1 randomNumber2
    5 mul add 5 sub       % randomNumber1 + 5*randomNumber2 - 5 = potentialResult
  }loop
}def

%Now, some testing code.

% For testing, we use the built-in rand operator;
% Doesn't really give a 100% even distribution as it returns numbers
% from 0 to 2^31-1, which is of course not divisible by 5.
/rand5 {
  rand 5 mod 1 add
}def

% For testing, we initialize a dict that counts the number of times any number
% has been returned. Of course, we start the count at 0 for every number.
<<1 1 7{0}for>>begin

% Now we're calling the function quite a number of times
% and increment the counters accordingly.
1000000 {
  rand7 dup load 1 add def
}repeat

% Print the results
currentdict{
  2 array astore ==
}forall
</code>```

ContentLicense: CC BY-SA 2.5

Title: Rand5() to Rand7()

Body:
PostScript (46)

This uses binary token encoding, therefore, here is a hexdump:

00000000  2f 72 61 6e 64 37 7b 38  7b 92 38 37 92 61 7b 92  |/rand7{8{.87.a{.|
00000010  40 7d 69 66 92 75 32 7b  72 61 6e 64 35 7d 92 83  |@}if.u2{rand5}..|
00000020  35 92 6c 92 01 35 92 a9  7d 92 65 7d 92 33        |5.l..5..}.e}.3|
0000002e

To try it out, you can also download it.

Here is the ungolfed and commented code, together with testing code.

% This is the actual rand7 procedure.
/rand7{
  8{                      % potentialResult
    % only if the random number is less than or equal to 7, we're done
    dup 7 le{             % result
      exit                % result
    }if                   % potentialResult
    pop                   % -/-
    2{rand5}repeat        % randomNumber1 randomNumber2
    5 mul add 5 sub       % randomNumber1 + 5*randomNumber2 - 5 = potentialResult
  }loop
}def

%Now, some testing code.

% For testing, we use the built-in rand operator;
% Doesn't really give a 100% even distribution as it returns numbers
% from 0 to 2^31-1, which is of course not divisible by 5.
/rand5 {
  rand 5 mod 1 add
}def

% For testing, we initialize a dict that counts the number of times any number
% has been returned. Of course, we start the count at 0 for every number.
<<1 1 7{0}for>>begin

% Now we're calling the function quite a number of times
% and increment the counters accordingly.
1000000 {
  rand7 dup load 1 add def
}repeat

% Print the results
currentdict{
  2 array astore ==
}forall


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

答:
Senva, <s>9 bytes</s> 4 bytes

There is two ways to write this program, let's begin by the longest :

```<code>82.8--8-~
</code>```

This stores 82 in the memory, substract 8, 8 again, 1, then display the memory as an ASCII char (65 is the ASCII code of A). The cell's value is 82 - 8 - 8 - 1 = 65.

The second way is a little bit pernicious :

```<code>B_-~
</code>```

This converts the 'B' character to its ASCII char code, substract 1, and then display it as an ASCII char.

Title: The Letter A without A

Body:
Senva, <s>9 bytes</s> 4 bytes

There is two ways to write this program, let's begin by the longest :

82.8--8-~

This stores 82 in the memory, substract 8, 8 again, 1, then display the memory as an ASCII char (65 is the ASCII code of A). The cell's value is 82 - 8 - 8 - 1 = 65.

The second way is a little bit pernicious :

B_-~

This converts the 'B' character to its ASCII char code, substract 1, and then display it as an ASCII char.


答:
PHP, 12 bytes

```<code><?=chr(833);
</code>```

Due to an overflow the above produces an 'A' (see example 2 of the PHP doc).

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:
PHP, 12 bytes

<?=chr(833);

Due to an overflow the above produces an 'A' (see example 2 of the PHP doc).


问:
Approximation of e
We all know that the Euler's number, denoted by \$e\$, to the power of some variable \$x\$, can be approximated by using the Maclaurin Series expansion:

$$e^x=\sum_{k=0}^{\infty}{\frac{x^k}{k!}}=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\frac{x^4}{4!}+\dots$$

By letting \$x\$ equal \$1\$, we obtain

$$\sum_{k=0}^{\infty}{\frac{1}{k!}{=\frac{1}{0!}+\frac{1}{1!}+\frac{1}{2!}+\frac{1}{3!}+\frac{1}{4!}+\dots\\=1+1+\frac{1}{2}+\frac{1}{6}+\frac{1}{24}+\dots}}$$

Challenge

Write a program in any language which approximates Euler's number by taking in an input \$n\$ and calculates the series to the \$n\$th term. Note that the first term has denominator \$0!\$, not \$1!\$, i.e. \$n=1\$ corresponds to \$\frac{1}{0!}\$.

Scoring

Program with least amount of bytes wins.

答:
WolframAlpha, 12 bytes

```<code>sum1/k!,0..n
</code>```

ContentLicense: CC BY-SA 4.0

Title: Approximation of e

Body:
WolframAlpha, 12 bytes

sum1/k!,0..n


答:
05AB1E, <s>18</s> 17 bytes

```<code>3Ld                # push list [1,1,1]
   ¹ÍG         }   # input-3 times do
      D3£          # duplicate list and take first 3 elements of the copy
         R`        # reverse and flatten
           /+      # divide then add
             ¸ì    # wrap in list and prepend to full list
                ¬  # get first element and implicitly print
</code>```

Try it online!

Saved 1 byte thanks to Luis Mendo

Title: The Piggyback Sequence

Body:
I made my own sequence recently (called the Piggyback sequence), and it works like this:

P(1), P(2) and P(3) = 1.

For all P(n) where n>3, the sequence works like this:

```<code>P(n) = P(n-3) + P(n-2)/P(n-1)
</code>```

So, continuing the sequence:

P(4) = 1 + 1/1 = 2

P(5) = 1 + 1/2 = 3/2
= 1.5

P(6) = 1 + 2/(3/2) = 7/3
= 2.33333...

P(7) = 2 + (3/2)/(7/3) = 37/14 = 2.6428571428...

P(8) = 3/2 + (7/3)/(37/14) = 529/222
= 2.3828828828...

Your task is, when given n, calculate P(n) either as a floating point number or an (im)proper fraction.

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

If anyone can find the name of the sequence, please edit the post accordingly.

Current leaders: MATL and Jelly (both at 15 bytes).

Body:
05AB1E, <s>18</s> 17 bytes

3Ld                # push list [1,1,1]
   ¹ÍG         }   # input-3 times do
      D3£          # duplicate list and take first 3 elements of the copy
         R`        # reverse and flatten
           /+      # divide then add
             ¸ì    # wrap in list and prepend to full list
                ¬  # get first element and implicitly print

Try it online!

Saved 1 byte thanks to Luis Mendo


问:
Exponentially Slimy Programming: Stacking Minecraft Slimes
Slimes are cube shaped enemies in Minecraft that break into multiple smaller versions of themselves when killed. For the purposes of this challenge we'll depict them as an 8×8 pixel image with 3 colors:

 ← True 8×8 version.

The precise RGB colors are:

0, 0, 0 for the eyes and mouth

110, 170, 90 for the central, darker green

116, 196, 96 for the outer, lighter green

Challenge

Write a program or function that takes in a positive integer N and outputs an image of N sizes of slimes packed into a rectangle. Going from left to right, the image should follow the pattern of having:

A stack of 2(N-1) 8×8 slimes.

A stack of 2(N-2) 16×16 slimes.

A stack of 2(N-3) 32×32 slimes.

And so on until the stack only contains one slime.

The slime images larger than the 8×8 version () are generated by nearest-neighbor upsampling (i.e. just doubling all the pixels). Note that you must use the exact slime design and colors given here.

The final image will contain 2N-1 slimes and be 2(N+3)-8 pixels wide and 2(N+2) pixels tall.

The image may be output in any common image file format, saved to a file or printed/returned as a raw data stream, or directly displayed during runtime.

The shortest code in bytes wins.

Examples

Your program should produce these exact results.

N = 1:

N = 2:

N = 3:

N = 4:

N = 5:

N = 6:

Larger N should work just as well.

答:
JavaScript (ES7), 326 <s>327</s> bytes

```<code>n=>{x=(d=document).body.appendChild(c=d.createElement`canvas`).getContext`2d`;c.width=2*(c.height=4*(p=2**n)));for(i=0;i<n;i++){c=-1;for(j of[...'0001000001111110022112200221122011111110011121110111111000010000'])for(x.fillStyle=['#74c460','#6eaa5a','#000'][j],c++,k=0;k<p;)x.fillRect(c%8*(_=2**i)+_*8,~~(c/8)*_+_*8*k++,_,_)}}
</code>```

Ungolfed ES6 Version

Try it yourself.

```<code>(n=>{
    x=(d=document).body.appendChild(c=d.createElement`canvas`).getContext`2d`;
    c.width=2*(c.height=4*(p=Math.pow(2,n)));
    for(i=0;i<n;i++){
        c=-1;
        for(j of[...'0001000001111110022112200221122011111110011121110111111000010000'])
            for(x.fillStyle=['#74c460','#6eaa5a','#000'][j],c++,k=0;k<p;)
                x.fillRect(c%8*(_=Math.pow(2,i))+_*8,~~(c/8)*_+_*8*k++,_,_)
    }
})(4);
</code>```

The only difference between the ES7 and ES6 version is using ** instead of Math.pow(). You can also see, how you can invoke the function – in this example with n=4.

Result

Edits

saved 1 byte - found an unnecessary trailing semicolon ;

This is pretty slow and might take some time for numbers greater 10.

Body:
JavaScript (ES7), 326 <s>327</s> bytes

n=>{x=(d=document).body.appendChild(c=d.createElement`canvas`).getContext`2d`;c.width=2*(c.height=4*(p=2**n)));for(i=0;i<n;i++){c=-1;for(j of[...'0001000001111110022112200221122011111110011121110111111000010000'])for(x.fillStyle=['#74c460','#6eaa5a','#000'][j],c++,k=0;k<p;)x.fillRect(c%8*(_=2**i)+_*8,~~(c/8)*_+_*8*k++,_,_)}}

Ungolfed ES6 Version

Try it yourself.

(n=>{
    x=(d=document).body.appendChild(c=d.createElement`canvas`).getContext`2d`;
    c.width=2*(c.height=4*(p=Math.pow(2,n)));
    for(i=0;i<n;i++){
        c=-1;
        for(j of[...'0001000001111110022112200221122011111110011121110111111000010000'])
            for(x.fillStyle=['#74c460','#6eaa5a','#000'][j],c++,k=0;k<p;)
                x.fillRect(c%8*(_=Math.pow(2,i))+_*8,~~(c/8)*_+_*8*k++,_,_)
    }
})(4);

The only difference between the ES7 and ES6 version is using ** instead of Math.pow(). You can also see, how you can invoke the function – in this example with n=4.

Result

Edits

saved 1 byte - found an unnecessary trailing semicolon ;

This is pretty slow and might take some time for numbers greater 10.


答:
><>, 531 bytes

The programs take two main forms:

```<code>##*o;
"chr-1"1+o;
</code>```

The first is for characters with character codes with two factors both less than 16, the other is for the other cases. Most numbers that I use the second form for have many equal length solutions, but I chose that one for readability.

Exceptions:

```<code>" b3*1+o; Would be "!"1+o; normally
0 11-n; n outputs as a number
1 22/n;
2-9 #1+n;
; ":"1+o* Ends in an error
</code>```

Full list:

```<code>! b3*o;
" b3*1+o;
# 57*o;
$ 66*o;
% "$"1+o;
& "%"1+o;
' d3*o;
( a4*o;
) "("1+o;
* ")"1+o;
+ ","1-o;
, b4*o;
- 95*o;
. "-"1+o;
/ "."1+o;
0 11-n;
1 22/n;
2 11+n;
3 21+n;
4 31+n;
5 41+n;
6 51+n;
7 61+n;
8 71+n;
9 81+n;
: "9"1+o;
; ":"1+o*
< a6*o;
= "<"1+o;
> "="1+o;
? 97*o;
@ 88*o;
A d5*o;
B b6*o;
C "B"1+o;
D "C"1+o;
E "D"1+o;
F a7*o;
G "F"1+o;
H 98*o;
I "H"1+o;
J "D"1+o;
K e5*o;
L "K"1+o;
M b7*o;
N d6*o;
O "D"1+o;
P a8*o;
Q 99*o;
R "Q"1+o;
S "R"1+o;
T c7*o;
U "T"1+o;
V "U"1+o;
W "V"1+o;
X b8*o;
Y "X"1+o;
Z a9*o;
[ c7*o;
\ "["1+o;
] "\"1+o;
^ "]"1+o;
_ "^"1+o;
` c8*o;
a "`"1+o;
b e7*o;
c b9*o;
d aa*o;
e "d"1+o;
f "e"1+o;
g "g"1+o;
h d8*o;
i e7*o;
j "i"1+o;
k "j"1+o;
l c9*o;
m "l"1+o;
n ba*o;
o DNP
p e8*o;
q "p"1+o;
r "q"1+o;
s "r"1+o;
t "s"1+o;
u c9*o;
v "u"1+o;
w "v"1+o;
x ca*o;
y bb*o;
z "y"1+o;
~ e9*o;
</code>```

Body:
><>, 531 bytes

The programs take two main forms:

##*o;
"chr-1"1+o;

The first is for characters with character codes with two factors both less than 16, the other is for the other cases. Most numbers that I use the second form for have many equal length solutions, but I chose that one for readability.

Exceptions:

" b3*1+o; Would be "!"1+o; normally
0 11-n; n outputs as a number
1 22/n;
2-9 #1+n;
; ":"1+o* Ends in an error

Full list:

! b3*o;
" b3*1+o;
# 57*o;
$ 66*o;
% "$"1+o;
& "%"1+o;
' d3*o;
( a4*o;
) "("1+o;
* ")"1+o;
+ ","1-o;
, b4*o;
- 95*o;
. "-"1+o;
/ "."1+o;
0 11-n;
1 22/n;
2 11+n;
3 21+n;
4 31+n;
5 41+n;
6 51+n;
7 61+n;
8 71+n;
9 81+n;
: "9"1+o;
; ":"1+o*
< a6*o;
= "<"1+o;
> "="1+o;
? 97*o;
@ 88*o;
A d5*o;
B b6*o;
C "B"1+o;
D "C"1+o;
E "D"1+o;
F a7*o;
G "F"1+o;
H 98*o;
I "H"1+o;
J "D"1+o;
K e5*o;
L "K"1+o;
M b7*o;
N d6*o;
O "D"1+o;
P a8*o;
Q 99*o;
R "Q"1+o;
S "R"1+o;
T c7*o;
U "T"1+o;
V "U"1+o;
W "V"1+o;
X b8*o;
Y "X"1+o;
Z a9*o;
[ c7*o;
\ "["1+o;
] "\"1+o;
^ "]"1+o;
_ "^"1+o;
` c8*o;
a "`"1+o;
b e7*o;
c b9*o;
d aa*o;
e "d"1+o;
f "e"1+o;
g "g"1+o;
h d8*o;
i e7*o;
j "i"1+o;
k "j"1+o;
l c9*o;
m "l"1+o;
n ba*o;
o DNP
p e8*o;
q "p"1+o;
r "q"1+o;
s "r"1+o;
t "s"1+o;
u c9*o;
v "u"1+o;
w "v"1+o;
x ca*o;
y bb*o;
z "y"1+o;
~ e9*o;


答:
05AB1E, <s>18</s> 17 bytes

```<code>26FA26×N>n£NnF¦},
</code>```

Explanation

```<code>26F                 # for N in range(0, 26) do
   A26×             # the alphabet repeated 26 times
       N>n£         # take (N+1)^2 letters
           NnF¦}    # throw away the first N^2 letters
                ,   # print with newline
</code>```

Try it online!

Title: Alphabet triangle strikes again

Body:
Task

Your task is to print this exact text:

```<code>A
BCD
EFGHI
JKLMNOP
QRSTUVWXY
ZABCDEFGHIJ
KLMNOPQRSTUVW
XYZABCDEFGHIJKL
MNOPQRSTUVWXYZABC
DEFGHIJKLMNOPQRSTUV
WXYZABCDEFGHIJKLMNOPQ
RSTUVWXYZABCDEFGHIJKLMN
OPQRSTUVWXYZABCDEFGHIJKLM
NOPQRSTUVWXYZABCDEFGHIJKLMN
OPQRSTUVWXYZABCDEFGHIJKLMNOPQ
RSTUVWXYZABCDEFGHIJKLMNOPQRSTUV
WXYZABCDEFGHIJKLMNOPQRSTUVWXYZABC
DEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL
MNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW
XYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ
KLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXY
ZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOP
QRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI
JKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCD
EFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZA
BCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ
</code>```

Specs

You may do it in all-lowercase instead of all-uppercase.

Trailing newlines at the end of the triangle is allowed.

Trailing spaces after each line is allowed.

You must print to STDOUT instead of outputting an array of strings.

Scoring

This is code-golf. Program with lowest byte-count wins.

Body:
05AB1E, <s>18</s> 17 bytes

26FA26×N>n£NnF¦},

Explanation

26F                 # for N in range(0, 26) do
   A26×             # the alphabet repeated 26 times
       N>n£         # take (N+1)^2 letters
           NnF¦}    # throw away the first N^2 letters
                ,   # print with newline

Try it online!


问:
Construct the Identity Matrix
The challenge is very simple. Given an integer input n, output the n x n identity matrix. The identity matrix is one that has 1s spanning from the top left down to the bottom right. You will write a program or a function that will return or output the identity matrix you constructed. Your output may be a 2D array, or numbers separated by spaces/tabs and newlines.

Example input and output

```<code>1: [[1]]
2: [[1, 0], [0, 1]]
3: [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
4: [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
5: [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]

1
===
1

2
===
1 0
0 1

3
===
1 0 0
0 1 0
0 0 1

etc.
</code>```

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

Title: Construct the Identity Matrix

Body:
PHP, 106 bytes

<?php $i=$argv[1];for($j=0;$j<$i;$j++){for($h=0;$h<$i;$h++){$l="0 ";if($h==$j)$l="1 ";echo$l;}echo"\n";}?>

Based on a double for loop, it uses the command-line argument for the input.

php 70365.php 3
1 0 0
0 1 0
0 0 1

Expanded code:

<?php
    $i = $argv[1];
    for($j = 0; $j < $i; $j++)
    {
        for($h = 0; $h < $i; $h++)
        {
            $l="0 ";
            if($h == $j)
                $l="1 ";
            echo $l;
        }
        echo "\n";
    }
?>


答:
Java, 109 bytes

```<code>for(int i=0,c=-1,j;i<26;i++,System.out.println())for(j=0;j<1+2*i;j++)System.out.print((char)(65+(c=++c%26)));
</code>```

Slightly ungolfed:

```<code>for (int i = 0, c = -1, j; i < 26; i++, System.out.println())
    for (j = 0; j < 1 + 2 * i; j++) System.out.print((char) (65 + (c = ++c % 26)));
</code>```

Title: Alphabet triangle strikes again

Body:
Java, 109 bytes

for(int i=0,c=-1,j;i<26;i++,System.out.println())for(j=0;j<1+2*i;j++)System.out.print((char)(65+(c=++c%26)));

Slightly ungolfed:

for (int i = 0, c = -1, j; i < 26; i++, System.out.println())
    for (j = 0; j < 1 + 2 * i; j++) System.out.print((char) (65 + (c = ++c % 26)));


答:
Actually, <s>27</s> <s>26</s> <s>22</s> <s>20</s> 17 bytes

Takes the lowercase alphabet 26 times, prints 1,3,5,...,(2*n+1) at a time. Golfing suggestions welcome. Try it online!

Edit: Many thanks and -4 bytes to Leaky Nun and his suggestions.

```<code>úlú*iúl`╜u╟Σ)2╖`n
</code>```

Ungolfing:

```<code>úl    Pushes 26 (the length of the lowercase alphabet).
ú*    26 * the lowercase alphabet.
i     Flatten the string.
úl    Pushes 26.
  `     Start function.
  ╜u    Push register 0 (default: 0) and increment (call it len, from now on)
  ╟     Take len elements from the stack
  Σ     sum() into a string.
  )     Rotate the string to the bottom of the stack.
  2╖    Add 2 to register 0.
  `     End function.
n     Run the above function (26) times.
</code>```

Title: Alphabet triangle strikes again

Body:
Actually, <s>27</s> <s>26</s> <s>22</s> <s>20</s> 17 bytes

Takes the lowercase alphabet 26 times, prints 1,3,5,...,(2*n+1) at a time. Golfing suggestions welcome. Try it online!

Edit: Many thanks and -4 bytes to Leaky Nun and his suggestions.

úlú*iúl`╜u╟Σ)2╖`n

Ungolfing:

úl    Pushes 26 (the length of the lowercase alphabet).
ú*    26 * the lowercase alphabet.
i     Flatten the string.
úl    Pushes 26.
  `     Start function.
  ╜u    Push register 0 (default: 0) and increment (call it len, from now on)
  ╟     Take len elements from the stack
  Σ     sum() into a string.
  )     Rotate the string to the bottom of the stack.
  2╖    Add 2 to register 0.
  `     End function.
n     Run the above function (26) times.