答:
Python, <s>56</s> <s>62</s> 64 bytes

```<code>lambda b:sorted(b,key=lambda x:(x,x[4:])[x.lower()[:4]=='the '])
</code>```

Try it

Thanks to @Chris H for pointing out that lstrip() was not handling The The correctly, since the strip was blasting all matching characters and sorting it as a blank string, and @manatwork for finding the flaw in using replace(). The new version should work.

Old version:

```<code>lambda b:sorted(b,key=lambda x:x.lower().lstrip('the '))
</code>```

Title: Sort band names

Body:
Python, <s>56</s> <s>62</s> 64 bytes

lambda b:sorted(b,key=lambda x:(x,x[4:])[x.lower()[:4]=='the '])

Try it

Thanks to @Chris H for pointing out that lstrip() was not handling The The correctly, since the strip was blasting all matching characters and sorting it as a blank string, and @manatwork for finding the flaw in using replace(). The new version should work.

Old version:

lambda b:sorted(b,key=lambda x:x.lower().lstrip('the '))


问:
Sort band names

Challenge description

You have a music library with many tracks recorded by many bands, each of which has a name, like Queen, Aerosmith, Sunny Day Real Estate, The Strokes . When an audio player displays your library alphabetically by band name, it usually skips the The part, as many band names start with The, making it easier to navigate through your media collection. In this challenge, given a list (array) of strings, you need to sort it that way (that is, omitting the The word at the beginning of the name). You can either write a method or a full working program.

Sample inputs / outputs

```<code>[Queen, Aerosmith, Sunny Day Real Estate, The Strokes] -> [Aerosmith, Queen, The Strokes, Sunny Day Real Estate]
[The Ramones, The Cure, The Pixies, The Roots, The Animals, Enrique Iglesias] -> [The Animals, The Cure, Enrique Iglesias, The Pixies, The Ramones, The Roots]
[The The, The They, Thermodynamics] -> [The The, Thermodynamics, The They]
</code>```

Notes / Edge cases

Sorting lexicographically is case insensitive, so The Police, The police and the police are all equivalent,

Your algorithm should only omit the first the word, so bands named The The or The The Band are sorted normally by the second the,

A band named The (a three letter word) is sorted normally (no skipping),

Order of two bands having the same name, one of which starts with the (like The Police and Police) is undefined,

You can assume that if a band's name consists of more than one word, they are separated by a single space character. You don't need to handle leading or trailing whitespaces,

All input strings match [A-Za-z0-9 ]*, that is they will consist only of lower- and uppercase letters of English alphabet, digits and space characters,

Remember that this is a code-golf challenge, so make your code as short as possible!

答:
V, <s>32</s> 28 bytes

```<code>ç^The /dwA_
:sort
ç_/$xIThe
</code>```

Try it online!

Note to self: Make an abbreviation for :sort so that I don't need 6 whole bytes for a single command!

Explanation:

```<code>ç^The /     "On every line starting with 'The ',
       dw   "Delete a word
         A_ "And (A)ppend an underscore '_'

:sort       "Sort all lines alphabetically

ç_/         "On every line containing an underscore,
   $x       "Delete the last character
     IThe   "And prepened 'The '
</code>```

ContentLicense: CC BY-SA 3.0

Title: Sort band names

Body:
V, <s>32</s> 28 bytes

ç^The /dwA_
:sort
ç_/$xIThe

Try it online!

Note to self: Make an abbreviation for :sort so that I don't need 6 whole bytes for a single command!

Explanation:

ç^The /     "On every line starting with 'The ',
       dw   "Delete a word
         A_ "And (A)ppend an underscore '_'

:sort       "Sort all lines alphabetically

ç_/         "On every line containing an underscore,
   $x       "Delete the last character
     IThe   "And prepened 'The '


答:
MATL, 16 bytes

```<code>tk'^the '[]YX2$S
</code>```

Input format is (each line corresponds to a test case)

```<code>{'Queen', 'Aerosmith', 'Sunny Day Real Estate', 'The Strokes'}
{'The Ramones', 'The Cure', 'The Pixies', 'The Roots', 'The Animals', 'Enrique Iglesias'}
{'The The', 'The They', 'Thermodynamics'}
</code>```

Try it online!

Explanation

```<code>t        % Implicitly input cell array of strings. Push another copy
k        % Convert to lowercase
'^the '  % String to be used as regex pattern: matches initial 'the '
[]       % Empty array
YX       % Regex replacement: replace initial 'the ' in each string by empty array
2$S      % Sort input according to the modified cell array. Implicitly display
</code>```

Title: Sort band names

Body:
Challenge description

You have a music library with many tracks recorded by many bands, each of which has a name, like Queen, Aerosmith, Sunny Day Real Estate, The Strokes . When an audio player displays your library alphabetically by band name, it usually skips the The part, as many band names start with The, making it easier to navigate through your media collection. In this challenge, given a list (array) of strings, you need to sort it that way (that is, omitting the The word at the beginning of the name). You can either write a method or a full working program.

Sample inputs / outputs

```<code>[Queen, Aerosmith, Sunny Day Real Estate, The Strokes] -> [Aerosmith, Queen, The Strokes, Sunny Day Real Estate]
[The Ramones, The Cure, The Pixies, The Roots, The Animals, Enrique Iglesias] -> [The Animals, The Cure, Enrique Iglesias, The Pixies, The Ramones, The Roots]
[The The, The They, Thermodynamics] -> [The The, Thermodynamics, The They]
</code>```

Notes / Edge cases

Sorting lexicographically is case insensitive, so The Police, The police and the police are all equivalent,

Your algorithm should only omit the first the word, so bands named The The or The The Band are sorted normally by the second the,

A band named The (a three letter word) is sorted normally (no skipping),

Order of two bands having the same name, one of which starts with the (like The Police and Police) is undefined,

You can assume that if a band's name consists of more than one word, they are separated by a single space character. You don't need to handle leading or trailing whitespaces,

All input strings match [A-Za-z0-9 ]*, that is they will consist only of lower- and uppercase letters of English alphabet, digits and space characters,

Remember that this is a code-golf challenge, so make your code as short as possible!

Body:
MATL, 16 bytes

tk'^the '[]YX2$S

Input format is (each line corresponds to a test case)

{'Queen', 'Aerosmith', 'Sunny Day Real Estate', 'The Strokes'}
{'The Ramones', 'The Cure', 'The Pixies', 'The Roots', 'The Animals', 'Enrique Iglesias'}
{'The The', 'The They', 'Thermodynamics'}

Try it online!

Explanation

t        % Implicitly input cell array of strings. Push another copy
k        % Convert to lowercase
'^the '  % String to be used as regex pattern: matches initial 'the '
[]       % Empty array
YX       % Regex replacement: replace initial 'the ' in each string by empty array
2$S      % Sort input according to the modified cell array. Implicitly display


问:
King of the Torus!

King of the Torus!

Your job is to conquer the torus, but wait, there are multiple other players banded together in teams facing you! You will need to use your wit's to conquer the torus.

There are three teams: red, blue and green. Teams are self-assigned arbitrarily. If the teams are even you may join the team of your choice, otherwise you must join the smallest team(s). The map is a torus presented as a square of length 640  by 640.  Lets take a look at a sample map

```<code>OOOOOOOOOOOOOOOOOOOOOOOOOOO
RRRRRRRRRRRRRRRRRRRRRRRRRRR
OOOOOOOOOOOOOOOOOOOOOOOOOOO
GGGGGOOOOOOOOBBBBBBBBBBBBBB
GGGGGGGGGGGGGGGGGGGGGOOOOOG
OOOOOOOOOOOOOOOOOOOOOOOOOGG
RRRRRRRRRRRRRRRRRRRRRRRRRRR
OOOOOOOOOOOOOOOOOOOOOOOOOOO
</code>```

as you can see, the red team has built a wall to safely conquer the territory between the two walls. Blue, and green will have to fight it out. This scaled down version of the map is representative of the larger one.

Red would likely win this battle as they would finish the game (once the board is filled or a large number of turns have passed) with the most territory

Now each bot has a location (known only to you). You can only move to an adjacent square if it is owned by your team. At the start of your game, you start on a single square of your teams color. Your goal is to expand this splotch by conquering other land. At any turn you can choose to move to any adjacent color of your own territory or you may alternatively choose to attack an adjacent territory. If the attacked square is unowned it will be captured.

Java API

You will override the Bot class to return a single number (0-3) for attempted moves and 4-7 for an attempted attack. Your bot's should only take 10 milliseconds to move, but the rule will not be formally enforced unless it becomes a problem. Problematic, malicous, or otherwise obnoxious bots are clearly not in the spirit of this competition and will be disqualified with an immediate low quality flag.
Otherwise bots acting in good faith, but otherwise buggy will be given time as needed for bug repairs.
Method summary

```<code>public abstract class Bot{
public final int team;// 0 = red 1 = green 2 = blue
public Bot(int inTeam){team=inTeam}//be sure to call super(inTeam);
public int move(){};//you will override this
}

Methods available

Color Bot.getColor(int x,int y){}//returns a Color object with rgb values where the r g or b value of the team owning it will be 100.
getX(); returns the X position of your bot
getY(); returns the y position of your bot
Bot.getMap();//returns the array representing the map. I.e Bot.getMap[i][j] returns a color with r g b values representing each teams stake in that spot.
//only one r g b value will be greater than 0 as only one team can hold a spot
Do not abuse the map access. Giving direct access (as opposed to a copy) is to speed up access to the map. Abusing it will result in disqualification!
</code>```

A wrapper program may be made available as long as it still allows the program to run smoothly.

How to play:

Step one: Post your bot here as an answer and ensure it follows the specs.

Step Two Head over to this gitHub repository fork it and add your bot's file in as well as add these two lines after '//init bots' Bot.run. Be sure to choose the team with the least members if applicable.

