答:
Python 3, 316 bytes

This answer looks at the coordinates of a and b on the spiral (using complex numbers) and adds the diagonal moves first, then the orthogonal moves.

def q(a,b):
 m=int(max(a,b)**.5)+1;d=[];c=0;e=[c];t=[a]
 for i in range(m):d+=[[0]*m]
 for k in range(m*m):d[int(c.real)][int(c.imag)]=k+1;e+=[c];c+=1j**int((4*k+1)**.5-1)
 z=e[a]-e[b];x,y=int(z.real),int(z.imag)
 while abs(x+y*1j):x+=(x<0)^-(x>0);y+=(y<0)^-(y>0);t+=[d[int(e[b].real)+x][int(e[b].imag)+y]]
 return t
```

<p><strong>Ungolfed:</strong></p>

<pre class="lang-python prettyprint-override"><code>def queen_spiral(a,b):
    square_size = int(max(a,b)**.5)+1
    complex_to_spiral = []
    complex = 0
    spiral_to_complex = [c] # add 0 first, so that it's 1-indexed later
    result = [a]

    for i in range(square_size):
        complex_to_spiral.append([0]*square_size) # the rows of the spiral

    for k in range(square_size**2):
        row = int(complex.real)
        column = int(complex.imag)
        complex_to_spiral[row][column] = k+1 # 1-indexing

        spiral_to_complex.append(complex)

        quarter_turns = int((4*k+1)**.5-1)
        complex += 1j**quarter_turns

    z = spiral_to_complex[a] - spiral_to_complex[b]
    v = spiral_to_complex[b]
    x, y = int(z.real), int(z.imag)
    r, s = int(v.real), int(v.imag)

    while abs(x+y*1j):
        if x < 0:
            x += 1
        elif x > 0:
            x += -1
        # else x == 0, do nothing
        if y < 0:
            y += 1
        elif y > 0:
            y += -1

        vertex = complex_to_spiral[r+x][s+y]
        result.append(vertex)
    return result
</code>```

Title: A queen's walk across a spiral

Body:
In a far-off kingdom, a chess queen takes a daily walk across a spiral path, numbered from 1 to n, not caring to follow the spiral itself, but simply making queen's moves as she would on a chessboard. The queen is beloved by her subjects, and they make a note of every square she visits on her path. Given that the queen can start her walk on any square and ends it on any square, what is the shortest queen's walk that she can take?

The challenge

Given a spiral of integers on a rectangular grid, write a function that returns one of the shortest possible paths (counted by number of cells travelled) between two numbers on this spiral grid using a chess queen's moves.

For example, from 16 to 25:

```<code>25 10 11 12 13
24  9  2  3 14
23  8  1  4 15
22  7  6  5 16
21 20 19 18 17
</code>```

Some possible paths include 16, 4, 2, 10, 25 and 16, 5, 1, 9, 25.

Rules

The input will be any two positive integers.

The output will be a path of integers (including both endpoints) across the spiral using only orthogonal and diagonal moves.

The length of a path is counted by the number of cells travelled.

Your answer may be a program or a function.

This is code golf, so the smallest number of bytes wins.

As always, if the problem is unclear, please let me know. Good luck and good golfing!

Test cases

```<code>>>> queen_spiral(4, 5)
4, 5
>>> queen_spiral(13, 20)
13, 3, 1, 7, 20
>>> queen_spiral(14, 14)
14
>>> queen_spiral(10, 3)
10, 11, 3
>>> queen_spiral(16, 25)
16, 4, 2, 10, 25
>>> queen_spiral(80, 1)
80, 48, 24, 8, 1
</code>```

Body:
Python 3, 316 bytes

This answer looks at the coordinates of a and b on the spiral (using complex numbers) and adds the diagonal moves first, then the orthogonal moves.

def q(a,b):
 m=int(max(a,b)**.5)+1;d=[];c=0;e=[c];t=[a]
 for i in range(m):d+=[[0]*m]
 for k in range(m*m):d[int(c.real)][int(c.imag)]=k+1;e+=[c];c+=1j**int((4*k+1)**.5-1)
 z=e[a]-e[b];x,y=int(z.real),int(z.imag)
 while abs(x+y*1j):x+=(x<0)^-(x>0);y+=(y<0)^-(y>0);t+=[d[int(e[b].real)+x][int(e[b].imag)+y]]
 return t

Ungolfed:

def queen_spiral(a,b):
    square_size = int(max(a,b)**.5)+1
    complex_to_spiral = []
    complex = 0
    spiral_to_complex = [c] # add 0 first, so that it's 1-indexed later
    result = [a]

    for i in range(square_size):
        complex_to_spiral.append([0]*square_size) # the rows of the spiral

    for k in range(square_size**2):
        row = int(complex.real)
        column = int(complex.imag)
        complex_to_spiral[row][column] = k+1 # 1-indexing

        spiral_to_complex.append(complex)

        quarter_turns = int((4*k+1)**.5-1)
        complex += 1j**quarter_turns

    z = spiral_to_complex[a] - spiral_to_complex[b]
    v = spiral_to_complex[b]
    x, y = int(z.real), int(z.imag)
    r, s = int(v.real), int(v.imag)

    while abs(x+y*1j):
        if x < 0:
            x += 1
        elif x > 0:
            x += -1
        # else x == 0, do nothing
        if y < 0:
            y += 1
        elif y > 0:
            y += -1

        vertex = complex_to_spiral[r+x][s+y]
        result.append(vertex)
    return result


问:
Alphabet triangle
You are to print this exact text:

```<code>A
ABA
ABCBA
ABCDCBA
ABCDEDCBA
ABCDEFEDCBA
ABCDEFGFEDCBA
ABCDEFGHGFEDCBA
ABCDEFGHIHGFEDCBA
ABCDEFGHIJIHGFEDCBA
ABCDEFGHIJKJIHGFEDCBA
ABCDEFGHIJKLKJIHGFEDCBA
ABCDEFGHIJKLMLKJIHGFEDCBA
ABCDEFGHIJKLMNMLKJIHGFEDCBA
ABCDEFGHIJKLMNONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXYXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXYZYXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXYXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNONMLKJIHGFEDCBA
ABCDEFGHIJKLMNMLKJIHGFEDCBA
ABCDEFGHIJKLMLKJIHGFEDCBA
ABCDEFGHIJKLKJIHGFEDCBA
ABCDEFGHIJKJIHGFEDCBA
ABCDEFGHIJIHGFEDCBA
ABCDEFGHIHGFEDCBA
ABCDEFGHGFEDCBA
ABCDEFGFEDCBA
ABCDEFEDCBA
ABCDEDCBA
ABCDCBA
ABCBA
ABA
A
</code>```

Specs

Extra trailing newlines are allowed at the end of the output.

Extra trailing spaces (U+0020) are allowed at the end of each line, including the extra trailing newlines.

You can use all lowercase instead of all uppercase, but you cannot print partially lowercase partially uppercase.

You can return the text as a function output instead of printing it in a full program.

Scoring

Since this is a triangle, and a triangle has 3 sides, and 3 is a small number, your code should be small in terms of byte-count.

答:
Guile, 188 bytes

```<code>(define(t d e)(if(= e 27)(apply string-append(map list->string(append(reverse(cdr d))d)))(t(cons(let((a(map integer->char(iota e #x41))))(append a(cdr(reverse a))'(#\newline)))d)(1+ e))))
</code>```

Or in a readable form:

```<code>(define (triangle done depth)
  (if (= depth 27)
    (apply string-append
     (map list->string
      (append (reverse (cdr done))
              done)))
    (triangle
     (cons (let ((alphabet (map integer->char (iota depth #x41))))
            (append alphabet (cdr (reverse alphabet)) '(#\newline)))
      done)
    (1+ depth))))
</code>```

Call the program with (triangle '() 1) or (t '() 1), note that srfi-1 needs to be loaded.

The program creates a list of the chars in the alphabet, from a to the last letter in the current line. It then takes that lists, reverses it and removes the original last character, appends the two lists and adds a newline character at the end. It then does that 26 times, from A to Z. It then converts the lists to strings and concats them.

The program returns a string, which then should be passed to display, but this wasn't needed in the challenge.

ContentLicense: CC BY-SA 3.0

Title: Alphabet triangle

Body:
Guile, 188 bytes

