问:
10 9 8 7 6 5 4 3 2 1... Print 2016
As a spin-off to my challenge over at Puzzling, your goal is to output 2016.

Rules:

You must include the numbers 10 9 8 7 6 5 4 3 2 1 in that order. They can be used as individual integers or concatenated together (like 1098), but the 10 may not be separated into 1 and 0 - no character(s) may be present between the digits. Note that, in some languages, 10 may not actually represent the integer literal 10, which is acceptable.

Your code must not contain any other numbers or pre-defined number variables or constants (so T in Pyth is not allowed, since it is a numeric constant).

You must calculate 2016 using numerics. Simply outputting 2016 without performing any operations on the required numbers (for example, by decoding an encoded string consisting of only alphabetic characters) is not allowed. Outputting 2016 in pieces (such as 20, then 16) is also not allowed; you must have a single output consisting of the numeric value 2016.

The valid answer with the fewest bytes wins.

答:
Python 2, 20 bytes

```<code>print 109876/54+3-21
</code>```

Again, that same boring 2016.(740). Makes use of the fact that if you don't have a decimal number in your expression it returns an integer.

Title: 10 9 8 7 6 5 4 3 2 1... Print 2016

Body:
Python 2, 20 bytes

print 109876/54+3-21

Again, that same boring 2016.(740). Makes use of the fact that if you don't have a decimal number in your expression it returns an integer.


问:
Falsify brief truths
Find the longest run of true in a list of booleans. Return the same list, with all other trues falsified.

Input, output

A list; any usual format (e.g., a delimited list as a string).

Details

True and false can be anything your language typically uses for those values, or the integers 1 and 0. If you use single characters, the list can be a concatenation (e.g., 10001).

If there's a tie for longest run, keep all tying runs true, and falsify all shorter runs.

Examples

```<code>input ↦ output
1,0,1,0,1 ↦ 1,0,1,0,1
1,1,0,1,1,0,1 ↦ 1,1,0,1,1,0,0
1,1,0,1,1,1,0,1,1 ↦ 0,0,0,1,1,1,0,0,0
1,1,1 ↦ 1,1,1
0,0,1 ↦ 0,0,1
0,0 ↦ 0,0
1,1,1,0,0,0,1,1,1,1,0,1,0,0,1,1,0,1,1,1,1,0,0,1,0 ↦ 0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0
</code>```

(directly from https://stackoverflow.com/q/37447114)

答:
Retina, 47 43 36

```<code>0
!
T`p`0`\b(1+)\b(?<=(?=.*1\1).*)|!
</code>```

Try it online! or try all the test cases

Thanks to msh210 for golfing 4 bytes!

Also big thanks to Martin for 7 bytes!

Explanation:

```<code>0
!
</code>```

Replace all 0s with !s. This is done to make matching groups of 1s shorter, as now 1! and !1 will have a word boundary (\b) between them, which also matches either the start or the end of the string.

```<code>T`p`0`
</code>```

This is a configuration option saying that after applying the regex after the backtick to the input, in every match translate every printable ascii character into a 0 character.

```<code>\b(1+)\b(?<=(?=.*1\1).*)|!
</code>```

This regex matches groups of 1s that are surrounded by zeroes, but do cannot match a 1 followed by itself anywhere in the string. These are the non-maximal groups that will be falsified. In addition, this also matches the ! characters we added to convert them back into 0s.

ContentLicense: CC BY-SA 3.0

Title: Falsify brief truths

Body:
Retina, 47 43 36

0
!
T`p`0`\b(1+)\b(?<=(?=.*1\1).*)|!

Try it online! or try all the test cases

Thanks to msh210 for golfing 4 bytes!

Also big thanks to Martin for 7 bytes!

Explanation:

0
!

Replace all 0s with !s. This is done to make matching groups of 1s shorter, as now 1! and !1 will have a word boundary (\b) between them, which also matches either the start or the end of the string.

T`p`0`

This is a configuration option saying that after applying the regex after the backtick to the input, in every match translate every printable ascii character into a 0 character.

\b(1+)\b(?<=(?=.*1\1).*)|!

This regex matches groups of 1s that are surrounded by zeroes, but do cannot match a 1 followed by itself anywhere in the string. These are the non-maximal groups that will be falsified. In addition, this also matches the ! characters we added to convert them back into 0s.


答:
Jelly, 8 bytes

```<code>ṣ0¬¬M¦j0
</code>```

Try it online! or verify all test cases.

How it works

```<code>ṣ0¬¬M¦j0  Main link. Argument: A (list of Booleans)

ṣ0        Split at zeroes. This leaves a 2D list of ones.
  ¬       Negate each 1, replacing it with 0.
     ¦    Conditional application:
    M       Yield all maximal indices.
            In lexicographical list comparison, a shorter list of zeroes is less
            than a longer one, so this identifies the longest runs.
   ¬        Negate the items in those lists, changing zeroes back to ones.
      j0  Join, separating by single zeroes.
</code>```

Title: Falsify brief truths

Body:
Find the longest run of true in a list of booleans. Return the same list, with all other trues falsified.

Input, output

A list; any usual format (e.g., a delimited list as a string).

Details

True and false can be anything your language typically uses for those values, or the integers 1 and 0. If you use single characters, the list can be a concatenation (e.g., 10001).

If there's a tie for longest run, keep all tying runs true, and falsify all shorter runs.

Examples

```<code>input ↦ output
1,0,1,0,1 ↦ 1,0,1,0,1
1,1,0,1,1,0,1 ↦ 1,1,0,1,1,0,0
1,1,0,1,1,1,0,1,1 ↦ 0,0,0,1,1,1,0,0,0
1,1,1 ↦ 1,1,1
0,0,1 ↦ 0,0,1
0,0 ↦ 0,0
1,1,1,0,0,0,1,1,1,1,0,1,0,0,1,1,0,1,1,1,1,0,0,1,0 ↦ 0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0
</code>```

(directly from https://stackoverflow.com/q/37447114)

Body:
Jelly, 8 bytes

ṣ0¬¬M¦j0

Try it online! or verify all test cases.

How it works

ṣ0¬¬M¦j0  Main link. Argument: A (list of Booleans)

ṣ0        Split at zeroes. This leaves a 2D list of ones.
  ¬       Negate each 1, replacing it with 0.
     ¦    Conditional application:
    M       Yield all maximal indices.
            In lexicographical list comparison, a shorter list of zeroes is less
            than a longer one, so this identifies the longest runs.
   ¬        Negate the items in those lists, changing zeroes back to ones.
      j0  Join, separating by single zeroes.


问:
Prefix Tree Traversal
Write a program that takes in (via stdin or command line) a string with the recursive form

```<code>PREFIX[SUFFIXES]
</code>```

where

PREFIX may be any string of lowercase letters (a-z), including the empty string, and

SUFFIXES may be any sequence of strings with the recursive form PREFIX[SUFFIXES] concatenated together, including the empty sequence.

Generate a list of lowercase lettered strings from the input by recursively evaluating the list of strings in each of the suffixes and appending them to the prefix. Output to stdout the strings in this list in any order, one per line (plus an optional trailing newline).

Example

If the input is

```<code>cat[s[up[][]][]ch[e[r[]s[]]]a[maran[]comb[]pult[[]ing[]]]]
</code>```

then the prefix is cat and and the suffixes are s[up[][]], [],
  ch[e[r[]s[]]], and a[maran[]comb[]pult[[]ing[]]]. Each suffix has
  its own prefix and suffixes in turn.

The output would be these 9 words in any order

```<code>catsup
cats
cat
catcher
catches
catamaran
catacomb
catapult
catapulting
</code>```

because the input encodes this tree

and each of the 9 output words can be formed by traversing the tree
  from root to leaf.

Notes

Remember that the prefix may be the empty string, so something like

```<code>[donut[][]cruller[]]
</code>```

is valid input whose output would be (in any order)

```<code>donut

cruller
</code>```

where the empty line is for the empty string that the second suffix matches.

The suffix sequence can also be empty, so the trivial input case

```<code>[]
</code>```

has a single empty line as its output:

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

You may assume that the input will only produce unique output words.

e.g. hat[s[]ter[]s[]] would be invalid input because hats is encoded twice.

Similarly, [[][]] is invalid because the empty string is encoded twice.

You may not assume that the input is as short or compressed as possible.

e.g. the 'e' node in the main example above could be combined with the 'ch' node, but that's doesn't mean the input is invalid.

Similarly, [[[[[]]]]] is valid, despite only encoding the empty string in a sub-optimal way.

Instead of a program you may write a function that takes the input string as an argument and prints the output normally or returns it as a string or list.

The shortest code in bytes wins.

答:
Q: 70 Bytes

```<code>f:{,/'$({(z_x),y}\[();{`$x@&~x="]"}'w;-b])@-1+&0<b:(+/"]"=)'w:"["\:x}
</code>```

defines a function f that accepts a string and return a list of strings (words)

As a lambda (anonymous function) we drop the first 2 chars f:, so length is 68 Bytes

Test

```<code>f "cat[s[up[][]][]ch[e[r[]s[]]]a[maran[]comb[]pult[[]ing[]]]]"
</code>```

("catsup";"cats";"cat";"catcher";"catches";"catamaran";"catacomb";"catapult";"catapulting")

```<code>f "[donut[][]cruller[]]"
</code>```

("donut";"";"cruller")

```<code>f "[[[[[]]]]]"
</code>```

,""

Notes

,"" indicates a list of strings that contains only has an empty string

Symbols are atomic. Push/pop a symbol on the stack is a simple operation not affected by the lenght of the symbol (see explanation)

Explanation

Q is a cousin of APL (kx.com)

Pseudocode:

Splits string (arg x) at "[" char. Result (list of strings) in w

Counts "]" chars in each elem. of w. Result in b

Modifies each item in w to filter out character "]" and converts each string to a symbol

Generates a logical sequence (bitmap) to mark items >0 in b

Iterates over partial results with a stack: if item marked we must drop one of more symbols (according to value in b). Always append actual symbol to stack

After iterating we have all intermediate states of stack. We select previously marked states

finally for each result we convert symbols to strings and concatenate them

Title: Prefix Tree Traversal

Body:
Q: 70 Bytes

f:{,/'$({(z_x),y}\[();{`$x@&~x="]"}'w;-b])@-1+&0<b:(+/"]"=)'w:"["\:x}