```<code>  bots.add(new UniqueBotNameHere(team=choiceOfTeam,x=getRandom(0,map.length),y=getRandom(0,map[0].length)));
    map[x][y].colors[team]=255;
</code>```

Step Three: Make a pull request. I will accept your pull request and your bot will automagically be added to the tournament.

Step Four: Download the source files and copy them into the proper package. Run the build and enjoy watching the bots

Good luck and don't let your team down! Team's will be made even by my sample bots. I may also move around teams to ensure equal members.

Interesting trivia

Modifying the Half Hearted flood filling sample bot, gives an interesting map generator.

答:
Waller

He builds a wall, but he can't make the other team pay for it! He makes a nice low level bot to help debug your submissions.

```<code>public class Trump extends Bot{
int moves;
int direction;
    public Trump(int team, int inX, int inY) {
        super(team, inX, inY);
direction = Bot.getRandom(0, 4);
    }

    @Override
    public int move() {
int ret = direction;
switch(++moves%4){
    case 0:
        ret = direction+4;
        break;
    case 1:
        ret = direction;
        break;
    case 2:
        ret = direction + 1;
        break;
    case 3:
        ret = direction +3;
}
return ret;
    }

}
</code>```

Title: King of the Torus!

Body:
Waller

He builds a wall, but he can't make the other team pay for it! He makes a nice low level bot to help debug your submissions.

public class Trump extends Bot{
int moves;
int direction;
    public Trump(int team, int inX, int inY) {
        super(team, inX, inY);
direction = Bot.getRandom(0, 4);
    }

    @Override
    public int move() {
int ret = direction;
switch(++moves%4){
    case 0:
        ret = direction+4;
        break;
    case 1:
        ret = direction;
        break;
    case 2:
        ret = direction + 1;
        break;
    case 3:
        ret = direction +3;
}
return ret;
    }

}


答:
Half Hearted Flood Filler

Another low level bot. He tries to flood fill the map, but he only puts in 50% effort! I will enter another more competitve bot, but this guy is just to demonstrate one possible approach.

```<code>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package toroidal.domination;

import java.awt.Color;
import java.util.Stack;

/**
 *
 * @author rohan
 */
public class HalfHeartedFloodFillBot extends Bot{
    public static class Node{
        public final int x,y;
        public Node(int x, int y){
            this.x=x;this.y=y;
        }
    }
private Stack<Integer> nodes = new Stack<>();
    public HalfHeartedFloodFillBot(int team, int inX, int inY) {
        super(team, inX, inY);
    }

    @Override
    public int move() {
        int x,y;

        for(int i = 0;i<4;i++){
    if(isEmpty(Bot.getColorAtSpot(x=getX()+(int) Math.cos(i*Math.PI/2),y= getY()+(int) Math.sin(i*Math.PI/2)))){
        nodes.add((i+2)%4);
        return i+4;
    }
}
        //no empty spots found try to backtrack or just do stuff!
return nodes.isEmpty()?Bot.getRandom(0,2)==0?Bot.getRandom(0, 2)==0?0:1:Bot.getRandom(0, 2)==0?2:3:nodes.pop();
    }
    boolean isEmpty(Color c){
        int r = c.getRed();
        int g = c.getGreen();
        int b = c.getBlue();
        return r == 0 && b == 0&& g == 0;
    }
}
</code>```

Title: King of the Torus!

Body:
King of the Torus!

Your job is to conquer the torus, but wait, there are multiple other players banded together in teams facing you! You will need to use your wit's to conquer the torus.

There are three teams: red, blue and green. Teams are self-assigned arbitrarily. If the teams are even you may join the team of your choice, otherwise you must join the smallest team(s). The map is a torus presented as a square of length 640  by 640.  Lets take a look at a sample map

```<code>OOOOOOOOOOOOOOOOOOOOOOOOOOO
RRRRRRRRRRRRRRRRRRRRRRRRRRR
OOOOOOOOOOOOOOOOOOOOOOOOOOO
GGGGGOOOOOOOOBBBBBBBBBBBBBB
GGGGGGGGGGGGGGGGGGGGGOOOOOG
OOOOOOOOOOOOOOOOOOOOOOOOOGG
RRRRRRRRRRRRRRRRRRRRRRRRRRR
OOOOOOOOOOOOOOOOOOOOOOOOOOO
</code>```

as you can see, the red team has built a wall to safely conquer the territory between the two walls. Blue, and green will have to fight it out. This scaled down version of the map is representative of the larger one.

Red would likely win this battle as they would finish the game (once the board is filled or a large number of turns have passed) with the most territory

Now each bot has a location (known only to you). You can only move to an adjacent square if it is owned by your team. At the start of your game, you start on a single square of your teams color. Your goal is to expand this splotch by conquering other land. At any turn you can choose to move to any adjacent color of your own territory or you may alternatively choose to attack an adjacent territory. If the attacked square is unowned it will be captured.

Java API

You will override the Bot class to return a single number (0-3) for attempted moves and 4-7 for an attempted attack. Your bot's should only take 10 milliseconds to move, but the rule will not be formally enforced unless it becomes a problem. Problematic, malicous, or otherwise obnoxious bots are clearly not in the spirit of this competition and will be disqualified with an immediate low quality flag.
Otherwise bots acting in good faith, but otherwise buggy will be given time as needed for bug repairs.
Method summary

```<code>public abstract class Bot{
public final int team;// 0 = red 1 = green 2 = blue
public Bot(int inTeam){team=inTeam}//be sure to call super(inTeam);
public int move(){};//you will override this
}

Methods available

Color Bot.getColor(int x,int y){}//returns a Color object with rgb values where the r g or b value of the team owning it will be 100.
getX(); returns the X position of your bot
getY(); returns the y position of your bot
Bot.getMap();//returns the array representing the map. I.e Bot.getMap[i][j] returns a color with r g b values representing each teams stake in that spot.
//only one r g b value will be greater than 0 as only one team can hold a spot
Do not abuse the map access. Giving direct access (as opposed to a copy) is to speed up access to the map. Abusing it will result in disqualification!
</code>```

A wrapper program may be made available as long as it still allows the program to run smoothly.

How to play:

Step one: Post your bot here as an answer and ensure it follows the specs.

Step Two Head over to this gitHub repository fork it and add your bot's file in as well as add these two lines after '//init bots' Bot.run. Be sure to choose the team with the least members if applicable.

```<code>  bots.add(new UniqueBotNameHere(team=choiceOfTeam,x=getRandom(0,map.length),y=getRandom(0,map[0].length)));
    map[x][y].colors[team]=255;
</code>```

Step Three: Make a pull request. I will accept your pull request and your bot will automagically be added to the tournament.

Step Four: Download the source files and copy them into the proper package. Run the build and enjoy watching the bots

Good luck and don't let your team down! Team's will be made even by my sample bots. I may also move around teams to ensure equal members.

Interesting trivia

Modifying the Half Hearted flood filling sample bot, gives an interesting map generator.

Body:
Half Hearted Flood Filler

Another low level bot. He tries to flood fill the map, but he only puts in 50% effort! I will enter another more competitve bot, but this guy is just to demonstrate one possible approach.

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package toroidal.domination;

import java.awt.Color;
import java.util.Stack;

/**
 *
 * @author rohan
 */
public class HalfHeartedFloodFillBot extends Bot{
    public static class Node{
        public final int x,y;
        public Node(int x, int y){
            this.x=x;this.y=y;
        }
    }
private Stack<Integer> nodes = new Stack<>();
    public HalfHeartedFloodFillBot(int team, int inX, int inY) {
        super(team, inX, inY);
    }

    @Override
    public int move() {
        int x,y;

        for(int i = 0;i<4;i++){
    if(isEmpty(Bot.getColorAtSpot(x=getX()+(int) Math.cos(i*Math.PI/2),y= getY()+(int) Math.sin(i*Math.PI/2)))){
        nodes.add((i+2)%4);
        return i+4;
    }
}
        //no empty spots found try to backtrack or just do stuff!
return nodes.isEmpty()?Bot.getRandom(0,2)==0?Bot.getRandom(0, 2)==0?0:1:Bot.getRandom(0, 2)==0?2:3:nodes.pop();
    }
    boolean isEmpty(Color c){
        int r = c.getRed();
        int g = c.getGreen();
        int b = c.getBlue();
        return r == 0 && b == 0&& g == 0;
    }
}


问:
Hofstadter H-sequence

Definition

\$a(0) = 0\$

\$a(n) = n-a(a(a(n-1)))\$ for integer \$n > 0\$

Task

Given non-negative integer \$n\$, output \$a(n)\$.

Testcases

```<code>n     a(n)
0     0
1     1
2     1
3     2
4     3
5     4
6     4
7     5
8     5
9     6
10    7
11    7
12    8
13    9
14    10
15    10
16    11
17    12
18    13
19    13
20    14
10000 6823
</code>```

References

WolframMathWorld

OEIS A005374

答:
Javascript ES6, 22 bytes

```<code>a=n=>n&&n-a(a(a(n-1)))
</code>```

I'll be boring and do the recursive version :P

ContentLicense: CC BY-SA 4.0

Title: Hofstadter H-sequence

Body:
Javascript ES6, 22 bytes

a=n=>n&&n-a(a(a(n-1)))

I'll be boring and do the recursive version :P


问:
Szekeres's sequence

Definition

\$a(1) = 1\$

\$a(2) = 2\$

\$a(n)\$ is smallest number \$k>a(n-1)\$ which avoids any 3-term arithmetic progression in \$a(1), a(2), ..., a(n-1), k\$.

In other words, \$a(n)\$ is the smallest number \$k>a(n-1)\$ such that there does not exist \$x, y\$ where \$0<x<y<n\$ and \$a(y)-a(x) = k-a(y)\$.

Worked out example

For \$n=5\$:

We have \$a(1), a(2), a(3), a(4) = 1, 2, 4, 5\$