(define(t d e)(if(= e 27)(apply string-append(map list->string(append(reverse(cdr d))d)))(t(cons(let((a(map integer->char(iota e #x41))))(append a(cdr(reverse a))'(#\newline)))d)(1+ e))))

Or in a readable form:

(define (triangle done depth)
  (if (= depth 27)
    (apply string-append
     (map list->string
      (append (reverse (cdr done))
              done)))
    (triangle
     (cons (let ((alphabet (map integer->char (iota depth #x41))))
            (append alphabet (cdr (reverse alphabet)) '(#\newline)))
      done)
    (1+ depth))))

Call the program with (triangle '() 1) or (t '() 1), note that srfi-1 needs to be loaded.

The program creates a list of the chars in the alphabet, from a to the last letter in the current line. It then takes that lists, reverses it and removes the original last character, appends the two lists and adds a newline character at the end. It then does that 26 times, from A to Z. It then converts the lists to strings and concats them.

The program returns a string, which then should be passed to display, but this wasn't needed in the challenge.


问:
Print a 10 by 10 grid of asterisks

Background

This is a standard textbook example to demonstrate for loops.

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

Task

You are to print this exact text:

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

Specs

You may have extra trailing newlines.

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

Scoring

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

答:
PostgreSQL, 39 bytes

```<code>select repeat('**********'||chr(13),10)
</code>```

Title: Print a 10 by 10 grid of asterisks

Body:
PostgreSQL, 39 bytes

select repeat('**********'||chr(13),10)


问:
Is it a pangram?
Write a function or program that takes as its input a string and prints a truthy value if the string is a pangram (a sequence of letters containing at least one of each letter in the English alphabet) and a falsey value otherwise.

Case of letters should be ignored; If the string is abcdefghijklmnopqrstuvwXYZ, then the function should still return a truthy value. Note that the string can contain any other characters in it, so 123abcdefghijklm NOPQRSTUVWXYZ321 would return a truthy value. An empty input should return a falsey value.

Test cases

```<code>AbCdEfGhIjKlMnOpQrStUvWxYz

==> True

ACEGIKMOQSUWY
BDFHJLNPRTVXZ

==> True

public static void main(String[] args)

==> False

The quick brown fox jumped over the lazy dogs. BOING BOING BOING

==> True
</code>```

This is code golf. Standard rules apply. Shortest code in bytes wins.

答:
R, <s>97</s> 92 bytes

Not competing with @mnel's excellent answer, but nevertheless :

```<code>function(s){a=strsplit(s,"")[[1]];m=match;sum(unique(c(m(a,letters,0),m(a,LETTERS,0))))=351}
</code>```

This function takes your input, breaks it into its letters (strsplit), matches (match function, obviously) each letters of the input with both letters and LETTERS, built-in constant containing lowercases and uppercases letters. The unmatched positions are replaced with 0's.

Then, it eliminates all the redundant positions (unique), and make their sum. Considering there are 26 letters in the alphabet and the 1-indexed positions in R, if all the letters are contained at least once in your input, the sum of their positions will be 1+2+...+25+26, which is 351

- 5 bytes thanks to @plannapus !

Title: Is it a pangram?

Body:
R, <s>97</s> 92 bytes

Not competing with @mnel's excellent answer, but nevertheless :

function(s){a=strsplit(s,"")[[1]];m=match;sum(unique(c(m(a,letters,0),m(a,LETTERS,0))))=351}

This function takes your input, breaks it into its letters (strsplit), matches (match function, obviously) each letters of the input with both letters and LETTERS, built-in constant containing lowercases and uppercases letters. The unmatched positions are replaced with 0's.

Then, it eliminates all the redundant positions (unique), and make their sum. Considering there are 26 letters in the alphabet and the 1-indexed positions in R, if all the letters are contained at least once in your input, the sum of their positions will be 1+2+...+25+26, which is 351

- 5 bytes thanks to @plannapus !


问:
Count the rectangles in a diagonal grid
As a follow-up to this challenge, we now want to count the number of rectangles in grid with r rows and c columns where there is a line crossing through every diagonal of a square in the grid. Now, we are still counting the the same rectangles as before, but this time we must also include rectangles that are tilted by 45 degrees.

Your goal is to create a function or program that given the number of rows r and columns c outputs the number of rectangles in a diagonal grid with dimensions (r, c).

As a demonstration, this is an animation that iterates through all 37 rectangles formed by a (2 x 3) diagonal grid.

Test Cases

```<code>Each case is [rows, columns] = # of rectangles
[0, 0] = 0
[0, 1] = 0
[1, 0] = 0
[1, 1] = 1
[3, 2] = 37
[2, 3] = 37
[6, 8] = 2183
[7, 11] = 5257
[18, 12] = 40932
[42, 42] = 2889558
[51, 72] = 11708274
</code>```

Rules

This is code-golf so the shortest code wins.

Builtins that solve this are not allowed.

ContentLicense: CC BY-SA 4.0

Title: Count the rectangles in a diagonal grid

Body:
Batch, 82 bytes

@if %2 gtr %1 %0 %2 %1
@cmd/cset/a%1*~%1*%2*~%2/4+((%1+%1-%2)*(%2*%2*4-1)-3)*%2/6


问:
Catalan Numbers
The Catalan numbers (OEIS) are a sequence of natural numbers often appearing in combinatorics.

The nth Catalan number is the number of Dyck words (balanced strings of parenthesis or brackets such as [[][]]; formally defined as a string using two characters a and b such that any substring starting from the beginning has number of a characters greater than or equal to number of b characters, and the entire string has the same number of a and b characters) with length 2n. The nth Catalan number (for \$n\ge0\$) is also explicitly defined as:
$$C_n=\frac1{n+1}\binom{2n}n$$
Starting from \$n=0\$, the first 20 Catalan numbers are:

```<code>1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, 742900, 2674440, 9694845, 35357670, 129644790, 477638700, 1767263190...
</code>```

Challenge

Write a full program or function that takes a non-negative integer n via STDIN or an acceptable alternative, and outputs the nth Catalan number. Your program must work at minimum for inputs 0-19.

I/O

Input

Your program must take input from STDIN, function arguments or any of the acceptable alternatives per this meta post. You can read the inputted number as its standard decimal represention, unary representation, or bytes.

If (and only if) your language cannot take input from STDIN or any acceptable alternative, it may take input from a hardcoded variable or suitable equivalent in the program.

Output

Your program must output the nth Catalan number to STDOUT, function result or any of the acceptable alternatives per this meta post. You can output the Catalan number in its standard decimal representation, unary representation or bytes.

The output should consist of the approriate Catalan number, optionally followed by one or more newlines. No other output can be generated, except constant output of your language's interpreter that cannot be suppressed (such as a greeting, ANSI color codes or indentation).

This is not about finding the language that is the shortest. This is about finding the shortest program in every language. Therefore, I will not accept an answer.

In this challenge, languages newer than the challenge are acceptable as long as they have an implementation. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language. Other than that, all the standard rules of code-golf must be obeyed. Submissions in most languages will be scored in bytes in an appropriate preexisting encoding (usually UTF-8). Note also that built-ins for calculating the nth Catalan number are allowed.

Catalog

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
R, 28 bytes

Not using a package, so slightly longer than a previous answer

```<code>choose(2*(n=scan()),n)/(n+1)
</code>```

Title: Catalan Numbers

Body:
R, 28 bytes

Not using a package, so slightly longer than a previous answer

choose(2*(n=scan()),n)/(n+1)


问:
Create a C program that takes the longest period of time to compile in gcc
Create a short C program that takes an absurdly long time to compile with gcc. Entries will be scored by timing the compilation then subtracting the reference program's compile time.

Rules

Any C language feature or gcc extension

gcc 4.2.1

答:
```<code>#define a "xxxxxxxxxxx"
#define b a a a a a a a
#define c b b b b b b b
#define d c c c c c c c
#define e d d d d d d d
#define f e e e e e e e
#define g f f f f f f f
#define h g g g g g g g
#define i h h h h h h h
#define j i i i i i i i
z=j;
</code>```


问:
Limerick Hello World
A rhyming program you write

Attempting to win the fight

For winning the contest and vote

It must compute "Hello World"

Then print it very polite

The most popular poem will win.

The requirements are:

The poem should be of 5 lines with rhymes AABBA

It can print whatever you want, but the output should contain "hello world" (uppercase/lowercase does not matter, quotes not included in the output)

Symbols are read aloud. For example, the fourth line above is read: It must compute quote hello world quote

Post below your code, on another code preview, the "read-aloud" version of your code for disambiguation on special symbols.

Excluded are poems:

including dead code, or characters which could be safely removed without changing the rhymes or the functionality

Using comments as a way to rhyme (except if there is a good reason for that)

using the same symbol as end of phrase for rhyme.

In case of a tie, programs outputting a poem will win. If there is still a tie, shorter programs will win.

New lines do not count. spaces, tabs and newlines are not read aloud.
For example, "Hello, world!" would be read aloud "double-quote hello comma world exclamation point double-quote".

答:
```<code>#include <stdio.h> //
void main (void){
printf("Hello, World");
//just for rhyme I say stolon
} /**/
</code>```

hash include less than stdio dot h greater than double slash after a space

void main left paren void right paren left brace

printf left paren quote Hello comma World quote right paren semi colon

double slash just for rhyme I say stolon

right brace and double asterisk between slashes at the last place

Title: Limerick Hello World

Body:
#include <stdio.h> //
void main (void){
printf("Hello, World");
//just for rhyme I say stolon
} /**/

hash include less than stdio dot h greater than double slash after a space

void main left paren void right paren left brace

printf left paren quote Hello comma World quote right paren semi colon

double slash just for rhyme I say stolon

right brace and double asterisk between slashes at the last place


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

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

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

If the input is 2:

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

If the input is 3:

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

If the input is 4:

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

If the input is 5:

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

And so on in the same pattern for larger inputs.

Note that:

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

No lines may have trailing spaces.

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

A single optional trailing newline is allowed.

The shortest code in bytes wins.

答:
Java 1.7, 238 bytes

A set of two functions: first iterates over input (# of turtles), second facilitates in constructing a sequence of repeated characters recursively (i.e. the leading spaces, the back and belly of the turtles).

```<code>String f(int n){String s="";for(int i=-1,x=-2;++i<n;){int m=(i+n)%2;s+=r(' ',n-i)+r('_',i*2+2)+"\n"+r(' ',n-i-(m==1?1:2))+(m==0?"o":"")+"/,"+r('_',x+=2)+",\\"+(m==1?"o":"")+"\n";}return s;}String r(char c,int n){return n>0?c+r(c,--n):"";}
</code>```

Ungolfed:

```<code>class C {
    public static void main(String[] a) {
        System.out.println(new T().f(1));
        System.out.println(new T().f(2));
        System.out.println(new T().f(3));
        System.out.println(new T().f(4));
        System.out.println(new T().f(5));
    }

    static class T {

        String f(int n) {
            String s = "";
            for (int i = -1, x = 0; ++i < n; x+=2) {
                int m = (i + n) % 2;
                s += r(' ', n - i) + r('_', i * 2 + 2) + "\n" + r(' ', n - i - (m == 1 ? 1 : 2)) + (m == 0 ? "o" : "") + "/," + r('_', x) + ",\\" + (m == 1 ? "o" : "") + "\n";
            }
            return s;
        }

        String r(char c, int n) {
            return n > 0 ? c + r(c, --n) : "";
        }

    }

}
</code>```

Run it! (Ideone)

I've assumed it's okay to exclude the class definition from the byte count.

I may be able to golf this a little further by reversing the iteration order of the loop (build from bottom turtle up) and/or by going fully recursive like some of the other answers.

Note to self: Java really lacks a built-in shorthand to repeat n characters...

Title: Turtles All the Way Down

Body:
Java 1.7, 238 bytes

A set of two functions: first iterates over input (# of turtles), second facilitates in constructing a sequence of repeated characters recursively (i.e. the leading spaces, the back and belly of the turtles).

String f(int n){String s="";for(int i=-1,x=-2;++i<n;){int m=(i+n)%2;s+=r(' ',n-i)+r('_',i*2+2)+"\n"+r(' ',n-i-(m==1?1:2))+(m==0?"o":"")+"/,"+r('_',x+=2)+",\\"+(m==1?"o":"")+"\n";}return s;}String r(char c,int n){return n>0?c+r(c,--n):"";}

Ungolfed:

class C {
    public static void main(String[] a) {
        System.out.println(new T().f(1));
        System.out.println(new T().f(2));
        System.out.println(new T().f(3));
        System.out.println(new T().f(4));
        System.out.println(new T().f(5));
    }

    static class T {

        String f(int n) {
            String s = "";
            for (int i = -1, x = 0; ++i < n; x+=2) {
                int m = (i + n) % 2;
                s += r(' ', n - i) + r('_', i * 2 + 2) + "\n" + r(' ', n - i - (m == 1 ? 1 : 2)) + (m == 0 ? "o" : "") + "/," + r('_', x) + ",\\" + (m == 1 ? "o" : "") + "\n";
            }
            return s;
        }

        String r(char c, int n) {
            return n > 0 ? c + r(c, --n) : "";
        }

    }

}

Run it! (Ideone)

I've assumed it's okay to exclude the class definition from the byte count.

I may be able to golf this a little further by reversing the iteration order of the loop (build from bottom turtle up) and/or by going fully recursive like some of the other answers.

Note to self: Java really lacks a built-in shorthand to repeat n characters...


答:
><>, 29+2 = 31 bytes

```<code>:1+$?!\:2-
$/?=1l<*-$4,$6
;\n
</code>```

Requires the input to be present on the stack at program start, so +2 bytes for the -v flag. Try it online!

Uses the algorithm presented in Stefano Sanfilippo's answer (linky).

The first line compiles n+1, n, n-1, ... , 2, 1 on the stack. The second line, running backwards, computes C(n) = (4 - (6 / (n+1)) * C(n-1). Each iteration reduces the size of the stack by 1, so the remaining number is output when the length of the stack is 1.

Title: Catalan Numbers

Body:
The Catalan numbers (OEIS) are a sequence of natural numbers often appearing in combinatorics.

The nth Catalan number is the number of Dyck words (balanced strings of parenthesis or brackets such as [[][]]; formally defined as a string using two characters a and b such that any substring starting from the beginning has number of a characters greater than or equal to number of b characters, and the entire string has the same number of a and b characters) with length 2n. The nth Catalan number (for \$n\ge0\$) is also explicitly defined as:
$$C_n=\frac1{n+1}\binom{2n}n$$
Starting from \$n=0\$, the first 20 Catalan numbers are:

```<code>1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, 742900, 2674440, 9694845, 35357670, 129644790, 477638700, 1767263190...
</code>```

Challenge

Write a full program or function that takes a non-negative integer n via STDIN or an acceptable alternative, and outputs the nth Catalan number. Your program must work at minimum for inputs 0-19.

I/O

Input

Your program must take input from STDIN, function arguments or any of the acceptable alternatives per this meta post. You can read the inputted number as its standard decimal represention, unary representation, or bytes.

If (and only if) your language cannot take input from STDIN or any acceptable alternative, it may take input from a hardcoded variable or suitable equivalent in the program.

Output

Your program must output the nth Catalan number to STDOUT, function result or any of the acceptable alternatives per this meta post. You can output the Catalan number in its standard decimal representation, unary representation or bytes.

The output should consist of the approriate Catalan number, optionally followed by one or more newlines. No other output can be generated, except constant output of your language's interpreter that cannot be suppressed (such as a greeting, ANSI color codes or indentation).

This is not about finding the language that is the shortest. This is about finding the shortest program in every language. Therefore, I will not accept an answer.

In this challenge, languages newer than the challenge are acceptable as long as they have an implementation. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language. Other than that, all the standard rules of code-golf must be obeyed. Submissions in most languages will be scored in bytes in an appropriate preexisting encoding (usually UTF-8). Note also that built-ins for calculating the nth Catalan number are allowed.

Catalog

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

Body:
><>, 29+2 = 31 bytes

:1+$?!\:2-
$/?=1l<*-$4,$6
;\n

Requires the input to be present on the stack at program start, so +2 bytes for the -v flag. Try it online!

Uses the algorithm presented in Stefano Sanfilippo's answer (linky).

The first line compiles n+1, n, n-1, ... , 2, 1 on the stack. The second line, running backwards, computes C(n) = (4 - (6 / (n+1)) * C(n-1). Each iteration reduces the size of the stack by 1, so the remaining number is output when the length of the stack is 1.


问:
Count up folks!

Introduction

It may sound strange, but we haven't got ONE challenge for counting from 1 to n, inclusive.

This is not the same thing. That one is a (closed) not well-explained challenge.

This is not the same thing. That one is about counting up indefinitely.

Challenge

Write a program or function that prints every integer from 1 to n inclusive.

Rules

You can get n any way.

You can assume that n will always be a positive integer.

You can get n in any base, but you should always output in decimal.

Output must be separated by any character (or pattern) not in 0123456789. Non-decimal leading or trailing characters are allowed (for example when using arrays such as [1, 2, 3, 4, 5, 6]).

Standard loopholes are denied.

We want to find the shortest approach in each language, not the shortest language, so I will not accept any answer.

You must update your answer(s) after this edit, answers posted before the last edit must comply with the change rule about standard loopholes (I didn't want to deny them, but I didn't want to make the community roar, so I denied them).

You can use any post-dating language version (or language). You cannot use any language or language version made just for this challenge.

Bonuses

20%

Your program must be able to count at least up to 18446744073709551615 (2^64-1). For example, if a new datatype is the only way to support big integers, you must construct it. If your language does not have any way to support huge integers up to 2^64-1, the upper limit of that particular language must be supported instead.

EDIT: I've changed the limit from 2^64 to 2^64-1 to allow more answers.

EDIT: I made the 2^64-1 rule a bonus, since there has not been much interest in this challenge. If your answer supports 2^64-1, you can now edit it to include the bonus. Also, you can post an answer not supporting it, if it is shorter.

答:
Jellyfish, 5 bytes

```<code>p`>ri
</code>```

Try it online!

Explanation

```<code>p     `    >         r     i
print(each_increment(range(input)))
</code>```

Title: Count up folks!

Body:
Jellyfish, 5 bytes

p`>ri

Try it online!

Explanation

p     `    >         r     i
print(each_increment(range(input)))


答:
3var, <s>27</s> 26 bytes

1 byte thanks to Business Cat

```
<s>iisiia+<*>aaaF[PPPPPPPPPPO]</s>
aaamaiis*>iiF[PPPPPPPPPPO]
```

I don't how do nested loops marked by F.

Try it online!

Title: Print a 10 by 10 grid of asterisks

Body:
Background

This is a standard textbook example to demonstrate for loops.

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

Task

You are to print this exact text:

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

Specs

You may have extra trailing newlines.

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

Scoring

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

Body:
3var, <s>27</s> 26 bytes

1 byte thanks to Business Cat

<s>iisiia+<*>aaaF[PPPPPPPPPPO]</s>
aaamaiis*>iiF[PPPPPPPPPPO]

I don't how do nested loops marked by F.

Try it online!


答:
Japt, 10 bytes

```<code>'*pA +R pA
</code>```

Prints * ten times, then \n, then repeat from the beginning ten times.

Demo.

Title: Print a 10 by 10 grid of asterisks

Body:
Japt, 10 bytes

'*pA +R pA

Prints * ten times, then \n, then repeat from the beginning ten times.

Demo.


Title: Print a 10 by 10 grid of asterisks

Body:
99, 137 bytes

99999 9 9
9999 99999 9
999 99 9
999999 99 9

99 99 9 99 9 99 9 99 9999
99
99
99
99
99
99
99
99
99
99
999999
999 999 9
 99 999
 9 99999

Try it online!


Title: Print a 10 by 10 grid of asterisks

Body:
Arcyóu, 21 bytes

(* "**********\n" 10)

Try it online!


问:
Integer goes back and forth through time
Input:

An integer.

Output:

First convert the integer to it's equivalent Roman Numeral.

Then convert each capital letter of that Roman Numeral to their ASCII/UNICODE decimal value.

And output the sum of those.

Example:

```<code>1991 -> MCMXCI -> 77+67+77+88+67+73 -> 449
^ input                                ^ output
</code>```

Roman Numerals:

Here is a perhaps useful Roman Numeral Converter.

Challenge rules:

Standard Roman Numeral rules are applied, so no alternative forms like IIII or VIIII instead of IV and IX.*

The Macron lines above the Roman Numerals past 1,000 are ¯ (UNICODE nr. 175). So one line counts as +175 and two as +350.

You are allowed to use any kind of input and output type, as long as it represents the integers.

The test cases will be in the range of 1 - 2,147,483,647.

* Roman Numeral rules (quote from Wikipedia):

Numbers are formed by combining symbols and adding the values, so II is two (two ones) and XIII is thirteen (a ten and three ones). Because each numeral has a fixed value rather than representing multiples of ten, one hundred and so on, according to position, there is no need for "place keeping" zeros, as in numbers like 207 or 1066; those numbers are written as CCVII (two hundreds, a five and two ones) and MLXVI (a thousand, a fifty, a ten, a five and a one).

Symbols are placed from left to right in order of value, starting with the largest. However, in a few specific cases, to avoid four characters being repeated in succession (such as IIII or XXXX), subtractive notation is often used as follows:

I placed before V or X indicates one less, so four is IV (one less than five) and nine is IX (one less than ten)

X placed before L or C indicates ten less, so forty is XL (ten less than fifty) and ninety is XC (ten less than a hundred)

C placed before D or M indicates a hundred less, so four hundred is CD (a hundred less than five hundred) and nine hundred is CM (a hundred less than a thousand)

  For example, MCMIV is one thousand nine hundred and four, 1904 (M is a thousand, CM is nine hundred and IV is four).

Some examples of the modern use of Roman numerals include:

  1954 as MCMLIV; 1990 as MCMXC; 2014 as MMXIV

  SOURCE

General rules:

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

Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.

Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters, full programs. Your call.

Default Loopholes are forbidden.

If possible, please add a link with a test for your code.

Also, please add an explanation if necessary.

Test cases:

```<code>100          ->   67
1            ->   73
4            ->   159
22           ->   322
5000         ->   261
2016         ->   401
1000000000   ->   427
1991         ->   449
9999         ->   800
1111111111   ->   2344
2147483647   ->   5362
</code>```

Body:
Python 3, 315 bytes

def p(n=int(input()),r=range):return sum([f*g for f,g in zip([abs(((n-4)%5)-1)]+[t for T in zip([((n+10**g)//(10**g*5))%2for g in r(10)],[(n%(10**g*5))//(10**g*4)+max((n%(10**g*5)%(10**g*4)+10**(g-1))//(10**g),0)for g in r(1,10)])for t in T],[73,86,88,76,67,68,77,261,263,251,242,243,252,436,438,426,417,418,427])])

Ungolfed version:

def p(n=int(input()),r=range):
    return sum([f*g for f,g in zip(
        [abs(((n-4)%5)-1)]+
        [t for T in zip(
            [((n+10**g)//(10**g*5))%2for g in r(10)],
            [(n%(10**g*5))//(10**g*4)+max((n%(10**g*5)%(10**g*4)+10**(g-1))//(10**g),0)for g in r(1,10)]
        )for t in T],
        [73,86,88,76,67,68,77,261,263,251,242,243,252,436,438,426,417,418,427])])

Explanation:
This version uses a different approach, it counts occurrences of roman numerals in the number.

[abs(((n-4)%5)-1)] is the number of Is in the roman numeral.

[((n+10**g)//(10**g*5))%2for g in r(10)] is the number of V,L,D,(V),(L),(D),((V)),((L)),((D))s in the number.

[(n%(10**g*5))//(10**g*4)+max((n%(10**g*5)%(10**g*4)+10**(g-1))//(10**g),0)for g in r(1,10)] is the number of the X,C,M,(X),(C),(M),((X)),((C)),((M))s in the number.

It then multiplies the occurrences with the value of the character and returns the sum of it.


问:
Output a shuffled deck using random input

Input/Output:

Input: A uniformly random, infinitely long, string of '0's and '1's, taken from stdin.  The string is assumed to be truly random, not pseudo-random.  It is uniform in that each character is equally likely to be a '0' or '1'.

Careful! The input is infinitely long, so you can't store it all in memory using a function like raw_input() in python.  If I'm not mistaken, golfscript will fail with infinite input, since it pushes the entire input onto the stack prior to running.

Output: A uniformly random shuffled standard deck, without jokers.  It is uniform in that all orderings are equally likely.

Each card in the output is it's rank, A, 2-9, T, J, Q or K concatenated with it's suit, c, d, h or s.  For example, the 10 of spades is Ts

The cards of the deck should be separated by spaces.

You may not use built-in random libraries or functions because they are not truly random, only pseudo-random.

Example input

You may use the following python script to pipe input into your program:

```<code>import sys, random
try:
    while True:
        sys.stdout.write(str(random.randint(0,1)))
except IOError:
    pass
</code>```

If you save the script as rand.py, test your program with python rand.py | your_program

In python 3 it runs as expected, but in python 2.7 I get an error message after my program's output, but only after everything's done, so just ignore the error message.

Example output:

Here's how the deck should be printed if it happened to be shuffled into a sorted order:

```<code>Ac 2c 3c 4c 5c 6c 7c 8c 9c Tc Jc Qc Kc Ad 2d 3d 4d 5d 6d 7d 8d 9d Td Jd Qd Kd Ah 2h 3h 4h 5h 6h 7h 8h 9h Th Jh Qh Kh As 2s 3s 4s 5s 6s 7s 8s 9s Ts Js Qs Ks
</code>```

Scoring:

This is a code golf.  Shortest code wins.

Example program:

Here is a python 2.7 solution, not golfed.

```<code>import sys
def next():
    return int(sys.stdin.read(1))==1
def roll(n):
    if n==1:
        return 0
    if n%2==0:
        r=roll(n/2)
        if next():
            r+=n/2
        return r
    else:
        r=n
        while(r==n):
            r=roll(n+1)
        return r
deck = [rank+suit for suit in 'cdhs' for rank in 'A23456789TJQK']
while len(deck)>0:
    print deck.pop(roll(len(deck))),
</code>```

答:
C, 197 178 161 chars

EDIT: Using a new random function, which is much shorter - reads a 4-digit integer s and uses s%64. Each 6-digit decimal number made of 0 and 1 only, taken %64 results in a unique result, so the randomness is good.

This approach consumes much more random bits, but is significantly shorter.

```<code>B[52],t,s,i=104;
r(){scanf("%6d",&s);s%=64;s>i&&r();}
main(){
    for(;i--;)B[i%52]=i<52
        ?r(),t=B[s],B[s]=B[i],printf("%c%c\n","23456789ATJQK"[t/4],"cdhs"[t%4]),t
        :i-52;
}
</code>```

The basic logic is simple - initialize an array of 52 ints with 0..51, shuffle (randomally replace element x with another from the range 0..x), print formatted (n/4=rank, n%4=suit).

One loop, that runs 104 times, does initialization (first 52 runs), shuffling and printing (last 52 runs).

A random number is generated by pulling n random bits, until 1<<n is at least the desired maximum. If the result is more than the maximum - retry.

Body:
C, 197 178 161 chars

EDIT: Using a new random function, which is much shorter - reads a 4-digit integer s and uses s%64. Each 6-digit decimal number made of 0 and 1 only, taken %64 results in a unique result, so the randomness is good.

This approach consumes much more random bits, but is significantly shorter.

B[52],t,s,i=104;
r(){scanf("%6d",&s);s%=64;s>i&&r();}
main(){
    for(;i--;)B[i%52]=i<52
        ?r(),t=B[s],B[s]=B[i],printf("%c%c\n","23456789ATJQK"[t/4],"cdhs"[t%4]),t
        :i-52;
}

The basic logic is simple - initialize an array of 52 ints with 0..51, shuffle (randomally replace element x with another from the range 0..x), print formatted (n/4=rank, n%4=suit).

One loop, that runs 104 times, does initialization (first 52 runs), shuffling and printing (last 52 runs).

A random number is generated by pulling n random bits, until 1<<n is at least the desired maximum. If the result is more than the maximum - retry.


Title: Print a 10 by 10 grid of asterisks

Body:
Gema, 31 characters

\A=@repeat{10;**********\n}@end

Sample run:

bash-4.3$ gema '\A=@repeat{10;**********\n}@end'
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********


答:
jq, <s>24</s> 18 characters

(16 characters code + 2 characters command line option.)

```<code>range(10)|"*"*10
</code>```

Thanks to:

Leaky Nun for suggesting to use string multiplication (-6 characters)

Sample run:

```<code>bash-4.3$ jq -nr 'range(10)|"*"*10'
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********
</code>```

On-line test (Passing -r through URL is not supported – check Raw Output yourself.)

Title: Print a 10 by 10 grid of asterisks

Body:
jq, <s>24</s> 18 characters

(16 characters code + 2 characters command line option.)

range(10)|"*"*10

Thanks to:

Leaky Nun for suggesting to use string multiplication (-6 characters)

Sample run:

bash-4.3$ jq -nr 'range(10)|"*"*10'
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********

On-line test (Passing -r through URL is not supported – check Raw Output yourself.)


Title: Print a 10 by 10 grid of asterisks

Body:
Awk, <s>37</s> 35 characters

BEGIN{for(OFS="*";++i<NF=11;)print}

Thanks to:

Cabbie407 for combining the OFS and loop-based solutions (-2 characters)

Sample run:

bash-4.3$ awk 'BEGIN{for(OFS="*";++i<NF=11;)print}'
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********


问:
Patch the Paragraph
In the spirit of Patch the Image, here's a similar challenge but with text.

Challenge

Bit rot has afflicted your precious text! Given a paragraph composed of ASCII characters, with a rectangular hole somewhere in it, your program should try to fill in the hole with appropriate text, so that the paragraph blends as best as possible.

Further definitions

The hole will always be rectangular, and it may span multiple lines.

There will only ever be one hole.

Note that the hole does not necessarily fall on word boundaries (in fact, it usually won't).

The hole will be at most 25% of the input paragraph, but may overlap or extend past the "end" of the "normal" text (see the Euclid or Badger examples below).

Since finding the hole is not the main point of this challenge, it will be composed solely of hash marks # to allow for easy identification.

No other location in the input paragraph will have a hash mark.

Your code cannot use the "normal" text in the examples below - it will only receive and process the text with the hole in it.

The input can be as a single multi-line string, as an array of strings (one element per line), as a file, etc. -- your choice of what is most convenient for your language.

If desired, an optional additional input detailing the coordinates of the hole can be taken (e.g., a tuple of coordinates or the like).

Please describe your algorithm in your submission.

Voting

Voters are asked to judge the entries based on how well the algorithm fills in the text hole. Some suggestions include the following:

Does the filled in area match the approximate distribution of spaces and punctuation as the rest of the paragraph?

Does the filled in area introduce faulty syntax? (e.g., two spaces in a row, a period followed by a question mark, an erroneous sequence like , ,, etc.)

If you squint your eyes (so you're not actually reading the text), can you see where the hole used to be?

If there aren't any CamelCase words outside the hole, does the hole contain any? If there aren't any Capitalized Letters outside the hole, does the hole contain any? If There Are A Lot Of Capitalized Letters Outside The Hole, does the hole contain a proportionate amount?

Validity Criterion

In order for a submission to be considered valid, it must not alter any text of the paragraph outside of the hole (including trailing spaces). A single trailing newline at the very end is optional.

Test Cases

Format is original paragraph in a code block, followed by the same paragraph with a hole. The paragraphs with the hole will be used for input.

1 (Patch the Image)

```<code>In a popular image editing software there is a feature, that patches (The term
used in image processing is inpainting as @minxomat pointed out.) a selected
area of an image, based on the information outside of that patch. And it does a
quite good job, considering it is just a program. As a human, you can sometimes
see that something is wrong, but if you squeeze your eyes or just take a short
glance, the patch seems to fill in the gap quite well.

In a popular image editing software there is a feature, that patches (The term
used in image processing is inpainting as @minxomat pointed out.) a selected
area of an image, #############information outside of that patch. And it does a
quite good job, co#############is just a program. As a human, you can sometimes
see that something#############t if you squeeze your eyes or just take a short
glance, the patch seems to fill in the gap quite well.
</code>```

2 (Gettysburg Address)

```<code>But, in a larger sense, we can not dedicate, we can not consecrate, we can not
hallow this ground. The brave men, living and dead, who struggled here, have
consecrated it, far above our poor power to add or detract. The world will
little note, nor long remember what we say here, but it can never forget what
they did here. It is for us the living, rather, to be dedicated here to the
unfinished work which they who fought here have thus far so nobly advanced. It
is rather for us to be here dedicated to the great task remaining before us-
that from these honored dead we take increased devotion to that cause for which
they gave the last full measure of devotion-that we here highly resolve that
these dead shall not have died in vain-that this nation, under God, shall have
a new birth of freedom-and that government of the people, by the people, for
the people, shall not perish from the earth.

But, in a larger sense, we can not dedicate, we can not consecrate, we can not
hallow this ground. The brave men, living and dead, who struggled here, have
consecrated it, far above our poor power to add or detract. The world will
little note, nor long remember what we say here, but it can never forget what
they did here. It is for us the living, rather, to be dedicated here to the
unfinished work which they who fought here h######################advanced. It
is rather for us to be here dedicated to the######################before us-
that from these honored dead we take increas######################use for which
they gave the last full measure of devotion-######################solve that
these dead shall not have died in vain-that ######################, shall have
a new birth of freedom-and that government of the people, by the people, for
the people, shall not perish from the earth.
</code>```

3 (Lorem Ipsum)

```<code>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit
in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo conse################irure dolor in reprehenderit
in voluptate velit esse cil################giat nulla pariatur. Excepteur
sint occaecat cupidatat non################in culpa qui officia deserunt
mollit anim id est laborum.
</code>```

4 (Jabberwocky)

```<code>'Twas brillig, and the slithy toves
Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe.

'Twas brillig, and the slithy toves
Did gyre a######### in the wabe;
All mimsy #########borogoves,
And the mome raths outgrabe.
</code>```

5 (Euclid's proof of the Pythagorean Theorem)

```<code>1.Let ACB be a right-angled triangle with right angle CAB.
2.On each of the sides BC, AB, and CA, squares are drawn,
CBDE, BAGF, and ACIH, in that order. The construction of
squares requires the immediately preceding theorems in Euclid,
and depends upon the parallel postulate. [footnote 14]
3.From A, draw a line parallel to BD and CE. It will
perpendicularly intersect BC and DE at K and L, respectively.
4.Join CF and AD, to form the triangles BCF and BDA.
5.Angles CAB and BAG are both right angles; therefore C, A,
and G are collinear. Similarly for B, A, and H.
6.Angles CBD and FBA are both right angles; therefore angle ABD
equals angle FBC, since both are the sum of a right angle and angle ABC.
7.Since AB is equal to FB and BD is equal to BC, triangle ABD
must be congruent to triangle FBC.
8.Since A-K-L is a straight line, parallel to BD, then rectangle
BDLK has twice the area of triangle ABD because they share the base
BD and have the same altitude BK, i.e., a line normal to their common
base, connecting the parallel lines BD and AL. (lemma 2)
9.Since C is collinear with A and G, square BAGF must be twice in area
to triangle FBC.
10.Therefore, rectangle BDLK must have the same area as square BAGF = AB^2.
11.Similarly, it can be shown that rectangle CKLE must have the same
area as square ACIH = AC^2.
12.Adding these two results, AB^2 + AC^2 = BD × BK + KL × KC
13.Since BD = KL, BD × BK + KL × KC = BD(BK + KC) = BD × BC
14.Therefore, AB^2 + AC^2 = BC^2, since CBDE is a square.

1.Let ACB be a right-angled triangle with right angle CAB.
2.On each of the sides BC, AB, and CA, squares are drawn,
CBDE, BAGF, and ACIH, in that order. The construction of
squares requires the immediately preceding theorems in Euclid,
and depends upon the parallel postulate. [footnote 14]
3.From A, draw a line parallel to BD and CE. It will
perpendicularly intersect BC and DE at K and L, respectively.
4.Join CF and AD, to form the triangles BCF and BDA.
5.Angles CAB and BAG are both right angles; therefore C, A,
and G are #############milarly for B, A, and H.
6.Angles C#############e both right angles; therefore angle ABD
equals ang############# both are the sum of a right angle and angle ABC.
7.Since AB#############FB and BD is equal to BC, triangle ABD
must be co#############iangle FBC.
8.Since A-#############ight line, parallel to BD, then rectangle
BDLK has t############# of triangle ABD because they share the base
BD and hav#############titude BK, i.e., a line normal to their common
base, conn#############rallel lines BD and AL. (lemma 2)
9.Since C #############with A and G, square BAGF must be twice in area
to triangl#############
10.Therefo############# BDLK must have the same area as square BAGF = AB^2.
11.Similar############# shown that rectangle CKLE must have the same
area as square ACIH = AC^2.
12.Adding these two results, AB^2 + AC^2 = BD × BK + KL × KC
13.Since BD = KL, BD × BK + KL × KC = BD(BK + KC) = BD × BC
14.Therefore, AB^2 + AC^2 = BC^2, since CBDE is a square.
</code>```

6 (Badger, Badger, Badger by weebl)

```<code>Badger, badger, badger, badger, badger,
badger, badger, badger, badger, badger
Mushroom, mushroom, a-
Badger, badger, badger, badger, badger,
badger, badger, badger, badger, badger
Mushroom, mushroom, a-
Badger, badger, badger, badger, badger,
badger, badger, badger, badger, badger
Mush-mushroom, a
Badger, badger, badger, badger, badger,
badger, badger, badger, badger, badger
Argh! Snake, a snake!
Snaaake! A snaaaake, oooh its a snake!

Badger, badger, badger, badger, badger,
badger, badger, badger, badger, badger
Mushroom, mushroom, a-
Badger##################badger, badger,
badger##################badger, badger
Mushro##################
Badger##################badger, badger,
badger##################badger, badger
Mush-mushroom, a
Badger, badger, badger, badger, badger,
badger, badger, badger, badger, badger
Argh! Snake, a snake!
Snaaake! A snaaaake, oooh its a snake!
</code>```

答:
Python 2.7

Another Python solution with a different approach. My program sees the text as a Markov chain, where each letter is followed by another letter with a certain probability. So the first step is to build the table of probabilities. The next step is to apply that probabilities to the patch.

Full code, including one sample text is below. Because one example used unicode characters, I included an explicit codepage (utf-8) for compatibility with that example.

```<code>#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import defaultdict
import numpy

texts = [
"""'Twas brillig, and the slithy toves
Did gyre a######### in the wabe;
All mimsy #########borogoves,
And the mome raths outgrabe."""
]

class Patcher:
    def __init__(self):
        self.mapper = defaultdict(lambda: defaultdict(int))

    def add_mapping(self, from_value, to_value):
        self.mapper[from_value][to_value] += 1

    def get_patch(self, from_value):
        if from_value in self.mapper:
            sum_freq = sum(self.mapper[from_value].values())
            return numpy.random.choice(
                self.mapper[from_value].keys(),
                p = numpy.array(
                    self.mapper[from_value].values(),dtype=numpy.float64) / sum_freq)
        else:
            return None

def add_text_mappings(text_string, patcher = Patcher(), ignore_characters = ''):
    previous_letter = text_string[0]
    for letter in text_string[1:]:
        if not letter in ignore_characters:
            patcher.add_mapping(previous_letter, letter)
            previous_letter = letter
    patcher.add_mapping(text_string[-1], '\n')

def patch_text(text_string, patcher, patch_characters = '#'):
    result = previous_letter = text_string[0]
    for letter in text_string[1:]:
        if letter in patch_characters:
            result += patcher.get_patch(previous_letter)
        else:
            result += letter
        previous_letter = result[-1]
    return result

def main():
    for text in texts:
        patcher = Patcher()
        add_text_mappings(text, patcher, '#')
        print patch_text(text, patcher, '#')
        print "\n"

if __name__ == '__main__':
    main()
</code>```

Sample output for the Lorem Ipsum:

```<code>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo conse Exe eut ccadamairure dolor in reprehenderit
in voluptate velit esse cilore indipserexepgiat nulla pariatur. Excepteur
sint occaecat cupidatat non upir alostat adin culpa qui officia deserunt
mollit anim id est laborum.
</code>```

An extra poetic line in the Jabberwocky:

```<code>'Twas brillig, and the slithy toves
Did gyre and me the in the wabe;
All mimsy was
An inborogoves,
And the mome raths outgrabe.
</code>```

Title: Patch the Paragraph

Body:
Python 2.7

Another Python solution with a different approach. My program sees the text as a Markov chain, where each letter is followed by another letter with a certain probability. So the first step is to build the table of probabilities. The next step is to apply that probabilities to the patch.

Full code, including one sample text is below. Because one example used unicode characters, I included an explicit codepage (utf-8) for compatibility with that example.

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import defaultdict
import numpy

texts = [
"""'Twas brillig, and the slithy toves
Did gyre a######### in the wabe;
All mimsy #########borogoves,
And the mome raths outgrabe."""
]

class Patcher:
    def __init__(self):
        self.mapper = defaultdict(lambda: defaultdict(int))

    def add_mapping(self, from_value, to_value):
        self.mapper[from_value][to_value] += 1

    def get_patch(self, from_value):
        if from_value in self.mapper:
            sum_freq = sum(self.mapper[from_value].values())
            return numpy.random.choice(
                self.mapper[from_value].keys(),
                p = numpy.array(
                    self.mapper[from_value].values(),dtype=numpy.float64) / sum_freq)
        else:
            return None

def add_text_mappings(text_string, patcher = Patcher(), ignore_characters = ''):
    previous_letter = text_string[0]
    for letter in text_string[1:]:
        if not letter in ignore_characters:
            patcher.add_mapping(previous_letter, letter)
            previous_letter = letter
    patcher.add_mapping(text_string[-1], '\n')

def patch_text(text_string, patcher, patch_characters = '#'):
    result = previous_letter = text_string[0]
    for letter in text_string[1:]:
        if letter in patch_characters:
            result += patcher.get_patch(previous_letter)
        else:
            result += letter
        previous_letter = result[-1]
    return result

def main():
    for text in texts:
        patcher = Patcher()
        add_text_mappings(text, patcher, '#')
        print patch_text(text, patcher, '#')
        print "\n"

if __name__ == '__main__':
    main()

Sample output for the Lorem Ipsum:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo conse Exe eut ccadamairure dolor in reprehenderit
in voluptate velit esse cilore indipserexepgiat nulla pariatur. Excepteur
sint occaecat cupidatat non upir alostat adin culpa qui officia deserunt
mollit anim id est laborum.

An extra poetic line in the Jabberwocky:

'Twas brillig, and the slithy toves
Did gyre and me the in the wabe;
All mimsy was
An inborogoves,
And the mome raths outgrabe.


Title: Print a 10 by 10 grid of asterisks

Body:
Groovy, 23 characters

print(("*"*10+"\n")*10)

Sample run:

bash-4.3$ groovy -e 'print(("*"*10+"\n")*10)'
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********


答:
Lua, 30 bytes

Full program outputting via its return value.

```<code>return("**********\n"):rep(10)
</code>```

Title: Print a 10 by 10 grid of asterisks

Body:
Lua, 30 bytes

Full program outputting via its return value.

return("**********\n"):rep(10)


答:
MATLAB, 53 Bytes

MATLAB is not made for strings, so this needs some looping. I haven't found a faster way to create a list 1 2 3 4 3 2 1, than [1:4,3:-1:1], which seems really verbose.

Anyway, it's only beaten by 11/55 other submissions, and most of those are golfing languages.

```<code>for i=[1:26,25:-1:1]
disp(['',64+[1:i,i-1:-1:1]])
end
</code>```

Title: Alphabet triangle

Body:
You are to print this exact text:

```<code>A
ABA
ABCBA
ABCDCBA
ABCDEDCBA
ABCDEFEDCBA
ABCDEFGFEDCBA
ABCDEFGHGFEDCBA
ABCDEFGHIHGFEDCBA
ABCDEFGHIJIHGFEDCBA
ABCDEFGHIJKJIHGFEDCBA
ABCDEFGHIJKLKJIHGFEDCBA
ABCDEFGHIJKLMLKJIHGFEDCBA
ABCDEFGHIJKLMNMLKJIHGFEDCBA
ABCDEFGHIJKLMNONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXYXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXYZYXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXYXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNONMLKJIHGFEDCBA
ABCDEFGHIJKLMNMLKJIHGFEDCBA
ABCDEFGHIJKLMLKJIHGFEDCBA
ABCDEFGHIJKLKJIHGFEDCBA
ABCDEFGHIJKJIHGFEDCBA
ABCDEFGHIJIHGFEDCBA
ABCDEFGHIHGFEDCBA
ABCDEFGHGFEDCBA
ABCDEFGFEDCBA
ABCDEFEDCBA
ABCDEDCBA
ABCDCBA
ABCBA
ABA
A
</code>```

Specs

Extra trailing newlines are allowed at the end of the output.

Extra trailing spaces (U+0020) are allowed at the end of each line, including the extra trailing newlines.

You can use all lowercase instead of all uppercase, but you cannot print partially lowercase partially uppercase.

You can return the text as a function output instead of printing it in a full program.

Scoring

Since this is a triangle, and a triangle has 3 sides, and 3 is a small number, your code should be small in terms of byte-count.

Body:
MATLAB, 53 Bytes

MATLAB is not made for strings, so this needs some looping. I haven't found a faster way to create a list 1 2 3 4 3 2 1, than [1:4,3:-1:1], which seems really verbose.

Anyway, it's only beaten by 11/55 other submissions, and most of those are golfing languages.

for i=[1:26,25:-1:1]
disp(['',64+[1:i,i-1:-1:1]])
end


答:
R, <s>71</s> 69 bytes

```<code>L=LETTERS;for(i in c(1:26,25:1))cat(c(L[1:i],L[i:1][-1]),"\n",sep="")
</code>```

See here on an online interpreter.

Edit: moved LETTERS outside the loop in order to avoid the curly brackets.

Title: Alphabet triangle

Body:
R, <s>71</s> 69 bytes

L=LETTERS;for(i in c(1:26,25:1))cat(c(L[1:i],L[i:1][-1]),"\n",sep="")

See here on an online interpreter.

Edit: moved LETTERS outside the loop in order to avoid the curly brackets.


问:
Convert Algebraic notation to Descriptive notation
Mr Short likes to play chess. Mr Short is also a very traditional man. Hence, Mr Short is disturbed by the recent trend of using Algebraic notation in modern chess, and he would rather use Descriptive notation, like his father and his father's father before him.

Note

To simplify this challenge, I chose not to deal with disambiguaties (as in, when two pieces can move to the same square, or can capture the same piece.) Also there is no dealing with en passant, promotion, or Castling.

Algebraic notation for the uninitiated

The board squares are numbered from a1 at the bottom left to h8 as the top right. The letters represent the files (columns) while the numbers represent the ranks (rows). The white King is placed in the beginning of the game at the square e1.

A move consists of the piece that moved + the destination square. For example, a King moving to e2 would be Ke2.

If the piece that had moved is a Pawn, the piece letter is omitted. For example, the starting move Pawn to e4 is written as e4.

If the move is a capture, then the x letter is inserted between the piece and the destination square. For example, a Queen capturing at f7 is annotated as Qxf7.

If the capturing piece is a Pawn, since it moves diagonally, the notation records the file the Pawn originated from. For example, when the Pawn at c4 captures a piece at d5, the move is annotated as cxd5.

Piece symbols are K for King, Q for Queen, B for Bishop, N for Knight, and R for Rook. Pawns have no symbols.

Other annotations include + for check, and # for checkmate. A Pawn moving to f7 and giving check is f7+. Note lack of space.

Descriptive notation for the uninitiated

The files are described by the piece that starts on it. For example, what would be the e file in Algebraic, becomes the King file, or, for short, K. The other files are marked by their side, then the piece. So file h is the King's Rook's file, or KR.

The ranks are numbered from the point of view of the moving player. What would be the fourth rank in Algebraic, is the fourth rank for white, but the fifth rank for black.

It follows that the square e4 is K4 for the white player and K5 for the black player. The square f7 is KB7 for the white player and KB2 for the black player.

A move is annotated by the piece moving, then a dash, then the target square. So a Pawn moving to K4 is P-K4. A Queen moving to KR5 is Q-KR5.

A capture is annotated by the capturing piece, then x, then the captured piece. Therefore a Bishop capturing a Pawn is BxP. Usually you need to mark which Pawn is being captured, but ignore this for sake of simplicity.

Piece symbols are K for King, Q for Queen, B for Bishop, Kt for Knight (note the different symbol), R for Rook, and P for Pawn.

Other annotations include ch for check and mate for checkmate. A Pawn moving to KB7 and giving check is P-KB7 ch. Note the space.

Input

A string of algebraic notation moves, delineated by spaces. There are no move numbers. For example, the Fool's mate goes like this:

```<code>f3 e5 g4 Qh4#
</code>```

Or the game Teed vs Delmar, from the same Wikipedia page:

```<code>d4 f5 Bg5 h6 Bf4 g5 Bg3 f4 e3 h5 Bd3 Rh6 Qxh5+ Rxh5 Bg6#
</code>```

The Immortal game.

```<code>e4 e5 f4 exf4 Bc4 Qh4+ Kf1 b5 Bxb5 Nf6 Nf3 Qh6 d3 Nh5 Nh4 Qg5 Nf5 c6 g4 Nf6 Rg1 cxb5 h4 Qg6 h5 Qg5 Qf3 Ng8 Bxf4 Qf6 Nc3 Bc5 Nd5 Qxb2 Bd6 Bxg1 e5 Qxa1+ Ke2 Na6 Nxg7+ Kd8 Qf6+ Nxf6 Be7#
</code>```

You may assume that input is always a valid game. All moves are in the correct order, and no extraneous data is present. No moves will include disambiguation.

For example, The Evergreen game despite being, obviously, a valid game, is not going to be input due to the 19th move, Rad1.

You may also assume that all input move lists start from the starting position.

Output

A move list, with a similar format, in Descriptive notation.

For example, the Fool's mate:

```<code>P-KB3 P-K4 P-KKt4 Q-KR5 mate
</code>```

Teed vs Delmar:

```<code>P-Q4 P-KB4 B-KKt5 P-KR3 B-KB4 P-KKt4 B-KKt3 P-KB5 P-K3 P-KR4 B-Q3 R-KR3 QxP ch RxQ B-KKt6 mate
</code>```

The Immortal Game:

```<code>P-K4 P-K4 P-KB4 PxP B-QB4 Q-KR5 ch K-KB1 P-QKt4 BxP Kt-KB3 Kt-KB3 Q-KR3 P-Q3 Kt-KR4 Kt-KR4 Q-KKt4 Kt-KB5 P-QB3 P-KKt4 Kt-KB4 R-KKt1 PxB P-KR4 Q-KKt3 P-KR5 Q-KKt4 Q-KB3 Kt-KKt1 BxP Q-KB3 Kt-QB3 B-QB4 Kt-Q5 QxP B-Q6 BxR P-K5 QxR ch K-K2 Kt-QR3 KtxP ch K-Q1 Q-KB6 ch KtxQ B-K7 mate
</code>```

This is not the simplest Descriptive notation possible, since sometimes you don't need to specify which Knight file was moved to (as in, Q-KKt4 could be written as Q-Kt4 since the move Q-QKt4 is impossible.) The move BxP is ambiguous (which pawn: should be BxQKtP), but Mr Short doesn't care about that too much.

You may consider these your test cases.

Note: I wrote these by hand. If you catch any glaring mistakes, please let me know.

Rules and Scoring

Standard rules apply : program with output to stdout, or function. Nothing to stderr. Standard loopholes are forbidden.

Please link to a site where we can test your code.

Code golf: shortest code wins.

In Conclusion

This is my first challenge, so I probably made some noobish errors. Feedback on the question (in the comments, obviously) is appreciated.

答:
Batch, 588 bytes

```<code>@echo off
for %%r in (a.R b.Kt c.B d.Q e.K f.B g.Kt h.R)do set %%~nr1=%%~xr&set %%~nr8=%%~xr
for %%r in (a b c d e f g h)do set %%r2=.P&set %%r7=.P
set s=
set a=
:l
set m=%1
set c=
for %%r in (ch.+ mate.#) do if .%m:~-1%==%%~xr set c= %%~nr&set m=%m:~,-1%
set/ab=(a^^%m:~-1%-1)+1,a=7-a
set p=%m:~0,1%
for %%r in (a b c d e f g h)do if %p%==%%r set p=P
for %%r in (QR.a QKt.b QB.c Q.d K.e KB.f KKt.g KR.h)do if .%m:~-2,1%==%%~xr set d=-%%~nr%b%
if %m:~-3,1%==x call set d=x%%%m:~-2%:~1%%
set %m:~-2%=.%p:N=Kt%
set s=%s% %p:N=Kt%%d%%c%
shift
if not "%1"=="" goto l
echo%s%
</code>```

s is the output string. m is the current move (moves are taken as command-line parameters). a is the current player (0 for White, 7 for Black). b is the row as seen from the point of view of the current player. c is the ch or mate flag. p is the current piece. If there is no piece (i.e. a lowercase letter a-h) then P is substituted. (The N to Kt substitution is done later to save bytes.) The destination column is then looked up in a dictionary. However if the move is actually a capture then the destination becomes an x followed by the piece previously on that square. Either way the destination square is then set to the piece that just moved there. The moves are accumulated until there are no more parameters and then they are printed.

The variables a1...h8 are used to store the last seen piece. The . prefix is there because of the way I initialise the back row; it's hard to loop over two variables at once in Batch unless I'm allowed to begin one with a ..

Body:
Batch, 588 bytes

@echo off
for %%r in (a.R b.Kt c.B d.Q e.K f.B g.Kt h.R)do set %%~nr1=%%~xr&set %%~nr8=%%~xr
for %%r in (a b c d e f g h)do set %%r2=.P&set %%r7=.P
set s=
set a=
:l
set m=%1
set c=
for %%r in (ch.+ mate.#) do if .%m:~-1%==%%~xr set c= %%~nr&set m=%m:~,-1%
set/ab=(a^^%m:~-1%-1)+1,a=7-a
set p=%m:~0,1%
for %%r in (a b c d e f g h)do if %p%==%%r set p=P
for %%r in (QR.a QKt.b QB.c Q.d K.e KB.f KKt.g KR.h)do if .%m:~-2,1%==%%~xr set d=-%%~nr%b%
if %m:~-3,1%==x call set d=x%%%m:~-2%:~1%%
set %m:~-2%=.%p:N=Kt%
set s=%s% %p:N=Kt%%d%%c%
shift
if not "%1"=="" goto l
echo%s%

s is the output string. m is the current move (moves are taken as command-line parameters). a is the current player (0 for White, 7 for Black). b is the row as seen from the point of view of the current player. c is the ch or mate flag. p is the current piece. If there is no piece (i.e. a lowercase letter a-h) then P is substituted. (The N to Kt substitution is done later to save bytes.) The destination column is then looked up in a dictionary. However if the move is actually a capture then the destination becomes an x followed by the piece previously on that square. Either way the destination square is then set to the piece that just moved there. The moves are accumulated until there are no more parameters and then they are printed.

The variables a1...h8 are used to store the last seen piece. The . prefix is there because of the way I initialise the back row; it's hard to loop over two variables at once in Batch unless I'm allowed to begin one with a ..


问:
Golf an InterpretMe interpreter
This is a very simple challenge.

The joke language InterpretMe consists of one command; *, which causes the program to take input of an InterpretMe program and execute it.

An InterpretMe  program will interpret as many InterpretMe programs as there are * in input.

Your goal is to create a program that interprets InterpretMe in as few bytes as possible.

Input

Input will consist of one line ASCII strings, unicode utf-8 strings if you really want, or any character encoding that your language uses, if you want it that much. These strings can either be inputted at the start, or at the start of every run of InterpretMe interpreter. If they are all inputted at the start, the program must output every program line as it begins it.

Output

In this challenge, there will be no output unless the option of one input is chosen, otherwise only termination and non-termination

Test cases consist not of input and output, but input and termination. A newline denotes a new input to be interpreted as InterpretMe.

If using one input at the start, this could be considered what is outputted when these programs are inputted, followed by inactive (do nothing) lines.

```<code>1. *   (executes input as an interpret me program, finishes)
2. *   (^same)
3. **  (executes input as an interpret me program, then does this again after the first program is done, finishes)
4. hi  (nothing, first star of previous line finishes)
5. **  (same as the other two star line)
6. hi  (nothing, first star of previous line finishes)
7. hi  (nothing, second star of line 5 finishes, so second star of line 3 finishes, so line 2 finishes, so line one finishes)
[termination] (not outputted)
</code>```

```<code>hi  (does nothing and finishes)
[termination]
</code>```

```<code>*hi  (executes inputted program, finishes)
*yo  (executes inputted program, finishes)
hey  (nothing)
[termination]
</code>```

Again, this is code-golf, so fewer bytes is better

答:
Python 3, <s>39</s> 38 bytes

```<code>def f():[f()for c in input()if c=="*"]
</code>```

Saved 1 byte thanks to @atlasologist

Title: Golf an InterpretMe interpreter

Body:
Python 3, <s>39</s> 38 bytes

def f():[f()for c in input()if c=="*"]

Saved 1 byte thanks to @atlasologist


答:
Python 3, 35 bytes

```<code>i=1
while i:i+=input().count('*')-1
</code>```

sets i to one, adds the amount of '*' -1 to i

<s>I think I can reduce this with ~ trickery</s> I couldn't

Title: Golf an InterpretMe interpreter

Body:
This is a very simple challenge.

The joke language InterpretMe consists of one command; *, which causes the program to take input of an InterpretMe program and execute it.

An InterpretMe  program will interpret as many InterpretMe programs as there are * in input.

Your goal is to create a program that interprets InterpretMe in as few bytes as possible.

Input

Input will consist of one line ASCII strings, unicode utf-8 strings if you really want, or any character encoding that your language uses, if you want it that much. These strings can either be inputted at the start, or at the start of every run of InterpretMe interpreter. If they are all inputted at the start, the program must output every program line as it begins it.

Output

In this challenge, there will be no output unless the option of one input is chosen, otherwise only termination and non-termination

Test cases consist not of input and output, but input and termination. A newline denotes a new input to be interpreted as InterpretMe.

If using one input at the start, this could be considered what is outputted when these programs are inputted, followed by inactive (do nothing) lines.

```<code>1. *   (executes input as an interpret me program, finishes)
2. *   (^same)
3. **  (executes input as an interpret me program, then does this again after the first program is done, finishes)
4. hi  (nothing, first star of previous line finishes)
5. **  (same as the other two star line)
6. hi  (nothing, first star of previous line finishes)
7. hi  (nothing, second star of line 5 finishes, so second star of line 3 finishes, so line 2 finishes, so line one finishes)
[termination] (not outputted)
</code>```

```<code>hi  (does nothing and finishes)
[termination]
</code>```

```<code>*hi  (executes inputted program, finishes)
*yo  (executes inputted program, finishes)
hey  (nothing)
[termination]
</code>```

Again, this is code-golf, so fewer bytes is better

Body:
Python 3, 35 bytes

i=1
while i:i+=input().count('*')-1

sets i to one, adds the amount of '*' -1 to i

<s>I think I can reduce this with ~ trickery</s> I couldn't


答:
Java only <s>45 60 101 100</s> 99 bytes

Reverse code-golf :D. I noticed that  I missread the specs (twice), but now it should work. Seems simple enough, perhaps there is a better way of writing this as a lamda expression.

```<code>void a(char[]a){for(char b:a)if(b==42)a(new java.util.Scanner(System.in).nextLine().toCharArray());}
</code>```

Slightly sleazy cheating for only 17 bytes!

```<code>void a(char[]a){}
</code>```

This version will take input via really fast typing

Title: Golf an InterpretMe interpreter

Body:
Java only <s>45 60 101 100</s> 99 bytes

Reverse code-golf :D. I noticed that  I missread the specs (twice), but now it should work. Seems simple enough, perhaps there is a better way of writing this as a lamda expression.

void a(char[]a){for(char b:a)if(b==42)a(new java.util.Scanner(System.in).nextLine().toCharArray());}

Slightly sleazy cheating for only 17 bytes!

void a(char[]a){}

This version will take input via really fast typing


问:
A queen's walk across a spiral
In a far-off kingdom, a chess queen takes a daily walk across a spiral path, numbered from 1 to n, not caring to follow the spiral itself, but simply making queen's moves as she would on a chessboard. The queen is beloved by her subjects, and they make a note of every square she visits on her path. Given that the queen can start her walk on any square and ends it on any square, what is the shortest queen's walk that she can take?

The challenge

Given a spiral of integers on a rectangular grid, write a function that returns one of the shortest possible paths (counted by number of cells travelled) between two numbers on this spiral grid using a chess queen's moves.

For example, from 16 to 25:

```<code>25 10 11 12 13
24  9  2  3 14
23  8  1  4 15
22  7  6  5 16
21 20 19 18 17
</code>```

Some possible paths include 16, 4, 2, 10, 25 and 16, 5, 1, 9, 25.

Rules

The input will be any two positive integers.

The output will be a path of integers (including both endpoints) across the spiral using only orthogonal and diagonal moves.

The length of a path is counted by the number of cells travelled.

Your answer may be a program or a function.

This is code golf, so the smallest number of bytes wins.

As always, if the problem is unclear, please let me know. Good luck and good golfing!

Test cases

```<code>>>> queen_spiral(4, 5)
4, 5
>>> queen_spiral(13, 20)
13, 3, 1, 7, 20
>>> queen_spiral(14, 14)
14
>>> queen_spiral(10, 3)
10, 11, 3
>>> queen_spiral(16, 25)
16, 4, 2, 10, 25
>>> queen_spiral(80, 1)
80, 48, 24, 8, 1
</code>```

答:
Scala (830 bytes)

Builds the spiral in a square 2D array using four mutually recursive functions. Another recursive search to build the path list.

```<code>def P(s:Int,e:Int):List[Int]={
import scala.math._
type G=Array[Array[Int]]
type I=Int
type T=(I,I)
def S(z:I)={def U(g:G,x:I,y:I,c:I,r:I):Unit={for(i<-0 to r.min(y)){g(y-i)(x)=c+i}
if(r<=y)R(g,x,y-r,c+r,r)}
def R(g:G,x:I,y:I,c:I,r:I)={for(i<-0 to r){g(y)(x+i)=c+i}
D(g,x+r,y,c+r,r+1)}
def D(g:G,x:I,y:I,c:I,r:I)={for(i<-0 to r){g(y+i)(x)=c+i}
L(g,x,y+r,c+r,r)}
def L(g:G,x:I,y:I,c:I,r:I)={for(i<-0 to r){g(y)(x-i)=c+i}
U(g,x-r,y,c+r,r+1)}
val g=Array.ofDim[I](z,z)
U(g,z/2,z/2,1,1)
g}
def C(n:I,g:G):T={var(x,y)=(0,0)
for(i<-g.indices){val j=g(i).indexOf(n)
if(j>=0){x=j
y=i}}
(x,y)}
def N(n:Int)=if(n==0)0 else if(n<0)-1 else 1
def Q(a:T,b:T):List[T]={val u=N(b._1-a._1)
val v=N(b._2-a._2)
if(u==0&&v==0)b::Nil else a::Q((a._1+u,a._2+v),b)}
val z=ceil(sqrt(max(s,e))).toInt|1
val p=S(z)
Q(C(s,p),C(e,p)).map{case(x,y)=>p(y)(x)}}
</code>```

Ungolfed

```<code>  import scala.math._
  type Grid=Array[Array[Int]]
  def spiral(size: Int) = {
    def up(grid:Grid, x: Int, y: Int, c: Int, r: Int): Unit = {
      for (i <- 0 to r.min(y)) {
        grid(y-i)(x) = c + i
      }
      if (r <= y)
        right(grid,x,y-r,c+r,r)
    }
    def right(grid:Grid, x: Int, y: Int, c: Int, r: Int) = {
      for (i <- 0 to r) {
        grid(y)(x+i) = c + i
      }
      down(grid,x+r,y,c+r,r+1)
    }
    def down(grid:Grid, x: Int, y: Int, c: Int, r: Int) = {
      for (i <- 0 to r) {
        grid(y+i)(x) = c + i
      }
      left(grid,x,y+r,c+r,r)
    }
    def left(grid:Grid, x: Int, y: Int, c: Int, r: Int) = {
      for (i <- 0 to r) {
        grid(y)(x-i) = c + i
      }
      up(grid,x-r,y,c+r,r+1)
    }
    val grid = Array.ofDim[Int](size,size)
    up(grid,size/2,size/2,1,1)
    grid
  }
  def findPath(start: Int, end: Int): List[Int] = {
    def findCoords(n: Int, grid: Grid): (Int, Int) = {
      var (x,y)=(0,0)
      for (i <- grid.indices) {
        val j = grid(i).indexOf(n)
        if (j >= 0) {
          x = j
          y = i
        }
      }
      (x,y)
    }
    def sign(n: Int) = if (n == 0) 0 else if (n < 0) -1 else 1
    def path(stc: (Int, Int), enc: (Int, Int)) : List[(Int, Int)] = {
      val dx = sign(enc._1 - stc._1)
      val dy = sign(enc._2 - stc._2)
      if (dx == 0 && dy == 0) {
        enc :: Nil
      } else {
        stc :: path((stc._1 + dx, stc._2 + dy), enc)
      }
    }
    val size = ceil(sqrt(max(start, end))).toInt | 1
    val spir = spiral(size)
    path(findCoords(start, spir),findCoords(end, spir)).
      map { case (x, y) => spir(y)(x) }
  }
</code>```

Title: A queen's walk across a spiral

Body:
Scala (830 bytes)

Builds the spiral in a square 2D array using four mutually recursive functions. Another recursive search to build the path list.

def P(s:Int,e:Int):List[Int]={
import scala.math._
type G=Array[Array[Int]]
type I=Int
type T=(I,I)
def S(z:I)={def U(g:G,x:I,y:I,c:I,r:I):Unit={for(i<-0 to r.min(y)){g(y-i)(x)=c+i}
if(r<=y)R(g,x,y-r,c+r,r)}
def R(g:G,x:I,y:I,c:I,r:I)={for(i<-0 to r){g(y)(x+i)=c+i}
D(g,x+r,y,c+r,r+1)}
def D(g:G,x:I,y:I,c:I,r:I)={for(i<-0 to r){g(y+i)(x)=c+i}
L(g,x,y+r,c+r,r)}
def L(g:G,x:I,y:I,c:I,r:I)={for(i<-0 to r){g(y)(x-i)=c+i}
U(g,x-r,y,c+r,r+1)}
val g=Array.ofDim[I](z,z)
U(g,z/2,z/2,1,1)
g}
def C(n:I,g:G):T={var(x,y)=(0,0)
for(i<-g.indices){val j=g(i).indexOf(n)
if(j>=0){x=j
y=i}}
(x,y)}
def N(n:Int)=if(n==0)0 else if(n<0)-1 else 1
def Q(a:T,b:T):List[T]={val u=N(b._1-a._1)
val v=N(b._2-a._2)
if(u==0&&v==0)b::Nil else a::Q((a._1+u,a._2+v),b)}
val z=ceil(sqrt(max(s,e))).toInt|1
val p=S(z)
Q(C(s,p),C(e,p)).map{case(x,y)=>p(y)(x)}}

Ungolfed

  import scala.math._
  type Grid=Array[Array[Int]]
  def spiral(size: Int) = {
    def up(grid:Grid, x: Int, y: Int, c: Int, r: Int): Unit = {
      for (i <- 0 to r.min(y)) {
        grid(y-i)(x) = c + i
      }
      if (r <= y)
        right(grid,x,y-r,c+r,r)
    }
    def right(grid:Grid, x: Int, y: Int, c: Int, r: Int) = {
      for (i <- 0 to r) {
        grid(y)(x+i) = c + i
      }
      down(grid,x+r,y,c+r,r+1)
    }
    def down(grid:Grid, x: Int, y: Int, c: Int, r: Int) = {
      for (i <- 0 to r) {
        grid(y+i)(x) = c + i
      }
      left(grid,x,y+r,c+r,r)
    }
    def left(grid:Grid, x: Int, y: Int, c: Int, r: Int) = {
      for (i <- 0 to r) {
        grid(y)(x-i) = c + i
      }
      up(grid,x-r,y,c+r,r+1)
    }
    val grid = Array.ofDim[Int](size,size)
    up(grid,size/2,size/2,1,1)
    grid
  }
  def findPath(start: Int, end: Int): List[Int] = {
    def findCoords(n: Int, grid: Grid): (Int, Int) = {
      var (x,y)=(0,0)
      for (i <- grid.indices) {
        val j = grid(i).indexOf(n)
        if (j >= 0) {
          x = j
          y = i
        }
      }
      (x,y)
    }
    def sign(n: Int) = if (n == 0) 0 else if (n < 0) -1 else 1
    def path(stc: (Int, Int), enc: (Int, Int)) : List[(Int, Int)] = {
      val dx = sign(enc._1 - stc._1)
      val dy = sign(enc._2 - stc._2)
      if (dx == 0 && dy == 0) {
        enc :: Nil
      } else {
        stc :: path((stc._1 + dx, stc._2 + dy), enc)
      }
    }
    val size = ceil(sqrt(max(start, end))).toInt | 1
    val spir = spiral(size)
    path(findCoords(start, spir),findCoords(end, spir)).
      map { case (x, y) => spir(y)(x) }
  }


答:
C#, <s>52</s> <s>50</s> 49 bytes

49 bytes : 'for(int i=0;i++<10;)Console.Write("**********\n")' (Thanks to Csharpie)

50 bytes : for(int i=0;i<10;i++)Console.Write("**********\n")

52 bytes : for(int i=0;i<10;i++)Console.WriteLine("**********")

Close with 70 bytes : Console.WriteLine(String.Concat(Enumerable.Repeat("**********\n",10)))

edit : Test here : Online C# Interactive compiler.

P.S : C# Interactive is there in Visual Studio/Roslyn for a long time, no one said the answer needs to compile into an executable, or that C# is limited to .NET's verbose BCL functions or that C# is limited to Windows.
csi.exe would just be same in functionality as other (interpreted) languages' interpreters do (like PowerShell), which is the beauty of C#.

Title: Print a 10 by 10 grid of asterisks

Body:
Background

This is a standard textbook example to demonstrate for loops.

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

Task

You are to print this exact text:

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

Specs

You may have extra trailing newlines.

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

Scoring

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


答:
Python 122

```<code>import sys
D=[R+S for S in'cdhs'for R in'A23456789TJQK']
while(D):
    x=int(sys.stdin.read(6),2)
    if x<len(D):print D.pop(x)
</code>```

Explanation:

Unused cards are stored in D. This simply gets the next valid random index from the input stream and pops that element from D.

Unless I am missing something, there shouldn't be a bias. The script will throw out any invalid indices > len(D), but this doesn't result in a bias for lower numbers because each successive pop will reduce the index of each element past than i.

Title: Output a shuffled deck using random input

Body:
Input/Output:

Input: A uniformly random, infinitely long, string of '0's and '1's, taken from stdin.  The string is assumed to be truly random, not pseudo-random.  It is uniform in that each character is equally likely to be a '0' or '1'.

Careful! The input is infinitely long, so you can't store it all in memory using a function like raw_input() in python.  If I'm not mistaken, golfscript will fail with infinite input, since it pushes the entire input onto the stack prior to running.

Output: A uniformly random shuffled standard deck, without jokers.  It is uniform in that all orderings are equally likely.

Each card in the output is it's rank, A, 2-9, T, J, Q or K concatenated with it's suit, c, d, h or s.  For example, the 10 of spades is Ts

The cards of the deck should be separated by spaces.

You may not use built-in random libraries or functions because they are not truly random, only pseudo-random.

Example input

You may use the following python script to pipe input into your program:

```<code>import sys, random
try:
    while True:
        sys.stdout.write(str(random.randint(0,1)))
except IOError:
    pass
</code>```

If you save the script as rand.py, test your program with python rand.py | your_program

In python 3 it runs as expected, but in python 2.7 I get an error message after my program's output, but only after everything's done, so just ignore the error message.

Example output:

Here's how the deck should be printed if it happened to be shuffled into a sorted order:

```<code>Ac 2c 3c 4c 5c 6c 7c 8c 9c Tc Jc Qc Kc Ad 2d 3d 4d 5d 6d 7d 8d 9d Td Jd Qd Kd Ah 2h 3h 4h 5h 6h 7h 8h 9h Th Jh Qh Kh As 2s 3s 4s 5s 6s 7s 8s 9s Ts Js Qs Ks
</code>```

Scoring:

This is a code golf.  Shortest code wins.

Example program:

Here is a python 2.7 solution, not golfed.

```<code>import sys
def next():
    return int(sys.stdin.read(1))==1
def roll(n):
    if n==1:
        return 0
    if n%2==0:
        r=roll(n/2)
        if next():
            r+=n/2
        return r
    else:
        r=n
        while(r==n):
            r=roll(n+1)
        return r
deck = [rank+suit for suit in 'cdhs' for rank in 'A23456789TJQK']
while len(deck)>0:
    print deck.pop(roll(len(deck))),
</code>```

Body:
Python 122

import sys
D=[R+S for S in'cdhs'for R in'A23456789TJQK']
while(D):
    x=int(sys.stdin.read(6),2)
    if x<len(D):print D.pop(x)

Explanation:

Unused cards are stored in D. This simply gets the next valid random index from the input stream and pops that element from D.

Unless I am missing something, there shouldn't be a bias. The script will throw out any invalid indices > len(D), but this doesn't result in a bias for lower numbers because each successive pop will reduce the index of each element past than i.


问:
Implement the divisibility-by-7 rule
To check whether a decimal number is divisible by 7:

Erase the last digit. Multiply it by 2 and subtract from what is left. If the result is divisible by 7, the original number is divisible by 7.

(also described e.g. here)

This rule is good for manual divisibility check. For example:

Is 2016 divisible by 7?

Subtract 6*2 from 201; we get 189. Is this divisible by 7? To check it, let's apply the rule again.

Subtract 9*2 from 18; we get 0. Therefore, 2016 is divisible by 7.

In this challenge, you should apply this rule until the divisibility status is obvious, that is, the number is not greater than 70 (however, see below for details). Make a function or a full program.

Input: a positive integer; your code should support inputs up to 32767 (supporting arbitrary-precision integers is a bonus; see below).

Output: an integer (possibly negative), not greater than 70, that is a result of applying the divisibility-by-7 rule zero or more times.

Test cases:

```<code>Input                   Output      Alternative output

1                       1
10                      10          1
100                     10          1
13                      13          -5
42                      42          0
2016                    0
9                       9
99                      -9
9999                    -3
12345                   3
32767                   28          -14

---------- Values below are only relevant for the bonus

700168844221            70          7
36893488147419103232    32          -1
231584178474632390847141970017375815706539969331281128078915168015826259279872    8
</code>```

Where two possible outputs are specified, either result is correct: the second one corresponds to applying the rule one more time. It's forbidden to apply the rule on a single-digit number: if you erase the digit, nothing (not 0) is left.

Bonus: If your algorithm

Supports arbitrary-precision integers

Performs only one pass on the input

Has space complexity o(n) (i.e. less than O(n)); and

Has time complexity O(n),

where n is the number of decimal digits:

Subtract 50% from your code's byte count.

Real bonus:

In addition, if your algorithm reads the input in normal direction, starting from the most significant digit, subtract 50% once again - your score is 25% of your byte count (it seems possible, but I'm not absolutely sure).

答:
Java, 133 bytes

```<code>int d(int n){String s=""+n;return n<71?n:d(Integer.parseInt(s.replaceFirst(".$",""))-Integer.parseInt(""+s.charAt(s.length()-1))*2);}
</code>```

I hate how verbose Integer.parseInt is. Ungolfed:

```<code>static int div(int n) {
    if (n <= 70) {
        return n;
    } else {
        String num = ("" + n);
        int last = Integer.parseInt("" + num.charAt(num.length() - 1));
        int k = Integer.parseInt(num.replaceFirst(".$", "")) - last * 2;
        return div(k);
    }
}
</code>```

Title: Implement the divisibility-by-7 rule

Body:
Java, 133 bytes

int d(int n){String s=""+n;return n<71?n:d(Integer.parseInt(s.replaceFirst(".$",""))-Integer.parseInt(""+s.charAt(s.length()-1))*2);}

I hate how verbose Integer.parseInt is. Ungolfed:

static int div(int n) {
    if (n <= 70) {
        return n;
    } else {
        String num = ("" + n);
        int last = Integer.parseInt("" + num.charAt(num.length() - 1));
        int k = Integer.parseInt(num.replaceFirst(".$", "")) - last * 2;
        return div(k);
    }
}


答:
HTML & CSS, <s>104</s> 60 bytes

p::after{content:"**********"```
<pre class="snippet-code-html lang-html prettyprint-override"><code><p><p><p><p><p><p><p><p><p><p></code>```

I'm unsure if the byte count is correct (as I'm not counting the

Title: Print a 10 by 10 grid of asterisks

Body:
HTML & CSS, <s>104</s> 60 bytes

p::after{content:"**********"

<p><p><p><p><p><p><p><p><p><p>

I'm unsure if the byte count is correct (as I'm not counting the <style> tags for CSS. The HTML could also be shortened if I used a HTML preprocessor, but I'm unsure if that's breaking rules

Thanks to manatwork and Business Cat.

See my Jade entry of 36 bytes


答:
Clojure, 38 bytes

```<code>(apply print(repeat 10"**********\n"))
</code>```

Simple enough

Title: Print a 10 by 10 grid of asterisks

Body:
Clojure, 38 bytes

(apply print(repeat 10"**********\n"))

Simple enough


答:
JavaScript, <s>53</s> <s>45</s> 44 bytes

```<code>f=_=>{for(i in prompt().match(/\*/g))f()}f()
</code>```

This program is rather annoying to use due to JavaScript's lack of good I/O.

Asks for a program, then asks for another program for every * in the input program.

Title: Golf an InterpretMe interpreter

Body:
JavaScript, <s>53</s> <s>45</s> 44 bytes

f=_=>{for(i in prompt().match(/\*/g))f()}f()

This program is rather annoying to use due to JavaScript's lack of good I/O.

Asks for a program, then asks for another program for every * in the input program.


答:
T-SQL, 35 bytes

I used a hard carriage return in the string, which is why it wraps to the next line.

```<code>select replicate('**********
',10)
</code>```

Title: Print a 10 by 10 grid of asterisks

Body:
T-SQL, 35 bytes

I used a hard carriage return in the string, which is why it wraps to the next line.

select replicate('**********
',10)


答:
Javascript (ES5), 105 bytes

Beating all other ES6 answers using some good ol' vanilla JS looping!

```<code>for(a="",n=g=1;n++<52;n<27?g++:g--){for(z=x=0;z++<g*2-1;z<g?x++:x--)a+=String.fromCharCode(65+x);a+="\n"}a
</code>```

I could save 1 byte by using ES6 and changing

```<code>a+="\n"
</code>```

to

```<code>a+=`
`
</code>```

but nah.

Title: Alphabet triangle

Body:
You are to print this exact text:

```<code>A
ABA
ABCBA
ABCDCBA
ABCDEDCBA
ABCDEFEDCBA
ABCDEFGFEDCBA
ABCDEFGHGFEDCBA
ABCDEFGHIHGFEDCBA
ABCDEFGHIJIHGFEDCBA
ABCDEFGHIJKJIHGFEDCBA
ABCDEFGHIJKLKJIHGFEDCBA
ABCDEFGHIJKLMLKJIHGFEDCBA
ABCDEFGHIJKLMNMLKJIHGFEDCBA
ABCDEFGHIJKLMNONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXYXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXYZYXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXYXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNONMLKJIHGFEDCBA
ABCDEFGHIJKLMNMLKJIHGFEDCBA
ABCDEFGHIJKLMLKJIHGFEDCBA
ABCDEFGHIJKLKJIHGFEDCBA
ABCDEFGHIJKJIHGFEDCBA
ABCDEFGHIJIHGFEDCBA
ABCDEFGHIHGFEDCBA
ABCDEFGHGFEDCBA
ABCDEFGFEDCBA
ABCDEFEDCBA
ABCDEDCBA
ABCDCBA
ABCBA
ABA
A
</code>```

Specs

Extra trailing newlines are allowed at the end of the output.

Extra trailing spaces (U+0020) are allowed at the end of each line, including the extra trailing newlines.

You can use all lowercase instead of all uppercase, but you cannot print partially lowercase partially uppercase.

You can return the text as a function output instead of printing it in a full program.

Scoring

Since this is a triangle, and a triangle has 3 sides, and 3 is a small number, your code should be small in terms of byte-count.

Body:
Javascript (ES5), 105 bytes

Beating all other ES6 answers using some good ol' vanilla JS looping!

for(a="",n=g=1;n++<52;n<27?g++:g--){for(z=x=0;z++<g*2-1;z<g?x++:x--)a+=String.fromCharCode(65+x);a+="\n"}a

I could save 1 byte by using ES6 and changing

a+="\n"

to

a+=`
`

but nah.


答:
Same, 239 bytes

```<code>ЕEЕEЕEЕEЕEEЕЕEЕEЕEЕЕEΕЕEЕEEЕЕЕΕЕЕEЕEЕEЕEЕEЕEЕEЕEЕEЕEΕEEΕEЕΕЕEEЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕΕЕЕEЕEЕEЕEЕEЕEЕEЕEЕEЕEЕЕЕЕEΕEEΕЕЕΕΕΕ
</code>```

Samebly code used to generate this:

```<code>add 5
mstore
add 3
mult
add 2
mstore
clear
add 10
while
    minc
    mstore
    mdec
    mread
    outc
    outc
    outc
    outc
    outc
    outc
    outc
    outc
    outc
    outc
    clear
    add 10
    outc
    minc
    mread
    mdec
    dec
end
</code>```

Title: Print a 10 by 10 grid of asterisks

Body:
Same, 239 bytes

ЕEЕEЕEЕEЕEEЕЕEЕEЕEЕЕEΕЕEЕEEЕЕЕΕЕЕEЕEЕEЕEЕEЕEЕEЕEЕEЕEΕEEΕEЕΕЕEEЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕЕΕЕЕEЕEЕEЕEЕEЕEЕEЕEЕEЕEЕЕЕЕEΕEEΕЕЕΕΕΕ

Samebly code used to generate this:

add 5
mstore
add 3
mult
add 2
mstore
clear
add 10
while
    minc
    mstore
    mdec
    mread
    outc
    outc
    outc
    outc
    outc
    outc
    outc
    outc
    outc
    outc
    clear
    add 10
    outc
    minc
    mread
    mdec
    dec
end


答:
JavaScript (ES6), 81 bytes

```<code>[...'ZYXWVUTSRQPONMLKJIHGFEDCBA'].reduce((p,c)=>c+`
`+p.replace(/^|$/gm,c)+`
`+c)
</code>```

Title: Alphabet triangle

Body:
JavaScript (ES6), 81 bytes

[...'ZYXWVUTSRQPONMLKJIHGFEDCBA'].reduce((p,c)=>c+`
`+p.replace(/^|$/gm,c)+`
`+c)


问:
Convert YYYYMM to MMMYY
Basing on this SO question.

Challenge is rather simple: given a date period in the format YYYYMM output it in the format MMMYY.

Rules:

The input will be a number or a string exactly 6 characters long, consisting only of digits.

Last two digits will be between 01 and 12.

Output must be in the form MMMYY, where MMM represents uppercase three-letter code for the month (below) and YY represents two last digits of the YYYY part of the input.

List of months with corresponding code:

```<code>MM    MMM
01    JAN
02    FEB
03    MAR
04    APR
05    MAY
06    JUN
07    JUL
08    AUG
09    SEP
10    OCT
11    NOV
12    DEC
</code>```

Examples:

```<code>Input     Output
201604    APR16
200001    JAN00
000112    DEC01
123405    MAY34
</code>```

答:
T-SQL, 96 bytes

declare @i varchar(8)
select  @i = '201604'
select upper(left(datename(month,@i+'01'),3)) + substring(@i,5,2)
```

Title: Convert YYYYMM to MMMYY