defines a function f that accepts a string and return a list of strings (words)

As a lambda (anonymous function) we drop the first 2 chars f:, so length is 68 Bytes

Test

f "cat[s[up[][]][]ch[e[r[]s[]]]a[maran[]comb[]pult[[]ing[]]]]"

("catsup";"cats";"cat";"catcher";"catches";"catamaran";"catacomb";"catapult";"catapulting")

f "[donut[][]cruller[]]"

("donut";"";"cruller")

f "[[[[[]]]]]"

,""

Notes

,"" indicates a list of strings that contains only has an empty string

Symbols are atomic. Push/pop a symbol on the stack is a simple operation not affected by the lenght of the symbol (see explanation)

Explanation

Q is a cousin of APL (kx.com)

Pseudocode:

Splits string (arg x) at "[" char. Result (list of strings) in w

Counts "]" chars in each elem. of w. Result in b

Modifies each item in w to filter out character "]" and converts each string to a symbol

Generates a logical sequence (bitmap) to mark items >0 in b

Iterates over partial results with a stack: if item marked we must drop one of more symbols (according to value in b). Always append actual symbol to stack

After iterating we have all intermediate states of stack. We select previously marked states

finally for each result we convert symbols to strings and concatenate them


答:
Hexagony, 61 bytes

Not gonna win, but I just wanted to do a challenge in Hexagony.

This uses a different method than other answers (much worse). It takes some factors of 2016 (2,3,6,7,8) and multiplies them all together.

Minified:

```<code>\109.8/7}_=\"6<}{>...$_5_4/*!@...../}3.."2\/="*=}<*...$1>"*"/
</code>```

Unminified:

```<code>    \ 1 0 9 .
   8 / 7 } _ =
  \ " 6 < } { >
 . . . $ _ 5 _ 4
/ * ! @ . . . . .
 / } 3 . . " 2 \
  / = " * = } <
   * . . . $ 1
    > " * " /
</code>```

Explanation coming soon;

Title: 10 9 8 7 6 5 4 3 2 1... Print 2016

Body:
As a spin-off to my challenge over at Puzzling, your goal is to output 2016.

Rules:

You must include the numbers 10 9 8 7 6 5 4 3 2 1 in that order. They can be used as individual integers or concatenated together (like 1098), but the 10 may not be separated into 1 and 0 - no character(s) may be present between the digits. Note that, in some languages, 10 may not actually represent the integer literal 10, which is acceptable.

Your code must not contain any other numbers or pre-defined number variables or constants (so T in Pyth is not allowed, since it is a numeric constant).

You must calculate 2016 using numerics. Simply outputting 2016 without performing any operations on the required numbers (for example, by decoding an encoded string consisting of only alphabetic characters) is not allowed. Outputting 2016 in pieces (such as 20, then 16) is also not allowed; you must have a single output consisting of the numeric value 2016.

The valid answer with the fewest bytes wins.

Body:
Hexagony, 61 bytes

Not gonna win, but I just wanted to do a challenge in Hexagony.

This uses a different method than other answers (much worse). It takes some factors of 2016 (2,3,6,7,8) and multiplies them all together.

Minified:

\109.8/7}_=\"6<}{>...$_5_4/*!@...../}3.."2\/="*=}<*...$1>"*"/

Unminified:

    \ 1 0 9 .
   8 / 7 } _ =
  \ " 6 < } { >
 . . . $ _ 5 _ 4
/ * ! @ . . . . .
 / } 3 . . " 2 \
  / = " * = } <
   * . . . $ 1
    > " * " /

Explanation coming soon;


答:
MATL, 14 bytes

```<code>Y'yy*X>y=b*wY"
</code>```

Try it Online!

Modified version with all test cases

Explanation

```<code>        % Implicitly grab the input as an array
Y'      % Perform run-length encoding of the input. Yields an array of values and an array
        % of run-lengths
yy      % Copy these outputs
*       % Multiply the values (booleans) by the run-lengths. This will zero-out all
        % zero-valued runs so we don't consider them when computing the longest run.
X>      % Compute the longest run of 1's
y       % Copy the run lengths vector
=       % Determine which runs are the same length as the longest run of ones
b*      % Bubble-up the values from the run-length encoding and multiply element-wise
        % With this boolean. This substitutes all 1's that are not in the longest run
        % of ones with 0's
w       % Flip the run-lengths and values on the stack
Y"      % Perform run-length decoding using these substituted values
        % Implicitly display the resulting boolean
</code>```

Title: Falsify brief truths

Body:
MATL, 14 bytes

Y'yy*X>y=b*wY"

Try it Online!

Modified version with all test cases

Explanation

        % Implicitly grab the input as an array
Y'      % Perform run-length encoding of the input. Yields an array of values and an array
        % of run-lengths
yy      % Copy these outputs
*       % Multiply the values (booleans) by the run-lengths. This will zero-out all
        % zero-valued runs so we don't consider them when computing the longest run.
X>      % Compute the longest run of 1's
y       % Copy the run lengths vector
=       % Determine which runs are the same length as the longest run of ones
b*      % Bubble-up the values from the run-length encoding and multiply element-wise
        % With this boolean. This substitutes all 1's that are not in the longest run
        % of ones with 0's
w       % Flip the run-lengths and values on the stack
Y"      % Perform run-length decoding using these substituted values
        % Implicitly display the resulting boolean


答:
Python 2, 62 bytes

