问:
What is the most frequent word?

What is the most frequent word?

Given a sentence, your program must make its way through it, counting the frequencies of each word, then output the most used word. Because a sentence has no fixed length, and so can get very long, your code must be as short as possible.

Rules/Requirements

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

There must be a free interpreter/compiler available for your language.

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

Your program must not write anything to STDERR.

Your program should take input from STDIN (or the closest alternative in your language).

Standard loopholes are forbidden.

Your program must be case-insensitive (tHe, The and the all contribute to the count of the).

If there is no most frequent word (see test case #3), your program should output nothing.

Definition of a 'word':

You get the list of words by splitting the input text on spaces. The input will never contain any other type of whitespace than plain spaces (in particular no newlines). However, the final words should only contain alphanumerics (a-z, A-Z, 0-9), hyphens (-) and apostrophes ('). You can make that so by removing all other characters or by replacing them by space before doing the word splitting. To remain compatible with previous versions of the rules, apostrophes are not required to be included.

Test Cases

```<code>The man walked down the road.
==> the

-----

Slowly, he ate the pie, savoring each delicious bite. He felt like he was truly happy.
==> he

-----

This sentence has no most frequent word.
==>

-----

"That's... that's... that is just terrible!" he said.
==> that's / thats

-----

The old-fashioned man ate an old-fashioned cake.
==> old-fashioned

-----

IPv6 looks great, much better than IPv4, except for the fact that IPv6 has longer addresses.
==> IPv6

-----

This sentence with words has at most two equal most frequent words.
==>
</code>```

Note: The third and seventh test cases have no output, you may choose either on the fourth.

Scoring

Programs are scored according to bytes. The usual character set is UTF-8, if you are using another please specify.

When the challenge finishes, the program with the least bytes (it's called code-golf), will win.

Submissions

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

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

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

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

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

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

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

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

Leaderboard

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

  });

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Shell, <s>89</s> <s>86</s> 82 bytes

grep -Po "[\w'-]+"|sort -f|uniq -ci|sort -nr|awk 'c>$1{print w}c{exit}{c=$1;w=$2}'
```

<p>This lists all words in the input, then sorts them with counts from most common to least common.  The <code>awk</code> call merely ensures that the #2 word doesn't have the same count as the #1 word.</p>

<p>Unwrapped:</p>

<pre class="lang-bash prettyprint-override"><code>grep -Po "[\w'-]+"      # get a list of the words, one per line
  |sort -f              # sort (case insensitive, "folded")
  |uniq -ci             # count unique entries while still ignoring case
  |sort -nr             # sort counted data in descending order
  |awk '
    count > $1 {        # if count of most common word exceeds that of this line
      print word        # print the word saved from it
    }
    count {             # if we have already saved a count (-> we are on line 2)
      exit              # we always exit on line 2 since we have enough info
    }
    {                   # if true (run on line 1 only due to the above exit)
      count = $1        # save the count of the word on this first line
      word = $2         # save the word itself
    }'
</code>```

grep -o is the magic tokenizer here. It takes each word (as defined by a regex accepting word characters (letters, numbers, underscore), apostrophe, or hyphen using PCRE given -P) and puts it on its own line.  This accepts underscores, as to many other answers here.  To disallow underscores, add four characters to turn this portion into grep -oi "[a-z0-9'-]*"

alias cnt='sort -f |uniq -ci |sort -nr' is an old standby of mine. Without regards to case, it alphabetizes (erm, asciibetizes) the lines of the input counts occurrences of each entry, then reverse-sorts by the numeric occurrences so the most popular is first.

awk only looks at the first two lines of that descending ranked list. On line one, count is not yet defined, so it is evaluated as zero and therefore the first two stanzas are skipped (zero == false).  The third stanza sets count and word.  On the second line, awk has a defined and nonzero value for count, so it compares that count to the second best count. If it's not tied, the saved word is printed. Regardless, the next stanza exits for us.

Test implemented as:

for s in "The man walked down the road." "Slowly, he ate the pie, savoring each delicious bite. He felt like he was truly happy." "This sentence has no most frequent word." "\"That's... that's... that is just terrible\!\" he said." "The old-fashioned man ate an old-fashioned cake." "IPv6 looks great, much better than IPv4, except for the fact that IPv6 has longer addresses." "This sentence with words has at most two equal most frequent words."; do printf "%s\n==> " "$s"; echo "$s" |grep -io "[a-z0-9'-]*"|sort -f|uniq -ci|sort -nr|awk 'c>$1{print w}c{exit}{c=$1;w=$2}'; echo; done
```

Title: What is the most frequent word?

Body:
Shell, <s>89</s> <s>86</s> 82 bytes

grep -Po "[\w'-]+"|sort -f|uniq -ci|sort -nr|awk 'c>$1{print w}c{exit}{c=$1;w=$2}'

This lists all words in the input, then sorts them with counts from most common to least common.  The awk call merely ensures that the #2 word doesn't have the same count as the #1 word.

Unwrapped:

grep -Po "[\w'-]+"      # get a list of the words, one per line
  |sort -f              # sort (case insensitive, "folded")
  |uniq -ci             # count unique entries while still ignoring case
  |sort -nr             # sort counted data in descending order
  |awk '
    count > $1 {        # if count of most common word exceeds that of this line
      print word        # print the word saved from it
    }
    count {             # if we have already saved a count (-> we are on line 2)
      exit              # we always exit on line 2 since we have enough info
    }
    {                   # if true (run on line 1 only due to the above exit)
      count = $1        # save the count of the word on this first line
      word = $2         # save the word itself
    }'

grep -o is the magic tokenizer here. It takes each word (as defined by a regex accepting word characters (letters, numbers, underscore), apostrophe, or hyphen using PCRE given -P) and puts it on its own line.  This accepts underscores, as to many other answers here.  To disallow underscores, add four characters to turn this portion into grep -oi "[a-z0-9'-]*"

alias cnt='sort -f |uniq -ci |sort -nr' is an old standby of mine. Without regards to case, it alphabetizes (erm, asciibetizes) the lines of the input counts occurrences of each entry, then reverse-sorts by the numeric occurrences so the most popular is first.

awk only looks at the first two lines of that descending ranked list. On line one, count is not yet defined, so it is evaluated as zero and therefore the first two stanzas are skipped (zero == false).  The third stanza sets count and word.  On the second line, awk has a defined and nonzero value for count, so it compares that count to the second best count. If it's not tied, the saved word is printed. Regardless, the next stanza exits for us.

Test implemented as:

for s in "The man walked down the road." "Slowly, he ate the pie, savoring each delicious bite. He felt like he was truly happy." "This sentence has no most frequent word." "\"That's... that's... that is just terrible\!\" he said." "The old-fashioned man ate an old-fashioned cake." "IPv6 looks great, much better than IPv4, except for the fact that IPv6 has longer addresses." "This sentence with words has at most two equal most frequent words."; do printf "%s\n==> " "$s"; echo "$s" |grep -io "[a-z0-9'-]*"|sort -f|uniq -ci|sort -nr|awk 'c>$1{print w}c{exit}{c=$1;w=$2}'; echo; done


问:
Generate 100 Java Tuple classes
Write a script that writes to standard output, or your language's equivalent, 100 lines of (valid) Java code that begins with:

```<code>class Tuple1 {public Object _0;}
class Tuple2 {public Object _0,_1;}
class Tuple3 {public Object _0,_1,_2;}
class Tuple4 {public Object _0,_1,_2,_3;}
class Tuple5 {public Object _0,_1,_2,_3,_4;}
class Tuple6 {public Object _0,_1,_2,_3,_4,_5;}
class Tuple7 {public Object _0,_1,_2,_3,_4,_5,_6;}
class Tuple8 {public Object _0,_1,_2,_3,_4,_5,_6,_7;}
class Tuple9 {public Object _0,_1,_2,_3,_4,_5,_6,_7,_8;}
class Tuple10 {public Object _0,_1,_2,_3,_4,_5,_6,_7,_8,_9;}
class Tuple11 {public Object _0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10;}
class Tuple12 {public Object _0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11;}
</code>```

The last line should begin with class Tuple100.

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

答:
JavaScript (ES6), 85 bytes

```<code>s='_0';for(i=1;i<101;s+=',_'+i++)console.log(`class Tuple${i} {public Object ${s};}`)
</code>```

ContentLicense: CC BY-SA 3.0

Title: Generate 100 Java Tuple classes

Body:
JavaScript (ES6), 85 bytes

s='_0';for(i=1;i<101;s+=',_'+i++)console.log(`class Tuple${i} {public Object ${s};}`)


问:
Simple cat program
One of the most common standard tasks (especially when showcasing esoteric programming languages) is to implement a "cat program": read all of STDIN and print it to STDOUT. While this is named after the Unix shell utility cat it is of course much less powerful than the real thing, which is normally used to print (and concatenate) several files read from disc.

Task

You should write a full program which reads the contents of the standard input stream and writes them verbatim to the standard output stream. If and only if your language does not support standard input and/or output streams (as understood in most languages), you may instead take these terms to mean their closest equivalent in your language (e.g. JavaScript's prompt and alert). These are the only admissible forms of I/O, as any other interface would largely change the nature of the task and make answers much less comparable.

The output should contain exactly the input and nothing else. 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. This also applies to trailing newlines. If the input does not contain a trailing newline, the output shouldn't include one either! (The only exception being if your language absolutely always prints a trailing newline after execution.)

Output to the standard error stream is ignored, so long as the standard output stream contains the expected output. In particular, this means your program can terminate with an error upon hitting the end of the stream (EOF), provided that doesn't pollute the standard output stream. If you do this, I encourage you to add an error-free version to your answer as well (for reference).

As this is intended as a challenge within each language and not between languages, there are a few language specific rules:

If it is at all possible in your language to distinguish null bytes in the standard input stream from the EOF, your program must support null bytes like any other bytes (that is, they have to be written to the standard output stream as well).

If it is at all possible in your language to support an arbitrary infinite input stream (i.e. if you can start printing bytes to the output before you hit EOF in the input), your program has to work correctly in this case. As an example yes | tr -d \\n | ./my_cat should print an infinite stream of ys. It is up to you how often you print and flush the standard output stream, but it must be guaranteed to happen after a finite amount of time, regardless of the stream (this means, in particular, that you cannot wait for a specific character like a linefeed before printing).

Please add a note to your answer about the exact behaviour regarding null-bytes, infinite streams, and extraneous output.

Additional rules

This is not about finding the language with the shortest solution for this (there are some where the empty program does the trick) - this is about finding the shortest solution 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.

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

Feel free to use a language (or language version) even if it's newer than this challenge. Languages specifically written to submit a 0-byte answer to this challenge are fair game but not particularly interesting.

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.

Also note that languages do have to fulfil our usual criteria for programming languages.

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.

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 catalogue as complete as possible. However, do primarily upvote answers in languages where the author actually had to put effort into golfing the code.

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>## [><>](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

```

答:
Javascript (browser), <s>16</s> 15 bytes

```<code>alert(prompt())
</code>```

Title: Simple cat program

Body:
Javascript (browser), <s>16</s> 15 bytes

alert(prompt())


问:
Loop without 'looping'
A question similar to this has been asked a couple of years ago, but this one is even trickier.

The challenge is simple. Write a program (in your language of choice) that repeatedly executes code without using any repetition structures such as while, for, do while, foreach or goto (So for all you nitpickers, you can't use a loop). However, recursion is not allowed, in the function calling itself sense (see definition below). That would make this challenge far too easy.

There is no restriction on what needs to be executed in the loop, but post an explanation with your answer so that others can understand exactly what is being implemented.

For those who may be hung up on definitions, the definition of a loop for this question is:

A programming language statement which allows code to be repeatedly executed.

And the definition of recursion for this question will be your standard recursive function definition:

A function that calls itself.

Winner will be the answer that has the most upvotes on July 16th at 10 AM eastern time. Good luck!

UPDATE:

To calm confusion that is still being expressed this may help:

Rules as stated above:

Don't use loops or goto

Functions cannot call themselves

Do whatever you want in the 'loop'

If you want to implement something and the rules don't explicitly disallow it, go ahead and do it. Many answers have already bent the rules.

答:
Python 2

```<code>class K(object):
    def __del__(self):
        print "You cannot stop the power of deallocators!"
        K()
</code>```

This code goes into an infinite loop printing You cannot stop the power of deallocators.

Note that this does not work in Python 3

Title: Loop without 'looping'

Body:
Python 2

class K(object):
    def __del__(self):
        print "You cannot stop the power of deallocators!"
        K()

This code goes into an infinite loop printing You cannot stop the power of deallocators.

Note that this does not work in Python 3


问:
Reinvent the For loop
For loops are used extensively in many languages, but what would you do if no languages supported them?

Create a way to execute a basic for loop without using any repetition structures (for, foreach, while, do, etc).

The basic for loop that you need to replicate is set up like this

```<code>for(i=0;i<1000;i++)
</code>```

You must be able to replicate this without using repetition structures.  It must also execute code in your language that would be in the body of the loop.  Any form of eval is allowed, though it may not execute the for loop on its own.

You can test your code by having it print i with a space 100 times, add this test case to the end of your answer to verify your code with others.

There are no restrictions on what exactly it has to be, all it needs to do is replicate the for loop.

Winner will be decided based on upvotes at the time that it is chosen.

答:
CPython 2, 158 bytes

(Yes, this is both implementation and version specific)

```<code>class K(object):
 def __init__(s,b,c,e,n):
  if not n:n={};exec b in n
  else:exec e in n
  s.n=n;s.c=c;s.e=e
 def __del__(s):eval(s.c,s.n)or K(0,s.c,s.e,s.n)
</code>```

Example usage:

```<code>K('i=55','i<88','i+=1;print i`,0)
</code>```

ContentLicense: CC BY-SA 2.5

Title: Reinvent the For loop

Body:
CPython 2, 158 bytes

(Yes, this is both implementation and version specific)

class K(object):
 def __init__(s,b,c,e,n):
  if not n:n={};exec b in n
  else:exec e in n
  s.n=n;s.c=c;s.e=e
 def __del__(s):eval(s.c,s.n)or K(0,s.c,s.e,s.n)

Example usage:

K('i=55','i<88','i+=1;print i`,0)


