问:
Count of "a"s and "b"s must be equal. Did you get it computer?
In the popular (and essential) computer science book, An Introduction to Formal Languages and Automata by Peter Linz, the following formal language is frequently stated:

$$\large{L=\{a^n b^n:n\in\mathbb{Z}^+\}}$$

mainly because this language can not be processed with finite-state automata.
This expression mean "Language L consists all strings of 'a's followed by 'b's, in which the number of 'a's and 'b's are equal and non-zero".

Challenge

Write a working program/function which gets a string, containing "a"s and "b"s only, as input and returns/outputs a truth value, saying if this string is valid the formal language L.

Your program cannot use any external computation tools, including network, external programs, etc. Shells are an exception to this rule; Bash, e.g., can use command line utilities.

Your program must return/output the result in a "logical" way, for example: returning 10 instead of 0, "beep" sound, outputting to stdout etc. More info here.

Standard code golf rules apply.

This is a code-golf. Shortest code in bytes wins. Good luck!

Truthy test cases

```<code>"ab"
"aabb"
"aaabbb"
"aaaabbbb"
"aaaaabbbbb"
"aaaaaabbbbbb"
</code>```

Falsy test cases

```<code>""
"a"
"b"
"aa"
"ba"
"bb"
"aaa"
"aab"
"aba"
"abb"
"baa"
"bab"
"bba"
"bbb"
"aaaa"
"aaab"
"aaba"
"abaa"
"abab"
"abba"
"abbb"
"baaa"
"baab"
"baba"
"babb"
"bbaa"
"bbab"
"bbba"
"bbbb"
</code>```

Leaderboard

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

  });

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
PHP bounty version, 31 bytes

for PHP 4.1, call php-cgi -f <scriptname> s=<argument> (or in browser with ?s=<argument>)

for current PHP, use $_GET[s] instead of $s

31 bytes

<?eval(strtr("do$s;",ab,'{}'));

unexpected ';' for valid, unexpected end of file or unexpected '}' for invalid

<?eval(strtr("1|$s;",ab,'[]'));

ok for valid, unexpected ';' or unexpected ']' for invalid

26 bytes

if empty input was undefined or valid:

<?eval(strtr($s,ab,'{}'));

29 bytes, if empty input was undefined or valid:

<?eval(strtr("$s;",ab,'[]'));

Abusing other control structures:

32 bytes

<?eval(strtr("$c=$s;",ab,'[]'));

ok for valid, Parse error for invalid: unexpected ';', unexpected ']' or Cannot use [] for reading (for abab)

33 bytes

<?eval(strtr("1 or$s;",ab,'[]'));

same as 1|

<?eval(strtr("if(0)$s",ab,'{}'));

ok for valid, unexpected end of file or unexpected '}' for invalid input

35 bytes:

<?eval(strtr("for(;;)$s",ab,'{}'));

infinite loop for valid (use for(;0;) to make finite), same as if for invalid

36 bytes

<?eval(strtr("while(0)$s",ab,'{}'));

same as if

39 bytes

<?eval(strtr("function()$s;",ab,'{}'));

unexpected ';' for empty, same as if for other input


问:
A single pixel moving in a circular path
This is a graphical output challenge where the task is to give the shortest code per language.

Task

Your code should plot a single purple pixel (hex value #800080 or
rgb(128, 0, 128)), moving clockwise round a circle. It should take exactly 60 seconds to make a full journey round the circle and should continue indefinitely. Nothing else should be shown on the screen or window except for the pixel.  The width of the circle should be 0.75 (rounding suitably) the width of the screen or window and the background should be white.  To prevent silly solutions, the screen or window should be at least 100 pixels wide.

Your code should be a full program.

Languages and libraries

You can use any language or library you like. However, I would like to be able to test your code if possible so if you can provide clear instructions for how to run it in Ubuntu that would be very much appreciated.

Missing top twenty languages. Help needed.

The following top twenty programming languages are currently missing any solution at all.

C, C++, C#, Python, PHP, Visual Basic .NET, Perl, Delphi/Object Pascal, Assembly, Objective-C, Swift, Pascal, Matlab/Octave, PL/SQL, OpenEdge ABL, R

Catalog

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
Progress ABL, character Interface, 445 bytes

A couple of comments:

I have no way in ABL to really work with pixels. It could possibly be done by creating a rectangle that's 1 x 1 pixel and moving it around. But even that would be cumbersome. Instead I choose to use a period character (.): hence this solution is for character interface and not a graphic client. Maybe I'll come back with a graphical solution some other time...

Since the space of one character is higher than it is wide I've set the screen size to 65 columns by 20 rows. Roughly estimating a square.

Purple colour is another problem. From start I'm limited to 16 preset colors and none match the purple I need. Changing the colors in character mode is done by editing a init file used when starting the program. Therefore I instead set the period to "color 13" - 255,0,255 by default. Not the wanted purple but at least a purple color.

Another dilemma is the absence of sine and cosine functions or anything remotely like that (rotate etc). To bypass this I choose to call an external Windows DLL - meaning this specific solution only works in Windows environments. However if there are any similar Linux libraries available it should be easy enough to port.

Of course I've been "inspired" by solutions in other languages to pull this off...

My main ways of reducing size:

Shortening certain statements, ie DISP instead of DISPLAY.

Global definitions (preprocessors).

Whitespace and line breaks

This is my first attempt at Golf so I might very well be doing something wrong here - like byte count or otherwise. Please tell me if so!

Solution:

```<code>&GLOB v DEF VAR
&GLOB e EXTERNAL "MSVCRT40.DLL" CDECL:
PROCE cos {&e} DEF INPUT PARAM v AS DO. DEF RETURN PARAM r AS DO. END. PROCE sin {&e} DEF INPUT PARAM v AS DO. DEF RETURN PARAM r AS DO. END. {&v} c AS C FORM "x". {&v} t AS DE. {&v} i AS DE. {&v} j AS DE. c=".". REPEAT: t=t - 0.1. DISP c NO-LABEL WITH FRAM f SIZE 65 BY 20. c:FGC=13. RUN cos(T, OUTPUT i). RUN sin(t, OUTPUT j). c:ROW=10 + i * 7.5. c:COLUMN=30 + j * 26.3. PAUSE 1. END
</code>```

Ungolfed:

```<code>&GLOBAL-DEFINE v DEFINE VARIABLE
&GLOBAL-DEFINE e EXTERNAL "MSVCRT40.DLL" CDECL:

PROCEDURE cos {&e}
    DEFINE INPUT PARAM v AS DOUBLE.
    DEFINE RETURN PARAM r AS DOUBLE.
END.

PROCEDURE sin {&e}
    DEF INPUT PARAM v AS DOUBLE.
    DEF RETURN PARAM r AS DOUBLE.
END.

{&v} c AS CHARACTER FORMAT "x".
{&v} t AS DECIMAL.
{&v} i AS DECIMAL.
{&v} j AS DECIMAL.

c = ".".

REPEAT:
    t = t - 0.1.
    DISPLAY c NO-LABEL WITH FRAM f SIZE 65 BY 20.
    c:FGCOLOR = 13.
    RUN cos(T, OUTPUT i).
    RUN sin(t, OUTPUT j).
    c:ROW = 10 + i * 7.5.
    c:COLUMN = 30 + j * 26.3.
    PAUSE 1.
END
</code>```

(All lines normally end with period or colon (colon for start of blocks) but the compiler lets this slip on the very last line...)

The preprocessor statements are basically pre run/compile replacements so {&v} in the part {&v} t AS DE. is replaced with DEF VAR rewriting the entire line to