lambda s:'0'.join(`1-(t+'1'in s)`*len(t)for t in s.split('0'))
```

Test it on Ideone.

How it works

s.split('0') splits the input string s into runs of zero or more 1's

For each run t, we check whether t+'1' is a substring of s.

If it is, the run isn't maximal, t+'1'in s return True, 1-(t+'1'in s) return 1 - True = 0 and the run is replaced with a run of 0's of the same length.

If it isn't, the run is maximal, t+'1'in s return False, 1-(t+'1'in s) return 1 - False = 1 and the run is replaced with a run of 1's of the same length, i.e., by itself.

Finally, '0'.join restores all removed 0's.

Title: Falsify brief truths

Body:
Python 2, 62 bytes

lambda s:'0'.join(`1-(t+'1'in s)`*len(t)for t in s.split('0'))

Test it on Ideone.

How it works

s.split('0') splits the input string s into runs of zero or more 1's

For each run t, we check whether t+'1' is a substring of s.

If it is, the run isn't maximal, t+'1'in s return True, 1-(t+'1'in s) return 1 - True = 0 and the run is replaced with a run of 0's of the same length.

If it isn't, the run is maximal, t+'1'in s return False, 1-(t+'1'in s) return 1 - False = 1 and the run is replaced with a run of 1's of the same length, i.e., by itself.

Finally, '0'.join restores all removed 0's.


问:
Make the lowest number square that equals n
A number square containing the values 1, 2, 3, 4 looks like this:

```<code>12
34
</code>```

To work out what a number square is, you first make four numbers by reading across the rows and across the columns; for the example above you would get 12, 34, 13 and 24, then you add them all up (12+34+13+24), giving you the value of the square.

However, there is a catch: the square your program outputs must output the lowest possible square. The way to calculate how 'low' the square is is like this:

Take the top-left number, and place it in the variable a.

Take the top-right number, double it and add the total to a.

Take the bottom-left number, triple it and add the total to a.

Take the bottom-right number, quadruple it and add the total to a.

The variable a now holds how 'low' you square is!

Requirements

Your program must output the lowest possible number square, in the format that follows:

```<code>ab
cd
</code>```

(where a, b, c and d are integers in the range 0-9).

The square will never contain a number multiple digits long (negative numbers as well). You don't have to handle that case.

You can take input, which will be the number the square should equal, as an argument, as function argument or from STDIN. Please specify how input should be given for your program.

If there is not a number square that equals what the input number, output nothing.

If two numbers squares are equally low and produce the same output, nothing should be output.

Rules

Standard loopholes are forbidden.

Your program must not write anything to STDERR.

Test Cases

```<code>44 ==>
04
00
-----
2 ==>
00
01
-----
100 ==>
50
00
</code>```

@MartinBüttner has also done a Pastebin with all the possible solutions.

Scoring

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

To win this code-golf challenge, try to get the least bytes!

Submissions

To make sure that your answer can be parsed, please start your answer with a headline, using the following Markdown template:

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

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

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

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

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

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

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

Leaderboard

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

  });

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
C (ANSI), 210 bytes

#define a (l/1000)+2*((l/100)%10)+3*((l%100)/10)+4*(l%10)
main(g,o,l,f){g--;o=91;for(f=l=-1;l<10000;g==++l%100+l/100+(l%10)+((l/100)%10*10)+((l/1000)*10)+(l/    10%10)?a==o?f=-1:a<o?f=l,o=a:1:1);printf("%04i",f);}

Pretty much makes all possible squares and finds the lowest.
Input is read in as number of arguments. Output is the square as a 4 digit number.

Ex: 8

./numberSquare 1 1 1 1 1 1 1 1
0004

Expanded Version:

calcScore(l){
    return (l/1000)+2*((l/100)%10)+3*((l%100)/10)+4*(l%10);
}

main(g,o,l,f){
    g-=2;
    o=91;
    for(f=l=-1;l<10000;l++){
        if(g==l%100+l/100+(l%10)+((l/100)%10*10)+((l/1000)*10)+(l/10%10))
            if(calcScore(l)==o)f=-1;
        else if(calcScore(l)<o)f=l,o=calcScore(l);
    }
    printf("%04i",f);
}


问:
Illiteral Prime numbers
Your challenge is to write a program (full program, not a function), that will take an integer and output all prime numbers up to (including) the given integer. Output is any readable list containing all integer primes (array, string, 1 prime per line, whatever you want) and must run to stdout or equivalent.

Simple? Here's the twist:

You may not use literals in your program. These include:

Literal numbers (0 through 9)

Literal strings (in quotes)

You may not use built in prime checks

EDIT: A prime check is a built in function that

Returns if a number is a prime number

Returns a prime number

Returns a list of prime numbers

You may code your own functions that do the above

Prime factorisation functions are allowed

As this is code-golf, shortest answer in bytes wins

Title: Illiteral Prime numbers

Body:
J, 22 bytes

([:>:@I.>:|*:@!)@i.@x:

Also uses Wilson's theorem.

Usage

   f =: ([:>:@I.>:|*:@!)@i.@x:
   f 9
2 3 5 7
   f 100
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97


问:
Generate Wordenticons
Identicons are visual depictions of hash values, often made from symmetrical arrangements of geometric shapes. Your default Stack Exchange avatar is an identicon. This challenge is about creating "wordenticons", simple text-based versions of identicons that apply to strings of lowercase letters, i.e. words.

Challenge

Write a program or function that takes in a string S and outputs its wordenticon. S is guaranteed to be nonempty and only contain lowercase English letter characters a-z. You may optionally assume S has a trailing newline.

The wordenticon of S will be a square grid of text with side lengths 2*length(S) composed of spaces ( ), vertical bars, (|), and horizontal bars (―).

To generate the wordenticon of S, form a square grid where every column corresponds to a letter of S (in normal left-to-right reading order) and every row corresponds to a letter of S (in normal top-to-bottom reading order).

For example, if S is food our initial grid looks like

```<code> food
f....
o....
o....
d....
</code>```

where . is just a placeholder.

For every empty point (every .) in the grid:

If the column letter comes before the row letter alphabetically, replace the . with |.

If the column letter comes after the row letter alphabetically, replace the . with ―.

If the column and row letters are the same, replace the . with   (space).

Here is the food example after each of these steps:

Adding |'s:

```<code> food
f...|
o|..|
o|..|
d....
</code>```

Adding ―'s:

```<code> food
f.――|
o|..|
o|..|
d―――.
</code>```

Adding  's:

```<code> food
f ――|
o|  |
o|  |
d―――
</code>```

To complete the wordenticon, remove the superfluous row and column containing the words

```<code> ――|
|  |
|  |
―――
</code>```

then mirror the entire thing horizontally

```<code> ――||――
|  ||  |
|  ||  |
―――  ―――
</code>```

and finally mirror it again vertically

```<code> ――||――
|  ||  |
|  ||  |
―――  ―――
―――  ―――
|  ||  |
|  ||  |
 ――||――
</code>```

resulting in the 2*length(S) side length text grid that is the final wordenticon.

Examples

Here are some additional wordenticon examples. Note that different words can have identical wordenticons and some wordenticons can be completely made of spaces (unfortunately markdown does not want to render those).

```<code>food

 ――||――
|  ||  |
|  ||  |
―――  ―――
―――  ―――
|  ||  |
|  ||  |
 ――||――

mood

 ――||――
|  ||  |
|  ||  |
―――  ―――
―――  ―――
|  ||  |
|  ||  |
 ――||――

foof

 ――  ――
|  ||  |
|  ||  |
 ――  ――
 ――  ――
|  ||  |
|  ||  |
 ――  ――

fool

 ――――――
|  ||  |
|  ||  |
|――  ――|
|――  ――|
|  ||  |
|  ||  |
 ――――――

a [2*2 grid of spaces]

to

 ||
―  ―
―  ―
 ||

it

 ――
|  |
|  |
 ――

tt [4*4 grid of spaces]

abc

 ――――
| ―― |
||  ||
||  ||
| ―― |
 ――――

and

 ――――
| || |
|―  ―|
|―  ―|
| || |
 ――――

but

 ――――
| || |
|―  ―|
|―  ―|
| || |
 ――――

you

 ||||
― ―― ―
―|  |―
―|  |―
― ―― ―
 ||||

bob

 ―  ―
| || |
 ―  ―
 ―  ―
| || |
 ―  ―

cat

 |――|
― ―― ―
||  ||
||  ||
― ―― ―
 |――|

cart

 |――――|
― ―――― ―
|| ―― ||
|||  |||
|||  |||
|| ―― ||
― ―――― ―
 |――――|

todo

 ||||||
― |  | ―
―― ―― ――
― |  | ―
― |  | ―
―― ―― ――
― |  | ―
 ||||||

mice

 ||||||
― |||| ―
―― ―― ――
――|  |――
――|  |――
―― ―― ――
― |||| ―
 ||||||

zyxw

 ||||||
― |||| ―
―― || ――
―――  ―――
―――  ―――
―― || ――
― |||| ―
 ||||||

banana

 |―|―||―|―|
― ― ―  ― ― ―
|| | || | ||
― ― ―  ― ― ―
|| | || | ||
― ― ―  ― ― ―
― ― ―  ― ― ―
|| | || | ||
― ― ―  ― ― ―
|| | || | ||
― ― ―  ― ― ―
 |―|―||―|―|

codegolf

 ――――――――――――――
| ||| |||| ||| |
|― ―――――――――― ―|
|―| ―――――――― |―|
|―|| ――||―― ||―|
| ||| |||| ||| |
|―|||― || ―|||―|
|―||―――  ―――||―|
|―||―――  ―――||―|
|―|||― || ―|||―|
| ||| |||| ||| |
|―|| ――||―― ||―|
|―| ―――――――― |―|
|― ―――――――――― ―|
| ||| |||| ||| |
 ――――――――――――――

programming

 ―||―||||||||||||―||―
| || |||||||||||| || |
―― |―||||||||||||―| ――
――― ―|――――  ――――|― ―――
| || |||||||||||| || |
――――― ―――――――――― ―――――
―――|―|  |―||―|  |―|―――
―――|―|  |―||―|  |―|―――
―――|―|―― ―||― ――|―|―――
―――|―|||| || ||||―|―――
――― ―|――――  ――――|― ―――
――― ―|――――  ――――|― ―――
―――|―|||| || ||||―|―――
―――|―|―― ―||― ――|―|―――
―――|―|  |―||―|  |―|―――
―――|―|  |―||―|  |―|―――
――――― ―――――――――― ―――――
| || |||||||||||| || |
――― ―|――――  ――――|― ―――
―― |―||||||||||||―| ――
| || |||||||||||| || |
 ―||―||||||||||||―||―

abcdefghijklm

 ――――――――――――――――――――――――
| ―――――――――――――――――――――― |
|| ―――――――――――――――――――― ||
||| ―――――――――――――――――― |||
|||| ―――――――――――――――― ||||
||||| ―――――――――――――― |||||
|||||| ―――――――――――― ||||||
||||||| ―――――――――― |||||||
|||||||| ―――――――― ||||||||
||||||||| ―――――― |||||||||
|||||||||| ―――― ||||||||||
||||||||||| ―― |||||||||||
||||||||||||  ||||||||||||
||||||||||||  ||||||||||||
||||||||||| ―― |||||||||||
|||||||||| ―――― ||||||||||
||||||||| ―――――― |||||||||
|||||||| ―――――――― ||||||||
||||||| ―――――――――― |||||||
|||||| ―――――――――――― ||||||
||||| ―――――――――――――― |||||
|||| ―――――――――――――――― ||||
||| ―――――――――――――――――― |||
|| ―――――――――――――――――――― ||
| ―――――――――――――――――――――― |
 ―――――――――――――――――――――――― </code>```

Scoring

This is code-golf, the shortest code in bytes wins. Tiebreaker goes to the earlier answer.

Notes

Any instance of horizontal bar (―) in your code may be counted as 1 byte instead of the 3 UTF-8 bytes it actually takes up. (Up to ten instances.)

If desired you may use regular dashes (-) in place of horizontal bars (―).

Removing or adding trailing spaces in the lines of a wordenticon is not allowed (even if the shape remains unchanged). It should be an exact 2*length(S) side length text square.

The output wordenticon may optionally have a single trailing newline.

答:
Haskell, 66 bytes

```<code>u s|e<-s++reverse s=unlines[["- |"!!min(length[a..b])2|a<-e]|b<-e]
</code>```

Title: Generate Wordenticons

Body:
Haskell, 66 bytes

u s|e<-s++reverse s=unlines[["- |"!!min(length[a..b])2|a<-e]|b<-e]


答:
Haskell, 133 bytes

```<code>a#b=10*a+b
g n|l<-[(a+2*b+3*c+4*d,m)|m@[a,b,c,d]<-mapM id$[0..9]<$"aaaa",a#b+a#c+b#d+c#d==n]=[b|q@(a,b)<-l,all(\k@(j,_)->j>a||k==q)l]
</code>```

Output is a four element list [a,b,c,d]. Usage example: map g [129..139] -> [[[1,9,0,5]],[],[[6,1,0,0]],[],[[5,3,0,0]],[],[[4,5,0,0]],[],[[3,7,0,0]],[],[[2,9,0,0]]].

How it works:

```<code>l<-[        ]                  -- let l be the list of all
  (a+2*b+3*c+4*d,m)|           -- pairs (score, matrix), where
     m@[a,b,c,d]<-             -- matrix m (= [a,b,c,d]) is drawn from
       mapM id$[0..9]<$"aaaa", -- all permutations of the digits of length 4 and
       a#b+a#c+b#d+c#d==n      -- the matrix sum equals n

=[b|            ]              -- return a list of all matrices b, where
  q@(a,b)<-l                   -- the pair q = (a,b) is drawn from l and
    all(\k@(j,_)->j>a||k==q)l] -- a is minimal and unique