If \$a(5)=6\$, then \$2, 4, 6\$ form an arithmetic progression.

If \$a(5)=7\$, then \$1, 4, 7\$ form an arithmetic progression.

If \$a(5)=8\$, then \$2, 5, 8\$ form an arithmetic progression.

If \$a(5)=9\$, then \$1, 5, 9\$ form an arithmetic progression.

If \$a(5)=10\$, no arithmetic progression can be found.

Therefore \$a(5)=10\$.

Task

Given \$n\$, output \$a(n)\$.

Specs

\$n\$ will be a positive integer.

You can use 0-indexed instead of 1-indexed, in which case \$n\$ can be \$0\$. Please state it in your answer if you are using 0-indexed.

Scoring

Since we are trying to avoid 3-term arithmetic progression, and 3 is a small number, your code should be as small (i.e. short) as possible, in terms of byte-count.

Testcases

The testcases are 1-indexed. You can use 0-indexed, but please specify it in your answer if you do so.

```<code>1     1
2     2
3     4
4     5
5     10
6     11
7     13
8     14
9     28
10    29
11    31
12    32
13    37
14    38
15    40
16    41
17    82
18    83
19    85
20    86
10000 1679657
</code>```

References

WolframMathWorld

OEIS A003278

答:
Python 3, 28 bytes

```<code>lambda n:int(bin(n)[2:],3)+1
</code>```

An anonymous function that takes input via argument and returns the result. This is zero-indexed.

How it works

```<code>lambda n    Anonymous function with input zero-indexed term index n
bin(n)      Convert n to a binary string..
...[2:]     ...remove `0b` from beginning...
int(...,3)  ...convert from base-3 to decimal...
...+1       ...increment...
:...        and return
</code>```

Try it on Ideone

Title: Szekeres's sequence

Body:
Python 3, 28 bytes

lambda n:int(bin(n)[2:],3)+1

An anonymous function that takes input via argument and returns the result. This is zero-indexed.

How it works

lambda n    Anonymous function with input zero-indexed term index n
bin(n)      Convert n to a binary string..
...[2:]     ...remove `0b` from beginning...
int(...,3)  ...convert from base-3 to decimal...
...+1       ...increment...
:...        and return

Try it on Ideone


答:
RETURN, 17 bytes

```<code>[$[$1-aaa-][]?]=a
</code>```

Try it here!

Recursive operator that leaves result on the stack. Example usage:

```<code>[$[$1-aaa-][]?]=a 4a
</code>```

Title: Hofstadter H-sequence

Body:
Definition

\$a(0) = 0\$

\$a(n) = n-a(a(a(n-1)))\$ for integer \$n > 0\$

Task

Given non-negative integer \$n\$, output \$a(n)\$.

Testcases

```<code>n     a(n)
0     0
1     1
2     1
3     2
4     3
5     4
6     4
7     5
8     5
9     6
10    7
11    7
12    8
13    9
14    10
15    10
16    11
17    12
18    13
19    13
20    14
10000 6823
</code>```

References

WolframMathWorld

OEIS A005374

Body:
RETURN, 17 bytes

[$[$1-aaa-][]?]=a

Try it here!

Recursive operator that leaves result on the stack. Example usage:

[$[$1-aaa-][]?]=a 4a


问:
Integers, Assemble!
Your task is to assemble the integers from 1 to N (given as input) into a rectangle of width W and height H (also given as input). Individual numbers may be rotated by any multiple of 90 degrees, but they must appear as contiguous blocks in the rectangle. That is, you cannot break one of the numbers into multiple digits and place the digits in the rectangle individually, neither can you bend three digits of a number around a corner. You could consider each number a brick from which you're building a wall.

Here is an example. Say your input is (N, W, H) = (12, 5, 3). One possible solution is:

```<code>18627
21901
53114
</code>```

For clarity, here are two copies of this grid, one with the one-digit numbers hidden and one with the two-digit numbers hidden:

```<code>1####    #8627
2##01    #19##
##11#    53##4
</code>```

It's fine if the rectangle cannot be disassembled again in a unique way. For instance, in the above example, the 12 could also have been placed like this:

```<code>#####    18627
21#01    ##9##
##11#    53##4
</code>```

Rules

You may assume that N is positive and that W*H matches the number of digits in the integers from 1 to N inclusive, and that a tiling of the rectangle into the given numbers exists. I don't currently have a proof whether this is always possible, but I'd be interested in one if you do.

Output may either be a single linefeed-separated string or a list of strings (one for each line) or a list of lists of single-digit integers (one for each cell).

The results of your submission must be determinstic and you should be able to handle all test cases in less than a minute on reasonable desktop machine.

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

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

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

Test Cases

Except for the first one, none of these are unique. Each test case is N W H followed by a possible output. Make sure that your answer works when the rectangle is too narrow to write the larger numbers horizontally.

```<code>1 1 1
1

6 6 1
536142

6 2 3
16
25
34

10 1 11
1
0
8
9
2
6
7
3
1
5
4

11 13 1
1234567891011

27 9 5
213112117
192422581
144136119
082512671
205263272

183 21 21
183116214112099785736
182516114011998775635
181116013911897765534
180415913811796755433
179115813711695745332
178315713611594735231
177115613511493725130
176215513411392715029
175115413311291704928
174115313211190694827
173115213111089684726
172015113010988674625
171915012910887664524
170814912810786654423
169714812710685644322
168614712610584634221
167514612510483624120
166414512410382614019
165314412310281603918
164214312210180593817
163114212110079583716

200 41 12
81711132917193661114105533118936111184136
50592924448815915414562967609909953662491
89529721161671582389717813151113658811817
41418184511110119010183423720433017331118
35171183614003547461181197275184300111711
41874381132041861871718311415915921116264
11914245014112711011594492626831219331845
17125112629222085166344707736090956375181
94507611291431121128817413566319161275711
11011540021119913511011169939551729880780
92725141607727665632702567369893534277304
78118311405621148296417218591118562161856
</code>```

答:
Pyth, <s>79 50</s>  48 Bytes

<s>Noncompeting until I work out bugs (for example, [6,6,1] returns the same as [6,1,6]).    It's my first time trying to use Pyth, so I'm probably missing a lot of features.</s>

Thanks to Jakube, saved 29 bytes and made my code actually work!

Saved another two byte by realizing that the repr() calls were unnecessary.

It's basically just a translation of mbomb007's Python 2 answer.

```<code>AEJmkHFb2VHVGIgGl+@JNQ XNJ~tQ)))=.[.TJkGA,HG)jJ
</code>```

Takes input in the form of

n

w,h.

Title: Integers, Assemble!

Body:
Pyth, <s>79 50</s>  48 Bytes

<s>Noncompeting until I work out bugs (for example, [6,6,1] returns the same as [6,1,6]).    It's my first time trying to use Pyth, so I'm probably missing a lot of features.</s>

Thanks to Jakube, saved 29 bytes and made my code actually work!

Saved another two byte by realizing that the repr() calls were unnecessary.

It's basically just a translation of mbomb007's Python 2 answer.

AEJmkHFb2VHVGIgGl+@JNQ XNJ~tQ)))=.[.TJkGA,HG)jJ

Takes input in the form of

n

w,h.


问:
Print this diamond
This question has been spreading like a virus in my office. There are quite a variety of approaches:

Print the following:

```<code>        1
       121
      12321
     1234321
    123454321
   12345654321
  1234567654321
 123456787654321
12345678987654321
 123456787654321
  1234567654321
   12345654321
    123454321
     1234321
      12321
       121
        1
</code>```

Answers are scored in characters with fewer characters being better.

Title: Print this diamond

Body:
Python, 65

for i in map(int,str(int('1'*9)**2)):print' '*(9-i),int('1'*i)**2


答:
Haskell, 84 bytes

```<code>import Data.List
p(t:'h':'e':' ':s)|elem t"Tt"=s
p s=s
sortBy(\a b->p a`compare`p b)
</code>```

Call with

```<code>sortBy(\a b->p a`compare`p b)["The The", "The They", "Thermodynamics"]
</code>```

Testcase:

```<code>let s = sortBy(\a b->p a`compare`p b)
and[s["Queen", "Aerosmith", "Sunny Day Real Estate", "The Strokes"]==["Aerosmith", "Queen", "The Strokes", "Sunny Day Real Estate"],s["The Ramones", "The Cure", "The Pixies", "The Roots", "The Animals", "Enrique Iglesias"]==["The Animals", "The Cure", "Enrique Iglesias", "The Pixies", "The Ramones", "The Roots"],s["The The", "The They", "Thermodynamics"]==["The The", "Thermodynamics", "The They"]]
</code>```

Title: Sort band names

Body:
Haskell, 84 bytes

import Data.List
p(t:'h':'e':' ':s)|elem t"Tt"=s
p s=s
sortBy(\a b->p a`compare`p b)

Call with

sortBy(\a b->p a`compare`p b)["The The", "The They", "Thermodynamics"]

Testcase:

let s = sortBy(\a b->p a`compare`p b)
and[s["Queen", "Aerosmith", "Sunny Day Real Estate", "The Strokes"]==["Aerosmith", "Queen", "The Strokes", "Sunny Day Real Estate"],s["The Ramones", "The Cure", "The Pixies", "The Roots", "The Animals", "Enrique Iglesias"]==["The Animals", "The Cure", "Enrique Iglesias", "The Pixies", "The Ramones", "The Roots"],s["The The", "The They", "Thermodynamics"]==["The The", "Thermodynamics", "The They"]]


问:
Cooke and Wheatstone telegraph, five-needle

Definition

According to Wikipedia:

The Cooke and Wheatstone telegraph was an early electrical telegraph system dating from the 1830s invented by English inventor William Fothergill Cooke and English scientist Charles Wheatstone. It was the first telegraph system to be put into commercial service. The receiver consisted of a number of needles which could be moved by electromagnetic coils to point to letters on a board. This feature was liked by early users who were unwilling to learn codes, and employers who did not want to invest in staff training.