答:
CoffeeScript/LiveScript/etc. (Node.js), 31 bytes

I'm not sure if any of those languages have been used yet, but here it is.

```<code>p=process;p.stdin.pipe p.stdout
</code>```

Because it takes advantage of so few features, most of the CoffeeScript descendants with any notability would work with this code, including LiveScript, Coco, and IcedCoffeeScript.

Oh, and it does deal with infinite streams.

Title: Simple cat program

Body:
One of the most common standard tasks (especially when showcasing esoteric programming languages) is to implement a "cat program": read all of STDIN and print it to STDOUT. While this is named after the Unix shell utility cat it is of course much less powerful than the real thing, which is normally used to print (and concatenate) several files read from disc.

Task

You should write a full program which reads the contents of the standard input stream and writes them verbatim to the standard output stream. If and only if your language does not support standard input and/or output streams (as understood in most languages), you may instead take these terms to mean their closest equivalent in your language (e.g. JavaScript's prompt and alert). These are the only admissible forms of I/O, as any other interface would largely change the nature of the task and make answers much less comparable.

The output should contain exactly the input and nothing else. 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. This also applies to trailing newlines. If the input does not contain a trailing newline, the output shouldn't include one either! (The only exception being if your language absolutely always prints a trailing newline after execution.)

Output to the standard error stream is ignored, so long as the standard output stream contains the expected output. In particular, this means your program can terminate with an error upon hitting the end of the stream (EOF), provided that doesn't pollute the standard output stream. If you do this, I encourage you to add an error-free version to your answer as well (for reference).

As this is intended as a challenge within each language and not between languages, there are a few language specific rules:

If it is at all possible in your language to distinguish null bytes in the standard input stream from the EOF, your program must support null bytes like any other bytes (that is, they have to be written to the standard output stream as well).

If it is at all possible in your language to support an arbitrary infinite input stream (i.e. if you can start printing bytes to the output before you hit EOF in the input), your program has to work correctly in this case. As an example yes | tr -d \\n | ./my_cat should print an infinite stream of ys. It is up to you how often you print and flush the standard output stream, but it must be guaranteed to happen after a finite amount of time, regardless of the stream (this means, in particular, that you cannot wait for a specific character like a linefeed before printing).

Please add a note to your answer about the exact behaviour regarding null-bytes, infinite streams, and extraneous output.

Additional rules

This is not about finding the language with the shortest solution for this (there are some where the empty program does the trick) - this is about finding the shortest solution 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.

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

Feel free to use a language (or language version) even if it's newer than this challenge. Languages specifically written to submit a 0-byte answer to this challenge are fair game but not particularly interesting.

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.

Also note that languages do have to fulfil our usual criteria for programming languages.

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.

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 catalogue as complete as possible. However, do primarily upvote answers in languages where the author actually had to put effort into golfing the code.

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>## [><>](http://esolangs.org/wiki/Fish), 121 bytes
</code>```

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

Body:
CoffeeScript/LiveScript/etc. (Node.js), 31 bytes

I'm not sure if any of those languages have been used yet, but here it is.

p=process;p.stdin.pipe p.stdout

Because it takes advantage of so few features, most of the CoffeeScript descendants with any notability would work with this code, including LiveScript, Coco, and IcedCoffeeScript.

Oh, and it does deal with infinite streams.


问:
Will the beam hit?
A laser shoots a straight beam in one of the four orthogonal directions, indicated by <>^v. Determine whether it will hit the target O on a rectangular grid.

Each of these will hit (True):

```<code>.....
...O.
.....
...^.
.....

>O.
...

v....
O....

...........
...........
O.........<
...........
</code>```

These will miss (False):

```<code>......
......
.^..O.

......
.....>
O.....
......
......

.O.
...
.v.

.....<.
..O....
</code>```

Input: A rectangular grid of ., sized at least 2x2, with exactly one target O and one laser that's one of <>^v. The lines can be a list of strings, a 2D array or nested list of characters, or a single newline-separated string with an optional trailing newline.

Output: A consistent truthy value if the laser beam hits the target, and a consistent falsy value if it misses.

I'll consider submissions that don't use regular expressions (or built-in pattern-based string matching) as a separate category. If you put (no regex) after the language name, your answer will appear separately in the leaderboard.

var QUESTION_ID=80196,OVERRIDE_USER=20260;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/80196/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

```

答:
Python 2 (no regex), 268 bytes

```<code>import numpy
def q(i):
 s=numpy.asmatrix(i)
 for n in s:
  n=n.tolist()[0]
  try:
   a=n.index("0")
   if n.index(">")<a or n.index("<")>a:return 1
  except:0
 for n in range(len(i)):
  c=[x[0] for x in s[:,n].tolist()]
  try:
   a=c.index("0")
   if c.index("v")<a or c.index("^")>a:return 1
  except:0
 return 0
</code>```

Truthy and Falsy values returned by the function are 1 and 0, respectively.

I haven't had a chance to golf yet. Honestly, I'm not too hopeful for this one...

Any suggestions would be greatly appreciated!

Title: Will the beam hit?

Body:
Python 2 (no regex), 268 bytes

import numpy
def q(i):
 s=numpy.asmatrix(i)
 for n in s:
  n=n.tolist()[0]
  try:
   a=n.index("0")
   if n.index(">")<a or n.index("<")>a:return 1
  except:0
 for n in range(len(i)):
  c=[x[0] for x in s[:,n].tolist()]
  try:
   a=c.index("0")
   if c.index("v")<a or c.index("^")>a:return 1
  except:0
 return 0

Truthy and Falsy values returned by the function are 1 and 0, respectively.

I haven't had a chance to golf yet. Honestly, I'm not too hopeful for this one...

Any suggestions would be greatly appreciated!


问:
Three Indistinguishable Dice

Given three dice rolls (integer values from 1-6) in sorted order (so as to be indistinguishable), convert them to the sum of two fair dice with an identical distribution.

The answer for three to one is summing them all, modulo 6. The end-result is a perfectly flat distribution, where each of the six numbers are equally likely (just like a single die).

It's easy to do this for three-to-one, by summing them all modulo 6. The end-result is a perfectly flat distribution, where each of the six numbers are equally likely (just like a single die).  Your challenge is to do the same for three-to-two.

Inspired by standupmath's The Three Indistinguishable Dice Puzzle. A follow-up "solution" video was also posted, but arguing about "elegance" of one way or another is a bit subjective. Counting characters isn't. :D

Instructions

Write a program or function that accepts three sorted integers/digits, 1-6, and outputs or returns a single integer, 2-12, such that, for the 216 possible inputs, the outputs are distributed as:

```<code> 222222
 333333333333
 444444444444444444
 555555555555555555555555
 666666666666666666666666666666
 777777777777777777777777777777777777
 888888888888888888888888888888
 999999999999999999999999
 AAAAAAAAAAAAAAAAAA
 BBBBBBBBBBBB
 CCCCCC
</code>```

(I've used hex to keep to single characters; decimal output is fine)

Because the dice are indistinguishable, there is no intrinsic order to them, hence the sorted input. You cannot simply "drop the third" because that would be ambiguous.

Details

Score is the length of the program in bytes

The program can be a function that's called somehow, or executable script that reads from stdin, or whatever's convienent.

No "rerolling" by getting entropy from another source

Example (and test)

Rather than doing any sort of probabilistic testing, it's easy enough to rip through the 216 (6³) cases of all the three dice and assert that your function returns each value as many times as it should. It will be called with identical parameters (e.g. the cases 1, 2, 3 and 3, 2, 1, ... are presumed indistinguishable and are (arbitrarily) converted to 1, 2, 3).

An example answer (extremely brute-force and inefficient) and test suite is provided below in Python. Hopefully the test bits are clear enough to port to your language of choice, though doing stdin/stdout would be a bit different. The testing code is just for testing and not scored (though if you want to provide it for other users of your language or I/O method, that might be useful).

```<code># 6x6 lists of numbers with digits sorted
LUT = [
    [[124], [133, 166], [346], [223, 355], [256], [115, 445]],
    [[233, 266], [125], [224, 455], [134], [116, 446], [356]],
    [[126], [111, 333, 555, 225], [234], [144, 366], [456], [135]],
    [[112, 244], [235], [334, 466], [145], [226, 556], [136]],
    [[146], [122, 155], [236], [113, 344], [245], [335, 566]],
    [[246], [123], [114, 336], [345], [222, 444, 666, 255], [156]],
]

def three2two(rolls):
    look_for = int('{}{}{}'.format(*sorted(rolls)))
    for i in range(6):
        for j in range(6):
            if look_for in LUT[i][j]:
                return i + j + 2

# fair distribution of the sum of two dice multiplied by 6 (because each should be hit 6x)
expected_counts = {
    2: 6,   12: 6,
    3: 12,  11: 12,
    4: 18,  10: 18,
    5: 24,   9: 24,
    6: 30,   8: 30,
    7: 36,
}

d = [1, 2, 3, 4, 5, 6]
for i in d:
    for j in d:
        for k in d:
            ijk = sorted([i, j, k])
            result = three2two(ijk)
            expected_counts[result] -= 1

for key in expected_counts:
    assert expected_counts[key] == 0
</code>```

Title: Three Indistinguishable Dice

Body:
Jelly, <s>22</s> 20 bytes

6ṗ3Ṣ€ṢðQ€L€Ụịḷi’:6d6‘S

Try it online! or simulate all 216 outcomes.

Background

We map each unordered triplet of dice rolls (listed with respective multiplicities) to an ordered pair of dice rolls in the following fashion:

[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3] -> [1,1]
[1,2,4],[1,2,4],[1,2,4],[1,2,4],[1,2,4],[1,2,4] -> [1,2]
[1,2,5],[1,2,5],[1,2,5],[1,2,5],[1,2,5],[1,2,5] -> [1,3]
[1,2,6],[1,2,6],[1,2,6],[1,2,6],[1,2,6],[1,2,6] -> [1,4]
[1,3,4],[1,3,4],[1,3,4],[1,3,4],[1,3,4],[1,3,4] -> [1,5]
[1,3,5],[1,3,5],[1,3,5],[1,3,5],[1,3,5],[1,3,5] -> [1,6]
[1,3,6],[1,3,6],[1,3,6],[1,3,6],[1,3,6],[1,3,6] -> [2,1]
[1,4,5],[1,4,5],[1,4,5],[1,4,5],[1,4,5],[1,4,5] -> [2,2]
[1,4,6],[1,4,6],[1,4,6],[1,4,6],[1,4,6],[1,4,6] -> [2,3]
[1,5,6],[1,5,6],[1,5,6],[1,5,6],[1,5,6],[1,5,6] -> [2,4]
[2,3,4],[2,3,4],[2,3,4],[2,3,4],[2,3,4],[2,3,4] -> [2,5]
[2,3,5],[2,3,5],[2,3,5],[2,3,5],[2,3,5],[2,3,5] -> [2,6]
[2,3,6],[2,3,6],[2,3,6],[2,3,6],[2,3,6],[2,3,6] -> [3,1]
[2,4,5],[2,4,5],[2,4,5],[2,4,5],[2,4,5],[2,4,5] -> [3,2]
[2,4,6],[2,4,6],[2,4,6],[2,4,6],[2,4,6],[2,4,6] -> [3,3]
[2,5,6],[2,5,6],[2,5,6],[2,5,6],[2,5,6],[2,5,6] -> [3,4]
[3,4,5],[3,4,5],[3,4,5],[3,4,5],[3,4,5],[3,4,5] -> [3,5]
[3,4,6],[3,4,6],[3,4,6],[3,4,6],[3,4,6],[3,4,6] -> [3,6]
[3,5,6],[3,5,6],[3,5,6],[3,5,6],[3,5,6],[3,5,6] -> [4,1]
[4,5,6],[4,5,6],[4,5,6],[4,5,6],[4,5,6],[4,5,6] -> [4,2]
[1,2,2],[1,2,2],[1,2,2],[1,3,3],[1,3,3],[1,3,3] -> [4,3]
[1,4,4],[1,4,4],[1,4,4],[1,5,5],[1,5,5],[1,5,5] -> [4,4]
[1,6,6],[1,6,6],[1,6,6],[2,3,3],[2,3,3],[2,3,3] -> [4,5]
[2,4,4],[2,4,4],[2,4,4],[2,5,5],[2,5,5],[2,5,5] -> [4,6]
[2,6,6],[2,6,6],[2,6,6],[3,4,4],[3,4,4],[3,4,4] -> [5,1]
[3,5,5],[3,5,5],[3,5,5],[3,6,6],[3,6,6],[3,6,6] -> [5,2]
[4,5,5],[4,5,5],[4,5,5],[4,6,6],[4,6,6],[4,6,6] -> [5,3]
[5,6,6],[5,6,6],[5,6,6],[1,1,2],[1,1,2],[1,1,2] -> [5,4]
[1,1,3],[1,1,3],[1,1,3],[1,1,4],[1,1,4],[1,1,4] -> [5,5]
[1,1,5],[1,1,5],[1,1,5],[1,1,6],[1,1,6],[1,1,6] -> [5,6]
[2,2,3],[2,2,3],[2,2,3],[2,2,4],[2,2,4],[2,2,4] -> [6,1]
[2,2,5],[2,2,5],[2,2,5],[2,2,6],[2,2,6],[2,2,6] -> [6,2]
[3,3,4],[3,3,4],[3,3,4],[3,3,5],[3,3,5],[3,3,5] -> [6,3]
[3,3,6],[3,3,6],[3,3,6],[4,4,5],[4,4,5],[4,4,5] -> [6,4]
[4,4,6],[4,4,6],[4,4,6],[5,5,6],[5,5,6],[5,5,6] -> [6,5]
[1,1,1],[2,2,2],[3,3,3],[4,4,4],[5,5,5],[6,6,6] -> [6,6]

This makes all outcomes equiprobable.

How it works

6ṗ3Ṣ€ṢðĠ€Ụịḷi’:6d6‘S  Main link. Argument: D (three dice rolls, sorted)

6ṗ3                     Generate lists of length 3 over [1, 2, 3, 4, 5, 6].
   Ṣ€                   Sort each triplet.
     Ṣ                  Sort the list of triplets.
      ð                 Begin a new, dyadic chain.
                        Arguments: A (list of triplets), D
       Ġ€               Group each; group the indices of each triplet by the
                        the corresponding values.
                        For a triplet [a, b, c], this yields:
                          [[1], [2], [3]] if a < b < c
                          [[1], [2, 3]]   if a < b = c
                          [[1, 2], [3]]   if a = b < c
                          [[1, 2, 3]]     if a = b = c
           Ụ            Grade up; sort the indices of A by those 2D lists.
            ịḷ          Retrieve the elements of A at those indices.
                        This sorts A as in the previous section.
              i         Find the (1-based) index of D.
               ’        Decrement to get the 0-based index.
                :6      Divide the index by 6, rounding down.
                  d6    Divmod; return quotient and remainder of division by 6.
                    ‘   Increment to map [0, ..., 5] to [1, ..., 6].
                     S  Sum the results.


问:
Find words that rhyme

Challenge

Joe the rapper is struggling with rhyming words in his lyrics. He needs your help.

For this situation, we will use rhymes where the last syllable in a word is the same as the other word (spelled the same).

When Joe inputs a word, the program will read a list of words from a file and output those that rhyme with Joe's word.

To show that the program works, we will only need to use a small list.

txt File:

```<code>hello
joe
crew
flow
time
apple
heart
glow
rhyme
art
jello
grew
doe
flue
blow
smart
dime
cat
slime
show
bedtime
clue
grime
toe
dart
cart
brew
snow
prime
hat
chart
lime
blue
knew
lunchtime
restart
</code>```

Examples

Input: snow

Output: blow flow glow show Note- Should not output the input

Input: fart

Output: restart art dart cart chart smart heart Note- Should work for inputs not in list

Input: crime

Output: time slime prime grime dime lime bedtime lunchtime Note- Should work for all syllables

Rules

Should output all words that rhyme with input

does not need to output rhymes with different letters Ex: Crime should not output rhyme

Should not output the input

Should work with inputs not in the list

Should work will all syllables

Shortest Bytes Wins!

答:
Ruby, 68 bytes

FGITW. Full program, takes file and word from command line: ruby script.rb words.txt "hello".

Assumes the last syllable (or rather, the section of the syllable to match against for the purposes of rhyming) is at least 2 characters long, or more if there are extra vowels before that.

```<code>f,w=$*
w=~/[aeiou]*..$/
puts open(f).map(&:chomp).grep(/#{$&}$/)-[w]
</code>```

Title: Find words that rhyme

Body:
Ruby, 68 bytes

FGITW. Full program, takes file and word from command line: ruby script.rb words.txt "hello".

Assumes the last syllable (or rather, the section of the syllable to match against for the purposes of rhyming) is at least 2 characters long, or more if there are extra vowels before that.

f,w=$*
w=~/[aeiou]*..$/
puts open(f).map(&:chomp).grep(/#{$&}$/)-[w]


问:
"99 Bottles of Beer"
Write a program that outputs the lyrics to 99 Bottles of Beer, in as few bytes as possible.

Lyrics:

```<code>99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.

98 bottles of beer on the wall, 98 bottles of beer.
Take one down and pass it around, 97 bottles of beer on the wall.

97 bottles of beer on the wall, 97 bottles of beer.
Take one down and pass it around, 96 bottles of beer on the wall.

96 bottles of beer on the wall, 96 bottles of beer.
Take one down and pass it around, 95 bottles of beer on the wall.

95 bottles of beer on the wall, 95 bottles of beer.
Take one down and pass it around, 94 bottles of beer on the wall.

....

3 bottles of beer on the wall, 3 bottles of beer.
Take one down and pass it around, 2 bottles of beer on the wall.

2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.

1 bottle of beer on the wall, 1 bottle of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
</code>```

Rules:

Your program must log to STDOUT or an acceptable alternative, or be returned from a function (with or without a trailing newline).

Your program must be a full, runnable program or function.

Languages specifically written to submit a 0-byte answer to this challenge are allowed, just not particularly interesting.

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.

This is different from the output by HQ9+ or 99. Any answers written in these languages will be deleted.

As this is a catalog challenge, this is not about finding the language with the shortest solution for this (there are some where the empty program does the trick) - this is about finding the shortest solution in every language. Therefore, no answer will be marked as accepted.

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>## [><>](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

```

答:
Python 3, 210 bytes

```<code>b=" of beer"
s="bottles"+b
t=s[:6]+b
q="on the wall."
p=print
x=99
while x>1:p(x,s,q,x,s+".\nTake one down and pass it around,",x-1,(s,t)[x>1],q);x-=1
p(1,t,q,1,t+".\nGo to the store and buy some more,",99,s,q)
</code>```

Try it here: https://ideone.com/iX4byJ

ContentLicense: CC BY-SA 4.0

Title: "99 Bottles of Beer"

Body:
Python 3, 210 bytes

b=" of beer"
s="bottles"+b
t=s[:6]+b
q="on the wall."
p=print
x=99
while x>1:p(x,s,q,x,s+".\nTake one down and pass it around,",x-1,(s,t)[x>1],q);x-=1
p(1,t,q,1,t+".\nGo to the store and buy some more,",99,s,q)

Try it here: https://ideone.com/iX4byJ


答:
JavaScript (ES6), 67 bytes

```<code>(a,w)=>a.filter(s=>s!=w&s.endsWith(w.replace(/.*([aeiou].)/,"$1")))
</code>```

Function that accepts an array of words and an input word as parameters. Uses the definition of rhyme as the substring of the word starting at the last vowel before the last letter.

a=
(a,w)=>a.filter(s=>s!=w&s.endsWith(w.replace(/.*([aeiou].)/,"$1")))
;
u=w=>r.value=a(f.value.split`\n`,w).join`\n````
<pre class="snippet-code-html lang-html prettyprint-override"><code>File:
<textarea rows=5 id=f>
hello
joe
crew
flow
time
apple
heart
glow
rhyme
art
jello
grew
doe
flue
blow
smart
dime
cat
slime
show
bedtime
clue
grime
toe
dart
cart
brew
snow
prime
hat
chart
lime
blue
knew
lunchtime
restart
</textarea>
<br>
Word:
<input oninput="u(this.value)">
<br>
Rhymes:
<textarea rows=5 id=r>
</textarea></code>```

Title: Find words that rhyme

Body:
Challenge

Joe the rapper is struggling with rhyming words in his lyrics. He needs your help.

For this situation, we will use rhymes where the last syllable in a word is the same as the other word (spelled the same).

When Joe inputs a word, the program will read a list of words from a file and output those that rhyme with Joe's word.

To show that the program works, we will only need to use a small list.

txt File:

```<code>hello
joe
crew
flow
time
apple
heart
glow
rhyme
art
jello
grew
doe
flue
blow
smart
dime
cat
slime
show
bedtime
clue
grime
toe
dart
cart
brew
snow
prime
hat
chart
lime
blue
knew
lunchtime
restart
</code>```

Examples

Input: snow

Output: blow flow glow show Note- Should not output the input

Input: fart

Output: restart art dart cart chart smart heart Note- Should work for inputs not in list

Input: crime

Output: time slime prime grime dime lime bedtime lunchtime Note- Should work for all syllables

Rules

Should output all words that rhyme with input

does not need to output rhymes with different letters Ex: Crime should not output rhyme

Should not output the input

Should work with inputs not in the list

Should work will all syllables

Shortest Bytes Wins!

Body:
JavaScript (ES6), 67 bytes

(a,w)=>a.filter(s=>s!=w&s.endsWith(w.replace(/.*([aeiou].)/,"$1")))

Function that accepts an array of words and an input word as parameters. Uses the definition of rhyme as the substring of the word starting at the last vowel before the last letter.

a=
(a,w)=>a.filter(s=>s!=w&s.endsWith(w.replace(/.*([aeiou].)/,"$1")))
;
u=w=>r.value=a(f.value.split`\n`,w).join`\n`

File:
<textarea rows=5 id=f>
hello
joe
crew
flow
time
apple
heart
glow
rhyme
art
jello
grew
doe
flue
blow
smart
dime
cat
slime
show
bedtime
clue
grime
toe
dart
cart
brew
snow
prime
hat
chart
lime
blue
knew
lunchtime
restart
</textarea>
<br>
Word:
<input oninput="u(this.value)">
<br>
Rhymes:
<textarea rows=5 id=r>
</textarea>


问:
Randomly Assign People to Tasks
The challenge is to assign people to tasks randomly~.
From stdin you get 2 lines. Line one is a comma-separated list of names. Line 2 is a comma-separated list of jobs.
The output required is one line per task person combo.
The line should be formatted as Name:task.
If there are not enough people for jobs or vice verse then they will not be output.

~ Randomly is defined as each run with the same input has a reasonably different output.

Example Input:

```<code>Bob,John,Susan,Josie,Kim,Tom
Bins,Floor,Windows
</code>```

Example Output:

```<code>Bob:Windows
Susan:Bins
Kim:Floor
</code>```

答:
Pyth, 6 bytes

```<code>CmO.pd
</code>```

Try it online!

How it works:

```<code>CmO.pd
        (implicitly) takes the evaluated input
 m   d  for each "line":
   .p       generate all permutations
  O         choose one randomly
C       truncating transpose
</code>```

Following strictly the input/output format:

(16 bytes)

```<code>jjL\:CmO.pcd\,.z
</code>```

Try it online!

How it works:

```<code>jjL\:CmO.pcd\,.z
              .z  takes all lines
      m    d      for each line:
          c \,        split by ","
        .p            generate all permutations
       O              choose one randomly
     C            truncating transpose
 jL\:             join every pair by ":"
j                 join all pairs by newlines
</code>```

Title: Randomly Assign People to Tasks

Body:
Pyth, 6 bytes

CmO.pd

Try it online!

How it works:

CmO.pd
        (implicitly) takes the evaluated input
 m   d  for each "line":
   .p       generate all permutations
  O         choose one randomly
C       truncating transpose

Following strictly the input/output format:

(16 bytes)

jjL\:CmO.pcd\,.z

Try it online!

How it works:

jjL\:CmO.pcd\,.z
              .z  takes all lines
      m    d      for each line:
          c \,        split by ","
        .p            generate all permutations
       O              choose one randomly
     C            truncating transpose
 jL\:             join every pair by ":"
j                 join all pairs by newlines


答:
JavaScript (ES6) (no regex), 126 bytes

```<code>s=>([n,o,l,r,u,d]=[..."\nO<>^"].map(c=>1+s.indexOf(c)),l>o&l-o<n&l%n>o%n||r&&r<o&o-r<n&r%n<o%n||u>o&u%n==o%n||d&&d<o&d%n==o%n)
</code>```

Where \n represents the literal newline character.

Title: Will the beam hit?

Body:
A laser shoots a straight beam in one of the four orthogonal directions, indicated by <>^v. Determine whether it will hit the target O on a rectangular grid.

Each of these will hit (True):

```<code>.....
...O.
.....
...^.
.....

>O.
...

v....
O....

...........
...........
O.........<
...........
</code>```

These will miss (False):

```<code>......
......
.^..O.

......
.....>
O.....
......
......

.O.
...
.v.

.....<.
..O....
</code>```

Input: A rectangular grid of ., sized at least 2x2, with exactly one target O and one laser that's one of <>^v. The lines can be a list of strings, a 2D array or nested list of characters, or a single newline-separated string with an optional trailing newline.

Output: A consistent truthy value if the laser beam hits the target, and a consistent falsy value if it misses.

I'll consider submissions that don't use regular expressions (or built-in pattern-based string matching) as a separate category. If you put (no regex) after the language name, your answer will appear separately in the leaderboard.

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
JavaScript (ES6) (no regex), 126 bytes

s=>([n,o,l,r,u,d]=[..."\nO<>^"].map(c=>1+s.indexOf(c)),l>o&l-o<n&l%n>o%n||r&&r<o&o-r<n&r%n<o%n||u>o&u%n==o%n||d&&d<o&d%n==o%n)

Where \n represents the literal newline character.


答:
Jelly, 13 bytes

```<code>Œ!€X€ZL’$ÐfŒṘ
</code>```

Try it online!

Title: Randomly Assign People to Tasks

Body:
The challenge is to assign people to tasks randomly~.
From stdin you get 2 lines. Line one is a comma-separated list of names. Line 2 is a comma-separated list of jobs.
The output required is one line per task person combo.
The line should be formatted as Name:task.
If there are not enough people for jobs or vice verse then they will not be output.

~ Randomly is defined as each run with the same input has a reasonably different output.

Example Input:

```<code>Bob,John,Susan,Josie,Kim,Tom
Bins,Floor,Windows
</code>```

Example Output:

```<code>Bob:Windows
Susan:Bins
Kim:Floor
</code>```

Body:
Jelly, 13 bytes

Œ!€X€ZL’$ÐfŒṘ

Try it online!


答:
05AB1E, 7 bytes

Code:

```<code>.r².r)ø
</code>```

Try it online

Following the input/output spec strictly (16 bytes):

```<code>.r².r)øvy`r?':?,
</code>```

Explained:

```<code>.r                # radomize first input
  ².r             # randomize second input
     )ø           # merge the lists to an array of pairs cutting out extras
       vy`r?':?,  # format output
</code>```

Try it online

Title: Randomly Assign People to Tasks

Body:
05AB1E, 7 bytes

Code:

.r².r)ø

Try it online

Following the input/output spec strictly (16 bytes):

.r².r)øvy`r?':?,

Explained:

.r                # radomize first input
  ².r             # randomize second input
     )ø           # merge the lists to an array of pairs cutting out extras
       vy`r?':?,  # format output

Try it online


Title: Will the beam hit?

Body:
Java (no regex), <s>413</s> <s>412</s> <s>246</s> <s>242</s> <s>212</s> <s>211</s> <s>209</s> 198 bytes

Competing in golf challenges using java has less sense than take a part in Formula 1 race on bicycle, but I'm not always doing thinks which makes any sense.

Here is my extremely long java solution
Golfed version

boolean l(char[][]w){int[]t={},l={};for(int y=0;y<w.length;y++)for(int x=0;x<w[0].length;x++){if(w[y][x]=='O')t=new int[]{x,y};if(w[y][x]=='<')l=new int[]{x,y,1};if(w[y][x]=='>')l=new int[]{x,y,2};if(w[y][x]=='v')l=new int[]{x,y,3};if(w[y][x]=='^')l=new int[]{x,y,4};};return(l[2]==1&&l[1]==t[1]&&l[0]>t[0])||(l[2]==2&&l[1]==t[1]&&l[0]<t[0])||(l[2]==3&&l[0]==t[0]&&l[1]<t[1])||(l[2]==4&&l[0]==t[0]&&l[1]>t[1]);}

and ungolfed

boolean l(char[][] w) {
    int[] t = {}, l = {};
    for (int y = 0; y < w.length; y++)
        for (int x = 0; x < w[0].length; x++) {
            if (w[y][x] == 'O')
                t = new int[] { x, y };
            if (w[y][x] == '<')
                l = new int[] { x, y, 1 };
            if (w[y][x] == '>')
                l = new int[] { x, y, 2 };
            if (w[y][x] == 'v')
                l = new int[] { x, y, 3 };
            if (w[y][x] == '^')
                l = new int[] { x, y, 4 };
        }
    ;
    return (l[2] == 1 && l[1] == t[1] && l[0] > t[0])
            || (l[2] == 2 && l[1] == t[1] && l[0] < t[0])
            || (l[2] == 3 && l[0] == t[0] && l[1] < t[1])
            || (l[2] == 4 && l[0] == t[0] && l[1] > t[1]);
}

Seems like my entire concept was wrong, here is my shorter solution

boolean z(char[][]w){int x=0,y=0,i=0,a=w.length,b=w[0].length;for(;w[y][x]!=79;)if(++y==a){y=0;x++;}for(;i<(a<b?b:a);)if(i<b&w[y][i]==(i<x?62:60)|i<a&w[i][x]==(i++<y?'v':94))return 1<2;return 1>2;}

and ungolfed version

oolean z(char[][] w) {
        int x = 0, y = 0, i = 0, a = w.length, b = w[0].length;
        for (; w[y][x] != 79;)
            if (++y == a) {
                y = 0;
                x++;
            }
        for (; i < (a < b ? b : a);)
            if (i < b & w[y][i] == (i < x ? 62 : 60) | i < a
                    & w[i][x] == (i++ < y ? 'v' : 94))
                return 1 < 2;
        return 1 > 2;
    }

EDIT
I rewrote code for looking for 'O', now it contains single loop is much shorter, and I also used @Frozn suggestion to replace some of characters with their ascii values.

In result,another 30 bytes bites the dust.

Another suggestion from @Frozn, and we are couple bytes closer to Python solution

Another rewrite drop one loop, and combine two if statements


问:
RegEx-golf: match all contents in a string
Your task is to write a RegEx that matches everything inside strings.

A string is defined as everything surrounded by (but not including) two unescaped ".

A " can be escaped by \, which can also be escaped again.

Testcases

```<code>string:  ab\c"defg\\\"hi"jkl"mn\\\\"opqrst""
matches:      ^^^^^^^^^^     ^^^^^^        ^ (the empty string)
</code>```

Scoring

Shortest solution wins.

Specs

Please specify the flavour used.

The input will have balanced ".

There will be no \ that immediately precedes a string-beginning-delimiter. For example, you would not need to handle abc\"def"

答:
PCRE, 21 20 15 19 bytes

```<code>(.|^)"\K(\\.|[^"])*
</code>```

Try it here.

This matches a character (or the beginning of the input) before the beginning double quote and then reset the match, to make sure the double quote isn't shared with another match.

PCRE, 25 23 bytes

Thanks to Martin Büttner for golfing off 2 bytes.

```<code>(\\.|[^"])*+(?!"(?R)|$)
</code>```

Try it here.

Explanation

```<code>(
    \\.|[^"]     # An escaped character, or a character that isn't a double quote
)*+              # Possessive zero-or-more quantifier, which means backtracking
                 # could not happen after first match is found. That means if \\.
                 # matched, it would never switch to [^"], because it is always a
                 # match if it just stopped after the \\. without backtracking.
(?!"(?R)|$)      # Make sure it is not followed by a double quote and another
                 # match, or the end of the input.
</code>```

Note that the possessive quantifier (*+) made sure the negative lookahead always begins after a whole string, or a whole segment of non-string.

There are 4 cases:

The match begins anywhere outside of a string. \\. would never match a double quote according to the clarification. It could only end just before the next double quote which begins a string, or the end of input. Both cases fails the negative lookahead.

The match begins at the beginning of a string. (\\.|[^"])*+ would match a complete string. The next character must be a double quote, and couldn't be the end of input. After the double quote it is outside of the string, so it couldn't be another match. So it passes the negative lookahead.

The match begins at the end of a string. It matches an empty string in the same way as the previous case. But it doesn't matter according to the clarification.

The match begins in the middle of a string. Impossible because matches don't overlap.

Body:
PCRE, 21 20 15 19 bytes

(.|^)"\K(\\.|[^"])*

Try it here.

This matches a character (or the beginning of the input) before the beginning double quote and then reset the match, to make sure the double quote isn't shared with another match.

PCRE, 25 23 bytes

Thanks to Martin Büttner for golfing off 2 bytes.

(\\.|[^"])*+(?!"(?R)|$)

Try it here.

Explanation

(
    \\.|[^"]     # An escaped character, or a character that isn't a double quote
)*+              # Possessive zero-or-more quantifier, which means backtracking
                 # could not happen after first match is found. That means if \\.
                 # matched, it would never switch to [^"], because it is always a
                 # match if it just stopped after the \\. without backtracking.
(?!"(?R)|$)      # Make sure it is not followed by a double quote and another
                 # match, or the end of the input.

Note that the possessive quantifier (*+) made sure the negative lookahead always begins after a whole string, or a whole segment of non-string.

There are 4 cases:

The match begins anywhere outside of a string. \\. would never match a double quote according to the clarification. It could only end just before the next double quote which begins a string, or the end of input. Both cases fails the negative lookahead.

The match begins at the beginning of a string. (\\.|[^"])*+ would match a complete string. The next character must be a double quote, and couldn't be the end of input. After the double quote it is outside of the string, so it couldn't be another match. So it passes the negative lookahead.

The match begins at the end of a string. It matches an empty string in the same way as the previous case. But it doesn't matter according to the clarification.

The match begins in the middle of a string. Impossible because matches don't overlap.


问:
Flatten the Array!
In this challenge, your task is to create a program which takes in a nested array and returns a single-dimensional flattened array. For Example [10,20,[30,[40]],50] should output [10,20,30,40,50].

Input

The input will be a nested array (eg. [10,20,[[[10]]]]). It will contain only Integers (both negative and positive), Strings and Arrays. You can take the input as function argument, STDIN or whatever suits your language. You can assume that the input array won't have an empty array.

Output

The output will be a flatted single-dimensional array with the same elements of same type as in the nested array and in the SAME order.

Test Cases

```<code>[10,20,30] -> [10,20,30]
[[10]] -> [10]
[["Hi"],[[10]]] -> ["Hi",10]
[[[20],["Hi"],"Hi",20]] -> [20,"Hi","Hi",20]
[[["[]"],"[]"]] -> ["[]","[]"]
</code>```

Feel free to ask for any clarification by using comments. This is code-golf, so the shortest code in bytes wins!

Note: If your language contains a built-in for this, then you must NOT use it.

Edit

Please also include a link to a website where your code can be executed.

答:
Clojure, 68 bytes

```<code>(def f #(if(some vector? %)(f(mapcat(fn[z](if(vector? z)z[z]))%))%))
</code>```

mapcat first applies function to each element and then concats results. So every time it concats one 'nesting level' is lost. Concat does not work on not sequences so elements have to be wrapped into vector if they're not vector.

You can try it here: http://www.tryclj.com

```<code>(f [[[20],["Hi"],"Hi",20]])
(f [[["[]"],"[]"]])
</code>```

Title: Flatten the Array!

Body:
Clojure, 68 bytes

(def f #(if(some vector? %)(f(mapcat(fn[z](if(vector? z)z[z]))%))%))

mapcat first applies function to each element and then concats results. So every time it concats one 'nesting level' is lost. Concat does not work on not sequences so elements have to be wrapped into vector if they're not vector.

You can try it here: http://www.tryclj.com

(f [[[20],["Hi"],"Hi",20]])
(f [[["[]"],"[]"]])


答:
JavaScript (Firefox 30-57), 82 bytes

```<code>(a,b,s=a=>a.sort(_=>Math.random()-.5),c=s(b))=>[for(x of s(a))if(c[0])[x,c.pop()]]
</code>```

Uses bogus sort to shuffle. Version which accepts two string parameters of comma-separated names and returns lines of colon-separated matchups for 110 bytes, where \n represents the literal newline character:

```<code>(a,b,s=a=>a.sort(_=>Math.random()-.5),c=s(b.split`,`))=>[for(x of s(a.split`,`))if(c[0])x+':'+c.pop()].join`\n`
</code>```

Title: Randomly Assign People to Tasks

Body:
JavaScript (Firefox 30-57), 82 bytes

(a,b,s=a=>a.sort(_=>Math.random()-.5),c=s(b))=>[for(x of s(a))if(c[0])[x,c.pop()]]

Uses bogus sort to shuffle. Version which accepts two string parameters of comma-separated names and returns lines of colon-separated matchups for 110 bytes, where \n represents the literal newline character:

(a,b,s=a=>a.sort(_=>Math.random()-.5),c=s(b.split`,`))=>[for(x of s(a.split`,`))if(c[0])x+':'+c.pop()].join`\n`


答:
Mathcad, [tbd] bytes

csort(M,n) sorts matrix M on column n.
augment joins two arrays columnwise.
runif(n,a,b) returns a vector of n uniformly-distributed numbers over the range a..b.
concat(a,b) concatenates strings a and b.

With due apologies to Messrs Gilbert and Sullivan.

Mathcad scoring system yet to be determined (must get round to posting something on Meta ...).  However, this solution clearly wouldn't be a contender for anything other than a Programming Language specific leaderboard.   Taking a rough keyboard equivalence, and noting that Mathcad uses keyboard shortcuts for entering programming and some other operators, it takes around 100 "bytes".

Title: Randomly Assign People to Tasks


问:
Count up folks!

Introduction

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

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

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

Challenge

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

Rules

You can get n any way.

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

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

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

Standard loopholes are denied.

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

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

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

Bonuses

20%

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

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

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

答:
Scratch, <s>12</s> 10 bytes

(scoring used)

Asks for the end number, resets, and counts up.

Title: Count up folks!


问:
Toggle a string

The challenge involve simply toggling a string within another string.

Explanation

If the toggle string is a substring of the main string, remove all instances of the toggle string from the main string; otherwise, append the toggle string at the end of the main string.

Rules

All string are composed of printable ASCII characters

The function should take two parameters: the main string and the toggle string.

The main string can be empty.

The toggle string cannot be empty.

The result should be a string, which can be empty.

The shortest answer wins.

Examples

```<code>function toggle(main_string, toggle_string){ ... }

toggle('this string has 6 words ', 'now')
=> 'this string has 6 words now'

toggle('this string has 5 words now', ' now')
=> 'this string has 5 words'
</code>```

Tests cases

```<code>'','a'          => 'a'
'a','a'         => ''

'b','a'         => 'ba'
'ab','a'        => 'b'

'aba','a'       => 'b'
'ababa', 'aba'  => 'ba'
</code>```

答:
Pyth, <s>13</s> <s>11</s> 10 bytes

```<code>?/Qz:Qzk+z
</code>```

Test suite.

Input format: first string in quotes, second string without quotes.

This is also 10 bytes:

```<code>?tJcQzsJ+z
</code>```

Test suite.

This is 11 bytes:

```<code>pscQz*!}zQz
</code>```

Test suite.

Previous 13-byte solution:

```<code>?:IQzk+Qz:Qzk
</code>```

Test suite.

Title: Toggle a string

Body:
Pyth, <s>13</s> <s>11</s> 10 bytes

?/Qz:Qzk+z

Test suite.

Input format: first string in quotes, second string without quotes.

This is also 10 bytes:

?tJcQzsJ+z

Test suite.

This is 11 bytes:

pscQz*!}zQz

Test suite.

Previous 13-byte solution:

?:IQzk+Qz:Qzk

Test suite.


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

```

答:
Batsh, 23 bytes

```<code>print("Hello, World!");
</code>```

Try it online!

One-sentence description

Batsh is a language which compiles to bash and Windows Batch, thereby providing effortless cross-platform support for shell scripts, without additional dependencies.

Title: "Hello, World!"

Body:
Batsh, 23 bytes

print("Hello, World!");

Try it online!

One-sentence description

Batsh is a language which compiles to bash and Windows Batch, thereby providing effortless cross-platform support for shell scripts, without additional dependencies.


答:
TSQL (sqlserver 2012) (no regex), 358 bytes

```<code>DECLARE @ varchar(1000)=
'......'+ CHAR(13)+CHAR(10)+
'......'+ CHAR(13)+CHAR(10)+
'...0..'+ CHAR(13)+CHAR(10)+
'...^..'+ CHAR(13)+CHAR(10)
;

WITH C as(SELECT
number n,SUBSTRING(@,number,1)a,1+min(IIF(SUBSTRING(@,number,1)=char(13),number,99))over()m
FROM master..spt_values
WHERE'P'=type and
SUBSTRING(@,number,1)in('>','<','^','v','0',char(13)))SELECT
IIF(c.n%c.m=d.n%c.m and c.a+d.a in('0^','v0')or
c.n/c.m=d.n/c.m and c.a+d.a in('>0','0<'),1,0)FROM c,c d
WHERE c.n<d.n and char(13)not in(c.a,d.a)
</code>```

Had to use funky linechange in the declaration to force the online version to execute it(assigning values to input variables doesn't affect the length calculation anyway)

Try it online!

Title: Will the beam hit?

Body:
TSQL (sqlserver 2012) (no regex), 358 bytes

DECLARE @ varchar(1000)=
'......'+ CHAR(13)+CHAR(10)+
'......'+ CHAR(13)+CHAR(10)+
'...0..'+ CHAR(13)+CHAR(10)+
'...^..'+ CHAR(13)+CHAR(10)
;

WITH C as(SELECT
number n,SUBSTRING(@,number,1)a,1+min(IIF(SUBSTRING(@,number,1)=char(13),number,99))over()m
FROM master..spt_values
WHERE'P'=type and
SUBSTRING(@,number,1)in('>','<','^','v','0',char(13)))SELECT
IIF(c.n%c.m=d.n%c.m and c.a+d.a in('0^','v0')or
c.n/c.m=d.n/c.m and c.a+d.a in('>0','0<'),1,0)FROM c,c d
WHERE c.n<d.n and char(13)not in(c.a,d.a)

Had to use funky linechange in the declaration to force the online version to execute it(assigning values to input variables doesn't affect the length calculation anyway)

Try it online!


答:
Javascript (ECMAScript 6): 47 bytes

```<code>(a,b)=>(c=a.replace(RegExp(b,'g'),''))!=a?c:a+b
</code>```

Title: Toggle a string

Body:
The challenge involve simply toggling a string within another string.

Explanation

If the toggle string is a substring of the main string, remove all instances of the toggle string from the main string; otherwise, append the toggle string at the end of the main string.

Rules

All string are composed of printable ASCII characters

The function should take two parameters: the main string and the toggle string.

The main string can be empty.

The toggle string cannot be empty.

The result should be a string, which can be empty.

The shortest answer wins.

Examples

```<code>function toggle(main_string, toggle_string){ ... }

toggle('this string has 6 words ', 'now')
=> 'this string has 6 words now'

toggle('this string has 5 words now', ' now')
=> 'this string has 5 words'
</code>```

Tests cases

```<code>'','a'          => 'a'
'a','a'         => ''

'b','a'         => 'ba'
'ab','a'        => 'b'

'aba','a'       => 'b'
'ababa', 'aba'  => 'ba'
</code>```

Body:
Javascript (ECMAScript 6): 47 bytes

(a,b)=>(c=a.replace(RegExp(b,'g'),''))!=a?c:a+b


答:
Pyke, 14 bytes

```<code>DX{iIXRk:)i!IJ
</code>```

Try it here!

Given that Pyke has no else structure, I think this is pretty reasonable score

Explanation:

```<code>D              -    Duplicate input
 X             -   a,b = ^
  {            -  a in b
   i           - i = ^
    I          - if i:
     XRk:      -  a = b.replace(a,"")
         i!I   - if not i:
            J  -  a = "".join(input)
               - print a
</code>```

Title: Toggle a string

Body:
Pyke, 14 bytes

DX{iIXRk:)i!IJ

Try it here!

Given that Pyke has no else structure, I think this is pretty reasonable score

Explanation:

D              -    Duplicate input
 X             -   a,b = ^
  {            -  a in b
   i           - i = ^
    I          - if i:
     XRk:      -  a = b.replace(a,"")
         i!I   - if not i:
            J  -  a = "".join(input)
               - print a


答:
Oracle SQL 11.2, 66 bytes

SELECT DECODE(:1,s,s||:2,s)FROM(SELECT REPLACE(:1,:2)s FROM DUAL);
```

Title: Toggle a string


答:
Java 8, <s>80</s> <s>70</s> <s>65</s> 34 bytes

t->m->m==(m=m.replace(t,""))?m+t:m
```
<p>Probably my shortest Java 'codegolf' so far.. xD<br />
with some help from the comments.. ;)</p>
<p><strong>Explanation:</strong></p>
<p>Try it online.</p>
<pre class="lang-java prettyprint-override"><code>t->m->                     // Method with two String parameters and String return-type
                           // (NOTE: Takes the toggle `t` and main `m` in reversed order)
  m==(m=m.replace(t,""))?  //  If `m` equals `m` with all `t`-substrings removed:
                           //  (And set `m` to `m` with all `t`-substrings removed)
   m+t                     //   Output this new `m` concatted with `t`
  :                        //  Else:
   m                       //   Output just this new `m`
</code>```

Title: Toggle a string

Body:
Java 8, <s>80</s> <s>70</s> <s>65</s> 34 bytes

t->m->m==(m=m.replace(t,""))?m+t:m

Probably my shortest Java 'codegolf' so far.. xD

with some help from the comments.. ;)

Explanation:

Try it online.

t->m->                     // Method with two String parameters and String return-type
                           // (NOTE: Takes the toggle `t` and main `m` in reversed order)
  m==(m=m.replace(t,""))?  //  If `m` equals `m` with all `t`-substrings removed:
                           //  (And set `m` to `m` with all `t`-substrings removed)
   m+t                     //   Output this new `m` concatted with `t`
  :                        //  Else:
   m                       //   Output just this new `m`


答:
PowerShell v2+, 47 bytes

```<code>param($a,$b)(($c=$a-replace$b),"$a$b")[$c-eq$a]
</code>```

Takes input $a,$b and then uses a pseudo-ternary (... , ...)[...] statement to perform an if/else. The inner parts are evaluated first to form an array of two elements. The 0th is $a with all occurrences of $b -replaced with nothing, which is stored into $c. The 1st is just a string concatenation of $a and $b.

If $c is -equal to $a, meaning that $b wasn't found, that's Boolean $true or 1, and so the 1st element of the array (the concatenation) is chosen. Else, it's Boolean $false, so we output $c, the 0th element.

Note that -replace is greedy, so it will replace from the left first, meaning the ababa / aba test case will properly return ba.

Title: Toggle a string

Body:
PowerShell v2+, 47 bytes

param($a,$b)(($c=$a-replace$b),"$a$b")[$c-eq$a]

Takes input $a,$b and then uses a pseudo-ternary (... , ...)[...] statement to perform an if/else. The inner parts are evaluated first to form an array of two elements. The 0th is $a with all occurrences of $b -replaced with nothing, which is stored into $c. The 1st is just a string concatenation of $a and $b.

If $c is -equal to $a, meaning that $b wasn't found, that's Boolean $true or 1, and so the 1st element of the array (the concatenation) is chosen. Else, it's Boolean $false, so we output $c, the 0th element.

Note that -replace is greedy, so it will replace from the left first, meaning the ababa / aba test case will properly return ba.


答:
MATL, 11 bytes

```<code>yyXf?''YX}h
</code>```

Try it Online!

All test cases

Explanation

```<code>            % Implicitly grab the main string
            % Implicitly grab the toggle string
y           % Copy the main string
y           % Copy the toggle string
Xf          % Check to see if the toggle string is present in the main string
?           % If so
    ''YX    % Replace with an empty string
}           % else
    h       % Horizontally concatenate the two strings
            % Implicit end of if...else
            % Implicitly display the result
</code>```

Title: Toggle a string

Body:
MATL, 11 bytes

yyXf?''YX}h

Try it Online!

All test cases

Explanation

            % Implicitly grab the main string
            % Implicitly grab the toggle string
y           % Copy the main string
y           % Copy the toggle string
Xf          % Check to see if the toggle string is present in the main string
?           % If so
    ''YX    % Replace with an empty string
}           % else
    h       % Horizontally concatenate the two strings
            % Implicit end of if...else
            % Implicitly display the result


问:
Count up forever
Write a program that counts up forever, starting from one.

Rules:

Your program must log to STDOUT or an acceptable alternative, if STDOUT is not available.

Your program must be a full, runnable program, and not a function or snippet.

Your program must output each number with a separating character in between (a newline, space, tab or comma), but this must be consistent for all numbers.

You may print the numbers in decimal, in unary or in base 256 where each digit is represented by a byte value.

Your program must count at least as far as 2128 (inclusive) without problems and without running out of memory on a reasonable desktop PC. In particular, this means if you're using unary, you cannot store a unary representation of the current number in memory.

Unlike our usual rules, feel free to use a language (or language version) even if it's newer than this challenge. Languages specifically written to submit a 0-byte answer to this challenge are fair game but not particularly interesting.

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.

This is not about finding the language with the shortest solution for this (there are some where the empty program does the trick) - this is about finding the shortest solution in every language. Therefore, no answer will be marked as accepted.

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>## [><>](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

```

答:
Tellurium, 6 bytes

```<code>[i|+^]
</code>```

Pretty simple.

The program adds one to the selected cell (+), and then outputs it (^). Using i as a loop's value makes it run the code forever.

Title: Count up forever

Body:
Tellurium, 6 bytes

[i|+^]

Pretty simple.

The program adds one to the selected cell (+), and then outputs it (^). Using i as a loop's value makes it run the code forever.


答:
Scratch, 252 bytes

(scoring used)

Resets, repeats for 98 cycles, then a modified last block for the last line.

If you allow "1 bottles" in the list, this can be golfed down to 133 bytes.

Title: "99 Bottles of Beer"

Body:
Write a program that outputs the lyrics to 99 Bottles of Beer, in as few bytes as possible.

Lyrics:

```<code>99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.

98 bottles of beer on the wall, 98 bottles of beer.
Take one down and pass it around, 97 bottles of beer on the wall.

97 bottles of beer on the wall, 97 bottles of beer.
Take one down and pass it around, 96 bottles of beer on the wall.

96 bottles of beer on the wall, 96 bottles of beer.
Take one down and pass it around, 95 bottles of beer on the wall.

95 bottles of beer on the wall, 95 bottles of beer.
Take one down and pass it around, 94 bottles of beer on the wall.

....

3 bottles of beer on the wall, 3 bottles of beer.
Take one down and pass it around, 2 bottles of beer on the wall.

2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.

1 bottle of beer on the wall, 1 bottle of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
</code>```

Rules:

Your program must log to STDOUT or an acceptable alternative, or be returned from a function (with or without a trailing newline).

Your program must be a full, runnable program or function.

Languages specifically written to submit a 0-byte answer to this challenge are allowed, just not particularly interesting.

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.

This is different from the output by HQ9+ or 99. Any answers written in these languages will be deleted.

As this is a catalog challenge, this is not about finding the language with the shortest solution for this (there are some where the empty program does the trick) - this is about finding the shortest solution in every language. Therefore, no answer will be marked as accepted.

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>## [><>](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

```