</code>```

Title: Make the lowest number square that equals n

Body:
A number square containing the values 1, 2, 3, 4 looks like this:

```<code>12
34
</code>```

To work out what a number square is, you first make four numbers by reading across the rows and across the columns; for the example above you would get 12, 34, 13 and 24, then you add them all up (12+34+13+24), giving you the value of the square.

However, there is a catch: the square your program outputs must output the lowest possible square. The way to calculate how 'low' the square is is like this:

Take the top-left number, and place it in the variable a.

Take the top-right number, double it and add the total to a.

Take the bottom-left number, triple it and add the total to a.

Take the bottom-right number, quadruple it and add the total to a.

The variable a now holds how 'low' you square is!

Requirements

Your program must output the lowest possible number square, in the format that follows:

```<code>ab
cd
</code>```

(where a, b, c and d are integers in the range 0-9).

The square will never contain a number multiple digits long (negative numbers as well). You don't have to handle that case.

You can take input, which will be the number the square should equal, as an argument, as function argument or from STDIN. Please specify how input should be given for your program.

If there is not a number square that equals what the input number, output nothing.

If two numbers squares are equally low and produce the same output, nothing should be output.

Rules

Standard loopholes are forbidden.

Your program must not write anything to STDERR.

Test Cases

```<code>44 ==>
04
00
-----
2 ==>
00
01
-----
100 ==>
50
00
</code>```

@MartinBüttner has also done a Pastebin with all the possible solutions.

Scoring

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

To win this code-golf challenge, try to get the least bytes!

Submissions

To make sure that your answer can be parsed, please start your answer with a headline, using the following Markdown template:

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

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

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

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

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

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

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

Leaderboard

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

  });

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Haskell, 133 bytes

a#b=10*a+b
g n|l<-[(a+2*b+3*c+4*d,m)|m@[a,b,c,d]<-mapM id$[0..9]<$"aaaa",a#b+a#c+b#d+c#d==n]=[b|q@(a,b)<-l,all(\k@(j,_)->j>a||k==q)l]

Output is a four element list [a,b,c,d]. Usage example: map g [129..139] -> [[[1,9,0,5]],[],[[6,1,0,0]],[],[[5,3,0,0]],[],[[4,5,0,0]],[],[[3,7,0,0]],[],[[2,9,0,0]]].

How it works:

l<-[        ]                  -- let l be the list of all
  (a+2*b+3*c+4*d,m)|           -- pairs (score, matrix), where
     m@[a,b,c,d]<-             -- matrix m (= [a,b,c,d]) is drawn from
       mapM id$[0..9]<$"aaaa", -- all permutations of the digits of length 4 and
       a#b+a#c+b#d+c#d==n      -- the matrix sum equals n

=[b|            ]              -- return a list of all matrices b, where
  q@(a,b)<-l                   -- the pair q = (a,b) is drawn from l and
    all(\k@(j,_)->j>a||k==q)l] -- a is minimal and unique


答:
JavaScript (ES6), 56 bytes

```<code>s=>s.replace(/1+/g,t=>t.replace(/1/g,+!~s.indexOf(t+1)))
</code>```

Works by checking all runs of 1s and replacing the characters with 0s unless the run is (equally) longest, as measured by searching the string for a longer run of 1s.

Previous 72-byte recursive solution:

```<code>f=s=>/11/.test(s)?f(s.replace(/1(1*)/g,"0$1")).replace(/0(1+)/g,"1$1"):s
</code>```

Does nothing if there are no runs of 1s (i.e. single 1s at most). Otherwise, subtracts one 1 from each 1 or run thereof, then calls itself recursively on the shorter runs, then adds one 1 back on the (now equally longest) runs. The number of recursive calls is one less than the length of the longest run.

Title: Falsify brief truths

Body:
JavaScript (ES6), 56 bytes

s=>s.replace(/1+/g,t=>t.replace(/1/g,+!~s.indexOf(t+1)))

Works by checking all runs of 1s and replacing the characters with 0s unless the run is (equally) longest, as measured by searching the string for a longer run of 1s.

Previous 72-byte recursive solution:

f=s=>/11/.test(s)?f(s.replace(/1(1*)/g,"0$1")).replace(/0(1+)/g,"1$1"):s

Does nothing if there are no runs of 1s (i.e. single 1s at most). Otherwise, subtracts one 1 from each 1 or run thereof, then calls itself recursively on the shorter runs, then adds one 1 back on the (now equally longest) runs. The number of recursive calls is one less than the length of the longest run.


问:
Approximate the Fransén-Robinson constant
Given an input n, output the value of the Fransén-Robinson constant with n digits after the decimal place, with rounding.

Rules

You may assume that all inputs are integers between 1 and 60.

You may not store any related values - the constant must be calculated, not recalled.

Rounding must be done with the following criteria:

If the digit following the final digit is less than five, the final digit must remain the same.

If the digit following the final digit is greater than or equal to five, the final digit must be incremented by one.

You must only output the first n+1 digits.

Standard loopholes apply.

Test Cases

```<code>>>> f(0)
3

>>> f(1)
2.8

>>> f(11)
2.80777024203

>>> f(50)
2.80777024202851936522150118655777293230808592093020

>>> f(59)
2.80777024202851936522150118655777293230808592093019829122005