It works like this:

In the middle are five needles, which can be deflected clockwise (as is the case of the middle needle) or anti-clockwise (as is the case of the last needle).

In the picture above, the two deflected needles point to the letter G, which means that the letter being transmitted/received is the letter G.

Note that the letters C, J, Q, V, X, Z are missing and thus have to be substituted with other letters.

Task

You will receive a character in ABDEFGHIKLMNOPRSTUWY as input, and you will output the corresponding configuration of the five needles, with undeflected as |, deflected clockwise as /, and deflected anti-clockwise as \.

Testcases

This covers all the possible inputs

```<code>input output
A     /|||\
B     /||\|
D     |/||\
E     /|\||
F     |/|\|
G     ||/|\  (explanation: see above)
H     /\|||
I     |/\||
K     ||/\|
L     |||/\
M     \/|||
N     |\/||
O     ||\/|
P     |||\/
R     \|/||
S     |\|/|
T     ||\|/
U     \||/|
W     |\||/
Y     \|||/
</code>```

Rules/Requirements

Each submission should be either a full program or function. If it is a function, it must be runnable by only needing to add the function call to the bottom of the program. Anything else (e.g. headers in C), must be included.

If it is possible, provide a link to a site where your program can be tested.

Your program must not write anything to STDERR.

Standard Loopholes are forbidden.

Your program can output in any case, but it must be printed (not an array or similar).

Scoring

Programs are scored according to bytes, in UTF-8 by default or a different character set of your choice.

Eventually, the answer with the least bytes will win.

Submissions

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

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

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

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

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

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

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

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

Leaderboard

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

/* Configuration */

var QUESTION_ID = 87104; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 48934; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });

  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (/ b.lang) return 1;
    if (a.lang < b.lang) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}</code>```

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Ruby, 159 bytes

```<code>v=[1,2,3,4,7,8,9,13,14,19];w=v+v.map{|e|25+e};a="HEBAIFDKGLMRUYNSWOTP";b="\\/"
x=w[a.index($*[0][0])];g="|"*5;y=(x>25)?0:1;g[(x/5)%5]=b[y];g[x%5]=b[1-y];puts g
</code>```

Explanation:

The positions of the deflected needles are mapped to 0..4, and thought as a  base-5 number (2 digits). For A-L, the numbers are "as is"; for M-Z, add 25 to the number. The map is from variables a to w.

Given the number corresponding to the letter, use its base-5 representation: the 5s digit for the first needle, the 1s digit for the second needle, and the 25s digit for the needles' directions.

A program to encode an entire string, instead of one character, is just a bit longer: 172 bytes.

```<code>v=[1,2,3,4,7,8,9,13,14,19];w=v+v.map{|e|25+e};a="HEBAIFDKGLMRUYNSWOTP";b="\\/"
$*[0].each_char{|c|x=w[a.index(c)];g="|"*5;y=(x>25)?0:1;g[(x/5)%5]=b[y];g[x%5]=b[1-y];puts g}
</code>```

Body:
Ruby, 159 bytes

v=[1,2,3,4,7,8,9,13,14,19];w=v+v.map{|e|25+e};a="HEBAIFDKGLMRUYNSWOTP";b="\\/"
x=w[a.index($*[0][0])];g="|"*5;y=(x>25)?0:1;g[(x/5)%5]=b[y];g[x%5]=b[1-y];puts g

Explanation:

The positions of the deflected needles are mapped to 0..4, and thought as a  base-5 number (2 digits). For A-L, the numbers are "as is"; for M-Z, add 25 to the number. The map is from variables a to w.

Given the number corresponding to the letter, use its base-5 representation: the 5s digit for the first needle, the 1s digit for the second needle, and the 25s digit for the needles' directions.

A program to encode an entire string, instead of one character, is just a bit longer: 172 bytes.

v=[1,2,3,4,7,8,9,13,14,19];w=v+v.map{|e|25+e};a="HEBAIFDKGLMRUYNSWOTP";b="\\/"
$*[0].each_char{|c|x=w[a.index(c)];g="|"*5;y=(x>25)?0:1;g[(x/5)%5]=b[y];g[x%5]=b[1-y];puts g}


答:
Ruby, 42 bytes

```<code>->a{a.sort_by{|s|s.upcase.sub /^THE /,''}}
</code>```

Try it online!

Title: Sort band names

Body:
Ruby, 42 bytes

->a{a.sort_by{|s|s.upcase.sub /^THE /,''}}

Try it online!


问:
Print/Output the L-phabet
Inspired by George Gibson's Print a Tabula Recta.

You are to print/output this exact text:

```<code>ABCDEFGHIJKLMNOPQRSTUVWXYZ
BBCDEFGHIJKLMNOPQRSTUVWXYZ
CCCDEFGHIJKLMNOPQRSTUVWXYZ
DDDDEFGHIJKLMNOPQRSTUVWXYZ
EEEEEFGHIJKLMNOPQRSTUVWXYZ
FFFFFFGHIJKLMNOPQRSTUVWXYZ
GGGGGGGHIJKLMNOPQRSTUVWXYZ
HHHHHHHHIJKLMNOPQRSTUVWXYZ
IIIIIIIIIJKLMNOPQRSTUVWXYZ
JJJJJJJJJJKLMNOPQRSTUVWXYZ
KKKKKKKKKKKLMNOPQRSTUVWXYZ
LLLLLLLLLLLLMNOPQRSTUVWXYZ
MMMMMMMMMMMMMNOPQRSTUVWXYZ
NNNNNNNNNNNNNNOPQRSTUVWXYZ
OOOOOOOOOOOOOOOPQRSTUVWXYZ
PPPPPPPPPPPPPPPPQRSTUVWXYZ
QQQQQQQQQQQQQQQQQRSTUVWXYZ
RRRRRRRRRRRRRRRRRRSTUVWXYZ
SSSSSSSSSSSSSSSSSSSTUVWXYZ
TTTTTTTTTTTTTTTTTTTTUVWXYZ
UUUUUUUUUUUUUUUUUUUUUVWXYZ
VVVVVVVVVVVVVVVVVVVVVVWXYZ
WWWWWWWWWWWWWWWWWWWWWWWXYZ
XXXXXXXXXXXXXXXXXXXXXXXXYZ
YYYYYYYYYYYYYYYYYYYYYYYYYZ
ZZZZZZZZZZZZZZZZZZZZZZZZZZ
</code>```

(Yes, I typed that by hand)

You are allowed to use all lowercase instead of all uppercase.

However, your choice of case must be consistent throughout the whole text.

Rules/Requirements

Each submission should be either a full program or function. If it is a function, it must be runnable by only needing to add the function call to the bottom of the program. Anything else (e.g. headers in C), must be included.

If it is possible, provide a link to a site where your program can be tested.

Your program must not write anything to STDERR.

Standard Loopholes are forbidden.

Your program can output in any case, but it must be printed (not an array or similar).

Scoring

Programs are scored according to bytes, in UTF-8 by default or a different character set of your choice.

Eventually, the answer with the least bytes will win.

Submissions

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

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

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

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

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

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

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

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

Leaderboard

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

/* Configuration */

var QUESTION_ID = 87064; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 48934; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });

  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (/ b.lang) return 1;
    if (a.lang < b.lang) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}</code>```

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
JavaScript, 101 bytes

Not as short as the other and probably doesn't have much room for improvement without changing how it works, but this was the solution I came up with without looking at any of the other answers first.

s=String.fromCharCode
for(l=0;l<26;){o=s(65+l).repeat(l)
for(i=l++;i<26;)o+=s(65+i++)
console.log(o)}```

Title: Print/Output the L-phabet


答:
Perl 6, 26 bytes

*.sort({fc S:i/^'the '//})
```

<h3>Explanation:</h3>

<pre class="lang-perl6 prettyprint-override"><code># ｢*｣ is the input to this Whatever lambda
*.sort(

  # sort based on the return value of this Block lambda
  {
    fc # foldcase the following

    # string replace but not in-place
    S
      :ignorecase
      /
        # at the start of the string
        ^

        # match ｢the ｣
        'the '

      # replace with nothing
      //
  }
)
</code>```

Test:

use v6.c;
use Test;

my @tests = (
  « Queen Aerosmith 'Sunny Day Real Estate' 'The Strokes' »
    => « Aerosmith Queen 'The Strokes' 'Sunny Day Real Estate' »,
  « 'The Ramones' 'The Cure' 'The Pixies' 'The Roots' 'The Animals' 'Enrique Iglesias' »
    => « 'The Animals' 'The Cure' 'Enrique Iglesias' 'The Pixies' 'The Ramones' 'The Roots' »,
  « 'The The' 'The They' Thermodynamics »
    => « 'The The' Thermodynamics 'The They' »,
);

# give it a lexical name for clarity
my &band-sort = *.sort({fc S:i/^'the '//});

plan +@tests;

for @tests -> ( :key(@input), :value(@expected) ) {
  is-deeply band-sort(@input), @expected, @expected.perl;
}
```

