答:
PHP, <s>80</s> <s>79</s> 69 bytes

```<code><?for($r=1;++$i<count($a=$_GET[a]);)$r*=$a[$i-1][1]/$a[$i][0];echo$r;
</code>```

takes input from GET parameter a; prints result

initializes $r with 1, then loops from second to last tuple to multiply with first element of previous and divide through second element of current tuple.

Thanks to Jörg for reminding me of $_GET; that saved 7 bytes.

more elegant version, 88 bytes:

```<code><?=array_reduce($a=$_GET[a],function($r,$x){return$r*$x[1]/$x[0];},$a[0][0]/end($a)[1]);
</code>```

Title: Gear Train, Rotating

Body:
PHP, <s>80</s> <s>79</s> 69 bytes

<?for($r=1;++$i<count($a=$_GET[a]);)$r*=$a[$i-1][1]/$a[$i][0];echo$r;

takes input from GET parameter a; prints result

initializes $r with 1, then loops from second to last tuple to multiply with first element of previous and divide through second element of current tuple.

Thanks to Jörg for reminding me of $_GET; that saved 7 bytes.

more elegant version, 88 bytes:

<?=array_reduce($a=$_GET[a],function($r,$x){return$r*$x[1]/$x[0];},$a[0][0]/end($a)[1]);


问:
Print numbers from 1 to 10
This might be a very simple challenge, but I am surprised it hasn't been done on code-golf yet:

Print all Integers from 1 to 10 inclusive in ascending order to standard output.

Your output format can be whatever your language supports. This includes arbitrary separators (commas, semicolons, newlines, combinations of those, etc., but no digits), and prefixes and postfixes (like [...]). However, you may not output any other numbers than 1 through 10. Your program may not take any input. Standard loopholes are disallowed.

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

Leaderboard

var QUESTION_ID=86075,OVERRIDE_USER=42570;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

```

ContentLicense: CC BY-SA 3.0

Title: Print numbers from 1 to 10

Body:
Python3 : <s>22</s> 19 bytes

print(*range(1,11))

Output:

1 2 3 4 5 6 7 8 9 10


答:
C++, <s>106</s> 98 bytes

I used two loops and a few tricks.

```<code>#import <cstdio>
main(){for(int i,j;i++-9;j=0)while(j++-i)printf("%dx%d=%d%c",j,i,i*j,j<i?32:10);}
</code>```

Title: Print this Multiplication Table

Body:
Write shortest code to print the following Multiplication Table:</p>

```<code>1×1=1
1×2=2  2×2=4
1×3=3  2×3=6  3×3=9
1×4=4  2×4=8  3×4=12 4×4=16
1×5=5  2×5=10 3×5=15 4×5=20 5×5=25
1×6=6  2×6=12 3×6=18 4×6=24 5×6=30 6×6=36
1×7=7  2×7=14 3×7=21 4×7=28 5×7=35 6×7=42 7×7=49
1×8=8  2×8=16 3×8=24 4×8=32 5×8=40 6×8=48 7×8=56 8×8=64
1×9=9  2×9=18 3×9=27 4×9=36 5×9=45 6×9=54 7×9=63 8×9=72 9×9=81
</code>```

Body:
C++, <s>106</s> 98 bytes

I used two loops and a few tricks.

#import <cstdio>
main(){for(int i,j;i++-9;j=0)while(j++-i)printf("%dx%d=%d%c",j,i,i*j,j<i?32:10);}


问:
Golf bit weaving
Note: the first half of this challenge comes from Martin Ender's previous challenge, Visualize Bit Weaving.

The esoteric programming language evil has an interesting operation on byte values which it calls "weaving".

It is essentially a permutation of the eight bits of the byte (it doesn't matter which end we start counting from, as the pattern is symmetric):

Bit 0 is moved to bit 2

Bit 1 is moved to bit 0

Bit 2 is moved to bit 4

Bit 3 is moved to bit 1

Bit 4 is moved to bit 6

Bit 5 is moved to bit 3

Bit 6 is moved to bit 7

Bit 7 is moved to bit 5

For convenience, here are three other representations of the permutation. As a cycle:

```<code>(02467531)
</code>```

As a mapping:

```<code>57361402 -> 76543210 -> 64725031
</code>```

And as a list of pairs of the mapping:

```<code>[[0,2], [1,0], [2,4], [3,1], [4,6], [5,3], [6,7], [7,5]]
</code>```

After 8 weavings, the byte is essentially reset.

For example, weaving the number 10011101 (which is 157 in base 10) will produce 01110110 (which is 118 in base 10).

Input

There are only 256 valid inputs, namely all the integers between 0 and 255 inclusive. That may be taken in any base, but it must be consistent and you must specify it if the base you choose is not base ten.

You may not zero-pad your inputs.

Output

You should output the result of the bit weaving, in any base, which must also be consistent and specified if not base ten.

You may zero-pad your outputs.

Related: Visualize Bit Weaving

答:
JavaScript, 98 Bytes

Input is taken in base-2 as a string, output is also base-2 as a string

```<code>n=>(n.length<8?n="0".repeat(8-n.length)+n:0,a="13052746",t=n,n.split``.map((e,i)=>t[a[i]]).join``)
</code>```

Title: Golf bit weaving

Body:
JavaScript, 98 Bytes

Input is taken in base-2 as a string, output is also base-2 as a string

n=>(n.length<8?n="0".repeat(8-n.length)+n:0,a="13052746",t=n,n.split``.map((e,i)=>t[a[i]]).join``)


答:
C++ : 67 bytes

```<code>#include<iostream>
int main(int i){for(;i<11;std::cout<<i++<<",");}
</code>```

Output:

1 2 3 4 5 6 7 8 9 10

Title: Print numbers from 1 to 10

Body:
This might be a very simple challenge, but I am surprised it hasn't been done on code-golf yet:

Print all Integers from 1 to 10 inclusive in ascending order to standard output.

Your output format can be whatever your language supports. This includes arbitrary separators (commas, semicolons, newlines, combinations of those, etc., but no digits), and prefixes and postfixes (like [...]). However, you may not output any other numbers than 1 through 10. Your program may not take any input. Standard loopholes are disallowed.

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

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
C++ : 67 bytes

#include<iostream>
int main(int i){for(;i<11;std::cout<<i++<<",");}

Output:

1 2 3 4 5 6 7 8 9 10


答:
Whitespace,

<s>71</s> bytes, thanks to LeakyNun,

63 bytes, thanks to Kevin

Spaces substituted with S, tabs with T, linefeeds with L:

(extra spaces inserted for readability)

```<code>SSSTL LSSTL SLS TLST SSSTSTSL TLS SSSSTL TSSS SLS SSSTSTTL TSST LTSSL LSLTL
</code>```

Run it!

Output:

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

Title: Print numbers from 1 to 10

Body:
Whitespace,

<s>71</s> bytes, thanks to LeakyNun,

63 bytes, thanks to Kevin

Spaces substituted with S, tabs with T, linefeeds with L:

(extra spaces inserted for readability)

SSSTL LSSTL SLS TLST SSSTSTSL TLS SSSSTL TSSS SLS SSSTSTTL TSST LTSSL LSLTL

Run it!

Output:

1
2
3
4
5
6
7
8
9
10


问:
Reverse Bayer Filter of an image
Almost all digital camera sensors are organized in a grid of photosensors. Each photo sensor is sensitive for one of the primary colors: red, green and blue. The way those photo sensors are organized is called the Bayer filter, after its inventor, Bryce Bayer of Eastman Kodak. After an image is taken, four photo sensors compose the RGB value of one pixel in the resulting image. Your task is to reverse that process and colorize the resulting pixels according to their filter color. For the sake of simplicity, we will ignore gamma correction.

For example: the "normal" forward Bayer filter steps are:

a lightray with a Pantone Beeswax color hits the sensor;

the BGGR (Blue - Green / Green - Red) filter decomposes this into four rays.

The four rays hit the sensor, which reads: 81 - 168 / 168 - 235 (sensor values range from 0 - 255);

The Bayer filter translates this to one RGB pixel with color (235, 168, 81).

The reverse Bayer filter steps are:

RGB pixel with color (235, 168, 81) is split into four pixels with RGB values: (0,0,81) - (0,168,0) / (0,168,0) - (235,0,0).

Challenge

You should write the shortest possible function or program that does the following:

Take a filename as in input and output the DeBayered image.

The output may be written to a file or displayed on the screen.

The output must be twice the width and twice the height of the original image.

Each pixel of the input image must be mapped according to the BGGR (Blue - Green / Green - Red) Bayer filter pattern as explained graphically in the following picture:

We'll assume that both green photosensors receive the same signal, so both the G values in the Bayer matrix are equal to the G value in the RGB image.

You may not return an array representation of the resulting image. The output must be an image or a file (in any suitable image format) that can be displayed as an image.

Example

Given this file as an input:

The resulting image should be:

Reference python implementation:

```<code>from PIL import Image
import numpy
import sys

