答:
C#, <s>356</s> 272 bytes

Golfed

```<code>()=>{Action f=Console.WriteLine;Action<int,int>o=(c,l)=>{Console.BackgroundColor=(ConsoleColor)c+8;Console.Write(new char[l]);};for(int d=1,i=0;i>-1;i+=d){if(i<7){o(1,7);o(7,1);o(4,2);o(7,1);o(1,14);}if(i==7){o(7,8);o(4,2);o(7,15);}if(i>7){o(4,25);f();o(4,25);d=-1;}f();}}
</code>```

Ungolfed

```<code>() =>
{
    Action f = Console.WriteLine;
    Action<int, int> o = (c, l) =>
    {
        Console.BackgroundColor = (ConsoleColor)c + 8;
        Console.Write(new char[l]);
    };
    for (int d = 1, i = 0; i > -1; i += d)
    {
        if (i < 7)
        {
            o(1, 7);
            o(7, 1);
            o(4, 2);
            o(7, 1);
            o(1, 14);
        }
        if (i == 7)
        {
            o(7, 8);
            o(4, 2);
            o(7, 15);
        }
        if (i > 7)
        {
            o(4, 25);
            f();
            o(4, 25);
            d = -1;
        }
        f();
    }
}
</code>```

By the rules anonymous delegates are allowed as long as the answer includes an example of how to run it...

```<code>using System;
class P
{
    static void Main()
    {
        new Action(
/*replace this with delegate*/
        )();
    }
}
</code>```

Title: Draw the national flag of Iceland

Body:
This year's UEFA Euro 2016 is over and besides a couple of negative headlines there has been a very positive surprise as well – the Iceland national football team. Let's draw their national flag.

Input

Well, obviously this challenge has no input.

Output

Draw the flag of Iceland in any applicable visual format of at least 100 x 72 pixels or 25 x 18 characters.

Save the output to a file or present it instantly – example formats are: images like png, jpg etc., vector graphics, draw on HTML canvas or even use non-whitespace characters for visualization.

Use these colors: blue: #0048e0, white: #ffffff and red: #d72828.

If your language doesn't support specific color values, use the standard values for red, blue and white from the ANSI color codes.

Draw the flag with the correct proportions, as shown in the figure below:

Boilerplate

You can write a program or a function. If it is an anonymous function, please include an example of how to invoke it.

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

Standard loopholes are disallowed.

Leaderboard

var QUESTION_ID = 85141; // 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 = 41859; // This should be the user ID of the challenge author.
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 (! /<a/.test(lang)) lang = '' + lang + '';lang = jQuery(lang).text().toLowerCase();languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link, uniq: lang};});var langs = [];for (var lang in languages)if (languages.hasOwnProperty(lang))langs.push(languages[lang]);langs.sort(function (a, b) {if (a.uniq > b.uniq) return 1;if (a.uniq < b.uniq) 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/Sites/codegolf/all.css?v=617d0685f6f3">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

If you can't find your answer, format your language and byte count as explained in the Leaderboard's "Info Section".

This challenge is inspired by Draw the national flag of france.

Body:
C#, <s>356</s> 272 bytes

Golfed

()=>{Action f=Console.WriteLine;Action<int,int>o=(c,l)=>{Console.BackgroundColor=(ConsoleColor)c+8;Console.Write(new char[l]);};for(int d=1,i=0;i>-1;i+=d){if(i<7){o(1,7);o(7,1);o(4,2);o(7,1);o(1,14);}if(i==7){o(7,8);o(4,2);o(7,15);}if(i>7){o(4,25);f();o(4,25);d=-1;}f();}}

Ungolfed

() =>
{
    Action f = Console.WriteLine;
    Action<int, int> o = (c, l) =>
    {
        Console.BackgroundColor = (ConsoleColor)c + 8;
        Console.Write(new char[l]);
    };
    for (int d = 1, i = 0; i > -1; i += d)
    {
        if (i < 7)
        {
            o(1, 7);
            o(7, 1);
            o(4, 2);
            o(7, 1);
            o(1, 14);
        }
        if (i == 7)
        {
            o(7, 8);
            o(4, 2);
            o(7, 15);
        }
        if (i > 7)
        {
            o(4, 25);
            f();
            o(4, 25);
            d = -1;
        }
        f();
    }
}

By the rules anonymous delegates are allowed as long as the answer includes an example of how to run it...

using System;
class P
{
    static void Main()
    {
        new Action(
/*replace this with delegate*/
        )();
    }
}


问:
Big big numbers
Whilst trying to golf several of my answers, I've needed to write large integers in as few characters as possible.

Now I know the best way to do that: I'll be getting you to be writing this program.

The challenge

Write a program that when given a positive integer, outputs a program that prints it to stdout or equivalent.

The output programs don't have to be in the same language as the creator.

The output must be at most 128 bytes.

You may accept input from stdin or equivalent (not function input)

You may output the resulting program to stdout or equivalent.

The number output must be in decimal (base 10)

Scoring

Your score is equal to the smallest positive integer your program can not encode.

The entry with the largest score wins.

答:
Python 3 → CJam, (163122 − 1)·255/162 + 1 ≈ 1.213·10270

import sys
n = int(input())
for b in range(163, 1, -1):
    s = []
    m = n
    while m:
        m, r = divmod(m - 93, b)
        if m < 0:
            break
        s.append(r + 93)
    else:
        sys.stdout.buffer.write(b'"%s"%db' % (bytes(s[::-1]), b))
        break
else:
    sys.stdout.buffer.write(b'%d' % n)
```

It turns out that every integer from 1023 through (163122 − 1)·255/162 can be represented in at least one way by a base b ≤ 163 conversion from a string of at most 122 characters with codes 93 through b + 92, rather than the usual 0 through b − 1.  This avoids the troublesome characters 34 (double quote) and 92 (backslash) without any extra output code.

ContentLicense: CC BY-SA 3.0

Title: Big big numbers

Body:
Python 3 → CJam, (163122 − 1)·255/162 + 1 ≈ 1.213·10270

import sys
n = int(input())
for b in range(163, 1, -1):
    s = []
    m = n
    while m:
        m, r = divmod(m - 93, b)
        if m < 0:
            break
        s.append(r + 93)
    else:
        sys.stdout.buffer.write(b'"%s"%db' % (bytes(s[::-1]), b))
        break
else:
    sys.stdout.buffer.write(b'%d' % n)

It turns out that every integer from 1023 through (163122 − 1)·255/162 can be represented in at least one way by a base b ≤ 163 conversion from a string of at most 122 characters with codes 93 through b + 92, rather than the usual 0 through b − 1.  This avoids the troublesome characters 34 (double quote) and 92 (backslash) without any extra output code.


问:
Calculate A190810
Your task is pretty simple, calculate the n-th element of A190810.

Elements of A190810 are calculated according to these rules:

The first element is 1

The sequence is increasing

If x occurs in the sequence, then 2x+1 and 3x-1 also do

You can use 1-based or 0-based indexing, but if you use 0-based indexing, please say it in the answer.

Test cases

```<code>a(1) = 1
a(2) = 2
a(3) = 3
a(4) = 5
a(5) = 7
a(10) = 17
a(20) = 50
a(30) = 95
a(55) = 255
</code>```

Since this is code-golf, the shortest answer in bytes wins!

答:
Retina, 57

```<code>^.+
$*¶¶1
¶¶(1(1*))
¶1$1$1¶$2$1$1
O`
}`(¶1+)\1\b
$1
G2`
1
</code>```

Try it online!

0-indexed. Follows the frequently used algorithm: remove the minimum value from the current set, call it x, and add 2x+1 and 3x-1 to the set a number of times equal to the input, then the leading number is the result. The "set" in Retina is just a list that is repeatedly sorted and made to contain only unique elements. There are some sneaky bits added to the algorithm for golf, which I will explain once I've had some more time.

Big thanks to Martin for golfing off around 20 bytes!

Title: Calculate A190810

Body:
Retina, 57

^.+
$*¶¶1
¶¶(1(1*))
¶1$1$1¶$2$1$1
O`
}`(¶1+)\1\b
$1
G2`
1

Try it online!

0-indexed. Follows the frequently used algorithm: remove the minimum value from the current set, call it x, and add 2x+1 and 3x-1 to the set a number of times equal to the input, then the leading number is the result. The "set" in Retina is just a list that is repeatedly sorted and made to contain only unique elements. There are some sneaky bits added to the algorithm for golf, which I will explain once I've had some more time.

Big thanks to Martin for golfing off around 20 bytes!


答:
Actually, 27 bytes

```<code>╗1#╜`;;2*1+)3*1@-#++╔S`n╜@E
</code>```

Try it online!

This program uses 0-based indexing. The approach is very brute-force, so don't expect it to work in the online interpreter for larger inputs.

Explanation:

```<code>╗1#╜`;;2*1+)3*1@-#++╔S`n╜@E
╗                            save input (n) in register 0
 1#                          push [1]
   ╜                         push n
    `;;2*1+)3*1@-#++╔S`n     do the following n times:
     ;;                        make two copies of the list
       2*1+                    apply 2x+1 to each element in one copy
           )3*1@-              and 3x-1 to each element in the other copy
                 #             workaround for a weird list bug
                  ++           append those two lists to the original list
                    ╔S         uniquify and sort
                        ╜@E  get the nth element (0-indexed)
</code>```

Title: Calculate A190810

Body:
Your task is pretty simple, calculate the n-th element of A190810.

Elements of A190810 are calculated according to these rules:

The first element is 1

The sequence is increasing

If x occurs in the sequence, then 2x+1 and 3x-1 also do

You can use 1-based or 0-based indexing, but if you use 0-based indexing, please say it in the answer.

Test cases

```<code>a(1) = 1
a(2) = 2
a(3) = 3
a(4) = 5
a(5) = 7
a(10) = 17
a(20) = 50
a(30) = 95
a(55) = 255
</code>```

Since this is code-golf, the shortest answer in bytes wins!

Body:
Actually, 27 bytes

╗1#╜`;;2*1+)3*1@-#++╔S`n╜@E

Try it online!

This program uses 0-based indexing. The approach is very brute-force, so don't expect it to work in the online interpreter for larger inputs.

Explanation:

╗1#╜`;;2*1+)3*1@-#++╔S`n╜@E
╗                            save input (n) in register 0
 1#                          push [1]
   ╜                         push n
    `;;2*1+)3*1@-#++╔S`n     do the following n times:
     ;;                        make two copies of the list
       2*1+                    apply 2x+1 to each element in one copy
           )3*1@-              and 3x-1 to each element in the other copy
                 #             workaround for a weird list bug
                  ++           append those two lists to the original list
                    ╔S         uniquify and sort
                        ╜@E  get the nth element (0-indexed)


问:
Ascending matrix
The "ascending matrix" is an infinite matrix of whole numbers (0 included) in which any element is the smallest available element which has not been previously used on the respective row and column:

```<code>  | 1 2 3 4 5 6 ...
--+----------------
1 | 0 1 2 3 4 5 ...
2 | 1 0 3 2 5 4 ...
3 | 2 3 0 1 6 7 ...
4 | 3 2 1 0 7 6 ...
5 | 4 5 6 7 0 1 ...
6 | 5 4 7 6 1 0 ...
. | ...............
</code>```

Your task is to write a program that will output the element found at the row and column specified by the input. (standard input and output)

Test cases:

```<code>5 3 -> 6
2 5 -> 5
</code>```

Code Golf rules apply—the shortest code wins.

P.S. Even if this has an algorithmic nature the code can be very, very concise.

EDIT: I wasn't expecting to see the xor solution so early. I was really hoping to see 10 posts with an algorithmic approach and THEN the xor solution. Now, having in mind that it's not much fun to see how to write xor in different languages I recommend that you also try an algorithmic approach.

So, yes, I think no one can beat the 5 character mark now—therefore I congratulate Ilmari Karonen for the smartest and shortest solution. But there's a new challenge up ahead: write the shortest algorithmic solution.

答:
GolfScript, 5 chars

```<code>~(\(^
</code>```

Indeed, this task is very simple once you recognize the pattern.  The only awkward bit is the 1-based indexing — if the input indices were zero-based, this 2-character solution would suffice:

```<code>~^
</code>```

