问:
Turn a string into a windmill
The code on this site is rapidly being depleted. We need to invest in renewable strings. So you must write a program that takes a string and converts it into a windmill.

The Challenge

Let's take a simple wind-mill string as an example. Take the string abc. The pivot is the center character, in this case b. Since the string is 3 chars long, every output will be exactly three lines tall and three characters wide. Here is your output on step 1. (Note the whitespace)

```

abc

```

To get the next step, rotate each character around the pivot clockwise. Here is step 2:

```
a
 b
  c
```

Here are steps 3-8:

```
 a
 b
 c
```
```
  a
 b
c
```
```

cba

```
```
c
 b
  a
```
```
 c
 b
 a
```
```
  c
 b
a
```

And on the ninth step, it comes around full circle to the original string:

```

abc

```

Note that the b stayed in the same spot the whole time. This is because b is the pivot character. You must write a program or function that takes a string as input and repeatedly prints out this sequence until the program is closed.

Clarifications

All input strings will have an odd number of characters. (So that every windmill will have a pivot)

To keep the challenge simple, all strings will only contain upper and lowercase alphabet characters.

The output must be len(input_string) characters wide and tall.

It doesn't matter which step of the sequence you start on, just as long as you continue rotating and looping forever.

More Test IO:

Since the post is already pretty long, here is a link to  the output for "windmill":

Sidenote:

Since this is supposed to be a windmill, it would be awesome if you include some boilerplate code to animate it with a small time delay or a user input between each step. However, since some languages don't have time builtins, this is not mandatory. The competing part of your submission can just print the sequence as fast as possible.

答:
JavaScript (ES6), 291 bytes

r=a=>{w.textContent=a.map(a=>a.join``).join`
`;for(i=j=h=a.length>>1;j++,i--;){t=a[i][i];a[i][i]=a[h][i];a[h][i]=a[j][i];a[j][i]=a[j][h];a[j][h]=a[j][j];a[j][j]=a[h][j];a[h][j]=a[i][j];a[i][j]=a[i][h];a[i][h]=t}}
s=w=>{a=[...w=[...w]].map(_=>w.map(_=>' '));a[w.length>>1]=w;setInterval(r,1000,a)}
s("windmills")```
<pre class="snippet-code-html lang-html prettyprint-override"><code><pre id=w></code>```

Title: Turn a string into a windmill

Body:
JavaScript (ES6), 291 bytes

r=a=>{w.textContent=a.map(a=>a.join``).join`
`;for(i=j=h=a.length>>1;j++,i--;){t=a[i][i];a[i][i]=a[h][i];a[h][i]=a[j][i];a[j][i]=a[j][h];a[j][h]=a[j][j];a[j][j]=a[h][j];a[h][j]=a[i][j];a[i][j]=a[i][h];a[i][h]=t}}
s=w=>{a=[...w=[...w]].map(_=>w.map(_=>' '));a[w.length>>1]=w;setInterval(r,1000,a)}
s("windmills")

<pre id=w>


答:
MATL, <s>35</s> <s>33</s> 21 bytes

```<code>jtn2/kYaG1$Xd`wtD3X!T
</code>```

The following will animate the windmill (26 bytes)

```<code>jtn2/kYaG1$Xd`wtXxDlY.3X!T
</code>```

Online Demo

In this version , the Xx specifies to clear the display and the 1Y. is a 1-second pause.

Explanation

The basic idea is that we want to create two versions of the input. An "orthogonal" version

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

And a "diagonal" version

```<code>+-----+
|a    |
| b   |
|  c  |
|   d |
|    e|
+-----+
</code>```

We push these two versions onto the stack. Each time through the loop, we switch the order of stack and rotate the top one clockwise.

```<code>j       % Grab the input as a string
t       % Duplicate the input

%--- Create the "orthogonal" version ---%

n2/     % Determine numel(input) / 2
k       % Round down to nearest integer
Ya      % Pad the input string with floor(numel(input)/2) rows above and below

%--- Create the "diagonal" version ---%

G       % Grab the input again
1$Xd    % Place the input along the diagonal of a matrix

`       % do...while loop
  w     % Flip the order of the first two elements on the stack
  t     % Duplicate the top of the stack

  %--- OCTAVE ONLY (converts NULL to space chars) ---%

  O       % Create a scalar zero
  32      % Number literal (ASCII code for ' ')
  XE      % Replaces 0 elements in our 3D array with 32 (' ')

  %--- END OCTAVE ONLY ---%

  D     % Display the element
  3X!   % Rotate this element 90 degrees counter-clockwise 3 times (clockwise)
  T     % Explicit TRUE to create an infinite loop
        % Implicit end of while loop

</code>```

ContentLicense: CC BY-SA 3.0

Title: Turn a string into a windmill

Body:
The code on this site is rapidly being depleted. We need to invest in renewable strings. So you must write a program that takes a string and converts it into a windmill.

The Challenge

Let's take a simple wind-mill string as an example. Take the string abc. The pivot is the center character, in this case b. Since the string is 3 chars long, every output will be exactly three lines tall and three characters wide. Here is your output on step 1. (Note the whitespace)

```

abc

```

To get the next step, rotate each character around the pivot clockwise. Here is step 2:

```
a
 b
  c
```

Here are steps 3-8:

```
 a
 b
 c
```
```
  a
 b
c
```
```

cba

```
```
c
 b
  a
```
```
 c
 b
 a
```
```
  c
 b
a
```

And on the ninth step, it comes around full circle to the original string:

```

abc

```

Note that the b stayed in the same spot the whole time. This is because b is the pivot character. You must write a program or function that takes a string as input and repeatedly prints out this sequence until the program is closed.

Clarifications

All input strings will have an odd number of characters. (So that every windmill will have a pivot)

To keep the challenge simple, all strings will only contain upper and lowercase alphabet characters.

The output must be len(input_string) characters wide and tall.

It doesn't matter which step of the sequence you start on, just as long as you continue rotating and looping forever.

More Test IO:

Since the post is already pretty long, here is a link to  the output for "windmill":

Sidenote:

Since this is supposed to be a windmill, it would be awesome if you include some boilerplate code to animate it with a small time delay or a user input between each step. However, since some languages don't have time builtins, this is not mandatory. The competing part of your submission can just print the sequence as fast as possible.

Body:
MATL, <s>35</s> <s>33</s> 21 bytes

jtn2/kYaG1$Xd`wtD3X!T

The following will animate the windmill (26 bytes)

jtn2/kYaG1$Xd`wtXxDlY.3X!T

Online Demo

In this version , the Xx specifies to clear the display and the 1Y. is a 1-second pause.

Explanation

The basic idea is that we want to create two versions of the input. An "orthogonal" version

+-----+
|     |
|     |
|abcde|
|     |
|     |
+-----+

And a "diagonal" version

+-----+
|a    |
| b   |
|  c  |
|   d |
|    e|
+-----+

We push these two versions onto the stack. Each time through the loop, we switch the order of stack and rotate the top one clockwise.

j       % Grab the input as a string
t       % Duplicate the input

%--- Create the "orthogonal" version ---%

n2/     % Determine numel(input) / 2
k       % Round down to nearest integer
Ya      % Pad the input string with floor(numel(input)/2) rows above and below

%--- Create the "diagonal" version ---%

G       % Grab the input again
1$Xd    % Place the input along the diagonal of a matrix

`       % do...while loop
  w     % Flip the order of the first two elements on the stack
  t     % Duplicate the top of the stack

  %--- OCTAVE ONLY (converts NULL to space chars) ---%

  O       % Create a scalar zero
  32      % Number literal (ASCII code for ' ')
  XE      % Replaces 0 elements in our 3D array with 32 (' ')

  %--- END OCTAVE ONLY ---%

  D     % Display the element
  3X!   % Rotate this element 90 degrees counter-clockwise 3 times (clockwise)
  T     % Explicit TRUE to create an infinite loop
        % Implicit end of while loop


问:
"Hello, World!"
So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most interesting code golf in the common languages, finding the shortest solution in certain esolangs can be a serious challenge. For instance, to my knowledge it is not known whether the shortest possible Brainfuck solution has been found yet.

Furthermore, while all of <s>Wikipedia</s> (the Wikipedia entry has been deleted but there is a copy at archive.org
), esolangs and Rosetta Code have lists of "Hello, World!" programs, none of these are interested in having the shortest for each language (there is also this GitHub repository). If we want to be a significant site in the code golf community, I think we should try and create the ultimate catalogue of shortest "Hello, World!" programs (similar to how our basic quine challenge contains some of the shortest known quines in various languages). So let's do this!

The Rules

Each submission must be a full program.

The program must take no input, and print Hello, World! to STDOUT (this exact byte stream, including capitalization and punctuation) plus an optional trailing newline, and nothing else.

The program must not write anything to STDERR.

If anyone wants to abuse this by creating a language where the empty program prints Hello, World!, then congrats, they just paved the way for a very boring answer.

Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language.

Submissions are scored in bytes, in an appropriate (pre-existing) encoding, usually (but not necessarily) UTF-8. Some languages, like Folders, are a bit tricky to score - if in doubt, please ask on Meta.

This is not about finding the language with the shortest "Hello, World!" program. This is about finding the shortest "Hello, World!" program in every language. Therefore, I will not mark any answer as "accepted".

If your language of choice is a trivial variant of another (potentially more popular) language which already has an answer (think BASIC or SQL dialects, Unix shells or trivial Brainfuck-derivatives like Alphuck), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

As a side note, please don't downvote boring (but valid) answers in languages where there is not much to golf - these are still useful to this question as it tries to compile a catalogue as complete as possible. However, do primarily upvote answers in languages where the authors actually had to put effort into golfing the code.