if len(sys.argv) == 1:
    print "Usage: python DeByer.py <<image_filename>>"
    sys.exit()

# Open image and put it in a numpy array
srcArray = numpy.array(Image.open(sys.argv[1]), dtype=numpy.uint8)
w, h, _ = srcArray.shape

# Create target array, twice the size of the original image
resArray = numpy.zeros((2*w, 2*h, 3), dtype=numpy.uint8)

# Map the RGB values in the original picture according to the BGGR pattern#

# Blue
resArray[::2, ::2, 2] = srcArray[:, :, 2]

# Green (top row of the Bayer matrix)
resArray[1::2, ::2, 1] = srcArray[:, :, 1]

# Green (bottom row of the Bayer matrix)
resArray[::2, 1::2, 1] = srcArray[:, :, 1]

# Red
resArray[1::2, 1::2, 0] = srcArray[:, :, 0]

# Save the imgage
Image.fromarray(resArray, "RGB").save("output.png")
</code>```

Remember: this is a code-golf, so shortest code wins!

答:
J, <s>100</s> <s>96</s> 90 bytes

```<code>load'bmp'
'o'writebmp~,./,./($a)$2 1 1 0(_2]\(2^0 8 8 16)*{)"1(3#256)#:,a=:readbmp]stdin''
</code>```

This is a script in J that reads the filename of the input image from stdin and outputs the result to a file named o. The input and output images will both be in bmp format. It also expects only the filename to be input, meaning that leading and trailing whitespace should not be present.

Sample Usage

```<code>$ echo -n mona.bmp | jconsole reversebayer.ijs
</code>```

Explanation

```<code>A=:readbmp]stdin''  Store the image in A as a 2d array of 24-bit rgb ints
,                   Flatten it into a list
(3#256) #:          Convert each 24-bit int to a tuple of 8-bit r/g/b ints
2 1 1 0 {"1         Select each column in BGGR order
(2^0 8 8 16) *      Shift each color to make it a 24-bit rgb value
_2 ]\               Convert each row from dimensions 1x4 to 2x2
($A) $              Reshape the list of 2x2 matrices into a matrix of
                    2x2 matrices with dimensions matching A
,./                 Append the 2x2 matrices by column
,./                 Append the 2x2 matrices by row - This is now a matrix of
                     24-bit rgb values with twice the dimensions of A
'o'writebmp~        Write the image array to a bmp file named 'o'
</code>```

ContentLicense: CC BY-SA 4.0

Title: Reverse Bayer Filter of an image

Body:
J, <s>100</s> <s>96</s> 90 bytes

load'bmp'
'o'writebmp~,./,./($a)$2 1 1 0(_2]\(2^0 8 8 16)*{)"1(3#256)#:,a=:readbmp]stdin''

This is a script in J that reads the filename of the input image from stdin and outputs the result to a file named o. The input and output images will both be in bmp format. It also expects only the filename to be input, meaning that leading and trailing whitespace should not be present.

Sample Usage

$ echo -n mona.bmp | jconsole reversebayer.ijs

Explanation

A=:readbmp]stdin''  Store the image in A as a 2d array of 24-bit rgb ints
,                   Flatten it into a list
(3#256) #:          Convert each 24-bit int to a tuple of 8-bit r/g/b ints
2 1 1 0 {"1         Select each column in BGGR order
(2^0 8 8 16) *      Shift each color to make it a 24-bit rgb value
_2 ]\               Convert each row from dimensions 1x4 to 2x2
($A) $              Reshape the list of 2x2 matrices into a matrix of
                    2x2 matrices with dimensions matching A
,./                 Append the 2x2 matrices by column
,./                 Append the 2x2 matrices by row - This is now a matrix of
                     24-bit rgb values with twice the dimensions of A
'o'writebmp~        Write the image array to a bmp file named 'o'


Title: Print this Multiplication Table

Body:
Maple, 64

seq(printf(seq(printf("%ax%a=%a ",j,i,i*j),j=1..i),"\n"),i=1..9)


答:
LOLCODE, 202 bytes

```<code>IM IN YR o UPPIN YR b TIL BOTH SAEM b AN 10
c R ""
IM IN YR i UPPIN YR a TIL BOTH SAEM a AN SUM OF b AN 1
c R SMOOSH c SMOOSH a "x" b "=" PRODUKT OF a AN b " " MKAY
IM OUTTA YR i
VISIBLE c
IM OUTTA YR o
</code>```

Ungolfed:

```<code>HAI 1.3 BTW Unnecessary in current implementations
IM IN YR outer UPPIN YR multiplicand TIL BOTH SAEM multiplicand AN 10
    I HAS A output ITZ ""
    IM IN YR inner UPPIN YR multiplier TIL BOTH SAEM multiplier AN SUM OF multiplicand AN 1
        output R SMOOSH output AN SMOOSH multiplier AN "x" AN multiplicand AN "=" AN PRODUCKT OF multiplicand AN multiplier AN " " MKAY MKAY BTW AN is optional to separate arguments, a linebreak is an implicit MKAY.
    IM OUTTA YR inner
    VISIBLE output
IM OUTTA YR outer
KTHXBYE BTW Unnecessary in current implementations
</code>```

Pythonated for non-leetspeakers:

```<code>for multiplicand in range(1, 10):
    output = ""
    for multiplier in range(1, multiplicand + 1):
        output = output + (multiplier + "x" + multiplicand + "=" + str(multiplicand * multiplier) + " ")
    print(output)
</code>```

Title: Print this Multiplication Table

Body:
LOLCODE, 202 bytes

IM IN YR o UPPIN YR b TIL BOTH SAEM b AN 10
c R ""
IM IN YR i UPPIN YR a TIL BOTH SAEM a AN SUM OF b AN 1
c R SMOOSH c SMOOSH a "x" b "=" PRODUKT OF a AN b " " MKAY
IM OUTTA YR i
VISIBLE c
IM OUTTA YR o

Ungolfed:

HAI 1.3 BTW Unnecessary in current implementations
IM IN YR outer UPPIN YR multiplicand TIL BOTH SAEM multiplicand AN 10
    I HAS A output ITZ ""
    IM IN YR inner UPPIN YR multiplier TIL BOTH SAEM multiplier AN SUM OF multiplicand AN 1
        output R SMOOSH output AN SMOOSH multiplier AN "x" AN multiplicand AN "=" AN PRODUCKT OF multiplicand AN multiplier AN " " MKAY MKAY BTW AN is optional to separate arguments, a linebreak is an implicit MKAY.
    IM OUTTA YR inner
    VISIBLE output
IM OUTTA YR outer
KTHXBYE BTW Unnecessary in current implementations

Pythonated for non-leetspeakers:

for multiplicand in range(1, 10):
    output = ""
    for multiplier in range(1, multiplicand + 1):
        output = output + (multiplier + "x" + multiplicand + "=" + str(multiplicand * multiplier) + " ")
    print(output)


答:
Python 2, 91 characters

```<code>for k in[" ".join(["%ix%i=%i"%(j,i,j*i)for j in range(1,i+1)])for i in range(1,10)]:print k
</code>```

Or, if each line as string like '1x2=2 2x2=4' is acceptable, this is 85 characters:

```<code>for k in[" ".join(["%ix%i=%i"%(j,i,j*i)for j in range(1,i+1)])for i in range(1,10)]:k
</code>```

This one is slightly varied, resulting 93 characters:

```<code>print("\n".join([" ".join(["%ix%i=%i"%(j,i,j*i)for j in range(1,i+1)])for i in range(1,10)]))
</code>```

Title: Print this Multiplication Table

Body:
Python 2, 91 characters

for k in[" ".join(["%ix%i=%i"%(j,i,j*i)for j in range(1,i+1)])for i in range(1,10)]:print k

Or, if each line as string like '1x2=2 2x2=4' is acceptable, this is 85 characters:

for k in[" ".join(["%ix%i=%i"%(j,i,j*i)for j in range(1,i+1)])for i in range(1,10)]:k

This one is slightly varied, resulting 93 characters:

print("\n".join([" ".join(["%ix%i=%i"%(j,i,j*i)for j in range(1,i+1)])for i in range(1,10)]))


问:
The shortest code to tell if a number is even or odd
One of my colleagues proposed us a challenge: to write the shortest C/C++ program to determine if a number is even or odd.

These are the requirements:

Get a number from keyboard, at run-time (not from command line)

Output the string pari if the number is even

Output the string dispari if the number is odd

We can assume that the input is legal

We can assume that the machine has a i386 architecture

Code preprocessing is not allowed (e.g.: use #defines)

[edit after comments] The code can be considered valid if it compiles with gcc 4.x

This is the best attempt we had so far (file test.c, 50B):

```<code>main(i){scanf("%d",&i);puts("dispari"+3*(~i&1));}
</code>```

Do you think we can go further?

(*): "dispari" is the italian for odd and "pari" is the italian for even

答:
48 bytes

```<code>main(i){scanf("%d",&i);puts("dispari"+3-i%2*3);}
</code>```

OwnerDisplayName: Vincenzo Pii

Body:
48 bytes

main(i){scanf("%d",&i);puts("dispari"+3-i%2*3);}


答:
Excel, <s>92</s> 91 Bytes

From the VBA editor's immediate window, run the following command:
Range("A1:I9").Formula="=IF(ROW()<COLUMN(),"""",COLUMN()&""×""&ROW()&""=""&COLUMN()*ROW())"
The output is directly on the active worksheet.

I golfed an extra byte by swapping the order of an if to change >= to <.  I didn't update the screenshot, but it only affects the formula at the top, not the output.

Title: Print this Multiplication Table


问:
Gear Train, Rotating
Gears transfer different amount of speeds, depending on the size of the meshed gear.

Jack has a machine, that rotates a Gear Train. but you don't know the speed of the last gear.

Luckily, You are a great code golfer, so you can help him!

So, What should I do?

Each gear is represented by 2 numbers, the radius of the inner gear and the radius of the outer gears.

If gear A is [a,b] and gear B is [c,d], then the ratio between the speed of A and the speed of B would be c:b.

Given a list of gears (list of 2-tuples), output the speed of the last gear.

You can assume the speed of the first gear is 1.

Worked out example

Let's say our input is [[6,12],[3,10],[5,8]].

The first gear, [6,12], would have a speed of 1.

Then, the second gear, [3,10], would have a speed of 1*12/3 = 4.

Then, the last gear, [5,8], would have a speed of 4*10/5 = 8.

Testcases

```<code>input                    output
[[1,1],[2,2]]            0.5     (1/2)
[[1,2],[1,2],[1,2]]      4       (2/1*2/1)
[[6,12],[3,10],[5,8]]    8       (12/3*10/5)
</code>```

Rules

Basic code-golf rules apply.

答:
Python 2, 52 bytes

```<code>lambda x:reduce(lambda x,y:y/float(x),x[1:-1][::-1])
</code>```

An anonymous function that takes input of a flattened list via argument and returns the output.

This makes use of the division cascade idea, as in xnor's answer.

Try it on Ideone

Title: Gear Train, Rotating

Body:
Python 2, 52 bytes

lambda x:reduce(lambda x,y:y/float(x),x[1:-1][::-1])

An anonymous function that takes input of a flattened list via argument and returns the output.

This makes use of the division cascade idea, as in xnor's answer.

Try it on Ideone


答:
Python 3, 59 bytes

```<code>lambda x:eval('/'.join('{}*{}'.format(*i)for i in x)[2:-2])
</code>```

An anonymous function that takes input of a non-flattened list via argument and returns the output.

How it works

For every pair of integers in the input, a string of the form 'int1*int2' is created. Joining all these pairs on / gives a string of the form 'int1*int2/int3*int4/...', which is the desired calculation, but includes the undesired first and last integers. These are removed by slicing out the first two and last two characters in the sting, leaving the desired calculation. This is then evaluated and returned.

Try it on Ideone

Title: Gear Train, Rotating

Body:
Gears transfer different amount of speeds, depending on the size of the meshed gear.

Jack has a machine, that rotates a Gear Train. but you don't know the speed of the last gear.

Luckily, You are a great code golfer, so you can help him!

So, What should I do?

Each gear is represented by 2 numbers, the radius of the inner gear and the radius of the outer gears.

If gear A is [a,b] and gear B is [c,d], then the ratio between the speed of A and the speed of B would be c:b.

Given a list of gears (list of 2-tuples), output the speed of the last gear.

You can assume the speed of the first gear is 1.

Worked out example

Let's say our input is [[6,12],[3,10],[5,8]].

The first gear, [6,12], would have a speed of 1.

Then, the second gear, [3,10], would have a speed of 1*12/3 = 4.

Then, the last gear, [5,8], would have a speed of 4*10/5 = 8.

Testcases

```<code>input                    output
[[1,1],[2,2]]            0.5     (1/2)
[[1,2],[1,2],[1,2]]      4       (2/1*2/1)
[[6,12],[3,10],[5,8]]    8       (12/3*10/5)
</code>```

Rules

Basic code-golf rules apply.

Body:
Python 3, 59 bytes

lambda x:eval('/'.join('{}*{}'.format(*i)for i in x)[2:-2])

An anonymous function that takes input of a non-flattened list via argument and returns the output.

How it works

For every pair of integers in the input, a string of the form 'int1*int2' is created. Joining all these pairs on / gives a string of the form 'int1*int2/int3*int4/...', which is the desired calculation, but includes the undesired first and last integers. These are removed by slicing out the first two and last two characters in the sting, leaving the desired calculation. This is then evaluated and returned.

Try it on Ideone


答:
Matlab, <s>104</s> 92 bytes

This makes use of the 3d-array/matrix representation of RGB images in Matlab, as well as the Kronecker product which is exactly what we need creating this new 2x2 "metapixel" form each source pixel. The output is then displayed in a popup window.

```<code>a=double(imread(input('')));for n=1:3;b(:,:,n)=kron(a(:,:,n),[1:2;2:3]==n)/255;end;imshow(b)
</code>```

Resized screencapture:

Title: Reverse Bayer Filter of an image

Body:
Almost all digital camera sensors are organized in a grid of photosensors. Each photo sensor is sensitive for one of the primary colors: red, green and blue. The way those photo sensors are organized is called the Bayer filter, after its inventor, Bryce Bayer of Eastman Kodak. After an image is taken, four photo sensors compose the RGB value of one pixel in the resulting image. Your task is to reverse that process and colorize the resulting pixels according to their filter color. For the sake of simplicity, we will ignore gamma correction.

For example: the "normal" forward Bayer filter steps are:

a lightray with a Pantone Beeswax color hits the sensor;

the BGGR (Blue - Green / Green - Red) filter decomposes this into four rays.

The four rays hit the sensor, which reads: 81 - 168 / 168 - 235 (sensor values range from 0 - 255);

The Bayer filter translates this to one RGB pixel with color (235, 168, 81).

The reverse Bayer filter steps are:

RGB pixel with color (235, 168, 81) is split into four pixels with RGB values: (0,0,81) - (0,168,0) / (0,168,0) - (235,0,0).

Challenge

You should write the shortest possible function or program that does the following:

Take a filename as in input and output the DeBayered image.

The output may be written to a file or displayed on the screen.

The output must be twice the width and twice the height of the original image.

Each pixel of the input image must be mapped according to the BGGR (Blue - Green / Green - Red) Bayer filter pattern as explained graphically in the following picture:

We'll assume that both green photosensors receive the same signal, so both the G values in the Bayer matrix are equal to the G value in the RGB image.

You may not return an array representation of the resulting image. The output must be an image or a file (in any suitable image format) that can be displayed as an image.

Example

Given this file as an input:

The resulting image should be:

Reference python implementation:

```<code>from PIL import Image
import numpy
import sys

if len(sys.argv) == 1:
    print "Usage: python DeByer.py <<image_filename>>"
    sys.exit()

# Open image and put it in a numpy array
srcArray = numpy.array(Image.open(sys.argv[1]), dtype=numpy.uint8)
w, h, _ = srcArray.shape

# Create target array, twice the size of the original image
resArray = numpy.zeros((2*w, 2*h, 3), dtype=numpy.uint8)

# Map the RGB values in the original picture according to the BGGR pattern#

# Blue
resArray[::2, ::2, 2] = srcArray[:, :, 2]

# Green (top row of the Bayer matrix)
resArray[1::2, ::2, 1] = srcArray[:, :, 1]

# Green (bottom row of the Bayer matrix)
resArray[::2, 1::2, 1] = srcArray[:, :, 1]

# Red
resArray[1::2, 1::2, 0] = srcArray[:, :, 0]

# Save the imgage
Image.fromarray(resArray, "RGB").save("output.png")
</code>```

Remember: this is a code-golf, so shortest code wins!

Body:
Matlab, <s>104</s> 92 bytes

This makes use of the 3d-array/matrix representation of RGB images in Matlab, as well as the Kronecker product which is exactly what we need creating this new 2x2 "metapixel" form each source pixel. The output is then displayed in a popup window.

a=double(imread(input('')));for n=1:3;b(:,:,n)=kron(a(:,:,n),[1:2;2:3]==n)/255;end;imshow(b)

Resized screencapture:


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

A path will look something like this:

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

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

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

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

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

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

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

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

```<code>S
===

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

nor can he in this one

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

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

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

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

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

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

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

Mario can reach the goal in all of these examples:

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

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

```<code>S
=

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

This is code golf, so fewest bytes wins!

答:
Python, <s>260</s> <s>239</s> <s>222</s> <s>215</s> <s>209</s> 206 Bytes,

try it on ideone (with test cases)

f=lambda m,y=-1,x=0:f(m,m[0].find("S"))if y<0else y<len(m[0])-1and x<len(m)and m[x][y]!="="and(m[x][y]=="E"or m[x][y+1]=="="and any(f(m,y-i,x+1)for i in range(5)[:(m[x][y::-1]+"=").find("=")])or f(m,y+1,x))
```
<p>call like: <code>f([' S=', ' E='])</code></p>
<h3>patch notes:</h3>
<p><em>Now, like some of the other solutions, assumes input is an array of coloumn strings, each starting with a " "</em></p>
<p><em>Wrapper for old input form:</em> <code>g=lambda x:f(map("".join,zip(*([" "*x.index("\n")]+x.split("\n")))))</code></p>
<p><em>Also, I fixed a bug where Mario could jump through blocks above him.</em></p>
<h3>ungolfed version with explanations:</h3>
<p><code>f</code> recursivly calls itself in all directions Mario can move to from <code>y,x</code>. It returns <code>True</code> when it reaches the <code>"E"nd</code>, which then goes back through all the function calls until <code>g</code> finally returns <code>True</code>.</p>
<pre class="lang-python prettyprint-override"><code>def g(x):
    #create a array of strings which are the rows of the input
    global m
    m=x.split("\n")
    m=[" "*len(m[0])]+m # because Mario can jump over sometimes
    #Mario starts at the S
    return f([i for i,a in enumerate(m) if a[0]=="S"][0],0)

def f(y,x):
    #print y,x
    if y>len(m)-2 or x>=len(m[0]) or y<0: return False #out of bounds
    if m[y][x]=="E":return True #Reached the goal
    if m[y][x]=="=":return False #We got stuck inside a wall
    if m[y+1][x]=="=": #if you have ground under your feet
        for i in range(5): #jump max 4
            if f(y-i,x+1): #go one forward and try to go further from there
                return True
    return f(y+1,x) ##fall down
</code>```

Title: Can Mario go to the end of this map

Body:
Python, <s>260</s> <s>239</s> <s>222</s> <s>215</s> <s>209</s> 206 Bytes,

try it on ideone (with test cases)

f=lambda m,y=-1,x=0:f(m,m[0].find("S"))if y<0else y<len(m[0])-1and x<len(m)and m[x][y]!="="and(m[x][y]=="E"or m[x][y+1]=="="and any(f(m,y-i,x+1)for i in range(5)[:(m[x][y::-1]+"=").find("=")])or f(m,y+1,x))

call like: f([' S=', ' E='])

patch notes:

Now, like some of the other solutions, assumes input is an array of coloumn strings, each starting with a " "

Wrapper for old input form: g=lambda x:f(map("".join,zip(*([" "*x.index("\n")]+x.split("\n")))))

Also, I fixed a bug where Mario could jump through blocks above him.

ungolfed version with explanations:

f recursivly calls itself in all directions Mario can move to from y,x. It returns True when it reaches the "E"nd, which then goes back through all the function calls until g finally returns True.

def g(x):
    #create a array of strings which are the rows of the input
    global m
    m=x.split("\n")
    m=[" "*len(m[0])]+m # because Mario can jump over sometimes
    #Mario starts at the S
    return f([i for i,a in enumerate(m) if a[0]=="S"][0],0)

def f(y,x):
    #print y,x
    if y>len(m)-2 or x>=len(m[0]) or y<0: return False #out of bounds
    if m[y][x]=="E":return True #Reached the goal
    if m[y][x]=="=":return False #We got stuck inside a wall
    if m[y+1][x]=="=": #if you have ground under your feet
        for i in range(5): #jump max 4
            if f(y-i,x+1): #go one forward and try to go further from there
                return True
    return f(y+1,x) ##fall down


答:
Mathematica <s>118</s> 127 bytes

The original submission used an actual picture as input. This uses a filename instead.

It applies two replacement rules to the image data of the referenced file:

For each row of the image data matrix,replace each pixel {r,b,g} with a blue pixel, {0,0,b} followed by a green pixel, {0,g,0};

Separately, for each row of the image data matrix, replace each pixel {r,b,g} with a green pixel {0,g,0} followed by a red pixel, {r,0,0};

Then Riffle (i.e. interleave) the matrices resulting from 1 and 2.

```<code>Image[Riffle[#/.{{_,g_,b_}:>(s=Sequence)[{0,0,b},{0,g,0}]}&/@(m=Import[#,"Data"]/255),#/.{{r_,g_,_}:>s[{0,g,0},{r,0,0}]}&/@m]]&
</code>```

```<code>Image[Riffle[#/.{{_,g_,b_}:>(s=Sequence)[{0,0,b},{0,g,0}]}&/@(m=Import[#,"Data"]/255),#/.{{r_,g_,_}:>s[{0,g,0},{r,0,0}]}&/@m]]&["mona.jpg"]
</code>```

Title: Reverse Bayer Filter of an image

Body:
Mathematica <s>118</s> 127 bytes

The original submission used an actual picture as input. This uses a filename instead.

It applies two replacement rules to the image data of the referenced file:

For each row of the image data matrix,replace each pixel {r,b,g} with a blue pixel, {0,0,b} followed by a green pixel, {0,g,0};

Separately, for each row of the image data matrix, replace each pixel {r,b,g} with a green pixel {0,g,0} followed by a red pixel, {r,0,0};

Then Riffle (i.e. interleave) the matrices resulting from 1 and 2.

Image[Riffle[#/.{{_,g_,b_}:>(s=Sequence)[{0,0,b},{0,g,0}]}&/@(m=Import[#,"Data"]/255),#/.{{r_,g_,_}:>s[{0,g,0},{r,0,0}]}&/@m]]&

Image[Riffle[#/.{{_,g_,b_}:>(s=Sequence)[{0,0,b},{0,g,0}]}&/@(m=Import[#,"Data"]/255),#/.{{r_,g_,_}:>s[{0,g,0},{r,0,0}]}&/@m]]&["mona.jpg"]


答:
Convex, 27 bytes

```<code>9´{_´f{æ*'×@@'=\_s,¿)S*}N}%
</code>```

Try it online!

Use the following version if only a single space is required between each equation:

Convex, 21 bytes

```<code>9´{_´f{æ*'×@@'=\S}N}%
</code>```

Try it online!

Title: Print this Multiplication Table

Body:
Write shortest code to print the following Multiplication Table:</p>

```<code>1×1=1
1×2=2  2×2=4
1×3=3  2×3=6  3×3=9
1×4=4  2×4=8  3×4=12 4×4=16
1×5=5  2×5=10 3×5=15 4×5=20 5×5=25
1×6=6  2×6=12 3×6=18 4×6=24 5×6=30 6×6=36
1×7=7  2×7=14 3×7=21 4×7=28 5×7=35 6×7=42 7×7=49
1×8=8  2×8=16 3×8=24 4×8=32 5×8=40 6×8=48 7×8=56 8×8=64
1×9=9  2×9=18 3×9=27 4×9=36 5×9=45 6×9=54 7×9=63 8×9=72 9×9=81
</code>```

Body:
Convex, 27 bytes

9´{_´f{æ*'×@@'=\_s,¿)S*}N}%

Try it online!

Use the following version if only a single space is required between each equation:

Convex, 21 bytes

9´{_´f{æ*'×@@'=\S}N}%

Try it online!


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

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

Write the shortest code that either:

Generates the Fibonacci sequence without end.

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

You may use standard forms of input and output.

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

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

Leaderboard

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

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

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

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

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
Sesos, 11 bytes (non-competing)

Not in-place, linear memory.

Hexdump:

```<code>0000000: ae8583 ef6bc7 045fe7 b907                         ....k.._...

Size   : 11 byte(s)
</code>```

Try it online!

Assembler

set numin
set numout
add 1,rwd 1,get    ;setup tape
jmp
  fwd 1
  jmp,sub 1,fwd 1,add 1,fwd 1,add 1,rwd 2,jnz
  rwd 1
  sub 1
  jmp,sub 1,fwd 1,add 1,rwd 1,jnz
  fwd 1
jnz
fwd 2
put
```

Title: Fibonacci function or sequence

Body:
Sesos, 11 bytes (non-competing)

Not in-place, linear memory.

Hexdump:

0000000: ae8583 ef6bc7 045fe7 b907                         ....k.._...

Size   : 11 byte(s)

Try it online!

Assembler

set numin
set numout
add 1,rwd 1,get    ;setup tape
jmp
  fwd 1
  jmp,sub 1,fwd 1,add 1,fwd 1,add 1,rwd 2,jnz
  rwd 1
  sub 1
  jmp,sub 1,fwd 1,add 1,rwd 1,jnz
  fwd 1
jnz
fwd 2
put


答:
Pyth, 26 bytes

```<code>MXm03H@GH.wsMsgLRRR,U2tU3'
</code>```

Expects the input filename with quotation marks on stdin, and writes to o.png. Example output:

Title: Reverse Bayer Filter of an image

Body:
Pyth, 26 bytes

MXm03H@GH.wsMsgLRRR,U2tU3'

Expects the input filename with quotation marks on stdin, and writes to o.png. Example output:


问:
Is this number a prime?
Believe it or not, we do not yet have a code golf challenge for a simple primality test. While it may not be the most interesting challenge, particularly for "usual" languages, it can be nontrivial in many languages.

Rosetta code features lists by language of idiomatic approaches to primality testing, one using the Miller-Rabin test specifically and another using trial division. However, "most idiomatic" often does not coincide with "shortest." In an effort to make Programming Puzzles and Code Golf the go-to site for code golf, this challenge seeks to compile a catalog of the shortest approach in every language, similar to "Hello, World!" and Golf you a quine for great good!.

Furthermore, the capability of implementing a primality test is part of our definition of programming language, so this challenge will also serve as a directory of proven programming languages.

Task

Write a full program that, given a strictly positive integer n as input, determines whether n is prime and prints a truthy or falsy value accordingly.

For the purpose of this challenge, an integer is prime if it has exactly two strictly positive divisors. Note that this excludes 1, who is its only strictly positive divisor.

Your algorithm must be deterministic (i.e., produce the correct output with probability 1) and should, in theory, work for arbitrarily large integers. In practice, you may assume that the input can be stored in your data type, as long as the program works for integers from 1 to 255.

Input

If your language is able to read from STDIN, accept command-line arguments or any other alternative form of user input, you can read the integer as its decimal representation, unary representation (using a character of your choice), byte array (big or little endian) or single byte (if this is your languages largest data type).

If (and only if) your language is unable to accept any kind of user input, you may hardcode the input in your program.

In this case, the hardcoded integer must be easily exchangeable. In particular, it may appear only in a single place in the entire program.

For scoring purposes, submit the program that corresponds to the input 1.

Output

Output has to be written to STDOUT or closest alternative.

If possible, output should consist solely of a truthy or falsy value (or a string representation thereof), optionally followed by a single newline.

The only exception to this rule is constant output of your language's interpreter that cannot be suppressed, such as a greeting, ANSI color codes or indentation.

Additional rules

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

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

The language Piet, for example, will be scored in codels, which is the natural choice for this language.

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

Unlike our usual rules, feel free to use a language (or language version) even if it's newer than this challenge. If anyone wants to abuse this by creating a language where the empty program performs a primality test, then congrats for paving the way for a very boring answer.

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

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

Built-in functions for testing primality are allowed. This challenge is meant to catalog the shortest possible solution in each language, so if it's shorter to use a built-in in your language, go for it.

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

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

Catalog

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

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

```<code>0000000: 16f0be afcf9c 37fcfe 8c19d7 c671d7 668ee3 f57b33  ......7......q.f...{3
0000015: 877bc6 662edb b961ba 8763bc 666e3c 66ec01         .{.f...a..c.fn<f..
</code>```

Try it online! Check Debug to see the generated binary code.

Background

To identify primes, we use a corollary of Wilson's theorem:

How it works (WIP)

The binary file above has been generated by assembling the following SASM code.

set numin
set numout

get
jmp
    jmp, fwd 1, add 1, fwd 1, add 1, fwd 1, add 1, rwd 3, sub 1, jnz
    fwd 1, sub 1, fwd 2
    jmp, rwd 3, add 1, fwd 3, sub 1, jnz
    rwd 1, sub 1
jnz
rwd 1, add 1, rwd 2
jmp
    fwd 1
    jmp, fwd 2, add 1, rwd 2, sub 1, jnz
    fwd 1
    jmp
        fwd 1
        jmp, fwd 1, add 1, rwd 3, add 1, fwd 2, sub 1, jnz
        fwd 1
        jmp, rwd 1, add 1, fwd 1, sub 1, jnz
        rwd 2
        sub 1
    jnz
    fwd 1
    get
    rwd 4
jnz
fwd 2
jmp
    rwd 1, sub 1, rwd 1, add 1, fwd 1
    jmp, rwd 1, jnz
    rwd 1
    jmp, fwd 1, add 1, rwd 1, sub 1, jnz
    fwd 2
    jmp, fwd 1, jnz
    rwd 1, sub 1
jnz
rwd 2
put
```

Title: Is this number a prime?

Body:
Sesos, <s>40</s> 39 bytes

0000000: 16f0be afcf9c 37fcfe 8c19d7 c671d7 668ee3 f57b33  ......7......q.f...{3
0000015: 877bc6 662edb b961ba 8763bc 666e3c 66ec01         .{.f...a..c.fn<f..

<a href="http://sesos.tryitonline.net/#code=c2V0IG51bWluCnNldCBudW1vdXQKCmdldApqbXAKICAgIGptcCwgZndkIDEsIGFkZCAxLCBmd2QgMSwgYWRkIDEsIGZ3ZCAxLCBhZGQgMSwgcndkIDMsIHN1YiAxLCBqbnoKICAgIGZ3ZCAxLCBzdWIgMSwgZndkIDIKICAgIGptcCwgcndkIDMsIGFkZCAxLCBmd2QgMywgc3ViIDEsIGpuegogICAgcndkIDEsIHN1YiAxCmpuegpyd2QgMSwgYWRkIDEsIHJ3ZCAyCmptcAogICAgZndkIDEKICAgIGptcCwgZndkIDIsIGFkZCAxLCByd2QgMiwgc3ViIDEsIGpuegogICAgZndkIDEKICAgIGptcAogICAgICAgIGZ3ZCAxCiAgICAgICAgam1wLCBmd2QgMSwgYWRkIDEsIHJ3ZCAzLCBhZGQgMSwgZndkIDIsIHN1YiAxLCBqbnoKICAgICAgICBmd2QgMQogICAgICAgIGptcCwgcndkIDEsIGFkZCAxLCBmd2QgMSwgc3ViIDEsIGpuegogICAgICAgIHJ3ZCAyCiAgICAgICAgc3ViIDEKICAgIGpuegogICAgZndkIDEKICAgIGdldAogICAgcndkIDQKam56CmZ3ZCAyCmptcAogICAgcndkIDEsIHN1YiAxLCByd2QgMSwgYWRkIDEsIGZ3ZCAxCiAgICBqbXAsIHJ3ZCAxLCBqbnoKICAgIHJ3ZCAxCiAgICBqbXAsIGZ3ZCAxLCBhZGQgMSwgcndkIDEsIHN1YiAxLCBqbnoKICAgIGZ3ZCAyCiAgICBqbXAsIGZ3ZCAxLCBqbnoKICAgIHJ3ZCAxLCBzdWIgMQpqbnoKcndkIDIKcHV0&input=Nw" rel="nofollow noreferrer">Try it online! Check Debug to see the generated binary code.

Background

To identify primes, we use a corollary of Wilson's theorem:

How it works (WIP)

The binary file above has been generated by assembling the following SASM code.

set numin
set numout

get
jmp
    jmp, fwd 1, add 1, fwd 1, add 1, fwd 1, add 1, rwd 3, sub 1, jnz
    fwd 1, sub 1, fwd 2
    jmp, rwd 3, add 1, fwd 3, sub 1, jnz
    rwd 1, sub 1
jnz
rwd 1, add 1, rwd 2
jmp
    fwd 1
    jmp, fwd 2, add 1, rwd 2, sub 1, jnz
    fwd 1
    jmp
        fwd 1
        jmp, fwd 1, add 1, rwd 3, add 1, fwd 2, sub 1, jnz
        fwd 1
        jmp, rwd 1, add 1, fwd 1, sub 1, jnz
        rwd 2
        sub 1
    jnz
    fwd 1
    get
    rwd 4
jnz
fwd 2
jmp
    rwd 1, sub 1, rwd 1, add 1, fwd 1
    jmp, rwd 1, jnz
    rwd 1
    jmp, fwd 1, add 1, rwd 1, sub 1, jnz
    fwd 2
    jmp, fwd 1, jnz
    rwd 1, sub 1
jnz
rwd 2
put


问:
Fibonacci reversed!

Introduction

We all know and love our Fibonacci sequence and have seen a myriad of challenge on it here already. However, we're still lacking a very simple case which this answer is going to provide: Reversed fibonacci! So given F_n your job is to find n.

Specification

Input

Your input will be a non-negative integer, which is guaranteed to be part of the fibonacci sequence.

Output

The output must be a non-negative integer as well.

What to do?

The introduction already said: Given a fibonacci number, output its index. Fiboancci number hereby is defined as F(0)=0, F(1)=1, F(n)=F(n-1)+F(n-2) and you're given F(n) and must return n.

Potential Corner Cases

0 is a valid in- and output.

If given "1" as input you may either output "1" or "2", as you prefer.

You may always assume that your input actually is a fibonacci number.

You may assume that the input is representable as a 32-bit signed integer.

Who wins?

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

Standard rules apply of course.

Test-cases

```<code>0 -> 0
2 -> 3
3 -> 4
5 -> 5
8 -> 6
13 -> 7
1836311903 -> 46
</code>```

答:
Java 7, 70 bytes

```<code>int c(int n){int a=0,b=1,c=0,t;while(a<n){c++;t=b;b+=a;a=t;}return c;}
</code>```

https://ideone.com/I4rUC5

Title: Fibonacci reversed!

Body:
Java 7, 70 bytes

int c(int n){int a=0,b=1,c=0,t;while(a<n){c++;t=b;b+=a;a=t;}return c;}

https://ideone.com/I4rUC5


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

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

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

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

Test cases:

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

Or as CSV:

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

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
x86_32 machine code, 2 bytes

```<code>08048540 <add7>:
 8048540:   01 c8                   add    %ecx,%eax
</code>```

Assuming the two values are already in the ecx and eax registers, performing the add instruction will add the values of the two registers and store the result in the destination register.

You can see the full program written in C and inline assembly here. Writing the wrapper in C makes it easier to provide inputs and do testing, but the actual add function can be reduced down to these two bytes.

Title: Add two numbers

Body:
x86_32 machine code, 2 bytes

08048540 <add7>:
 8048540:   01 c8                   add    %ecx,%eax

Assuming the two values are already in the ecx and eax registers, performing the add instruction will add the values of the two registers and store the result in the destination register.

You can see the full program written in C and inline assembly here. Writing the wrapper in C makes it easier to provide inputs and do testing, but the actual add function can be reduced down to these two bytes.


问:
Reverse a 1-dimensional array
Note: This challenge is not the same.

Challenge

Believe it or not, we haven't got ONE challenge for reversing one-dimensional arrays (although we've got one for n-dimensional ones)! This should operate only on the 1st dimension, not on all dimensions of an array.

Rules

Standard loopholes are denied

[[1, 2], [3, 4]] becomes [[3, 4], [1, 2]], not [[4, 3], [2, 1]].

This is code-golf, but no answer is accepted. Go beat the others!

You can get the array any way, except hardcoding. You can also get a string and process it.

The input will be an array (yes, commas or no commas, it needs to be an array).

Test cases

These are the test cases:

```<code>[1, 2, 3, 4]
[1, 2, 'hello', 'world!']
[[1, 2, 3, 4], [2, 3, 4, 1]]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
</code>```

These are the supposed results:

```<code>[4, 3, 2, 1]
['world!', 'hello', 2, 1]
[[2, 3, 4, 1], [1, 2, 3, 4]]
[23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
</code>```

You may accept input as [1 2 3 4], or even 1 2 3 4, or any other form or array your language has.

答:
, 3 bytes

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

Literally reverses array. Implicitly performs I/O.

Title: Reverse a 1-dimensional array

Body:
, 3 bytes

ᴚ

Literally reverses array. Implicitly performs I/O.


答:
UGL, 20 bytes

```<code>cuuuuu$+$Rl$d:_lorO:
</code>```

Try it online!

Title: Print numbers from 1 to 10

Body:
This might be a very simple challenge, but I am surprised it hasn't been done on code-golf yet:

Print all Integers from 1 to 10 inclusive in ascending order to standard output.

Your output format can be whatever your language supports. This includes arbitrary separators (commas, semicolons, newlines, combinations of those, etc., but no digits), and prefixes and postfixes (like [...]). However, you may not output any other numbers than 1 through 10. Your program may not take any input. Standard loopholes are disallowed.

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

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
UGL, 20 bytes

cuuuuu$+$Rl$d:_lorO:

Try it online!


答:
Python 2, <s>256</s> 275 bytes

First I simplified the original code:

```<code>from PIL import Image
from numpy import*
import sys

# Open image and put it in a numpy array
srcArray = array(Image.open(sys.argv[1]), dtype=uint8)
w, h, _ = srcArray.shape

# Create target array, twice the size of the original image
resArray = zeros((2*w, 2*h, 3), dtype=uint8)

# Map the RGB values in the original picture according to the BGGR pattern#

# Blue
resArray[::2, ::2, 2] = srcArray[:, :, 2]

# Green (top row of the Bayer matrix)
resArray[1::2, ::2, 1] = srcArray[:, :, 1]

# Green (bottom row of the Bayer matrix)
resArray[::2, 1::2, 1] = srcArray[:, :, 1]

# Red
resArray[1::2, 1::2, 0] = srcArray[:, :, 0]

# Save the imgage
Image.fromarray(resArray, "RGB").save("o.png")
</code>```

Then minify to:

```<code>from PIL import Image
from numpy import*
import sys
a=array(Image.open(sys.argv[1]),dtype=uint8)
w,h,_=a.shape
b=zeros((2*w,2*h,3),dtype=uint8)
b[::2,::2,2]=a[:,:,2]
b[1::2,::2,1]=a[:,:,1]
b[::2,1::2,1]=a[:,:,1]
b[1::2,1::2,0]=a[:,:,0]
Image.fromarray(b,"RGB").save("o.png")
</code>```

Resulting in the image o.png:

Title: Reverse Bayer Filter of an image

Body:
Python 2, <s>256</s> 275 bytes

First I simplified the original code:

from PIL import Image
from numpy import*
import sys

# Open image and put it in a numpy array
srcArray = array(Image.open(sys.argv[1]), dtype=uint8)
w, h, _ = srcArray.shape

# Create target array, twice the size of the original image
resArray = zeros((2*w, 2*h, 3), dtype=uint8)

# Map the RGB values in the original picture according to the BGGR pattern#

# Blue
resArray[::2, ::2, 2] = srcArray[:, :, 2]

# Green (top row of the Bayer matrix)
resArray[1::2, ::2, 1] = srcArray[:, :, 1]

# Green (bottom row of the Bayer matrix)
resArray[::2, 1::2, 1] = srcArray[:, :, 1]

# Red
resArray[1::2, 1::2, 0] = srcArray[:, :, 0]

# Save the imgage
Image.fromarray(resArray, "RGB").save("o.png")

Then minify to:

from PIL import Image
from numpy import*
import sys
a=array(Image.open(sys.argv[1]),dtype=uint8)
w,h,_=a.shape
b=zeros((2*w,2*h,3),dtype=uint8)
b[::2,::2,2]=a[:,:,2]
b[1::2,::2,1]=a[:,:,1]
b[::2,1::2,1]=a[:,:,1]
b[1::2,1::2,0]=a[:,:,0]
Image.fromarray(b,"RGB").save("o.png")

Resulting in the image o.png:


答:
Brainfuck, 41 bytes

+[[-<]>->>->-<-]<<[-<<+<<.+>>>>>.<]<<+.-.
```

<p><strong>Output</strong></p>

<pre class="lang-default prettyprint-override"><code>1 2 3 4 5 6 7 8 9 10
</code>```

Try it online.

Title: Print numbers from 1 to 10

Body:
Brainfuck, 41 bytes

+[[-<]>->>->-<-]<<[-<<+<<.+>>>>>.<]<<+.-.

Output

1 2 3 4 5 6 7 8 9 10

Try it online.


答:
VIM, using Bash and coreutils: 9 bytes

```<code>:!seq 10
</code>```

Title: Print numbers from 1 to 10

Body:
VIM, using Bash and coreutils: 9 bytes

:!seq 10


答:
, 7 bytes

```<code>⩤ 1,Ⅹ
</code>```

Prints out

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

Implicit print, Ⅹ is 10 and ⩤ is range(a, b) so the overall pseudocode is stdout.write(range(1, 10))

Note that, while it is only 5 characters, it still takes up 7 bytes, this is due to the Ⅹ and the ⩤ not being ASCII characters. (Ⅹ is the Roman numeral version)

Title: Print numbers from 1 to 10

Body:
, 7 bytes

⩤ 1,Ⅹ

Prints out

1,2,3,4,5,6,7,8,9,10

Implicit print, Ⅹ is 10 and ⩤ is range(a, b) so the overall pseudocode is stdout.write(range(1, 10))

Note that, while it is only 5 characters, it still takes up 7 bytes, this is due to the Ⅹ and the ⩤ not being ASCII characters. (Ⅹ is the Roman numeral version)


答:
Python 3, <s>259</s> 254 bytes

from PIL.Image import*
o=open(input())
w,h=o.size
n=new('RGB',(2*w,2*h))
P=Image.putpixel
for b in range(w*h):x=b//h;y=b%h;r,g,b=o.getpixel((x,y));c=2*x;d=2*y;G=0,g,0;P(n,(c,d),(0,0,b));P(n,(c+1,d),G);P(n,(c,d+1),G);P(n,(c+1,d+1),(r,0,0))
n.save('o.png')
```

<p>The input filename is given in standard input. Outputs to <code>o.png</code>.</p>

<p>Example usage:</p>

```$ echo mona-lisa.jpg | python bayer.py
```

Title: Reverse Bayer Filter of an image

Body:
Almost all digital camera sensors are organized in a grid of photosensors. Each photo sensor is sensitive for one of the primary colors: red, green and blue. The way those photo sensors are organized is called the Bayer filter, after its inventor, Bryce Bayer of Eastman Kodak. After an image is taken, four photo sensors compose the RGB value of one pixel in the resulting image. Your task is to reverse that process and colorize the resulting pixels according to their filter color. For the sake of simplicity, we will ignore gamma correction.

For example: the "normal" forward Bayer filter steps are:

a lightray with a Pantone Beeswax color hits the sensor;

the BGGR (Blue - Green / Green - Red) filter decomposes this into four rays.

The four rays hit the sensor, which reads: 81 - 168 / 168 - 235 (sensor values range from 0 - 255);

The Bayer filter translates this to one RGB pixel with color (235, 168, 81).

The reverse Bayer filter steps are:

RGB pixel with color (235, 168, 81) is split into four pixels with RGB values: (0,0,81) - (0,168,0) / (0,168,0) - (235,0,0).

Challenge

You should write the shortest possible function or program that does the following:

Take a filename as in input and output the DeBayered image.

The output may be written to a file or displayed on the screen.

The output must be twice the width and twice the height of the original image.

Each pixel of the input image must be mapped according to the BGGR (Blue - Green / Green - Red) Bayer filter pattern as explained graphically in the following picture:

We'll assume that both green photosensors receive the same signal, so both the G values in the Bayer matrix are equal to the G value in the RGB image.

You may not return an array representation of the resulting image. The output must be an image or a file (in any suitable image format) that can be displayed as an image.

Example

Given this file as an input:

The resulting image should be:

Reference python implementation:

```<code>from PIL import Image
import numpy
import sys

if len(sys.argv) == 1:
    print "Usage: python DeByer.py <<image_filename>>"
    sys.exit()

# Open image and put it in a numpy array
srcArray = numpy.array(Image.open(sys.argv[1]), dtype=numpy.uint8)
w, h, _ = srcArray.shape

# Create target array, twice the size of the original image
resArray = numpy.zeros((2*w, 2*h, 3), dtype=numpy.uint8)

# Map the RGB values in the original picture according to the BGGR pattern#

# Blue
resArray[::2, ::2, 2] = srcArray[:, :, 2]

# Green (top row of the Bayer matrix)
resArray[1::2, ::2, 1] = srcArray[:, :, 1]

# Green (bottom row of the Bayer matrix)
resArray[::2, 1::2, 1] = srcArray[:, :, 1]

# Red
resArray[1::2, 1::2, 0] = srcArray[:, :, 0]

# Save the imgage
Image.fromarray(resArray, "RGB").save("output.png")
</code>```

Remember: this is a code-golf, so shortest code wins!

Body:
Python 3, <s>259</s> 254 bytes

from PIL.Image import*
o=open(input())
w,h=o.size
n=new('RGB',(2*w,2*h))
P=Image.putpixel
for b in range(w*h):x=b//h;y=b%h;r,g,b=o.getpixel((x,y));c=2*x;d=2*y;G=0,g,0;P(n,(c,d),(0,0,b));P(n,(c+1,d),G);P(n,(c,d+1),G);P(n,(c+1,d+1),(r,0,0))
n.save('o.png')

The input filename is given in standard input. Outputs to o.png.

Example usage:

$ echo mona-lisa.jpg | python bayer.py


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

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

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

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

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

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

Leaderboard:

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Base64, 9 Bytes

MjAxNA==

(You can decode it with: echo MjAxNA== |base64 -d)


答:
<h1>
JavaScript, 17 Bytes
</h1>

```<code>atob("MjAxNA==")
</code>```

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

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

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

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

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

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

Leaderboard:

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
JavaScript, 17 Bytes

atob("MjAxNA==")


问:
Interquartile Mean

Task

Given (by any means) a sorted floating point dataset, return (by any means and within 1‰ of the correct value) the interquartile mean.

One possible algorithm

Discard the lowest and highest quarters of the data points.

Calculate the average (sum divided by count) of the remaining data points.

Note: If the dataset size is not evenly split-able in four, you will have to weigh the datapoints that are shared by sub-sets. See Example evaluation 2 below.

Example evaluation 1

Given {1, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 38}

Data count is 12, so we remove lowest and highest 3 datapoints:
{<s>1, 3, 4,</s> 5, 6, 6, 7, 7, 8, <s>8, 9, 38</s>}

Average of the remaining 6 datapoints:
(5 + 6 + 6 + 7 + 7 + 8) / 6 = 6.5

Example evaluation 2

Given {1, 3, 5, 7, 9, 11, 13, 15, 17}

Count is 9, so each quarter has 2¼ datapoints:
{<s>1, 2, (0.25×5),</s> (0.75×5), 7, 9, 11, (0.75×13), <s>(0.25×13), 15, 17</s>}

Average of the remaining 4.5 datapoints:
(0.75×5 + 7 + 9 + 11 + 0.75×13) / 4.5 = 9

答:
Pyth, <s>11</s> 10 bytes

```
<s>.O><lQS*4Ql</s>
.OsPtc4S*4
```

Test suite.

How it works

It quadruplicates the input list to ensure that the data count is divisible by 4.

It still needs sorting, because *4 applies to the whole list instead of to each individual element.

Then, it splits the list into four equal parts, then takes away the first and the last part.

The remaining list is flattened and the average is taken.

Title: Interquartile Mean

Body:
Pyth, <s>11</s> 10 bytes

<s>.O><lQS*4Ql</s>
.OsPtc4S*4

Test suite.

How it works

It quadruplicates the input list to ensure that the data count is divisible by 4.

It still needs sorting, because *4 applies to the whole list instead of to each individual element.

Then, it splits the list into four equal parts, then takes away the first and the last part.

The remaining list is flattened and the average is taken.


答:
Jelly, <s>14</s> <s>13</s> 12 bytes

```
<s>x4ṫL‘$ḣLN$S÷LH</s>
<s>x4ṫLḊḣLN$S÷LH</s>
x4œs4ḊṖFS÷LH
```

Try it online!

Test suite.

How it works

It is a translation of my answer in Pyth.

Title: Interquartile Mean

Body:
Task

Given (by any means) a sorted floating point dataset, return (by any means and within 1‰ of the correct value) the interquartile mean.

One possible algorithm

Discard the lowest and highest quarters of the data points.

Calculate the average (sum divided by count) of the remaining data points.

Note: If the dataset size is not evenly split-able in four, you will have to weigh the datapoints that are shared by sub-sets. See Example evaluation 2 below.

Example evaluation 1

Given {1, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 38}

Data count is 12, so we remove lowest and highest 3 datapoints:
{<s>1, 3, 4,</s> 5, 6, 6, 7, 7, 8, <s>8, 9, 38</s>}

Average of the remaining 6 datapoints:
(5 + 6 + 6 + 7 + 7 + 8) / 6 = 6.5

Example evaluation 2

Given {1, 3, 5, 7, 9, 11, 13, 15, 17}

Count is 9, so each quarter has 2¼ datapoints:
{<s>1, 2, (0.25×5),</s> (0.75×5), 7, 9, 11, (0.75×13), <s>(0.25×13), 15, 17</s>}

Average of the remaining 4.5 datapoints:
(0.75×5 + 7 + 9 + 11 + 0.75×13) / 4.5 = 9

Body:
Jelly, <s>14</s> <s>13</s> 12 bytes

<s>x4ṫL‘$ḣLN$S÷LH</s>
<s>x4ṫLḊḣLN$S÷LH</s>
x4œs4ḊṖFS÷LH

Try it online!

Test suite.

How it works

It is a translation of my answer in Pyth.


问:
Substring Sum Set

Introduction

Let's observe this array: [3, 2, 4, 1, 1, 5, 1, 2].

Each element displays the length of the substring which must be summed up. Let's take a look at the first element of the above array:

```<code>[3, 2, 4, 1, 1, 5, 1, 2]
 ^
</code>```

The element at the first index is 3, so we now take a substring of length three with the same index as the starting position:

```<code>[3, 2, 4]
</code>```

When summed up, this results into 9, so the first element of the substring sum set is 9.

We do this for all the elements in the array:

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

You can see that the number 5 is a bit of a weird case. That number exceeds the length of the array:

```<code>[3, 2, 4, 1, 1, 5, 1, 2]
                ^  ^  ^  ^  ^
</code>```

We'll ignore everything that exceeds the array, so we just use [5, 1, 2].

The last step is to sum everything up:

```<code>[3, 2, 4]     -> 9
[2, 4]        -> 6
[4, 1, 1, 5]  -> 11
[1]           -> 1
[1]           -> 1
[5, 1, 2]     -> 8
[1]           -> 1
[2]           -> 2
</code>```

And that is the array that needs to be outputted:

```<code>[9, 6, 11, 1, 1, 8, 1, 2]
</code>```

The Task

Given an non-empty array with positive (non-zero) integers, output the substring sum set. This is code-golf, so the submission with the smallest number of bytes wins!

Test cases

```<code>[1, 2, 3, 4, 5] -> [1, 5, 12, 9, 5]
[3, 3, 3, 3, 3, 3, 3, 3] -> [9, 9, 9, 9, 9, 9, 6, 3]
[5, 1, 2, 4, 1] -> [13, 1, 6, 5, 1]
[1] -> [1]
</code>```

答:
Matricks, 25 bytes

Yay, finally a challenge I don't need new features for!

```<code>md{z:l-g:c;+c;q:c;};:1:l;
</code>```

Run with: python matricks.py substring.txt [[<input>]] 0

Explanation:

```<code>m                  :1:l;   #loop over entire input
                           #set each value to...
 d{               }        #the sum of...
   z:l-g:c:+c;q:c;         #the input cropped to
                           #the length of the value in the cell
</code>```

Title: Substring Sum Set

Body:
Matricks, 25 bytes

Yay, finally a challenge I don't need new features for!

md{z:l-g:c;+c;q:c;};:1:l;

Run with: python matricks.py substring.txt [[<input>]] 0

Explanation:

m                  :1:l;   #loop over entire input
                           #set each value to...
 d{               }        #the sum of...
   z:l-g:c:+c;q:c;         #the input cropped to
                           #the length of the value in the cell


问:
Divisibility test

Task

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

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

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

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

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

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

Test cases

```<code> n,  d    output

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

Leaderboard

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
><>, 3 bytes

```<code>%n;
</code>```

Input numbers are assumed to be on the stack. ><> does not have any default truthy or falsy values, so I use 0 as truthy and everything else as falsy. That seems to be allowed. (If not, 1-truthy, 0-falsy, can be done like this in 5 bytes: %0=n;).

Title: Divisibility test

Body:
><>, 3 bytes

%n;

Input numbers are assumed to be on the stack. ><> does not have any default truthy or falsy values, so I use 0 as truthy and everything else as falsy. That seems to be allowed. (If not, 1-truthy, 0-falsy, can be done like this in 5 bytes: %0=n;).


Title: Interquartile Mean

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

2 bytes thanks to @miles

<s>#-:@%~-@#+/@}.#}.4#]</s>
-@#(+/%#)@}.#}.4#]

Try it online!
(Online interpreter)

Usage

>> f =: -@#(+/%#)@}.#}.4#]
>> f 1 3 5 7 9 11 13 15 17
<< 9

How it works

It is a translation of my answer in Pyth.


答:
Python 3, 50 bytes

lambda n:sum(sorted(n*4)[len(n):-len(n)])/len(n)/2
```

Ideone it!

How it works

It is a translation of my answer in Pyth.

Title: Interquartile Mean

Body:
Python 3, 50 bytes

lambda n:sum(sorted(n*4)[len(n):-len(n)])/len(n)/2

Ideone it!

How it works

It is a translation of my answer in Pyth.


答:
Pyke, <s>16</s> 13 bytes

```<code>4*S4ftOsDsRl/
</code>```

Try it here!

Title: Interquartile Mean

Body:
Pyke, <s>16</s> 13 bytes

4*S4ftOsDsRl/

Try it here!


答:
Actually, <s>20</s> <s>15</s> 13 bytes

```
<s>;l╗;+;+S╜@t╜τ@HΣ╜τ@/</s>
<s>;l;τ;a;+;+StHΣ/</s>
;l;τ;aττStHΣ/
```

Try it online!

How it works

It is a translation of my answer in Pyth.

Title: Interquartile Mean

Body:
Actually, <s>20</s> <s>15</s> 13 bytes

<s>;l╗;+;+S╜@t╜τ@HΣ╜τ@/</s>
<s>;l;τ;a;+;+StHΣ/</s>
;l;τ;aττStHΣ/

Try it online!

How it works

It is a translation of my answer in Pyth.


答:
Brachylog, 21 bytes

```<code>:3jo@4brbcLl/N,L+:N*.
</code>```

Try it online! or verify multiple test cases

Explanation

This is basically @LeakyNun's Pyth answer algorithm.

```<code>:3j      Append 3 copies of the input to itself
o@4      Sort and split in 4 lists of equal length
brb      Remove the head and the tail of the list of lists
cL       Concatenate the 2 sublists into a list L
l/N,     N is the inverse of the length of L
L+:N*.   Output is the product of N and the sum of the elements of L
</code>```

The only small trick there is in multiplying by the inverse of the length instead of dividing by the length, because division between 2 integers is integer division.

Title: Interquartile Mean

Body:
Brachylog, 21 bytes

:3jo@4brbcLl/N,L+:N*.

Try it online! or verify multiple test cases

Explanation

This is basically @LeakyNun's Pyth answer algorithm.

:3j      Append 3 copies of the input to itself
o@4      Sort and split in 4 lists of equal length
brb      Remove the head and the tail of the list of lists
cL       Concatenate the 2 sublists into a list L
l/N,     N is the inverse of the length of L
L+:N*.   Output is the product of N and the sum of the elements of L

The only small trick there is in multiplying by the inverse of the length instead of dividing by the length, because division between 2 integers is integer division.


Title: Interquartile Mean

Body:
Golfscript, <s>28</s> 29 bytes

<s>~.4*$\,.@/1>2<{+}*{+}*'/'@2*</s>
~.4*$\,.@/1>2<{+}*{+}*\2*-1?*

Try it online!


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

答:
ZX Spectrum Z80 assembly, 55 Bytes

1st attempt.

```<code>     org 8000H

start:

     ld hl,5800h
     ld c,18
main:

     ld de,120*256+8
     ld a,c
     sub e
     jr c, line
     jr z,white_line
     sub 3
     jr c,red_line
     jr nz,line

white_line:

     ld e,d
     jr line

red_line:

     ld de,16*256+16

line:

     ld a,16
     ld b,7

first_bit:

     ld (hl),e
     inc hl
     djnz first_bit
     ld (hl),d
     inc hl
     ld (hl),a
     inc hl
     ld (hl),a
     inc hl
     ld (hl),d
     ld b,15

next_bit:

     inc hl
     ld (hl),e
     djnz next_bit
     ld de,7
     add hl,de
     dec c
     jr nz,main
     ret

     end
</code>```

Title: Draw the national flag of Iceland

Body:
ZX Spectrum Z80 assembly, 55 Bytes

1st attempt.

     org 8000H

start:

     ld hl,5800h
     ld c,18
main:

     ld de,120*256+8
     ld a,c
     sub e
     jr c, line
     jr z,white_line
     sub 3
     jr c,red_line
     jr nz,line

white_line:

     ld e,d
     jr line

red_line:

     ld de,16*256+16

line:

     ld a,16
     ld b,7

first_bit:

     ld (hl),e
     inc hl
     djnz first_bit
     ld (hl),d
     inc hl
     ld (hl),a
     inc hl
     ld (hl),a
     inc hl
     ld (hl),d
     ld b,15

next_bit:

     inc hl
     ld (hl),e
     djnz next_bit
     ld de,7
     add hl,de
     dec c
     jr nz,main
     ret

     end


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

```<code>4Y"G"6L)]Ym
</code>```

Input is a horizontal vector, with the format

```<code>[1, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 38]
</code>```

or

```<code>[1 3 4 5 6 6 7 7 8 8 9 38]
</code>```

Try it online!

Explanation

```<code>4Y"    % Input horizontal vector implicitly. Repeat each element 4 times (run-length
       % decoding). The resulting array is still sorted.
G"     % Push input, for each: repeat as many times as the input size
  6L)  %   Remove first and last elements, by applying the index "2:end-1"
]      % End for each
Ym     % Compute mean. Display implicitly
</code>```

Title: Interquartile Mean

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

4Y"G"6L)]Ym

Input is a horizontal vector, with the format

[1, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 38]

or

[1 3 4 5 6 6 7 7 8 8 9 38]

Try it online!

Explanation

4Y"    % Input horizontal vector implicitly. Repeat each element 4 times (run-length
       % decoding). The resulting array is still sorted.
G"     % Push input, for each: repeat as many times as the input size
  6L)  %   Remove first and last elements, by applying the index "2:end-1"
]      % End for each
Ym     % Compute mean. Display implicitly