<pre class="lang-perl6 prettyprint-override"><code>1..3
ok 1 - ("Aerosmith", "Queen", "The Strokes", "Sunny Day Real Estate")
ok 2 - ("The Animals", "The Cure", "Enrique Iglesias", "The Pixies", "The Ramones", "The Roots")
ok 3 - ("The The", "Thermodynamics", "The They")
</code>```

Title: Sort band names

Body:
Perl 6, 26 bytes

*.sort({fc S:i/^'the '//})

Explanation:

# ｢*｣ is the input to this Whatever lambda
*.sort(

  # sort based on the return value of this Block lambda
  {
    fc # foldcase the following

    # string replace but not in-place
    S
      :ignorecase
      /
        # at the start of the string
        ^

        # match ｢the ｣
        'the '

      # replace with nothing
      //
  }
)

Test:

use v6.c;
use Test;

my @tests = (
  « Queen Aerosmith 'Sunny Day Real Estate' 'The Strokes' »
    => « Aerosmith Queen 'The Strokes' 'Sunny Day Real Estate' »,
  « 'The Ramones' 'The Cure' 'The Pixies' 'The Roots' 'The Animals' 'Enrique Iglesias' »
    => « 'The Animals' 'The Cure' 'Enrique Iglesias' 'The Pixies' 'The Ramones' 'The Roots' »,
  « 'The The' 'The They' Thermodynamics »
    => « 'The The' Thermodynamics 'The They' »,
);

# give it a lexical name for clarity
my &band-sort = *.sort({fc S:i/^'the '//});

plan +@tests;

for @tests -> ( :key(@input), :value(@expected) ) {
  is-deeply band-sort(@input), @expected, @expected.perl;
}

1..3
ok 1 - ("Aerosmith", "Queen", "The Strokes", "Sunny Day Real Estate")
ok 2 - ("The Animals", "The Cure", "Enrique Iglesias", "The Pixies", "The Ramones", "The Roots")
ok 3 - ("The The", "Thermodynamics", "The They")


答:
Scratch (scratchblocks), 323 bytes

```<code>when gf clicked
set [a v] to [ABCDEFGHIJKLMNOPQRSTUVWXYZ
set [l v] to [1
repeat (26
  set [o v] to [
  repeat (l
    set [o v] to (join (o) (letter (l) of (a
  end
  set [i v] to (l
  repeat ((26) - (l
    change [i v] by (1
    set [o v] to (join (o) (letter (i) of (a
  end
  say (o) for (1) secs
  change [l v] by (1
end
</code>```

Proof the scratchblocks works (assuming the add "to backpack" feature still exists!), and a project demoing it.

EDIT: At a certain width, Scratch hard-wraps speech bubbles, which I use for output. There isn't really anything I can do about that.

Scratch, 74 bytes

```<code>when gf clicked
replace item (1 v) of [l v] with ([costume name v] of [_ v
</code>```

A project demoing it.

This is definitely a hack!

(It could actually be shortened a bit but then it would break if you ran the project twice. This relies on a project that is.. well, exactly as the demo project!)

Title: Print/Output the L-phabet

Body:
Inspired by George Gibson's Print a Tabula Recta.

You are to print/output this exact text:

```<code>ABCDEFGHIJKLMNOPQRSTUVWXYZ
BBCDEFGHIJKLMNOPQRSTUVWXYZ
CCCDEFGHIJKLMNOPQRSTUVWXYZ
DDDDEFGHIJKLMNOPQRSTUVWXYZ
EEEEEFGHIJKLMNOPQRSTUVWXYZ
FFFFFFGHIJKLMNOPQRSTUVWXYZ
GGGGGGGHIJKLMNOPQRSTUVWXYZ
HHHHHHHHIJKLMNOPQRSTUVWXYZ
IIIIIIIIIJKLMNOPQRSTUVWXYZ
JJJJJJJJJJKLMNOPQRSTUVWXYZ
KKKKKKKKKKKLMNOPQRSTUVWXYZ
LLLLLLLLLLLLMNOPQRSTUVWXYZ
MMMMMMMMMMMMMNOPQRSTUVWXYZ
NNNNNNNNNNNNNNOPQRSTUVWXYZ
OOOOOOOOOOOOOOOPQRSTUVWXYZ
PPPPPPPPPPPPPPPPQRSTUVWXYZ
QQQQQQQQQQQQQQQQQRSTUVWXYZ
RRRRRRRRRRRRRRRRRRSTUVWXYZ
SSSSSSSSSSSSSSSSSSSTUVWXYZ
TTTTTTTTTTTTTTTTTTTTUVWXYZ
UUUUUUUUUUUUUUUUUUUUUVWXYZ
VVVVVVVVVVVVVVVVVVVVVVWXYZ
WWWWWWWWWWWWWWWWWWWWWWWXYZ
XXXXXXXXXXXXXXXXXXXXXXXXYZ
YYYYYYYYYYYYYYYYYYYYYYYYYZ
ZZZZZZZZZZZZZZZZZZZZZZZZZZ
</code>```

(Yes, I typed that by hand)

You are allowed to use all lowercase instead of all uppercase.

However, your choice of case must be consistent throughout the whole text.

Rules/Requirements

Each submission should be either a full program or function. If it is a function, it must be runnable by only needing to add the function call to the bottom of the program. Anything else (e.g. headers in C), must be included.

If it is possible, provide a link to a site where your program can be tested.

Your program must not write anything to STDERR.

Standard Loopholes are forbidden.

Your program can output in any case, but it must be printed (not an array or similar).

Scoring

Programs are scored according to bytes, in UTF-8 by default or a different character set of your choice.

Eventually, the answer with the least bytes will win.

Submissions

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

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

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

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

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

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

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

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

Leaderboard

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

/* Configuration */

var QUESTION_ID = 87064; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 48934; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });

  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (/ b.lang) return 1;
    if (a.lang < b.lang) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}</code>```

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Scratch (scratchblocks), 323 bytes

when gf clicked
set [a v] to [ABCDEFGHIJKLMNOPQRSTUVWXYZ
set [l v] to [1
repeat (26
  set [o v] to [
  repeat (l
    set [o v] to (join (o) (letter (l) of (a
  end
  set [i v] to (l
  repeat ((26) - (l
    change [i v] by (1
    set [o v] to (join (o) (letter (i) of (a
  end
  say (o) for (1) secs
  change [l v] by (1
end

Proof the scratchblocks works (assuming the add "to backpack" feature still exists!), and a project demoing it.

EDIT: At a certain width, Scratch hard-wraps speech bubbles, which I use for output. There isn't really anything I can do about that.

Scratch, 74 bytes

when gf clicked
replace item (1 v) of [l v] with ([costume name v] of [_ v

A project demoing it.

This is definitely a hack!

(It could actually be shortened a bit but then it would break if you ran the project twice. This relies on a project that is.. well, exactly as the demo project!)


答:
Sesos, <s>58</s> 55 bytes

```<code>0000000: 16e0d7 bdcdf8 8cdf1b e6cfbb 840d3f bf659b 38e187  ..............?.e.8..
0000015: f8639b 39dc37 fc893f 666c05 7e7ed9 b88b3f ae0d3f  .c.9.7..?fl.~~...?..?
000002a: 676ed8 bd9940 7fdc3b 36619e f1                    gn...@..;6a..
</code>```

Handles inputs up to 400 reasonably well, but run time increases dramatically after that point.

Try it online! Check Debug to see the generated SBIN code.

Sesos assembly

The binary file above has been generated by assembling the following SASM code.

set numin, set numout

get
jmp
    jmp
        rwd 3, add 1, rwd 1, add 1, fwd 4, sub 1
    jnz
    rwd 3, sub 1
jnz
rwd 3, add 1, fwd 2
jmp
    rwd 1, sub 1, fwd 3, sub 1, fwd 2, add 3
    jmp
        rwd 2
        jmp
            rwd 3
        jnz
        fwd 6, get, rwd 4, sub 1
        jmp
            fwd 1, sub 1
            jmp
                rwd 3
            jnz
            sub 1
            jmp
                fwd 3
            jnz
            rwd 4, sub 1
        jnz
        fwd 1
        jmp
            rwd 1, add 1, fwd 1, add 1
        jnz
        sub 1, fwd 3, sub 1
        jmp
            fwd 3
        jnz
        rwd 1, sub 1
    jnz
    rwd 2, get
    nop
        rwd 3
    jnz
    fwd 3, get, rwd 2
    jmp
        fwd 2, add 1
        jmp
            fwd 3
        jnz
        rwd 1, add 1, rwd 2
        jmp
            rwd 3
        jnz
        fwd 1, sub 1
    jnz
    fwd 2
    jmp
        rwd 2, add 1, fwd 2, sub 1
    jnz
    nop
        get, fwd 3
    jnz
    rwd 1, add 1, fwd 2
jnz
rwd 2, sub 1
jmp
    rwd 1, sub 1, fwd 1, sub 1
jnz
rwd 1, put
```

Title: Hofstadter H-sequence

Body:
Sesos, <s>58</s> 55 bytes

0000000: 16e0d7 bdcdf8 8cdf1b e6cfbb 840d3f bf659b 38e187  ..............?.e.8..
0000015: f8639b 39dc37 fc893f 666c05 7e7ed9 b88b3f ae0d3f  .c.9.7..?fl.~~...?..?
000002a: 676ed8 bd9940 7fdc3b 36619e f1                    gn...@..;6a..

Handles inputs up to 400 reasonably well, but run time increases dramatically after that point.

<a href="http://sesos.tryitonline.net/#code=c2V0IG51bWluLCBzZXQgbnVtb3V0CgpnZXQKam1wCglqbXAKCQlyd2QgMywgYWRkIDEsIHJ3ZCAxLCBhZGQgMSwgZndkIDQsIHN1YiAxCglqbnoKCXJ3ZCAzLCBzdWIgMQpqbnoKcndkIDMsIGFkZCAxLCBmd2QgMgpqbXAKCXJ3ZCAxLCBzdWIgMSwgZndkIDMsIHN1YiAxLCBmd2QgMiwgYWRkIDMKCWptcAoJCXJ3ZCAyCgkJam1wCgkJCXJ3ZCAzCgkJam56CgkJZndkIDYsIGdldCwgcndkIDQsIHN1YiAxCgkJam1wCgkJCWZ3ZCAxLCBzdWIgMQoJCQlqbXAKCQkJCXJ3ZCAzCgkJCWpuegoJCQlzdWIgMQoJCQlqbXAKCQkJCWZ3ZCAzCgkJCWpuegoJCQlyd2QgNCwgc3ViIDEKCQlqbnoKCQlmd2QgMQoJCWptcAoJCQlyd2QgMSwgYWRkIDEsIGZ3ZCAxLCBhZGQgMQoJCWpuegoJCXN1YiAxLCBmd2QgMywgc3ViIDEKCQlqbXAKCQkJZndkIDMKCQlqbnoKCQlyd2QgMSwgc3ViIDEKCWpuegoJcndkIDIsIGdldAoJbm9wCgkJcndkIDMKCWpuegoJZndkIDMsIGdldCwgcndkIDIKCWptcAoJCWZ3ZCAyLCBhZGQgMQoJCWptcAoJCQlmd2QgMwoJCWpuegoJCXJ3ZCAxLCBhZGQgMSwgcndkIDIKCQlqbXAKCQkJcndkIDMKCQlqbnoKCQlmd2QgMSwgc3ViIDEKCWpuegoJZndkIDIKCWptcAoJCXJ3ZCAyLCBhZGQgMSwgZndkIDIsIHN1YiAxCglqbnoKCW5vcAoJCWdldCwgZndkIDMKCWpuegoJcndkIDEsIGFkZCAxLCBmd2QgMgpqbnoKcndkIDIsIHN1YiAxCmptcAoJcndkIDEsIHN1YiAxLCBmd2QgMSwgc3ViIDEKam56CnJ3ZCAxLCBwdXQ&input=MjA" rel="nofollow">Try it online! Check Debug to see the generated SBIN code.

Sesos assembly

The binary file above has been generated by assembling the following SASM code.

set numin, set numout

get
jmp
    jmp
        rwd 3, add 1, rwd 1, add 1, fwd 4, sub 1
    jnz
    rwd 3, sub 1
jnz
rwd 3, add 1, fwd 2
jmp
    rwd 1, sub 1, fwd 3, sub 1, fwd 2, add 3
    jmp
        rwd 2
        jmp
            rwd 3
        jnz
        fwd 6, get, rwd 4, sub 1
        jmp
            fwd 1, sub 1
            jmp
                rwd 3
            jnz
            sub 1
            jmp
                fwd 3
            jnz
            rwd 4, sub 1
        jnz
        fwd 1
        jmp
            rwd 1, add 1, fwd 1, add 1
        jnz
        sub 1, fwd 3, sub 1
        jmp
            fwd 3
        jnz
        rwd 1, sub 1
    jnz
    rwd 2, get
    nop
        rwd 3
    jnz
    fwd 3, get, rwd 2
    jmp
        fwd 2, add 1
        jmp
            fwd 3
        jnz
        rwd 1, add 1, rwd 2
        jmp
            rwd 3
        jnz
        fwd 1, sub 1
    jnz
    fwd 2
    jmp
        rwd 2, add 1, fwd 2, sub 1
    jnz
    nop
        get, fwd 3
    jnz
    rwd 1, add 1, fwd 2
jnz
rwd 2, sub 1
jmp
    rwd 1, sub 1, fwd 1, sub 1
jnz
rwd 1, put


问:
Is the DAG a transitive reduction?
The goal of this challenge is given a finite directed acyclic graph (DAG), determine if the graph is a transitive reduction.

A brief explanation of what a DAG and transitive reductions are:

A DAG is a graph with directed edges (i.e. you can only travel in one direction on that edge) such that given any starting node on the graph, it is impossible to return to the starting node (i.e. there are no cycles).

Given any starting node, if it is possible to travel to another ending node in the graph via any arbitrary positive number of edges, then that ending node is defined as reachable from the starting node. In a general DAG, there might be multiple paths which can be taken from a starting node to a target ending node. For example, take this diamond graph:

To get to node D from A, you could take the path A->B->D or A->C->D. Thus, D is reachable from A. However, there is no path which can be taken to get to node B starting from node C. Thus, node B is not reachable from node C.

Define the reachability of the graph as the list of reachable nodes for every starting node in the graph. So for the same example diamond graph, the reachability is:

```<code>A: [B, C, D]
B: [D]
C: [D]
D: []
</code>```

Another graph which has the same reachability as the above graph is shown below:

However, this second graph has more edges than the original graph. The transitive reduction of a graph is a graph with the least number of edges and same reachability of the original graph. So the first graph is the transitive reduction of the second one.

For a finite DAG, the transitive reduction is guaranteed to exist and is unique.

Input

The input is a "list of lists", where the external list has the length of the number of vertices, and each internal list is the length of the number of edges leaving the associated node, and contains the indices of destination nodes. For example, one way to describe the first graph above would be (assuming zero based indexing):

```<code>[[1, 2], [3], [3], []]
</code>```

You may begin indexing of the first node at any arbitrary integer value (e.g. 0 or 1 based indexing).

The input may come from any input source desired (stdio, function parameter, etc.). You are free to choose the exact input format as long as no additional information is given. For example, if you want to take input from stdio, you could have each line be a list of edges for the associated node. Ex.:

```<code>1 2
3
3
'' (blank line)
</code>```

The indices in each adjacency list is not necessarily sorted, and there could be multiple edges connecting two nodes (ex.: [[1,1],[]]). You may assume the input graph is weakly connected, and contains no cycles (i.e. it is a DAG).

Output

The output is truthy if the given input DAG is a transitive reduction, and a falsy value otherwise. This may be to any sink desired (stdio, return value, output parameter, etc.)

Examples

All examples use 0-based indexing.

```<code>[[1,2],[3],[3],[]]
true

[[1,2,3],[3],[3],[]]
false

[[1,1],[]]
false

[[1,2,3,4],[5,6,7],[5,8,9],[6,8,10],[7,9,10],[11,12],[11,13],[12,13],[11,14],[12,14],[13,14],[],[],[],[]]
true

[[5,6,7],[2,3,0,4],[5,8,9],[6,8,10],[7,9,10],[11,12],[11,13],[12,13],[11,14],[12,14],[13,14],[],[],[],[]]
true

[[5,6,7],[2,3,0,4,14,5,7],[5,8,9],[6,8,10],[7,9,10],[11,12],[11,13],[12,13],[11,14],[12,14],[13,14],[],[],[],[]]
false

[[5,6,7],[2,3,0,4],[5,8,9],[6,8,10],[7,9,10,14],[11,12],[11,13],[12,13],[11,14],[12,14],[13,14],[],[],[],[]]
false

[[1,3],[2],[3],[]]
false
</code>```

Scoring

This is code golf; smallest code in bytes wins. Your code should complete in a reasonable amount of time (10 minutes max on whatever hardware you have). Standard loopholes apply. You may use any built-ins desired.

答:
Jelly, 20 bytes

```<code>ị³$ÐĿ€ị@Fœ&¥";œ-Q$€E
</code>```

Uses 1-based indexing. Try it online!

Loose Overview

```<code>     €                for each vertex,
ị³$ÐĿ                   compute its reach.
        Fœ&¥"         intersect each vertex's lists of children and
      ị@                children's reaches.
             ;        then concatenate the list of intersections with
              œ-Q$€     all duplicate edges in the original graph.
                   E  are all elements equal? checks that all are empty lists,
                        meaning empty intersections and no duplicates.
</code>```

Title: Is the DAG a transitive reduction?

Body:
Jelly, 20 bytes

ị³$ÐĿ€ị@Fœ&¥";œ-Q$€E

Uses 1-based indexing. Try it online!

Loose Overview

     €                for each vertex,
ị³$ÐĿ                   compute its reach.
        Fœ&¥"         intersect each vertex's lists of children and
      ị@                children's reaches.
             ;        then concatenate the list of intersections with
              œ-Q$€     all duplicate edges in the original graph.
                   E  are all elements equal? checks that all are empty lists,
                        meaning empty intersections and no duplicates.


Title: Print this diamond

Body:
This question has been spreading like a virus in my office. There are quite a variety of approaches:

Print the following:

```<code>        1
       121
      12321
     1234321
    123454321
   12345654321
  1234567654321
 123456787654321
12345678987654321
 123456787654321
  1234567654321
   12345654321
    123454321
     1234321
      12321
       121
        1
</code>```

Answers are scored in characters with fewer characters being better.

Body:
C, 79 chars

v;main(i){for(;i<307;putchar(i++%18?v>8?32:57-v:10))v=abs(i%18-9)+abs(i/18-8);}


问:
Greatest Common Divisor
Your task is to compute the greatest common divisor (GCD) of two given integers in as few bytes of code as possible.

You may write a program or function, taking input and returning output via any of our accepted standard methods (including STDIN/STDOUT, function parameters/return values, command-line arguments, etc.).

Input will be two non-negative integers. You should be able to handle either the full range supported by your language's default integer type, or the range [0,255], whichever is greater. You are guaranteed that at least one of the inputs will be non-zero.

You are not allowed to use built-ins that compute either the GCD or the LCM (least common multiple).

Standard code-golf rules apply.

Test Cases

```<code>0 2     => 2
6 0     => 6
30 42   => 6
15 14   => 1
7 7     => 7
69 25   => 1
21 12   => 3
169 123 => 1
20 142  => 2
101 202 => 101
</code>```

答:
Maple, <s>77</s> 75 bytes

```<code>`if`(min(a,b)=0,max(a,b),max(`intersect`(op(numtheory:-divisors~({a,b})))))
</code>```

Usage:

```<code>> f:=(a,b)->ifelse(min(a,b)=0,max(a,b),max(`intersect`(op(numtheory:-divisors~({a,b})))));
> f(0,6);
  6
> f(21,12);
  3
</code>```

This uses a Maple deprecated built-in for computing all of the factors for a and b. The updated built-in is NumberTheory:-Divisors.

Title: Greatest Common Divisor

Body:
Maple, <s>77</s> 75 bytes

`if`(min(a,b)=0,max(a,b),max(`intersect`(op(numtheory:-divisors~({a,b})))))

Usage:

> f:=(a,b)->ifelse(min(a,b)=0,max(a,b),max(`intersect`(op(numtheory:-divisors~({a,b})))));
> f(0,6);
  6
> f(21,12);
  3

This uses a Maple deprecated built-in for computing all of the factors for a and b. The updated built-in is NumberTheory:-Divisors.


答:
Python 2, <s>54</s> 53 bytes

a=r,=0,
exec'r=len(a)-a[a[r]];a+=r,;'*input()
print r
```

Not even close to the recursive solution, but at least it's fast.

Test it on Ideone.

Title: Hofstadter H-sequence

Body:
Python 2, <s>54</s> 53 bytes

a=r,=0,
exec'r=len(a)-a[a[r]];a+=r,;'*input()
print r

Not even close to the recursive solution, but at least it's fast.

Test it on Ideone.


问:
Simulate a sock drawer

Background

I have a collection of "weekday socks", which are seven pairs of socks labeled by the days of the week.
When I wash my socks, they end up in a pile, and I must arrange them into the correct pairs before putting them into the closet.
My strategy is to pull one random sock from the pile at a time and put it on a drawer.
Whenever there's a matching pair of socks on the drawer, I tie them together and put them in the closet.
Your task is to simulate this random process and return the number of draws required to find the first matching pair.

Input

Your input is an integer N ≥ 1.
It represents the "number of days in a week": there are N pairs of socks in the pile, and each pair has a distinct label.
If necessary, you may also take a PRNG seed as input.

Output

Your output is the number of socks I have to draw before the first matching pair is found.
For example, if the first two socks already form a matching pair, the output is 2.

Of course, the output is random, and depends on the drawing order.
We assume that all drawing orders are equally likely, so that each time a sock is drawn, the choice is uniform and independent from all other choices.

Example

Let N = 3, so that we have 6 socks in total, labeled A A B B C C.
One possible run of the "sock-drawing protocol" is as follows:

```<code>       | Pile   | Drawer | Pairs
Begin  | AABBCC | -      | -
Draw B | AABCC  | B      | -
Draw C | AABC   | BC     | -
Draw B | AAC    | C      | BB
Draw A | AC     | AC     | BB
Draw A | C      | C      | AA BB
Draw C | -      | -      | AA BB CC
</code>```

The first matching pair was found after drawing the second B, which was the third sock to be drawn, so the correct output is 3.

Rules and scoring

You can write a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.
Input and output can be in any reasonable format, including unary (string of 1s).

You may assume that your language's built-in RNG is perfect.
You don't have to actually simulate the sock-drawing protocol, as long as your outputs have the correct probability distribution.

"Test cases"

Here are the approximate probabilities of all outputs for the input N = 7:

```<code>Output       2     3     4     5     6     7     8
Probability  0.077 0.154 0.210 0.224 0.186 0.112 0.037
</code>```

To test your solution, you can run it for, say, 40 000 times and see whether the output distribution is reasonably close to this.

答:
R, 49

```<code>N=scan();which(duplicated(sample(rep(1:N,2))))[1]
</code>```

I'm sure there must be a better way of doing this in R! I tried doing something cleverer but it didn't work.

Edit: Improved by @bouncyball since it doesn't have to be a function.

Title: Simulate a sock drawer

Body:
R, 49

N=scan();which(duplicated(sample(rep(1:N,2))))[1]

I'm sure there must be a better way of doing this in R! I tried doing something cleverer but it didn't work.

Edit: Improved by @bouncyball since it doesn't have to be a function.


问:
Print a Tabula Recta!
The Tabula Recta (sometimes called a 'Vigenere Table'), was created by Johannes Trithemius, and has been used in several ciphers, including all variants of Bellaso's Vigenere cipher and the Trithemius cipher. It looks like this:

```<code>ABCDEFGHIJKLMNOPQRSTUVWXYZ
BCDEFGHIJKLMNOPQRSTUVWXYZA
CDEFGHIJKLMNOPQRSTUVWXYZAB
DEFGHIJKLMNOPQRSTUVWXYZABC
EFGHIJKLMNOPQRSTUVWXYZABCD
FGHIJKLMNOPQRSTUVWXYZABCDE
GHIJKLMNOPQRSTUVWXYZABCDEF
HIJKLMNOPQRSTUVWXYZABCDEFG
IJKLMNOPQRSTUVWXYZABCDEFGH
JKLMNOPQRSTUVWXYZABCDEFGHI
KLMNOPQRSTUVWXYZABCDEFGHIJ
LMNOPQRSTUVWXYZABCDEFGHIJK
MNOPQRSTUVWXYZABCDEFGHIJKL
NOPQRSTUVWXYZABCDEFGHIJKLM
OPQRSTUVWXYZABCDEFGHIJKLMN
PQRSTUVWXYZABCDEFGHIJKLMNO
QRSTUVWXYZABCDEFGHIJKLMNOP
RSTUVWXYZABCDEFGHIJKLMNOPQ
STUVWXYZABCDEFGHIJKLMNOPQR
TUVWXYZABCDEFGHIJKLMNOPQRS
UVWXYZABCDEFGHIJKLMNOPQRST
VWXYZABCDEFGHIJKLMNOPQRSTU
WXYZABCDEFGHIJKLMNOPQRSTUV
XYZABCDEFGHIJKLMNOPQRSTUVW
YZABCDEFGHIJKLMNOPQRSTUVWX
ZABCDEFGHIJKLMNOPQRSTUVWXY
</code>```

I frequently need this, but can't find it anywhere on the internet to copy and paste from. Because the square table is so long, and takes frigging ages to type, your code must be as short as possible.

Rules/Requirements

Each submission should be either a full program or function. If it is a function, it must be runnable by only needing to add the function call to the bottom of the program. Anything else (e.g. headers in C), must be included.

If it is possible, provide a link to a site where your program can be tested.

Your program must not write anything to STDERR.

Standard Loopholes are forbidden.

Your program can output in any case, but it must be printed (not an array or similar).

Scoring

Programs are scored according to bytes, in UTF-8 by default or a different character set of your choice.

Eventually, the answer with the least bytes will win.

Submissions

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

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

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

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

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

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

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

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

Leaderboard

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

/* Configuration */

var QUESTION_ID = 86986; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 53406; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });

  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (/ b.lang) return 1;
    if (a.lang < b.lang) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}</code>```

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Awk, 73 bytes

```<code>awk 'BEGIN{for(a="ABCDEFGHIJKLMNOPQRSTUVWXYZ";i<26;)print substr(a a,++i,26)}'
</code>```

Edit: Dennis saved me a few bytes. And I learned a new Awk trick.

Title: Print a Tabula Recta!

Body:
Awk, 73 bytes

awk 'BEGIN{for(a="ABCDEFGHIJKLMNOPQRSTUVWXYZ";i<26;)print substr(a a,++i,26)}'

Edit: Dennis saved me a few bytes. And I learned a new Awk trick.


问:
Forecast Palindromic Dates
Palindromic dates are dates that appear as palindromes: the string of digits can be read the same way backwards as forwards. For the North American date format (MM/DD/YYYY), the next few palindromic dates are:

02/02/2020

12/02/2021

03/02/2030

The Challenge

Create a function that returns all palindromic dates in a consistent, common date format (of your choosing) that fall within a range of dates (edit: including the range itself).

Rules

To qualify as a palindrome, only the numeric characters of the date should be
checked.

The date can be in any common format (MM/DD/YYYY, DD-MM-YYYY), as
long as it uses two digits for both the month and day and four for
the year, and it uses a character to separate parts of the date. The output must preserve seperating characters (/, -, etc.). Your function only needs to handle one distinct date format. Please include the format in your answer.

If there are more than one dates returned, they should be comma or
new-line separated.

Shortest answer wins!

Example

```<code>date_palindrome('05/02/2050', '12/12/2060')
>>>['05/02/2050', '06/02/2060']
</code>```

答:
Javascript (using external library) (158 bytes)

```<code>(a,b)=>_.RangeTo(a%1e20,b%1e20,864e5).Select(y=>new Date(y)).Where(x=>z=(_.From(x.toJSON()).Where(y=>!isNaN(y)).Take(8)).SequenceEqual(z.Reverse())).ToArray()
</code>```

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

Code explanation: Ok, I finally used some actual code golfing here for once. So the inputs a,b are Date objects. Create a range of integers from a to b, where a and b are coerced into integers, and the distance between values in the range is 86400000, i.e the amount of ticks in one day. Map each value in the range to a date object. Filter that range by the predicate that represents palindromic dates. The logic to determine that is simple...cast the JSON string representation of the current date object to a char array using the library and filter out the non-numeric entries, and only take the first 8 values (because the that would be yyyyMMdd) and store that into variable z, then check if z is equivalent to z Reversed. Finally, cast back to native JS array

Edit: Shaved 2 bytes by removing unnecessary parens..

Title: Forecast Palindromic Dates

Body:
Javascript (using external library) (158 bytes)

(a,b)=>_.RangeTo(a%1e20,b%1e20,864e5).Select(y=>new Date(y)).Where(x=>z=(_.From(x.toJSON()).Where(y=>!isNaN(y)).Take(8)).SequenceEqual(z.Reverse())).ToArray()

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

Code explanation: Ok, I finally used some actual code golfing here for once. So the inputs a,b are Date objects. Create a range of integers from a to b, where a and b are coerced into integers, and the distance between values in the range is 86400000, i.e the amount of ticks in one day. Map each value in the range to a date object. Filter that range by the predicate that represents palindromic dates. The logic to determine that is simple...cast the JSON string representation of the current date object to a char array using the library and filter out the non-numeric entries, and only take the first 8 values (because the that would be yyyyMMdd) and store that into variable z, then check if z is equivalent to z Reversed. Finally, cast back to native JS array

Edit: Shaved 2 bytes by removing unnecessary parens..


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

答:
Python 3, 97 bytes

s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
a=[s[:x]+s[x::-1]for x in range(26)]
print('\n'.join(a+a[24::-1]))
```

Ideone it!

Title: Alphabet triangle

Body:
Python 3, 97 bytes

s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
a=[s[:x]+s[x::-1]for x in range(26)]
print('\n'.join(a+a[24::-1]))

Ideone it!


答:
Jelly, <s>16</s> 13 bytes

```<code>Ṗ;Ṛ
ØAḣJÇ€Çj⁷
</code>```

Thanks to @LeakyNun for golfing off 3 bytes!

Try it online!

How it works

```<code>Ṗ;Ṛ        Helper link. Argument: A (array)

Ṗ          Pop; yield A without its last element.
  Ṛ        Reversed; yield A with inverted order.
 ;         Concatenate the results to both sides.

ØAḣJÇ€Çj⁷  Main link. No arguments.

ØA         Alphabet; set link argument and return value to "A...Z".
   J       Indices; yield [1, ..., 26].
  ḣ        Head; take the first, the first two, etc. elements of the alphabet.
           This yields ["A", AB", ..., "A...Z"].
    Ç€     Apply the helper link to each string.
      Ç    Apply the helper link to the array itself.
       j⁷  Join, separating by linefeeds.
</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:
Jelly, <s>16</s> 13 bytes

Ṗ;Ṛ
ØAḣJÇ€Çj⁷

Thanks to @LeakyNun for golfing off 3 bytes!

Try it online!

How it works

Ṗ;Ṛ        Helper link. Argument: A (array)

Ṗ          Pop; yield A without its last element.
  Ṛ        Reversed; yield A with inverted order.
 ;         Concatenate the results to both sides.

ØAḣJÇ€Çj⁷  Main link. No arguments.

ØA         Alphabet; set link argument and return value to "A...Z".
   J       Indices; yield [1, ..., 26].
  ḣ        Head; take the first, the first two, etc. elements of the alphabet.
           This yields ["A", AB", ..., "A...Z"].
    Ç€     Apply the helper link to each string.
      Ç    Apply the helper link to the array itself.
       j⁷  Join, separating by linefeeds.


问:
Simple redstone simulator
Redstone is a material in the game Minecraft, and it is used for many complex contraptions. For this program, you will only need to simulate three items: the redstone wire (noted with R), redstone torch (noted with T), and block (noted with B).

Here are a list of basic rules about how redstone works:

```<code>A redstone torch sends power to any adjacent redstone wire.
TRRRR
 ^This redstone wire is powered.

Redstone wire can only hold power for 15 blocks.
TRRRRRRRRRRRRRRRR
                ^This last wire is unpowered, because the torch is >15 blocks away.

A block is said to be powered if a powered redstone wire is found adjacent to it.
TRRRB
    ^This block is powered.

If a block next to a redstone torch is powered, then the torch stops emitting power.
T
R
R
R
B <This block is powered.
T <This redstone torch does not emit power because of the block next to it.
R <This redstone is unpowered because the torch is not providing power.
R
</code>```

Input will be given in two dimensional arrays up to a size of 64x64, like this:

```<code>TRRR
   B
TBRTRR
R
RRRRRRRRR
        R
   RRRRRR
</code>```

It is guaranteed that the input will not have any "clocks", or redstone powered by a torch pointing to the block that the torch is on. There will only be one redstone circuit in every input.

Your program must change each character to be a 1 or a 0, 1 indicating if this item is powered/emitting power, and a 0 if it is unpowered/not emitting power.

This input should have this output:

```<code>1111
   1
100000
1
111111111
        1
   001111
</code>```

This is a code-golf, so shortest code wins, as always.

答:
Python 2, 556 bytes

c=' 0';L=len;M=map;q=list;r='B';s='16';t='T';u='0';E=enumerate
b=[q(M(lambda x:x+[u,s][x==t],q(w[:-1])))+[c]*(64-L(w))for w in open('redstone.txt')]
k=lambda h,l,z:max(q(M(lambda x:[int((x or c)[1:]),0][l^((x or c)[0]==h)],z)))
def v(d=0):
 for e,f in E(b):
    for g,G in E(f):z=[e!=0and b[e-1][g],g<L(f)-1and f[g+1],e<L(b)-1and b[e+1][g],g and f[g-1]];j=G;i=j[0]+str([[s,u][k(r,1,z)>0],4,4,k(t,0,z),0,max(1,k(r,0,z))-1][ord(j[0])%7]);b[e][g]=i;d=d|(i!=j)
 return d
while v():0
for f in b:print''.join(M(lambda j:[' ',`int(j[1:]!=u)`][j[0]!=' '],f))+'\n'
```

See it in action

Assumes each line in input ends with a newline

Outputs via print()

Each line of output ends with lots of whitespace and a newline

Saved lots of bytes thanks to @mbomb007 (#34718)

Saved 1 byte thanks to @ZacharyT (#55550)

Title: Simple redstone simulator

Body:
Python 2, 556 bytes

c=' 0';L=len;M=map;q=list;r='B';s='16';t='T';u='0';E=enumerate
b=[q(M(lambda x:x+[u,s][x==t],q(w[:-1])))+[c]*(64-L(w))for w in open('redstone.txt')]
k=lambda h,l,z:max(q(M(lambda x:[int((x or c)[1:]),0][l^((x or c)[0]==h)],z)))
def v(d=0):
 for e,f in E(b):
    for g,G in E(f):z=[e!=0and b[e-1][g],g<L(f)-1and f[g+1],e<L(b)-1and b[e+1][g],g and f[g-1]];j=G;i=j[0]+str([[s,u][k(r,1,z)>0],4,4,k(t,0,z),0,max(1,k(r,0,z))-1][ord(j[0])%7]);b[e][g]=i;d=d|(i!=j)
 return d
while v():0
for f in b:print''.join(M(lambda j:[' ',`int(j[1:]!=u)`][j[0]!=' '],f))+'\n'

See it in action

Assumes each line in input ends with a newline

Outputs via print()

Each line of output ends with lots of whitespace and a newline

Saved lots of bytes thanks to @mbomb007 (#34718)

Saved 1 byte thanks to @ZacharyT (#55550)


问:
Modulo code golf
Write a function f(a,b) that returns a mod b given the constraints:

you can't use division in any way

f(a,b) is always positive, eg: f(-1,5) = 4

it performs reasonably well for values of ~10e50 for a and b

答:
Haskell (22)

Abuse of the rules, please don't downvote: Mathematically, the modulus may be arbitrary large, because all moduli are equivalent. Thus, you may also use this, it WILL always return a positive result:

```<code>1234567890123456789012
a?b|a<0=(a+b)?b|True=a
</code>```

And it will also always satisfy the equation

```<code>a?b = c <-> n*b + c = a
</code>```

For some integer n.

Title: Modulo code golf

Body:
Haskell (22)

Abuse of the rules, please don't downvote: Mathematically, the modulus may be arbitrary large, because all moduli are equivalent. Thus, you may also use this, it WILL always return a positive result:

1234567890123456789012
a?b|a<0=(a+b)?b|True=a

And it will also always satisfy the equation

a?b = c <-> n*b + c = a

For some integer n.

ContentLicense: CC BY-SA 2.5


问:
Basic Calculator
You must write a program to evaluate a string that would be entered into a calculator.

The program must accept input and output the correct answer.  For languages that do not have standard input/output functions, you may assume the functions readLine and print.

Requirements

Does not use any kind of "eval" functions

Can handle floating point and negative numbers

Supports at least the +, -, *, and / operators

Can handle input containing one or more spaces between the operators and numbers

Evaluates the expression from left to right

The program that is the shortest wins.  In the event of a tie, the program that was submitted first wins.

You can assume that the input is valid and follows the correct format

Test Cases

Input

```<code>-4 + 5
</code>```

Output

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

Input

```<code>-7.5 / 2.5
</code>```

Output

```<code>-3
</code>```

Input

```<code>-2 + 6 / 2 * 8 - 1 / 2.5 - 18
</code>```

Output

```<code>-12
</code>```

答:
PostScript (145)

Another PostScript entry (thanks to luser droog for digging the golfs interesting for PostScript!):

```<code>[/+{add}/-{sub}/*{mul}/{div}>>begin(%stdin)(r)file
999 string readline
pop{token not{exit}if
count 4 eq{3 1 roll
4 1 roll
cvx exec}if
exch}loop
=
</code>```

Un-golfed:

```<code>[/+{add}/-{sub}/*{mul}/ {div}>>begin
% Read the input
(%stdin)(r)file 999 string readline pop
{                        % .. string
  token not{exit}if      % .. string token
  % If we have 4 objects on the stack, we have two operands, one operator
  % and the input string. This means, we can calculate now.
  count 4 eq{            % a op string b
    % perform operation a op b = c (where op can be +,-,*,/)
    3 1 roll             % a b op string
    4 1 roll             % string a b op
    cvx exec             % string c
  }if                    % string token (or c)
  exch                   % token string
}loop
=
</code>```

Title: Basic Calculator

Body:
PostScript (145)

Another PostScript entry (thanks to luser droog for digging the golfs interesting for PostScript!):

[/+{add}/-{sub}/*{mul}/{div}>>begin(%stdin)(r)file
999 string readline
pop{token not{exit}if
count 4 eq{3 1 roll
4 1 roll
cvx exec}if
exch}loop
=

Un-golfed:

[/+{add}/-{sub}/*{mul}/ {div}>>begin
% Read the input
(%stdin)(r)file 999 string readline pop
{                        % .. string
  token not{exit}if      % .. string token
  % If we have 4 objects on the stack, we have two operands, one operator
  % and the input string. This means, we can calculate now.
  count 4 eq{            % a op string b
    % perform operation a op b = c (where op can be +,-,*,/)
    3 1 roll             % a b op string
    4 1 roll             % string a b op
    cvx exec             % string c
  }if                    % string token (or c)
  exch                   % token string
}loop
=