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

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

The Rules

Each submission must be a full program.

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

The program must not write anything to STDERR.

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

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

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

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

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

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

For inspiration, check the Hello World Collection.

The Catalogue

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

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

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

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

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

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

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

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

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

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

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

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

    var lang = a.language;
    lang = jQuery(''+lang+'').text();

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

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

  langs.sort(function (a, b) {
    if (a.lang_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;
    if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) return -1;
    return 0;
  });

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
INTERCALL, 311 bytes

```<code>INTERCALL IS A ANTIGOLFING LANGUAGE
SO THIS HEADER IS HERE TO PREVENT GOLFING IN INTERCALL
THE PROGRAM STARTS HERE:
PUSH LXXII
PRINT
PUSH CI
PRINT
PUSH CVIII
PRINT
PRINT
PUSH CXI
PRINT
PUSH XLIV
PRINT
PUSH XXXII
PRINT
PUSH LXXXVII
PRINT
CALL ONE VII
PUSH CXIV
PRINT
CALL ONE V
PUSH C
PRINT
PUSH XXXIII
PRINT
END
</code>```

It can probably be more golfed, but coding in INTERCALL is very hard.

CALL ONE jump to a line, execute it and return to the line after the calling line.

Title: "Hello, World!"

Body:
INTERCALL, 311 bytes

INTERCALL IS A ANTIGOLFING LANGUAGE
SO THIS HEADER IS HERE TO PREVENT GOLFING IN INTERCALL
THE PROGRAM STARTS HERE:
PUSH LXXII
PRINT
PUSH CI
PRINT
PUSH CVIII
PRINT
PRINT
PUSH CXI
PRINT
PUSH XLIV
PRINT
PUSH XXXII
PRINT
PUSH LXXXVII
PRINT
CALL ONE VII
PUSH CXIV
PRINT
CALL ONE V
PUSH C
PRINT
PUSH XXXIII
PRINT
END

It can probably be more golfed, but coding in INTERCALL is very hard.

CALL ONE jump to a line, execute it and return to the line after the calling line.


问:
Return the integers with square digit-sums

Introduction and Credit

We all know and love our awesome rules to test whether a number is divisble by 11 or 3, which is just some clever sum over the digits of the number. Now this challenge takes this to a new level, by requiring you to compute the sum of the digits and then checking whether the result is a perfect integer square, neither of which operations usually can be done very short. As this property is also very hard to see when looking at a number, we want this to be done for entire lists of numbers so we can save human work. So this is your challenge now!

This was an assignment at my university functional programming course. This assignment is now closed and has been discussed in class and I have my professor's permission to post it here (I asked explicitely).

Specification

Input

Your input is a list of non-negative integers, in any standard I/O format.

You may choose the list format as your language needs it

Output

The output is a list of integers, in any standard I/O format.

What to do?

Filter out every integer from the input list for which the sum of the digits is not a a square (of an integer).

The order of the elements may not be changed, e.g. if you get [1,5,9] you may not return [9,1]

Potential corner cases

0 is a non-negative integer and thus a valid input and 0 is also a valid integer root, e.g. 0 counts as an integer square.

The empty list is a valid input and output as well.

Who wins?

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

Standard rules apply of course.

Test Cases

```<code>[1,4,9,16,25,1111] -> [1,4,9,1111]
[1431,2,0,22,999999999] -> [1431,0,22,999999999]
[22228,4,113125,22345] -> [22228,4,22345]
[] -> []
[421337,99,123456789,1133557799] -> []
</code>```

Step-by-Step Example

```<code>Example input: [1337,4444]
Handling first number:
Sum of the digits of 1337: 1+3+3+7=14
14 is not an integer square, thus will be dropped!
Handling second number:
Sum of the digits of 4444: 4+4+4+4=16
16 is an integer square because 4*4=16, can get into the output list!
Example output: [4444]
</code>```

答:
Mathematica, <s>39</s> 36 bytes

An anonymous function:

```<code>Select[AtomQ@√Tr@IntegerDigits@#&]
</code>```

LLlAMnYP saved a byte. Thank you!

Martin Ender saved three more by replacing IntegerQ with AtomQ. Clever! (The result of √ will be exact, so it returns a compound expression like Sqrt[5] if its argument isn’t a square.)

ContentLicense: CC BY-SA 3.0

Body:
Mathematica, <s>39</s> 36 bytes

An anonymous function:

Select[AtomQ@√Tr@IntegerDigits@#&]

LLlAMnYP saved a byte. Thank you!

Martin Ender saved three more by replacing IntegerQ with AtomQ. Clever! (The result of √ will be exact, so it returns a compound expression like Sqrt[5] if its argument isn’t a square.)


问:
I'm not the language you're looking for!
Isn't it annoying when you find a piece of code and you don't know what language it was written in? This challenge attempts to somewhat solve this.

Challenge

You will have to write a program that when run in two different languages, will output the string:

This program wasn't written in <language program compiled/interpreted in>, it was built for <other language the program can be run in>!

In the output, language names should have official capitalization. eg: CJam, C++

Neither program should take any input from the user.

When run in both languages, output should be to stdout or equivalent.

There should be no output to stderr in either program.

You may use comments in either language.

Two different versions of the same language count as different languages.

If this is done, the program should output the major version number, and if running on two different minor versions, should report the minor version also.

You should not use prebuilt version functions (this includes variables that have already been evaluated at runtime).

Example output:

Perl and Ruby:

Perl: This program wasn't written in Perl, it was built for Ruby!

Ruby: This program wasn't written in Ruby, it was built for Perl!

Python and C:

Python: This program wasn't written in Python, it was built for C!

C: This program wasn't written in C, it was built for Python!

Python 2 and Python 3:

Python 2: This program wasn't written in Python 2, it was built for Python 3!

Python 3: This program wasn't written in Python 3, it was built for Python 2!

Python 2.4 and Python 2.7:

Python 2.4: This program wasn't written in Python 2.4, it was built for Python 2.7!

Python 2.7: This program wasn't written in Python 2.7, it was built for Python 2.4!

This is code golf so the shortest code in bytes wins.

答:
Javascript ES6, ES5 <s>131</s> 127 bytes

I just thought I post this for fun

```<code>"This program wasn't written in "+((c=eval("try{let a=0}catch(e){1}"))?"ES5":"ES6")+", it was built for "+(c?"ES6":"ES5")+"!"
</code>```

The main part of the code is this:

```<code>try{d.join``;0}catch(e){1}
</code>```

If the version of javascript is ES5, this returns 1, because d.join`` throws an error.

Body:
Javascript ES6, ES5 <s>131</s> 127 bytes

I just thought I post this for fun

"This program wasn't written in "+((c=eval("try{let a=0}catch(e){1}"))?"ES5":"ES6")+", it was built for "+(c?"ES6":"ES5")+"!"

The main part of the code is this:

try{d.join``;0}catch(e){1}

If the version of javascript is ES5, this returns 1, because d.join`` throws an error.


答:
Julia - 38 bytes

```<code>!X=filter(i->√sum(digits(i))%1==0,X)
</code>```

It's pretty easy to see what this does. digits converts a number into a list of its digits, sum thus calculates the digit-sum, √ will then produce a whole number if the number is a square, otherwise there will be a fractional part. %1 will return only the fractional part, and if it's zero (==0), filter will keep it on the list, otherwise it gets filtered out.

Used as ![22228,4,113125,22345]

Title: Return the integers with square digit-sums

Body:
Introduction and Credit

We all know and love our awesome rules to test whether a number is divisble by 11 or 3, which is just some clever sum over the digits of the number. Now this challenge takes this to a new level, by requiring you to compute the sum of the digits and then checking whether the result is a perfect integer square, neither of which operations usually can be done very short. As this property is also very hard to see when looking at a number, we want this to be done for entire lists of numbers so we can save human work. So this is your challenge now!

This was an assignment at my university functional programming course. This assignment is now closed and has been discussed in class and I have my professor's permission to post it here (I asked explicitely).

Specification

Input

Your input is a list of non-negative integers, in any standard I/O format.

You may choose the list format as your language needs it

Output

The output is a list of integers, in any standard I/O format.

What to do?

Filter out every integer from the input list for which the sum of the digits is not a a square (of an integer).

The order of the elements may not be changed, e.g. if you get [1,5,9] you may not return [9,1]

Potential corner cases

0 is a non-negative integer and thus a valid input and 0 is also a valid integer root, e.g. 0 counts as an integer square.

The empty list is a valid input and output as well.

Who wins?

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

Standard rules apply of course.

Test Cases

```<code>[1,4,9,16,25,1111] -> [1,4,9,1111]
[1431,2,0,22,999999999] -> [1431,0,22,999999999]
[22228,4,113125,22345] -> [22228,4,22345]
[] -> []
[421337,99,123456789,1133557799] -> []
</code>```

Step-by-Step Example

```<code>Example input: [1337,4444]
Handling first number:
Sum of the digits of 1337: 1+3+3+7=14
14 is not an integer square, thus will be dropped!
Handling second number:
Sum of the digits of 4444: 4+4+4+4=16
16 is an integer square because 4*4=16, can get into the output list!
Example output: [4444]
</code>```

Body:
Julia - 38 bytes

!X=filter(i->√sum(digits(i))%1==0,X)

It's pretty easy to see what this does. digits converts a number into a list of its digits, sum thus calculates the digit-sum, √ will then produce a whole number if the number is a square, otherwise there will be a fractional part. %1 will return only the fractional part, and if it's zero (==0), filter will keep it on the list, otherwise it gets filtered out.

Used as ![22228,4,113125,22345]


问:
Pseudofactorial
There is a rather curious number which shows up sometimes in math problems or riddles. The pseudofactorial(N) is the least (i.e. lowest) common multiple of the numbers 1 through N; in other words, it's the lowest number which has all numbers from 1 through N as factors.

For instance pseudofactorial(7) = 3 * 4 * 5 * 7, which is the same as 7! except that 2 and 6 have been removed because they are contained in other terms.

Write a program to calculate pseudofactorial(N) and as always, shortest code wins.

Here is a short list for your use. More test cases can be found in the OEIS under A003418.

Factorial:

1

2

6

24

120

720

5040

Pseudofactorial:

1

2

6

12

60

60

420

答:
Pyke, 3 bytes

```<code>S.L
</code>```

Try it here!

```<code>S   - range(1, input+1)
 .L - lowest_common_multiple(^)
</code>```

Title: Pseudofactorial

Body:
Pyke, 3 bytes

S.L

Try it here!

S   - range(1, input+1)
 .L - lowest_common_multiple(^)

ContentLicense: CC BY-SA 4.0


答:
Python 2, 53 bytes

lambda x:[n for n in x if sum(map(int,`n`))**.5%1==0]
```

Test it on Ideone.

Body:
Python 2, 53 bytes

lambda x:[n for n in x if sum(map(int,`n`))**.5%1==0]

Test it on Ideone.


答:
Jolf, 8 bytes

Try it here!

```<code>ψxd!iUuH
</code>```

Explanation

```<code>ψxd!iUuH
ψxd       filter the input according to the input
      uH  digit sum of H (element)
     U    sqrt of
   !i     is an integer?
</code>```

Body:
Jolf, 8 bytes

Try it here!

ψxd!iUuH

Explanation

ψxd!iUuH
ψxd       filter the input according to the input
      uH  digit sum of H (element)
     U    sqrt of
   !i     is an integer?


问:
Count sum of all digits
This challenge is to write a program or script which counts the sum of all digits within the integers from 1 up to and including a given number.

Input, one positive integer.
Output, the sum of digits in that number and all smaller numbers.

Examples:

```<code>Input: 5
Integer Sequence: 1, 2, 3, 4, 5
Sum of Digits: 1 + 2 + 3 + 4 + 5 = 15

Input: 12
Integer Sequence: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
Sum of Digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 1 + 0 + 1 + 1 + 1 + 2 = 51
</code>```

To be clear, this is to count a sum of the digits - not the integers. For single-digit inputs, this will be the same. However, inputs larger than 10 will have different responses. This would be an incorrect response:

```<code>Input: 12
Output: 78
</code>```

Another example, to show the difference:

```<code>Input: 10

Integer Sequence: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Sum of Integers (INCORRECT RESPONSE): 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55

Digit Sequence: 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0
Sum of Digits (CORRECT RESPONSE): 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 1 + 0 = 46
</code>```

A larger test case (CORRECT RESPONSE):

```<code>Input: 1000000
Output: 27000001
</code>```

Rules & Guidelines:

Submitted code must be a complete program or script - not just a function. If the code requires includes, imports, etc., they must be included in the posted code.

The number must be input by the user - not hard-coded. Input may be received as a command-line argument, file, stdin, or any other means by which your language can take user input.

The code must be able to properly handle inputs at least up to (2^64)-1.

The code should only output the sum.

Submitted programs & scripts should be user-friendly and not wasteful of computer resources (e.g.: they should not declare insanely-large arrays to hold every character). There is no strict bonus or penalty for this, but please be good programmers.

Scoring:

Primary scoring mechanism is by code length. Lower scores are better. The following bonuses and penalties also apply:

-25 Bonus if your code can handle all positive numbers, for example: 1234567891234567891234564789087414984894900000000

-50 Bonus if your code can handle simple expressions, for example 55*96-12. To qualify for this bonus, the code should handle + - / * (addition, subtraction, division, multiplication) operators and enforce order of operations. Division is regular integer division.

The given example (55*96-12) evaluates to 5268. Your code should return the same for either of those inputs - correct answer is 81393.

-10 Bonus if your code qualifies for the -50 bonus and can handle the ^ (exponent) operator.

-100 Bonus if your code qualifies for the -50 bonus and does not use eval or similar to handle expressions.

+300 Penalty if your code relies upon any web resources.

答:
PHP, 110

```<code>$a=$argv[1];$b='0';do{$b=bcadd($b,(string)array_sum(str_split($a,1)));}while(($a=bcadd($a,-1))!='0');echo $b;
</code>```

PHP is certainly not the easiest language for this, but the standard library has some nice stuff inside. The code relying on bcmath to do the job of working with very large numbers, and on two functions for string splitting and summing the contents of an array. It is certainly going to run with very large numbers, but that's gonna take some time (2 minutes 9 seconds for the number 100000000).

Here's an ungolfed version:

```<code>$a = $argv[1];
$b = '0';

do {
    $b = bcadd($b, (string) array_sum(str_split($a, 1)));
}
while(($a = bcadd($a, -1)) != '0');

echo $b;
</code>```

And here's another shorter version (68 bytes), but this one is going to work only until an integer overflow occurs.

```<code>$a=$b=$argv[1];while($a--){$b.=$a;}echo array_sum(str_split($b,1));
</code>```

P.S: Yes, I'm a necromancer, so feel free to burn me at the stake :)

Title: Count sum of all digits

Body:
PHP, 110

$a=$argv[1];$b='0';do{$b=bcadd($b,(string)array_sum(str_split($a,1)));}while(($a=bcadd($a,-1))!='0');echo $b;

PHP is certainly not the easiest language for this, but the standard library has some nice stuff inside. The code relying on bcmath to do the job of working with very large numbers, and on two functions for string splitting and summing the contents of an array. It is certainly going to run with very large numbers, but that's gonna take some time (2 minutes 9 seconds for the number 100000000).

Here's an ungolfed version:

$a = $argv[1];
$b = '0';

do {
    $b = bcadd($b, (string) array_sum(str_split($a, 1)));
}
while(($a = bcadd($a, -1)) != '0');

echo $b;

And here's another shorter version (68 bytes), but this one is going to work only until an integer overflow occurs.

$a=$b=$argv[1];while($a--){$b.=$a;}echo array_sum(str_split($b,1));

P.S: Yes, I'm a necromancer, so feel free to burn me at the stake :)


答:
MATLAB, <s>52</s> <s>43</s> 42 bytes

```<code>@(x)x(~mod(sum(dec2base(x,10)'-48).^.5,1))
</code>```

Creates an anonymous function named ans that can be called with an array as input: ans([22228,4,113125,22345]).

Online Demo. The online demo is in Octave which doesn't work for the empty input, but MATLAB does.

Explanation

We convert each element in the input array to base 10 which will yield a 2D character array where each row contains the digits of a number in the array. To convert these characters to numbers, we subtract 48 (ASCII for '0'). We then sum across the rows, take the square root, and determine whether each value is a perfect square ~mod 1. We then use this boolean to filter the input array.

Body:
MATLAB, <s>52</s> <s>43</s> 42 bytes

@(x)x(~mod(sum(dec2base(x,10)'-48).^.5,1))

Creates an anonymous function named ans that can be called with an array as input: ans([22228,4,113125,22345]).

Online Demo. The online demo is in Octave which doesn't work for the empty input, but MATLAB does.

Explanation

We convert each element in the input array to base 10 which will yield a 2D character array where each row contains the digits of a number in the array. To convert these characters to numbers, we subtract 48 (ASCII for '0'). We then sum across the rows, take the square root, and determine whether each value is a perfect square ~mod 1. We then use this boolean to filter the input array.


问:
Alex-style Addition
Inspired by Alex's glorious Learn you an R for great good, we are going to humbly recreate Alex's "one true R program" -- but with a twist.

Alex-style Addition works like this -- it has a 90% chance of simply returning the sum of the two numbers given and a 10% chance of recursively Alex-adding the first number and the second number + 1. This means that, potentially, an addition could be off by 1 or more.

Challenge

Write a full program or function that takes two integers and Alex-adds them as defined. You may assume that your program will not stack overflow if your language doesn't have tail recursion. (Note that you do not have to implement it recursively, as long as the probabilities are the same.)

Reference Implementation (Groovy)

```<code>int alexAdd(int a, int b) {
  int i = new Random().nextInt(11);
  if(i == 1) {
    return alexAdd(a,b+1);
  } else {
    return a + b;
  }
}
</code>```

Try this fiddle online.

Leaderboard

var QUESTION_ID=66522,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

```

答:
Jelly, 7 bytes

```<code>‘⁵XỊ¤¿+
</code>```

Try it online!

How it works

```<code>‘⁵XỊ¤¿+  Main link. Arguments: n, m (integers)

    ¤    Combine the three atoms to the left into a niladic chain.
 ⁵       Yield 10.
  X      Pseudo-randomly generate a positive integer not greater than 10.
   Ị     Insignificant; test if the generated integer is 1 (or less).
     ¿   While chain yields 1:
‘          Increment n.
      +  Add m to the result.
</code>```

Title: Alex-style Addition

Body:
Jelly, 7 bytes

‘⁵XỊ¤¿+

Try it online!

How it works

‘⁵XỊ¤¿+  Main link. Arguments: n, m (integers)

    ¤    Combine the three atoms to the left into a niladic chain.
 ⁵       Yield 10.
  X      Pseudo-randomly generate a positive integer not greater than 10.
   Ị     Insignificant; test if the generated integer is 1 (or less).
     ¿   While chain yields 1:
‘          Increment n.
      +  Add m to the result.


问:
Sum It Up with a Digital Triangle
Well, sum it down really.

Write a program or function that takes in a nonempty list of decimal integers (0-9) and outputs a downward pointing "triangle" of digits with the input list at the top where every digit after the first line is the sum of the two digits above it modulo 10.

For example, the input [7, 5, 0, 9] has output

```<code>7 5 0 9
 2 5 9
  7 4
   1
</code>```

because 2 is (7 + 5) mod 10, 5 is (5 + 0) mod 10, 9 is (0 + 9) mod 10, etc. all the way to 1 being (7 + 4) mod 10.

If the list has only one item, then the output matches the input; e.g. an input of [4] will yield

```<code>4
</code>```

Here are some additional examples:

```<code>[0]

0

[1, 2]

1 2
 3

[8, 7]

8 7
 5

[0, 0]

0 0
 0

[1, 4, 2]

1 4 2
 5 6
  1

[0, 1, 0]

0 1 0
 1 1
  2

[1, 0, 0, 0]

1 0 0 0
 1 0 0
  1 0
   1

[1, 2, 3, 4]

1 2 3 4
 3 5 7
  8 2
   0

[1, 2, 3, 5, 8]

1 2 3 5 8
 3 5 8 3
  8 3 1
   1 4
    5

[9, 2, 4, 5, 3, 2, 2]

9 2 4 5 3 2 2
 1 6 9 8 5 4
  7 5 7 3 9
   2 2 0 2
    4 2 2
     6 4
      0
</code>```

Note that in the output:

The first line does not have leading spaces.

Each subsequent line has one more leading space than the line previous.

Digits are separated by a single space.

Each line is allowed to have up to one trailing space.

There may be a single optional trailing newline.

You must use the characters for normal decimal digits (0 through 9).

The shortest code in bytes wins. Tiebreaker is earlier answer.

Title: Sum It Up with a Digital Triangle

Body:
C, 138 bytes

Golfed

c,d;main(int a,char**b){b++;while(c++,d=0,--a)while(d<a)printf("%*c%c",!d?c:1,*b[d],(d+2>a)*10),++d<a?*b[d-1]=(*b[d-1]+*b[d]-96)%10+48:0;}

Ungolfed

c,d;
main(int a,char**b){
b++;
while(c++,d=0,--a)
    while(d<a)
        printf("%*c%c",
          !d?c:1,      //number of blanks in front of digit
          *b[d],       //digit
          (d+2>a)*10), //returns 10(new line) only for d+1 == a
        ++d<a
          ? *b[d-1]=(*b[d-1]+*b[d]-96)%10+48 //update digit
          :  0;
}


答:
Perl 5, 42 bytes

41, plus 1 for -pe instead of -e

```<code>my$s;map$s+=$_,/./g;$_ x=sqrt$s==~~sqrt$s
</code>```

Explanation:

-p gets each input integer on a new line and assigns $_ to that string.

my$s initializes the variable $s to nothing, anew for each input integer.

map$s+=$_,/./g grabs each numeric character and numerically adds it to $s. (The newline becomes 0 when numified.)

sqrt$s==~~sqrt$s tests whether $s has a nonintegral square root, and $_ x= makes $_ into itself or the empty string depending on that test.

-p prints $_

Thanks to Brad Gilbert b2gills for saving three bytes.

Also 41 plus 1:

```<code>my$s;s/./$s+=$&/ger;$_ x=sqrt$s==~~sqrt$s
</code>```

s/./$s+=$&/ger adds each numeric character to $s (and the newline is 0 as above)

Body:
Perl 5, 42 bytes

41, plus 1 for -pe instead of -e

my$s;map$s+=$_,/./g;$_ x=sqrt$s==~~sqrt$s

Explanation:

-p gets each input integer on a new line and assigns $_ to that string.

my$s initializes the variable $s to nothing, anew for each input integer.

map$s+=$_,/./g grabs each numeric character and numerically adds it to $s. (The newline becomes 0 when numified.)

sqrt$s==~~sqrt$s tests whether $s has a nonintegral square root, and $_ x= makes $_ into itself or the empty string depending on that test.

-p prints $_

Thanks to Brad Gilbert b2gills for saving three bytes.

Also 41 plus 1:

my$s;s/./$s+=$&/ger;$_ x=sqrt$s==~~sqrt$s

s/./$s+=$&/ger adds each numeric character to $s (and the newline is 0 as above)


问:
Don't google "google"
We all know that if you google the word "google" it will break the internet.

Your task is to create a function that accepts one string and returns its length, in the fewest possible Unicode characters.

However, if the given string is google (lowercase), it will cause an error.

For example, g('bing') will return 4 but g('google') will cause an error.

Please provide an example of usage, and the error if possible.

答:
Java, <s>84</s> <s>68</s> 37 bytes

```<code>b->b.equals("google")?1/0:b.length();
</code>```

This is a java.util.function.Function<String, Integer> that divides by 0 if b is the string google.

Title: Don't google "google"

Body:
Java, <s>84</s> <s>68</s> 37 bytes

b->b.equals("google")?1/0:b.length();

This is a java.util.function.Function<String, Integer> that divides by 0 if b is the string google.


问:
Check if a pattern appears in a DNA sequence
In a project I am working on, I am checking to see if certain DNA sequences appear in certain genes in E. coli. I have written a program in Java that performs the below features. However, since I wrote my program in Java, the universe needs to be corrected and rid of verbosity by having you write your code in as few bytes as possible.

My program took a DNA sequences and a regex as input (for this challenge, order doesn't matter). The DNA sequence contains only the letters A, C, G, and T. It will be determined if the DNA sequence contains any subsequences that follow the regex, and the output of the program will be the one-indexed location(s) of the first character of each matching subsequence in the DNA sequence in your choice of format. If there is no such location, you may output any reasonable indicator of this.

The regex I used had the following specifications.

A, C, G, and T match to themselves.

N matches to any of A, C, G, and T

(X/Y) means that at the current location in the sequence, the next character(s) in the sequence match X or Y (note that X and Y can be multiple characters long, and that there can be multiple slashes; for example, (AA/AG/GA) matches to AA, AG or GG; however, X and Y must have the same length)

You may assume that the DNA sequence is longer than any sequence that follows the specifications of the regex, and that both the DNA and the regex are valid.

Test cases

Here, the DNA sequence is first, and the regex is second.

```<code>AAAAAAAAAA
AAA
==> 1 2 3 4 5 6 7 8

ACGTAATGAA
A(A/C)(T/G/A)
==> 1 5

GGGGCAGCAGCTGACTA
C(NA/AN)
==> 5 8 15

ACGTTAGTTAGCGTGATCGTG
CGTNA
==> 2 12
</code>```

This is code-golf. The shortest answer in bytes wins. Standard rules apply.

答:
Python 3, 125 bytes

```<code>import re,sys
a=sys.argv
s=re.sub
print([i+1 for i in range(len(a[1]))if re.match(s('N','[ACGT]',s('/','|',a[2])),a[1][i:])])
</code>```

Body:
Python 3, 125 bytes

import re,sys
a=sys.argv
s=re.sub
print([i+1 for i in range(len(a[1]))if re.match(s('N','[ACGT]',s('/','|',a[2])),a[1][i:])])


Body:
Javascript, 61 <s>65</s>

f=
a=>a.filter(x=>(r=Math.sqrt(eval([...`${x}`].join`+`)))==~~r)

j=JSON.stringify;
console.log([
[1,4,9,16,25,1111],
[1431,2,0,22,999999999],
[22228,4,113125,22345],
[],
[421337,99,123456789,1133557799]
].map(x=>j(x)+' -> '+j(f(x))).join`
`)


答:
C, 143 141 bytes

 saved 2 bytes, @user6188402

i;q(char*n){double m=0;while(*n)m+=*n++-48;m=sqrt(m)-(int)sqrt(m);return !m;}s(n,s)char**n;{i=-1;while(++i<s)if(q(n[i]))printf("%s\n",n[i]);}
```

<p><strong>Ungolfed</strong> try online</p>

<pre class="lang-C prettyprint-override"><code>int q(char*n)
{
    double m=0;

    while(*n) // sum digits
        m+=*n++-48;

    // get the decimal part of its square root
    m=sqrt(m)-(int)sqrt(m);

    // true if decimal part is zero
    return !m;
}

// input is text, can be a file
void s(char**n, int s)
{
    int i=-1;

    while(++i<s) // for each number in input
        if(q(n[i])) // if is square
            printf("%s\n",n[i]); // output is terminal
}
</code>```

Body:
C, 143 141 bytes

 saved 2 bytes, @user6188402

i;q(char*n){double m=0;while(*n)m+=*n++-48;m=sqrt(m)-(int)sqrt(m);return !m;}s(n,s)char**n;{i=-1;while(++i<s)if(q(n[i]))printf("%s\n",n[i]);}

Ungolfed try online

int q(char*n)
{
    double m=0;

    while(*n) // sum digits
        m+=*n++-48;

    // get the decimal part of its square root
    m=sqrt(m)-(int)sqrt(m);

    // true if decimal part is zero
    return !m;
}

// input is text, can be a file
void s(char**n, int s)
{
    int i=-1;

    while(++i<s) // for each number in input
        if(q(n[i])) // if is square
            printf("%s\n",n[i]); // output is terminal
}


答:
Clojure, 110 bytes

```<code>(fn[t](filter(fn[x](let[a(reduce +(*(count(str x))-48)(map int(str x)))](some #(=(* % %)a)(range(inc a)))))t))
</code>```

Calculates the sum of number digits and then filters out those for which there doesn't exist a number which squared is equal to the sum.

You can see the result here – https://ideone.com/ciKOje

Body:
Clojure, 110 bytes

(fn[t](filter(fn[x](let[a(reduce +(*(count(str x))-48)(map int(str x)))](some #(=(* % %)a)(range(inc a)))))t))

Calculates the sum of number digits and then filters out those for which there doesn't exist a number which squared is equal to the sum.

You can see the result here – https://ideone.com/ciKOje


问:
Approximation of e
We all know that the Euler's number, denoted by \$e\$, to the power of some variable \$x\$, can be approximated by using the Maclaurin Series expansion:

$$e^x=\sum_{k=0}^{\infty}{\frac{x^k}{k!}}=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\frac{x^4}{4!}+\dots$$

By letting \$x\$ equal \$1\$, we obtain

$$\sum_{k=0}^{\infty}{\frac{1}{k!}{=\frac{1}{0!}+\frac{1}{1!}+\frac{1}{2!}+\frac{1}{3!}+\frac{1}{4!}+\dots\\=1+1+\frac{1}{2}+\frac{1}{6}+\frac{1}{24}+\dots}}$$

Challenge

Write a program in any language which approximates Euler's number by taking in an input \$n\$ and calculates the series to the \$n\$th term. Note that the first term has denominator \$0!\$, not \$1!\$, i.e. \$n=1\$ corresponds to \$\frac{1}{0!}\$.

Scoring

Program with least amount of bytes wins.

答:
Pyth, <s>7</s> 6 bytes

```<code>smc1.!
</code>```

Try it here.

```<code> m      map over range 0..input:
    .!  factorial
  c1    1 / ^
s       sum
</code>```

Thanks to FryAmTheEggman for a byte!

Title: Approximation of e

Body:
Pyth, <s>7</s> 6 bytes

smc1.!

Try it here.

 m      map over range 0..input:
    .!  factorial
  c1    1 / ^
s       sum

Thanks to FryAmTheEggman for a byte!


答:
MATL, <s>11</s> 7 bytes

```<code>:Ygl_^s
</code>```

4 bytes saved thanks to @Luis's recommendation to use gamma (Yg)

Try it Online

Explanation

```<code>        % Implicitly grab input (N)
:       % Create an array from 1...N
Yg      % Compute factorial(x-1) for each element (x) in the array
l_^     % Take the inverse
s       % Sum all elements
        % Implicitly display the result
</code>```

Title: Approximation of e

Body:
We all know that the Euler's number, denoted by \$e\$, to the power of some variable \$x\$, can be approximated by using the Maclaurin Series expansion:

$$e^x=\sum_{k=0}^{\infty}{\frac{x^k}{k!}}=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\frac{x^4}{4!}+\dots$$

By letting \$x\$ equal \$1\$, we obtain

$$\sum_{k=0}^{\infty}{\frac{1}{k!}{=\frac{1}{0!}+\frac{1}{1!}+\frac{1}{2!}+\frac{1}{3!}+\frac{1}{4!}+\dots\\=1+1+\frac{1}{2}+\frac{1}{6}+\frac{1}{24}+\dots}}$$

Challenge

Write a program in any language which approximates Euler's number by taking in an input \$n\$ and calculates the series to the \$n\$th term. Note that the first term has denominator \$0!\$, not \$1!\$, i.e. \$n=1\$ corresponds to \$\frac{1}{0!}\$.

Scoring

Program with least amount of bytes wins.

Body:
MATL, <s>11</s> 7 bytes

:Ygl_^s

4 bytes saved thanks to @Luis's recommendation to use gamma (Yg)

Try it Online

Explanation

        % Implicitly grab input (N)
:       % Create an array from 1...N
Yg      % Compute factorial(x-1) for each element (x) in the array
l_^     % Take the inverse
s       % Sum all elements
        % Implicitly display the result


答:
Pyke, 10 bytes

```<code>FSBQi^R/)s
</code>```

Try it here!

Or 8 bytes if power=1

```<code>FSB1R/)s
</code>```

Try it here!

Title: Approximation of e

Body:
Pyke, 10 bytes

FSBQi^R/)s

Try it here!

Or 8 bytes if power=1

FSB1R/)s

Try it here!


问:
Who's gonna win the football game?
The American football championship, Super Bowl 50, is happening today at 11:30pm UTC (and you can watch it live online). This challenge was made to celebrate it.

In an American football game, two teams compete to get the most points and there are six ways to score these points. We'll give each an abbreviation:

Field goal - FG: 3 points

Touchdown - TD: 6 points

Extra point - XP: 1 point - Can only be scored directly after a touchdown.

Two-point conversion - XD (like an extra point but happier): 2 points - Can only be scored directly after a touchdown.

Safety - S: 2 points

Fair catch kick - FCK: 3 points (a very rare play)

Write a program or function that takes in a single line string containing only these six abbreviations, in both uppercase and lowercase.

This string represents all the scoring events in a game (or portion of a game) of football, with the uppercase terms belonging to one team and the lowercase belonging to the other.

Your job is to report the final scores of the game and indicate who won with output of the form

```<code>[score 1] [to] [score 2]
</code>```

where:

[score 1] is always the larger of the two scores (if not equal), regardless of if uppercase or lowercase won.

[score 2] is the smaller of the two scores (if not equal).

[to] is TO if the uppercase team won, to if the lowercase team won, and To if it's a tie.

Example: All the scoring events in Super Bowl XLIX
  could be summarized by the string

```<code>TDXPtdxpTDXPtdxpfgtdxpTDXPTDXP
</code>```

where uppercase is the New England Patriots and lowercase is the
  Seattle Seahawks. The Patriots scored 28 and the Hawks 24, so
  the output would be:

```<code>28 TO 24
</code>```

Notes

Your program/function must support any arbitrary input, including the empty string.

XP and XD will only occur right after TD. xp and xd will only occur right after td.

You may not assume the input string starts or ends in a certain case.

A single trailing newline is optionally allowed in both the input and output

Scoring

The shortest code in bytes wins. Answers that are posted before the kickoff (too late now!) of Super Bowl 50 may predict the winning team (either Panthers or Broncos), and if they are correct, get a -10% byte bonus!

(I will check revision history to ensure predictions have not changed and really were made before kickoff.)

Test Cases

```<code>[empty string] -> 0 To 0
TDXPtdxpTDXPtdxpfgtdxpTDXPTDXP -> 28 TO 24
FG -> 3 TO 0
fg -> 3 to 0
TD -> 6 TO 0
td -> 6 to 0
TDXP -> 7 TO 0
tdxp -> 7 to 0
TDXD -> 8 TO 0
tdxd -> 8 to 0
S -> 2 TO 0
s -> 2 to 0
FCK -> 3 TO 0
fck -> 3 to 0
TDTDXDSssFCKfgfckFGtd -> 22 TO 16
fcksFCKS -> 5 To 5
tdtdtdtdxp -> 25 to 0
SSSSSSSTD -> 20 TO 0
fgSfckFGfgtdxptdxdTDs -> 26 to 11
FGTDXPtdxdtdsStdxpfgTDfckTDXDFCK -> 29 To 29
```

答:
Python, 167 bytes

The superb owl is long past, but since there isn't a Python solution yet:

```<code>def f(s):g=lambda s:0if s==""else{68:1,70:3,83:2,84:5,88:1}.get(ord(s[0]),0)+g(s[1:]);a=g(s);b=g(s.upper())-a;return"%i %s %i"%((a,("To","TO")[a>b],b),(b,"to",a))[a<b]
</code>```

Works in Python 2 or 3.

Title: Who's gonna win the football game?

Body:
Python, 167 bytes

The superb owl is long past, but since there isn't a Python solution yet:

def f(s):g=lambda s:0if s==""else{68:1,70:3,83:2,84:5,88:1}.get(ord(s[0]),0)+g(s[1:]);a=g(s);b=g(s.upper())-a;return"%i %s %i"%((a,("To","TO")[a>b],b),(b,"to",a))[a<b]

Works in Python 2 or 3.


问:
Stack Exchange Vote Counter
Write a program/function that returns the vote count of its own Stack Exchange answer at the time of its execution.

Your program/function may access this page (codegolf.stackexchange.com/questions/82609) off the internet, however:

Your program/function may not accept any user input and

The use of URL shorteners is not allowed

Your program/function may use only its own source as a reference point to its vote count (for example: no referencing strings of text in its contained answer but not in its own source)

Your program/function must output its own vote count and only its own vote count (for example: no returning all vote counts on this page)

This is code-golf, shortest code wins.

答:
jQuery + JavaScript, 85 bytes

$.get("//api.stackexchange.com/posts/82610?site=codegolf",d=>alert(d.items[0].score))```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script></code>```

History

-6 bytes because I was using the var data instead of d.

-3 bytes thanks to @msh210

-13 bytes thanks to @CᴏɴᴏʀO'Bʀɪᴇɴ

-4 bytes thanks to @user6188402

-5 bytes thanks to @Suever

-4 bytes thanks to @RobW

Recommended usage

Run snippet.

Upvote.

Run snippet, and be amazed as the number magically increases.

Bonus!!

Who doesn't like a bonus?

$.getJSON("//api.stackexchange.com/posts/" + prompt() + "?site=codegolf",d=>alert(d.items[0].score));```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script></code>```

Enter the ID into the bonus and it will tell you the score.

<s>Even more bonus!! Run this snippet to automatically run the program, upvote, and run again! (Requires rep > 15, auth). If it doesn't work, please tell me.</s>

Title: Stack Exchange Vote Counter

Body:
jQuery + JavaScript, 85 bytes

$.get("//api.stackexchange.com/posts/82610?site=codegolf",d=>alert(d.items[0].score))

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

History

-6 bytes because I was using the var data instead of d.

-3 bytes thanks to @msh210

-13 bytes thanks to @CᴏɴᴏʀO'Bʀɪᴇɴ

-4 bytes thanks to @user6188402

-5 bytes thanks to @Suever

-4 bytes thanks to @RobW

Recommended usage

Run snippet.

Upvote.

Run snippet, and be amazed as the number magically increases.

Bonus!!

Who doesn't like a bonus?

$.getJSON("//api.stackexchange.com/posts/" + prompt() + "?site=codegolf",d=>alert(d.items[0].score));

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Enter the ID into the bonus and it will tell you the score.

<s>Even more bonus!! Run this snippet to automatically run the program, upvote, and run again! (Requires rep > 15, auth). If it doesn't work, please tell me.</s>


答:
MATLAB, 103 bytes

```<code>g=@getfield;g(g(webread('http://api.stackexchange.com/2.2/posts/82611?site=codegolf'),'items'),'score')
</code>```

Title: Stack Exchange Vote Counter

Body:
Write a program/function that returns the vote count of its own Stack Exchange answer at the time of its execution.

Your program/function may access this page (codegolf.stackexchange.com/questions/82609) off the internet, however:

Your program/function may not accept any user input and

The use of URL shorteners is not allowed

Your program/function may use only its own source as a reference point to its vote count (for example: no referencing strings of text in its contained answer but not in its own source)

Your program/function must output its own vote count and only its own vote count (for example: no returning all vote counts on this page)

This is code-golf, shortest code wins.

Body:
MATLAB, 103 bytes

g=@getfield;g(g(webread('http://api.stackexchange.com/2.2/posts/82611?site=codegolf'),'items'),'score')


答:
05AB1E, <s>89</s> <s>87</s> 81 bytes

Thanks Python...

```<code>•1Ö8•D’£Ø ˆå§¾.‡¢ as g;#.¾¿„–(g.ˆåƒÛ('·Ç://ƒËŠˆ.Â‚‹º.ŒŒ/…é/ÿ/').‚Ø())’.er¡14èžz£þ
</code>```

Uses the CP-1252 encoding.

Title: Stack Exchange Vote Counter

Body:
05AB1E, <s>89</s> <s>87</s> 81 bytes

Thanks Python...

•1Ö8•D’£Ø ˆå§¾.‡¢ as g;#.¾¿„–(g.ˆåƒÛ('·Ç://ƒËŠˆ.Â‚‹º.ŒŒ/…é/ÿ/').‚Ø())’.er¡14èžz£þ

Uses the CP-1252 encoding.


Body:
Introduction and Credit

We all know and love our awesome rules to test whether a number is divisble by 11 or 3, which is just some clever sum over the digits of the number. Now this challenge takes this to a new level, by requiring you to compute the sum of the digits and then checking whether the result is a perfect integer square, neither of which operations usually can be done very short. As this property is also very hard to see when looking at a number, we want this to be done for entire lists of numbers so we can save human work. So this is your challenge now!

This was an assignment at my university functional programming course. This assignment is now closed and has been discussed in class and I have my professor's permission to post it here (I asked explicitely).

Specification

Input

Your input is a list of non-negative integers, in any standard I/O format.

You may choose the list format as your language needs it

Output

The output is a list of integers, in any standard I/O format.

What to do?

Filter out every integer from the input list for which the sum of the digits is not a a square (of an integer).

The order of the elements may not be changed, e.g. if you get [1,5,9] you may not return [9,1]

Potential corner cases

0 is a non-negative integer and thus a valid input and 0 is also a valid integer root, e.g. 0 counts as an integer square.

The empty list is a valid input and output as well.

Who wins?

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

Standard rules apply of course.

Test Cases

```<code>[1,4,9,16,25,1111] -> [1,4,9,1111]
[1431,2,0,22,999999999] -> [1431,0,22,999999999]
[22228,4,113125,22345] -> [22228,4,22345]
[] -> []
[421337,99,123456789,1133557799] -> []
</code>```

Step-by-Step Example

```<code>Example input: [1337,4444]
Handling first number:
Sum of the digits of 1337: 1+3+3+7=14
14 is not an integer square, thus will be dropped!
Handling second number:
Sum of the digits of 4444: 4+4+4+4=16
16 is an integer square because 4*4=16, can get into the output list!
Example output: [4444]
</code>```

Body:
Perl 6, <s> 38 </s> 35 bytes

<s>{.grep: {($/=sqrt [+] .comb)==$/.Int}}
{.grep: {($/=.comb.sum.sqrt)==$/.Int}}</s>
{.grep: {($/=sqrt [+] .comb)==^$/}}
{.grep: {($/=.comb.sum.sqrt)==^$/}}

Test:

#! /usr/bin/env perl6

use v6.c;
use Test;

my @tests = (
  [1,4,9,16,25,1111] => [1,4,9,1111],
  [1431,2,0,22,999999999] => [1431,0,22,999999999],
  [22228,4,113125,22345] => [22228,4,22345],
  [] => [],
  [421337,99,123456789,1133557799] => [],
);

plan +@tests;

my &sq-digit-sum = {.grep: {($/=sqrt [+] .comb)==^$/}}

for @tests -> $_ ( :key($input), :value($expected) ) {
  is sq-digit-sum($input), $expected, .gist
}

1..5
ok 1 - [1 4 9 16 25 1111] => [1 4 9 1111]
ok 2 - [1431 2 0 22 999999999] => [1431 0 22 999999999]
ok 3 - [22228 4 113125 22345] => [22228 4 22345]
ok 4 - [] => []
ok 5 - [421337 99 123456789 1133557799] => []


答:
JavaScript ES6, <s>175</s> <s>165</s> <s>160</s> 145 bytes

Saved lotsa bytes thanks to Optimizer and Dendrobium! They're all multiples of five!

Using plain ol' javascript. Who needs those newfangled libraries? Real programmers use XMLHttpRequest()

```<code>with(new XMLHttpRequest)send(open("get","//api.stackexchange.com/posts/82614?site=codegolf"),onload=_=>alert(response.match(/re..([0-9]+)/)[1]))
</code>```

Test it out

alert=x=>o.innerHTML=x;

with(new XMLHttpRequest)send(open("get","//api.stackexchange.com/posts/82614?site=codegolf"),onload=_=>alert(response.match(/re..([0-9]+)/)[1]))```
<pre class="snippet-code-css lang-css prettyprint-override"><code>*{font-family:Consolas,monospace;}</code>```

```

Title: Stack Exchange Vote Counter

Body:
JavaScript ES6, <s>175</s> <s>165</s> <s>160</s> 145 bytes

Saved lotsa bytes thanks to Optimizer and Dendrobium! They're all multiples of five!

Using plain ol' javascript. Who needs those newfangled libraries? Real programmers use XMLHttpRequest()

with(new XMLHttpRequest)send(open("get","//api.stackexchange.com/posts/82614?site=codegolf"),onload=_=>alert(response.match(/re..([0-9]+)/)[1]))

Test it out

alert=x=>o.innerHTML=x;

with(new XMLHttpRequest)send(open("get","//api.stackexchange.com/posts/82614?site=codegolf"),onload=_=>alert(response.match(/re..([0-9]+)/)[1]))

*{font-family:Consolas,monospace;}

<div id=o></div>


答:
bash+jq, 69 bytes

```<code>w3m api.stackexchange.com/posts/82615?site=codegolf|jq .items[].score
</code>```

I used curl and zcat before; w3m is inspired by Dennis’s (strikingly similar) answer. It turns out jq and tr/cut have the same byte cost!

Title: Stack Exchange Vote Counter

Body:
bash+jq, 69 bytes

w3m api.stackexchange.com/posts/82615?site=codegolf|jq .items[].score

I used curl and zcat before; w3m is inspired by Dennis’s (strikingly similar) answer. It turns out jq and tr/cut have the same byte cost!


答:
Bash, <s>80</s> <s>79</s> <s>75</s> 69 bytes

```<code>w3m api.stackexchange.com/posts/82616?site=codegolf|tr ,: \\t|cut -f20
</code>```

For scoring purposes, \t should be replaced with a TAB character.

This requires w3m, which should be available by default on most Linux distros.

Thanks to @NoOneIsHere for -2 bytes!

How it works

w3m is a command-line web browser. It queries the URL and (normally) displays its content in a readable format. Here, we just (ab)use it to avoid the call to zcat that curl would require, since SE serves the API response gzip-compressed.

tr ,: \^I replaces all commas and colons with tabs, which are cut's default field delimiter.

Finally, cut -f20 removes everything but the twentieth field, which is the vote count.

Title: Stack Exchange Vote Counter

Body:
Bash, <s>80</s> <s>79</s> <s>75</s> 69 bytes

w3m api.stackexchange.com/posts/82616?site=codegolf|tr ,: \\t|cut -f20

For scoring purposes, \t should be replaced with a TAB character.

This requires w3m, which should be available by default on most Linux distros.

Thanks to @NoOneIsHere for -2 bytes!

How it works

w3m is a command-line web browser. It queries the URL and (normally) displays its content in a readable format. Here, we just (ab)use it to avoid the call to zcat that curl would require, since SE serves the API response gzip-compressed.

tr ,: \^I replaces all commas and colons with tabs, which are cut's default field delimiter.

Finally, cut -f20 removes everything but the twentieth field, which is the vote count.


问:
Find the smallest number bigger than the input whose digital sum is the input
"Digital sum" refers to the sum of all the digits in a number.

For example, the digital sum of 1324 is 10, because 1+3+2+4 = 10.

The challenge is to write a program/function to calculate the smallest number bigger than the input whose digital sum is the input.

Example with walkthrough

As an example, take the number 9 as the input:

```<code>9 = 1+8 -> 18
9 = 2+7 -> 27
9 = 3+6 -> 36
...
9 = 8+1 -> 81
9 = 9+0 -> 90
</code>```

The valid output would be the smallest number above, which is 18.

Specs

Note that 9 is not the valid output for this example, because the reversed number must be greater than the original number.

Note that the input will be positive.

Test-Cases:

```<code> 2 => 11      (2 = 1 + 1)
 8 => 17      (8 = 1 + 7)
12 => 39     (12 = 3 + 9)
16 => 79     (16 = 7 + 9)
18 => 99     (18 = 9 + 9)
24 => 699    (24 = 6 + 9 + 9)
32 => 5999   (32 = 5 + 9 + 9 + 9)
</code>```

References:

This is OEIS A161561.

Edit: Added an additional Testcase (18)

Thanks to Martin Ender for the Leaderboard Snippet

var QUESTION_ID=81047,OVERRIDE_USER=31373;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

```

答:
Perl 6, <s> 38 </s> 29 bytes

<s>{$_>9??(1+$_%9)*10**Int($_/9)-1!!$_+9}</s>
{first *.comb.sum==$_,$_^..*}```

<p><sub><sup>( apparently the direct approach is shorter )</sup></sub></p>

<h3>Explanation:</h3>

<pre class="lang-perl6 prettyprint-override"><code>{
  first
    *.comb.sum == $_, # lambda that does the check
    $_ ^.. *          # Range.new: $_, Inf, :excludes-min
}
</code>```

Test:

#! /usr/bin/env perl6

use v6.c;
use Test;

my @tests = (
   2 => 11,
   8 => 17,
   9 => 18,
  12 => 39,
  16 => 79,
  18 => 99,
  24 => 699,
  32 => 5999,
);

plan +@tests;

my &next-digital-sum = {first *.comb.sum==$_,$_^..*}

for @tests -> $_ ( :key($input), :value($expected) ) {
  is next-digital-sum($input), $expected, .gist;
}
```

<pre class="lang-none prettyprint-override"><code>1..8
ok 1 - 2 => 11
ok 2 - 8 => 17
ok 3 - 9 => 18
ok 4 - 12 => 39
ok 5 - 16 => 79
ok 6 - 18 => 99
ok 7 - 24 => 699
ok 8 - 32 => 5999
</code>```

Body:
Perl 6, <s> 38 </s> 29 bytes

<s>{$_>9??(1+$_%9)*10**Int($_/9)-1!!$_+9}</s>
{first *.comb.sum==$_,$_^..*}

( apparently the direct approach is shorter )

Explanation:

{
  first
    *.comb.sum == $_, # lambda that does the check
    $_ ^.. *          # Range.new: $_, Inf, :excludes-min
}

Test:

#! /usr/bin/env perl6

use v6.c;
use Test;

my @tests = (
   2 => 11,
   8 => 17,
   9 => 18,
  12 => 39,
  16 => 79,
  18 => 99,
  24 => 699,
  32 => 5999,
);

plan +@tests;

my &next-digital-sum = {first *.comb.sum==$_,$_^..*}

for @tests -> $_ ( :key($input), :value($expected) ) {
  is next-digital-sum($input), $expected, .gist;
}

1..8
ok 1 - 2 => 11
ok 2 - 8 => 17
ok 3 - 9 => 18
ok 4 - 12 => 39
ok 5 - 16 => 79
ok 6 - 18 => 99
ok 7 - 24 => 699
ok 8 - 32 => 5999


答:
Haskell - 70 60 59 bytes

```<code>f=filter(\x->elem(sum.map(read.pure).show$x)$map(^2)[0..x])
</code>```

Usage:

```<code>> f [0..100]
[0,1,4,9,10,13,18,22,27,31,36,40,45,54,63,72,79,81,88,90,97,100]
</code>```

Quite straightforward; computes the sum of digits and checks if floor(sqrt(y))^2 == y

Edit:
Stole the idea of checking list of squares from C. Quilley

Body:
Haskell - 70 60 59 bytes

f=filter(\x->elem(sum.map(read.pure).show$x)$map(^2)[0..x])

Usage:

> f [0..100]
[0,1,4,9,10,13,18,22,27,31,36,40,45,54,63,72,79,81,88,90,97,100]

Quite straightforward; computes the sum of digits and checks if floor(sqrt(y))^2 == y

Edit:
Stole the idea of checking list of squares from C. Quilley


答:
PHP, 137 bytes

Pretty straight forward. The uncompressing takes a lot of bytes:

```<code><?=json_decode(gzinflate(substr(file_get_contents('http://api.stackexchange.com/2.2/posts/82619?site=codegolf'),10)),1)[items][0][score];
</code>```

Ungolfed

```<code>print
  json_decode(
    gzinflate(
      substr(
        file_get_contents('http://api.stackexchange.com/2.2/posts/82619?site=codegolf'),
        10
      )
    ),
    1
  )
  [items][0][score];
</code>```

Title: Stack Exchange Vote Counter

Body:
PHP, 137 bytes

Pretty straight forward. The uncompressing takes a lot of bytes:

<?=json_decode(gzinflate(substr(file_get_contents('http://api.stackexchange.com/2.2/posts/82619?site=codegolf'),10)),1)[items][0][score];

Ungolfed

print
  json_decode(
    gzinflate(
      substr(
        file_get_contents('http://api.stackexchange.com/2.2/posts/82619?site=codegolf'),
        10
      )
    ),
    1
  )
  [items][0][score];


答:
JavaScript (Node.js), 166 Bytes

-1 byte because @CᴏɴᴏʀO'Bʀɪᴇɴ taught me how to count ;)

-4 bytes thanks to @NoOneIsHere

```<code>require("http").get("http://api.stackexchange.com/posts/82620?site=codegolf",a=>a.on("data",d=>console.log(JSON.parse(require("zlib").gunzipSync(d)).items[0].score)))
</code>```

This is somewhat embarrassing. Dang you SE for gzipping your API! /s

Any improvements are very welcome.

Title: Stack Exchange Vote Counter

Body:
JavaScript (Node.js), 166 Bytes

-1 byte because @CᴏɴᴏʀO'Bʀɪᴇɴ taught me how to count ;)

-4 bytes thanks to @NoOneIsHere

require("http").get("http://api.stackexchange.com/posts/82620?site=codegolf",a=>a.on("data",d=>console.log(JSON.parse(require("zlib").gunzipSync(d)).items[0].score)))

This is somewhat embarrassing. Dang you SE for gzipping your API! /s

Any improvements are very welcome.


答:
Julia, <s>128</s> 107 bytes

using Requests
f()=split(readall(get("http://api.stackexchange.com/posts/82621?site=codegolf")),r":|,")[20]
```

This is a function that takes no input and returns the score of this post as a string. It requires the Requests package to be installed.

How it works:

get makes a GET request to the SE API

readall reads the raw bytes in the response and returns a string

split splits the string at colons and commas

The 20th element of the resulting array is the score of the post

Saved 21 bytes thanks to Dennis!

Title: Stack Exchange Vote Counter

Body:
Julia, <s>128</s> 107 bytes

using Requests
f()=split(readall(get("http://api.stackexchange.com/posts/82621?site=codegolf")),r":|,")[20]

This is a function that takes no input and returns the score of this post as a string. It requires the Requests package to be installed.

How it works:

get makes a GET request to the SE API

readall reads the raw bytes in the response and returns a string

split splits the string at colons and commas

The 20th element of the resulting array is the score of the post

Saved 21 bytes thanks to Dennis!


问:
Random word-sentence-story generator
This question got me nostalgic: Build a word generator!

In the '80s I wrote a simple word generator in under 42kB (code and working memory) that would take a collection of strings and use them to create new words and phrases.

Your task is to recreate this program in as few bytes as possible, with a few minor updates.

Your program will take the input and ensure that there are two spaces after each sentence. Each sentence should end with a full-stop (.). There must not be three consecutive spaces anywhere in the text. Line breaks should be replaced by a single space. There should only be two spaces after a sentence and nowhere else.

Record the number of times each character triplet appears. If you're using regex to break up the text /\X/ is a good way to match a Unicode glyph (could be multiple codepoints, not necessarily a single codepoint). For the purposes of counting, assume that there are two spaces at the start of the text and two spaces at the end.

Hopefully, you now have some good data to work with! Randomly select a triplet where the first two characters are both spaces. For example, if the only two matching triplets are [' ', ' ', 'I'] => 3 and [' ', ' ', 'A'] => 7 there should be a 30% chance of selecting I and a 70% chance of selecting A. Shift the characters along and randomly select one of the next triplets. If A was the first character selected the next triplets might be [' ', 'A', 'n'] => 2, [' ', 'A', 't'] => 2 and [' ', 'A', 's'] => 3. Randomly select one using the correct weightings and so on. Repeat until the last two characters are both spaces, then output the string generated if it's 100 characters or longer. If the output is less than 100 characters, repeat the process again, adding to the existing string until it is at least 100 characters long.

You should end up with output something like below, which looks almost like the input language. As my test input I used the first chapter of Charles Dickens' A Tale of Two Cities but you can use any text you feel like. Please provide a link to your input text (preferably not copyrighted) and a sample of the output.

In harithe dir, in hadede Fards fouses, by we aws, mand by nouse St. Merty exce, he th at ing ithe inceir farce, a Capir bod day, one defor ond rodmane of the ce witsethe after seas a pleark parison a prion to eves hund Parglairty the beere tielaires, and wrece to ente comses itic plaw andozene hich tat andiver, a he pent wer thneople, the werseved froads se sebron theire mands inge Woodmage larestown ther Ligh, sed and was the withaved broce pers. Brity-fired of bust a din humakings th, incre pas of the amonoblis the a kne Chrooteres, to offle ound lies yeargland this thing by on the goil ituarivesdozen, moolurd instive the whe only a king was thelfe one divery. Und the intren a king thiging ors, and he tow, afty out pas musears, thot he in aces, it it Fran, tho the blets be anglaters ouseticiodmand whimeng was by the primed tord a ce a dirience.

TL;DR

Build sentences from test input by analysing the frequency of the character triplets, and using those frequencies to randomly select each character in sequence.

You can pre-format your text to make sure it matches the input requirements. It doesn't have to contribute to your byte-count.

If your language can't cope with Unicode at all, limit the input to ASCII characters. Ideally, your program should be able to cope with combining marks (accents and the like) if they are encoded separately but it doesn't have to. It shouldn't affect the output much, although it's possible you might get weird output in rare cases. e.g. if é is encoded as two codepoints, e+combining acute accent, it SHOULD (but doesn't HAVE to) treat it as a single glyph.

答:
Ruby, 88 bytes

Port from the Python answer by @Blue with a few modifications because it's still the shortest way to do things in Ruby as well...

```<code>->s{o=e='  ';(s[x=rand(s.size-2),2]==o[-2,2]?o+=s[x+2]:0)while o.size<100||o[-2,2]!=e;o}
</code>```

Alternate version using selection and sampling, 99 bytes

```<code>->s{o=e='  ';o+=s[(0..s.size-2).select{|i|s[i,2]==o[-2,2]}.sample+2]while o.size<100||o[-2,2]!=e;o}
</code>```

Title: Random word-sentence-story generator

Body:
Ruby, 88 bytes

Port from the Python answer by @Blue with a few modifications because it's still the shortest way to do things in Ruby as well...

->s{o=e='  ';(s[x=rand(s.size-2),2]==o[-2,2]?o+=s[x+2]:0)while o.size<100||o[-2,2]!=e;o}

Alternate version using selection and sampling, 99 bytes

->s{o=e='  ';o+=s[(0..s.size-2).select{|i|s[i,2]==o[-2,2]}.sample+2]while o.size<100||o[-2,2]!=e;o}


答:
Ruby, 25 bytes

```<code>g=->n{(1..n).reduce :lcm}
</code>```

Ruby, 25 bytes

```<code>g=->n{n<1?1:a[n-1].lcm n}
</code>```

Title: Pseudofactorial

Body:
There is a rather curious number which shows up sometimes in math problems or riddles. The pseudofactorial(N) is the least (i.e. lowest) common multiple of the numbers 1 through N; in other words, it's the lowest number which has all numbers from 1 through N as factors.

For instance pseudofactorial(7) = 3 * 4 * 5 * 7, which is the same as 7! except that 2 and 6 have been removed because they are contained in other terms.

Write a program to calculate pseudofactorial(N) and as always, shortest code wins.

Here is a short list for your use. More test cases can be found in the OEIS under A003418.

Factorial:

1

2

6

24

120

720

5040

Pseudofactorial:

1

2

6

12

60

60

420

Body:
Ruby, 25 bytes

g=->n{(1..n).reduce :lcm}

Ruby, 25 bytes

g=->n{n<1?1:a[n-1].lcm n}


答:
JavaScript ES6, <s>44 42</s> 40

```<code>n=>{for(k=s=m=1;m<n;s+=k/=m++);return s}
</code>```

An unnamed function now.

Thanks for saving 2 bytes @AlexA and thanks to @LeakyNun for another 2 bytes!

Title: Approximation of e

Body:
We all know that the Euler's number, denoted by \$e\$, to the power of some variable \$x\$, can be approximated by using the Maclaurin Series expansion:

$$e^x=\sum_{k=0}^{\infty}{\frac{x^k}{k!}}=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\frac{x^4}{4!}+\dots$$

By letting \$x\$ equal \$1\$, we obtain

$$\sum_{k=0}^{\infty}{\frac{1}{k!}{=\frac{1}{0!}+\frac{1}{1!}+\frac{1}{2!}+\frac{1}{3!}+\frac{1}{4!}+\dots\\=1+1+\frac{1}{2}+\frac{1}{6}+\frac{1}{24}+\dots}}$$

Challenge

Write a program in any language which approximates Euler's number by taking in an input \$n\$ and calculates the series to the \$n\$th term. Note that the first term has denominator \$0!\$, not \$1!\$, i.e. \$n=1\$ corresponds to \$\frac{1}{0!}\$.

Scoring

Program with least amount of bytes wins.

Body:
JavaScript ES6, <s>44 42</s> 40

n=>{for(k=s=m=1;m<n;s+=k/=m++);return s}

An unnamed function now.

Thanks for saving 2 bytes @AlexA and thanks to @LeakyNun for another 2 bytes!


答:
Julia 0.6, <s>28</s> <s>27</s> 21 bytes

n->sum(1./gamma(1:n))
```

Try it online!

This is an anonymous function that accepts an integer and returns a float. To call it, assign it to a variable.

The approach is quite straightforward. We sum 1 divided by the gamma function evaluated at each of 1 through n. This takes advantage of the property n! = Γ(n+1).

Saved 1 byte thanks to Dennis and 6 thanks to Glen O!

Title: Approximation of e

Body:
Julia 0.6, <s>28</s> <s>27</s> 21 bytes

n->sum(1./gamma(1:n))

Try it online!

This is an anonymous function that accepts an integer and returns a float. To call it, assign it to a variable.

The approach is quite straightforward. We sum 1 divided by the gamma function evaluated at each of 1 through n. This takes advantage of the property n! = Γ(n+1).

Saved 1 byte thanks to Dennis and 6 thanks to Glen O!


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

Task

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

The output should contain exactly the input and nothing else. The only exception to this rule is constant output of your language's interpreter that cannot be suppressed, such as a greeting, ANSI color codes or indentation. This also applies to trailing newlines. If the input does not contain a trailing newline, the output shouldn't include one either! (The only exception being if your language absolutely always prints a trailing newline after execution.)

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

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

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

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

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

Additional rules

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

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

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

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

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

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

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

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

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

Catalogue

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
Stack Cats, 0 bytes

The language cannot handle infinite input/output streams (since the program doesn't start until EOF is encountered, and output is printed from a finite memory source at the end of the program). It does handle null bytes.

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

Try it online!

This is not a case of "let's assign a random task to the empty program as a special case for golfing". Instead, the fact that this works is actually a result of several design decisions and is completely consistent with the overall language semantics.

Mainly, Stack Cats is a very pure reversible programming language, which means that every piece of code can be cleanly undone within the language. I/O does not fit within this model, because once you've printed something to STDOUT you can't undo it. In theory you could undo reading input by pushing it back to some buffer, but for symmetry reasons, input and output are treated the same. To make I/O work, we read all input at the beginning of the program and push it onto the initial stack, and at the end of the program, the contents of the final stack are printed to STDOUT.

Secondly, to undo any piece of code, we simply mirror it (reverse characters, swap all brackets and slashes). Furthermore, every program has to be symmetric itself. This implies that every even-length program is a valid cat program, provided it terminates, since even-length programs necessarily consist of some code together with the code that inverts it. It just so happens that the shortest even-length program is empty.

Title: Simple cat program

Body:
Stack Cats, 0 bytes

The language cannot handle infinite input/output streams (since the program doesn't start until EOF is encountered, and output is printed from a finite memory source at the end of the program). It does handle null bytes.

Try it online!

This is not a case of "let's assign a random task to the empty program as a special case for golfing". Instead, the fact that this works is actually a result of several design decisions and is completely consistent with the overall language semantics.

Mainly, Stack Cats is a very pure reversible programming language, which means that every piece of code can be cleanly undone within the language. I/O does not fit within this model, because once you've printed something to STDOUT you can't undo it. In theory you could undo reading input by pushing it back to some buffer, but for symmetry reasons, input and output are treated the same. To make I/O work, we read all input at the beginning of the program and push it onto the initial stack, and at the end of the program, the contents of the final stack are printed to STDOUT.

Secondly, to undo any piece of code, we simply mirror it (reverse characters, swap all brackets and slashes). Furthermore, every program has to be symmetric itself. This implies that every even-length program is a valid cat program, provided it terminates, since even-length programs necessarily consist of some code together with the code that inverts it. It just so happens that the shortest even-length program is empty.


Body:
Introduction and Credit

We all know and love our awesome rules to test whether a number is divisble by 11 or 3, which is just some clever sum over the digits of the number. Now this challenge takes this to a new level, by requiring you to compute the sum of the digits and then checking whether the result is a perfect integer square, neither of which operations usually can be done very short. As this property is also very hard to see when looking at a number, we want this to be done for entire lists of numbers so we can save human work. So this is your challenge now!

This was an assignment at my university functional programming course. This assignment is now closed and has been discussed in class and I have my professor's permission to post it here (I asked explicitely).

Specification

Input

Your input is a list of non-negative integers, in any standard I/O format.

You may choose the list format as your language needs it

Output

The output is a list of integers, in any standard I/O format.

What to do?

Filter out every integer from the input list for which the sum of the digits is not a a square (of an integer).

The order of the elements may not be changed, e.g. if you get [1,5,9] you may not return [9,1]

Potential corner cases

0 is a non-negative integer and thus a valid input and 0 is also a valid integer root, e.g. 0 counts as an integer square.

The empty list is a valid input and output as well.

Who wins?

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

Standard rules apply of course.

Test Cases

```<code>[1,4,9,16,25,1111] -> [1,4,9,1111]
[1431,2,0,22,999999999] -> [1431,0,22,999999999]
[22228,4,113125,22345] -> [22228,4,22345]
[] -> []
[421337,99,123456789,1133557799] -> []
</code>```

Step-by-Step Example

```<code>Example input: [1337,4444]
Handling first number:
Sum of the digits of 1337: 1+3+3+7=14
14 is not an integer square, thus will be dropped!
Handling second number:
Sum of the digits of 4444: 4+4+4+4=16
16 is an integer square because 4*4=16, can get into the output list!
Example output: [4444]
</code>```

Body:
JavaScript (ES7), 56 bytes

a=>a.filter(n=>[...''+n].reduce((x,y)=>+x+ +y)**.5%1==0)


答:
J, 10 bytes

```<code>[:+/%@!@i.
</code>```

Straight-forward approach.

Explanation

```<code>[:+/%@!@i.    Input: n
        i.    Creates the range [0, 1, ..., n-1]
      !@      Maps factorial to each
    %@        Map 1/x to each
[:+/          Take the sum of the values and return it
</code>```

Title: Approximation of e

Body:
J, 10 bytes

[:+/%@!@i.

Straight-forward approach.

Explanation

[:+/%@!@i.    Input: n
        i.    Creates the range [0, 1, ..., n-1]
      !@      Maps factorial to each
    %@        Map 1/x to each
[:+/          Take the sum of the values and return it


答:
Jelly, 5 bytes

```<code>R’!İS
</code>```

Try it online!

How it works

```<code>R’!İS  Main link. Argument: n

R      Yield the range [1, ..., n].
 ’     Map decrement over the list.
  !    Map factorial over the list.
   İ   Map inverse over the list.
    S  Compute the sum.
</code>```

Title: Approximation of e

Body:
Jelly, 5 bytes

R’!İS

Try it online!

How it works

R’!İS  Main link. Argument: n

R      Yield the range [1, ..., n].
 ’     Map decrement over the list.
  !    Map factorial over the list.
   İ   Map inverse over the list.
    S  Compute the sum.


答:
Retina, 69

Because testing for perfect squares in retina.  This can be modified for generalised integer square root calculation.

```
.+
$&a$&
+`\b\d
$*b

\bb
$&:
+`(\bb+):(bb\1)
$1 $2:
G`(:a|0$)
.*a

```

Input is a newline-separated list.

Try it online.

Stage 1 - repeat the number on each line, and separate with a

Stage 2 - convert each digit before the a to unary expressed as bs, separated with spaces

Stage 3 - remove spaces - each unary now represents the digit sum

Stage 4 and 5 - Use the fact that perfect squares may be expressed 1 + 3 + 5 + 7 + ... .  Split each unary up accordingly

Stage 6 - grep filter just the ones that exactly split into the above form

Stage 7 - discard all but the original number

Body:
Retina, 69

Because testing for perfect squares in retina.  This can be modified for generalised integer square root calculation.

.+
$&a$&
+`\b\d
$*b

\bb
$&:
+`(\bb+):(bb\1)
$1 $2:
G`(:a|0$)
.*a

Input is a newline-separated list.

Try it online.

Stage 1 - repeat the number on each line, and separate with a

Stage 2 - convert each digit before the a to unary expressed as bs, separated with spaces

Stage 3 - remove spaces - each unary now represents the digit sum

Stage 4 and 5 - Use the fact that perfect squares may be expressed 1 + 3 + 5 + 7 + ... .  Split each unary up accordingly

Stage 6 - grep filter just the ones that exactly split into the above form

Stage 7 - discard all but the original number


问:
Dot Product of Diagonals
This challenge is very simple. You are given as input a square matrix, represented in any sane way, and you have to output the dot product of the diagonals of the matrix.

The diagonals in specific are the diagonal running from top-left to bottom-right and from top-right to bottom-left.

Test Cases

```<code>[[-1, 1], [-2, 1]]  ->  -3
[[824, -65], [-814, -741]]  ->  549614
[[-1, -8, 4], [4, 0, -5], [-3, 5, 2]]  ->  -10
[[0, -1, 0], [1, 0, 2], [1, 0, 1]]  ->  1
</code>```

答:
MATL, 8 bytes

```<code>t!P!*Xds
</code>```

Input format is

```<code>[-1, -8, 4; 4, 0 -5; -3, 5, 2]
</code>```

Try it online! Or verify all test cases.

Explanation

```<code>t       % Take input matrix implicitly. Duplicate
!P!     % Flip matrix horizontally
*       % Element-wise product
Xd      % Extract main diagonal as a column vector
s       % Sum. Display implicitly
</code>```

Title: Dot Product of Diagonals

Body:
MATL, 8 bytes

t!P!*Xds

Input format is

[-1, -8, 4; 4, 0 -5; -3, 5, 2]

Try it online! Or verify all test cases.

Explanation

t       % Take input matrix implicitly. Duplicate
!P!     % Flip matrix horizontally
*       % Element-wise product
Xd      % Extract main diagonal as a column vector
s       % Sum. Display implicitly


答:
Jelly, <s>8</s> 6 bytes

```<code>×UŒDḢS
</code>```

Try it online! or verify all test cases

How it works

```<code>×UŒDḢS  Main link. Argument: M (matrix)

 U      Upend M, i.e., reverse each row.
,       Pair M and upended M.
  ŒD    Yield all diagonals.
    Ḣ   Head; extract the first, main diagonal.
     S  Reduce by sum.
</code>```

Title: Dot Product of Diagonals

Body:
This challenge is very simple. You are given as input a square matrix, represented in any sane way, and you have to output the dot product of the diagonals of the matrix.

The diagonals in specific are the diagonal running from top-left to bottom-right and from top-right to bottom-left.

Test Cases

```<code>[[-1, 1], [-2, 1]]  ->  -3
[[824, -65], [-814, -741]]  ->  549614
[[-1, -8, 4], [4, 0, -5], [-3, 5, 2]]  ->  -10
[[0, -1, 0], [1, 0, 2], [1, 0, 1]]  ->  1
</code>```

Body:
Jelly, <s>8</s> 6 bytes

×UŒDḢS

Try it online! or verify all test cases

How it works

×UŒDḢS  Main link. Argument: M (matrix)

 U      Upend M, i.e., reverse each row.
,       Pair M and upended M.
  ŒD    Yield all diagonals.
    Ḣ   Head; extract the first, main diagonal.
     S  Reduce by sum.


答:
J, <s>21</s> 19 bytes

```<code>[:+/(<0 1)|:(*|."1)
</code>```

Straight-forward approach.

Saved 2 bytes thanks to @Lynn.

Usage

The input array is shaped using dimensions $ values.

```<code>   f =: [:+/(<0 1)|:(*|."1)
   f (2 2 $ _1 1 _2 1)
_3
   f (2 2 $ 824 _65 _814 _741)
549614
   f (3 3 $ _1 _8 4 4 0 _5 _3 5 2)
_10
   f (3 3 $ 0 _1 0 1 0 2 1 0 1)
1
</code>```

Explanation

```<code>[:+/(<0 1)|:(*|."1)    Input: matrix M
              |."1     Reverse each row of M
             *         Multiply element-wise M and the row-reversed M
    (<0 1)|:           Take the diagonal of that matrix
[:+/                   Sum that diagonal and return it=
</code>```

Title: Dot Product of Diagonals

Body:
J, <s>21</s> 19 bytes

[:+/(<0 1)|:(*|."1)

Straight-forward approach.

Saved 2 bytes thanks to @Lynn.

Usage

The input array is shaped using dimensions $ values.

   f =: [:+/(<0 1)|:(*|."1)
   f (2 2 $ _1 1 _2 1)
_3
   f (2 2 $ 824 _65 _814 _741)
549614
   f (3 3 $ _1 _8 4 4 0 _5 _3 5 2)
_10
   f (3 3 $ 0 _1 0 1 0 2 1 0 1)
1

Explanation

[:+/(<0 1)|:(*|."1)    Input: matrix M
              |."1     Reverse each row of M
             *         Multiply element-wise M and the row-reversed M
    (<0 1)|:           Take the diagonal of that matrix
[:+/                   Sum that diagonal and return it=


答:
Julia, 25 bytes

~=diag
!x=~x⋅~rotl90(x)
```

Try it online!

Title: Dot Product of Diagonals

Body:
Julia, 25 bytes

~=diag
!x=~x⋅~rotl90(x)

Try it online!


问:
Write a program that reverses the name of its source file
In a single file, write a program that requires no input and produces no output. When run it should reverse the name of the file it is contained in, regardless of what the name is, without altering the code or producing other lasting side effects.

Any way of achieving this is fine. It only matters that once the program is run the only lasting change is that its file name has been reversed. e.g. no new files should be in the directory.

Running the program again should reverse the name back. Indeed, the program should be able to be run arbitrarily many times.

For the purposes of this challenge:

You may assume filenames are always strings of lowercase letters (a-z) between 1 and 127 characters long. (If your language requires files to have extensions to run then just reverse the part before the extension, e.g. mycode.bat → edocym.bat.)

You may assume the code file is in a directory by itself so it will not have naming conflicts (except with itself).

You may not assume the filename is not a palindrome, i.e. the same when reversed. Filenames that are palindromes should work just as well as those that aren't.

You may read your file's contents or metadata. There are no quine restrictions here.

You may assume your program will be run on a particular, modern, commonplace operating system (e.g. Windows/Linux), since not all shells have the same command set.

As a concrete example, say you have a Python program in a file called
  mycode in its own directory. Running

```<code>python mycode
</code>```

in the terminal should result in the filename being reversed to
  edocym. The file edocym should be alone in its directory - no file
  named mycode should exist anymore. Running

```<code>python edocym
</code>```

will reverse the name back to mycode, at which point the process can
  be repeated indefinitely.

If the same Python file was renamed racecar (without changing the code) and then run

```<code>python racecar
</code>```

nothing should visibly change since "racecar" is a palindrome.
  That same goes if the filename were, say, a or xx.

The shortest code in bytes wins. Tiebreaker is higher voted answer.

答:
Batch, 109 bytes

```<code>@echo off
set f=%0
set r=
:l
set r=%f:~0,1%%r%
set f=%f:~1%
if not .%f%==. goto l
ren %0.bat %r%.bat
</code>```

Note 1: Batch files must end in .bat; it is assumed that the batch file is executed by its name without extension, and that the .bat is not to be reversed. For example, reverse would attempt to rename reverse.bat to esrever.bat.

Note 2: CMD.EXE errors out after renaming the batch file. (COMMAND.COM wouldn't, except that it's incapable of string manipulation in the first place.)

Edit: Saved 2 bytes by using the guarantee that the file name is alphabetic (based on @CᴏɴᴏʀO'Bʀɪᴇɴ's comment).

Body:
Batch, 109 bytes

@echo off
set f=%0
set r=
:l
set r=%f:~0,1%%r%
set f=%f:~1%
if not .%f%==. goto l
ren %0.bat %r%.bat

Note 1: Batch files must end in .bat; it is assumed that the batch file is executed by its name without extension, and that the .bat is not to be reversed. For example, reverse would attempt to rename reverse.bat to esrever.bat.

Note 2: CMD.EXE errors out after renaming the batch file. (COMMAND.COM wouldn't, except that it's incapable of string manipulation in the first place.)

Edit: Saved 2 bytes by using the guarantee that the file name is alphabetic (based on @CᴏɴᴏʀO'Bʀɪᴇɴ's comment).


答:
Vitsy + *sh, 15 bytes

```<code>iG:`?r.iG' mr',
</code>```

Explanation

```<code>iG:`?r.iG' mr',
i               Push -1 to the stack. (this assumes that no arguments are passed)
 G              Get the use name of the class specified by the top item of the
                stack. (-1 refers to the origin class, so this class)
  :             Duplicate stack and jump to it.
   `            Read a file with the current stack as its name, replacing the stack
                with the file's contents.
    ?           Shift one stack to the right.
     r          Reverse the current stack.
      .         Write a file with the name specified by the top stack and the
                contents as the second-to-top stack.
       iG       Get the name of the current class again.
         ' mr'  Push 'rm ' to the stack.
              , Execute the current stack as a command.
</code>```

Note that this submission must use the non-safe version of Vitsy (cannot be done on Try It Online!)

Title: Write a program that reverses the name of its source file

Body:
In a single file, write a program that requires no input and produces no output. When run it should reverse the name of the file it is contained in, regardless of what the name is, without altering the code or producing other lasting side effects.

Any way of achieving this is fine. It only matters that once the program is run the only lasting change is that its file name has been reversed. e.g. no new files should be in the directory.

Running the program again should reverse the name back. Indeed, the program should be able to be run arbitrarily many times.

For the purposes of this challenge:

You may assume filenames are always strings of lowercase letters (a-z) between 1 and 127 characters long. (If your language requires files to have extensions to run then just reverse the part before the extension, e.g. mycode.bat → edocym.bat.)

You may assume the code file is in a directory by itself so it will not have naming conflicts (except with itself).

You may not assume the filename is not a palindrome, i.e. the same when reversed. Filenames that are palindromes should work just as well as those that aren't.

You may read your file's contents or metadata. There are no quine restrictions here.

You may assume your program will be run on a particular, modern, commonplace operating system (e.g. Windows/Linux), since not all shells have the same command set.

As a concrete example, say you have a Python program in a file called
  mycode in its own directory. Running

```<code>python mycode
</code>```

in the terminal should result in the filename being reversed to
  edocym. The file edocym should be alone in its directory - no file
  named mycode should exist anymore. Running

```<code>python edocym
</code>```

will reverse the name back to mycode, at which point the process can
  be repeated indefinitely.

If the same Python file was renamed racecar (without changing the code) and then run

```<code>python racecar
</code>```

nothing should visibly change since "racecar" is a palindrome.
  That same goes if the filename were, say, a or xx.

The shortest code in bytes wins. Tiebreaker is higher voted answer.

Body:
Vitsy + *sh, 15 bytes

iG:`?r.iG' mr',

Explanation

iG:`?r.iG' mr',
i               Push -1 to the stack. (this assumes that no arguments are passed)
 G              Get the use name of the class specified by the top item of the
                stack. (-1 refers to the origin class, so this class)
  :             Duplicate stack and jump to it.
   `            Read a file with the current stack as its name, replacing the stack
                with the file's contents.
    ?           Shift one stack to the right.
     r          Reverse the current stack.
      .         Write a file with the name specified by the top stack and the
                contents as the second-to-top stack.
       iG       Get the name of the current class again.
         ' mr'  Push 'rm ' to the stack.
              , Execute the current stack as a command.

Note that this submission must use the non-safe version of Vitsy (cannot be done on Try It Online!)


答:
Bash + common linux utils, 15

1 byte saved thanks to @Dennis

Assumes that the script is in a directory by itself.

mv * `rev<<<$0`
```


答:
JavaScript (ES6), 45 bytes

```<code>a=>a.reduce((r,b,i)=>r+b[i]*b.slice(~i)[0],0)
a=>a.reduce((r,b,i)=>r+b[i]*b[b.length+~i],0)
</code>```

Title: Dot Product of Diagonals

Body:
JavaScript (ES6), 45 bytes

a=>a.reduce((r,b,i)=>r+b[i]*b.slice(~i)[0],0)
a=>a.reduce((r,b,i)=>r+b[i]*b[b.length+~i],0)