>>> f(60)
2.807770242028519365221501186557772932308085920930198291220055
</code>```

答:
Mathematica, <s>44</s> <s>39</s> <s>36</s> 25 UTF-8 bytes

-5 bytes thanks to Sp3000

-3 bytes thanks to kennytm

-11 bytes thanks to senegrom

Crossed out <s>44</s> is still regular 44!!

```<code>N[∫1/x!{x,-1,∞},#+1]&
</code>```

Example:

```<code>f=N[∫1/x!{x,-1,∞},#+1]&
f[2]
</code>```

Outputs 2.81.

Explanation

```<code>N[               , # + 1]
  ∫1/x!{x,-1,∞}
</code>```

First step takes Numeric of the rest, with # (first parameter) + 1 precision. ! (factorial) does what you'd expect. {x, -1, Infinity} sets the bounds for the (strangely formatted) Integral.

Body:
Mathematica, <s>44</s> <s>39</s> <s>36</s> 25 UTF-8 bytes

-5 bytes thanks to Sp3000

-3 bytes thanks to kennytm

-11 bytes thanks to senegrom

Crossed out <s>44</s> is still regular 44!!

N[∫1/x!{x,-1,∞},#+1]&

Example:

f=N[∫1/x!{x,-1,∞},#+1]&
f[2]

Outputs 2.81.

Explanation

N[               , # + 1]
  ∫1/x!{x,-1,∞}

First step takes Numeric of the rest, with # (first parameter) + 1 precision. ! (factorial) does what you'd expect. {x, -1, Infinity} sets the bounds for the (strangely formatted) Integral.


答:
Python 2, 74 bytes

```<code>lambda n:[-p for p in range(-n,n/-n)if all(p%i for i in range(-~True,-p))]
</code>```

Title: Illiteral Prime numbers

Body:
Your challenge is to write a program (full program, not a function), that will take an integer and output all prime numbers up to (including) the given integer. Output is any readable list containing all integer primes (array, string, 1 prime per line, whatever you want) and must run to stdout or equivalent.

Simple? Here's the twist:

You may not use literals in your program. These include:

Literal numbers (0 through 9)

Literal strings (in quotes)

You may not use built in prime checks

EDIT: A prime check is a built in function that

Returns if a number is a prime number

Returns a prime number

Returns a list of prime numbers

You may code your own functions that do the above

Prime factorisation functions are allowed

As this is code-golf, shortest answer in bytes wins

Body:
Python 2, 74 bytes

lambda n:[-p for p in range(-n,n/-n)if all(p%i for i in range(-~True,-p))]


答:
Julia, 51 bytes

s->replace(s,r"1+",t->map(c->c-contains(s,"1"t),t))
```

Try it online!

How it works

replace finds all all runs of one or more 1's in the input string s via the regex r"1+" and calls the lambda t->map(c->c-contains(s,"1"t),t) to determine the replacement string.

The lambda maps c->c-contains(s,"1"t) over all characters in the run of ones t.

If "1"t (concatenation) is a substring of s, the run isn't maximal, contains returns true and c-contains(s,"1"t) returns '1' - true = '0', replacing all 1's in that run with 0's.

If "1"t (concatenation) is not a substring of s, the run is maximal, contains returns false and c-contains(s,"1"t) returns '1' - false = '1', leaving the run unmodified.

Title: Falsify brief truths

Body:
Julia, 51 bytes

s->replace(s,r"1+",t->map(c->c-contains(s,"1"t),t))

Try it online!

How it works

replace finds all all runs of one or more 1's in the input string s via the regex r"1+" and calls the lambda t->map(c->c-contains(s,"1"t),t) to determine the replacement string.

The lambda maps c->c-contains(s,"1"t) over all characters in the run of ones t.

If "1"t (concatenation) is a substring of s, the run isn't maximal, contains returns true and c-contains(s,"1"t) returns '1' - true = '0', replacing all 1's in that run with 0's.

If "1"t (concatenation) is not a substring of s, the run is maximal, contains returns false and c-contains(s,"1"t) returns '1' - false = '1', leaving the run unmodified.


答:
Pyth, <s>26</s> <s>24</s> <s>23</s> 21 bytes

```<code>M,G&HGJrgMrQ8 9qReSJJ
</code>```

Test suite.

Uses 1/0 or true/false in input.

Uses true/false in output.

Explanation

```<code>M,G&HGJrgMrQ8 9qReSJJ

           Q      input
          r 8     run-length encode
        gM        convert each run of 1 to their length
                  for example: [1,1,1,0,1,1] will be
                  converted to [3,3,3,0,2,2]
                  in the run-length encoded version
                  [1,1,1,0,1,1] will be [[3,1],[1,0],[2,1]]
                  [3,3,3,0,2,2] will be [[3,3],[1,0],[2,2]]
                  therefore basically [G,H] becomes [G,H and G]
                  which is what the code below does:
M,G&HG            def g(G,H): return [G,H and G]
       r      9   run-length decode
      J           store to J

               qReSJJ

                R   J   in each element of J
               q eSJ    check if equal to maximum of J
</code>```

Previous 23-byte

```<code>M,G&HGJrgMrQ8 9msqdeSJJ
</code>```

Test suite.

Uses 1/0 or true/false in input.

Uses 1/0 in output.

Previous 24-byte

```<code>Jrm,hd&edhdrQ8 9msqdeSJJ
</code>```

Test suite.

Uses 1/0 or true/false in input.

Uses 1/0 in output.

Previous 26-byte

```<code>rm?nhdeS.u&YhNQ0,hd0drQ8 9
</code>```

Test suite.

Uses 1/0 or true/false in input.

Uses 1/0 in output.

Title: Falsify brief truths

Body:
Find the longest run of true in a list of booleans. Return the same list, with all other trues falsified.

Input, output

A list; any usual format (e.g., a delimited list as a string).

Details

True and false can be anything your language typically uses for those values, or the integers 1 and 0. If you use single characters, the list can be a concatenation (e.g., 10001).

If there's a tie for longest run, keep all tying runs true, and falsify all shorter runs.

Examples

```<code>input ↦ output
1,0,1,0,1 ↦ 1,0,1,0,1
1,1,0,1,1,0,1 ↦ 1,1,0,1,1,0,0
1,1,0,1,1,1,0,1,1 ↦ 0,0,0,1,1,1,0,0,0
1,1,1 ↦ 1,1,1
0,0,1 ↦ 0,0,1
0,0 ↦ 0,0
1,1,1,0,0,0,1,1,1,1,0,1,0,0,1,1,0,1,1,1,1,0,0,1,0 ↦ 0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0
</code>```

(directly from https://stackoverflow.com/q/37447114)

Body:
Pyth, <s>26</s> <s>24</s> <s>23</s> 21 bytes

M,G&HGJrgMrQ8 9qReSJJ

Test suite.

Uses 1/0 or true/false in input.

Uses true/false in output.

Explanation

M,G&HGJrgMrQ8 9qReSJJ

           Q      input
          r 8     run-length encode
        gM        convert each run of 1 to their length
                  for example: [1,1,1,0,1,1] will be
                  converted to [3,3,3,0,2,2]
                  in the run-length encoded version
                  [1,1,1,0,1,1] will be [[3,1],[1,0],[2,1]]
                  [3,3,3,0,2,2] will be [[3,3],[1,0],[2,2]]
                  therefore basically [G,H] becomes [G,H and G]
                  which is what the code below does:
M,G&HG            def g(G,H): return [G,H and G]
       r      9   run-length decode
      J           store to J

               qReSJJ

                R   J   in each element of J
               q eSJ    check if equal to maximum of J

Previous 23-byte

M,G&HGJrgMrQ8 9msqdeSJJ

Test suite.

Uses 1/0 or true/false in input.

Uses 1/0 in output.

Previous 24-byte

Jrm,hd&edhdrQ8 9msqdeSJJ

Test suite.

Uses 1/0 or true/false in input.

Uses 1/0 in output.

Previous 26-byte

rm?nhdeS.u&YhNQ0,hd0drQ8 9

Test suite.

Uses 1/0 or true/false in input.

Uses 1/0 in output.


答:
Python 2, <s>59</s> 58 bytes

n=input();k=p=n/n
while k<n:
 p*=k*k;k=-~k
 if p%k:print k
```

Test it on Ideone.

Title: Illiteral Prime numbers

Body:
Python 2, <s>59</s> 58 bytes

n=input();k=p=n/n
while k<n:
 p*=k*k;k=-~k
 if p%k:print k

Test it on Ideone.


答:
Mathematica, <s>46</s> 41

```<code>1-Join@@Sign[1~Max~#-#]&[#*Tr/@#]&@*Split
</code>```

Works on lists of 0 and 1.  I thought I had done pretty well until I looked at the other answers!

Explanation for 46 character version; I shall update when I cannot improve it further.

An explanation of this code was requested.

A non-code-golf equivalent (using version 10 operator forms) is:

```<code>RightComposition[
  Split,
  Map[# Tr@# &],
  # - Max[1, #] &,
  UnitStep,
  Apply[Join]
]
</code>```

This means a function made up of five steps (sub-functions) applied in order from top to bottom.

Split: break up into runs of identical elements:  {1,1,0,1,1,0,1} ↦ {{1,1}, {0}, {1,1}, {0,0}}

Map[# Tr@# &]: For each sub-list (Map) multiply it (#) by its sum (vector trace, Tr): {1,1} ↦ {2, 2}

# - Max[1, #] & subtract from every element the maximum value appearing anywhere in the list of lists, or one, whichever is higher.  (The one handles the case of all zeros.)

UnitStep: equal to 0 for x < 0 and 1 for x >= 0, applied to every element.

Apply[Join]: join the sub-lists into a single list.  Could also be done with Flatten or Catenate, but in short form Join@@ is more terse.

Title: Falsify brief truths

Body:
Mathematica, <s>46</s> 41

1-Join@@Sign[1~Max~#-#]&[#*Tr/@#]&@*Split

Works on lists of 0 and 1.  I thought I had done pretty well until I looked at the other answers!

Explanation for 46 character version; I shall update when I cannot improve it further.

An explanation of this code was requested.

A non-code-golf equivalent (using version 10 operator forms) is:

RightComposition[
  Split,
  Map[# Tr@# &],
  # - Max[1, #] &,
  UnitStep,
  Apply[Join]
]

This means a function made up of five steps (sub-functions) applied in order from top to bottom.

Split: break up into runs of identical elements:  {1,1,0,1,1,0,1} ↦ {{1,1}, {0}, {1,1}, {0,0}}

Map[# Tr@# &]: For each sub-list (Map) multiply it (#) by its sum (vector trace, Tr): {1,1} ↦ {2, 2}

# - Max[1, #] & subtract from every element the maximum value appearing anywhere in the list of lists, or one, whichever is higher.  (The one handles the case of all zeros.)

UnitStep: equal to 0 for x < 0 and 1 for x >= 0, applied to every element.

Apply[Join]: join the sub-lists into a single list.  Could also be done with Flatten or Catenate, but in short form Join@@ is more terse.


答:
Python 2, 102 bytes

```<code>p=input()
q=p/p
print[i if min([i%l for l in range(q+q,i)]+[q])>q-q else None for i in range(q+q,p+q)]
</code>```

Title: Illiteral Prime numbers

Body:
Python 2, 102 bytes

p=input()
q=p/p
print[i if min([i%l for l in range(q+q,i)]+[q])>q-q else None for i in range(q+q,p+q)]


问:
Maximum Maxima!
Inspired by this question and refined by Luis Mendo.

Challenge

Given a 2D matrix of integers, each row has a maximum value. One or more elements of each row will be equal to the maximum value of their respective row. Your goal is to determine which column(s) contain the most entries which are equal to their respective row's maximum value as well as the number of row-wise maxima found in these columns.

Input

The input will be a non-empty M x N matrix (M > 0 and N > 0) in whatever form is well-suited to your language of choice.

Output

Your program should return the index of each column containing the maximum number of row-wise maxima (either as separate values or a list). Either 0- or 1-based indexing can be used (specify in your description).

Your program should also return the number of maxima that were present in these columns (a single number).

The order/format of the output is flexible but should be explained in the text accompanying your answer.

Additional Information

All entries in the input matrix will be positive integers.

If the maximum value of a row is shared by multiple elements in that row, all
occurrences of that value count towards their columns' total.

If multiple columns contain the same number of maxima, you should return a list of all columns
which had this number of maxima.

An Example

Consider input

```<code> 7  93
69  35
77  30
</code>```

Row 1 has maxium 93, which occurs only once, namely at column 2. Row 2: occurs at column 1. Row 3: also at column 1. So the winner column is 1, with 2 maxima. Thus the output will be [1] [2]. If we change the input to

```<code> 7  93
69  35
77  77
</code>```

the output will be [1 2] [2], because both columns have 2 maxima.

Test Cases

```<code>input                 =>    output ( [1-based index array], [nMaxima] )
----------------------------------------------
 7  93
69  35                =>    [1], [2]
77  30

 7  93
69  35                =>    [1 2], [2]
77  77

1   2   3   4         =>    [4], [2]
5   6   7   8

16   2   3  13
 5  11  10   8        =>    [1  2  4], [1]
 9   7   6  12

 1   1   1   1        =>    [1  2  3  4], [1]

25   6  13  25        =>    [1  4], [1]

1
2
3                     =>    [1], [4]
4

100                   =>    [1], [1]
</code>```

Scoring

This is code-golf, the shortest code in bytes wins. Tiebreaker goes to the earlier answer.

Leaderboard

Below is a stack snippet for analyzing all entries.

var QUESTION_ID=80788,OVERRIDE_USER=51939;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

```

答:
Python 3, 142 bytes

The algorithm here is basically, go through each row and increase the score of columns that have the max of that row. Then find the max of the scores and find the columns that have that max score and return them. Columns are 1-indexed. I tried one-lining this into a lambda, but with generating the scores column by column it was 153 bytes.

def f(r):
    s=[0]*len(r[0]);e=enumerate
    for x in r:
        for i,j in e(x):
            s[i]+=(0,1)[j==max(x)]
    m=max(s);return[i+1for i,j in e(s)if j==m],m
```

<hr>

<h2>Test Cases</h2>

<pre class="lang-py prettyprint-override"><code>x=[[7, 93],
[69, 35],
[77, 30]]

print(f(x)) #=>    [[1], 2]

x=[[ 7, 93],
[69, 35],
[77, 77]]

print(f(x)) #=>    [[1 2], 2]

x=[[1,  2,   3,  4],
[5,  6,  7,  8]]

print(f(x)) #=>    [[4], 2]

x=[[16,  2,  3, 13],
 [5, 11, 10,  8],
 [9,  7, 6, 12]]

print(f(x)) #=>    [[1  2  4], 1]

x=[[1,  1,  1,  1]]

print(f(x)) #=>    [[1  2  3  4], 1]

x=[[25,   6,  13,  25]]

print(f(x)) #=>    [[1  4], 1]

x=[[1],
[2],
[3],
[4]]

print(f(x)) #=>    [[1], 4]

x=[[100]]

print(f(x)) #=>    [[1], 1]
</code>```

Title: Maximum Maxima!

Body:
Python 3, 142 bytes

The algorithm here is basically, go through each row and increase the score of columns that have the max of that row. Then find the max of the scores and find the columns that have that max score and return them. Columns are 1-indexed. I tried one-lining this into a lambda, but with generating the scores column by column it was 153 bytes.

def f(r):
    s=[0]*len(r[0]);e=enumerate
    for x in r:
        for i,j in e(x):
            s[i]+=(0,1)[j==max(x)]
    m=max(s);return[i+1for i,j in e(s)if j==m],m

Test Cases

x=[[7, 93],
[69, 35],
[77, 30]]

print(f(x)) #=>    [[1], 2]

x=[[ 7, 93],
[69, 35],
[77, 77]]

print(f(x)) #=>    [[1 2], 2]

x=[[1,  2,   3,  4],
[5,  6,  7,  8]]

print(f(x)) #=>    [[4], 2]

x=[[16,  2,  3, 13],
 [5, 11, 10,  8],
 [9,  7, 6, 12]]

print(f(x)) #=>    [[1  2  4], 1]

x=[[1,  1,  1,  1]]

print(f(x)) #=>    [[1  2  3  4], 1]

x=[[25,   6,  13,  25]]

print(f(x)) #=>    [[1  4], 1]

x=[[1],
[2],
[3],
[4]]

print(f(x)) #=>    [[1], 4]

x=[[100]]

print(f(x)) #=>    [[1], 1]


答:
Jelly, 9 bytes

```<code>="Ṁ€SµM,Ṁ
</code>```

Input is a 2D list, output is a pair: a list of 1-based indices and the maximal number of maxima.

Try it online! or verify all test cases.

How it works

```<code>="Ṁ€SµM,Ṁ  Main link. Argument: M (matrix)

  Ṁ€       Apply maximum to each row.
="         Zipwith equal; compare the entries of the nth row with its maxmium.
    S      Sum; reduce across columns to count the maxima in each row.
     µ     Begin a new, monadic link. Argument: A (list of maxima)
      M    Yield all indices with maximal value.
        Ṁ  Yield the maximum of A.
       ,   Pair the results to both sides.
</code>```

Title: Maximum Maxima!

Body:
Inspired by this question and refined by Luis Mendo.

Challenge

Given a 2D matrix of integers, each row has a maximum value. One or more elements of each row will be equal to the maximum value of their respective row. Your goal is to determine which column(s) contain the most entries which are equal to their respective row's maximum value as well as the number of row-wise maxima found in these columns.

Input

The input will be a non-empty M x N matrix (M > 0 and N > 0) in whatever form is well-suited to your language of choice.

Output

Your program should return the index of each column containing the maximum number of row-wise maxima (either as separate values or a list). Either 0- or 1-based indexing can be used (specify in your description).

Your program should also return the number of maxima that were present in these columns (a single number).

The order/format of the output is flexible but should be explained in the text accompanying your answer.

Additional Information

All entries in the input matrix will be positive integers.

If the maximum value of a row is shared by multiple elements in that row, all
occurrences of that value count towards their columns' total.

If multiple columns contain the same number of maxima, you should return a list of all columns
which had this number of maxima.

An Example

Consider input

```<code> 7  93
69  35
77  30
</code>```

Row 1 has maxium 93, which occurs only once, namely at column 2. Row 2: occurs at column 1. Row 3: also at column 1. So the winner column is 1, with 2 maxima. Thus the output will be [1] [2]. If we change the input to

```<code> 7  93
69  35
77  77
</code>```

the output will be [1 2] [2], because both columns have 2 maxima.

Test Cases

```<code>input                 =>    output ( [1-based index array], [nMaxima] )
----------------------------------------------
 7  93
69  35                =>    [1], [2]
77  30

 7  93
69  35                =>    [1 2], [2]
77  77

1   2   3   4         =>    [4], [2]
5   6   7   8

16   2   3  13
 5  11  10   8        =>    [1  2  4], [1]
 9   7   6  12

 1   1   1   1        =>    [1  2  3  4], [1]

25   6  13  25        =>    [1  4], [1]

1
2
3                     =>    [1], [4]
4

100                   =>    [1], [1]
</code>```

Scoring

This is code-golf, the shortest code in bytes wins. Tiebreaker goes to the earlier answer.

Leaderboard

Below is a stack snippet for analyzing all entries.

var QUESTION_ID=80788,OVERRIDE_USER=51939;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

```

Body:
Jelly, 9 bytes

="Ṁ€SµM,Ṁ

Input is a 2D list, output is a pair: a list of 1-based indices and the maximal number of maxima.

Try it online! or verify all test cases.

How it works

="Ṁ€SµM,Ṁ  Main link. Argument: M (matrix)

  Ṁ€       Apply maximum to each row.
="         Zipwith equal; compare the entries of the nth row with its maxmium.
    S      Sum; reduce across columns to count the maxima in each row.
     µ     Begin a new, monadic link. Argument: A (list of maxima)
      M    Yield all indices with maximal value.
        Ṁ  Yield the maximum of A.
       ,   Pair the results to both sides.


问:
Include a JavaScript script with JavaScript
To dynamically include a JavaScript file in a web page, you'd normally insert a

答:
49 bytes

```<code>document.write`<script src=//v.ht/KvtI></script>`
</code>```

no one clearly said: you should keep current page content

Body:
49 bytes

document.write`<script src=//v.ht/KvtI></script>`

no one clearly said: you should keep current page content


答:
Python 2, 106 bytes

x=map(sum,zip(*[map(max(r).__eq__,r)for r in input()]))
m=max(x);print[i for i,n in enumerate(x)if n==m],m
```

Input is a 2D list of floats, output is a pair: a list of 0-based indices and an integer.

Test it on Ideone.

Title: Maximum Maxima!

Body:
Python 2, 106 bytes

x=map(sum,zip(*[map(max(r).__eq__,r)for r in input()]))
m=max(x);print[i for i,n in enumerate(x)if n==m],m

Input is a 2D list of floats, output is a pair: a list of 0-based indices and an integer.

Test it on Ideone.


答:
Julia, 54 bytes

f(x,m=maximum,t=sum(x.==m(x,2),1))=find(t.==m(t)),m(t)
```

Input is a matrix, output is a pair: a list of 1-based indices and the maximal number of maxima.

Try it online!

Title: Maximum Maxima!

Body:
Julia, 54 bytes

f(x,m=maximum,t=sum(x.==m(x,2),1))=find(t.==m(t)),m(t)

Input is a matrix, output is a pair: a list of 1-based indices and the maximal number of maxima.

Try it online!


答:
Haskell, <s>59</s>, <s>58</s>, <s>55</s>, 64 bytes

```<code>import Data.List
((=<<)=<<(=<<)(<$).(==).maximum.([1<2]:)).group
</code>```

Fun note, this works on any list of values where falsy < truthy. So False/True, 0/1, 'f'/'t', etc.

Note:

As several people have pointed out (including @proud haskeller and @nimi), the previous version failed on a list of all falsy values. The addition of .([1<2]:) has fixed this, as suggested by @proud haskeller. I'm leaving the explanation the same for now, because I think it still makes sense. If anyone comments, asking for an explanation of the edit, I'll edit.

Explanation:

I'll first desugar without the group, and then add it back.
First, I find that words are often easier on the eyes than symbols, so I'll make a few substitutions. (Note that =<< is 'classy' so it applies differently for lists and functions. I'm calling bind the version of =<< for functions.)

```<code>bind :: (a -> b -> c) -> (b -> a) -> b -> c
bind k f = k =<< f
bind k f = \ r -> k (f r) r

f = ((=<<)=<<(=<<)(<$).(==).maximum)
f = ((bind) concatMap (bind)(<$).equals.maximum)
f = (bind concatMap (bind (<$) . equals . maximum))
f = bind concatMap ((bind (<$)) . equals . maximum))
f = bind concatMap ((\f r -> (<$) (f r) r) . equals . maximum))
f = bind concatMap ((\f r -> (f r) <$ r) . equals . maximum)
f = bind concatMap ((\g r -> (g r) <$ r) . equals . maximum)
f = (\h r -> concatMap (h r) r) ((\g r -> (g r) <$ r) . equals . maximum)
f = \r -> concatMap (((\g r -> (g r) <$ r) . equals . maximum) r) r
f = \r -> concatMap (((\g r -> (g r) <$ r) . equals) (maximum r)) r
f = \r -> concatMap (((\g s -> (g s) <$ s)) (equals (maximum r))) r
f = \r -> concatMap (((\s -> ((equals (maximum r)) s) <$ s))) r
f = \r -> concatMap (\s -> (s == (maximum r)) <$ s) r

f . group = ((=<<)=<<(=<<)(<$).(==).maximum).group
f . group = \r -> concatMap (\s -> (s == (maximum (group r))) <$ s) (group r)
</code>```

The last details are that x <$ list replaces every element of the list with x and group list splits the list up into chunks of equal elements. So group [1, 1, 2, 3, 3, 3] == [[1, 1], [2], [3, 3, 3]].

To sum it all up, the function splits the list of values into groups of only true and groups of only false. Then for each group, replace each element with the result of the statement this is the biggest group (the largest group of true's will be the biggest) and concatenate the groups.

Four bytes saved by @Zgarb

Title: Falsify brief truths

Body:
Haskell, <s>59</s>, <s>58</s>, <s>55</s>, 64 bytes

import Data.List
((=<<)=<<(=<<)(<$).(==).maximum.([1<2]:)).group

Fun note, this works on any list of values where falsy < truthy. So False/True, 0/1, 'f'/'t', etc.

Note:

As several people have pointed out (including @proud haskeller and @nimi), the previous version failed on a list of all falsy values. The addition of .([1<2]:) has fixed this, as suggested by @proud haskeller. I'm leaving the explanation the same for now, because I think it still makes sense. If anyone comments, asking for an explanation of the edit, I'll edit.

Explanation:

I'll first desugar without the group, and then add it back.
First, I find that words are often easier on the eyes than symbols, so I'll make a few substitutions. (Note that =<< is 'classy' so it applies differently for lists and functions. I'm calling bind the version of =<< for functions.)

bind :: (a -> b -> c) -> (b -> a) -> b -> c
bind k f = k =<< f
bind k f = \ r -> k (f r) r

f = ((=<<)=<<(=<<)(<$).(==).maximum)
f = ((bind) concatMap (bind)(<$).equals.maximum)
f = (bind concatMap (bind (<$) . equals . maximum))
f = bind concatMap ((bind (<$)) . equals . maximum))
f = bind concatMap ((\f r -> (<$) (f r) r) . equals . maximum))
f = bind concatMap ((\f r -> (f r) <$ r) . equals . maximum)
f = bind concatMap ((\g r -> (g r) <$ r) . equals . maximum)
f = (\h r -> concatMap (h r) r) ((\g r -> (g r) <$ r) . equals . maximum)
f = \r -> concatMap (((\g r -> (g r) <$ r) . equals . maximum) r) r
f = \r -> concatMap (((\g r -> (g r) <$ r) . equals) (maximum r)) r
f = \r -> concatMap (((\g s -> (g s) <$ s)) (equals (maximum r))) r
f = \r -> concatMap (((\s -> ((equals (maximum r)) s) <$ s))) r
f = \r -> concatMap (\s -> (s == (maximum r)) <$ s) r

f . group = ((=<<)=<<(=<<)(<$).(==).maximum).group
f . group = \r -> concatMap (\s -> (s == (maximum (group r))) <$ s) (group r)

The last details are that x <$ list replaces every element of the list with x and group list splits the list up into chunks of equal elements. So group [1, 1, 2, 3, 3, 3] == [[1, 1], [2], [3, 3, 3]].

To sum it all up, the function splits the list of values into groups of only true and groups of only false. Then for each group, replace each element with the result of the statement this is the biggest group (the largest group of true's will be the biggest) and concatenate the groups.

Four bytes saved by @Zgarb


问:
Correct way to add numbers to get lots of 8's
Inspired by this question which was further inspired by this one, write a program which takes two integers and adds them in a unique way, by performing an OR operation on the segments used to display them in a 7-segment display.  For reference, the digits are represented in the following way:

```<code> _        _   _         _    _   _    _    _
| |   |   _|  _|  |_|  |_   |_    |  |_|  |_|
|_|   |  |_   _|    |   _|  |_|   |  |_|   _|
</code>```

Note that the 1 uses the two segments on the right, not the left.  There are two special characters that can be produced this way which are not numbers.  See the addition table below:

```<code>  | 0 1 2 3 4 5 6 7 8 9
--+--------------------
0 | 0 0 8 8 8 8 8 0 8 8
1 | 0 1 a 3 4 9 8 7 8 9
2 | 8 a 2 a 8 8 8 a 8 8
3 | 8 3 a 3 9 9 8 3 8 9
4 | 8 4 8 9 4 9 8 Q 8 9
5 | 8 9 8 9 9 5 6 9 8 9
6 | 8 8 8 8 8 6 6 8 8 8
7 | 0 7 a 3 Q 9 8 7 8 9
8 | 8 8 8 8 8 8 8 8 8 8
9 | 8 9 8 9 9 9 8 9 8 9
</code>```

Useful observations:

Any digit plus itself equals itself

8 plus any digit equals 8

2 plus 1, 3, or 7 equals the letter 'a' (must be lower-case)

4 plus 7 equals either 'q' or 'Q', your choice

Numbers should be right-aligned, so the digits should be added from right to left.  If one number has more digits than the other, the extra digits at the beginning should be unchanged.  There are no leading 0's, unless the number is exactly 0.

All numbers will be 0 or greater.  You don't need to handle a '-' sign.  (Mainly because there's no good fit for the sum of a '-' and a '1' or '7'.)

Your program should accept 2 integers in any format you choose, and output a string containing their "sum" when calculated in this manner.  This is code-golf, so your program should be as small as possible.

Examples:

Input: 12345, 123.  Output: 12389

Input: 88888, 42.  Output: 88888

Input: 0, 23.  Output: 28

Input: 120, 240.  Output: a80

Input: 270, 42.  Output: 2Q8 (or 2q8)

Input: 1234567890, 1234567890.  Output: 1234567890

答:
Java, 170 bytes

This is terribly long... but this is Java anyway.

String A(int a,int b){String c="|HgmY=?h}oy",r="";for(;a>0|b>0;a/=10,b/=10)r="0123456789aq".charAt(c.indexOf((a>0?c.charAt(a%10):0)|(b>0?c.charAt(b%10):0)))+r;return r;}
```

<h2>Full program, with ungolfed code</h2>

<pre class="lang-java prettyprint-override"><code>public class Q80716 {
    String A(int a,int b){String c="|HgmY=?h}oy",r="";for(;a>0|b>0;a/=10,b/=10)r="0123456789aq".charAt(c.indexOf((a>0?c.charAt(a%10):0)|(b>0?c.charAt(b%10):0)))+r;return r;}
    String Add(int a,int b){
        String c = "|HgmY=?h}oy", d = "0123456789aq";
        String r = "";
        for(;a>0|b>0;a/=10,b/=10){
            r = d.charAt(c.indexOf((a>0?c.charAt(a%10):0)|(b>0?c.charAt(b%10):0))) + r;
        }
        return r;
    }
    public static void main(String[]args){
        int[][] testcases = new int[][]{
            {12345,123},
            {88888,42},
            {0,23},
            {120,240},
            {270,42},
            {1234567890,1234567890}
        };
        for(int i=0;i<testcases.length;i++){
            System.out.println(new Q80716().Add(testcases[i][0],testcases[i][1]));
            System.out.println(new Q80716().A(testcases[i][0],testcases[i][1]));
        }
    }
}
</code>```

All output (all duplicated once)

12389
88888
23
a80
2q8
1234567890
```

Body:
Java, 170 bytes

This is terribly long... but this is Java anyway.

String A(int a,int b){String c="|HgmY=?h}oy",r="";for(;a>0|b>0;a/=10,b/=10)r="0123456789aq".charAt(c.indexOf((a>0?c.charAt(a%10):0)|(b>0?c.charAt(b%10):0)))+r;return r;}

Full program, with ungolfed code

public class Q80716 {
    String A(int a,int b){String c="|HgmY=?h}oy",r="";for(;a>0|b>0;a/=10,b/=10)r="0123456789aq".charAt(c.indexOf((a>0?c.charAt(a%10):0)|(b>0?c.charAt(b%10):0)))+r;return r;}
    String Add(int a,int b){
        String c = "|HgmY=?h}oy", d = "0123456789aq";
        String r = "";
        for(;a>0|b>0;a/=10,b/=10){
            r = d.charAt(c.indexOf((a>0?c.charAt(a%10):0)|(b>0?c.charAt(b%10):0))) + r;
        }
        return r;
    }
    public static void main(String[]args){
        int[][] testcases = new int[][]{
            {12345,123},
            {88888,42},
            {0,23},
            {120,240},
            {270,42},
            {1234567890,1234567890}
        };
        for(int i=0;i<testcases.length;i++){
            System.out.println(new Q80716().Add(testcases[i][0],testcases[i][1]));
            System.out.println(new Q80716().A(testcases[i][0],testcases[i][1]));
        }
    }
}

All output (all duplicated once)

12389
88888
23
a80
2q8
1234567890


问:
Create output twice the length of the code

The Challenge

Write a complete program that writes twice as many bytes to standard output as the length of the program.

Rules

The program must write ASCII characters to the standard output.

The contents of the output doesn't matter.

The output, measured in bytes, must be exactly twice the length of the program, also measured in bytes, unless you fulfill the bonus.

Any trailing newline is included in the output's byte count.

Bonus

Your program can optionally take a number, n, as input. If so, the output must be exactly n * program length bytes. You can assume that n will always be a positive integer. If no input is provided, n must default to 2.

If you do this,  you can subtract 25 bytes from your score.

Shortest program wins.

Restrictions

No standard loopholes.

The program must be at least 1 byte long.

No adding unnecessary whitespace to the source code to change its length. Similarly, comments don't count.

Unless you fulfill the bonus, the program must accept no input. If you do fulfill the bonus, the integer must be the only input.

Lowest score (program length in bytes - bonus) wins.

The shortest answer for each language wins for that language.

Leaderboards

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

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

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

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

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

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

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

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

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

var QUESTION_ID=59436,OVERRIDE_USER=41505;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

```

答:
Tellurium, 10 bytes

```<code>µa~Åm16.
</code>```

Outputs a 16 times. Simple enough.

More detailed explanation:

```<code>µ         Begins reading a string
a
~         Stops reading a string and stores it in the selected cell
Å         Command set 2
m         Print the cell's value n times
16
.
</code>```

There might be a shorter version using Åw but I'm too tired to do that :P

Body:
Tellurium, 10 bytes

µa~Åm16.

Outputs a 16 times. Simple enough.

More detailed explanation:

µ         Begins reading a string
a
~         Stops reading a string and stores it in the selected cell
Å         Command set 2
m         Print the cell's value n times
16
.

There might be a shorter version using Åw but I'm too tired to do that :P


答:
Matlab(284)

Too much rules, too much bytes, i hate too much rules!

```<code>function h(n),f=mod(n,2);b=(n-11*f)/2;a=fix((n-2*b)/11);c=(mod(ceil(b/11),10)+1)*(b>99);b=b-c*11;a=a+2*c;u=min(fix(b/10),mod(b,10));r=min(u,fix((9-a)/2*(a<9)));a=a+2*r;b=b-11*r;if(a>18||b<0||a+2*(u-r)>9&a==8)return;end,u=(a>9);r=mod(a,10-u);[fix(b/10),max(u*9,r);min(u*9,r),mod(b,10)]
</code>```

this is a straight-forward method without even calculating the lowest weight of a square, i will add an explanation once i online-fork it.

This is how it goes, as known that a square value ab+cd+ac+bd can be simplified algebrically as 11(b+c)+2*[ad]_dec where [ad] is a*10+d , with weights assigned by ops respectively as (W_a,W_d)=(1,4) and (W_b,W_c)=(2,3) .

Thus, assuming an initial value of [ad] set as maximal number written in two digits, any number subtracted from it must be a multiple of 11 to be added to (b+c), otherwise that would screw the general form that the square value must be written as.

Since [ad] is two digits number, the multiple of 11 subtracted from [ad] must hold same amount from both a and d, which means weights are decreased equally but not added to (b+c) equally because it is required to attribute the maximal number to the lowest upweighting number which is b. so b will receive an even number. See the picture below it is definitely clearer than my awkward wording:

See that a (ported) value is not addded gradually, but there is a mathematical condition for it , it is S=minimum_positive(9-(b+c),a,d)

For the rest of conditions, function doesnt output nothing when:

b+c exceeds 18

the square value is below 11 and odd

after adding the farce to (b+c), min(a,d) remains bigger than 1, and b+c = 8, this means there is a potential square value of weight 3+2 , which equals the weight 1+4 , two equivalent values is an exclusive option, and disqualifies the outputs (tbh i dont see any point behind this rule)

Body:
A number square containing the values 1, 2, 3, 4 looks like this:

```<code>12
34
</code>```

To work out what a number square is, you first make four numbers by reading across the rows and across the columns; for the example above you would get 12, 34, 13 and 24, then you add them all up (12+34+13+24), giving you the value of the square.

However, there is a catch: the square your program outputs must output the lowest possible square. The way to calculate how 'low' the square is is like this:

Take the top-left number, and place it in the variable a.

Take the top-right number, double it and add the total to a.

Take the bottom-left number, triple it and add the total to a.

Take the bottom-right number, quadruple it and add the total to a.

The variable a now holds how 'low' you square is!

Requirements

Your program must output the lowest possible number square, in the format that follows:

```<code>ab
cd
</code>```

(where a, b, c and d are integers in the range 0-9).

The square will never contain a number multiple digits long (negative numbers as well). You don't have to handle that case.

You can take input, which will be the number the square should equal, as an argument, as function argument or from STDIN. Please specify how input should be given for your program.

If there is not a number square that equals what the input number, output nothing.

If two numbers squares are equally low and produce the same output, nothing should be output.

Rules

Standard loopholes are forbidden.

Your program must not write anything to STDERR.

Test Cases

```<code>44 ==>
04
00
-----
2 ==>
00
01
-----
100 ==>
50
00
</code>```

@MartinBüttner has also done a Pastebin with all the possible solutions.

Scoring

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

To win this code-golf challenge, try to get the least bytes!

Submissions

To make sure that your answer can be parsed, please start your answer with a headline, using the following Markdown template:

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

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

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

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

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

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

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

Leaderboard

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

  });

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Matlab(284)

Too much rules, too much bytes, i hate too much rules!

function h(n),f=mod(n,2);b=(n-11*f)/2;a=fix((n-2*b)/11);c=(mod(ceil(b/11),10)+1)*(b>99);b=b-c*11;a=a+2*c;u=min(fix(b/10),mod(b,10));r=min(u,fix((9-a)/2*(a<9)));a=a+2*r;b=b-11*r;if(a>18||b<0||a+2*(u-r)>9&a==8)return;end,u=(a>9);r=mod(a,10-u);[fix(b/10),max(u*9,r);min(u*9,r),mod(b,10)]

this is a straight-forward method without even calculating the lowest weight of a square, i will add an explanation once i online-fork it.

This is how it goes, as known that a square value ab+cd+ac+bd can be simplified algebrically as 11(b+c)+2*[ad]_dec where [ad] is a*10+d , with weights assigned by ops respectively as (W_a,W_d)=(1,4) and (W_b,W_c)=(2,3) .

Thus, assuming an initial value of [ad] set as maximal number written in two digits, any number subtracted from it must be a multiple of 11 to be added to (b+c), otherwise that would screw the general form that the square value must be written as.

Since [ad] is two digits number, the multiple of 11 subtracted from [ad] must hold same amount from both a and d, which means weights are decreased equally but not added to (b+c) equally because it is required to attribute the maximal number to the lowest upweighting number which is b. so b will receive an even number. See the picture below it is definitely clearer than my awkward wording:

See that a (ported) value is not addded gradually, but there is a mathematical condition for it , it is S=minimum_positive(9-(b+c),a,d)

For the rest of conditions, function doesnt output nothing when:

b+c exceeds 18

the square value is below 11 and odd

after adding the farce to (b+c), min(a,d) remains bigger than 1, and b+c = 8, this means there is a potential square value of weight 3+2 , which equals the weight 1+4 , two equivalent values is an exclusive option, and disqualifies the outputs (tbh i dont see any point behind this rule)