To explain this to readers unfamiliar with GolfScript, the ~ command evals the input, leaving the two numbers on the stack.  ^ then XORs the two topmost numbers on the stack together, leaving the result for output.  To deal with 1-based input, two more commands are needed: ( decrements the topmost number on the stack by one, while \ swaps the top two items on the stack.

Title: Ascending matrix

Body:
GolfScript, 5 chars

~(\(^

Indeed, this task is very simple once you recognize the pattern.  The only awkward bit is the 1-based indexing — if the input indices were zero-based, this 2-character solution would suffice:

~^

To explain this to readers unfamiliar with GolfScript, the ~ command evals the input, leaving the two numbers on the stack.  ^ then XORs the two topmost numbers on the stack together, leaving the result for output.  To deal with 1-based input, two more commands are needed: ( decrements the topmost number on the stack by one, while \ swaps the top two items on the stack.


问:
Pi Bowling to 10 in 10
Your Goal: Estimate pi to at least 10 decimal places. The format is your choice - it can output as a number, as a string, as an output to STDOUT, etc.

Seems easy, right? But wait, it's not as simple as it seems...

The Rules: You get exactly 10 function calls (this includes operators). These functions cannot be ones that naturally induce or define pi, such as the arc-trig functions or a function converting degrees to radians (this also includes any function that operates as a "solver", such as one that can find roots of sin(x)). If your language has complex number capabilities, this capability cannot be used. All functions must be part of your languages built-in functions or within a standard library (loading the library does not count as an operation, but it must be a standard library, not just a popular one).

All function calls must be crucial to your code - this means that you cannot use division by one, or factorial of two. You also cannot use any literal (except for three digits in the form of one, two, or three integers)*, reading of files of any sort, or a code's ability to convert itself into values (such as a function to get the name of a variable as a string).

*Note: an exception is made for format strings for languages that require them for output. However, only formats, not actual contents, can be found in the format strings, so you can have printf("%f%f",x,y), but not printf("%f.%f",x,y).

Loops may be used, but will eat up your function calls - the 10 function calls are calls, not total functions used. Assignment does not count as an operation, but operations such as array slicing (including obtaining a single value from an array) count, in which case a[1] would count as two bytes (for []).

If you think you've found a loophole for the rules, then it's also against the rules. This is not a challenge for finding the best bending of the rules, or the best way of abusing a minor oversight in the challenge question... if your instinct is to call it a "loophole", then post it as a comment to help close it.

Scoring: This is code bowling, so you're after the highest score. But it's not the total number of bytes in your code that is being counted.

Instead, it's the sum of bytes in the functions being used. That is, if you use 4*cos(2/3) (which happens to be approximately 3.14355), then you have three functions - *, cos, and /, with the total being 5 bytes. If you were to use, for instance (using Julia), sum(map(n->1/n,1:4)), then the operations are sum, map, /, and :, for 8 bytes... but as 1/n is being called four times, it uses 7 function calls (sum, map, four instances of /, and :). User-made functions do not count towards either the function call allowance or the byte count (note: functions used in those user-made functions do count).

Additional emphasis: The point, here, is to find the best way to abuse your language's longest built-in/standard function names in the context of calculating pi. More digits of pi aren't necessary, but I will personally be more likely to upvote an answer that gets more digits than necessary.

Remember, since you're after long function names, you should probably avoid unary and binary operators, as most of these have full function equivalents (in Julia, for instance, * can be replaced by prod).

Quick Summary: You have 10 built-in function calls (includes operators/subroutines/etc). You must estimate pi to 10 decimal places. You can use a total of 3 characters for integer literals (so you can have 1 and 36, or 1 and 2 and 3, or 328, but you can't have 22 and 49). Score is count of built-in function name bytes (if the user defines the name, it doesn't count). No functions that calculate or use pi directly. No complex numbers. This is not a challenge to find loopholes.

答:
Racket, 72 bytes

Gotta love those verbose built-in names!

```<code>((lambda() ; lambda is a Racket-defined function too, 6 bytes
  (define-values (a b) (integer-sqrt/remainder 491)) ; 13 (define-values) + 22 (integer-sqrt/remainder) = 35 (on this line alone).  a and b are 22 and 7 respectively
  (define-values (q) (/ a b)) ; 13 (define-values) + 1 (/) = 14
  (define-values (c) (+ (sin q) q)) ; 13 + 1 + 3  = 17
  (+ (sin c) c) ; 1 + 3 = 4
  )) ; total: 6 + 35 + 14 + 17 + 4 = 72
</code>```

With the amount of precision that in-exact numbers in Racket have, this is actually equal to pi such that (- pi (lambda...) outputs 0.0.

Also, I know this is a realllllllllllly old challenge.  But all of the current challenge answers do horribly in comparison to this bowl, so I had to do it.

Title: Pi Bowling to 10 in 10

Body:
Racket, 72 bytes

Gotta love those verbose built-in names!

((lambda() ; lambda is a Racket-defined function too, 6 bytes
  (define-values (a b) (integer-sqrt/remainder 491)) ; 13 (define-values) + 22 (integer-sqrt/remainder) = 35 (on this line alone).  a and b are 22 and 7 respectively
  (define-values (q) (/ a b)) ; 13 (define-values) + 1 (/) = 14
  (define-values (c) (+ (sin q) q)) ; 13 + 1 + 3  = 17
  (+ (sin c) c) ; 1 + 3 = 4
  )) ; total: 6 + 35 + 14 + 17 + 4 = 72

With the amount of precision that in-exact numbers in Racket have, this is actually equal to pi such that (- pi (lambda...) outputs 0.0.

Also, I know this is a realllllllllllly old challenge.  But all of the current challenge answers do horribly in comparison to this bowl, so I had to do it.


问:
Draw the national flag of Iceland
This year's UEFA Euro 2016 is over and besides a couple of negative headlines there has been a very positive surprise as well – the Iceland national football team. Let's draw their national flag.

Input

Well, obviously this challenge has no input.

Output

Draw the flag of Iceland in any applicable visual format of at least 100 x 72 pixels or 25 x 18 characters.

Save the output to a file or present it instantly – example formats are: images like png, jpg etc., vector graphics, draw on HTML canvas or even use non-whitespace characters for visualization.

Use these colors: blue: #0048e0, white: #ffffff and red: #d72828.

If your language doesn't support specific color values, use the standard values for red, blue and white from the ANSI color codes.

Draw the flag with the correct proportions, as shown in the figure below:

Boilerplate

You can write a program or a function. If it is an anonymous function, please include an example of how to invoke it.

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

Standard loopholes are disallowed.

Leaderboard

var QUESTION_ID = 85141; // 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 = 41859; // This should be the user ID of the challenge author.
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 (! /<a/.test(lang)) lang = '' + lang + '';lang = jQuery(lang).text().toLowerCase();languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link, uniq: lang};});var langs = [];for (var lang in languages)if (languages.hasOwnProperty(lang))langs.push(languages[lang]);langs.sort(function (a, b) {if (a.uniq > b.uniq) return 1;if (a.uniq < b.uniq) 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/Sites/codegolf/all.css?v=617d0685f6f3">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

If you can't find your answer, format your language and byte count as explained in the Leaderboard's "Info Section".

This challenge is inspired by Draw the national flag of france.

答:
FLIF, 48 bytes

I'm surprised that no (bitmap) image formats have been used as answers here. A well compressed PNG comes in at a respectable 132 bytes (thanks to tools like pngout, pngcrush and optipng). However, I encountered another intriguing format that does even better! Using FLIF (Free Lossless Image Format) and some manual trimming I got down to 48 bytes:

```<code>4c46 4649 3133 6400 4800 4023 eb51 1272
9034 113b 7727 a2b6 fdac dc4e c1ae 6cf8
4a00 fc03 2064 7772 dc38 97a7 63f2 0a03
</code>```

Viewing the image with viewflif gives the expected output:

EDIT: Added link to FLIF web site.

Title: Draw the national flag of Iceland

Body:
FLIF, 48 bytes

I'm surprised that no (bitmap) image formats have been used as answers here. A well compressed PNG comes in at a respectable 132 bytes (thanks to tools like pngout, pngcrush and optipng). However, I encountered another intriguing format that does even better! Using FLIF (Free Lossless Image Format) and some manual trimming I got down to 48 bytes:

4c46 4649 3133 6400 4800 4023 eb51 1272
9034 113b 7727 a2b6 fdac dc4e c1ae 6cf8
4a00 fc03 2064 7772 dc38 97a7 63f2 0a03

Viewing the image with viewflif gives the expected output:

EDIT: Added link to FLIF web site.


问:
Draw the national flag of France
There have been many other flag challenges posted but not one for the national flag of France. This week seems like an appropriate time.

Produce this flag in the fewest bytes possible:

The image must be in a ratio of 3:2, with size at least 78 pixels wide and 52 pixels tall.

Each stripe takes up one third of the width.

The stripe colors from left to right are RGB: (0, 85, 164), (255, 255, 255), (239, 65, 53).

The image can be saved to a file or piped raw to STDOUT in any common image file format, or it can be displayed.

Alternatively, output a block of text at least 78 characters wide made of non-whitespace characters that depicts the flag, using ANSI color codes to color it. (Use standard blue, white, and red.)

Built-in flag images/libraries are not allowed.

The shortest code in bytes wins.

Leaderboard

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
FLIF, 37 bytes

FLIF is an excellent bitmap format for when you really want to squeeze some bytes away:

```<code>4c46 4649 3133 4e00 3400 1e27 2ce3 5d2f
ab15 8fdd c110 4117 8d25 5fa2 c8b6 d02d
fdfe af77 000a
</code>```

Using viewflif:

ContentLicense: CC BY-SA 4.0

Title: Draw the national flag of France

Body:
FLIF, 37 bytes

FLIF is an excellent bitmap format for when you really want to squeeze some bytes away:

4c46 4649 3133 4e00 3400 1e27 2ce3 5d2f
ab15 8fdd c110 4117 8d25 5fa2 c8b6 d02d
fdfe af77 000a

Using viewflif:


答:
SVG+HTML, 134

<svg><path d="m0,2h100v72H0"fill="#0048e0"/><path d="M0 32H30V0h12V32h60v12H42V76H30V44H0"fill='#d72828'stroke="#fff"stroke-width='4'>```

Cheated a bit in that the rectangle is slightly offset so that I can use a second path with a red fill and white outline to draw the cross. This emerged as an idea while making suggestions to golf nicael's SVG+JS answer further and ended up as a complete rewrite of the SVG in question. In fact, this is pure SVG anyway, it just needs the HTML parser, so has to be put into an HTML file.

Title: Draw the national flag of Iceland

Body:
SVG+HTML, 134

<svg><path d="m0,2h100v72H0"fill="#0048e0"/><path d="M0 32H30V0h12V32h60v12H42V76H30V44H0"fill='#d72828'stroke="#fff"stroke-width='4'>

Cheated a bit in that the rectangle is slightly offset so that I can use a second path with a red fill and white outline to draw the cross. This emerged as an idea while making suggestions to golf nicael's SVG+JS answer further and ended up as a complete rewrite of the SVG in question. In fact, this is pure SVG anyway, it just needs the HTML parser, so has to be put into an HTML file.


答:
HTML+CSS, 225 bytes

I liked Nicael's answer, but I found a way to draw the bars in less bytes.

   *{position:fixed;width:100px;margin:0}a{background:#0048E0;height:72px}b,c{box-shadow:0 0 0 4px #FFF;}b,c,d{background:#D72828}b,d{width:8px;left:32px}b{height:72px}c{height:8px;top:32px}d{height:16px;top:28px```
<pre class="snippet-code-html lang-html prettyprint-override"><code><a><b></b><c><d></code>```

Title: Draw the national flag of Iceland

Body:
HTML+CSS, 225 bytes

I liked Nicael's answer, but I found a way to draw the bars in less bytes.

   *{position:fixed;width:100px;margin:0}a{background:#0048E0;height:72px}b,c{box-shadow:0 0 0 4px #FFF;}b,c,d{background:#D72828}b,d{width:8px;left:32px}b{height:72px}c{height:8px;top:32px}d{height:16px;top:28px

<a><b></b><c><d>


答:
HTML+CSS, single element, 321

```<code><p style="width:100;height:72;background:linear-gradient(0deg,transparent 44.4%,#D72828 44.5%,#D72828 55.6%,transparent 55.7%),linear-gradient(90deg,transparent 28%,#fff 28.1%,#fff 32%,#D72828 32.1%,#D72828 40%,#fff 40.1%,#fff 44%,transparent 44.1%),linear-gradient(0deg,#0047E0 38.9%,#fff 39%,#fff 61.1%,#0047E0 61.2%)">
</code>```

Needs quirks mode to run, so the snippet below has the errors fixed:

```

Title: Draw the national flag of Iceland

Body:
HTML+CSS, single element, 321

<p style="width:100;height:72;background:linear-gradient(0deg,transparent 44.4%,#D72828 44.5%,#D72828 55.6%,transparent 55.7%),linear-gradient(90deg,transparent 28%,#fff 28.1%,#fff 32%,#D72828 32.1%,#D72828 40%,#fff 40.1%,#fff 44%,transparent 44.1%),linear-gradient(0deg,#0047E0 38.9%,#fff 39%,#fff 61.1%,#0047E0 61.2%)">

Needs quirks mode to run, so the snippet below has the errors fixed:

<p style="width:100px;height:72px;background:linear-gradient(0deg,transparent 44.4%,#D72828 44.5%,#D72828 55.6%,transparent 55.7%),linear-gradient(90deg,transparent 28%,#fff 28.1%,#fff 32%,#D72828 32.1%,#D72828 40%,#fff 40.1%,#fff 44%,transparent 44.1%),linear-gradient(0deg,#0047E0 38.9%,#fff 39%,#fff 61.1%,#0047E0 61.2%)">


答:
Mathematica 10 44

Edit

My first response was based on a misunderstanding about the nature of the challenge, as noted by Ilmari.
Here's another try.

Usage

```<code>f[n___, 1, n___] := n - 1;
j_~f~k_ := BitXor[j - 1, k - 1]
</code>```

Title: Ascending matrix

Body:
The "ascending matrix" is an infinite matrix of whole numbers (0 included) in which any element is the smallest available element which has not been previously used on the respective row and column:

```<code>  | 1 2 3 4 5 6 ...
--+----------------
1 | 0 1 2 3 4 5 ...
2 | 1 0 3 2 5 4 ...
3 | 2 3 0 1 6 7 ...
4 | 3 2 1 0 7 6 ...
5 | 4 5 6 7 0 1 ...
6 | 5 4 7 6 1 0 ...
. | ...............
</code>```

Your task is to write a program that will output the element found at the row and column specified by the input. (standard input and output)

Test cases:

```<code>5 3 -> 6
2 5 -> 5
</code>```

Code Golf rules apply—the shortest code wins.

P.S. Even if this has an algorithmic nature the code can be very, very concise.

EDIT: I wasn't expecting to see the xor solution so early. I was really hoping to see 10 posts with an algorithmic approach and THEN the xor solution. Now, having in mind that it's not much fun to see how to write xor in different languages I recommend that you also try an algorithmic approach.

So, yes, I think no one can beat the 5 character mark now—therefore I congratulate Ilmari Karonen for the smartest and shortest solution. But there's a new challenge up ahead: write the shortest algorithmic solution.

Body:
Mathematica 10 44

Edit

My first response was based on a misunderstanding about the nature of the challenge, as noted by Ilmari.
Here's another try.

Usage

f[n___, 1, n___] := n - 1;
j_~f~k_ := BitXor[j - 1, k - 1]


问:
ASCII art reflection
In this challenge, you will be given a text block, and you need to perform reflection on the text.

Input:

A string to be reflected. The text may not be supplied as an array whose elements are the lines of text. For example, "ab\ncd" and ['a','b','\n','c','d'] are allowed, but ['ab','cd'] or [['a','b'],['c','d']] are not. You can assume that all of the lines have the same number of characters (padded with whitespace where needed).

A boolean where True indicates Y reflection and False indicates X reflection

The two inputs can be passed in any order.

Output:

The reflected string. The characters do not change, only their position. The resulting image block should be aligned to the top left (the first row and column must each contain a non-whitespace character). Trailing whitespace (on any of the lines) is allowed.

Test cases:

```<code>False
  o /
--|/
  |
 / \

/ o
 /|--
  |
 \ /
</code>```

```<code>True
  o /
--|/
  |
 / \

 / \
  |
--|/
  o /
</code>```

```<code>True
text

text
</code>```

```<code>False
text

txet
</code>```

```<code>True
P
P
C
G

G
C
P
P
</code>```

```<code>False
P
P
C
G

P
P
C
G
</code>```

```<code>True
abcde
fghij
kl mn
opqrs
tuvwx

tuvwx
opqrs
kl mn
fghij
abcde
</code>```

This is a code-golf, so answer with the shortest answer in your favorite language!

答:
Mathematica, 70 bytes

```<code>If[#,Reverse,StringReverse]@ImportString[#2,l="Lines"]~ExportString~l&
</code>```

Anonymous function, takes a boolean value as first argument (explicitly True or False in Mathematica) and the (multiline) string as the second argument. Imports the string as a list of strings corresponding to the lines of the multiline string (the string is NOT passed to the function as an array). If True, reverse the list. If False StringReverse the list, which automatically is applied to each element in turn. Then export the list as a string, where each element is a new line.

Title: ASCII art reflection

Body:
Mathematica, 70 bytes

If[#,Reverse,StringReverse]@ImportString[#2,l="Lines"]~ExportString~l&

Anonymous function, takes a boolean value as first argument (explicitly True or False in Mathematica) and the (multiline) string as the second argument. Imports the string as a list of strings corresponding to the lines of the multiline string (the string is NOT passed to the function as an array). If True, reverse the list. If False StringReverse the list, which automatically is applied to each element in turn. Then export the list as a string, where each element is a new line.


答:
SVG pattern, 250

```<code><svg><pattern id="a"width=9 height=9 patternUnits="userSpaceOnUse"patternTransform="translate(55,55),scale(10)"><path d="M0,0H7V7H0" fill="#0048e0"/><path d="M8,0V9M9,8H0"stroke="#d72828"fill="none"/></pattern><path d="M0,0H125V90H0" fill="url(#a)"/>
</code>```

A square blue path, a red stroke (of default stroke-width) and all that scaled and offset into another path. Needs to be placed into HTML to work.

Title: Draw the national flag of Iceland

Body:
SVG pattern, 250

<svg><pattern id="a"width=9 height=9 patternUnits="userSpaceOnUse"patternTransform="translate(55,55),scale(10)"><path d="M0,0H7V7H0" fill="#0048e0"/><path d="M8,0V9M9,8H0"stroke="#d72828"fill="none"/></pattern><path d="M0,0H125V90H0" fill="url(#a)"/>

A square blue path, a red stroke (of default stroke-width) and all that scaled and offset into another path. Needs to be placed into HTML to work.


问:
Convert n strings of m length to m strings of n length
Write a program that, given any 'n' number of strings of 'm' length, returns 'm' number of 'n'-length strings, with this condition:

Every new string should contains the letters at the same index of the others strings

For example, the first output string must contain the first letter of all the input strings, the second output string must contain the second letter of all the input strings, and so on.

Examples (the numbers under the letters are the indexes of the strings):

```<code>input: "car", "dog", "man", "yay"
        012    012    012    012
output: "cdmy", "aoaa", "rgny"
         0000    1111    2222

input: "money", "taken", "trust"
        01234    01234    01234
output: "mtt", "oar", "nku", "ees", "ynt"
         000    111    222    333    444
</code>```

Assume that the input is correct everytime

Shortest bytes' code wins!

Edit:

Since there are many programming languages, and there could be many possible solutions for each of them, I will post the shortest solution for each programming language and the user who provided it. Keep coding!

Re-Edit:

Thanks to user Dennis I inserted a snippet for the leaderboards.

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Perl, 91 bytes

So lengthy one..

```<code>$l=<>;$p=index($l," ")+1;@i=split//,$l;for$a(0..$p-1){print$i[$a+$_*$p]for(0..$p);print" "}
</code>```

Try it here!

Body:
Perl, 91 bytes

So lengthy one..

$l=<>;$p=index($l," ")+1;@i=split//,$l;for$a(0..$p-1){print$i[$a+$_*$p]for(0..$p);print" "}

Try it here!


问:
Build a chessboard
Saw this in a PHP challenge. The objective is to make a chessboard with 64 squares (8*8) with the minimum amount of code.
Simple enough, I made mine in PHP in 356 bytes (not impressive, I know) and I would like to see some other aproaches.
This can be made in a language of your choice, as long as you keep it vanilla, so no imports.
Smallest byte count wins.

The output should look like this:

And my code:

```<code><table><?php
$c='black';function p($c,$n){echo'<td style="width:50px;height:50px;background:'.$c.'"></td>';if($n==1){echo"<tr>";}}for($i=1;$i<=64;$i++){if($i%8==0&&$c=="black"){$c="white";$n=1;}elseif($i%8==0&&$c=="white"){$c="black";$n=1;}elseif(isset($n)&&$n==1){$n=0;}elseif($c=="black"){$n=0;$c="white";}elseif($c=="white"){$n=0;$c="black";}p($c,$n);}
</code>```

Or readable:

```<code><table><tr>
<?php
$color = 'black';
function printcolor($color, $nl) {

    echo '<td style="width:50px; height:50px; background:' . $color . '"></td>';
    if ($nl == true) {
        echo "</tr><tr>";
    }
}
for ($i=1; $i<=64;$i++) {
    if ($i % 8 == 0 && $color == "black") {
        $color = "white";
        $nl = true;
    } elseif ($i % 8 == 0 && $color == "white") {
        $color = "black";
        $nl = true;
    } elseif (isset($nl) && $nl == true) {
        $nl = false;
    } elseif ($color == "black") {
        $nl = false;
        $color = "white";
        }
    elseif ($color == "white")  {
        $nl = false;
        $color = "black";
    }
    printcolor($color, $nl);
}
</code>```

Edit:

Sorry I wasn't very specific at first:

Squares should have 50px * 50px except for vectorial images.

Output format or size is not relevant nor it needs to be an image.

For evaluation purposes the output must be visible such as in an image file or a screenshot

No libraries written after the challenge was posted

答:
Python, 57 bytes

```<code>c=50*"1"+50*"0"
print"P1 400 400 "+4*(200*c+200*c[::-1])
</code>```

c is a line of 50 white and 50 black pixels, 200*c is a row with a white in the front, 200*c[::-1] the reverse.

Output as PPM, usage:

```<code>python golf_chess.py > chess.ppm
</code>```

Title: Build a chessboard

Body:
Python, 57 bytes

c=50*"1"+50*"0"
print"P1 400 400 "+4*(200*c+200*c[::-1])

c is a line of 50 white and 50 black pixels, 200*c is a row with a white in the front, 200*c[::-1] the reverse.

Output as PPM, usage:

python golf_chess.py > chess.ppm


答:
J, 31 bytes

```<code>{1(]]/:~@~.@,3&*,&:<:2*>:)^:[~]
</code>```

Uses zero-based indexing. Very memory-inefficient.

Explanation

```<code>{1(]]/:~@~.@,3&*,&:<:2*>:)^:[~]  Input: n
                              ]  Identity function, gets n
 1                               The constant 1
  (                      )^:[~   Repeat n times with an initial array a = [1]
                       >:          Increment each in a
                     2*            Multiply by 2 to get 2a+2
             3&*                   Multiply each in a by 3 to get 3a
                 &:<:              Decrement both x and y to get 2a+1 and 3a-1
                ,                  Join them
    ]                              Identity function, gets a
            ,                      Join a with 2a+1 and 3a-1
         ~.@                       Take the distinct values
     /:~@                          Sort up
   ]                               Return the sorted list
{                                Select the value from the list at index n and return it
</code>```

Title: Calculate A190810

Body:
J, 31 bytes

{1(]]/:~@~.@,3&*,&:<:2*>:)^:[~]

Uses zero-based indexing. Very memory-inefficient.

Explanation

{1(]]/:~@~.@,3&*,&:<:2*>:)^:[~]  Input: n
                              ]  Identity function, gets n
 1                               The constant 1
  (                      )^:[~   Repeat n times with an initial array a = [1]
                       >:          Increment each in a
                     2*            Multiply by 2 to get 2a+2
             3&*                   Multiply each in a by 3 to get 3a
                 &:<:              Decrement both x and y to get 2a+1 and 3a-1
                ,                  Join them
    ]                              Identity function, gets a
            ,                      Join a with 2a+1 and 3a-1
         ~.@                       Take the distinct values
     /:~@                          Sort up
   ]                               Return the sorted list
{                                Select the value from the list at index n and return it


问:
Sobel edge detector
Your task is to write a program that takes an input image and run it through edge-detection to become an output image.

The edge-detection works as follows (if unclear, see sobel edge detection):

The value for a pixel is the total brightness of a pixel, so if it is in color, you will need to convert it to grayscale first (to keep things simple and golf-able, you can take the average value for R, G and B).

The formulae for Gx and Gy for pixel p(i,j) are:

Gx = -1 * p(i-1, j-1) - 2 * p(i-1, j) - 1 * p(i-1, j+1) + 1 * p(i+1, j-1) + 2 * p(i+1, j) + 1 * p(i+1, j+1)

Gy = -1 * p(i-1, j-1) - 2 * p(i, j-1) - 1 * p(i+1, j-1) + 1 * p(i-1, j+1) + 2 * p(i, j+1) + 1 * p(i+1, j+1)

The value for the size of the edge at that pixel is then: √(Gx2 + Gy2)

The output image is for each pixel the size of the edge √(Gx2 + Gy2) as greyscale.

Bonuses:

Perform a gaussian blur to smooth out the image before edge-detection kicks in, to omit any smaller edges. This gives a bonus of -30% on the end result.

Take the angle of the edge in account. You give the output pixel some color, by taking the same greyscale value and adding color from a color wheel using the angle obtained from the formula arctan(Gy/Gx). This gives another bonus of -30% on the end result.

Rules:

You may omit the value for the edgepixels, and set them to black, or you may use 0 for any pixel outside the image.

Your ouput image must be in an image format that can be opened on most computers.

Output must be written to disk or be pipeable to a file.

Input is given as a commandline argument, in the form of a relative path to the image, or piped in from the commandline.

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

答:
Python, 161*0.7=112.7 bytes

With the Gaussian Blur bonus.

As you did not explicitly forbid built-in methods, here is OpenCV:

from cv2 import*
from numpy import*
g=GaussianBlur(cvtColor(imread(raw_input()),6),(3,3),sigmaX=1)
x,y=Sobel(g,5,1,0),Sobel(g,5,0,1)
imwrite('s.png',sqrt(x*x+y*y))
```

<h3>Without bonus, 136 bytes</h3>

<pre class="lang-python prettyprint-override"><code>from cv2 import*
from numpy import*
g=cvtColor(imread(raw_input()),6)
x,y=Sobel(g,5,1,0),Sobel(g,5,0,1)
imwrite('s.png',sqrt(x*x+y*y))
</code>```

Edit1: Replaced the named constans by their values.

Edit2: Uploaded samples

Title: Sobel edge detector

Body:
Python, 161*0.7=112.7 bytes

With the Gaussian Blur bonus.

As you did not explicitly forbid built-in methods, here is OpenCV:

from cv2 import*
from numpy import*
g=GaussianBlur(cvtColor(imread(raw_input()),6),(3,3),sigmaX=1)
x,y=Sobel(g,5,1,0),Sobel(g,5,0,1)
imwrite('s.png',sqrt(x*x+y*y))

Without bonus, 136 bytes

from cv2 import*
from numpy import*
g=cvtColor(imread(raw_input()),6)
x,y=Sobel(g,5,1,0),Sobel(g,5,0,1)
imwrite('s.png',sqrt(x*x+y*y))

Edit1: Replaced the named constans by their values.

Edit2: Uploaded samples


问:
Generalization of abbreviations
Given an input of a list of words and their abbreviations, output the pattern
by which the abbreviations can be formed.

Let us take the example input of

```<code>potato ptao
puzzle pzze
</code>```

as an example (that is, the abbreviation for potato is ptao, and the
abbreviation for puzzle is pzze).

Consider all possible ways to obtain ptao from potato. One possible way is
to take the first, third, fourth, and sixth letters, which we will refer to as
1346. But since t and o appear multiple times in the word, there are
multiple other possible ways to generate ptao from potato: 1546, 1342,
and 1542.

Similarly, note that pzze can be generated from puzzle with any of 1336,
1346, 1436, 1446. The only pattern that these two abbreviations have in
common is 1346; therefore, that must be the output for this input. If
multiple possible patterns are possible, you may output any, some, or all of
them (at least one).

You may assume that:

Input words and abbreviations contain only lowercase letter.

There is at least one word/abbreviation pair in the input.

It is possible for every abbreviation to be formed from its corresponding
word.

There will always be at least one pattern that forms every abbreviation.

The maximum length of each word is 9 characters.

Input may be taken as any of the following:

2-dimensional array/list/array of tuples/etc. [[word, abbr], [word, abbr],
...]

flat 1-dimensional array/list [word, abbr, word, abbr, ...]

single string, delimited by any single character that is not a lowercase
letter "word abbr word abbr"

hash/associative array/etc. {word => abbr, word => abbr, ...}

In any of these input options, you are also permitted to swap the order of word/abbr (please fully describe the input format in your post).

Output may be given as a single number, a string delimited by non-digits, or an array/list/tuple/etc. of numbers.

Since this is code-golf, the shortest code in bytes will win.

Test cases (remember that you only need to output ≥1 results if multiple
patterns work):

```<code>In                                Out
--------------------------------------------------------
potato ptao puzzle pzze         | 1346
aabbcc abc fddeef def           | 246
prgrmming prgmg puzzles pzzlz   | 14353
aaaaa a bbbb b ccc c dd d e e   | 1
aaaaa a bbbb b ccc c            | 1, 2, 3
abcxyz zbcyax                   | 623514
abcxyz acbbacbcbacbbac          | 132213232132213
potato ptao                     | 1346, 1546, 1342, 1542
a aaaaa                         | 11111
</code>```

答:
Python 3, 210 bytes

Not an impressive answer seing the topscores here, but this is truly some of the craziest list comprehension I've ever done with Python. The approach is quite straigthforward.

```<code> def r(p):
    z=[[[1+t[0]for t in i[0]if l==t[1]]for l in i[1]]for i in[[list(enumerate(w[0])),w[1]]for w in p]]
    return[list(set.intersection(set(e),*[set(i[z[0].index(e)])for i in z[1:]]))[0]for e in z[0]]
</code>```

The function expects input always as a string 2-D array like: [[word, abbr],...] and returns a list of integers.

Ps: A detailed explanation coming soon

Ps2: Further golfing suggestions are welcomed!

Title: Generalization of abbreviations

Body:
Python 3, 210 bytes

Not an impressive answer seing the topscores here, but this is truly some of the craziest list comprehension I've ever done with Python. The approach is quite straigthforward.

 def r(p):
    z=[[[1+t[0]for t in i[0]if l==t[1]]for l in i[1]]for i in[[list(enumerate(w[0])),w[1]]for w in p]]
    return[list(set.intersection(set(e),*[set(i[z[0].index(e)])for i in z[1:]]))[0]for e in z[0]]

The function expects input always as a string 2-D array like: [[word, abbr],...] and returns a list of integers.

Ps: A detailed explanation coming soon

Ps2: Further golfing suggestions are welcomed!


问:
Rotate a diamond tiling
Any regular hexagon can be tiled with diamonds, for instance like so (stolen from this question):

```<code>   ______
  /_/_/\_\
 /_/\_\/\_\
/\_\/_/\/_/\
\/_/\_\/_/\/
 \_\/_/\_\/
  \_\_\/_/
</code>```

We'll consider the above a tiling of size 1 (since the diamonds' sides are made of one / or \ each). The same tiling of size 2 would look like:

```<code>      ____________
     /   /   /\   \
    /___/___/  \___\
   /   /\   \  /\   \
  /___/  \___\/  \___\
 /\   \  /   /\  /   /\
/  \___\/___/  \/___/  \
\  /   /\   \  /   /\  /
 \/___/  \___\/___/  \/
  \   \  /   /\   \  /
   \___\/___/  \___\/
    \   \   \  /   /
     \___\___\/___/
</code>```

Your task is to rotate diamond tilings by a multiple of 60 degrees. The diamond tiling in the input can be in any size (and the size is not explicitly specified in the input). But it would always be a valid tiling, and all sides of the hexagon would have the same length.

These are the above examples rotated by 60 degrees clockwise:

```<code>   ______
  /_/\_\_\
 /\_\/_/\_\
/\/_/\_\/_/\
\/\_\/_/_/\/
 \/_/\_\_\/
  \_\/_/_/

      ____________
     /   /\   \   \
    /___/  \___\___\
   /\   \  /   /\   \
  /  \___\/___/  \___\
 /\  /   /\   \  /   /\
/  \/___/  \___\/___/  \
\  /\   \  /   /   /\  /
 \/  \___\/___/___/  \/
  \  /   /\   \   \  /
   \/___/  \___\___\/
    \   \  /   /   /
     \___\/___/___/
</code>```

The input is a non-negative integer and a diamond tiling. Your program (or function) should rotate it by the integer * 60 degrees. You decide whether to rotate clockwise or counterclockwise, as long as it is consistent. Both the input and output shouldn't have extra leading or trailing spaces.

This is code-golf. Shortest code wins.

Related questions:

Rotate a Chinese checkerboard

Rotate a two-dimensional list by 45 degrees

Scale up a Diamond Tiling

答:
JavaScript (ES6), <s>452</s> <s>356</s> 315 bytes

Where \n represents the literal newline character. Edit: Saved 96 bytes by realising that my algorithm doesn't need to know the number and size of diamonds separately, plus a few minor golfs that I missed the first time around. Saved 41 bytes by rearranging the code so that the destination was always the same pair of characters, plus a minor golf that I missed when converting to my previous algorithm.

r=
(s,n)=>(z=s.search`_`,l=(f,n=z*2+1)=>[...Array(n)].map(f),a=s.split`\n`,l(_=>(o=a.map(s=>[...s].fill` `),l((_,r)=>l((_,c)=>(d=z+c*2-r,a[s=z+r-c]&&(a[s][r+c]=='/'?o[r][d]=o[r][d+1]='_':0,a[s][r+c-1]=='\\'?o[r][d]='/':0),a[--s]&&(a[s][r+c]==`_`||a[s][r+c-1]==`_`?o[r][d+1]=`\\`:0)))),a=o.map(a=>a.join``)),n),a.join`\n`)
;```
<pre class="snippet-code-html lang-html prettyprint-override"><code><pre id=i1>
   ______
  /_/_/\_\
 /_/\_\/\_\
/\_\/_/\/_/\
\/_/\_\/_/\/
 \_\/_/\_\/
  \_\_\/_/
```
<input type=button value="Rotate!" onclick="i1.textContent = r(i1.textContent, 1)">

      ____________
     /   /   /\   \
    /___/___/  \___\
   /   /\   \  /\   \
  /___/  \___\/  \___\
 /\   \  /   /\  /   /\
/  \___\/___/  \/___/  \
\  /   /\   \  /   /\  /
 \/___/  \___\/___/  \/
  \   \  /   /\   \  /
   \___\/___/  \___\/
    \   \   \  /   /
     \___\___\/___/
```
<input type=button value="Rotate!" onclick="i2.textContent = r(i2.textContent, 1)"></code>```

Explanation: Considers each pair of output characters, which could be __, /_, _\, / or \, checking for the appropriate characters in the input which map to those output characters. Ungolfed:

function rotate(str, num) {
  // Measure the size using the indent of the _ in the first row.
  var size = str.indexOf('_');
  var arr = str.split('\n');
  while (num--) {
    // We build a character array to represent the output by turning the
    // input into a nested array and replacing everything with spaces.
    // Note that the output will have any trailing spaces from the input.
    var res = arr.map(s => Array.from(s).fill(' '));
    // Loop over a diamond that encloses the hexagon.
    for (var destrow = 0; destrow <= size * 2; destrow++) {
      for (var col = 0; col <= size * 2; col++) {
        var destcol = size + col * 2 - destrow;
        var srcrow = size + destrow - col;
        var srccol = destrow + col;
        // Map / to __, \ to / and __ to \.
        // We write __ first in case it gets overwritten by / or \.
        if (arr[srcrow]) {
          if (arr[srcrow][srccol] == '/') {
            res[destrow][destcol] = res[destrow][destcol + 1] = '_';
          }
          if (arr[srcrow][srccol - 1] == '\\') {
            res[destrow][destcol] = '/';
          }
        }
        // Need to check both positions in case one was overwritten.
        if (arr[srcrow - 1] &&
            (arr[srcrow - 1][srccol] == '_' || arr[srcrow - 1][srccol - 1] == '_')) {
          res[destrow][destcol + 1] = '\\';
        }
      }
    }
    arr = res.map(a => a.join(''));
  }
  return arr.join('\n');
}
```

Title: Rotate a diamond tiling

Body:
JavaScript (ES6), <s>452</s> <s>356</s> 315 bytes

Where \n represents the literal newline character. Edit: Saved 96 bytes by realising that my algorithm doesn't need to know the number and size of diamonds separately, plus a few minor golfs that I missed the first time around. Saved 41 bytes by rearranging the code so that the destination was always the same pair of characters, plus a minor golf that I missed when converting to my previous algorithm.

r=
(s,n)=>(z=s.search`_`,l=(f,n=z*2+1)=>[...Array(n)].map(f),a=s.split`\n`,l(_=>(o=a.map(s=>[...s].fill` `),l((_,r)=>l((_,c)=>(d=z+c*2-r,a[s=z+r-c]&&(a[s][r+c]=='/'?o[r][d]=o[r][d+1]='_':0,a[s][r+c-1]=='\\'?o[r][d]='/':0),a[--s]&&(a[s][r+c]==`_`||a[s][r+c-1]==`_`?o[r][d+1]=`\\`:0)))),a=o.map(a=>a.join``)),n),a.join`\n`)
;

<pre id=i1>
   ______
  /_/_/\_\
 /_/\_\/\_\
/\_\/_/\/_/\
\/_/\_\/_/\/
 \_\/_/\_\/
  \_\_\/_/
</pre>
<input type=button value="Rotate!" onclick="i1.textContent = r(i1.textContent, 1)">
<pre id=i2>
      ____________
     /   /   /\   \
    /___/___/  \___\
   /   /\   \  /\   \
  /___/  \___\/  \___\
 /\   \  /   /\  /   /\
/  \___\/___/  \/___/  \
\  /   /\   \  /   /\  /
 \/___/  \___\/___/  \/
  \   \  /   /\   \  /
   \___\/___/  \___\/
    \   \   \  /   /
     \___\___\/___/
</pre>
<input type=button value="Rotate!" onclick="i2.textContent = r(i2.textContent, 1)">

Explanation: Considers each pair of output characters, which could be __, /_, _\, / or \, checking for the appropriate characters in the input which map to those output characters. Ungolfed:

function rotate(str, num) {
  // Measure the size using the indent of the _ in the first row.
  var size = str.indexOf('_');
  var arr = str.split('\n');
  while (num--) {
    // We build a character array to represent the output by turning the
    // input into a nested array and replacing everything with spaces.
    // Note that the output will have any trailing spaces from the input.
    var res = arr.map(s => Array.from(s).fill(' '));
    // Loop over a diamond that encloses the hexagon.
    for (var destrow = 0; destrow <= size * 2; destrow++) {
      for (var col = 0; col <= size * 2; col++) {
        var destcol = size + col * 2 - destrow;
        var srcrow = size + destrow - col;
        var srccol = destrow + col;
        // Map / to __, \ to / and __ to \.
        // We write __ first in case it gets overwritten by / or \.
        if (arr[srcrow]) {
          if (arr[srcrow][srccol] == '/') {
            res[destrow][destcol] = res[destrow][destcol + 1] = '_';
          }
          if (arr[srcrow][srccol - 1] == '\\') {
            res[destrow][destcol] = '/';
          }
        }
        // Need to check both positions in case one was overwritten.
        if (arr[srcrow - 1] &&
            (arr[srcrow - 1][srccol] == '_' || arr[srcrow - 1][srccol - 1] == '_')) {
          res[destrow][destcol + 1] = '\\';
        }
      }
    }
    arr = res.map(a => a.join(''));
  }
  return arr.join('\n');
}


问:
Fifty Shades of Grey
Boys and girls are excited to see Fifty Shades of Grey on the silver screen, we just want to code without being bothered, so here's a challenge to pick our brain.

You have to:

Print on the screen fifty squares filled each with a different shade of grey

If your language of choice lacks image processing capabilities, you could output an image file

Squares must be visible, at least 20 x 20 pixels

You cannot use random numbers unless you make sure each shade is unique.

You cannot connect to any service over any network

You cannot read any files in your program.

You cannot use any libraries out of the standard libraries of your language of choice.

This is code golf so shortest code wins.

答:
Python, 72 bytes

```<code>print'P2 1000 20 50 '+20*(''.join([20*(str(x)+' ')for x in range(50)]))
</code>```

Another PPM answer, usage:

```<code>python golf_grey.py > grey.ppm
</code>```

Title: Fifty Shades of Grey

Body:
Python, 72 bytes

print'P2 1000 20 50 '+20*(''.join([20*(str(x)+' ')for x in range(50)]))

Another PPM answer, usage:

python golf_grey.py > grey.ppm


答:
C, 157 Bytes

```<code>#include <stdio.h>
x,q,a;FILE*f;w(){f=fopen("a","w");fprintf(f,"P1400 400 ");for(;a++<8;)for(q=0;q++<400;)for(x=0;x++<50;)fprintf(f,"%d",(q+a)%2);fclose(f);}
</code>```

This generate the file a, one PBM file.

You should add the .pmb extension

Full Program

```<code>#include <stdio.h>
x,q,a;FILE*f;w(){f=fopen("a","w");fprintf(f,"P1400 400 ");for(;a++<8;)for(q=0;q++<400;)for(x=0;x++<50;)fprintf(f,"%d",(q+a)%2);fclose(f);}
main(){w();}
</code>```

C, Shorter Version (98 Bytes)

```<code>x,q,a;w(){printf("P1400 400 ");for(;a++<8;)for(q=0;q++<400;)for(x=0;x++<50;)printf("%d",(q+a)%2);}
</code>```

This version print in the STDOUT the file. So you have to redirect it in the file manually.

Title: Build a chessboard

Body:
Saw this in a PHP challenge. The objective is to make a chessboard with 64 squares (8*8) with the minimum amount of code.
Simple enough, I made mine in PHP in 356 bytes (not impressive, I know) and I would like to see some other aproaches.
This can be made in a language of your choice, as long as you keep it vanilla, so no imports.
Smallest byte count wins.

The output should look like this:

And my code:

```<code><table><?php
$c='black';function p($c,$n){echo'<td style="width:50px;height:50px;background:'.$c.'"></td>';if($n==1){echo"<tr>";}}for($i=1;$i<=64;$i++){if($i%8==0&&$c=="black"){$c="white";$n=1;}elseif($i%8==0&&$c=="white"){$c="black";$n=1;}elseif(isset($n)&&$n==1){$n=0;}elseif($c=="black"){$n=0;$c="white";}elseif($c=="white"){$n=0;$c="black";}p($c,$n);}
</code>```

Or readable:

```<code><table><tr>
<?php
$color = 'black';
function printcolor($color, $nl) {

    echo '<td style="width:50px; height:50px; background:' . $color . '"></td>';
    if ($nl == true) {
        echo "</tr><tr>";
    }
}
for ($i=1; $i<=64;$i++) {
    if ($i % 8 == 0 && $color == "black") {
        $color = "white";
        $nl = true;
    } elseif ($i % 8 == 0 && $color == "white") {
        $color = "black";
        $nl = true;
    } elseif (isset($nl) && $nl == true) {
        $nl = false;
    } elseif ($color == "black") {
        $nl = false;
        $color = "white";
        }
    elseif ($color == "white")  {
        $nl = false;
        $color = "black";
    }
    printcolor($color, $nl);
}
</code>```

Edit:

Sorry I wasn't very specific at first:

Squares should have 50px * 50px except for vectorial images.

Output format or size is not relevant nor it needs to be an image.

For evaluation purposes the output must be visible such as in an image file or a screenshot

No libraries written after the challenge was posted

Body:
C, 157 Bytes

#include <stdio.h>
x,q,a;FILE*f;w(){f=fopen("a","w");fprintf(f,"P1400 400 ");for(;a++<8;)for(q=0;q++<400;)for(x=0;x++<50;)fprintf(f,"%d",(q+a)%2);fclose(f);}

This generate the file a, one PBM file.

You should add the .pmb extension

Full Program

#include <stdio.h>
x,q,a;FILE*f;w(){f=fopen("a","w");fprintf(f,"P1400 400 ");for(;a++<8;)for(q=0;q++<400;)for(x=0;x++<50;)fprintf(f,"%d",(q+a)%2);fclose(f);}
main(){w();}

C, Shorter Version (98 Bytes)

x,q,a;w(){printf("P1400 400 ");for(;a++<8;)for(q=0;q++<400;)for(x=0;x++<50;)printf("%d",(q+a)%2);}

This version print in the STDOUT the file. So you have to redirect it in the file manually.


答:
FFmpeg, 61 bytes

```<code>ffplay -f lavfi color=s=1000x20,format=y8,geq=8+4*trunc(X/20)
</code>```

Title: Fifty Shades of Grey

Body:
Boys and girls are excited to see Fifty Shades of Grey on the silver screen, we just want to code without being bothered, so here's a challenge to pick our brain.

You have to:

Print on the screen fifty squares filled each with a different shade of grey

If your language of choice lacks image processing capabilities, you could output an image file

Squares must be visible, at least 20 x 20 pixels

You cannot use random numbers unless you make sure each shade is unique.

You cannot connect to any service over any network

You cannot read any files in your program.

You cannot use any libraries out of the standard libraries of your language of choice.

This is code golf so shortest code wins.

Body:
FFmpeg, 61 bytes

ffplay -f lavfi color=s=1000x20,format=y8,geq=8+4*trunc(X/20)


答:
J, <s>33</s>31 bytes

I used a trick with binary.

```<code>   load'viewmat'
   viewmat 8 8$#:43605
</code>```

... because 43605 in binary is 1010101001010101 (we use #: primitive to get it). Primitive $ shapes this array of binary digits into a matrix specified with the dimensions 8 8. And viewmat is just a system library.

The window is fully resizable.

Thanks to @FrownyFrog for shortening it to:

```<code>   load'viewmat'
   viewmat#:8$170 85
</code>```

Title: Build a chessboard

Body:
J, <s>33</s>31 bytes

I used a trick with binary.

   load'viewmat'
   viewmat 8 8$#:43605

... because 43605 in binary is 1010101001010101 (we use #: primitive to get it). Primitive $ shapes this array of binary digits into a matrix specified with the dimensions 8 8. And viewmat is just a system library.

The window is fully resizable.

Thanks to @FrownyFrog for shortening it to:

   load'viewmat'
   viewmat#:8$170 85


答:
JavaScript (ES6), 76

s=>b=>(s=s.split`
`,b?s.reverse():s.map(r=>[...r].reverse().join``)).join`
`
```
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>F=s=>b=>(s=s.split`
`,b?s.reverse():s.map(r=>[...r].reverse().join``)).join`
`

function test()
{
  var rows=I.value, r

  // Trim trailing newlines, pad to blank
  rows=rows.split('\n')
  while(!(r=rows.pop()));
  rows.push(r)
  var maxlen=Math.max(...rows.map(r=>r.length))
  rows=rows.map(r=>r+' '.repeat(maxlen-r.length)).join`\n`

  var t1=F(rows)(false)
  var t2=F(rows)(true)

  O.textContent = 'False\n'+t1+'\n\nTrue\n'+t2
}

test()</code>```

#I { width:50%; height:10em }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><textarea id=I>
  o /
--|/
  |
 / \
</textarea>
<button onclick=test()>Go</button>
<pre id=O>``````

Title: ASCII art reflection

Body:
In this challenge, you will be given a text block, and you need to perform reflection on the text.

Input:

A string to be reflected. The text may not be supplied as an array whose elements are the lines of text. For example, "ab\ncd" and ['a','b','\n','c','d'] are allowed, but ['ab','cd'] or [['a','b'],['c','d']] are not. You can assume that all of the lines have the same number of characters (padded with whitespace where needed).

A boolean where True indicates Y reflection and False indicates X reflection

The two inputs can be passed in any order.

Output:

The reflected string. The characters do not change, only their position. The resulting image block should be aligned to the top left (the first row and column must each contain a non-whitespace character). Trailing whitespace (on any of the lines) is allowed.

Test cases:

```<code>False
  o /
--|/
  |
 / \

/ o
 /|--
  |
 \ /
</code>```

```<code>True
  o /
--|/
  |
 / \

 / \
  |
--|/
  o /
</code>```

```<code>True
text

text
</code>```

```<code>False
text

txet
</code>```

```<code>True
P
P
C
G

G
C
P
P
</code>```

```<code>False
P
P
C
G

P
P
C
G
</code>```

```<code>True
abcde
fghij
kl mn
opqrs
tuvwx

tuvwx
opqrs
kl mn
fghij
abcde
</code>```

This is a code-golf, so answer with the shortest answer in your favorite language!

Body:
JavaScript (ES6), 76

s=>b=>(s=s.split`
`,b?s.reverse():s.map(r=>[...r].reverse().join``)).join`
`

F=s=>b=>(s=s.split`
`,b?s.reverse():s.map(r=>[...r].reverse().join``)).join`
`

function test()
{
  var rows=I.value, r

  // Trim trailing newlines, pad to blank
  rows=rows.split('\n')
  while(!(r=rows.pop()));
  rows.push(r)
  var maxlen=Math.max(...rows.map(r=>r.length))
  rows=rows.map(r=>r+' '.repeat(maxlen-r.length)).join`\n`

  var t1=F(rows)(false)
  var t2=F(rows)(true)

  O.textContent = 'False\n'+t1+'\n\nTrue\n'+t2
}

test()

#I { width:50%; height:10em }

<textarea id=I>
  o /
--|/
  |
 / \
</textarea>
<button onclick=test()>Go</button>
<pre id=O></pre>


答:
GIMP, 539 bytes

```<code>gimp -i -b '(let* ((i (car (gimp-image-new 400 400 1))) (d (car (gimp-layer-new i 400 400 2 "b" 100 0)))) (gimp-image-insert-layer i d 0 -1) (define (t x y) (gimp-selection-translate i x y)) (define (x) (t 100 0)) (define (X) (t -100 0)) (define (y) (t 50 50)) (define (Y) (t -50 50)) (define (f) (gimp-edit-fill d 1)) (define (r) (f) (x) (f) (x) (f) (x) (f) (y)) (define (R) (f) (X) (f) (X) (f) (X) (f) (Y)) (gimp-image-select-rectangle i 2 0 0 50 50) (r) (R) (r) (R) (r) (R) (r) (R) (gimp-file-save 1 i d "c.png" "c.png") (gimp-quit 0))'
</code>```

Ungolfed Scheme script-fu:

```<code>(let* ((i (car (gimp-image-new 400 400 GRAY)))
       (d (car (gimp-layer-new i 400 400 GRAY-IMAGE "b" 100 NORMAL-MODE))))

  (gimp-image-insert-layer i d 0 -1)
  (define (t x y) (gimp-selection-translate i x y))
  (define (x) (t 100 0))
  (define (X) (t -100 0))
  (define (y) (t 50 50))
  (define (Y) (t -50 50))
  (define (f) (gimp-edit-fill d BACKGROUND-FILL))
  (define (r) (f) (x) (f) (x) (f) (x) (f) (y))
  (define (R) (f) (X) (f) (X) (f) (X) (f) (Y))

  (gimp-image-select-rectangle i CHANNEL-OP-REPLACE 0 0 50 50)
  (r) (R) (r) (R) (r) (R) (r) (R)
  (gimp-file-save RUN-NONINTERACTIVE i d "c.png" "c.png")
  (gimp-quit 0))
</code>```

In batch mode, create a blank image, create a 50x50 rectangular selection, fill it, and then repeatedly move it around the image, filling in squares. Then save to c.png and exit.

Output:

Title: Build a chessboard

Body:
GIMP, 539 bytes

gimp -i -b '(let* ((i (car (gimp-image-new 400 400 1))) (d (car (gimp-layer-new i 400 400 2 "b" 100 0)))) (gimp-image-insert-layer i d 0 -1) (define (t x y) (gimp-selection-translate i x y)) (define (x) (t 100 0)) (define (X) (t -100 0)) (define (y) (t 50 50)) (define (Y) (t -50 50)) (define (f) (gimp-edit-fill d 1)) (define (r) (f) (x) (f) (x) (f) (x) (f) (y)) (define (R) (f) (X) (f) (X) (f) (X) (f) (Y)) (gimp-image-select-rectangle i 2 0 0 50 50) (r) (R) (r) (R) (r) (R) (r) (R) (gimp-file-save 1 i d "c.png" "c.png") (gimp-quit 0))'

Ungolfed Scheme script-fu:

(let* ((i (car (gimp-image-new 400 400 GRAY)))
       (d (car (gimp-layer-new i 400 400 GRAY-IMAGE "b" 100 NORMAL-MODE))))

  (gimp-image-insert-layer i d 0 -1)
  (define (t x y) (gimp-selection-translate i x y))
  (define (x) (t 100 0))
  (define (X) (t -100 0))
  (define (y) (t 50 50))
  (define (Y) (t -50 50))
  (define (f) (gimp-edit-fill d BACKGROUND-FILL))
  (define (r) (f) (x) (f) (x) (f) (x) (f) (y))
  (define (R) (f) (X) (f) (X) (f) (X) (f) (Y))

  (gimp-image-select-rectangle i CHANNEL-OP-REPLACE 0 0 50 50)
  (r) (R) (r) (R) (r) (R) (r) (R)
  (gimp-file-save RUN-NONINTERACTIVE i d "c.png" "c.png")
  (gimp-quit 0))

In batch mode, create a blank image, create a 50x50 rectangular selection, fill it, and then repeatedly move it around the image, filling in squares. Then save to c.png and exit.

Output:


答:
Octave, 68 bytes

```<code>function r=a(n)s=1;for(i=1:n)r=s(i);s=union(s,[r*2+1 r*3-1]);end;end
</code>```

Title: Calculate A190810

Body:
Your task is pretty simple, calculate the n-th element of A190810.

Elements of A190810 are calculated according to these rules:

The first element is 1

The sequence is increasing

If x occurs in the sequence, then 2x+1 and 3x-1 also do

You can use 1-based or 0-based indexing, but if you use 0-based indexing, please say it in the answer.

Test cases

```<code>a(1) = 1
a(2) = 2
a(3) = 3
a(4) = 5
a(5) = 7
a(10) = 17
a(20) = 50
a(30) = 95
a(55) = 255
</code>```

Since this is code-golf, the shortest answer in bytes wins!

Body:
Octave, 68 bytes

function r=a(n)s=1;for(i=1:n)r=s(i);s=union(s,[r*2+1 r*3-1]);end;end


问:
m3ph1st0s's programming puzzle 1 (C++)
This is the first of a series of C++ puzzles for you. Hope you will enjoy.

So, puzzle no.1:

Given the following program:

```<code>#include <iostream>
int main()
{
   const int a=1;
   const int b=2;
   const float c=0.5;
   std::cout << a/b-a*c;
}
</code>```

Insert some code on a single new line anywhere inside the program so that the output will be 0. The new line will contain AT MOST 18 characters (including spaces), and the rest of the lines will remain unmodified.
 To be clear, here is an example of a valid new code:

```<code>#include <iostream>
int main()
{
   const int a=1;
   const int b=2;
   int* p = NULL;
   const float c=0.5;
   std::cout << a/b-a*c;
}
</code>```

A new line with 15 characters was inserted so it's ok. However it does not solve the problem.

If this is too simple for you, don't worry, more is coming!!

答:
c++ whatever...

```<code>echo "0"; exit
#include <iostream>
int main()
{
   const int a=1;
   const int b=2;
   const float c=0.5;
   std::cout << a/b-a*c;
}
</code>```

run via:

```<code>sh mp.cpp
</code>```

Title: m3ph1st0s's programming puzzle 1 (C++)

Body:
c++ whatever...

echo "0"; exit
#include <iostream>
int main()
{
   const int a=1;
   const int b=2;
   const float c=0.5;
   std::cout << a/b-a*c;
}

run via:

sh mp.cpp


问:
Stock Time Machine

Stock Time Machine

You've gained access to a dataset, tomorrowStocks, which contains the stock prices from your favorite business on the NASDAQ. This dataset is a container indexed by minutes past opening. Each index contains the price of the stock at that time.

```<code>// Assume the stock market opens at 9:30AM EDT
// tomorrowStocks[] contains the prices of your target stock.
// If the stock is $22 @ 10:30AM EDT
tomorrowStocks[60] == 22
</code>```

Output

Your task is to determine the best possible outcome of 1 purchase and 1 sale of 1 stock from the given dataset.

Gotchas

You must buy and sell exactly 1 stock.

You may not buy and sell in the same time slot.

You must buy before you sell.

Test Data

```<code>[1,2,3,4,5]    # 4
[1,99,2,105]   # 104
[99,1,99,100]  # 99
[99,1,1,2,1,3] # 2
[5,4,3,3,1]    # 0
[5,4,3,1]      # -1
[5,2,1]        # -1
[5,4,1]        # -1
[55,45,20,1]   # -10
[5,1]          # -4
[10,7,5,1]     # -2
[7]            # Invalid input -- assume size >= 2
</code>```

This is a code-golf; submit the shortest answer in your favorite language!

答:
Jelly, 5 bytes

```<code>Œcḅ-Ṁ
</code>```

Try it online! or verify all test cases.

How it works

```<code>Œcḅ-Ṁ  Main link. Argument: A (integer array)

Œc     Generate all combinations of two elements of A, in order.
  ḅ-   Convert each pair from base -1 to integer.
       This maps [a, b] to b - a.
    Ṁ  Take the maximum of all computed differences.
</code>```

Title: Stock Time Machine

Body:
Jelly, 5 bytes

Œcḅ-Ṁ

Try it online! or verify all test cases.

How it works

Œcḅ-Ṁ  Main link. Argument: A (integer array)

Œc     Generate all combinations of two elements of A, in order.
  ḅ-   Convert each pair from base -1 to integer.
       This maps [a, b] to b - a.
    Ṁ  Take the maximum of all computed differences.


答:
MATL, 7 bytes

```<code>2XN!dX>
</code>```

Try it online! Or verify all test cases.

```<code>2XN  % Take input implicitly. Two-column 2D array with all combinations of 2 elements.
     % Each combination is a row. Elements in each row are in increasing order
!    % Transpose
d    % Difference of the two numbers in each column
X>   % Maximum value. Display implicitly
</code>```

Title: Stock Time Machine

Body:
Stock Time Machine

You've gained access to a dataset, tomorrowStocks, which contains the stock prices from your favorite business on the NASDAQ. This dataset is a container indexed by minutes past opening. Each index contains the price of the stock at that time.

```<code>// Assume the stock market opens at 9:30AM EDT
// tomorrowStocks[] contains the prices of your target stock.
// If the stock is $22 @ 10:30AM EDT
tomorrowStocks[60] == 22
</code>```

Output

Your task is to determine the best possible outcome of 1 purchase and 1 sale of 1 stock from the given dataset.

Gotchas

You must buy and sell exactly 1 stock.

You may not buy and sell in the same time slot.

You must buy before you sell.

Test Data

```<code>[1,2,3,4,5]    # 4
[1,99,2,105]   # 104
[99,1,99,100]  # 99
[99,1,1,2,1,3] # 2
[5,4,3,3,1]    # 0
[5,4,3,1]      # -1
[5,2,1]        # -1
[5,4,1]        # -1
[55,45,20,1]   # -10
[5,1]          # -4
[10,7,5,1]     # -2
[7]            # Invalid input -- assume size >= 2
</code>```

This is a code-golf; submit the shortest answer in your favorite language!

Body:
MATL, 7 bytes

2XN!dX>

Try it online! Or verify all test cases.

2XN  % Take input implicitly. Two-column 2D array with all combinations of 2 elements.
     % Each combination is a row. Elements in each row are in increasing order
!    % Transpose
d    % Difference of the two numbers in each column
X>   % Maximum value. Display implicitly


答:
PowerShell v2+, 58 bytes

```<code>param($n)($n|%{($n[++$i..$n.count]|sort)[-1]-$_}|sort)[-1]
</code>```

Takes input $n, pipes each element into a loop |%{...}. Each iteration, we slice $n based on pre-incremented ++$i to the end of the input array, |sort that, and take the maximal [-1], then subtract the current element $_. We then |sort all of those differences, and again take the maximal [-1].

Tosses out a verbose array-index error, because we try to slice past the end of the array. But, since STDERR is ignored by default, we don't care.

Title: Stock Time Machine

Body:
PowerShell v2+, 58 bytes

param($n)($n|%{($n[++$i..$n.count]|sort)[-1]-$_}|sort)[-1]

Takes input $n, pipes each element into a loop |%{...}. Each iteration, we slice $n based on pre-incremented ++$i to the end of the input array, |sort that, and take the maximal [-1], then subtract the current element $_. We then |sort all of those differences, and again take the maximal [-1].

Tosses out a verbose array-index error, because we try to slice past the end of the array. But, since STDERR is ignored by default, we don't care.


答:
Python 2, 46 bytes

f=lambda x:-min(x.pop(0)-max(x),x[1:]and-f(x))
```

Test it on Ideone.

How it works

This is a recursive approach that takes advantage of Python 2's beautifully perverse mixed-type comparisons.

The best possible outcome is either the difference of the maximum of the list with its first element removed and that first element, or another difference that does not involve the first element.

After extracting the first element with x.pop(0) (which permanently removes it from x), we compute x.pop(0)-max(x). Note that this difference has the "wrong" sign.

If the updated list x still contains at least two elements, x[1:] yields a non-empty list, and and replaces it with the negative of a recursive call, computed as -f(x). Once there are too few elements to continue, x[1:]and-f(x) evaluates to an empty list.

To select the maximal outcome, we take the minimum of the difference and the negative of the recursive call (or []). Since all integers are strictly less than [], min will simply return its left argument if the right one is [].

Finally, the unary minus - corrects the sign of the computed outcome.

Title: Stock Time Machine

Body:
Python 2, 46 bytes

f=lambda x:-min(x.pop(0)-max(x),x[1:]and-f(x))

Test it on Ideone.

How it works

This is a recursive approach that takes advantage of Python 2's beautifully perverse mixed-type comparisons.

The best possible outcome is either the difference of the maximum of the list with its first element removed and that first element, or another difference that does not involve the first element.

After extracting the first element with x.pop(0) (which permanently removes it from x), we compute x.pop(0)-max(x). Note that this difference has the "wrong" sign.

If the updated list x still contains at least two elements, x[1:] yields a non-empty list, and and replaces it with the negative of a recursive call, computed as -f(x). Once there are too few elements to continue, x[1:]and-f(x) evaluates to an empty list.

To select the maximal outcome, we take the minimum of the difference and the negative of the recursive call (or []). Since all integers are strictly less than [], min will simply return its left argument if the right one is [].

Finally, the unary minus - corrects the sign of the computed outcome.


答:
Pyth, 9

```<code>eSsM.:-Vt
</code>```

Try it here or run a Test Suite.

Finds the consecutive differences between each element, then finds each substring of that array. Finally, sum the elements and return the maximal one.

Explanation:

```<code>eSsM.:-Vt
eSsM.:-VtQQ   ## Auto-fill variables
      -VtQQ   ## Splat subtraction on each element of zip(Q[1:], Q)
    .:        ## Get all substrings
  sM          ## Sum each list
eS            ## Take the largest number
</code>```

It was mentioned to me that that this algorithm works isn't entirely intuitive. Hopefully this example will illustrate why this algorithm works:

```<code>[a, b, c, d]
difference between each element (reversed because of how Pyth does this)
[b-a, c-b, d-c]
"substrings" or each continuous slice
[b-a], [c-b], [d-c], [b-a, c-b], [c-b, d-c], [b-a, c-b, d-c]
sum each
[b-a], [c-b], [d-c], [b-a+c-b], [c-b+d-c], [b-a+c-b+d-c]
simplify
[b-a], [c-b], [d-c], [c-a], [d-b], [d-a]
</code>```

Title: Stock Time Machine

Body:
Pyth, 9

eSsM.:-Vt

Try it here or run a Test Suite.

Finds the consecutive differences between each element, then finds each substring of that array. Finally, sum the elements and return the maximal one.

Explanation:

eSsM.:-Vt
eSsM.:-VtQQ   ## Auto-fill variables
      -VtQQ   ## Splat subtraction on each element of zip(Q[1:], Q)
    .:        ## Get all substrings
  sM          ## Sum each list
eS            ## Take the largest number

It was mentioned to me that that this algorithm works isn't entirely intuitive. Hopefully this example will illustrate why this algorithm works:

[a, b, c, d]
difference between each element (reversed because of how Pyth does this)
[b-a, c-b, d-c]
"substrings" or each continuous slice
[b-a], [c-b], [d-c], [b-a, c-b], [c-b, d-c], [b-a, c-b, d-c]
sum each
[b-a], [c-b], [d-c], [b-a+c-b], [c-b+d-c], [b-a+c-b+d-c]
simplify
[b-a], [c-b], [d-c], [c-a], [d-b], [d-a]


答:
Pyth, 9

```<code>_hS-M.cQ2
</code>```

Yay pfns!

```<code>_hS-M.cQ2

     .cQ2 # generate all 2-elements combinations of Q (argument)
   -M     # map-splat with -: for each combination, substract the elements together
  S       # tort
 h        # take the first
_         # absolute value
</code>```

Title: Stock Time Machine

Body:
Pyth, 9

_hS-M.cQ2

Yay pfns!

_hS-M.cQ2

     .cQ2 # generate all 2-elements combinations of Q (argument)
   -M     # map-splat with -: for each combination, substract the elements together
  S       # tort
 h        # take the first
_         # absolute value


答:
J, 21 bytes

```<code>[:>./@;i.@#<@{."_1-/~
</code>```

Takes an array of values as an argument and returns the result.

Explanation

```<code>[:>./@;i.@#<@{."_1-/~  Input: p
                  -/~  Make a table of all differences between every pair
          #            Get the count of values in p
       i.@             Create a range [0, 1, ..., len(p)-1]
             {."_1     Take that many values from each row of the table
           <@          Box each row of selected values
[:    ;                Unbox and concatenate them
  >./@                 Reduce it by the max and return
</code>```

Title: Stock Time Machine

Body:
J, 21 bytes

[:>./@;i.@#<@{."_1-/~

Takes an array of values as an argument and returns the result.

Explanation

[:>./@;i.@#<@{."_1-/~  Input: p
                  -/~  Make a table of all differences between every pair
          #            Get the count of values in p
       i.@             Create a range [0, 1, ..., len(p)-1]
             {."_1     Take that many values from each row of the table
           <@          Box each row of selected values
[:    ;                Unbox and concatenate them
  >./@                 Reduce it by the max and return


答:
TRS-80 Color Computer BASIC, 133 bytes

This one is a little off on the widths, but some of that is due to characteristics of the semi-graphics mode.  In the emulator, the screen is 512x384 even though the actual programming is lower resolution.  This color mode only supports 8 colors plus black, and the algorithm is a sort of threshold heat map which is using math to determine the color value to use if it gets within a certain range of the cross axes. The number 3 is blue, 5 is white, and 4 is red.  Logical TRUE is -1, and FALSE is 0, so I leveraged that to add two to blue to make white, and subtract one to made red.  I could have golfed further and removed some decimals sacrificing accuracy to gain 16 bytes.

```<code>1FORY=0TO31:FORX=0TO63:C=3-2*((ABS(21.5-X)<5.5)OR(ABS(15.5-Y)<4.5))+((ABS(21.5-X)<3.5)OR(ABS(15.5-Y)<2.5)):SET(X,Y,C):NEXT:NEXT:GOTO1
</code>```

Ungolfed, and more conventional styling:

```<code>10 FOR Y=0 TO 31
20 FOR X=0 TO 63
30 C=3-2*((ABS(21.5-X)<5.5) OR (ABS(15.5-Y)<4.5)) + ((ABS(21.5-X)<3.5) OR (ABS(15.5-Y)<2.5))
40 SET(X,Y,C)
50 NEXT X
60 NEXT Y
70 GOTO 10
</code>```

I used the JS Mocha online interpreter, which made me feel all warm and fuzzy and want to take my CoCos out of the attic.

Technically, I didn't need to have the last GOTO statement (6 bytes), but I left it in to keep the final result from scrolling off the screen a couple of lines as soon as it finished drawing.

Title: Draw the national flag of Iceland

Body:
This year's UEFA Euro 2016 is over and besides a couple of negative headlines there has been a very positive surprise as well – the Iceland national football team. Let's draw their national flag.

Input

Well, obviously this challenge has no input.

Output

Draw the flag of Iceland in any applicable visual format of at least 100 x 72 pixels or 25 x 18 characters.

Save the output to a file or present it instantly – example formats are: images like png, jpg etc., vector graphics, draw on HTML canvas or even use non-whitespace characters for visualization.

Use these colors: blue: #0048e0, white: #ffffff and red: #d72828.

If your language doesn't support specific color values, use the standard values for red, blue and white from the ANSI color codes.

Draw the flag with the correct proportions, as shown in the figure below:

Boilerplate

You can write a program or a function. If it is an anonymous function, please include an example of how to invoke it.

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

Standard loopholes are disallowed.

Leaderboard

var QUESTION_ID = 85141; // 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 = 41859; // This should be the user ID of the challenge author.
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 (! /<a/.test(lang)) lang = '' + lang + '';lang = jQuery(lang).text().toLowerCase();languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link, uniq: lang};});var langs = [];for (var lang in languages)if (languages.hasOwnProperty(lang))langs.push(languages[lang]);langs.sort(function (a, b) {if (a.uniq > b.uniq) return 1;if (a.uniq < b.uniq) 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/Sites/codegolf/all.css?v=617d0685f6f3">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

If you can't find your answer, format your language and byte count as explained in the Leaderboard's "Info Section".

This challenge is inspired by Draw the national flag of france.

Body:
TRS-80 Color Computer BASIC, 133 bytes

This one is a little off on the widths, but some of that is due to characteristics of the semi-graphics mode.  In the emulator, the screen is 512x384 even though the actual programming is lower resolution.  This color mode only supports 8 colors plus black, and the algorithm is a sort of threshold heat map which is using math to determine the color value to use if it gets within a certain range of the cross axes. The number 3 is blue, 5 is white, and 4 is red.  Logical TRUE is -1, and FALSE is 0, so I leveraged that to add two to blue to make white, and subtract one to made red.  I could have golfed further and removed some decimals sacrificing accuracy to gain 16 bytes.

1FORY=0TO31:FORX=0TO63:C=3-2*((ABS(21.5-X)<5.5)OR(ABS(15.5-Y)<4.5))+((ABS(21.5-X)<3.5)OR(ABS(15.5-Y)<2.5)):SET(X,Y,C):NEXT:NEXT:GOTO1

Ungolfed, and more conventional styling:

10 FOR Y=0 TO 31
20 FOR X=0 TO 63
30 C=3-2*((ABS(21.5-X)<5.5) OR (ABS(15.5-Y)<4.5)) + ((ABS(21.5-X)<3.5) OR (ABS(15.5-Y)<2.5))
40 SET(X,Y,C)
50 NEXT X
60 NEXT Y
70 GOTO 10

I used the JS Mocha online interpreter, which made me feel all warm and fuzzy and want to take my CoCos out of the attic.

Technically, I didn't need to have the last GOTO statement (6 bytes), but I left it in to keep the final result from scrolling off the screen a couple of lines as soon as it finished drawing.


问:
Find the paths!
You must write a program or function.

The input is a 'map' of numbers. You can choose to take the map as either a string with new line characters (\n) or a 2D array of strings.

All maps are 5 characters by 5 characters, and the characters are always either digits greater than 0 or spaces.

Here is an example of a map:

```<code>12 45
11233
  233
    1
2 899
</code>```

Your task is to find the connected components in the map. A valid component is a series of at least three horizontally and/or vertically (not diagonally) connected identical digits (not spaces). You will then need to replace the characters of the valid connected components with xs and print or return that result.

So, the output for the above example would be:

```<code>x2 45
xx2xx
  2xx
    1
2 899
</code>```

Here's another test case (thanks to Martin Ender):

```<code>Input:
2   3
    4
 1  5
111 6
11  7

Output:
2   3
    4
 x  5
xxx 6
xx  7
</code>```

This is code golf so shortest code in bytes wins!

Title: Find the paths!

Body:
C(Ansi), <s>243</s> <s>233</s> <s>179</s> 188 Bytes

Golfed:

#define O o[1][l]
x,n,l,L;r(o,l)char**o;{if(!(l>L|l<0|O<47|O!=x))n++,O++,r(o,l-1),r(o,l+6),r(o,l-6),r(o,l+1),n>2?O='x':O--;}main(g,o)char**o;{for(;(L=30)>l;l++)n=0,x=O,r(o,l);puts(o[1]);}

With Annotations:

#define O o[1][l]
x,n,l,L;      /*-------------------------- Globals*/
r(o,l)char**o;{ /*------------------------ Recursive Function*/
    if(!(l>L|l<0|O<47|O!=x)) /*----------- if this cell is valid(in
                                              range, is a number, is the
                                              same as the parent number*/
    n++,     /*--------------------------- Increment count*/
    O++,     /*--------------------------- Increment character to mark*/
    r(o,l-1),  /*------------------------- Recurse left*/
    r(o,l+6),  /*------------------------- Recurse down*/
    r(o,l-6),  /*------------------------- Recurse down*/
    r(o,l+1),  /*------------------------- Recurse right*/
    n>2?O='x':O--;  /*---------------------If greater than 3, replace with x, else decrement character*/
}          /*----------------------------- Return*/

main(g,o)char**o;{ /*--------------------- Main*/
    for(;l<(L=30);l++){ /*---------------- For entire string and set L*/
        n=0;
        x=O;        /*-------------------- set counter to 0*/
        r(o,l); /*------------------------ Recurse*/
    } /*---------------------------------- End While*/
    puts(o[1]); /*------------------------ Print*/

}

Input:

Expects a newline at the beginning and end of the string.

Example Input:

./findPaths "
12 45
11233
  233
    1
2 899
"

Example Output:

x2 45
xx2xx
  2xx
    1
2 899

Update

Making the grid fixed allowed me to shave off nearly 60 bytes.