```<code>DEF VAR t AS DE.
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Progress ABL, character Interface, 445 bytes

A couple of comments:

I have no way in ABL to really work with pixels. It could possibly be done by creating a rectangle that's 1 x 1 pixel and moving it around. But even that would be cumbersome. Instead I choose to use a period character (.): hence this solution is for character interface and not a graphic client. Maybe I'll come back with a graphical solution some other time...

Since the space of one character is higher than it is wide I've set the screen size to 65 columns by 20 rows. Roughly estimating a square.

Purple colour is another problem. From start I'm limited to 16 preset colors and none match the purple I need. Changing the colors in character mode is done by editing a init file used when starting the program. Therefore I instead set the period to "color 13" - 255,0,255 by default. Not the wanted purple but at least a purple color.

Another dilemma is the absence of sine and cosine functions or anything remotely like that (rotate etc). To bypass this I choose to call an external Windows DLL - meaning this specific solution only works in Windows environments. However if there are any similar Linux libraries available it should be easy enough to port.

Of course I've been "inspired" by solutions in other languages to pull this off...

My main ways of reducing size:

Shortening certain statements, ie DISP instead of DISPLAY.

Global definitions (preprocessors).

Whitespace and line breaks

This is my first attempt at Golf so I might very well be doing something wrong here - like byte count or otherwise. Please tell me if so!

Solution:

&GLOB v DEF VAR
&GLOB e EXTERNAL "MSVCRT40.DLL" CDECL:
PROCE cos {&e} DEF INPUT PARAM v AS DO. DEF RETURN PARAM r AS DO. END. PROCE sin {&e} DEF INPUT PARAM v AS DO. DEF RETURN PARAM r AS DO. END. {&v} c AS C FORM "x". {&v} t AS DE. {&v} i AS DE. {&v} j AS DE. c=".". REPEAT: t=t - 0.1. DISP c NO-LABEL WITH FRAM f SIZE 65 BY 20. c:FGC=13. RUN cos(T, OUTPUT i). RUN sin(t, OUTPUT j). c:ROW=10 + i * 7.5. c:COLUMN=30 + j * 26.3. PAUSE 1. END

Ungolfed:

&GLOBAL-DEFINE v DEFINE VARIABLE
&GLOBAL-DEFINE e EXTERNAL "MSVCRT40.DLL" CDECL:

PROCEDURE cos {&e}
    DEFINE INPUT PARAM v AS DOUBLE.
    DEFINE RETURN PARAM r AS DOUBLE.
END.

PROCEDURE sin {&e}
    DEF INPUT PARAM v AS DOUBLE.
    DEF RETURN PARAM r AS DOUBLE.
END.

{&v} c AS CHARACTER FORMAT "x".
{&v} t AS DECIMAL.
{&v} i AS DECIMAL.
{&v} j AS DECIMAL.

c = ".".

REPEAT:
    t = t - 0.1.
    DISPLAY c NO-LABEL WITH FRAM f SIZE 65 BY 20.
    c:FGCOLOR = 13.
    RUN cos(T, OUTPUT i).
    RUN sin(t, OUTPUT j).
    c:ROW = 10 + i * 7.5.
    c:COLUMN = 30 + j * 26.3.
    PAUSE 1.
END

(All lines normally end with period or colon (colon for start of blocks) but the compiler lets this slip on the very last line...)

The preprocessor statements are basically pre run/compile replacements so {&v} in the part {&v} t AS DE. is replaced with DEF VAR rewriting the entire line to

DEF VAR t AS DE.


问:
Produce the number 2014 without any numbers in your source code

Note to challenge writers as per meta consensus:
This question was well-received when it was posted, but challenges
like this, asking answerers to Do X without using
Y
are likely to be poorly received. Try using the
sandbox
to get feedback on if you want to post a similar challenge.

It's <s>2017</s> <s>2018</s> <s>2019</s> <s>2020</s> <s>2021</s> <s>2022</s> 2023 already, folks, go home.

So, now that it's 2014, it's time for a code question involving the number 2014.

Your task is to make a program that prints the number 2014, without using any of the characters 0123456789 in your code, and independently of any external variables such as the date or time or a random seed.

The shortest code (counting in bytes) to do so in any language in which numbers are valid tokens wins.

Leaderboard:

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Jelly, 10 bytes

```<code>⁹⁴×H_⁴Ḥ¤’’
</code>```

Explanation:

```<code>⁹            Set the current value to 256.
 ⁴×          Multiply by 16. The current value is now 4096.
   H         Divide by 2. The current value is now 2048.
    _⁴Ḥ¤     Subtract by 16/2. The current value is now 2016.
        ’’   Decrement twice. The current value is now 2014.
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Jelly, 10 bytes

⁹⁴×H_⁴Ḥ¤’’

Explanation:

⁹            Set the current value to 256.
 ⁴×          Multiply by 16. The current value is now 4096.
   H         Divide by 2. The current value is now 2048.
    _⁴Ḥ¤     Subtract by 16/2. The current value is now 2016.
        ’’   Decrement twice. The current value is now 2014.


问:
Product over a range
Your task is simple: given two integers \$a\$ and \$b\$, output \$\Pi[a,b]\$; that is, the product of the range between \$a\$ and \$b\$. You may take \$a\$ and \$b\$ in any reasonable format, whether that be arguments to a function, a list input, STDIN, et cetera. You may output in any reasonable format, such as a return value (for functions) or STDOUT. \$a\$ will always be less than \$b\$.

Note that the end may be exclusive or inclusive of \$b\$. I'm not picky. ^_^

Test cases

```<code>[a,b) => result
[2,5) => 24
[5,10) => 15120
[-4,3) => 0
[0,3) => 0
[-4,0) => 24

[a,b] => result
[2,5] => 120
[5,10] => 151200
[-4,3] => 0
[0,3] => 0
[-4,-1] => 24
</code>```

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

Leaderboard

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

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

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

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

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

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

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

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

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
JavaScript (using external library) (31 bytes)

```<code> (a,b)=>_.RangeTo(a,b).Product()
</code>```

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

Explanation of code: Anonymous method accepts low bound and high bound for range, and uses built in .Product method to produce the product for that range

Title: Product over a range

Body:
JavaScript (using external library) (31 bytes)

 (a,b)=>_.RangeTo(a,b).Product()

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

Explanation of code: Anonymous method accepts low bound and high bound for range, and uses built in .Product method to produce the product for that range


问:
Detriplicate a string
A lot of languages have built-in ways to get rid of duplicates, or "deduplicate" or "uniquify" a list or string. A less common task is to "detriplicate" a string. That is, for every character that appears, the first two occurrences are kept.

Here is an example where the characters that should be deleted are labelled with ^:

```<code>aaabcbccdbabdcd
  ^    ^ ^^^ ^^
aabcbcdd
</code>```

Your task is to implement exactly this operation.

Rules

Input is a single, possibly empty, string. You may assume that it only contains lowercase letters in the ASCII range.

Output should be a single string with all characters removed which have already appeared at least twice in the string (so the left-most two occurrences are kept).

Instead of strings you may work with lists of characters (or singleton strings), but the format has to be consistent between input and output.

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

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

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

Test Cases

Every pair of lines is one test case, input followed by output.

```<code>

xxxxx
xx
abcabc
abcabc
abcdabcaba
abcdabc
abacbadcba
abacbdc
aaabcbccdbabdcd
aabcbcdd
</code>```

Leaderboard