For inspiration, check the Hello World Collection.

The Catalogue

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

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

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

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

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

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

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

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

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

/* Configuration */

var QUESTION_ID = 55422; // 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 = 8478; // 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,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\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,
      });
    else console.log(body);
  });

  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;
    lang = jQuery(''+lang+'').text();

    languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;
    if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) 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;
  display: block !important;
}

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

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

table thead {
  font-weight: bold;
}

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

<link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/all.css?v=ffb5d0584c5f">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
BTClang, 53 bytes

My newest invention! BTClang is short for Bitcoin language. Although it has nothing to do with bitcoins, it shares some similiarities with this language. Code:

```<code>4|$&2h
2|A%
3|Im!
3|%([F
2|!4P
2|"Cv
3|zJO
1|!M
2|!&r
</code>```

Explanation:

First of all, each line of the code consists of a number, a pipe and a key. The process goes as following for the example 2|5C. We take the key (5C), and generate the SHA256-hash of it. We get this:

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

The number before the pipe says how many hexadecimal number we want to extract from the end of the hash. This number is 2, so we take two 2-digit hexadecimal numbers from the end of the hash.

We are left with ae and b0. Converting these to integers will result into 174 and 176. These will be processed with the formula n % 94 + 32, so when this is converted to a character, the character will always be a printable ASCII character with 31 < ord < 128. The hashtags are replaced with newlines.

```<code>174 % 94 + 32 = 112 (p)
176 % 94 + 32 = 114 (r)
</code>```

And so on...

The final translation of the code is print("Hello, World!"), which is then evaluated as normal Python. Although this is a solution, I am pretty sure this can be golfed further. It just takes a lot of computational power...

(By the way, you can try to find sets of characters yourself with the BTClang_miner)

ContentLicense: CC BY-SA 4.0

Title: "Hello, World!"

Body:
BTClang, 53 bytes

My newest invention! BTClang is short for Bitcoin language. Although it has nothing to do with bitcoins, it shares some similiarities with this language. Code:

4|$&2h
2|A%
3|Im!
3|%([F
2|!4P
2|"Cv
3|zJO
1|!M
2|!&r

Explanation:

First of all, each line of the code consists of a number, a pipe and a key. The process goes as following for the example 2|5C. We take the key (5C), and generate the SHA256-hash of it. We get this:

ad5d3cc03d8b60e308b22e27fe4bbccae6a83d5496bc5e2a36aeb76eae51aeb0

The number before the pipe says how many hexadecimal number we want to extract from the end of the hash. This number is 2, so we take two 2-digit hexadecimal numbers from the end of the hash.

We are left with ae and b0. Converting these to integers will result into 174 and 176. These will be processed with the formula n % 94 + 32, so when this is converted to a character, the character will always be a printable ASCII character with 31 < ord < 128. The hashtags are replaced with newlines.

174 % 94 + 32 = 112 (p)
176 % 94 + 32 = 114 (r)

And so on...

The final translation of the code is print("Hello, World!"), which is then evaluated as normal Python. Although this is a solution, I am pretty sure this can be golfed further. It just takes a lot of computational power...

(By the way, you can try to find sets of characters yourself with the BTClang_miner)


问:
Is this number a prime?
Believe it or not, we do not yet have a code golf challenge for a simple primality test. While it may not be the most interesting challenge, particularly for "usual" languages, it can be nontrivial in many languages.

Rosetta code features lists by language of idiomatic approaches to primality testing, one using the Miller-Rabin test specifically and another using trial division. However, "most idiomatic" often does not coincide with "shortest." In an effort to make Programming Puzzles and Code Golf the go-to site for code golf, this challenge seeks to compile a catalog of the shortest approach in every language, similar to "Hello, World!" and Golf you a quine for great good!.

Furthermore, the capability of implementing a primality test is part of our definition of programming language, so this challenge will also serve as a directory of proven programming languages.

Task

Write a full program that, given a strictly positive integer n as input, determines whether n is prime and prints a truthy or falsy value accordingly.

For the purpose of this challenge, an integer is prime if it has exactly two strictly positive divisors. Note that this excludes 1, who is its only strictly positive divisor.

Your algorithm must be deterministic (i.e., produce the correct output with probability 1) and should, in theory, work for arbitrarily large integers. In practice, you may assume that the input can be stored in your data type, as long as the program works for integers from 1 to 255.

Input

If your language is able to read from STDIN, accept command-line arguments or any other alternative form of user input, you can read the integer as its decimal representation, unary representation (using a character of your choice), byte array (big or little endian) or single byte (if this is your languages largest data type).

If (and only if) your language is unable to accept any kind of user input, you may hardcode the input in your program.

In this case, the hardcoded integer must be easily exchangeable. In particular, it may appear only in a single place in the entire program.

For scoring purposes, submit the program that corresponds to the input 1.

Output

Output has to be written to STDOUT or closest alternative.

If possible, output should consist solely of a truthy or falsy value (or a string representation thereof), optionally followed by a single newline.

The only exception to this rule is constant output of your language's interpreter that cannot be suppressed, such as a greeting, ANSI color codes or indentation.

Additional rules

This is not about finding the language with the shortest approach for prime testing, this is about finding the shortest approach in every language. Therefore, no answer will be marked as accepted.

Submissions in most languages will be scored in bytes in an appropriate preexisting encoding, usually (but not necessarily) UTF-8.

The language Piet, for example, will be scored in codels, which is the natural choice for this language.

Some languages, like Folders, are a bit tricky to score. If in doubt, please ask on Meta.

Unlike our usual rules, feel free to use a language (or language version) even if it's newer than this challenge. If anyone wants to abuse this by creating a language where the empty program performs a primality test, then congrats for paving the way for a very boring answer.

Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language.

If your language of choice is a trivial variant of another (potentially more popular) language which already has an answer (think BASIC or SQL dialects, Unix shells or trivial Brainfuck derivatives like Headsecks or Unary), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

Built-in functions for testing primality are allowed. This challenge is meant to catalog the shortest possible solution in each language, so if it's shorter to use a built-in in your language, go for it.

Unless they have been overruled earlier, all standard code-golf rules apply, including the http://meta.codegolf.stackexchange.com/q/1061.

As a side note, please don't downvote boring (but valid) answers in languages where there is not much to golf; these are still useful to this question as it tries to compile a catalog as complete as possible. However, do primarily upvote answers in languages where the author actually had to put effort into golfing the code.

Catalog

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
Pylongolf2, 4 bytes

```<code>cnz~
</code>```

Explanations:

```<code>cnz~
c    read input
 n   convert to integer
  z  primality test (beta8+)
   ~ print it.
</code>```

Title: Is this number a prime?

Body:
Pylongolf2, 4 bytes

cnz~

Explanations:

cnz~
c    read input
 n   convert to integer
  z  primality test (beta8+)
   ~ print it.


问:
Dennis, Doorknob, Martin Büttner, Chris Jester-Young - Pizzeria!
Programming Puzzles & Code Golf is about to get a new moderator, Dennis! This challenge is a tribute to him and our other active (or recently active) moderators: Doorknob, Martin Büttner, and Chris Jester-Young. The challenge title is meant to be read to the tune of the Pepto Bismol song.

Basically, we're going to treat them all to pizza at The Nineteenth Bite Pizzeria, but we need to make sure they share it fairly because some of the mods are known to be pizza addicts!

The pizzas sold by the pizzeria are all rectangular blocks of text. The width and length of a pizza may be any non-negative integers as long as their product is divisible by four. Each grid space in the block of text pizza represents a slice, so it's always possible to split the slices up into four equal groups.

The mods will collectively order a single pizza, providing its width and length parameters to their server in any reasonable format such as [width],[length]. Just before the pizza arrives at their table, you need to label each slice with the initial of the mod who gets to eat it to ensure they all share fairly. Everyone should get the same number of slices.

E is for Dennis

D is for Doorknob

M is for Martin

C is for Chris

The mods are a little persnickety, however, and require that their respective sets of slices be path-connected, that is, that all their slices can be reached from one another by moving up, down, left, and right, not crossing anyone else's slices (and not moving diagonal). The don't care how you do this as long as it is done.

Once you've accurately labeled each slice, deliver the pizza to the mods with an optional trailing newline.

Your labeler may be a program or a function and can print or return the labeled pizza. The shortest labeler in bites wins.

Examples

Example 1

Order: 4,1

Some Possible Labeled Pizzas:

```<code>EDMC</code>```
```<code>MEDC</code>```
```<code>CDEM</code>```

Example 2

Order: 4,4

Some Possible Labeled Pizzas:

```<code>MMMM
CCCC
DDDD
EEEE</code>```
```<code>DEMC
DEMC
DEMC
DEMC</code>```
```<code>CCCC
DEEM
DEEM
DDMM</code>```

Example 3

Order: 8,3

Some Possible Labeled Pizzas:

```<code>MMMMMMCC
DDDDCCCC
DDEEEEEE</code>```
```<code>DDDCMMMM
DCDCMEEE
DCCCMEEE</code>```

Example 4

Order: 20,5

A Possible Labeled Pizza:

```<code>DDDDDDDDDDDDMCCCCCCCCCCC
DEEEEEEEEEEDMMMMMMMCCCCC
DEEEEEEEEEEDMMMCCCCCCCCC
DEEEEEEEEEEDMMMMMMMMCCCC
DDDDDDDDDDDDMMMMMMMMMMMC</code>```

(The D's here are not simply-connected but that's ok.)

答:
Retina, 83 bytes

The features used in this answer are newer than this challenge (not that it matters...). Byte count assumes ISO 8859-1 encoding.

```<code>\d+
$*#
#(?=.*¶(.+))
$1
\G####
CDEM
S_`((.)+?(?=.*¶(?<-2>#)+$))|\D
O`.
T`DE`ED
O%`.
</code>```

Try it online!

This implements aditsu's solution which is now somewhat feasible thanks to the new sort stages.

Body:
Retina, 83 bytes

The features used in this answer are newer than this challenge (not that it matters...). Byte count assumes ISO 8859-1 encoding.

\d+
$*#
#(?=.*¶(.+))
$1
\G####
CDEM
S_`((.)+?(?=.*¶(?<-2>#)+$))|\D
O`.
T`DE`ED
O%`.

Try it online!

This implements aditsu's solution which is now somewhat feasible thanks to the new sort stages.


问:
Say "Hello" to the world in ASCII art
Challenge: Produce the following output using as few chars as possible:

```<code> _   _      _ _                             _     _ _
| | | | ___| | | ___    __      _____  _ __| | __| | |
| |_| |/ _ \ | |/ _ \   \ \ /\ / / _ \| '__| |/ _` | |
|  _  |  __/ | | (_) |   \ V  V / (_) | |  | | (_| |_|
|_| |_|\___|_|_|\___( )   \_/\_/ \___/|_|  |_|\__,_(_)
                    |/
</code>```

Rules and restrictions:

You may not use FIGLet or any similar tools.  (Otherwise, figlet Hello, world! would be a trivial and pretty much unbeatable solution.)

Your program must consist entirely of printable ASCII characters — specifically, code points 9 (TAB), 10 (LF) and 32 – 126.  (If your language / OS requires CRLF line breaks, you may use those instead of plain LFs.)  Yes, this regrettably disqualifies any language that requires non-ASCII characters (or non-textual data) as part of its syntax.

The output must look exactly like the example above.  You may, however, include extra whitespace around the output if you want.  You may assume 8-character tab spacing (or your chosen platform's native default setting, if it has a consistent one).

Ps. To set the par, I came up with a 199-char Perl solution.  I won't post it yet, though, in case someone comes up with it independently.  (Also, it's kind of cheesy.)  Of course, this shouldn't discourage you from posting your own solution, even if it's longer.

Update: Now that han has beaten it by one char, here's my cheesy 199-char Perl solution:

```<code>use Compress'Zlib;say uncompress unpack u,'M>-I]BT$*`S$,`^]YQ=R:0,&_Z<DP?8@?WVQJ]E2J"%E$$@)R(/(/MCJ*\U!OM`Z#=5`4Y>6M=L\L%DMP&DB0V.4GQL&OOGB$4:%`4TT4!R8O-Z(^BTZWNV?>F86K:9+""-35*-LNC:T^D:_$#%^`";"DD0'
</code>```

It's very similar to D C's solution (and all the other zlib/gzip-based solutions in various languages), except that I used uuencoding instead of base64 for the compressed text and a few other minor golfing tricks.

Update 2: I think it's time to officially accept a winner.  The first place goes to konsolenfreddy's PHP code, since, however you count the chars, it is the shortest submitted so far.  In fact, combining it with the optimized DEFLATE stream from my 199-char Perl code yields an even shorter 176-char solution:

```<code><?=gzinflate(base64_decode("fYtBCgMxDAPvecXcmkDBv+nJMH2IH99savZUqghZRBICciDyD7Y6ivNQbwOg3VQFOXlrXbPLBZLcBpIkNjlJ8bBr754hFGhQFNNFAcmLzeiPotOt7tn3plq2mSwgjU1SjbLo2tPpGvxAxfgA"));
</code>```

However, I do think that han deserves a special honorary mention for getting so close without using any pre-written decompression tools.  Congratulations to both of you, and a happy new year to everyone!

Title: Say "Hello" to the world in ASCII art

Body:
Pylongolf2, 300 bytes

" _   _      _ _                             _     _ _
| | | | ___| | | ___    __      _____  _ __| | __| | |
| |_| |/ _ \ | |/ _ \   \ \ /\ / / _ \| '__| |/ _` | |
|  _  |  __/ | | (_) |   \ V  V / (_) | |  | | (_| |_|
|_| |_|\___|_|_|\___( )   \_/\_/ \___/|_|  |_|\__,_(_)
                    |/"~

I couldn't find any classy encoding methods, so I'm probably not competing.


答:
JavaScript (Node.js), 28 bytes

```<code>console.log("Hello, World!")
</code>```

Title: "Hello, World!"

Body:
So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most interesting code golf in the common languages, finding the shortest solution in certain esolangs can be a serious challenge. For instance, to my knowledge it is not known whether the shortest possible Brainfuck solution has been found yet.

Furthermore, while all of <s>Wikipedia</s> (the Wikipedia entry has been deleted but there is a copy at archive.org
), esolangs and Rosetta Code have lists of "Hello, World!" programs, none of these are interested in having the shortest for each language (there is also this GitHub repository). If we want to be a significant site in the code golf community, I think we should try and create the ultimate catalogue of shortest "Hello, World!" programs (similar to how our basic quine challenge contains some of the shortest known quines in various languages). So let's do this!

The Rules

Each submission must be a full program.

The program must take no input, and print Hello, World! to STDOUT (this exact byte stream, including capitalization and punctuation) plus an optional trailing newline, and nothing else.

The program must not write anything to STDERR.

If anyone wants to abuse this by creating a language where the empty program prints Hello, World!, then congrats, they just paved the way for a very boring answer.

Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language.

Submissions are scored in bytes, in an appropriate (pre-existing) encoding, usually (but not necessarily) UTF-8. Some languages, like Folders, are a bit tricky to score - if in doubt, please ask on Meta.

This is not about finding the language with the shortest "Hello, World!" program. This is about finding the shortest "Hello, World!" program in every language. Therefore, I will not mark any answer as "accepted".

If your language of choice is a trivial variant of another (potentially more popular) language which already has an answer (think BASIC or SQL dialects, Unix shells or trivial Brainfuck-derivatives like Alphuck), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

As a side note, please don't downvote boring (but valid) answers in languages where there is not much to golf - these are still useful to this question as it tries to compile a catalogue as complete as possible. However, do primarily upvote answers in languages where the authors actually had to put effort into golfing the code.

For inspiration, check the Hello World Collection.

The Catalogue

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

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

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

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

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

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

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

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

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

/* Configuration */

var QUESTION_ID = 55422; // 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 = 8478; // 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,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\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,
      });
    else console.log(body);
  });

  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;
    lang = jQuery(''+lang+'').text();

    languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;
    if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) 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;
  display: block !important;
}

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

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

table thead {
  font-weight: bold;
}

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

<link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/all.css?v=ffb5d0584c5f">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

Body:
JavaScript (Node.js), 28 bytes

console.log("Hello, World!")


问:
Making an acronym

Objective

Your goal is to make a program that converts an input to its acronym. Your input is guaranteed to have only letters and spaces. The input will have exactly one space between words. You must output the acronym of the input.

Rules

Your code cannot be case-sensitive(e.g. foo and Foo are the same)

Your code must ignore the following words and not put them in the acronym:
and or by of

You cannot assume that the words are all lowercase.

The output must be entirely capitalised, with no separation between characters.

A trailing newline is accepted but not necessary.

If your language has an acronym function builtin, you may not use it.

Examples

(inputs/outputs grouped)

```<code>United States of America
USA

Light Amplification by Stimulation of Emitted Radiation
LASER

united states of america
USA

Jordan Of the World
JTW
</code>```

Scoring

This is a code-golf challenge so the shortest code wins.

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
JavaScript, <s>80</s> <s>72</s> <s>55</s> 53 bytes

Code

<s>

```<code>function a(t){t=t.toUpperCase();t=t.replace(/AND|OR|BY|OF|\B.| |/g,"");return t}
</code>```

</s>
<s>

```<code>function a(t){return t.toUpperCase().replace(/AND|OR|BY|OF|\B.| |/g,"")}
</code>```

</s>
I just read about arrow functions and realized I could shorten this up even more.
<s>

```<code>a=t=>t.toUpperCase().replace(/AND|OR|BY|OF|\B.| |/g,"")
</code>```

</s>
According to this, you don't count the assignment in the length, so -2 bytes.

```<code>t=>t.toUpperCase().replace(/AND|OR|BY|OF|\B.| |/g,"")
</code>```

This is my first golf, so it's not very good.

Title: Making an acronym

Body:
JavaScript, <s>80</s> <s>72</s> <s>55</s> 53 bytes

Code

<s>

function a(t){t=t.toUpperCase();t=t.replace(/AND|OR|BY|OF|\B.| |/g,"");return t}

</s>
<s>

function a(t){return t.toUpperCase().replace(/AND|OR|BY|OF|\B.| |/g,"")}

</s>
I just read about arrow functions and realized I could shorten this up even more.
<s>

a=t=>t.toUpperCase().replace(/AND|OR|BY|OF|\B.| |/g,"")

</s>
According to this, you don't count the assignment in the length, so -2 bytes.

t=>t.toUpperCase().replace(/AND|OR|BY|OF|\B.| |/g,"")

This is my first golf, so it's not very good.


问:
Optimal solution to go to opposite corner of a rectangle
Your job is to write a program that finds the optimal number of moves it takes to get from the lower-left corner of a rectangle to the upper-right corner directly opposite.

Your program will accept input as an ordered pair (width, height). These will be the dimensions of the rectangle you will work with. Your program will create an ASCII-art of the solution (use . for empty square and # for part of the solution, X for starting square) and count the number of moves it takes to reach the endpoint. Diagonal moves are not allowed. If there are multiple solutions, choose one to output.

The shortest program in bytes wins.

Example

Input: (4, 5)

Output:

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

Move count: 7

答:
Scala, 118 bytes

```<code>(w:Int,h:Int)=>{print(Array.fill(h-1,w-1)('.')map(new String(_))mkString("","#\n","#\nX"));Seq.fill(w-1)(print("#"))}

(w:Int,h:Int)=>{...}           //define a function with 2 Ints as parameters
print(                        //print ...
  Array.fill(h-1,w-1)('.')    //an array of arrays with dimensions (h-1,w-1)
                              //and fill it with a dot
  map(new String(_))          //map each inner array of chars to a string
  mkString("","#\n","#\nX")   //create a string from the array, with
                              //an empty string before the array,
                              //"#\n" as a seperator between the elements
                              //and "#\nX" at the end
);
Seq.fill(w-1)(print("#"))     //w-1 times print "#"
</code>```

Body:
Scala, 118 bytes

(w:Int,h:Int)=>{print(Array.fill(h-1,w-1)('.')map(new String(_))mkString("","#\n","#\nX"));Seq.fill(w-1)(print("#"))}

(w:Int,h:Int)=>{...}           //define a function with 2 Ints as parameters
print(                        //print ...
  Array.fill(h-1,w-1)('.')    //an array of arrays with dimensions (h-1,w-1)
                              //and fill it with a dot
  map(new String(_))          //map each inner array of chars to a string
  mkString("","#\n","#\nX")   //create a string from the array, with
                              //an empty string before the array,
                              //"#\n" as a seperator between the elements
                              //and "#\nX" at the end
);
Seq.fill(w-1)(print("#"))     //w-1 times print "#"


问:
Tweetable hash function challenge
In this code-challenge you will write a hash function in 140 bytes1 or less of source code. The hash function must take an ASCII string as input, and return a 24-bit unsigned integer ([0, 224-1]) as output.

Your hash function will be evaluated for every word in this large British English dictionary2. Your score is the amount of words that share a hash value with another word (a collision).

The lowest score wins, ties broken by first poster.

Test case

Before submitting, please test your scoring script on the following input:

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

If it gives any score other than 4, it is buggy.

Clarifying rules:

Your hash function must run on a single string, not a whole array. Also, your hash function may not do any other I/O than the input string and output integer.

Built-in hash functions or similar functionality (e.g. encryption to scramble bytes) is disallowed.

Your hash function must be deterministic.

Contrary to most other contests optimizing specifically for the scoring input is allowed.

1 I am aware Twitter limits characters instead of bytes, but for simplicity we will use bytes as a limit for this challenge.

2 Modified from Debian's wbritish-huge, removing any non-ASCII words.

答:
C++: 7112 6694 6483 6479 6412 6339 collisions, 90 bytes

I implemented a naïve genetic algorithm for my coefficient array. I'll update this code as it finds better ones. :)

```<code>int h(const char*s){uint32_t t=0,p=0;while(*s)t="cJ~Z]q"[p++%6]*t+*s++;return t%16777213;}
</code>```

Test function:

```<code>int main(void)
{
    std::map<int, int> shared;

    std::string s;
    while (std::cin >> s) {
        shared[h(s.c_str())]++;
    }

    int count = 0;
    for (auto c : shared) {
        if ((c.first & 0xFFFFFF) != c.first) { std::cerr << "invalid hash: " << c.first << std::endl; }
        if (c.second > 1) { count += c.second; }
    }

    std::cout << count << std::endl;
    return 0;
}
</code>```

Title: Tweetable hash function challenge

Body:
C++: 7112 6694 6483 6479 6412 6339 collisions, 90 bytes

I implemented a naïve genetic algorithm for my coefficient array. I'll update this code as it finds better ones. :)

int h(const char*s){uint32_t t=0,p=0;while(*s)t="cJ~Z]q"[p++%6]*t+*s++;return t%16777213;}

Test function:

int main(void)
{
    std::map<int, int> shared;

    std::string s;
    while (std::cin >> s) {
        shared[h(s.c_str())]++;
    }

    int count = 0;
    for (auto c : shared) {
        if ((c.first & 0xFFFFFF) != c.first) { std::cerr << "invalid hash: " << c.first << std::endl; }
        if (c.second > 1) { count += c.second; }
    }

    std::cout << count << std::endl;
    return 0;
}


问:
Draw a random hexa-glyph

The above image is called a hexa-glyph.  Hexa-glyphs are some cool patterns I made up while doodling during my DiffEq class.  Here's how you make one:

Consider the following set of points, shaped like a regular hexagram.  The inner hexagon is what will contain the final glyph, while the outer 6 points form a star and are where we will start drawing our lines.

From the outer six points, randomly select a pair.  For efficiency, there should be at least one other point between the two selected points (otherwise, it would have no effect on the final figure).  Then, from each of the two points, cast a ray towards the other.  This ray is blocked by previous lines.

Repeat this process until all 9 edges have been formed, as shown in the next few images.

Here is an example of rays being blocked.  The ends of the ray segment are still visible, but the middle portion is occluded by the first two segments we drew.

These two rays are also "blocked," but this doesn't cause any visible difference because they are blocked by the same other line.

Fast-forwarding until all 9 lines are drawn.  If you want a more detailed explanation of these skipped steps, I can expound.

Finally, remove the points of the star.  To make it look prettier, the thick dots are also removed.

The challenge

You challenge is to output a visual representation of a random hexa-glyph.  This is code-golf, fewest bytes wins.

All possible hexa-glyphs should appear with some positive probability. Different hexa-glyphs are generated by changing the order in which the 9 edges are drawn.

Furthermore, all images output by your program must be valid hexa-glyphs. Certain patterns (like a complete outline of the inner hexagon) cannot possibly appear as a hexa-glyph, and so you program mustn't output these.

The output should be a graphical image (printed to screen or file).

The hexagon must be regular, but can appear in any orientation.

Reflections / rotations are not considered unique.  (This might make requirement 1 easier to follow).

答:
Mathematica, <s>273</s> <s>268</s> <s>264</s> 242 bytes

```<code>c=CirclePoints;b@_=k=1>0;Graphics[Line/@Cases[Append[Join@@({c@6,{3^.5/2,-Pi/6}~c~6}),{0,0}][[b@#=!k;#]]&/@TakeWhile[#,t=k;(r=t;t=b@#;r)&]&/@Join@@RandomSample[{#,Reverse@#}&/@Partition[Range@12,3,2,1]~Join~Array[{2#,13,2#+6}&,3]],{_,__}]]
</code>```

The  renders as a superscript T in Mathematica and is a postfix transpose operator.

Sorting out the bugs in this took forever... towards the end I hacked a few things together to make it work, so this is definitely suboptimal. I also wonder whether it might be better overall to implement the spec more literally via the lines across the outer hexagon and let Mathematica's geometry functions handle the intersections.

Note that this is a full program and if you want to run the code multiple times within a single REPL session you'll have to prefix it with Clear[b].

Here are the results of 20 runs:

Explanation

This solution doesn't make use of the outer star points at all. Instead it works directly with the points that are part of the hexaglyph and lines that cover three of them at a time.

Let's label the points:

1 starts on a slightly weird corner but this is due to the (also somewhat weird) default behaviour of CirclePoints. Starting the hexagon from there turned out cheapest.

Now we want to find the relevant lines through three of those points which correspond to connected points of the outer star. The ones around the hexagon are of course just 3 adjacent points (modulo 12), starting from an odd number. The ones across the centre consist of an even number n, 13 and n+6.

Representations of these lines (in the form of lists of three points are generated by the following code):

```<code>Partition[Range@12,3,2,1]~Join~Array[{2#,13,2#+6}&,3]
</code>```

The Partition generates the lines around the hexagon and the Array the lines through the centre. To process both beams, we map this function over the list of lines:

```<code>{#,Reverse@#}&
</code>```

Now we shuffle these with RandomSample to process them in a random order. Join @@ flattens the list of pairs so that we have a list of beams.

Short intermission: to keep track of which points are already blocked we use a lookup function b, which is initialised to True for all values by b@_=k=1>0;. When processing a beam we keep all points until the first point that has b[n] == False (including that one):

```<code>TakeWhile[#,t=k;(r=t;t=b@#;r)&]&
</code>```

I feel like this is the most golfable part right now... the use of two temporary variables to play Mastermind seems really expensive. Anyway, the result of this gives us the points in a line we're allowed to draw. Now this function is mapped over each of those points:

```<code>Append[Join@@({c@6,{3^.5/2,-Pi/6}~c~6}),{0,0}][[b@#=!k;#]]&
</code>```

The first part generates the list of all 13 points using the interleaved results of two calls to CirclePoints (with different radii for the edge centres and the corners of the hexagon). Note the b@#=!k which now sets the lookup table's value for the current point to False so that no further beam can pass through it. Finally, the value is used as an index into the list of coordinates to get the correct 2D point.

```<code>Cases[...,{_,__}]
</code>```

This discards all single-element lists, because they would render as individual (and visible) points. Finally we render the result:

```<code>Graphics[Line/@...]
</code>```

Title: Draw a random hexa-glyph

Body:
Mathematica, <s>273</s> <s>268</s> <s>264</s> 242 bytes

c=CirclePoints;b@_=k=1>0;Graphics[Line/@Cases[Append[Join@@({c@6,{3^.5/2,-Pi/6}~c~6}),{0,0}][[b@#=!k;#]]&/@TakeWhile[#,t=k;(r=t;t=b@#;r)&]&/@Join@@RandomSample[{#,Reverse@#}&/@Partition[Range@12,3,2,1]~Join~Array[{2#,13,2#+6}&,3]],{_,__}]]

The  renders as a superscript T in Mathematica and is a postfix transpose operator.

Sorting out the bugs in this took forever... towards the end I hacked a few things together to make it work, so this is definitely suboptimal. I also wonder whether it might be better overall to implement the spec more literally via the lines across the outer hexagon and let Mathematica's geometry functions handle the intersections.

Note that this is a full program and if you want to run the code multiple times within a single REPL session you'll have to prefix it with Clear[b].

Here are the results of 20 runs:

Explanation

This solution doesn't make use of the outer star points at all. Instead it works directly with the points that are part of the hexaglyph and lines that cover three of them at a time.

Let's label the points:

1 starts on a slightly weird corner but this is due to the (also somewhat weird) default behaviour of CirclePoints. Starting the hexagon from there turned out cheapest.

Now we want to find the relevant lines through three of those points which correspond to connected points of the outer star. The ones around the hexagon are of course just 3 adjacent points (modulo 12), starting from an odd number. The ones across the centre consist of an even number n, 13 and n+6.

Representations of these lines (in the form of lists of three points are generated by the following code):

Partition[Range@12,3,2,1]~Join~Array[{2#,13,2#+6}&,3]

The Partition generates the lines around the hexagon and the Array the lines through the centre. To process both beams, we map this function over the list of lines:

{#,Reverse@#}&

Now we shuffle these with RandomSample to process them in a random order. Join @@ flattens the list of pairs so that we have a list of beams.

Short intermission: to keep track of which points are already blocked we use a lookup function b, which is initialised to True for all values by b@_=k=1>0;. When processing a beam we keep all points until the first point that has b[n] == False (including that one):

TakeWhile[#,t=k;(r=t;t=b@#;r)&]&

I feel like this is the most golfable part right now... the use of two temporary variables to play Mastermind seems really expensive. Anyway, the result of this gives us the points in a line we're allowed to draw. Now this function is mapped over each of those points:

Append[Join@@({c@6,{3^.5/2,-Pi/6}~c~6}),{0,0}][[b@#=!k;#]]&

The first part generates the list of all 13 points using the interleaved results of two calls to CirclePoints (with different radii for the edge centres and the corners of the hexagon). Note the b@#=!k which now sets the lookup table's value for the current point to False so that no further beam can pass through it. Finally, the value is used as an index into the list of coordinates to get the correct 2D point.

Cases[...,{_,__}]

This discards all single-element lists, because they would render as individual (and visible) points. Finally we render the result:

Graphics[Line/@...]


问:
Ravenity of Cube Distance Numbers
Inspired by this Numberphile entry

Background

The cube distance numbers of an integer n are defined here as the set of integers that are x³ distance away for a given x. For a simple example, with n=100 and x=2, the cube distance numbers are {92,108}.

This can be extended into a larger set simply by varying x. With x ∈ {1,2,3,4} and the same n=100, we have the resultant set {36,73,92,99,101,108,127,164}.

Let's define CD(n,x) as the set of all integers n ± z³ with z ∈ {1,2,3,...,x}.

Now we can focus on some of the special properties of these cube distance numbers. Of the many special properties that numbers can have, the two properties we're interested in here are primality and prime divisors.

For the above example CD(100,4), note that 73, 101, 127 are all prime. If we remove those from the set, we're left with {36,92,99,108,164}. All prime divisors of these numbers are (in order) {2,2,3,3,2,2,23,3,3,11,2,2,3,3,3,2,2,41}, which means we have 5 distinct prime divisors {2,3,23,11,41}. We can therefore define that CD(100,4) has ravenity1 of 5.

The challenge here is to write a function or program, in the fewest bytes, that outputs the ravenity of a given input.

Input

Two positive integers, n and x, in any convenient format.

Output

A single integer describing the ravenity of the two input numbers, when calculated with CD(n,x).

Rules

Input/output can be via any suitable method.

Standard loophole restrictions apply.

For ease of calculation, you can assume that the input data will be such that CD(n,x) will only have positive numbers in the set (i.e., no CD(n,x) will ever have negative numbers or zero).

The function or program should be able to handle input numbers so that n + x³ fits in your language's native integer data type. For example, for a 32-bit signed integer type, all input numbers with n + x³ < 2147483648 are possible.

Examples

```<code>n,x   - output
2,1   - 0   (since CD(2,1)={1,3}, distinct prime divisors={}, ravenity=0)
5,1   - 2
100,4 - 5
720,6 - 11
</code>```

Footnotes

1 - So named because we're not interested in the cardinality of the set, but a different type of bird. Since we're dealing with "common" divisors, I chose to use the common raven.

答:
Python 3.5 - <s>177</s> <s>175</s> 159 bytes

Any golfing tips welcome :)

```<code>a=range
p=lambda n:any(n%x<1for x in a(2,n))
r=lambda n,x:len(set(sum([[x for x in a(2,z+1)if z%x<1&1>p(x)]for z in filter(p,[n+z**3for z in a(-x,x+1)])],[])))
</code>```

Ungolfed:

```<code>def is_composite(n):
    return any(n % x == 0 for x in range(2, n))

def prime_factors(n):
    return {x for x in range(2, n+1) if n % x == 0 and not is_composite(x)}

def ravenity(n, x):
    nums = [n + z**3 for z in range(-x, x+1)]
    nums = filter(is_composite, nums)
    factors = map(prime_factors, nums)
    factors = sum(factors, [])
    #remove duplicates
    factors = set(factors)
    return len(factors)
</code>```

Title: Ravenity of Cube Distance Numbers

Body:
Python 3.5 - <s>177</s> <s>175</s> 159 bytes

Any golfing tips welcome :)

a=range
p=lambda n:any(n%x<1for x in a(2,n))
r=lambda n,x:len(set(sum([[x for x in a(2,z+1)if z%x<1&1>p(x)]for z in filter(p,[n+z**3for z in a(-x,x+1)])],[])))

Ungolfed:

def is_composite(n):
    return any(n % x == 0 for x in range(2, n))

def prime_factors(n):
    return {x for x in range(2, n+1) if n % x == 0 and not is_composite(x)}

def ravenity(n, x):
    nums = [n + z**3 for z in range(-x, x+1)]
    nums = filter(is_composite, nums)
    factors = map(prime_factors, nums)
    factors = sum(factors, [])
    #remove duplicates
    factors = set(factors)
    return len(factors)


Title: Tweetable hash function challenge

Body:
In this code-challenge you will write a hash function in 140 bytes1 or less of source code. The hash function must take an ASCII string as input, and return a 24-bit unsigned integer ([0, 224-1]) as output.

Your hash function will be evaluated for every word in this large British English dictionary2. Your score is the amount of words that share a hash value with another word (a collision).

The lowest score wins, ties broken by first poster.

Test case

Before submitting, please test your scoring script on the following input:

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

If it gives any score other than 4, it is buggy.

Clarifying rules:

Your hash function must run on a single string, not a whole array. Also, your hash function may not do any other I/O than the input string and output integer.

Built-in hash functions or similar functionality (e.g. encryption to scramble bytes) is disallowed.

Your hash function must be deterministic.

Contrary to most other contests optimizing specifically for the scoring input is allowed.

1 I am aware Twitter limits characters instead of bytes, but for simplicity we will use bytes as a limit for this challenge.

2 Modified from Debian's wbritish-huge, removing any non-ASCII words.

Body:
CJam, <s>4125</s> <s>3937</s> <s>3791</s> 3677

0000000: 7b 5f 39 62 31 31 30 25 5f 22 7d 13 25 77  {_9b110%_"}.%w
000000e: 77 5c 22 0c e1 f5 7b 83 45 85 c0 ed 08 10  w\"...{.E.....
000001c: d3 46 0c 5c 22 59 f8 da 7b f8 18 14 8e 4b  .F.\"Y..{....K
000002a: 3a c1 9e 97 f8 f2 5c 18 21 63 13 c8 d3 86  :.....\.!c....
0000038: 45 8e 64 33 61 50 96 c4 48 ea 54 3b b3 ab  E.d3aP..H.T;..
0000046: bc 90 bc 24 21 20 50 30 85 5f 7d 7d 59 2c  ...$! P0._}}Y,
0000054: 4a 67 88 c8 94 29 1a 1a 1a 0f 38 c5 8a 49  Jg...)....8..I
0000062: 9b 54 90 b3 bd 23 c6 ed 26 ad b6 79 89 6f  .T...#..&..y.o
0000070: bd 2f 44 6c f5 3f ae af 62 9b 22 3d 69 40  ./Dl.?..b."=i@
000007e: 62 31 35 32 35 31 39 25 31 31 30 2a 2b 7d  b152519%110*+}

This approach divides domain and codomain into 110 disjoint sets, and defines a slightly different hash function for each pair.

Scoring / Verification

$ echo $LANG
en_US
$ cat gen.cjam
"qN%{_9b110%_"
[125 19 37 119 119 34 12 225 245 123 131 69 133 192 237 8 16 211 70 12 34 89 248 218 123 248 24 20 142 75 58 193 158 151 248 242 92 24 33 99 19 200 211 134 69 142 100 51 97 80 150 196 72 234 84 59 179 171 188 144 188 36 33 32 80 48 133 95 125 125 89 44 74 103 136 200 148 41 26 26 26 15 56 197 138 73 155 84 144 179 189 35 198 237 38 173 182 121 137 111 189 47 68 108 245 63 174 175 98 155]
:c`"=i@b152519%110*+}%N*N"
$ cjam gen.cjam > test.cjam
$ cjam test.cjam < british-english-huge.txt | sort -n > temp
$ head -1 temp
8
$ tail -1 temp
16776899
$ all=$(wc -l < british-english-huge.txt)
$ unique=$(uniq -u < temp | wc -l)
$ echo $[all - unique]
3677

The following port to Python can be used with the official scoring snippet:

h=lambda s,b:len(s)and ord(s[-1])+b*h(s[:-1],b)

def H(s):
 p=h(s,9)%110
 return h(s,ord(
  '}\x13%ww"\x0c\xe1\xf5{\x83E\x85\xc0\xed\x08\x10\xd3F\x0c"Y\xf8\xda{\xf8\x18\x14\x8eK:\xc1\x9e\x97\xf8\xf2\\\x18!c\x13\xc8\xd3\x86E\x8ed3aP\x96\xc4H\xeaT;\xb3\xab\xbc\x90\xbc$! P0\x85_}}Y,Jg\x88\xc8\x94)\x1a\x1a\x1a\x0f8\xc5\x8aI\x9bT\x90\xb3\xbd#\xc6\xed&\xad\xb6y\x89o\xbd/Dl\xf5?\xae\xafb\x9b'
  [p]))%152519*110+p


答:
Haskell, 64 bytes

```<code>c!n=c<$[2..n]
w#h=unlines$('.'!w++"#")!h++['X':'#'!w,show$w+h-2]
</code>```

Usage example:

```<code>*Main> putStr $ 4 # 5
...#
...#
...#
...#
X###
7
</code>```

How it works:

```<code>c!n = c <$ [2..n]                       -- helper function: make (n-1) copies of c

                                        -- main function
                     !h                 -- (h-1) times
       ('.'!w ++ "#")                   --    (w-1) dots and a hash sign
                       ++[      ,     ] -- followed by
                          'X' : '#'!w   --    an 'X' and (w-1) hash signs
                            show$w+h-2  --    and the number of steps
unlines                                 -- join everything with newlines in-between
</code>```

Title: Optimal solution to go to opposite corner of a rectangle

Body:
Your job is to write a program that finds the optimal number of moves it takes to get from the lower-left corner of a rectangle to the upper-right corner directly opposite.

Your program will accept input as an ordered pair (width, height). These will be the dimensions of the rectangle you will work with. Your program will create an ASCII-art of the solution (use . for empty square and # for part of the solution, X for starting square) and count the number of moves it takes to reach the endpoint. Diagonal moves are not allowed. If there are multiple solutions, choose one to output.

The shortest program in bytes wins.

Example

Input: (4, 5)

Output:

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

Move count: 7

Body:
Haskell, 64 bytes

c!n=c<$[2..n]
w#h=unlines$('.'!w++"#")!h++['X':'#'!w,show$w+h-2]

Usage example:

*Main> putStr $ 4 # 5
...#
...#
...#
...#
X###
7

How it works:

c!n = c <$ [2..n]                       -- helper function: make (n-1) copies of c

                                        -- main function
                     !h                 -- (h-1) times
       ('.'!w ++ "#")                   --    (w-1) dots and a hash sign
                       ++[      ,     ] -- followed by
                          'X' : '#'!w   --    an 'X' and (w-1) hash signs
                            show$w+h-2  --    and the number of steps
unlines                                 -- join everything with newlines in-between


问:
Shortest code for infinite disk I/O
(Just open 50 tabs in Google Chrome :D (just kidding, no you can't))

Shortest code for infinite disk I/O any language, C# example:

using System.IO;

namespace FileApp {
    static class Program {
        public static void Main() {
            do {
                File.WriteAllText("a", "a");
                File.Delete("a");
            } while (true);
        }
    }
}
```

You can't just fill the entire disk though, as then it would halt in the end and would be finite.

And you can't do reading only, infinite writing has to happen. (It has to kill my SSD after enough runtime.)

Get cracking! :)

答:
Racket, 46 bytes

```<code>(do()(#f)(write-to-file'a"f"#:exists'replace))
</code>```

Title: Shortest code for infinite disk I/O

Body:
Racket, 46 bytes

(do()(#f)(write-to-file'a"f"#:exists'replace))


问:
Javascript left-pad golf

Introduction

In the wake of the left-pad npm package fallout, let's have a code golf for implementing left-pad.

The left-pad function consists of 2 default arguments and 1 additional argument, in the form string, length, (padchar). If the padchar is not given, this is standardized to a space character. Let's take an example with two arguments:

```<code>left_pad("abc", 6)
</code>```

First, we observe the length of the string, which is 3. After this, we need to pad this string in the left until the length of the full string has reached the length given in the function. In this case 6. Since the padchar is not given, we need to pad this with spaces:

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

This is a string with 3 spaces and the initial string, resulting into a string with length 6. Here is an example with the padchar given:

```<code>left_pad("abc", 6, "-")
</code>```

We just do the same as the example above, but replace the spaces with the padchar. In this case, the hyphen:

```<code>---abc
</code>```

The Task

Given the string, length, and maybe the additional argument padchar, output the left-padded string. You can assume that the length number is equal or greater than the length of the string. The padchar will always consist of 1 character.

Test cases

```<code>left_pad("string", length, ("padchar")) === "left-padded string"

left_pad("foo", 5) === "  foo"
left_pad("foobar", 6) === "foobar"
left_pad("1", 2, "0") === "01"
left_pad("1", 2, "-") === "-1"
</code>```

This is code-golf, so the submission with the smallest number of bytes wins!

答:
Java 8, <s>86</s> 88 bytes

This is a function. The third argument is a varargs to allow the optional pad char (defaults to ' ')

```<code>String p(String s,int l,char...p){return s.length()<l?p((p.length>0?p[0]:' ')+s,l,p):s;}
</code>```

Recursion!
+2 bytes (added brackets because of incompatible type error)

Title: Javascript left-pad golf

Body:
Java 8, <s>86</s> 88 bytes

This is a function. The third argument is a varargs to allow the optional pad char (defaults to ' ')

String p(String s,int l,char...p){return s.length()<l?p((p.length>0?p[0]:' ')+s,l,p):s;}

Recursion!
+2 bytes (added brackets because of incompatible type error)


答:
Python 3, 193 bytes

```
def c(a):e=' ';s=len(a);l=int(s/2);b=range(s);m='\n'*l;print(m,a,m);for x in b:print(e*x,a[x]);for x in b:print(e*l,a[x]);for x in b:print(e*(s-1-x),a[x]); a=input();while True:c(a);c(a[::-1]);
```

Ungolfed

```
def c(a):
    e=' ';s=len(a);l=int(s/2);b=range(s);m='\n'*l;
    print(m,a,m);
    for x in b:print(e*x,a[x]);
    for x in b:print(e*l,a[x]);
    for x in b:print(e*(s-1-x),a[x]);
a=input();
while True:
    c(a);
    c(a[::-1]);
```

Recursive, 177 bytes

(crash after a few seconds)

```
def c(a):e=' ';s=len(a);l=int(s/2);b=range(s);m='\n'*l;print(m,a,m);for x in b:print(e*x,a[x]);for x in b:print(e*l,a[x]);for x in b:print(e*(s-1-x),a[x]);c(a[::-1]);c(input());
```

Ungolfed

```
def c(a):
    e=' ';s=len(a);l=int(s/2);b=range(s);m='\n'*l;
    print(m,a,m);
    for x in b:print(e*x,a[x]);
    for x in b:print(e*l,a[x]);
    for x in b:print(e*(s-1-x),a[x]);
    c(a[::-1])
c(input());
```

Another solution, 268 bytes

```
import itertools as i;def w(a):e=' ';s=len(a);l=int(s/2);t='\n';m=(l-1)*t;h=list(i.chain.from_iterable((e*x+a[x],e*l+a[x],e*(s-1-x)+a[x]) for x in range(s)));print(m,a,m,t.join(h[::3]),t.join(h[1::3]),t.join(h[2::3]),sep=t,end='');a=input();while True:w(a);w(a[::-1]);
```

Ungolfed

```
import itertools as i;
def w(a):
    e=' ';s=len(a);l=int(s/2);t='\n';m=(l-1)*t;
    h=list(i.chain.from_iterable((e*x+a[x],e*l+a[x],e*(s-1-x)+a[x]) for x in range(s)))
    print(m,a,m,t.join(h[::3]),t.join(h[1::3]),t.join(h[2::3]),sep=t,end='');
a=input();
while True:
    w(a);
    w(a[::-1]);
```

Title: Turn a string into a windmill

Body:
The code on this site is rapidly being depleted. We need to invest in renewable strings. So you must write a program that takes a string and converts it into a windmill.

The Challenge

Let's take a simple wind-mill string as an example. Take the string abc. The pivot is the center character, in this case b. Since the string is 3 chars long, every output will be exactly three lines tall and three characters wide. Here is your output on step 1. (Note the whitespace)

```

abc

```

To get the next step, rotate each character around the pivot clockwise. Here is step 2:

```
a
 b
  c
```

Here are steps 3-8:

```
 a
 b
 c
```
```
  a
 b
c
```
```

cba

```
```
c
 b
  a
```
```
 c
 b
 a
```
```
  c
 b
a
```

And on the ninth step, it comes around full circle to the original string:

```

abc

```

Note that the b stayed in the same spot the whole time. This is because b is the pivot character. You must write a program or function that takes a string as input and repeatedly prints out this sequence until the program is closed.

Clarifications

All input strings will have an odd number of characters. (So that every windmill will have a pivot)

To keep the challenge simple, all strings will only contain upper and lowercase alphabet characters.

The output must be len(input_string) characters wide and tall.

It doesn't matter which step of the sequence you start on, just as long as you continue rotating and looping forever.

More Test IO:

Since the post is already pretty long, here is a link to  the output for "windmill":

Sidenote:

Since this is supposed to be a windmill, it would be awesome if you include some boilerplate code to animate it with a small time delay or a user input between each step. However, since some languages don't have time builtins, this is not mandatory. The competing part of your submission can just print the sequence as fast as possible.

Body:
Python 3, 193 bytes

def c(a):e=' ';s=len(a);l=int(s/2);b=range(s);m='\n'*l;print(m,a,m);for x in b:print(e*x,a[x]);for x in b:print(e*l,a[x]);for x in b:print(e*(s-1-x),a[x]); a=input();while True:c(a);c(a[::-1]);

Ungolfed

def c(a):
    e=' ';s=len(a);l=int(s/2);b=range(s);m='\n'*l;
    print(m,a,m);
    for x in b:print(e*x,a[x]);
    for x in b:print(e*l,a[x]);
    for x in b:print(e*(s-1-x),a[x]);
a=input();
while True:
    c(a);
    c(a[::-1]);

Recursive, 177 bytes

(crash after a few seconds)

def c(a):e=' ';s=len(a);l=int(s/2);b=range(s);m='\n'*l;print(m,a,m);for x in b:print(e*x,a[x]);for x in b:print(e*l,a[x]);for x in b:print(e*(s-1-x),a[x]);c(a[::-1]);c(input());

Ungolfed

def c(a):
    e=' ';s=len(a);l=int(s/2);b=range(s);m='\n'*l;
    print(m,a,m);
    for x in b:print(e*x,a[x]);
    for x in b:print(e*l,a[x]);
    for x in b:print(e*(s-1-x),a[x]);
    c(a[::-1])
c(input());

Another solution, 268 bytes

import itertools as i;def w(a):e=' ';s=len(a);l=int(s/2);t='\n';m=(l-1)*t;h=list(i.chain.from_iterable((e*x+a[x],e*l+a[x],e*(s-1-x)+a[x]) for x in range(s)));print(m,a,m,t.join(h[::3]),t.join(h[1::3]),t.join(h[2::3]),sep=t,end='');a=input();while True:w(a);w(a[::-1]);

Ungolfed

import itertools as i;
def w(a):
    e=' ';s=len(a);l=int(s/2);t='\n';m=(l-1)*t;
    h=list(i.chain.from_iterable((e*x+a[x],e*l+a[x],e*(s-1-x)+a[x]) for x in range(s)))
    print(m,a,m,t.join(h[::3]),t.join(h[1::3]),t.join(h[2::3]),sep=t,end='');
a=input();
while True:
    w(a);
    w(a[::-1]);


Body:
Lua, 81 bytes

Try it online!

Golfed:

w,h=(...)print((("."):rep(w-1).."#\n"):rep(h-1).."X"..("#"):rep(w-1))print(w+h-2)

Ungolfed:

w,h=4,5
print((("."):rep(w-1).."#\n"):rep(h-1).."X"..("#"):rep(w-1))
print(w+h-2)


答:
Factor, 73 bytes

```<code>USING: io.files io.encodings
[ 0 "a" utf8 set-file-contents ] [ t ] while
</code>```

Sets the file contents to the nul byte forever.

Title: Shortest code for infinite disk I/O

Body:
(Just open 50 tabs in Google Chrome :D (just kidding, no you can't))

Shortest code for infinite disk I/O any language, C# example:

using System.IO;

namespace FileApp {
    static class Program {
        public static void Main() {
            do {
                File.WriteAllText("a", "a");
                File.Delete("a");
            } while (true);
        }
    }
}
```

You can't just fill the entire disk though, as then it would halt in the end and would be finite.

And you can't do reading only, infinite writing has to happen. (It has to kill my SSD after enough runtime.)

Get cracking! :)

Body:
Factor, 73 bytes

USING: io.files io.encodings
[ 0 "a" utf8 set-file-contents ] [ t ] while

Sets the file contents to the nul byte forever.


答:
Pyth, 48 bytes

```<code>JlzK/J2#*btKz*btKM+*dG@zHVJgNN)VJgKN)VJg-JNN)=_z
</code>```

Try it online! (Note: this is a version that does not forever loop, because it would crash the interpreter.)

Shamelessly translated from the Python 3 solution by @ByHH.

How it works:

```<code>JlzK/J2#*btKz*btKM+*dG@zHVJgNN)VJgKN)VJg-JNN)=_z
                                                 assign('z',input())
Jlz                                              assign("J",Plen(z))
   K/J2                                          assign("K",div(J,2))
       #                                         loop-until-error:
        *btK                                      imp_print(times(b,tail(K)))
            z                                     imp_print(z)
             *btK                                 imp_print(times(b,tail(K)))
                                                  @memoized
                 M                                def gte(G,H):
                  +*dG@zH                          return plus(times(d,G),lookup(z,H))
                         VJ   )                   for N in num_to_range(J):
                           gNN                     imp_print(gte(N,N))
                               VJ   )             for N in num_to_range(J):
                                 gKN               imp_print(gte(K,N))
                                     VJ     )     for N in num_to_range(J):
                                       g-JNN       imp_print(gte(minus(J,N),N))
                                             =_z  assign('z',neg(z))
</code>```

Title: Turn a string into a windmill

Body:
Pyth, 48 bytes

JlzK/J2#*btKz*btKM+*dG@zHVJgNN)VJgKN)VJg-JNN)=_z

Try it online! (Note: this is a version that does not forever loop, because it would crash the interpreter.)

Shamelessly translated from the Python 3 solution by @ByHH.

How it works:

JlzK/J2#*btKz*btKM+*dG@zHVJgNN)VJgKN)VJg-JNN)=_z
                                                 assign('z',input())
Jlz                                              assign("J",Plen(z))
   K/J2                                          assign("K",div(J,2))
       #                                         loop-until-error:
        *btK                                      imp_print(times(b,tail(K)))
            z                                     imp_print(z)
             *btK                                 imp_print(times(b,tail(K)))
                                                  @memoized
                 M                                def gte(G,H):
                  +*dG@zH                          return plus(times(d,G),lookup(z,H))
                         VJ   )                   for N in num_to_range(J):
                           gNN                     imp_print(gte(N,N))
                               VJ   )             for N in num_to_range(J):
                                 gKN               imp_print(gte(K,N))
                                     VJ     )     for N in num_to_range(J):
                                       g-JNN       imp_print(gte(minus(J,N),N))
                                             =_z  assign('z',neg(z))


Body:
JavaScript (ES6), 60 bytes

w=>h=>--w+--h+`
${"."[r="repeat"](w)}#`[r](h)+`
X`+"#"[r](w)

Usage

f(4)(5)

7
...#
...#
...#
...#
X###


问:
Open the browser to http://codegolf.stackexchange.com
Your job is to open a browser window of the default browser to http://codegolf.stackexchange.com.

Your code must open the browser itself, and cannot rely on an open one.

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

Moderator note: A large number of answers to this challenge use the URLs http://ppcg.lol or http://ppcg.ga. These URLs did direct to https://codegolf.stackexchange.com at the time, but have since expired. By this meta discussion, they have been allowed to stay, with the note that they are currently invalid.

答:
C# (Full Class) 89 bytes

```<code>class P{static void Main(string[]a){System.Diagnostics.Process.Start("http://ppcg.ga");}}
</code>```

Not sure that it's possible to write a full class (with the System.Diagnostics reference) any shorter.

Inside main method only without references, 32 bytes:

```<code>Process.Start("http://ppcg.ga");
</code>```

Body:
C# (Full Class) 89 bytes

class P{static void Main(string[]a){System.Diagnostics.Process.Start("http://ppcg.ga");}}

Not sure that it's possible to write a full class (with the System.Diagnostics reference) any shorter.

Inside main method only without references, 32 bytes:

Process.Start("http://ppcg.ga");


答:
Perl 6, 45 bytes

Requires the Browser::Open module.

```<code>use Browser::Open;open_browser 'http:ppcg.ga'
</code>```

Title: Open the browser to http://codegolf.stackexchange.com

Body:
Your job is to open a browser window of the default browser to http://codegolf.stackexchange.com.

Your code must open the browser itself, and cannot rely on an open one.

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

Moderator note: A large number of answers to this challenge use the URLs http://ppcg.lol or http://ppcg.ga. These URLs did direct to https://codegolf.stackexchange.com at the time, but have since expired. By this meta discussion, they have been allowed to stay, with the note that they are currently invalid.

Body:
Perl 6, 45 bytes

Requires the Browser::Open module.

use Browser::Open;open_browser 'http:ppcg.ga'


问:
Code a code page

Introduction

A code page maps integer values to a specific character. We can visualize a code page like this:

```
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|   | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 0 | q | w | e | r | t | z | u | i | o | p | a | s | d | f | g | j |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 1 | k | l | y | x | c | v | b | n | m | Q | W | E | R | T | Z | U |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 2 | I | O | P | A | S | D | F | G | H | J |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
```

The rows specify the first digit and the columns the second digit of the hex-number.

The Challenge

Given a string of 16-255 unique characters, output the corresponding code page using the zero-based index of each character in the string as it's value.
The input qwertzuiopasdfgjklyxcvbnmQWERTZUIOPASDFGHJ for example would yield the table above.

The output has to be in the exact same format as the table above. Only a trailing newline is optional.

If the input length is not a multiple of 16, you need to start a new row for the remaining characters and leave the unused cells empty (=filled with 3 spaces).

Each character is placed exactly in the middle of a cell, padded by one space to the left and right.

The values in the first row and column are given by hex-numbers with the digits 0123456789ABCDEF. Those are padded with one space to the left and right as well. You may choose to use lowercase hex-digits but you need to stick to one.

The only characters present in the output are hyphens -, pluses +, pipes |, spaces  , the digits for hexadecimal numbers and the characters from the input.

Any builtins that are related to ASCII-art tables or trivialize the problem in any way are forbidden.

You may assume that the input consists only of characters of a specific encoding. Please specify if that is the case.

If your language can only handle ASCII input, you may assume ASCII-only input and repeated characters.

Rules

Function or full program allowed.

Default rules for input/output.

Standard loopholes apply.

This is code-golf, so lowest byte-count wins. Tiebreaker is earlier submission.

Happy Coding!

Title: Code a code page

Body:
Python 3.5, 326 355 bytes:

(+29 bytes since if the length of the last row is not a multiple of 16, unused cells should be left empty (although, in my opinion, it looks much better if those empty cells are just not even shown))

def f(r):o=' 0123456789ABCDEF';r=[r[0+i:16+i]for i in range(0,len(r),16)];print('+---'*17+'+\n|',end='');[print(' {} |'.format(h),end='')for h in o];print(''.join([str(e+' | ')if e.isdigit()or e.isalpha()else str(e)for e in''.join([str('\n'+'+---'*17+'+\n| '+x[0]+x[1])for x in zip(o[1::1],r)])]),end='');print('  |'+'   |'*(15-len(r[-1]))+'\n'+'+---'*17+'+')

Works like a charm!

Sample Inputs and Outputs:

Input: 'hopper'

Output:

    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    |   | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    | 0 | h | o | p | p | e | r |   |   |   |   |   |   |   |   |   |   |
    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

Input: 'honkhonkhonkhonkhonk'

Output:

    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    |   | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    | 0 | h | o | n | k | h | o | n | k | h | o | n | k | h | o | n | k |
    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    | 1 | h | o | n | k |   |   |   |   |   |   |   |   |   |   |   |   |
    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

Input: 'hi'

Output:

    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    |   | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    | 0 | h | i |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

I hope this is okay.

Also, here is another version I created for this challenge, which, although is an invalid candidate since it does not print out extra empty cells for the last row if its length is not a multiple 16, in my opinion outputs a much better looking page than the one required by OP, mainly because it does not even show empty cells if the last row is not a multiple of 16, but instead just shows filled cells, and that's it:

def f2(r):o=' 0123456789ABCDEF';r=[r[0+i:16+i]for i in range(0,len(r),16)];print('+---'*17+'+\n|',end='');[print(' {} |'.format(h),end='')for h in o];print(''.join([str(e+' | ')if e.isdigit()or e.isalpha()else str(e)for e in''.join([str('\n'+'+---'*17+'+\n| '+x[0]+x[1])for x in zip(o[1::1],r)])]));print('+---'*(len(r[-1])+1)+'+')

Here is a sample input and output for the inapplicable code above:

Input: 'ggreuuobgugoubgoubguorgoruguor'

Output:

    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    |   | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    | 0 | g | g | r | e | u | u | o | b | g | u | g | o | u | b | g | o |
    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    | 1 | u | b | g | u | o | r | g | o | r | u | g | u | o | r |
    +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

    (As you can see, there are no empty cells shown in the entire table. This looks much better to me.)


问:
Validate a Wikipedia page name
Wikipedia has several restrictions on an article's title. I summarize them here:

It may not be empty.

It may not begin with a lowercase letter. A character is considered lowercase if it has an Ll after its name in UnicodeData.txt.

It may not contain any of the characters: # < > [ ] | { } _

It may not be . or ..

It may not begin with ./ or ../.

It may not contain /./ or /../.

It may not end with /. or /...

It may not contain any space character (a character is considered a space if it has Zs after its name in UnicodeData.txt) except for U+0020 SPACE.

It may not contain more than one consecutive space.

It may not consist entirely of spaces.

It may not begin with a colon.

It may not begin with the language prefix of any of the 292 language editions of Wikipedia followed by a colon. This includes en: for English.

It may not begin with the prefix of another Wikimedia Foundation project or its shortcut followed by a colon.

It may not contain the character % followed by two hexadecimal digits.

It may not contain a named HTML character entity. Numbered entities are already forbidden through #.

It must contain no more than 256 bytes when encoded in UTF-8.

Write a function that takes in a string (or whatever data type your language normally uses to manipulate text) and outputs a boolean indicating whether the string is a valid Wikipedia article title. You are permitted to use networking libraries to download and read from any page that I linked in this question.

答:
Retina, 1221 bytes

```<code>^(?=...:|\w|(^|.*/)\.\.?(/.*|$)|.*([#<>\[\]|{}]|  |__|%[0-9a-fA-F]{2}|&#(\d{4}|[0-9a-fA-F]{4}|a(mp|pos)|(l|g|quo)t);|~~~)|[ _]*$|.{257,}).*
no
^(?!no$).+
yes
</code>```

where ... is:

```<code>(w(ik(i(s(pecies|ource)|v(ersity|oyage)|([mp]edi|dat)a|(book|new)s|quote|tech)|t(ionary)?)|m(i[dlnt]|c[ahz]|a[ru]|b[de]|d[ek]|h[ku]|n[lo]|r[su]|u[ak]|fi?|mk|pl|se|tw)|ar?|uu|o)?|m(e(dia(wikiwiki|zilla)|t(awikipedi)?a)|a(p-bms|i)|[klnr]|[ghi]|[iz]n|[st]|yv?|df|hr|rj|us|wl)|s([degh]|t(rategy|q)|i(mple)?|[klmnoqr]|c(n?|o)|pecies|[uvw]|[st]|ah?|rn|zl)|b(a(t-smg|r?)|ug(zilla)?|e-tarask|[eghi]|[mno]|[rs]|cl|jn|py|xr)|t([aghw]|e(stwiki|t)?|[iklno]|oollabs|[rst]|yv?|pi|um)|c(o(mmons)?|h[ory]?|[es]b?|bk-zam|[uvy]|rh?|do|kb|a)|p(habricator|a[gmp]?|n[bt]|[st]|f?l|ih?|cd|dc|ms)|n(ds(-nl)?|[glno]|a[hp]?|[vy]|ew?|ov|rm|so)|a([afkm]|r[cz]?|[vyz]|ng?|st?|z?b|ce|dy|ls)|k([gijklmnor]|[uvwy]|a[ab]?|sh?|bd|oi|rc)|z(h(-(classical|min-nan|yue))?|e?a|u)|f([afijory]|oundation|iu-vro|r[pr]|ur)|l([gi]|[no]|ad?|be?|tg?|ez|ij|mo|rc|v)|r([nw]|o(a-(tara|rup))?|my?|ue?)|g(a[gn]?|[dln]|o[mt]|[uv]|lk)|h([eiortu]|a[kw]?|[yz]|if|sb)|i([adegikostu]|ncubator|lo)|v(e(c?|p)|oy?|ls|i)|d([vz]|[ae]|iq|sb)|e([elnostu]|ml|xt)|u([gz]|[kr]|dm)|j([av]|bo)|x(al|mf|h)|[nbqsvcdm]|o[cmrs]|y[io]|qu|)
</code>```

(I used this regex optimizer and manutally typed in all the data)

Try it online without the ...!

Title: Validate a Wikipedia page name

Body:
Retina, 1221 bytes

^(?=...:|\w|(^|.*/)\.\.?(/.*|$)|.*([#<>\[\]|{}]|  |__|%[0-9a-fA-F]{2}|&#(\d{4}|[0-9a-fA-F]{4}|a(mp|pos)|(l|g|quo)t);|~~~)|[ _]*$|.{257,}).*
no
^(?!no$).+
yes

where ... is:

(w(ik(i(s(pecies|ource)|v(ersity|oyage)|([mp]edi|dat)a|(book|new)s|quote|tech)|t(ionary)?)|m(i[dlnt]|c[ahz]|a[ru]|b[de]|d[ek]|h[ku]|n[lo]|r[su]|u[ak]|fi?|mk|pl|se|tw)|ar?|uu|o)?|m(e(dia(wikiwiki|zilla)|t(awikipedi)?a)|a(p-bms|i)|[klnr]|[ghi]|[iz]n|[st]|yv?|df|hr|rj|us|wl)|s([degh]|t(rategy|q)|i(mple)?|[klmnoqr]|c(n?|o)|pecies|[uvw]|[st]|ah?|rn|zl)|b(a(t-smg|r?)|ug(zilla)?|e-tarask|[eghi]|[mno]|[rs]|cl|jn|py|xr)|t([aghw]|e(stwiki|t)?|[iklno]|oollabs|[rst]|yv?|pi|um)|c(o(mmons)?|h[ory]?|[es]b?|bk-zam|[uvy]|rh?|do|kb|a)|p(habricator|a[gmp]?|n[bt]|[st]|f?l|ih?|cd|dc|ms)|n(ds(-nl)?|[glno]|a[hp]?|[vy]|ew?|ov|rm|so)|a([afkm]|r[cz]?|[vyz]|ng?|st?|z?b|ce|dy|ls)|k([gijklmnor]|[uvwy]|a[ab]?|sh?|bd|oi|rc)|z(h(-(classical|min-nan|yue))?|e?a|u)|f([afijory]|oundation|iu-vro|r[pr]|ur)|l([gi]|[no]|ad?|be?|tg?|ez|ij|mo|rc|v)|r([nw]|o(a-(tara|rup))?|my?|ue?)|g(a[gn]?|[dln]|o[mt]|[uv]|lk)|h([eiortu]|a[kw]?|[yz]|if|sb)|i([adegikostu]|ncubator|lo)|v(e(c?|p)|oy?|ls|i)|d([vz]|[ae]|iq|sb)|e([elnostu]|ml|xt)|u([gz]|[kr]|dm)|j([av]|bo)|x(al|mf|h)|[nbqsvcdm]|o[cmrs]|y[io]|qu|)

(I used this regex optimizer and manutally typed in all the data)

Try it online without the ...!