问:
Shortest infinite loop producing no output
Your task is to create the shortest infinite loop!

The point of this challenge is to create an infinite loop producing no output, unlike its possible duplicate. The reason to this is because the code might be shorter if no output is given.

Rules

Each submission must be a full program.

You must create the shortest infinite loop.

Even if your program runs out of memory eventually, it is still accepted as long as it is running the whole time from the start to when it runs out of memory. Also when it runs out of memory, it should still not print anything to STDERR.

The program must take no input (however, reading from a file is allowed), and should not print anything to STDOUT. Output to a file is also forbidden.

The program must not write anything to STDERR.

Feel free to use a language (or language version) even if it's newer than this challenge.
-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. :D

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 infinite loop program. This is about finding the shortest infinite loop program in every language. Therefore, I will not accept an answer.

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 Brainf**k-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.

There should be a website such as Wikipedia, Esolangs, or GitHub for the language. For example, if the language is CJam, then one could link to the site in the header like #[CJam](http://sourceforge.net/p/cjam/wiki/Home/), X bytes.

Standard loopholes are not allowed.

(I have taken some of these rules from Martin Büttner's "Hello World" challenge)

Please feel free to post in the comments to tell me how this challenge could be  improved.

Catalogue

This is a Stack Snippet which generates both an alphabetical catalogue of the used languages, and an overall leaderboard. To make sure your answer shows up, please start it with this Markdown header:

```<code># Language name, X bytes
</code>```

Obviously replacing Language name and X bytes with the proper items. If you want to link to the languages' website, use this template, as posted above:

```<code>#[Language name](http://link.to/the/language), X bytes
</code>```

Now, finally, here's the snippet: (Try pressing "Full page" for a better view.)

var QUESTION_ID=59347;var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk";var OVERRIDE_USER=41805;var answers=[],answers_hash,answer_ids,answer_page=1,more_answers=true,comment_page;function answersUrl(index){return"//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"//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}#answer-list{padding:10px;width:500px;float:left}#language-list{padding:10px;padding-right:40px;width:500px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
Codan, 4 bytes

```<code>«»
</code>```

All loops in Codan are infinite if they don't have breaks. This program is transpiled to C as follows:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <termios.h>
int main(void)
{
    int mem[10000];
    int alpha, beta, t;
for (;;) {
}

    return 0;
}
```

Body:
Codan, 4 bytes

«»

All loops in Codan are infinite if they don't have breaks. This program is transpiled to C as follows:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <termios.h>
int main(void)
{
    int mem[10000];
    int alpha, beta, t;
for (;;) {
}

    return 0;
}


答:
tinyBF, 5 bytes

```<code>+|= |
</code>```

Similar to +[] in BF. The space is required here, as |=| (meaning []) is converted to ,.

ContentLicense: CC BY-SA 3.0

Title: Shortest infinite loop producing no output

Body:
Your task is to create the shortest infinite loop!

The point of this challenge is to create an infinite loop producing no output, unlike its possible duplicate. The reason to this is because the code might be shorter if no output is given.

Rules

Each submission must be a full program.

You must create the shortest infinite loop.

Even if your program runs out of memory eventually, it is still accepted as long as it is running the whole time from the start to when it runs out of memory. Also when it runs out of memory, it should still not print anything to STDERR.

The program must take no input (however, reading from a file is allowed), and should not print anything to STDOUT. Output to a file is also forbidden.

The program must not write anything to STDERR.

Feel free to use a language (or language version) even if it's newer than this challenge.
-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. :D

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 infinite loop program. This is about finding the shortest infinite loop program in every language. Therefore, I will not accept an answer.

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 Brainf**k-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.

There should be a website such as Wikipedia, Esolangs, or GitHub for the language. For example, if the language is CJam, then one could link to the site in the header like #[CJam](http://sourceforge.net/p/cjam/wiki/Home/), X bytes.

Standard loopholes are not allowed.

(I have taken some of these rules from Martin Büttner's "Hello World" challenge)

Please feel free to post in the comments to tell me how this challenge could be  improved.

Catalogue

This is a Stack Snippet which generates both an alphabetical catalogue of the used languages, and an overall leaderboard. To make sure your answer shows up, please start it with this Markdown header:

```<code># Language name, X bytes
</code>```

Obviously replacing Language name and X bytes with the proper items. If you want to link to the languages' website, use this template, as posted above:

```<code>#[Language name](http://link.to/the/language), X bytes
</code>```

Now, finally, here's the snippet: (Try pressing "Full page" for a better view.)

var QUESTION_ID=59347;var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk";var OVERRIDE_USER=41805;var answers=[],answers_hash,answer_ids,answer_page=1,more_answers=true,comment_page;function answersUrl(index){return"//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"//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}#answer-list{padding:10px;width:500px;float:left}#language-list{padding:10px;padding-right:40px;width:500px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

Body:
tinyBF, 5 bytes

+|= |

Similar to +[] in BF. The space is required here, as |=| (meaning []) is converted to ,.


问:
Autocomplete the input
Pre-Note

Because of popular demand, and to avoid disqualifying certain languages, the dictionary can now be provided as input parameter.

Intro

Given a dictionary of words, you should write an autocomplete program or function.

Autocompletion

"Autocomplete, or word completion, is a feature in which an application predicts the rest of a word a user is typing." (Wikipedia)

Autocompletion is oftenly used to reduce the time needed for typing sentences. After typing a single character, the program will start guessing what the user is trying to say. In this challenge we will simulate the behaviour of autocompleting words.

If the program encounters a word it doesn't know, and no matching autocompletion words can be found, it will assume that the user is trying to type a word the program doesn't know. Good autocompletion software will own and edit a custom dictionary of words, but for the sakes of complexity that's not part of this challenge.

Input

Your program/function will take at least a single parameter of input. This parameter can either be a string or an array of characters, and will consist of lowercase characters [a-z].

Optionally, your program/function will take a second parameter containing a dictionary of words. More info on this in the paragraph Dictionary.

Output

You should print or return an array of autocompleted words. For each character in the input, an autocompletion should be added to the output array.

The autocompletions will be taken from the provided dictionary. If a word doesn't exist in the dictionary, it will alphabetically search for the next word matching your characters. If no matching word is found, the input will be returned (see test cases)

Dictionary

If you choose to read the dictionary from a file, the file structure should be your list of words, seperated by newlines.

If you choose to submit the dictionary of words as a parameter of a function call, it should be structured as an ordered list of strings; ['cat', 'cake', ...].

The input is always fully lowercase and sorted alphabetically.

Test case

a.txt content:

```<code>alpha
calf
cave
coax
code
codegimmick
codegolf
cool
gamma
</code>```

Test cases:

```<code>"codegolf"                  // ["calf", "coax", "code", "code", "codegimmick", "codegolf", "codegolf", "codegolf"]
"alpaca"                    // ["alpha", "alpha", "alpha", "alpa", "alpac", "alpaca"]
["t", "h", "i", "s"]        // ["t", "th", "thi", "this"]
("catses", ["cake","cats"]) // ["cake", "cake", "cats", "cats", "catse", "catses"]
</code>```

This is code-golf, shortest code in bytes wins

答:
Mathematica, <s>108</s> 89 bytes

```<code>Select[Append[#2,c=b~StringTake~a],StringStartsQ@c][[1]]~Table~{a,StringLength[b=""<>#]}&
</code>```

No, it isn't very pretty.

Title: Autocomplete the input

Body:
Mathematica, <s>108</s> 89 bytes

Select[Append[#2,c=b~StringTake~a],StringStartsQ@c][[1]]~Table~{a,StringLength[b=""<>#]}&

No, it isn't very pretty.


答:
JavaScript (ES6 / Node.js), 94 bytes

s=>s.map(c=>(d.match(`\\b${p+=c}.*`)||p)+"",p="",d=require("fs").readFileSync("a.txt","utf8"))
```

<p>Anonymous function that takes an array of characters.</p>

<p>Or <strong>52 bytes</strong> in <strong>JavaScript (ES6)</strong> with passing the dictionary as a string:</p>

<pre class="lang-js prettyprint-override"><code>d=>s=>s.map(c=>(d.match(`\\b${p+=c}.*`)||p)+"",p="")
</code>```

Title: Autocomplete the input

Body:
Pre-Note

Because of popular demand, and to avoid disqualifying certain languages, the dictionary can now be provided as input parameter.

Intro

Given a dictionary of words, you should write an autocomplete program or function.

Autocompletion

"Autocomplete, or word completion, is a feature in which an application predicts the rest of a word a user is typing." (Wikipedia)

Autocompletion is oftenly used to reduce the time needed for typing sentences. After typing a single character, the program will start guessing what the user is trying to say. In this challenge we will simulate the behaviour of autocompleting words.

If the program encounters a word it doesn't know, and no matching autocompletion words can be found, it will assume that the user is trying to type a word the program doesn't know. Good autocompletion software will own and edit a custom dictionary of words, but for the sakes of complexity that's not part of this challenge.

Input

Your program/function will take at least a single parameter of input. This parameter can either be a string or an array of characters, and will consist of lowercase characters [a-z].

Optionally, your program/function will take a second parameter containing a dictionary of words. More info on this in the paragraph Dictionary.

Output

You should print or return an array of autocompleted words. For each character in the input, an autocompletion should be added to the output array.

The autocompletions will be taken from the provided dictionary. If a word doesn't exist in the dictionary, it will alphabetically search for the next word matching your characters. If no matching word is found, the input will be returned (see test cases)

Dictionary

If you choose to read the dictionary from a file, the file structure should be your list of words, seperated by newlines.

If you choose to submit the dictionary of words as a parameter of a function call, it should be structured as an ordered list of strings; ['cat', 'cake', ...].

The input is always fully lowercase and sorted alphabetically.

Test case

a.txt content:

```<code>alpha
calf
cave
coax
code
codegimmick
codegolf
cool
gamma
</code>```

Test cases:

```<code>"codegolf"                  // ["calf", "coax", "code", "code", "codegimmick", "codegolf", "codegolf", "codegolf"]
"alpaca"                    // ["alpha", "alpha", "alpha", "alpa", "alpac", "alpaca"]
["t", "h", "i", "s"]        // ["t", "th", "thi", "this"]
("catses", ["cake","cats"]) // ["cake", "cake", "cats", "cats", "catse", "catses"]
</code>```

This is code-golf, shortest code in bytes wins

Body:
JavaScript (ES6 / Node.js), 94 bytes

s=>s.map(c=>(d.match(`\\b${p+=c}.*`)||p)+"",p="",d=require("fs").readFileSync("a.txt","utf8"))

Anonymous function that takes an array of characters.

Or 52 bytes in JavaScript (ES6) with passing the dictionary as a string:

d=>s=>s.map(c=>(d.match(`\\b${p+=c}.*`)||p)+"",p="")


问:
Tips for golfing in PowerShell
What general tips do you have for golfing in Windows PowerShell? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to PowerShell (e.g. "remove comments" is not an answer). Please post one tip per answer.

—taken nearly verbatim from marcog's question.

答:
Invoke-Expression and Get-Random can also get pipeline input instead of arguments.

For iex this allows to save parentheses on some expressions:

```<code>iex 1..5-join'+'   # won't work
iex(1..5-join'+')  # does work, but has extra parentheses
1..5-join'+'|iex   # doesn't need the parentheses
</code>```

In case of random this allows a common case to be optimized a bit:

```<code>random -mi 10 31   # gets a random integer between 10 and 30
10..30|random      # much better :-)
(random 21)+10     # if needed in another expression that doesn't require extra
                   # parentheses
</code>```

The latter way of using it simply selects an item from a list. The -c argument can be given to allow more than a single selection.

Title: Tips for golfing in PowerShell

Body:
Invoke-Expression and Get-Random can also get pipeline input instead of arguments.

For iex this allows to save parentheses on some expressions:

iex 1..5-join'+'   # won't work
iex(1..5-join'+')  # does work, but has extra parentheses
1..5-join'+'|iex   # doesn't need the parentheses

In case of random this allows a common case to be optimized a bit:

random -mi 10 31   # gets a random integer between 10 and 30
10..30|random      # much better :-)
(random 21)+10     # if needed in another expression that doesn't require extra
                   # parentheses

The latter way of using it simply selects an item from a list. The -c argument can be given to allow more than a single selection.

ContentLicense: CC BY-SA 2.5


答:
Braille, 6 bytes

```<code>⠁⡀
</code>```

Self-GOTO with a NOP. If it isn't displayed properly (and/or you want to test it):

```<code>0000000: e2a0 81e2 a180                           ......
</code>```

Body:
Braille, 6 bytes

⠁⡀

Self-GOTO with a NOP. If it isn't displayed properly (and/or you want to test it):

0000000: e2a0 81e2 a180                           ......


问:
Are there More Hard Objects or Soft Objects
Tangentially inspired by the opening to the What-If book.

The input is a rectangle of spaces as a string, list of string, etc., with objects made of #'s inside:

```<code>########
#      #
########

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

The objects will always be non-intersecting, non-touching, rectangles. A soft object is defined as an object that isn't filled up with #'s in the middle and is only a border, a hard object is one that is filled up. An object with width or height <=2 is considered hard. All objects are either hard or soft.

If there are more hard objects in the input, output "Hard", if more soft, output "Soft", if they are equal, output "Equal".

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

Test Cases

These cases aren't full inputs, but rather what each object should be characterized as. The actual input will be like the ascii-art at the top of the question.

Hard

```<code>#

####

##
##

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

Soft

```<code>###
# #
###

###################
#                 #
#                 #
#                 #
###################

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

Actual Test Cases

```<code>########
#      #
########

   ###        ####
   ###        ####
   ###

Hard

###
###
###

###################
#                 #
#                 #
#                 #
###################

Equal

   ######
   #    #
   ######
          ###
   ##  #  # #
          ###

 ########
 #      #
 ########

Soft
</code>```

答:
TSQL, <s>328</s> 249 bytes

Declaring variables and test data:

```<code>DECLARE @l int = 20
DECLARE @ varchar(max)=''
SELECT @+=LEFT(x + replicate(' ', @l), @l)
FROM (values
(' xxxx'),
(' xxxx'),
(' xxxx'),
('x'),
(''),
('xxx'),
('x x  xxx'),
('xxx  x x'),
('     xxx    ')) x(x)
</code>```

Code:

```<code>SELECT substring('Soft EqualHard',sign(sum(iif(substring(@,N,@l+2)like'xx'+replicate('_', @l-2)+'x ',-1,1)))*5+6,5)FROM(SELECT row_number()OVER(ORDER BY Type)N FROM sys.all_objects)x WHERE n<=len(@)AND' x'=substring(@,N-1,2)AND''=substring(@,N-@l,1)
</code>```

Code deflated:

```<code>SELECT
  substring('Soft EqualHard',
    sign(sum(iif(substring(@,N,@l+2)like'xx'+replicate('_', @l-2)+'x ',-1,1)))*5+6,5)
FROM(SELECT row_number()OVER(ORDER BY Type)N FROM sys.all_objects)x
WHERE n<=len(@)AND' x'=substring(@,N-1,2)AND''=substring(@,N-@l,1)
</code>```

Explaination:

Script is scanning the text for the pattern:

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

Each of those is the start of a box

For those positions, the script is then checking for the pattern, don't need to check for first x:

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

When that exists it is a soft object, otherwise it is a hard object.

Body:
TSQL, <s>328</s> 249 bytes

Declaring variables and test data:

DECLARE @l int = 20
DECLARE @ varchar(max)=''
SELECT @+=LEFT(x + replicate(' ', @l), @l)
FROM (values
(' xxxx'),
(' xxxx'),
(' xxxx'),
('x'),
(''),
('xxx'),
('x x  xxx'),
('xxx  x x'),
('     xxx    ')) x(x)

Code:

SELECT substring('Soft EqualHard',sign(sum(iif(substring(@,N,@l+2)like'xx'+replicate('_', @l-2)+'x ',-1,1)))*5+6,5)FROM(SELECT row_number()OVER(ORDER BY Type)N FROM sys.all_objects)x WHERE n<=len(@)AND' x'=substring(@,N-1,2)AND''=substring(@,N-@l,1)

Code deflated:

SELECT
  substring('Soft EqualHard',
    sign(sum(iif(substring(@,N,@l+2)like'xx'+replicate('_', @l-2)+'x ',-1,1)))*5+6,5)
FROM(SELECT row_number()OVER(ORDER BY Type)N FROM sys.all_objects)x
WHERE n<=len(@)AND' x'=substring(@,N-1,2)AND''=substring(@,N-@l,1)

Explaination:

Script is scanning the text for the pattern:

      space
space x

Each of those is the start of a box

For those positions, the script is then checking for the pattern, don't need to check for first x:

  x
x space

When that exists it is a soft object, otherwise it is a hard object.


问:
Solve a quadratic equation using Vieta's formulas

Exposition

Your mathematics teacher is a big fan of Vieta's formulas, and he believes that you should use them to solve quadratic equations. Given the equation

```<code>ax^2 + bx + c = 0
</code>```

the product of its roots is c/a, and their sum is -b/a. When all of a, b and c are nonzero integers, assuming the roots are rational numbers, it's enough to try all possible numbers in the form

```<code>r1 = ±s/t
</code>```

where s is a divisor of abs(c), and t is a divisor of abs(a). For each such r1, plug it into ax^2 + bx + c, and see whether the result is 0. If yes, then r1 is a root. The second root is -b/a-r1 or (c/a)/r1 - you can choose whatever formula you like.

Your teacher decided to give you many exercises, and he expects you to describe how you used Vieta's formulas to solve each one. Each exercise looks like this (example):

```<code>9x^2+12x+4=0
</code>```

Write a subroutine or a program that gets an exercise as input, and outputs your alleged "solving process" to appease your teacher.

Input

Since you will feed the exercise to your program manually, format it in any convenient form. For example, use space-separated values on stdin:

```<code>9 12 4
</code>```

or call a function with 3 parameters:

```<code>SolveExercise(9, 12, 4);
</code>```

or parse the exercise literally:

```<code>9x^2+12x+4=0
</code>```

Your output should be formatted as described below. Use the standard output device or return it as a string from your subroutine.

Output (example)

```<code>x = 1? 9x^2+12x+4 = 25
x = 2? 9x^2+12x+4 = 64
x = 1/3? 9x^2+12x+4 = 9
x = 2/3? 9x^2+12x+4 = 16
... (as many or as few failed attempts as you like)
x = -2/3? 9x^2+12x+4 = 0
r1 = -2/3
r2 = -12/9-(-2/3) = -2/3
</code>```

Alternatively, the last line can be:

```<code>r2 = 4/9/(-2/3) = -2/3
</code>```

Some additional notes:

The minimum number of line-breaks in the output is as described in the example (trailing line-break is not required). Additional line-breaks are permitted.

All coefficients in input are integers in the range [-9999...9999], none can be equal to 0

All roots are rational numbers, and should be output as such - e.g. 0.66666667 is not equal to 2/3 and so is incorrect

In the final expressions for r1 and r2, integers should be output as such, e.g. -99/1 is unacceptable, and should be output as -99; in other places in the output, denominator equal to ±1 is acceptable

Reduced form for rational numbers is not required - e.g. 2/4 is a good substitute for 1/2, even though it's ugly, even for roots r1 and r2

Parentheses in the output are sometimes required by rules of mathematics, e.g. in the expression 12/9/(2/3). When precedence rules of mathematics permit omission of parentheses, they are not required, e.g. -12/9--2/3. Superfluous parentheses are permitted: 4-(2) is OK, even though it's ugly

There should be at least one case (input) for which your program tries 3 or more non-integer values for r1; however, it's allowed to "guess the right answer" almost always on the first try

All trial values for r1 must be rational numbers ±s/t, where s and t are constrained as described above

Test cases

Input

```<code>x^2-x-2=0
</code>```

or

```<code>1 -1 -2
</code>```

Possible output

```<code>r1 = ±s/t
</code>```0

Input

```<code>r1 = ±s/t
</code>```1

or

```<code>r1 = ±s/t
</code>```2

Possible output

```<code>x=1? -x^2+2x-1=0
r1=1
r2=-2/-1-1=1
</code>```

Input

```<code>7x^2-316x+924=0
</code>```

or

```<code>X(7, -316, 924);
</code>```

Possible output (a divisor of 924 is 42, which solves the equation by "luck")

```<code>x=42? 7x^2-316x+924=0
r1=42
r2=316/7-42=22/7
</code>```

Input

```<code>6x^2-35x-6=0
</code>```

or

```<code>[6 -35 -6]
</code>```

Possible output (even though your program may "know" that 6 is a root, it decides to show some failed trials)

```<code>x=1/2? 6x^2-35x-6=-88/4
x=1/3? 6x^2-35x-6=-153/9
x=3/2? 6x^2-35x-6=-180/4
x=6/1? 6x^2-35x-6=0
r1=6
r2=35/6-6=-1/6
</code>```

Alternative versions for the last line:

```<code>9x^2+12x+4=0
</code>```0

Impossible input (no rational solutions)

```<code>9x^2+12x+4=0
</code>```1

Impossible input (zero coefficient)

```<code>9x^2+12x+4=0
</code>```2

答:
Mathematica, 236 Bytes

I'm sure there's a way to shorten this further, but this was my first attempt at learning the language.

Golfed

```<code>s=Input[];f[x_]:=#3 x^2+#1 x+#2&@@s;t=Drop[Z1,1];r=Catch[Do[Print[StringForm["x=``? ``=``",y,f[x],f[y]]];If[f[y]==0,Throw[y]],{y,(Flatten[Outer[Divide,#1,#2]]&@@(Join[#,-#]&/@Divisors[#]&[t]))}]]StringForm["r1=``\nr2=``",r, #1/#2/r&@@t]
</code>```

Ungolfed with comments

```<code>(*Get coefficients in list {B,C,A}*)
s=Input[];

(*Create the function*)
f[x_]:=#3 x^2+#1 x+#2&@@s;

(*Take C and A*)
t=Drop[Z1,1];

(*Get a list of all positive and negative divisors for C and A, then use those to get all possible permutations for R=S/T as given in the challenge*)
(*Print out each attempt at finding a root. If one is found, exit the loop and return it*)

r=Catch[Do[Print[StringForm["x=``? ``=``",y,f[x],f[y]]];If[f[y]==0,Throw[y]],{y,(Flatten[Outer[Divide,#1,#2]]&@@(Join[#,-#]&/@Divisors[#]&[t]))}]];

(*Print the roots using (c/a)/r1 *)
StringForm["r1=``\nr2= ``",r, #1/#2/r&@@t]
</code>```

Coefficients must be entered in the (convenient) form {B,C,A}.

Body:
Mathematica, 236 Bytes

I'm sure there's a way to shorten this further, but this was my first attempt at learning the language.

Golfed

s=Input[];f[x_]:=#3 x^2+#1 x+#2&@@s;t=Drop[Z1,1];r=Catch[Do[Print[StringForm["x=``? ``=``",y,f[x],f[y]]];If[f[y]==0,Throw[y]],{y,(Flatten[Outer[Divide,#1,#2]]&@@(Join[#,-#]&/@Divisors[#]&[t]))}]]StringForm["r1=``\nr2=``",r, #1/#2/r&@@t]

Ungolfed with comments

(*Get coefficients in list {B,C,A}*)
s=Input[];

(*Create the function*)
f[x_]:=#3 x^2+#1 x+#2&@@s;

(*Take C and A*)
t=Drop[Z1,1];

(*Get a list of all positive and negative divisors for C and A, then use those to get all possible permutations for R=S/T as given in the challenge*)
(*Print out each attempt at finding a root. If one is found, exit the loop and return it*)

r=Catch[Do[Print[StringForm["x=``? ``=``",y,f[x],f[y]]];If[f[y]==0,Throw[y]],{y,(Flatten[Outer[Divide,#1,#2]]&@@(Join[#,-#]&/@Divisors[#]&[t]))}]];

(*Print the roots using (c/a)/r1 *)
StringForm["r1=``\nr2= ``",r, #1/#2/r&@@t]

Coefficients must be entered in the (convenient) form {B,C,A}.


答:
Pyth, <s>22</s> 13 bytes

```<code>mhf!xTd+Qd._z
</code>```

```<code>m         _z  map over prefixes of second input...
 hf    +Qd    find the first element in (dictionary+word) which...
   !xTd       ... starts with k
</code>```

Sample run:

```<code>llama@llama:~$ pyth -c 'mhf!xTd+Qd._z'
['alpha', 'calf', 'cave', 'coax', 'code', 'codegimmick', 'codegolf', 'cool', 'gamma']
codegolf
['calf', 'coax', 'code', 'code', 'codegimmick', 'codegolf', 'codegolf', 'codegolf']
</code>```

Thanks to @FryAmTheEggman for 4 bytes!

Title: Autocomplete the input

Body:
Pyth, <s>22</s> 13 bytes

mhf!xTd+Qd._z

m         _z  map over prefixes of second input...
 hf    +Qd    find the first element in (dictionary+word) which...
   !xTd       ... starts with k

Sample run:

llama@llama:~$ pyth -c 'mhf!xTd+Qd._z'
['alpha', 'calf', 'cave', 'coax', 'code', 'codegimmick', 'codegolf', 'cool', 'gamma']
codegolf
['calf', 'coax', 'code', 'code', 'codegimmick', 'codegolf', 'codegolf', 'codegolf']

Thanks to @FryAmTheEggman for 4 bytes!


问:
Subsequence Substitution
Most languages come with a built-in to search a string for all occurrences of a given substring and replace those with another. I don't know of any language that generalises this concept to (not necessarily contiguous) subsequences. So that's your task in this challenge.

The input will consist of three strings A, B and C, where B and C are guaranteed to be of the same length. If B appears as a subsequence in A it should be replaced with C. Here is a simple example:

```<code>A: abcdefghijklmnopqrstuvwxyz
B: ghost
C: 12345
</code>```

It would be processed like this:

```<code>abcdefghijklmnopqrstuvwxyz
      ||      |   ||
abcdef12ijklmn3pqr45uvwxyz
</code>```

If there are several ways to find B as a subsequence, you should greedily replace the left-most one:

```<code>A: abcdeedcba
B: ada
C: BOB

Result:   BbcOeedcbB
and NOT:  BbcdeeOcbB
</code>```

The same applies if B could be found in multiple disjoint places:

```<code>A: abcdeedcbaabcde
B: ed
C: 12

Result:   abcd1e2cbaabcde
and NOT:  abcd112cbaabc2e (or similar)
</code>```

When B does not appear in A, you should output A unchanged.

Rules

As stated above, take three strings A, B and C as input and replace the left-most occurrence of B as a subsequence in A with C, if there is any.

You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.

You may take the three strings in any consistent order which you should specify in your answer. You may assume that B and C have the same length. All strings will only contain alphanumeric characters.

Standard code-golf rules apply.

Test Cases

Each test case is four lines: A, B, C followed by the result.

```<code>abcdefghijklmnopqrstuvwxyz
ghost
12345
abcdef12ijklmn3pqr45uvwxyz

abcdeedcba
ada
BOB
BbcOeedcbB

abcdeedcbaabcde
ed
12
abcd1e2cbaabcde

121
121
aBc
aBc

abcde
acb
123
abcde

ABC
ABCD
1234
ABC

012345678901234567890123456789
42
TT
0123T5678901T34567890123456789

edcbaedcbaedcbaedcba
abcde
12345
edcbaedcbaedcbaedcba

edcbaedcbaedcbaedcbaedcba
abcde
12345
edcb1edc2aed3bae4cba5dcba

daccdedca
ace
cra
dcrcdadca

aacbcbabcccaabcbabcaabbbbca
abaaaccbac
1223334444
aacbcbabcccaabcbabcaabbbbca

aacbcbabcccaabcbabcaabbbbcac
abaaaccbac
1223334444
1ac2cb2bccc33b3bab4aa4bbbc44
</code>```

Leaderboard

The Stack Snippet at the bottom of this post generates leaderboards 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>```

/* Configuration */

var QUESTION_ID = 77719; // Obtain this from the url
// It will be like http://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 "http://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 "http://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}

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

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

table thead {
  font-weight: bold;
}

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
Julia, <s>89</s> 70 bytes

f(s,a,b,i=0)=(o=join(["$a "[i+1]!=c?c:b[i+=1]for c=s]);i<endof(a)?s:o)
```

Uses an index i to iterate through the pattern/replacement strings as we go. -19 bytes thanks to @Dennis!

Title: Subsequence Substitution

Body:
Julia, <s>89</s> 70 bytes

f(s,a,b,i=0)=(o=join(["$a "[i+1]!=c?c:b[i+=1]for c=s]);i<endof(a)?s:o)

Uses an index i to iterate through the pattern/replacement strings as we go. -19 bytes thanks to @Dennis!


问:
Calculate average characters of string

Task

Your task is to produce string that contains average characters of string.
First character of result would be average character of first character (which is first character) and second character average of two first characters and so on.

What is average character?

Strings are arrays of bytes. Average character of string can be found by calculating the average of the ASCII values of characters in string and taking corresponding ASCII character.

For example string "Hello!" can be written as byte sequence 72 101 108 108 111 33. Average of ascii values is 533/6 = 88.833... and when it's rounded to nearest integer we get 89 which is ascii code for captial letter Y.

Rules

You can assume that input contains only printable ASCII characters

Input can be read from stdin or as command line arguments or as function arguments

Output must be stdout. If your program is function, you can also return the string you would otherwise print.

It must be whole program or function, not snippet

Standard loopholes apply

Integers are rounded by function floor(x+0.5) or similar function.

How do I win?

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

Examples

Hello! → HW^adY

test → tmop

42 → 43

StackExchange → Sdccd_ccccddd

答:
TSQL, 118 bytes

```<code>DECLARE @ varchar(400) = 'StackExchange'

SELECT
top(len(@))char(avg(ascii(stuff(@,1,number,''))+.5)over(order by number))FROM
master..spt_values
WHERE'P'=type
</code>```

Returning characters vertical

```<code>S
d
c
c
d
_
c
c
c
c
d
d
d
</code>```

Title: Calculate average characters of string

Body:
TSQL, 118 bytes

DECLARE @ varchar(400) = 'StackExchange'

SELECT
top(len(@))char(avg(ascii(stuff(@,1,number,''))+.5)over(order by number))FROM
master..spt_values
WHERE'P'=type

Returning characters vertical

S
d
c
c
d
_
c
c
c
c
d
d
d


问:
Linear Independence
Given a set of vectors all of the same positive finite dimension, output a falsey value if they are linearly dependent and a truthy value if they are linearly independent. A set of vectors v1, v2, ... is linearly dependent if for some scalars a1, a2, ... not all equal to 0,  a1v1 + a2v2 + ... = 0. (0 is the zero vector.)

Note: Using an inbuilt function to find the rank of a matrix or test vectors for linear dependence is not allowed.

Note 2: All input will be formed from integers.

Test cases (input -> output):

```<code>[[0,1],[2,3]] -> True
[[1,2],[2,4]] -> False
[[2,6,8],[3,9,12]] -> False
[[1,2],[2,3],[3,4]] -> False
[[1,0,0],[0,1,0],[0,0,1]] -> True
[[0]] -> False
[] -> True
[[1,1],[0,1],[1,0]] -> False
[[1,2,3],[1,3,5],[0,0,0]] -> False
</code>```

答:
JavaScript (ES6), 162

M=>M.sort((a,b)=>P(a)-P(b),P=r=>r.findIndex(v=>v)).map(_=>M=M.map((r,i)=>(p=P(r))>q?(k=M[i],q=p,r):r.map((v,j)=>v*k[q]-k[j]*r[p]),q=-1))&&M.every(r=>r.some(v=>v))
```

<p>Reduce the matrix and check if every row has at least 1 non zero element.</p>

<p><em>Less golfed</em></p>

<pre class="lang-js prettyprint-override"><code>M=>(
  P=r=> P=r=>r.findIndex(v=>v)), // First nonzero element position or -1
  // sort to have P in ascending order, but rows all 0 are at top
  M.sort((a,b)=>P(a)-P(b)),
  M.map(_=> // repeat transformation for the number of rows
    M=M.map((r,i)=>(
      p = P(r),
      p > q
       ? (k=M[i], q=p, r)
         // row transform
         // note: a 0s row generate a NaN row as p is -1
       : r.map((v,j) => v*k[q] - k[j]*r[p])
     )
     ,q=-1
    )
  ),
  // return false if there are rows all 0 or all NaN
  M.every(r=>r.some(v=>v))
)
</code>```

Test

F=M=>M.sort((a,b)=>P(a)-P(b),P=r=>r.findIndex(v=>v))
.map(_=>M=M.map((r,i)=>
(p=P(r))>q?(k=M[i],q=p,r):r.map((v,j)=>v*k[q]-k[j]*r[p])
,q=-1))&&M.every(r=>r.some(v=>v))

console.log=(...x)=>O.textContent += x +'\n'

;[[[0,1],[2,3]] // True
,[[1,2],[2,4]] // False
,[[2,6,8],[3,9,12]] // False
,[[1,2],[2,3],[3,4]] // False
,[[1,0,0],[0,1,0],[0,0,1]] // True
,[[0]] // False
,[[0,0],[1,1]] // False
,[] // True
,[[1,1],[0,1],[1,0]] // False
,[[1,2,3],[1,3,5],[0,0,0]] // False
,[[1,2,3],[4,5,6]] // True
].forEach(m=>console.log(m,F(m)))```
<pre class="snippet-code-html lang-html prettyprint-override"><code><pre id=O>``````

Title: Linear Independence

Body:
JavaScript (ES6), 162

M=>M.sort((a,b)=>P(a)-P(b),P=r=>r.findIndex(v=>v)).map(_=>M=M.map((r,i)=>(p=P(r))>q?(k=M[i],q=p,r):r.map((v,j)=>v*k[q]-k[j]*r[p]),q=-1))&&M.every(r=>r.some(v=>v))

Reduce the matrix and check if every row has at least 1 non zero element.

Less golfed

M=>(
  P=r=> P=r=>r.findIndex(v=>v)), // First nonzero element position or -1
  // sort to have P in ascending order, but rows all 0 are at top
  M.sort((a,b)=>P(a)-P(b)),
  M.map(_=> // repeat transformation for the number of rows
    M=M.map((r,i)=>(
      p = P(r),
      p > q
       ? (k=M[i], q=p, r)
         // row transform
         // note: a 0s row generate a NaN row as p is -1
       : r.map((v,j) => v*k[q] - k[j]*r[p])
     )
     ,q=-1
    )
  ),
  // return false if there are rows all 0 or all NaN
  M.every(r=>r.some(v=>v))
)

Test

F=M=>M.sort((a,b)=>P(a)-P(b),P=r=>r.findIndex(v=>v))
.map(_=>M=M.map((r,i)=>
(p=P(r))>q?(k=M[i],q=p,r):r.map((v,j)=>v*k[q]-k[j]*r[p])
,q=-1))&&M.every(r=>r.some(v=>v))

console.log=(...x)=>O.textContent += x +'\n'

;[[[0,1],[2,3]] // True
,[[1,2],[2,4]] // False
,[[2,6,8],[3,9,12]] // False
,[[1,2],[2,3],[3,4]] // False
,[[1,0,0],[0,1,0],[0,0,1]] // True
,[[0]] // False
,[[0,0],[1,1]] // False
,[] // True
,[[1,1],[0,1],[1,0]] // False
,[[1,2,3],[1,3,5],[0,0,0]] // False
,[[1,2,3],[4,5,6]] // True
].forEach(m=>console.log(m,F(m)))

<pre id=O></pre>


问:
The Ackermann function
The Ackermann function is notable for being the one of the simplest examples of a total, computable function that isn't primitive recursive.

We will use the definition of \$A(m,n)\$ taking in two nonnegative integers where

$$\begin{align}
A(0,n) & = n+1 \\
A(m,0) & = A(m-1,1) \\
A(m,n) & = A(m-1,A(m,n-1))
\end{align}$$

You may implement

a named or anonymous function taking two integers as input, returning an integer, or

a program taking two space- or newline-separated integers on STDIN, printing a result to STDOUT.

You may not use an Ackermann function or hyperexponentiation function from a library, if one exists, but you may use any other function from any other library. Regular exponentiation is allowed.

Your function must be able to find the value of \$A(m,n)\$ for \$m \le 3\$ and \$n \le 10\$ in less than a minute. It must at least theoretically terminate on any other inputs: given infinite stack space, a native Bigint type, and an arbitrarily long period of time, it would return the answer. Edit: If your language has a default recursion depth that is too restrictive, you may reconfigure that at no character cost.

The submission with the shortest number of characters wins.

Here are some values, to check your answer:

$$\begin{array}{c|cccccccccc}
A & n = 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\
\hline
m=0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 \\
2 & 3 & 5 & 7 & 9 & 11 & 13 & 15 & 17 & 19 & 21 & 23 \\
3 & 5 & 13 & 29 & 61 & 125 & 253 & 509 & 1021 & 2045 & 4093 & 8189 \\
4 & 13 & 65533 & \text{big}
\end{array}$$

答:
UGL, <s>31</s> 30 bytes

```<code>iiRuldr%l%lR$d%rd:u%d:%+uRu:ro
</code>```

Input separated by newlines.

Try it online!

(It has been implemented as a standard example in the interpreter.)

ContentLicense: CC BY-SA 4.0

Title: The Ackermann function

Body:
UGL, <s>31</s> 30 bytes

iiRuldr%l%lR$d%rd:u%d:%+uRu:ro

Input separated by newlines.

Try it online!

(It has been implemented as a standard example in the interpreter.)


答:
Pyth, 15 bytes

```<code>M?GgtG?HgGtH1hH
</code>```

Try it online! (sample usage of the function g3T added, which means g(3,10))

Title: The Ackermann function

Body:
The Ackermann function is notable for being the one of the simplest examples of a total, computable function that isn't primitive recursive.

We will use the definition of \$A(m,n)\$ taking in two nonnegative integers where

$$\begin{align}
A(0,n) & = n+1 \\
A(m,0) & = A(m-1,1) \\
A(m,n) & = A(m-1,A(m,n-1))
\end{align}$$

You may implement

a named or anonymous function taking two integers as input, returning an integer, or

a program taking two space- or newline-separated integers on STDIN, printing a result to STDOUT.

You may not use an Ackermann function or hyperexponentiation function from a library, if one exists, but you may use any other function from any other library. Regular exponentiation is allowed.

Your function must be able to find the value of \$A(m,n)\$ for \$m \le 3\$ and \$n \le 10\$ in less than a minute. It must at least theoretically terminate on any other inputs: given infinite stack space, a native Bigint type, and an arbitrarily long period of time, it would return the answer. Edit: If your language has a default recursion depth that is too restrictive, you may reconfigure that at no character cost.

The submission with the shortest number of characters wins.

Here are some values, to check your answer:

$$\begin{array}{c|cccccccccc}
A & n = 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\
\hline
m=0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 \\
2 & 3 & 5 & 7 & 9 & 11 & 13 & 15 & 17 & 19 & 21 & 23 \\
3 & 5 & 13 & 29 & 61 & 125 & 253 & 509 & 1021 & 2045 & 4093 & 8189 \\
4 & 13 & 65533 & \text{big}
\end{array}$$

Body:
Pyth, 15 bytes

M?GgtG?HgGtH1hH

Try it online! (sample usage of the function g3T added, which means g(3,10))


问:
Make a better score than my students!
For the last day of the semester, I decided to have some fun with my students and I showed them Code Golf... poor guys, they're addicted now.

The goal was to compete against the other students to solve those problems with what would be very usual rules for you. They had to use C# (because it's the language they are learning right now) so please do the same.

The length of each method must be the shortest including the method signature!

Tasks

Write functions that do the following:

Input: string, int.

Output: string.

Description: the output string repeats the input string as many times as the input int.

Example: a("Hi", 5) returns "HiHiHiHiHi".

Input: int.

Output: int.

Description: the output is the quantity of prime numbers lower or equal to the input.

Example: b(10) returns 4. b(100) returns 25.

Input: object[].

Output: object[].

Description: returns the input without the null values.

Example: c(new object[] { "Hello", 42, null, new Program(), null, null, false }) returns an array containing [Hello, 42, Program instance, false].

Input: int.

Output: int.

Description: the output is the sum of all the integers from 1 to int input.

Example: d(4) returns 10 (because 1 + 2 + 3 + 4 = 10).

Input: char.

Output: char.

Description: the output is the input char with the other case. non-letters don't need to be checked.

Example: e('a') returns 'A'. e('A') returns 'a'. e('-') may have unexpected results.

Input: string, int.

Output: bool.

Description: true if and only if the length of the input string is a multiple of the input int.

Example: f("Programmer", 5) returns true. f("Programming", 5) returns false.

Input: string.

Output: boolean.

Description: true if and only if the input string is a palindrome.

Example: g("level") returns true. g('label') returns false.

Their solutions

I took the best of each task that they presented to me.

64

135

105

30

71

45

83

Total: 533

(I will write their complete answers when the challenge is over).

Your rules

Use C# to be evaluated equally to my students.

Write each task on a separate line with the method signature (string a(string s,int i)), it is part of the answer.

Write your best score for each task so we know what score matches what task.

Write the sum of all task scores in the title of your answer.

The shortest overall score wins, but honorary mention may be awarded to the lowest score of a given task.

Note: It is not impossible that many of you have the same answer, my students did without cheating. Please consider that someont who has the same answer as you may simply have taken the same path and did not steal your idea.

FAQ:

Why should people here use C#? It's not the best language for code golfing !

I know, but I would like to have some examples from pros like you to show them what a real golfer would do in their shoes.

答:
Score: 387

string a(string s,int n){return string.Join(s,new string[n+1]);} (64)

int b(int n){bool p=true;for(int i=2;i<n;i++)if(n%i<1)p=false;return n<2?0:b(n-1)+(p?1:0);} (91)

object[]c(object[]l){return l.Where(x=>x!=null).ToArray();} (59)

int d(int n){return(n+1)*n/2;} (30)

char e(char c){return(char)(c<97?c+32:c-32);} (45)

bool f(string s,int n){return s.Length%n<1;} (44)

bool g(string s){return s.SequenceEqual(s.Reverse());} (54)

Total: 387

Title: Make a better score than my students!


答:
Python 3, 94 bytes

```<code>s=""
for c in input():s+=c;print(next((o for o in open("a.txt")if o.startswith(s)),s).strip())
</code>```

Title: Autocomplete the input

Body:
Python 3, 94 bytes

s=""
for c in input():s+=c;print(next((o for o in open("a.txt")if o.startswith(s)),s).strip())


问:
Josephus problem with three inputs
There's a question on this site that is similar to this question, but I have added a twist.

You have three inputs, the number of people in the circle n, the k-th person counted out at each step, and the q-th person that survives. The people in the circle are numbered 1 to n.

For example, in a circle of 20 people, the 20th person to survive is the very first person removed, the 19th survivor is the second person removed and so on. Normally, the Josephus problem is to determine the last person removed, here called the first survivor.

Write the shortest program or function that, with those three inputs, returns the number of the q-th person to survive.

If there are any issues with clarity, please let me know.

Some examples:

```<code>>>> josephus(20, 3, 9)
4
>>> josephus(4, 3, 1)
1
>>> josephus(100, 9, 12)
46
</code>```

Edit: Assume all inputs are valid. That is no one will ask for 0 or any negative numbers and no one will ask for the 20th survivor in a circle of 5 people (that is, 1 ≤ q ≤ n)

Edit: I'll accept an answer at midnight UTC+7 at the start of December 2.

答:
GameMaker Language (GML), 88 bytes

Based on @user81655's answer

```<code>r=argument0
k=argument1
q=argument2
r=(k-1)mod q;for(i=q;i<n;r=(r+k)mod ++i){}return r+1
</code>```

Title: Josephus problem with three inputs

Body:
GameMaker Language (GML), 88 bytes

Based on @user81655's answer

r=argument0
k=argument1
q=argument2
r=(k-1)mod q;for(i=q;i<n;r=(r+k)mod ++i){}return r+1


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

```

Title: "Hello, World!"

Body:
UGL, 80 bytes

cuu$u$$$$$$*$d*O$*u$*u$O$@++u$O$O^^+$O@@$$uu**dO%$$*$**$O@$*$u*dddO%$OuuuO%OdOuO

<a href="http://schas002.github.io/Unipants-Golfing-Language/?code=I0ggIGUgICBsICAgbCAgIG8gICAsICAgICBXICBvICAgciAgIGwgICBkICAgIQojNzIgMTAxIDEwOCAxMDggMTExIDQ0IDMyIDg3IDExMSAxMTQgMTA4IDEwMCAzMwpjdXUkdSQkJCQkJCokZCpPICAjcHJpbnQgSCAgNzIgICAgICAgIChzdGFjazoyIDMgMyAzIDMgMyAzKQokKnUkKnUkTyRAICAgICAgICAjcHJpbnQgZSAgMTAxICAgICAgIChzdGFjazoxMDEgMiAzIDMgMyAzIDEwMSkKKyt1JE8kTyAgICAgICAgICAgI3ByaW50IGxsIDEwOCAxMDggICAoc3RhY2s6MTAxIDIgMyAzIDEwOCkKXl4rJE9AQCAgICAgICAgICAgI3ByaW50IG8gIDExMSAgICAgICAoc3RhY2s6MTA4IDExMSAxMDEgMiAzIDMpCiQkdXUqKmRPICAgICAgICAgICNwcmludCAsICA0NCAgICAgICAgKHN0YWNrOjEwOCAxMTEgMTAxIDIgMykKJSQkKiQqKiRPQCAgICAgICAgI3ByaW50ICAgIDMyICAgICAgICAoc3RhY2s6MzIgMTA4IDExMSAxMDEgMykKJCokdSpkZGRPICAgICAgICAgI3ByaW50IFcgIDg3ICAgICAgICAoc3RhY2s6MzIgMTA4IDExMSAxMDEpCiUkTyAgICAgICAgICAgICAgICNwcmludCBvICAxMTEgICAgICAgKHN0YWNrOjMyIDEwOCAxMDEgMTExKQp1dXVPICAgICAgICAgICAgICAjcHJpbnQgciAgMTE0ICAgICAgIChzdGFjazozMiAxMDggMTAxKQolTyAgICAgICAgICAgICAgICAjcHJpbnQgbCAgMTA4ICAgICAgIChzdGFjazozMiAxMDEpCmRPICAgICAgICAgICAgICAgICNwcmludCBkICAxMDAgICAgICAgKHN0YWNrOjMyKQp1TyAgICAgICAgICAgICAgICAjcHJpbnQgISAgMzMgICAgICAgIChzdGFjazop&input=" rel="nofollow">Try it online!

With comments:

#H  e   l   l   o   ,     W  o   r   l   d   !
#72 101 108 108 111 44 32 87 111 114 108 100 33
cuu$u$$$$$$*$d*O  #print H  72        (stack:2 3 3 3 3 3 3)
$*u$*u$O$@        #print e  101       (stack:101 2 3 3 3 3 101)
++u$O$O           #print ll 108 108   (stack:101 2 3 3 108)
^^+$O@@           #print o  111       (stack:108 111 101 2 3 3)
$$uu**dO          #print ,  44        (stack:108 111 101 2 3)
%$$*$**$O@        #print    32        (stack:32 108 111 101 3)
$*$u*dddO         #print W  87        (stack:32 108 111 101)
%$O               #print o  111       (stack:32 108 101 111)
uuuO              #print r  114       (stack:32 108 101)
%O                #print l  108       (stack:32 101)
dO                #print d  100       (stack:32)
uO                #print !  33        (stack:)


问:
Calculator that adds char values

Task

Build a calculator, that takes any string, from a file, stdin or whatever, and adds up all the values of the chars.

Example

```<code>Input
Hello World!

Output
1085
</code>```

Rules

The calculator needs to accept just ASCII encoding.

The shortest code wins.

Notes

Regarding to the comment of m.buettner, I need to say, I didn't thought of the multibyte part.

So I leave it as a bonus thing aswell.

The calculator should be run as written, so no need to modify before compiling or interpreting.

Bonus

Thanks to Synthetica, here is one more bonus,

The program that has the lowest output when you use its code as its input wins gets a star.

I don't want to modify it completly.

If you write it additional to output the (right) value in UTF-8 you get a star.

The code that executes fastest on my Laptop (Lenovo Yoga 13 Intel Core i5 3317U 1.7Ghz, 8GB RAM, 128GB SSD, Intel HD 4000, Windows 8) gets a star.

Web codes will run first under IE11 with chakra and then in FireFox 29.0.1 with SpiderMonkey

Linux code will run on a Raspberry Pi with Raspbian.

The teststring is this:

```<code>q/%8hnp>T%y?'wNb\},9krW &D9']K$n;l.3O+tE*$*._B^s!@k\&Cl:EO1zo8sVxEvBxCock_I+2o6 yeX*0Xq:tS^f)!!7=!tk9K<6#/E`ks(D'$z$\6Ac+MT&[s[]_Y(`<g%"w%cW'`c&q)D$0#C$QGf>?A$iawvc,}`9!('`c&q)D$0#C$QGf>?A$iawvc,}`9!(
</code>```

Have fun coding :)

Bonusscoring

I plan to do the scoring at this Saturday so the 07.06.14, all answers after that date won't get bonus points ;)

You can download the code I gonna use for testing here feel free to fork and improve it :)

Little update because of the bonus, my laptop is partially broken so I will do it probably next weekend, I am really sorry for that :(

答:
Unipants' Golfing Language, 8 bytes

```<code>cIl+I:_o
</code>```

Try it online!

Returns 660 given its own source code.

Explanation

```<code>cIl+I:_o
c        # Create an integer. We need it - you'll see why.
 I       # Input the first character.
  l  :   # While loop.
   +     # Add the character value to the integer. This is
         # why we needed an integer. Otherwise, there would
         # only be 1 item in a stack now, and the "+" op is
         # not defined for this case. In fact, it returns 0
    I    # Input the next character.
      _  # Discard a zero (the zero from the last input,
         # representing the End Of Line).
       o # Output the result.
</code>```

Title: Calculator that adds char values

Body:
Unipants' Golfing Language, 8 bytes

cIl+I:_o

Try it online!

Returns 660 given its own source code.

Explanation

cIl+I:_o
c        # Create an integer. We need it - you'll see why.
 I       # Input the first character.
  l  :   # While loop.
   +     # Add the character value to the integer. This is
         # why we needed an integer. Otherwise, there would
         # only be 1 item in a stack now, and the "+" op is
         # not defined for this case. In fact, it returns 0
    I    # Input the next character.
      _  # Discard a zero (the zero from the last input,
         # representing the End Of Line).
       o # Output the result.


答:
Mathcad, 60 "bytes"

Mathcad is mathematical application based on 2D worksheets comprised of "regions" each of which can be text, a mathematical expression, program, plot or scripted component.

A mathematical or programming instruction is picked from a palette toolbar or entered using a keyboard shortcut. For golfing purposes, an operation ("byte") is taken to be the number of keyboard operations necessary to create a name or expression (for example, to set the variable a to 3, we would write a:=3. The definition operator := is a single keypress ":", as are a and 3 giving a total of 3 "bytes". The programming for operator requires typing ctl-shft-# (or a single click on the programming toolbar) so again is equivalent to 1 byte.

In Mathcad the user enters programming language commands using keyboard shortcuts (or picking them from the Programming Toolbar) rather than writing them in text. For example, typing ctl-] creates a while-loop operator that has two "placeholders" for entering the condition and a single line of the body, respectively. Typing = at the end of a Mathcad expressions causes Mathcad to evaluate the expression.

(Count bytes) By looking at it from a user input perspective and equating one Mathcad input operation (keyboard usually, mouse-click on toolbar if no kbd shortcut) to a character and interpreting this as a byte. csort = 5 bytes as it's typed char-by-char as are other variable/function names. The for operator is a special construct that occupies 11 characters (including 3 blank "placeholders" and 3 spaces) but is entered by ctl-shft-#, hence = 1 byte (similar to tokens in some languages). Typing ' (quote) creates balanced parentheses (usually) so counts as 1 byte. Indexing v = 3 bytes (type v[k).

Title: Calculate average characters of string

Body:
Task

Your task is to produce string that contains average characters of string.
First character of result would be average character of first character (which is first character) and second character average of two first characters and so on.

What is average character?

Strings are arrays of bytes. Average character of string can be found by calculating the average of the ASCII values of characters in string and taking corresponding ASCII character.

For example string "Hello!" can be written as byte sequence 72 101 108 108 111 33. Average of ascii values is 533/6 = 88.833... and when it's rounded to nearest integer we get 89 which is ascii code for captial letter Y.

Rules

You can assume that input contains only printable ASCII characters

Input can be read from stdin or as command line arguments or as function arguments

Output must be stdout. If your program is function, you can also return the string you would otherwise print.

It must be whole program or function, not snippet

Standard loopholes apply

Integers are rounded by function floor(x+0.5) or similar function.

How do I win?

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

Examples

Hello! → HW^adY

test → tmop

42 → 43

StackExchange → Sdccd_ccccddd


答:
Mathcad, 11 "bytes"

Uses Mathcad's built-in vector summation operator.   As "whatever" is an input method, the user types the word directly into the argument for the function str2vec (which converts a string to a vector of its character codes).

Title: Calculator that adds char values

Body:
Task

Build a calculator, that takes any string, from a file, stdin or whatever, and adds up all the values of the chars.

Example

```<code>Input
Hello World!

Output
1085
</code>```

Rules

The calculator needs to accept just ASCII encoding.

The shortest code wins.

Notes

Regarding to the comment of m.buettner, I need to say, I didn't thought of the multibyte part.

So I leave it as a bonus thing aswell.

The calculator should be run as written, so no need to modify before compiling or interpreting.

Bonus

Thanks to Synthetica, here is one more bonus,

The program that has the lowest output when you use its code as its input wins gets a star.

I don't want to modify it completly.

If you write it additional to output the (right) value in UTF-8 you get a star.

The code that executes fastest on my Laptop (Lenovo Yoga 13 Intel Core i5 3317U 1.7Ghz, 8GB RAM, 128GB SSD, Intel HD 4000, Windows 8) gets a star.

Web codes will run first under IE11 with chakra and then in FireFox 29.0.1 with SpiderMonkey

Linux code will run on a Raspberry Pi with Raspbian.

The teststring is this:

```<code>q/%8hnp>T%y?'wNb\},9krW &D9']K$n;l.3O+tE*$*._B^s!@k\&Cl:EO1zo8sVxEvBxCock_I+2o6 yeX*0Xq:tS^f)!!7=!tk9K<6#/E`ks(D'$z$\6Ac+MT&[s[]_Y(`<g%"w%cW'`c&q)D$0#C$QGf>?A$iawvc,}`9!('`c&q)D$0#C$QGf>?A$iawvc,}`9!(
</code>```

Have fun coding :)

Bonusscoring

I plan to do the scoring at this Saturday so the 07.06.14, all answers after that date won't get bonus points ;)

You can download the code I gonna use for testing here feel free to fork and improve it :)

Little update because of the bonus, my laptop is partially broken so I will do it probably next weekend, I am really sorry for that :(


答:
><>, 30 bytes

```<code>i:0(?v
v &l~<
\+l2(?
\&,12,+o;
</code>```

The first line reads from stdin and puts the characters on the stack

The second will remove the EOL char, take the size of the stack and put it in the & register

The third line will add numbers on the stack while there are two or more of them

The fourth line will divide the resulting number by the register's value, then add 1/2, output the value as a character and stop. When faced with a float value when displaying a char, ><> will floor it, which is why we added 1/2

You can try it on the online interpreter but then you need to use the following version, because the online interpreter pads the code box to a rectangle and applies ? to spaces.

```<code>i:0(?v
v &l~<
\+l2(   ?
\&,12,+o;
</code>```

Title: Calculate average characters of string

Body:
><>, 30 bytes

i:0(?v
v &l~<
\+l2(?
\&,12,+o;

The first line reads from stdin and puts the characters on the stack

The second will remove the EOL char, take the size of the stack and put it in the & register

The third line will add numbers on the stack while there are two or more of them

The fourth line will divide the resulting number by the register's value, then add 1/2, output the value as a character and stop. When faced with a float value when displaying a char, ><> will floor it, which is why we added 1/2

You can try it on the online interpreter but then you need to use the following version, because the online interpreter pads the code box to a rectangle and applies ? to spaces.

i:0(?v
v &l~<
\+l2(   ?
\&,12,+o;


问:
Winnable Solitaire Mancala Boards
Mancala is the name of a family of board games that usually involve a series of cups filled with beads that the players manipulate. This challenge will use a specific rule set for a solitaire variant of the game.

The board consists of a "basket" at one end, followed by an infinite number of cups, numbered starting from 1. Some of the cups will have some number of beads in them. If the nth cup has exactly n beads in it, you may "sow" the beads from it. Sowing means to take all n beads out of the cup, then deposit them one at a time in each cup towards the basket. The last bead will go into the basket. The player wins when all of the beads on the board are in the basket.

Clearly, there are many boards which are not winnable, such as if there is exactly one bead in the second cup. There are no legal plays because all the cups with 0 beads cannot be sown, and the second cup does not have enough beads to be sown. This is obviously no fun, so your task will be to create winnable boards.

Task

Given a positive integer representing a number of beads output a list of non-negative integers representing the number of beads that should be put in each cup to make a winnable board as described above. This list should not contain any trailing zeroes.

For any given number of beads, there is always exactly one winnable board configuration.

Demonstration

This is a demonstration of how to play the winnable board for and input of 4. The winnable board is [0, 1, 3]. We start with the only available move, sowing the beads from the third cup to get [1, 2, 0]. Now we actually have a choice, but the only correct one is sowing the first cup, getting: [0, 2, 0]. Then we sow the second cup yielding [1, 0, 0] and finally we sow the first cup again to get all empty cups.

Test cases:

```<code>1 => [1]
2 => [0, 2]
3 => [1, 2]
4 => [0, 1, 3]
5 => [1, 1, 3]
6 => [0, 0, 2, 4]
7 => [1, 0, 2, 4]
8 => [0, 2, 2, 4]
9 => [1, 2, 2, 4]
10 => [0, 1, 1, 3, 5]
11 => [1, 1, 1, 3, 5]
12 => [0, 0, 0, 2, 4, 6]
13 => [1, 0, 0, 2, 4, 6]
14 => [0, 2, 0, 2, 4, 6]
15 => [1, 2, 0, 2, 4, 6]
16 => [0, 1, 3, 2, 4, 6]
17 => [1, 1, 3, 2, 4, 6]
18 => [0, 0, 2, 1, 3, 5, 7]
19 => [1, 0, 2, 1, 3, 5, 7]
20 => [0, 2, 2, 1, 3, 5, 7]
</code>```

Big thanks to PeterTaylor for coming up with a program to generate test cases!

答:
Python, 42 41 bytes

```<code>m=lambda n,i=2:n*[1]and[n%i]+m(n-n%i,i+1)
</code>```

Title: Winnable Solitaire Mancala Boards

Body:
Python, 42 41 bytes

m=lambda n,i=2:n*[1]and[n%i]+m(n-n%i,i+1)


答:
JavaScript (ES6), <s>63</s> 37 bytes

```<code>f=(n,d=2)=>n?[n%d,...f(n-n%d,d+1)]:[]
</code>```

Port of @orlp's Python answer. Explanation: Consider the total number of beads in the ith and higher cups. Each play from one of these cups will remove i beads from that total. (For instance, if i is 3, and you play from the fifth cup, you reduce the number of beads in that cup by five, but you also add one to both the fourth and the third cups.) The total must therefore be a multiple of i. Now the i-1th cup cannot contain i or more beads, so in order for it to leave a multiple of i it must contain the remainder of the beads modulo i.

Previous explanation (from @xnor's link): The naive approach is the "reverse playing" technique. This uses the observation that making a play empties a cup, so reverse playing collects a bead from each cup and puts them in the first empty cup, like so (63 bytes):

```<code>f=n=>n?[...a=f(n-1),0].some((m,i)=>(m?a[i]--:a[i]=i+1)>m)&&a:[]
</code>```

Now, just consider the first i cups. In the case that one of them is empty, reverse playing will add 1 to the total number of beads in those cups, while in the case that none of them is empty, reverse playing will subtract i from the total, however this is equivalent to adding 1 modulo i+1. After n reverse plays the sum of the beads in the first i cups will therefore be equivalent to n modulo i+1, or put it another way, the number of beads in the ith cup will be equivalent to n minus the sum of the beads in the preceding cups, modulo i+1. Now for the ith cup to be playable the number of beads cannot exceed i, so in fact it will equal the number of remaining beads modulo i+1. (Note that I use d=i+1 as it uses fewer bytes.)

Title: Winnable Solitaire Mancala Boards

Body:
Mancala is the name of a family of board games that usually involve a series of cups filled with beads that the players manipulate. This challenge will use a specific rule set for a solitaire variant of the game.

The board consists of a "basket" at one end, followed by an infinite number of cups, numbered starting from 1. Some of the cups will have some number of beads in them. If the nth cup has exactly n beads in it, you may "sow" the beads from it. Sowing means to take all n beads out of the cup, then deposit them one at a time in each cup towards the basket. The last bead will go into the basket. The player wins when all of the beads on the board are in the basket.

Clearly, there are many boards which are not winnable, such as if there is exactly one bead in the second cup. There are no legal plays because all the cups with 0 beads cannot be sown, and the second cup does not have enough beads to be sown. This is obviously no fun, so your task will be to create winnable boards.

Task

Given a positive integer representing a number of beads output a list of non-negative integers representing the number of beads that should be put in each cup to make a winnable board as described above. This list should not contain any trailing zeroes.

For any given number of beads, there is always exactly one winnable board configuration.

Demonstration

This is a demonstration of how to play the winnable board for and input of 4. The winnable board is [0, 1, 3]. We start with the only available move, sowing the beads from the third cup to get [1, 2, 0]. Now we actually have a choice, but the only correct one is sowing the first cup, getting: [0, 2, 0]. Then we sow the second cup yielding [1, 0, 0] and finally we sow the first cup again to get all empty cups.

Test cases:

```<code>1 => [1]
2 => [0, 2]
3 => [1, 2]
4 => [0, 1, 3]
5 => [1, 1, 3]
6 => [0, 0, 2, 4]
7 => [1, 0, 2, 4]
8 => [0, 2, 2, 4]
9 => [1, 2, 2, 4]
10 => [0, 1, 1, 3, 5]
11 => [1, 1, 1, 3, 5]
12 => [0, 0, 0, 2, 4, 6]
13 => [1, 0, 0, 2, 4, 6]
14 => [0, 2, 0, 2, 4, 6]
15 => [1, 2, 0, 2, 4, 6]
16 => [0, 1, 3, 2, 4, 6]
17 => [1, 1, 3, 2, 4, 6]
18 => [0, 0, 2, 1, 3, 5, 7]
19 => [1, 0, 2, 1, 3, 5, 7]
20 => [0, 2, 2, 1, 3, 5, 7]
</code>```

Big thanks to PeterTaylor for coming up with a program to generate test cases!

Body:
JavaScript (ES6), <s>63</s> 37 bytes

f=(n,d=2)=>n?[n%d,...f(n-n%d,d+1)]:[]

Port of @orlp's Python answer. Explanation: Consider the total number of beads in the ith and higher cups. Each play from one of these cups will remove i beads from that total. (For instance, if i is 3, and you play from the fifth cup, you reduce the number of beads in that cup by five, but you also add one to both the fourth and the third cups.) The total must therefore be a multiple of i. Now the i-1th cup cannot contain i or more beads, so in order for it to leave a multiple of i it must contain the remainder of the beads modulo i.

Previous explanation (from @xnor's link): The naive approach is the "reverse playing" technique. This uses the observation that making a play empties a cup, so reverse playing collects a bead from each cup and puts them in the first empty cup, like so (63 bytes):

f=n=>n?[...a=f(n-1),0].some((m,i)=>(m?a[i]--:a[i]=i+1)>m)&&a:[]

Now, just consider the first i cups. In the case that one of them is empty, reverse playing will add 1 to the total number of beads in those cups, while in the case that none of them is empty, reverse playing will subtract i from the total, however this is equivalent to adding 1 modulo i+1. After n reverse plays the sum of the beads in the first i cups will therefore be equivalent to n modulo i+1, or put it another way, the number of beads in the ith cup will be equivalent to n minus the sum of the beads in the preceding cups, modulo i+1. Now for the ith cup to be playable the number of beads cannot exceed i, so in fact it will equal the number of remaining beads modulo i+1. (Note that I use d=i+1 as it uses fewer bytes.)


答:
Ruby, 36 bytes

A port of @orlp's answer because it's far too genius for me to think of anything better.

```<code>m=->n,i=2{n>0?[n%i]+m[n-n%i,i+1]:[]}
</code>```

Title: Winnable Solitaire Mancala Boards

Body:
Ruby, 36 bytes

A port of @orlp's answer because it's far too genius for me to think of anything better.

m=->n,i=2{n>0?[n%i]+m[n-n%i,i+1]:[]}


问:
The Luhn algorithm for verifying credit card numbers, etc

Challenge

Write the shortest program or function to calculate the Luhn Algorithm for verifying (credit card) numbers.

Luhn algorithm explained

From RosettaCode, this algorithm for the purposes of this challenge is specified as such, with the example input of 49927398716:

```<code>Reverse the digits, make an array:
    6, 1, 7, 8, 9, 3, 7, 2, 9, 9, 4
Double the numbers in odd indexes:
    6, 2, 7, 16, 9, 6, 7, 4, 9, 18, 4
Sum the digits in each number:
    6, 2, 7, 7, 9, 6, 7, 4, 9, 9, 4
Sum all of the numbers:
    6 + 2 + 7 + 7 + 9 + 6 + 7 + 4 + 9 + 9 + 4 = 70
If the sum modulo 10 is 0, then the number is valid:
    70 % 10 = 0 => valid
</code>```

IO Rules

Input: A string or number (your choice), in your language's input/output format of choice

Output: A truthy or falsy value, respectively, indicating whether or not the input is valid according to the test above.

Notes / Tips

Try not to accidentally post your own credit card or account numbers, if you use them to test :)

If the input is invalid and impossible to process with the specified algorithm (i.e, too short to work with), you can do whatever you want, including blow up my computer.

However, the previous bullet does not mean that your language can do whatever it wants with Numbers that are too large for it to handle. If your language isn't capable of handling a test case, then consider taking a string as input.

Examples

The following examples were validated with this Python script; if you think one is wrong or have a question, just ping @cat.

```<code>49927398716      True
49927398717      False
1234567812345670 True
1234567812345678 False
79927398710      False
79927398711      False
79927398712      False
79927398713      True
79927398714      False
79927398715      False
79927398716      False
79927398717      False
79927398718      False
79927398719      False
374652346956782346957823694857692364857368475368 True
374652346956782346957823694857692364857387456834 False
8 False **
0 True  **
</code>```

** according to the Python implementation, but you may do anything because these are too short to be eligible by a strict adherence to the specification.

If any of the above invalidates existing answers (though I believe that should not be possible), then those answers are stil valid. However, new answers, in order to be valid, should follow the specification above.

Leaderboard

var QUESTION_ID=22,OVERRIDE_USER=73772;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

```

答:
Retina, <s>43</s> 42 bytes

Retina is (much) newer than this challenge.

```<code>
;
r`(.);.
$1$&
\d
$*
1+
$.&
.
$*
$
$._
0$</code>```

The leading empty line is significant.

Prints 0 for falsy and 1 for truthy results.

Try it online! (Slightly modified to run all test cases at once.)

Explanation

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

Insert ; in every position to separate digits.

```<code>r`(.);.
$1$&
</code>```

From the right, we repeatedly match two digits and double the left one. This way we avoid an expensive reversing of the list.

```<code>\d
$*
</code>```

We match each digit and convert it to that many 1s (that is, we convert each digit to unary).

```<code>1+
$.&
</code>```

This matches each unary number and converts it back to decimal by replacing it with its length. Together with the previous stage, this adds the doubled digits.

```<code>.
$*
</code>```

Again, we match every character and turn it into that many 1s. That is we convert each digit individually back to unary. This also matches the ; separators, which are treated as zeros in the conversion, which means they're simply removed. Since all the unary numbers are now squashed together we've automatically added the unary representations of the all digits together.

```<code>$
$._
</code>```

At the end, we insert the length of the entire string, i.e. the decimal representation of the unary checksum.

```<code>0$
</code>```

Finally we count the number of matches of this regex, i.e. we check whether the decimal representation ends in 0, printing 0 or 1 accordingly.

Body:
Retina, <s>43</s> 42 bytes

Retina is (much) newer than this challenge.

;
r`(.);.
$1$&
\d
$*
1+
$.&
.
$*
$
$._
0$

The leading empty line is significant.

Prints 0 for falsy and 1 for truthy results.

<a href="http://retina.tryitonline.net/#code=JShHYAoKOwpyYCguKTsuCiQxJCYKXGQKJCoKMSsKJC4mCi4KJCoKJAokLl8KTWAwJAopR2A&input=NDk5MjczOTg3MTYKMTIzNDU2NzgxMjM0NTY3MAo3OTkyNzM5ODcxMwozNzQ2NTIzNDY5NTY3ODIzNDY5NTc4MjM2OTQ4NTc2OTIzNjQ4NTczNjg0NzUzNjgKMAoKNDk5MjczOTg3MTcKMTIzNDU2NzgxMjM0NTY3OAo3OTkyNzM5ODcxMAo3OTkyNzM5ODcxMQo3OTkyNzM5ODcxMgo3OTkyNzM5ODcxNAo3OTkyNzM5ODcxNQo3OTkyNzM5ODcxNgo3OTkyNzM5ODcxNwo3OTkyNzM5ODcxOAo3OTkyNzM5ODcxOQozNzQ2NTIzNDY5NTY3ODIzNDY5NTc4MjM2OTQ4NTc2OTIzNjQ4NTczODc0NTY4MzQKOA" rel="nofollow">Try it online! (Slightly modified to run all test cases at once.)

Explanation

;

Insert ; in every position to separate digits.

r`(.);.
$1$&

From the right, we repeatedly match two digits and double the left one. This way we avoid an expensive reversing of the list.

\d
$*

We match each digit and convert it to that many 1s (that is, we convert each digit to unary).

1+
$.&

This matches each unary number and converts it back to decimal by replacing it with its length. Together with the previous stage, this adds the doubled digits.

.
$*

Again, we match every character and turn it into that many 1s. That is we convert each digit individually back to unary. This also matches the ; separators, which are treated as zeros in the conversion, which means they're simply removed. Since all the unary numbers are now squashed together we've automatically added the unary representations of the all digits together.

$
$._

At the end, we insert the length of the entire string, i.e. the decimal representation of the unary checksum.

0$

Finally we count the number of matches of this regex, i.e. we check whether the decimal representation ends in 0, printing 0 or 1 accordingly.