The Stack Snippet at the bottom of this post generates a leaderboard 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 + 3 (-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

```

答:
J, <s>20</s> 15 bytes

```<code>#~(3>[+/@:={:)\
</code>```

This defines a monadic function that takes and returns a string. Try it here. Usage:

```<code>   f =: #~(3>[+/@:={:)\
   f 'abaacbb'
abacb
</code>```

Explanation

I switched to the same algorithm that some other solutions use, since it turned out to be shorter...

```<code>#~(3>[+/@:={:)\  Input is y.
  (          )\  For each prefix of y:
          =        compute the equality vector
     [     {:      of the prefix and its last element, and
      +/@:         take its sum. Now we have a vector r such that y[i] has its
                   r[i]'th occurrence at position i.
   3>              Mark those coordinates where r[i] < 3.
#~               Remove the non-marked characters from y.
</code>```

Title: Detriplicate a string

Body:
J, <s>20</s> 15 bytes

#~(3>[+/@:={:)\

This defines a monadic function that takes and returns a string. Try it here. Usage:

   f =: #~(3>[+/@:={:)\
   f 'abaacbb'
abacb

Explanation

I switched to the same algorithm that some other solutions use, since it turned out to be shorter...

#~(3>[+/@:={:)\  Input is y.
  (          )\  For each prefix of y:
          =        compute the equality vector
     [     {:      of the prefix and its last element, and
      +/@:         take its sum. Now we have a vector r such that y[i] has its
                   r[i]'th occurrence at position i.
   3>              Mark those coordinates where r[i] < 3.
#~               Remove the non-marked characters from y.


答:
Haskell, <s>40</s> 39 bytes

```<code>foldl(\s c->s++[c|filter(==c)s<=[c]])""
</code>```

Usage example: foldl(\s c->s++[c|filter(==c)s<=[c]])"" "aaabcbccdbabdcd" -> "aabcbcdd".

Keep the next char c if the string of all cs so far are lexicographical less or equal the singleton string [c].

Edit: @xnor saved a byte by switching from list comprehension to filter. Thanks!

Title: Detriplicate a string

Body:
A lot of languages have built-in ways to get rid of duplicates, or "deduplicate" or "uniquify" a list or string. A less common task is to "detriplicate" a string. That is, for every character that appears, the first two occurrences are kept.

Here is an example where the characters that should be deleted are labelled with ^:

```<code>aaabcbccdbabdcd
  ^    ^ ^^^ ^^
aabcbcdd
</code>```

Your task is to implement exactly this operation.

Rules

Input is a single, possibly empty, string. You may assume that it only contains lowercase letters in the ASCII range.

Output should be a single string with all characters removed which have already appeared at least twice in the string (so the left-most two occurrences are kept).

Instead of strings you may work with lists of characters (or singleton strings), but the format has to be consistent between input and output.

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

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

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

Test Cases

Every pair of lines is one test case, input followed by output.

```<code>

xxxxx
xx
abcabc
abcabc
abcdabcaba
abcdabc
abacbadcba
abacbdc
aaabcbccdbabdcd
aabcbcdd
</code>```

Leaderboard

The Stack Snippet at the bottom of this post generates a leaderboard 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 + 3 (-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:
Haskell, <s>40</s> 39 bytes

foldl(\s c->s++[c|filter(==c)s<=[c]])""

Usage example: foldl(\s c->s++[c|filter(==c)s<=[c]])"" "aaabcbccdbabdcd" -> "aabcbcdd".

Keep the next char c if the string of all cs so far are lexicographical less or equal the singleton string [c].

Edit: @xnor saved a byte by switching from list comprehension to filter. Thanks!


问:
Array Escape - get out of there
One day you awake only to find yourself caught in an array. You try to just walk out of there, taking one index at the time, but it seems there are other rules:

The array is completely filled with natural numbers.

If you find yourself on an index n, you go to the index array[n], except:

If you find yourself on an index n which is a prime number, you take array[n] steps back

Example:
You start on index 4, in this array (start index is 0):

```<code>array = [1,4,5,6,8,10,14,15,2,2,4,5,7];
-----------------^ you are here
</code>```

As the value of the field you are on is 8, you go to the index 8 as the first step. The field you land on contains the value 2. You then go to index 2 as your second step. As2is a prime number, you take 5 steps back, which is your third step. As there is no index -3, you successfully escaped the array in a total of 3 steps.

Your task is:

To write a program or function, which accepts an array and a start index as parameter, and outputs the amount of steps to escape the array. If you can't escape the array (e.g. [2,0,2] with start-index 2 => you constantly go from index 2 to 0), output a falsy value. You may use one-based indexing or zero-based indexing, but please specify which you use.

Test cases

Input: [2,5,6,8,1,2,3], 3

Output: 1

Input: [2, 0, 2], 2

Output: false

Input: [14,1,2,5,1,3,51,5,12,3,4,41,15,4,12,243,51,2,14,51,12,11], 5;

Output: 6

The shortest answer wins.

答:
CJam, 44 bytes

Expects index array on the stack.

```<code>:G\{_G,,&{G=_L#)0{_L+:L;_mp3T?-F}?}L,?}:F~o@
</code>```

Try it online!

My first CJam answer, hence why it's so terrible and imperative...

```<code>:G\{_G,,&{G=_L#)0{_L+:L;_mp3T?-F}?}L,?}:F~o@
:G                                              Store the array as G
  \                                             Put the index first
   {                                  }:F~      The recursive F function
     G,,                                        Generate a 0..length(G) sequence
    _   &                            ?          Check that the index is contained
         {                        }             If so, then...
          G=                                    Get the value at the index
            _L#)                 ?              If the value is in L (`-1)` gives `0` which is falsy)
                0                               Return 0 (infinite loop)
                 {              }               Otherwise...
                  _L+:L;                        Store the value we're accessing in L (infinite loop check)
                        _mp3T?-                 Remove 3 if the number is prime
                               F                Then recursively call F
                                   L,           We escaped! Return the size of "L" (number of steps)
                                          o     Print the top value of the stack
                                           @    Tries to swap 3 elements, which will error out
</code>```

(it is considered okay to crash after the correct output as printed, which is what the program here does)

Title: Array Escape - get out of there

Body:
CJam, 44 bytes

Expects index array on the stack.

:G\{_G,,&{G=_L#)0{_L+:L;_mp3T?-F}?}L,?}:F~o@

Try it online!

My first CJam answer, hence why it's so terrible and imperative...

:G\{_G,,&{G=_L#)0{_L+:L;_mp3T?-F}?}L,?}:F~o@
:G                                              Store the array as G
  \                                             Put the index first
   {                                  }:F~      The recursive F function
     G,,                                        Generate a 0..length(G) sequence
    _   &                            ?          Check that the index is contained
         {                        }             If so, then...
          G=                                    Get the value at the index
            _L#)                 ?              If the value is in L (`-1)` gives `0` which is falsy)
                0                               Return 0 (infinite loop)
                 {              }               Otherwise...
                  _L+:L;                        Store the value we're accessing in L (infinite loop check)
                        _mp3T?-                 Remove 3 if the number is prime
                               F                Then recursively call F
                                   L,           We escaped! Return the size of "L" (number of steps)
                                          o     Print the top value of the stack
                                           @    Tries to swap 3 elements, which will error out

(it is considered okay to crash after the correct output as printed, which is what the program here does)


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

This was a good one! Didn't win but it was fun

```<code>n=>{a={};return _.From(n).Where(x=>{b=a[x]?a[x]++:a[x]=1;return b<2}).Write("")}
</code>```

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

Code explanation: Method accepts a string, library parses it as a char array, and the Where clause is a complex filtering predicate that checks the 'a' hashmap for presence of the current char. If exists, increment counter, else set to 1. If < 2, the predicate (and current char) passes, else fail

Title: Detriplicate a string

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

This was a good one! Didn't win but it was fun

n=>{a={};return _.From(n).Where(x=>{b=a[x]?a[x]++:a[x]=1;return b<2}).Write("")}

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

Code explanation: Method accepts a string, library parses it as a char array, and the Where clause is a complex filtering predicate that checks the 'a' hashmap for presence of the current char. If exists, increment counter, else set to 1. If < 2, the predicate (and current char) passes, else fail


问:
1, 2, Fizz, 4, Buzz

Introduction

In our recent effort to collect catalogues of shortest solutions for standard programming exercises, here is PPCG's first ever vanilla FizzBuzz challenge. If you wish to see other catalogue challenges, there is "Hello World!" and "Is this number a prime?".

Challenge

Write a program that prints the decimal numbers from 1 to 100 inclusive. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

Output

The output will be a list of numbers (and Fizzes, Buzzes and FizzBuzzes) separated by a newline (either \n or \r\n). A trailing newline is acceptable, but a leading newline is not.  Apart from your choice of newline, the output should look exactly like this:

```<code>1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Fizz
22
23
Fizz
Buzz
26
Fizz
28
29
FizzBuzz
31
32
Fizz
34
Buzz
Fizz
37
38
Fizz
Buzz
41
Fizz
43
44
FizzBuzz
46
47
Fizz
49
Buzz
Fizz
52
53
Fizz
Buzz
56
Fizz
58
59
FizzBuzz
61
62
Fizz
64
Buzz
Fizz
67
68
Fizz
Buzz
71
Fizz
73
74
FizzBuzz
76
77
Fizz
79
Buzz
Fizz
82
83
Fizz
Buzz
86
Fizz
88
89
FizzBuzz
91
92
Fizz
94
Buzz
Fizz
97
98
Fizz
Buzz
</code>```

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.

Further Rules

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

Submissions are 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.

Nothing can be printed to STDERR.

Feel free to use a language (or language version) even if it's newer than this challenge. If anyone wants to abuse this by creating a language where the empty program generates FizzBuzz output, then congrats for paving the way for a very boring answer.

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

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

Because the output is fixed, you may hardcode the output (but this may not be the shortest option).

You may use preexisting solutions, as long as you credit the original author of the program.

Standard loopholes are otherwise disallowed.

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.

Catalogue

var QUESTION_ID=58615;var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk";var OVERRIDE_USER=30525;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.toLowerCase(),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>b.lang_raw)return 1;if(a.lang_raw<b.lang_raw)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:700}table td{padding:5px}</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 (using external library) (90 bytes)

```<code>x=>_.Range(1,100).Select(x=>x%3==0?(x%5==0?"FizzBuzz":"Fizz"):x%5==0?"Buzz":x).WriteLine()
</code>```

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

Code explanation: Creates a range starting at 1 and extending 100 elements. Select maps the item according to the predicate. First check if divisible by 3, if so check if divisible by 5. If so, select "FizzBuzz", else select "Fizz". Otherwise,check if divisible by 5. If so, select "Buzz", else just select the number. WriteLine is built into the library, and it writes each element on its own line

Title: 1, 2, Fizz, 4, Buzz

Body:
JavaScript (using external library) (90 bytes)

x=>_.Range(1,100).Select(x=>x%3==0?(x%5==0?"FizzBuzz":"Fizz"):x%5==0?"Buzz":x).WriteLine()

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

Code explanation: Creates a range starting at 1 and extending 100 elements. Select maps the item according to the predicate. First check if divisible by 3, if so check if divisible by 5. If so, select "FizzBuzz", else select "Fizz". Otherwise,check if divisible by 5. If so, select "Buzz", else just select the number. WriteLine is built into the library, and it writes each element on its own line


答:
Mathematica, 39 bytes

```<code>Fold[If[Count@##<2,Append@##,#]&,{},#]&
</code>```

Anonymous function. Takes a character list as input, and returns the detriplicated list as output. Uses the method of folding over the list and rejecting triplicate elements, it's not too complicated.

Title: Detriplicate a string

Body:
Mathematica, 39 bytes

Fold[If[Count@##<2,Append@##,#]&,{},#]&

Anonymous function. Takes a character list as input, and returns the detriplicated list as output. Uses the method of folding over the list and rejecting triplicate elements, it's not too complicated.


问:
Output a Magical 8 Trapezium
Your task is to output a Magical 8 Trapezium:

```<code>        1 × 8 + 1 = 9
       12 × 8 + 2 = 98
      123 × 8 + 3 = 987
     1234 × 8 + 4 = 9876
    12345 × 8 + 5 = 98765
   123456 × 8 + 6 = 987654
  1234567 × 8 + 7 = 9876543
 12345678 × 8 + 8 = 98765432
123456789 × 8 + 9 = 987654321
</code>```

Output in your chosen language in the fewest bytes possible.

Note the number of spaces at the start of each line to maintain the trapezium shape.

Trailing spaces are allowed.

You can use × or the letter x - whichever you prefer.

答:
CJam, <s>39</s> <s>38</s> 36 bytes

Thanks to Optimizer for saving 2 bytes.

```<code>9{)_,:)9Se[" x 8 + "@S'=S9_,fm4$<N}/
</code>```

Test it here.

Same byte count:

```<code>9{)_,:)9Se[]"x8+"+:\'=9_,f-Y$<]S*n}/
</code>```

This requires the latest version, available on Try it online!

Title: Output a Magical 8 Trapezium

Body:
CJam, <s>39</s> <s>38</s> 36 bytes

Thanks to Optimizer for saving 2 bytes.

9{)_,:)9Se[" x 8 + "@S'=S9_,fm4$<N}/

Test it here.

Same byte count:

9{)_,:)9Se[]"x8+"+:\'=9_,f-Y$<]S*n}/

This requires the latest version, available on Try it online!


答:
PowerShell v2+, <s>85</s> <s>64</s> <s>58</s> <s>57</s> 52 bytes

```<code>8..0|%{" "*$_+-join(1..++$i+" x 8 + $i = "+9..++$_)}
</code>```

Loops from 8 to 0 8..0|%{...} via the range operator. Each iteration, we output a string concatenation consisting of (the appropriate number of spaces " "*$_), plus a -joined string of (a range from 1 to a pre-incremented helper number ++$i, plus the middle bit " x 8 + $i = ", plus the final range from 9 to the current number $_ pre-incremented).

One big trick here is we leverage the "left-preference" for typecasting, which allows us to "add" arrays together inside the -join parens, meaning we use only one -join operator.

Example

```<code>PS C:\Tools\Scripts\golfing> .\magical-8-trapezium.ps1
        1 x 8 + 1 = 9
       12 x 8 + 2 = 98
      123 x 8 + 3 = 987
     1234 x 8 + 4 = 9876
    12345 x 8 + 5 = 98765
   123456 x 8 + 6 = 987654
  1234567 x 8 + 7 = 9876543
 12345678 x 8 + 8 = 98765432
123456789 x 8 + 9 = 987654321
</code>```

Title: Output a Magical 8 Trapezium

Body:
Your task is to output a Magical 8 Trapezium:

```<code>        1 × 8 + 1 = 9
       12 × 8 + 2 = 98
      123 × 8 + 3 = 987
     1234 × 8 + 4 = 9876
    12345 × 8 + 5 = 98765
   123456 × 8 + 6 = 987654
  1234567 × 8 + 7 = 9876543
 12345678 × 8 + 8 = 98765432
123456789 × 8 + 9 = 987654321
</code>```

Output in your chosen language in the fewest bytes possible.

Note the number of spaces at the start of each line to maintain the trapezium shape.

Trailing spaces are allowed.

You can use × or the letter x - whichever you prefer.

Body:
PowerShell v2+, <s>85</s> <s>64</s> <s>58</s> <s>57</s> 52 bytes

8..0|%{" "*$_+-join(1..++$i+" x 8 + $i = "+9..++$_)}

Loops from 8 to 0 8..0|%{...} via the range operator. Each iteration, we output a string concatenation consisting of (the appropriate number of spaces " "*$_), plus a -joined string of (a range from 1 to a pre-incremented helper number ++$i, plus the middle bit " x 8 + $i = ", plus the final range from 9 to the current number $_ pre-incremented).

One big trick here is we leverage the "left-preference" for typecasting, which allows us to "add" arrays together inside the -join parens, meaning we use only one -join operator.

Example

PS C:\Tools\Scripts\golfing> .\magical-8-trapezium.ps1
        1 x 8 + 1 = 9
       12 x 8 + 2 = 98
      123 x 8 + 3 = 987
     1234 x 8 + 4 = 9876
    12345 x 8 + 5 = 98765
   123456 x 8 + 6 = 987654
  1234567 x 8 + 7 = 9876543
 12345678 x 8 + 8 = 98765432
123456789 x 8 + 9 = 987654321


答:
Haskell, 92 bytes

```<code>s=(show=<<)
[1..9]>>= \x->([x..8]>>" ")++s[1..x]++" x 8 + "++s[x]++" = "++s[9,8..10-x]++"\n"
</code>```

How it works:

```<code>s=(show=<<)                   -- helper function that turns a list of numbers into
                              -- a string without delimiters, e.g. [1,2] -> "12"

[1..9]>>=                     -- for each number 1 to 9
     ([x..8]>>" ")            -- take length of [x..8] copies of a space
     s[1..x]                  -- the digits from 1 to x
     " x 8 + "                -- a string literal
     s[x]                     -- the digit of x
     " = "                    -- another string literal
     s[9,8..10-x]             -- the digits from 9 down to 10-x
     "\n"                     -- an a newline
</code>```

Title: Output a Magical 8 Trapezium

Body:
Haskell, 92 bytes

s=(show=<<)
[1..9]>>= \x->([x..8]>>" ")++s[1..x]++" x 8 + "++s[x]++" = "++s[9,8..10-x]++"\n"

How it works:

s=(show=<<)                   -- helper function that turns a list of numbers into
                              -- a string without delimiters, e.g. [1,2] -> "12"

[1..9]>>=                     -- for each number 1 to 9
     ([x..8]>>" ")            -- take length of [x..8] copies of a space
     s[1..x]                  -- the digits from 1 to x
     " x 8 + "                -- a string literal
     s[x]                     -- the digit of x
     " = "                    -- another string literal
     s[9,8..10-x]             -- the digits from 9 down to 10-x
     "\n"                     -- an a newline


答:
JavaScript (ES6), 99 bytes

```<code>_=>[...Array(9)].map((n,i)=>`${n="        123456789".substr(i,9)} x 8 + ${++i} = ${n*8+i}`).join`\n`
_=>".........".replace(/./g,(n,i)=>`${n="        123456789".substr(i,9)} x 8 + ${++i) = ${n*8+i}\n`)
</code>```

Where \n represents a literal newline character. The second version outputs a trailing newline. I came up with a formula for the numbers ('1'.repeat(9-i)+0+i)/9 but the padding was easier to do this way.

Title: Output a Magical 8 Trapezium

Body:
JavaScript (ES6), 99 bytes

_=>[...Array(9)].map((n,i)=>`${n="        123456789".substr(i,9)} x 8 + ${++i} = ${n*8+i}`).join`\n`
_=>".........".replace(/./g,(n,i)=>`${n="        123456789".substr(i,9)} x 8 + ${++i) = ${n*8+i}\n`)

Where \n represents a literal newline character. The second version outputs a trailing newline. I came up with a formula for the numbers ('1'.repeat(9-i)+0+i)/9 but the padding was easier to do this way.


Title: Output a Magical 8 Trapezium

Body:
Pyke, <s>30</s> 29 bytes

9Fd*~utj+9<\x8\+9i-\=ji>_dJ)X

Try it here!

9F                         )  -  for i in range(9):
  d*                          -       " " * i
        +                     -      ^ + V
       j                      -       j = V
    ~ut                       -        "123456789"
         9<                   -     ^[:9]
           \x8\+9i-\=         -    [^, "x", 8, "+", (9-i), "=", V]
                        _     -     reversed(V)
                     ji>      -      j[i:]
                         dJ   -   " ".join(^)
                            X - print(reversed(^))


答:
Retina, 66 bytes

Byte count assumes ISO 8859-1 encoding. The leading linefeed is significant.

```<code>
123456789!9 = 987654321
+`^((.)+)\B.!.(.+).
 $1!$2$3¶$&
!
 x 8 +
</code>```

Try it online!

Title: Output a Magical 8 Trapezium

Body:
Retina, 66 bytes

Byte count assumes ISO 8859-1 encoding. The leading linefeed is significant.

123456789!9 = 987654321
+`^((.)+)\B.!.(.+).
 $1!$2$3¶$&
!
 x 8 +

Try it online!


答:
Pyth, 32 bytes

```<code>VS9ss[*dK-9NSN" x 8 + "N" = "r9K
</code>```

Try it online!

```<code>VS9ss[*dK-9NSN" x 8 + "N" = "r9K
VS9                                  # For N in 1..9
   s                                 # Join without delimiter
    s[                               # Reduce the array on + (flattens)
      *dK-9N                         # - Space, repeated K=(9-N) times
            SN                       # - The string sequence 1..N
              " x 8 + "              # - This string literal
                       N             # - N itself
                        " = "        # - This string literal
                             r9K     # - The string sequence 9..K
</code>```

Thanks to @FryAmTheEggman for saving 2 bytes.
Thanks to @KennyLau for saving 3 bytes.

Title: Output a Magical 8 Trapezium

Body:
Pyth, 32 bytes

VS9ss[*dK-9NSN" x 8 + "N" = "r9K

Try it online!

VS9ss[*dK-9NSN" x 8 + "N" = "r9K
VS9                                  # For N in 1..9
   s                                 # Join without delimiter
    s[                               # Reduce the array on + (flattens)
      *dK-9N                         # - Space, repeated K=(9-N) times
            SN                       # - The string sequence 1..N
              " x 8 + "              # - This string literal
                       N             # - N itself
                        " = "        # - This string literal
                             r9K     # - The string sequence 9..K

Thanks to @FryAmTheEggman for saving 2 bytes.
Thanks to @KennyLau for saving 3 bytes.


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

```

答:
Maple, 233 bytes

Added (unnecessary) newlines for code readability:

```<code>seq(printf("%d %s of beer on the wall,\n%d %s of beer.\nTake one down, pass it around,\n%d %s of beer on the wall.\n\n",
         i,`if`(i<>1,"bottles","bottle"),
         i,`if`(i<>1,"bottles","bottle"),
         i-1,`if`(i-1<>1,"bottles","bottle")),
i=99..1,-1);
</code>```

Title: "99 Bottles of Beer"

Body:
Maple, 233 bytes

Added (unnecessary) newlines for code readability:

seq(printf("%d %s of beer on the wall,\n%d %s of beer.\nTake one down, pass it around,\n%d %s of beer on the wall.\n\n",
         i,`if`(i<>1,"bottles","bottle"),
         i,`if`(i<>1,"bottles","bottle"),
         i-1,`if`(i-1<>1,"bottles","bottle")),
i=99..1,-1);


Title: Output a Magical 8 Trapezium

Body:
V, 37 bytes

i¸ 1 X 8 + 1 = 98ñYp|Eylp^Xf+$ylp

Try it online!

This contains unprintable, so here is a hexdump:

00000000: 69c2 b820 3120 5820 3820 2b20 3120 3d20  i.. 1 X 8 + 1 =
00000010: 391b 38c3 b159 707c 4579 6c70 015e 5866  9.8..Yp|Eylp.^Xf
00000020: 2b01 2479 6c70 18                        +.$ylp.


答:
05AB1E, 32 bytes

```<code>ï[U¯Xåi0,q}²gL<Xå_#X²XèXDˆpi-]¯g
</code>```

Explanation

```<code>ï                                 # explicitly convert input to int
 [                            ]   # infinite loop
  U                               # store current index in X
   ¯Xåi0,q}                       # if we've already been at this index, print 0 and exit
           ²gL<Xå_#               # if we've escaped, break out of infinite loop
                   X²XèXDˆpi-     # else calculate new index
                               ¯g # print nr of indices traversed
</code>```

Try it online

Title: Array Escape - get out of there

Body:
One day you awake only to find yourself caught in an array. You try to just walk out of there, taking one index at the time, but it seems there are other rules:

The array is completely filled with natural numbers.

If you find yourself on an index n, you go to the index array[n], except:

If you find yourself on an index n which is a prime number, you take array[n] steps back

Example:
You start on index 4, in this array (start index is 0):

```<code>array = [1,4,5,6,8,10,14,15,2,2,4,5,7];
-----------------^ you are here
</code>```

As the value of the field you are on is 8, you go to the index 8 as the first step. The field you land on contains the value 2. You then go to index 2 as your second step. As2is a prime number, you take 5 steps back, which is your third step. As there is no index -3, you successfully escaped the array in a total of 3 steps.

Your task is:

To write a program or function, which accepts an array and a start index as parameter, and outputs the amount of steps to escape the array. If you can't escape the array (e.g. [2,0,2] with start-index 2 => you constantly go from index 2 to 0), output a falsy value. You may use one-based indexing or zero-based indexing, but please specify which you use.

Test cases

Input: [2,5,6,8,1,2,3], 3

Output: 1

Input: [2, 0, 2], 2

Output: false

Input: [14,1,2,5,1,3,51,5,12,3,4,41,15,4,12,243,51,2,14,51,12,11], 5;

Output: 6

The shortest answer wins.

Body:
05AB1E, 32 bytes

ï[U¯Xåi0,q}²gL<Xå_#X²XèXDˆpi-]¯g

Explanation

ï                                 # explicitly convert input to int
 [                            ]   # infinite loop
  U                               # store current index in X
   ¯Xåi0,q}                       # if we've already been at this index, print 0 and exit
           ²gL<Xå_#               # if we've escaped, break out of infinite loop
                   X²XèXDˆpi-     # else calculate new index
                               ¯g # print nr of indices traversed

Try it online


问:
Add two numbers
Input: Two integers. Preferably decimal integers, but other forms of numbers can be used. These can be given to the code in standard input, as arguments to the program or function, or as a list.

Output: Their sum. Use the same format for output integers as input integers. For example, the input 5 16 would lead to the output 21.

Restrictions: No standard loopholes please. This is code-golf, answer in lowest amount of bytes wins.

Notes: This should be fairly trivial, however I'm interested to see how it can be implemented. The answer can be a complete program or a function, but please identify which one it is.

Test cases:

```<code>1 2 -> 3
14 15 -> 29
7 9 -> 16
-1 8 -> 7
8 -9 -> -1
-8 -9 -> -17
</code>```

Or as CSV:

```<code>a,b,c
1,2,3
14,15,29
7,9,16
-1,8,7
8,-9,-1
-8,-9,-17
</code>```

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Title: Add two numbers

Body:
Maple, 3 bytes

`+`

Usage:

> `+`(1,2)
  3


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

Title: Count up folks!

Body:
Maple, 9 bytes

seq(1..n)

Usage:

> seq(1..10);
1, 2, 3, 4, 5, 6, 7, 8, 9, 10


答:
05AB1E, 12 bytes

```<code>vyˆ¯y¢O3‹iy?
</code>```

Explanation

```<code>v            # for each char in input
 yˆ          # push to global array
   ¯y¢O3‹i   # if nr of occurrences are less than 3
          y? # print it
</code>```

Try it online

Title: Detriplicate a string

Body:
A lot of languages have built-in ways to get rid of duplicates, or "deduplicate" or "uniquify" a list or string. A less common task is to "detriplicate" a string. That is, for every character that appears, the first two occurrences are kept.

Here is an example where the characters that should be deleted are labelled with ^:

```<code>aaabcbccdbabdcd
  ^    ^ ^^^ ^^
aabcbcdd
</code>```

Your task is to implement exactly this operation.

Rules

Input is a single, possibly empty, string. You may assume that it only contains lowercase letters in the ASCII range.

Output should be a single string with all characters removed which have already appeared at least twice in the string (so the left-most two occurrences are kept).

Instead of strings you may work with lists of characters (or singleton strings), but the format has to be consistent between input and output.

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

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

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

Test Cases

Every pair of lines is one test case, input followed by output.

```<code>

xxxxx
xx
abcabc
abcabc
abcdabcaba
abcdabc
abacbadcba
abacbdc
aaabcbccdbabdcd
aabcbcdd
</code>```

Leaderboard

The Stack Snippet at the bottom of this post generates a leaderboard 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 + 3 (-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:
05AB1E, 12 bytes

vyˆ¯y¢O3‹iy?

Explanation

v            # for each char in input
 yˆ          # push to global array
   ¯y¢O3‹i   # if nr of occurrences are less than 3
          y? # print it

Try it online


答:
Python 2, <s>87</s> <s>84</s> <s>78</s> 75 bytes

s="123456789"
n=1
exec'print"%9s"%s[:n],"x 8 + %s ="%n,s[::-1][:n];n+=1;'*9
```
<p><strong>Try it online</strong></p>
<p>A previous version uses some string magic.</p>
<pre class="lang-python prettyprint-override"><code>R=range(1,10)
for n in R:print" "*(9-n)+`R`[1:n*3:3]+" x 8 + %d = "%n+`R`[-2:27-3*n:-3]
</code>```

Casting range(1,10) to a string gives [1, 2, 3, 4, 5, 6, 7, 8, 9], and this is nice since every number is only a single digit. So getting the string 123456789 from this is simple with `range(1,10)`[1::3]. The reversed range is  `range(1,10)`[-2::-3]. Then, to get only as far as I want each iteration, I slice it off at either 3*n, or at 3*(9-n) (27-3*n) for the reversed digits.

Title: Output a Magical 8 Trapezium

Body:
Python 2, <s>87</s> <s>84</s> <s>78</s> 75 bytes

s="123456789"
n=1
exec'print"%9s"%s[:n],"x 8 + %s ="%n,s[::-1][:n];n+=1;'*9

Try it online

A previous version uses some string magic.

R=range(1,10)
for n in R:print" "*(9-n)+`R`[1:n*3:3]+" x 8 + %d = "%n+`R`[-2:27-3*n:-3]

Casting range(1,10) to a string gives [1, 2, 3, 4, 5, 6, 7, 8, 9], and this is nice since every number is only a single digit. So getting the string 123456789 from this is simple with `range(1,10)`[1::3]. The reversed range is  `range(1,10)`[-2::-3]. Then, to get only as far as I want each iteration, I slice it off at either 3*n, or at 3*(9-n) (27-3*n) for the reversed digits.


问:
Fibonacci function or sequence
The Fibonacci sequence is a sequence of numbers, where every number in the sequence is the sum of the two numbers preceding it.  The first two numbers in the sequence are both 1. Here are the first few terms:

```<code>1 1 2 3 5 8 13 21 34 55 89 ...
</code>```

Write the shortest code that either:

Generates the Fibonacci sequence without end.

Given n calculates the nth term of the sequence. (Either 1 or zero indexed)

You may use standard forms of input and output.

(I gave both options in case one is easier to do in your chosen language than the other.)

For the function that takes an n, a reasonably large return value (the largest Fibonacci number that fits your computer's normal word size, at a minimum) has to be supported.

Leaderboard

/* Configuration */

var QUESTION_ID = 85; // 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 = 3; // 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: 290px;
  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

```

Title: Fibonacci function or sequence

Body:
Maple, 27 bytes

ifelse(n<3,1,f(n-1)+f(n-2))

Usage:

> f := n -> ifelse(n<3,1,f(n-1)+f(n-2));
> f(2);
  1
> f(3);
  2


问:
Golf the Subset-Sum Problem

Task

Given a list of space-delimited integers as input, output all unique non-empty subsets of these numbers that each subset sums to 0.

Test Case

Input:  8 −7 5 −3 −2

Output: -3 -2 5

Winning Criterion

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

答:
Mathematica 62 57 38

Code

Input entered as integers in an array, x.

```<code>x
</code>```

```<code>Grid@Select[Subsets@x[[1, 1]], Tr@# == 0 &]
</code>```

Output

Explanation

x[[1, 1]] converts the input to a list of integers.

Subsets generates all subsets from the integers.

Select....Tr@# == 0 gives all those subsets that have a total equal to 0.

Grid formats the selected subsets as space-separated integers.

Title: Golf the Subset-Sum Problem

Body:
Mathematica 62 57 38

Code

Input entered as integers in an array, x.

x

Grid@Select[Subsets@x[[1, 1]], Tr@# == 0 &]

Output

Explanation

x[[1, 1]] converts the input to a list of integers.

Subsets generates all subsets from the integers.

Select....Tr@# == 0 gives all those subsets that have a total equal to 0.

Grid formats the selected subsets as space-separated integers.


答:
Ruby, <s>77</s> <s>73</s> <s>65</s> 60 bytes

Try it online~

Major revamps from @manatwork

Another overhaul from @xsot

```<code>a=i=0;9.times{puts"%9d x 8 + %d = %d"%[a=a*10+i+=1,i,a*8+i]}
</code>```

Title: Output a Magical 8 Trapezium

Body:
Your task is to output a Magical 8 Trapezium:

```<code>        1 × 8 + 1 = 9
       12 × 8 + 2 = 98
      123 × 8 + 3 = 987
     1234 × 8 + 4 = 9876
    12345 × 8 + 5 = 98765
   123456 × 8 + 6 = 987654
  1234567 × 8 + 7 = 9876543
 12345678 × 8 + 8 = 98765432
123456789 × 8 + 9 = 987654321
</code>```

Output in your chosen language in the fewest bytes possible.

Note the number of spaces at the start of each line to maintain the trapezium shape.

Trailing spaces are allowed.

You can use × or the letter x - whichever you prefer.

Body:
Ruby, <s>77</s> <s>73</s> <s>65</s> 60 bytes

Try it online~

Major revamps from @manatwork

Another overhaul from @xsot

a=i=0;9.times{puts"%9d x 8 + %d = %d"%[a=a*10+i+=1,i,a*8+i]}


答:
05AB1E, <s>32</s> <s>31</s> <s>30</s> 28 bytes

Code:

```<code>TG9N-ð×NLJðN"x8+ÿ="€ðJžmN£J,
</code>```

Uses the CP-1252 encoding. Try it online!.

Title: Output a Magical 8 Trapezium

Body:
05AB1E, <s>32</s> <s>31</s> <s>30</s> 28 bytes

Code:

TG9N-ð×NLJðN"x8+ÿ="€ðJžmN£J,

Uses the CP-1252 encoding. Try it online!.


答:
C, 121 bytes

Function f accepts array, starting index (0-based) and number of elements in the array, since there is no way how to test the end of an array in C (at least I don't know any).

```<code>p(n,i,z){return--i?p(n,i,z*i*i%n):z%n;}c;f(a,i,n)int*a;{return i<0||i/n?c:c++>n?0:i&&p(i,i,1)?f(a,i-a[i],n):f(a,a[i],n);}
</code>```

Try it on ideone!

Note: function p(n) tests if n is prime or not. Credit for this goes to @Lynn and his answer for Is this number a prime?

Title: Array Escape - get out of there

Body:
C, 121 bytes

Function f accepts array, starting index (0-based) and number of elements in the array, since there is no way how to test the end of an array in C (at least I don't know any).

p(n,i,z){return--i?p(n,i,z*i*i%n):z%n;}c;f(a,i,n)int*a;{return i<0||i/n?c:c++>n?0:i&&p(i,i,1)?f(a,i-a[i],n):f(a,a[i],n);}

Try it on ideone!

Note: function p(n) tests if n is prime or not. Credit for this goes to @Lynn and his answer for Is this number a prime?


问:
Can Mario go to the end of this map
Create a program that determines, given an input of the path, whether Mario can reach the end, denoted by E, from the start, denoted by S.

A path will look something like this:

```<code>S = E
=====
</code>```

In a path, the various symbols and what they represent are:

=: wall/floor/ceiling. Mario cannot walk through wall , and cannot fall past a floor, or jump past a ceiling (he would hit his head)

  (space): air. Mario can walk through this, and jump through it, and fall through it

S: air, except showing where Mario starts. This will always appear in the left-most column of the input, at ground level.

E: air, except showing where Mario wants to get. This will always appear in the right-most column of the input, at ground level.

The input will have spaces at every place where Mario could walk.

Mario can only move forward; in this example Mario cannot get to the goal

```<code>S
===

 ===
   E
====
</code>```

nor can he in this one

```<code>    E
   ==
==
  #==
==
   ==
==
S  ==
======
</code>```

However, he can reach the space denoted by # (which will not appear in input), because he can jump up to four cells high; Mario is superhuman. As another example of his superhumanity:

```<code>S
=
=
=
=
=
= #
= =
=
=
=
=     E
=======
</code>```

Mario can get to the E by falling the great distance, surviving, and walking calmly to E. Note that he cannot reach the #, because Mario falls straight down.

Mario can jump really high, but not very far forward by comparison.

```<code>S   E
== ==
 = =
</code>```

Mario may attempt to jump the gap, but he will fail, and fall straight in. he cannot reach the end.

Mario can reach the goal in all of these examples:

```<code> E
 =
 =
 =
S=
==
</code>```

```<code> =
 =   E
S=   =
==   =
 =   =
 =====
</code>```

```<code>S
=

=  E
====
</code>```

This is code golf, so fewest bytes wins!

答:
PHP, <s>399</s> <s>338</s> <s>284</s> <s>265</s> 251 bytes

```<code><?function w($m,$p){$w=strpos($m,"
")+1;if($p>strlen($m)|($p%$w)>$w-2|$p<0|'='==$m[$p])return 0;if('E'==$m[$p])die(1);if('='!=$m[$p+$w])return w($m,$p+$w);else for(;$z<5&'='!=$m[$q=$p-$w*$z];$z++)if(w($m,$q+1))die(1);}die(w($m=$argv[1],strpos($m,S)));
</code>```

expects input as command line argument with unix style line breaks and trailing spaces in every line, returns exit code 1 for success, 0 for failure

breakdown to function

```<code>function w($m,$p) // function walk
{
    $w=strpos($m,"\n")+1;
    if($p<0|$p>strlen($m)|($p%$w)>$w-2  // too high / too low / too far right
        | '='==$m[$p]                   // or inside a wall
    )return 0;
    if('E'==$m[$p])return 1;            // Exit found
    if('='!=$m[$p+$w])return w($m,$p+$w); // no wall below: fall down
    else for($z=0;$z<5                  // else: jump
        & '='!=$m[$q=$p-$w*$z]          // do not jump through walls
        ;$z++)
        if(w($m,$q+1))                  // try to walk on from there
            return 1;
    // no success, return failure (NULL)
}
function m($i){$argv=[__FILE__,$i];
    return w($m=$argv[1],strpos($m,S));     // walk through map starting at position of S
}
</code>```

tests (on function m)

```<code>$cases=[
    // examples
    "S = E\n=====",0,
    "S   \n=== \n    \n ===\n   E\n====",0,
    "    E \n   == \n==    \n   == \n==    \n   == \n==    \nS  == \n======",0,
    "S      \n=      \n=      \n=      \n=      \n=      \n=      \n= =    \n=      \n=      \n=      \n=     E\n=======",1,
    "S   E\n== ==\n = = ",0,
    " E\n =\n =\n =\nS=\n==",1,
    "      \n =    \n =   E\nS=   =\n==   =\n =   =\n =====",1,
    "S   \n=   \n    \n    \n    \n    \n    \n    \n=  E\n====",1,
    // additional cases
    "S \n= \n=E",1,
    " == \n == \n    \nS==E\n==  ",1
];
echo'<table border=1><tr><th>input</th><th>output</th><th>expected</th><th>ok?</th></tr>';
while($cases)
{
    $m=array_shift($cases);
    $e=array_shift($cases);
    $y=m($m);
    $w=strpos($m,"\n");
    echo"<tr><td><div style=background-color:yellow;width:",$w*8,"px>```$m```</div>width=$w</td>
        <td>$y</td><td>$e</td><td>",$e-$y?'N':'Y',"</td></tr>";
}
echo'</table>';
</code>```

Title: Can Mario go to the end of this map

Body:
PHP, <s>399</s> <s>338</s> <s>284</s> <s>265</s> 251 bytes

<?function w($m,$p){$w=strpos($m,"
")+1;if($p>strlen($m)|($p%$w)>$w-2|$p<0|'='==$m[$p])return 0;if('E'==$m[$p])die(1);if('='!=$m[$p+$w])return w($m,$p+$w);else for(;$z<5&'='!=$m[$q=$p-$w*$z];$z++)if(w($m,$q+1))die(1);}die(w($m=$argv[1],strpos($m,S)));

expects input as command line argument with unix style line breaks and trailing spaces in every line, returns exit code 1 for success, 0 for failure

breakdown to function

function w($m,$p) // function walk
{
    $w=strpos($m,"\n")+1;
    if($p<0|$p>strlen($m)|($p%$w)>$w-2  // too high / too low / too far right
        | '='==$m[$p]                   // or inside a wall
    )return 0;
    if('E'==$m[$p])return 1;            // Exit found
    if('='!=$m[$p+$w])return w($m,$p+$w); // no wall below: fall down
    else for($z=0;$z<5                  // else: jump
        & '='!=$m[$q=$p-$w*$z]          // do not jump through walls
        ;$z++)
        if(w($m,$q+1))                  // try to walk on from there
            return 1;
    // no success, return failure (NULL)
}
function m($i){$argv=[__FILE__,$i];
    return w($m=$argv[1],strpos($m,S));     // walk through map starting at position of S
}

tests (on function m)

$cases=[
    // examples
    "S = E\n=====",0,
    "S   \n=== \n    \n ===\n   E\n====",0,
    "    E \n   == \n==    \n   == \n==    \n   == \n==    \nS  == \n======",0,
    "S      \n=      \n=      \n=      \n=      \n=      \n=      \n= =    \n=      \n=      \n=      \n=     E\n=======",1,
    "S   E\n== ==\n = = ",0,
    " E\n =\n =\n =\nS=\n==",1,
    "      \n =    \n =   E\nS=   =\n==   =\n =   =\n =====",1,
    "S   \n=   \n    \n    \n    \n    \n    \n    \n=  E\n====",1,
    // additional cases
    "S \n= \n=E",1,
    " == \n == \n    \nS==E\n==  ",1
];
echo'<table border=1><tr><th>input</th><th>output</th><th>expected</th><th>ok?</th></tr>';
while($cases)
{
    $m=array_shift($cases);
    $e=array_shift($cases);
    $y=m($m);
    $w=strpos($m,"\n");
    echo"<tr><td><div style=background-color:yellow;width:",$w*8,"px><pre>$m</pre></div>width=$w</td>
        <td>$y</td><td>$e</td><td>",$e-$y?'N':'Y',"</td></tr>";
}
echo'</table>';


答:
Python, 107 bytes

```<code>import sympy
f=lambda a,i,n=0:0if n>len(a)else f(a,[a[i],i-a[i]][sympy.isprime(i)],n+1)if 0<=i<len(a)else n
</code>```

Usage: f(list, start) ex: f([2,5,6,8,1,2,3], 3)

Returns 0 for loops (detected when n > len(a))

Title: Array Escape - get out of there

Body:
Python, 107 bytes

import sympy
f=lambda a,i,n=0:0if n>len(a)else f(a,[a[i],i-a[i]][sympy.isprime(i)],n+1)if 0<=i<len(a)else n

Usage: f(list, start) ex: f([2,5,6,8,1,2,3], 3)

Returns 0 for loops (detected when n > len(a))


Title: Array Escape - get out of there

Body:
JavaScript, <s>121</s> 132 bytes

p=n=>t=i=>n%i&&n>i?t(i+1):(0<n&&n<=i?1:0),c=-1,a=>r=s=>(++c,0<=s&&s<a.length?(p(s)(2)?r(s-a[s]):0||([a[s],s]=[0,a[s]])[1]?r(s):0):c)

f=(p=n=>t=i=>n%i&&n>i?t(i+1):(0<n&&n<=i?1:0),c=-1,a=>r=s=>(++c,0<=s&&s<a.length?(p(s)(2)?r(s-a[s]):0||([a[s],s]=[0,a[s]])[1]?r(s):0):c));

let test_data = [[[1,4,5,6,8,10,14,15,2,2,4,5,7],4],
                 [[2,5,6,8,1,2,3],3],
                 [[2,0,2],2],
                 [[14,1,2,5,1,3,51,5,12,3,4,41,15,4,12,243,51,2,14,51,12,11],5]];
for (test of test_data) {
    c = -1;
    console.log(f(test[0])(test[1]));
}

edit 1: oops, missed the bit about returning number of steps. fix coming soonish.

edit 2: fixed


答:
Python (<s>128 137</s> 136)

Damn you, itertools.permutations, for having such a long name!

Brute force solution. I'm surprised it's not the shortest: but I guess itertools ruins the solution.

Ungolfed:

```<code>import itertools
initial_set=map(int, input().split())
ans=[]
for length in range(1, len(x)+1):
    for subset in itertools.permutations(initial_set, length):
        if sum(subset)==0:
            ans+=str(sorted(subset))
print set(ans)
</code>```

Golfed (ugly output):

```<code>from itertools import*
x=map(int,input().split())
print set(`sorted(j)`for a in range(1,len(x)+1)for j in permutations(x,a)if sum(j)==0)
</code>```

Golfed (pretty output) (183):

```<code>from itertools import*
x=map(int,input().split())
print `set(`sorted(j)`[1:-1]for a in range(1,len(x)+1)for j in permutations(x,a)if sum(j)==0)`[5:-2].replace("'","\n").replace(",","")
</code>```

import itertools as i: importing the itertools module and calling it i

x=map(int,input().split()): seperates the input by spaces, then turns the resulting lists' items into integers (2 3 -5 -> [2, 3, -5])

set(sorted(j)for a in range(1,len(x)+1)for j in i.permutations(x,a)if sum(j)==0):

Returns a list of all subsets in x, sorted, where the sum is 0, and then gets only the unique items

(set(...))

The graves (`) around sorted(j) is Python shorthand for repr(sorted(j)). The reason why this is here is because sets in Python cannot handle lists, so the next best thing is to use strings with a list as the text.

Title: Golf the Subset-Sum Problem

Body:
Task

Given a list of space-delimited integers as input, output all unique non-empty subsets of these numbers that each subset sums to 0.

Test Case

Input:  8 −7 5 −3 −2

Output: -3 -2 5

Winning Criterion

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

Body:
Python (<s>128 137</s> 136)

Damn you, itertools.permutations, for having such a long name!

Brute force solution. I'm surprised it's not the shortest: but I guess itertools ruins the solution.

Ungolfed:

import itertools
initial_set=map(int, input().split())
ans=[]
for length in range(1, len(x)+1):
    for subset in itertools.permutations(initial_set, length):
        if sum(subset)==0:
            ans+=str(sorted(subset))
print set(ans)

Golfed (ugly output):

from itertools import*
x=map(int,input().split())
print set(`sorted(j)`for a in range(1,len(x)+1)for j in permutations(x,a)if sum(j)==0)

Golfed (pretty output) (183):

from itertools import*
x=map(int,input().split())
print `set(`sorted(j)`[1:-1]for a in range(1,len(x)+1)for j in permutations(x,a)if sum(j)==0)`[5:-2].replace("'","\n").replace(",","")

import itertools as i: importing the itertools module and calling it i

x=map(int,input().split()): seperates the input by spaces, then turns the resulting lists' items into integers (2 3 -5 -> [2, 3, -5])

set(sorted(j)for a in range(1,len(x)+1)for j in i.permutations(x,a)if sum(j)==0):

Returns a list of all subsets in x, sorted, where the sum is 0, and then gets only the unique items

(set(...))

The graves (`) around sorted(j) is Python shorthand for repr(sorted(j)). The reason why this is here is because sets in Python cannot handle lists, so the next best thing is to use strings with a list as the text.


问:
Divisibility test

Task

Given two strictly positive integers n and d as input, determine whether n is evenly divisible by d, i.e., if there exists an integer q such that n = qd.

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

The output should be a truthy or a falsy value; truthy if n is divisible by d, and falsy otherwise.

Your code only has to handle integers it can represent natively, as long as it works for all signed 8-bit integers. However, your algorithm has to work for arbitrarily large integers.

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

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

Test cases

```<code> n,  d    output

 1,  1    truthy
 2,  1    truthy
 6,  3    truthy
17, 17    truthy
22,  2    truthy
 1,  2    falsy
 2,  3    falsy
 2,  4    falsy
 3,  9    falsy
15, 16    falsy
</code>```

Leaderboard

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

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

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

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

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

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

```<code>## Perl, 43 + 3 (-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

```

答:
Brain-Flak, <s>88</s> 86 bytes

```<code>(<({}<>)>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}<>(({}<{}>)){{}{}(<(())>)}{}
</code>```

This is a denser version of the original Brain-Flak divisibility test algorithm written by <s>Dr Green Eggs and Iron Man</s> DJMcMayhem and myself.

Here is a brief(ish) explanation of how it works:

```<code>  ({}<>)        #Move the top of the stack to the other stack #Start Mod
(<      >)      #Push zero
<>              #Switch stacks
{               #While the top of the stack is not zero
 ({}[()])       #Subtract one from the top of the stack
 <>             #Switch stacks
   {}()         #Pop the top, add one and ...
       [({})]   #Subtract the second element on the stack
 ((          )) #Push twice
 {              #If the top is not zero
  {}            #Pop the duplicate
    ({}({}))    #Add the second element to the first
  (<        >)  #Push zero
 }              #End if
 {}             #Pop the zero
 <>             #Switch back
}               #End While
<>              #Switch to the other stack
 ({}<{}>)       #Remove the second value on the stack         #End Mod
(        )      #Duplicate the result of modulation
{               #If the top is not zero
 {}{}           #Pop the top two elements
 (<(())>)       #Push a one and a zero
}               #End if
{}              #Pop the zero
</code>```

Try it Online!

Title: Divisibility test

Body:
Brain-Flak, <s>88</s> 86 bytes

(<({}<>)>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}<>(({}<{}>)){{}{}(<(())>)}{}

This is a denser version of the original Brain-Flak divisibility test algorithm written by <s>Dr Green Eggs and Iron Man</s> DJMcMayhem and myself.

Here is a brief(ish) explanation of how it works:

  ({}<>)        #Move the top of the stack to the other stack #Start Mod
(<      >)      #Push zero
<>              #Switch stacks
{               #While the top of the stack is not zero
 ({}[()])       #Subtract one from the top of the stack
 <>             #Switch stacks
   {}()         #Pop the top, add one and ...
       [({})]   #Subtract the second element on the stack
 ((          )) #Push twice
 {              #If the top is not zero
  {}            #Pop the duplicate
    ({}({}))    #Add the second element to the first
  (<        >)  #Push zero
 }              #End if
 {}             #Pop the zero
 <>             #Switch back
}               #End While
<>              #Switch to the other stack
 ({}<{}>)       #Remove the second value on the stack         #End Mod
(        )      #Duplicate the result of modulation
{               #If the top is not zero
 {}{}           #Pop the top two elements
 (<(())>)       #Push a one and a zero
}               #End if
{}              #Pop the zero

Try it Online!


Title: Output a Magical 8 Trapezium

Body:
MATL, <s>38</s> <s>36</s> 35 bytes

9:"9@-Z"@:!V' x 8 + '@VO61O58@:-v!D

Try it online!