问:
Showcase of Languages

Notes

This thread is open and unlocked only because the community decided to make an exception. Please do not use this question as evidence that you can ask similar questions here. Please do not create additional showcase questions.

This is no longer a popularity-contest, nor are snippet lengths limited by the vote tally. If you know this thread from before, please make sure you familiarize yourself with the changes.

This thread is dedicated to showing off interesting, useful, obscure, and/or unique features your favorite programming languages have to offer. This is neither a challenge nor a competition, but a collaboration effort to showcase as many programming languages as possible as well as possible.

How this works

All answers should include the name of the programming language at the top of the post, prefixed by a #.

Answers may contain one (and only one) factoid, i.e., a couple of sentences without code that describe the language.

Aside from the factoid, answers should consist of snippets of code, which can (but don't have to be) programs or functions.

The snippets do not need to be related. In fact, snippets that are too related may be redundant.

Since this is not a contest, all programming languages are welcome, whenever they were created.

Answers that contain more than a handful of code snippets should use a Stack Snippet to collapse everything except the factoid and one of the snippets.

Whenever possible, there should be only one answer per programming language. This is a community wiki, so feel free to add snippets to any answer, even if you haven't created it yourself. There is a Stack Snippet for compressing posts, which should mitigate the effect of the 30,000 character limit.

Answers that predate these guidelines should be edited. Please help updating them as needed.

Current answers, sorted alphabetically by language name

$.ajax({type:"GET",url:"https://api.stackexchange.com/2.2/questions/44680/answers?site=codegolf&filter=withbody",success:function(data){for(var i=0;i<data.items.length;i++){var temp=document.createElement('p');temp.innerHTML = data.items[i].body.split("\n")[0];$('#list').append('
' + temp.innerText || temp.textContent + '');}}})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><base href="http://codegolf.stackexchange.com"><ul id="list"></ul></code>```

答:
Pyke

Factoid: Pyke is a stack-based golfing language with lots of implicit inputs. It was created to be easily extendable in February 2016. It is a great language to golf in.

1 byte:

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

Try it here!

This is the shortest semi-infinite loop in Pyke (Pyke has a setting that breaks out of it early turned on by default). It is equivalent to

```<code>1: GOTO_START
</code>```

r has 2 defined functions - goto_start and return. If r is visited in a function macro, it will instead return the current values on the stack.

If an error occurs whilst redoing the code again, it will go back to r and continue onwards.

2 bytes:

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

Try it here!

The factorial function - not a builtin. Equivalent to

```<code>product(range(1, input+1))
</code>```

Input is implicit in Pyke, whenever input is missing, it loads the next value off the input stack onto the program stack. At the end of the input stack there is an infinite amount of whatever the first item was. Output in Pyke is also implicit. Explicit output can also be used with the newline and p nodes for with and without a trailing newline respectively.

3 bytes:

```<code>]UP
</code>```

Try it here!

This actually shows off 3 interesting features:

```<code>]   -   [input, input] - Pyke reuses the stack when already used
 U  -  2d_map(^) - Creates a 2d range, effectively an `a*b` grid
  P - pretty_print(^) - Pretty print the values keeping the same padding for every column
</code>```

4 bytes

```<code>F\_+
</code>```

Try it here!

This shows off Pyke's for-loops using strings. If the input to a for loop is a string and the output is a list of strings, it automatically concatinates them together. Equivalent to

```<code>rtn = []
for i in input:
    rtn.append(i+"_")
rtn = "".join(rtn)
print(rtn)
</code>```

5 bytes

```<code>#.b){
</code>```

Try it here!

This program outputs if the input is a Fibonacci number. It uses the up_to node to generate Fibonacci numbers up to the input and then decides if the input is in that list

```<code>      - rtn = []
      - i = 0
#  )  - while rtn[-1] <= input:
 .b   -     rtn.append(nth_fib(i))
      -     i += 1
    { - input in rtn
</code>```

6 bytes

```<code>1: GOTO_START
</code>```0

Try it here!

Pyke has a neat function for clock related queries. The C or 'clock' takes any amount of numbers  afterwards and returns a time-related thing for each of them.

6 - months

9 - Months of the year (1 indexed, 0 is "PADDING")

5 - days

The script outputs the day of the current month as well as the name of that month.

```<code>1: GOTO_START
</code>```1

7 bytes

Finally... We got there, an absolutely minimal 'Hello World' program. Yes that is 7 bytes, in characters it is . d 0x02 0x0973 v

```<code>1: GOTO_START
</code>```2

Try it here!

This uses Pyke's built in compression to stick the words 'hello' and 'world' together. . d 0x02 says that there are 2 words to be combined and the other 2 characters say which words to use.

A compressor for Pyke can be found here

8 bytes

```<code>1: GOTO_START
</code>```3

Try it here!

This introduces 2 new features: Variable modification and escaping of infinite loops.

The explanation is annotated with python code to show what each character's doing

```<code>1: GOTO_START
</code>```4

The ? inplace variable modification node applies the first node to the contents of the second. Eventually Y will equal 0 and the 1/Y section will raise a ZeroDivisionError and will jump out of the infinite while loop.

9 bytes

```<code>1: GOTO_START
</code>```5

Try it here!

Takes a list of numbers and outputs the largest even number or 0 if there are no even numbers in the list.

```<code>1: GOTO_START
</code>```6

This overloads the e node which when given a list returns the last element and when given an integer, divides it by 2 and rounds down.

10 bytes

```<code>1: GOTO_START
</code>```7

Try it here!

This uses the brand new time types to add 1 hour 30 mins to the current time and drop the date part

```<code>1: GOTO_START
</code>```8

11 bytes

```<code>1: GOTO_START
</code>```9

Try it here!

This shows off two new instructions (There are in fact only two unique ones in the program). These are the repeat V and the print_grid .X functions.

V takes an integer or iterable and repeats the code the length of that iterable or the number of times. It takes the whole stack and when it loops, the current stack is kept and fed as input. If an iterable is passed, it also pushes that iterable at the beginning.

.X is a special function in that it will probably only be used in challenges requiring a strict output format. It takes a string (with optional newlines) and pads it so it is in a grid-like format. It also optionally takes up to 8 characters to pad with:

0: upper (all characters have this as default)

1: topleft (corners if undefined have this)

2: left line

3: right line

4: lower line

5: topright corner

6: bottomright corner

7: bottomleft corner

If no characters are given, it defaults to surrounding the entire thing with spaces. The program can stop defining extra characters by ending with a ".

```<code>SB
</code>```0

12 bytes

Whoever said golfing languages had far to many useless builtins?

```<code>SB
</code>```1

Try it here!

Returns the distance Jupiter will be from Earth on the next full moon (in AU). Seriously.

```<code>SB
</code>```2

Also works for all the planets in the solar system as well as some artificial satellites such as Voyager 2 and PIONEER 10

13 bytes

```<code>~1#_P)D3M*+mP
</code>```

Try it here!

We've just gone infinite! Returns an infinite list of all the prime numbers combined with all numbers with 2 prime factors.

```<code>~1            -    An infinite list of all the natural numbers, starting from 0.
  #  )        -   filter(^ as i, V)
   _P         -    is_prime(^)
      D3      -  duplicate ^ 3 times
        M*    -   cartesian_product(^ * ^) (Return an infinite list of all numbers with 2 prime factors)
          +   -  ^ + ^^ (Return an infinite list with a semi-sorted transposition of the 2 input ones)
           mP - map(factors, ^) (Return an infinite list of the factors of the 1 and 2 factor numbers)
</code>```

Infinite lists are effectively Python's generators. At the end of a Pyke program, all infinite lists on the stack are unwound as far as it will go in the time limit available (or none if done offline). Pyke has operators to filter and map nodes to infinite lists as well as combine them in various ways. Infinite lists are a relatively new feature and have been used in several short answers.

14 bytes

```<code>y0:0"wVs5

</code>```

Try it here!

Prints out every second in a day. This could be useful for challenges where you have to filter by specific seconds.

```<code>y0:0"         - create the time "0:0" (0 hours and 0 minutes)
     w      -  86400. Takes the ordinate of `` - 32.
        V     - repeat ^ times: V
         s5   -   increment the seconds by 1
           \n -  print(^)
</code>```

Both s and l change the amount of time by a predetermined amount. s increases and l decreases.

0 - years

1 - months

2 - days

3 - hours

4 - minutes

5 - seconds

6 - weeks

7 - 4 years

8 - decades

9 - 12 hours

15 bytes

```<code>.dȇጾȞĶl5
</code>```

Try it here!

Again another dictionary command. It's up to you to understand what it does

Title: Showcase of Languages

Body:
Pyke

Factoid: Pyke is a stack-based golfing language with lots of implicit inputs. It was created to be easily extendable in February 2016. It is a great language to golf in.

1 byte:

r

Try it here!

This is the shortest semi-infinite loop in Pyke (Pyke has a setting that breaks out of it early turned on by default). It is equivalent to

1: GOTO_START

r has 2 defined functions - goto_start and return. If r is visited in a function macro, it will instead return the current values on the stack.

If an error occurs whilst redoing the code again, it will go back to r and continue onwards.

2 bytes:

SB

Try it here!

The factorial function - not a builtin. Equivalent to

product(range(1, input+1))

Input is implicit in Pyke, whenever input is missing, it loads the next value off the input stack onto the program stack. At the end of the input stack there is an infinite amount of whatever the first item was. Output in Pyke is also implicit. Explicit output can also be used with the newline and p nodes for with and without a trailing newline respectively.

3 bytes:

]UP

Try it here!

This actually shows off 3 interesting features:

]   -   [input, input] - Pyke reuses the stack when already used
 U  -  2d_map(^) - Creates a 2d range, effectively an `a*b` grid
  P - pretty_print(^) - Pretty print the values keeping the same padding for every column

4 bytes

F\_+

Try it here!

This shows off Pyke's for-loops using strings. If the input to a for loop is a string and the output is a list of strings, it automatically concatinates them together. Equivalent to

rtn = []
for i in input:
    rtn.append(i+"_")
rtn = "".join(rtn)
print(rtn)

5 bytes

#.b){

Try it here!

This program outputs if the input is a Fibonacci number. It uses the up_to node to generate Fibonacci numbers up to the input and then decides if the input is in that list

      - rtn = []
      - i = 0
#  )  - while rtn[-1] <= input:
 .b   -     rtn.append(nth_fib(i))
      -     i += 1
    { - input in rtn

6 bytes

C695@]

Try it here!

Pyke has a neat function for clock related queries. The C or 'clock' takes any amount of numbers  afterwards and returns a time-related thing for each of them.

6 - months

9 - Months of the year (1 indexed, 0 is "PADDING")

5 - days

The script outputs the day of the current month as well as the name of that month.

C695   - stack = months, month_names, days
    @  - stack = month_names[months], days
     ] - stack = [month_names[months], days]

7 bytes

Finally... We got there, an absolutely minimal 'Hello World' program. Yes that is 7 bytes, in characters it is . d 0x02 0x0973 v

.dॳv

Try it here!

This uses Pyke's built in compression to stick the words 'hello' and 'world' together. . d 0x02 says that there are 2 words to be combined and the other 2 characters say which words to use.

A compressor for Pyke can be found here

8 bytes

1?tY/r"Z

Try it here!

This introduces 2 new features: Variable modification and escaping of infinite loops.

The explanation is annotated with python code to show what each character's doing

         - Y = 256
     r   - try:
         -     while True:
 ? Y     -         Y = lambda: v(Y)
  t      -             lambda x: x-1
1   /    -         stack.append(1/^)
         - except:
      "Z -     stack.append("Z")

The ? inplace variable modification node applies the first node to the contents of the second. Eventually Y will equal 0 and the 1/Y section will raise a ZeroDivisionError and will jump out of the infinite while loop.

9 bytes

S#2%!)1|e

Try it here!

Takes a list of numbers and outputs the largest even number or 0 if there are no even numbers in the list.

S         -  sorted(input)
 #   )    - filter(V, ^):
  2%!     -  not i%2
      1|  - ^ or 1
        e - if isinstance(^, int): floor_half(^)
          - else: ^[-1]

This overloads the e node which when given a list returns the last element and when given an integer, divides it by 2 and rounds down.

10 bytes

Cy1H30M"+t

Try it here!

This uses the brand new time types to add 1 hour 30 mins to the current time and drop the date part

C          -   current_time()
        +  -  ^ + V
 y1H30M"   -   time(hours=1, minutes = 30)
         t - time(^)

11 bytes

V.X".X-+||"

Try it here!

This shows off two new instructions (There are in fact only two unique ones in the program). These are the repeat V and the print_grid .X functions.

V takes an integer or iterable and repeats the code the length of that iterable or the number of times. It takes the whole stack and when it loops, the current stack is kept and fed as input. If an iterable is passed, it also pushes that iterable at the beginning.

.X is a special function in that it will probably only be used in challenges requiring a strict output format. It takes a string (with optional newlines) and pads it so it is in a grid-like format. It also optionally takes up to 8 characters to pad with:

0: upper (all characters have this as default)

1: topleft (corners if undefined have this)

2: left line

3: right line

4: lower line

5: topright corner

6: bottomright corner

7: bottomleft corner

If no characters are given, it defaults to surrounding the entire thing with spaces. The program can stop defining extra characters by ending with a ".

V           - repeat number of times:
 .X"        -  surround with spaces
    .X-+||" -  surround in a ascii box

12 bytes

Whoever said golfing languages had far to many useless builtins?

CB"Jupiter"@

Try it here!

Returns the distance Jupiter will be from Earth on the next full moon (in AU). Seriously.

C            -   current_time()
 B           -  full_moon_after(^)
  "Jupiter"@ - distance_to_earth("Jupiter", time=^)

Also works for all the planets in the solar system as well as some artificial satellites such as Voyager 2 and PIONEER 10

13 bytes

~1#_P)D3M*+mP

Try it here!

We've just gone infinite! Returns an infinite list of all the prime numbers combined with all numbers with 2 prime factors.

~1            -    An infinite list of all the natural numbers, starting from 0.
  #  )        -   filter(^ as i, V)
   _P         -    is_prime(^)
      D3      -  duplicate ^ 3 times
        M*    -   cartesian_product(^ * ^) (Return an infinite list of all numbers with 2 prime factors)
          +   -  ^ + ^^ (Return an infinite list with a semi-sorted transposition of the 2 input ones)
           mP - map(factors, ^) (Return an infinite list of the factors of the 1 and 2 factor numbers)

Infinite lists are effectively Python's generators. At the end of a Pyke program, all infinite lists on the stack are unwound as far as it will go in the time limit available (or none if done offline). Pyke has operators to filter and map nodes to infinite lists as well as combine them in various ways. Infinite lists are a relatively new feature and have been used in several short answers.

14 bytes

y0:0"wVs5

Try it here!

Prints out every second in a day. This could be useful for challenges where you have to filter by specific seconds.

y0:0"         - create the time "0:0" (0 hours and 0 minutes)
     w      -  86400. Takes the ordinate of `` - 32.
        V     - repeat ^ times: V
         s5   -   increment the seconds by 1
           \n -  print(^)

Both s and l change the amount of time by a predetermined amount. s increases and l decreases.

0 - years

1 - months

2 - days

3 - hours

4 - minutes

5 - seconds

6 - weeks

7 - 4 years

8 - decades

9 - 12 hours

15 bytes

.dȇጾȞĶl5

Try it here!

Again another dictionary command. It's up to you to understand what it does


答:
Pyke, <s>17</s> 16 bytes (noncompeting)

Pyke was created after this question was asked

```<code>TFjSF\xj\=ij*s(P
</code>```

Try it here!

```<code>TFj           (  - for j in range(10):
   SF         (  -     for i in range(1,j+1):
     \xj\=ij*s   -         sum(i,"x",j,"=",i*j)
               P - pretty_print(^)
</code>```

ContentLicense: CC BY-SA 3.0

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:
Pyke, <s>17</s> 16 bytes (noncompeting)

Pyke was created after this question was asked

TFjSF\xj\=ij*s(P

Try it here!

TFj           (  - for j in range(10):
   SF         (  -     for i in range(1,j+1):
     \xj\=ij*s   -         sum(i,"x",j,"=",i*j)
               P - pretty_print(^)


问:
Output a Magical 8 Trapezium
Your task is to output a Magical 8 Trapezium:

```<code>        1 × 8 + 1 = 9
       12 × 8 + 2 = 98
      123 × 8 + 3 = 987
     1234 × 8 + 4 = 9876
    12345 × 8 + 5 = 98765
   123456 × 8 + 6 = 987654
  1234567 × 8 + 7 = 9876543
 12345678 × 8 + 8 = 98765432
123456789 × 8 + 9 = 987654321
</code>```

Output in your chosen language in the fewest bytes possible.

Note the number of spaces at the start of each line to maintain the trapezium shape.

Trailing spaces are allowed.

You can use × or the letter x - whichever you prefer.

答:
Batch, 117 bytes

```<code>@echo off
set a=         12345678987654321
for /l %%i in (1,1,9)do call echo %%a:~%%i,9%% x 8 + %%i = %%a:~17,%%i%%
</code>```

Yes, that is 16 % signs on one line; that's Batch for you!

Title: Output a Magical 8 Trapezium

Body:
Batch, 117 bytes

@echo off
set a=         12345678987654321
for /l %%i in (1,1,9)do call echo %%a:~%%i,9%% x 8 + %%i = %%a:~17,%%i%%

Yes, that is 16 % signs on one line; that's Batch for you!


问:
Truncate consecutive character runs to n length

The challenge

Given an input string, and an integer n - truncate any runs of consecutive characters to a maximum of n length. The characters can be anything, including special characters. The function should be case sensitive, and n can range from 0 to infinity.

Example inputs/outputs:

```<code>f("aaaaaaabbbccCCCcc", 2) //"aabbccCCcc"
f("aaabbbc", 1) //"abc"
f("abcdefg", 0) //""
f("aaaaaaabccccccccCCCCCC@", 4) //"aaaabccccCCCC@"
</code>```

Scoring

The scoring is based on the number of bytes used.
Thus

```<code>function f(s,n){return s.replace(new RegExp("(.)\\1{"+n+",}","g"),function(x){return x.substr(0, n);});}
</code>```

would be 104 points.

Happy golfing!

Edit: removed language restriction, but I still would love to see javascript answers

答:
TCC, <s>7</s> 5 bytes

```<code>$~(;)
</code>```

Input is a string and a number, seperated by space.

Try it online!

```<code>       | Printing is implicit
$~     | Limit occurence
  (;   | First part of input
    )  | Second part of input
</code>```

Body:
TCC, <s>7</s> 5 bytes

$~(;)

Input is a string and a number, seperated by space.

Try it online!

       | Printing is implicit
$~     | Limit occurence
  (;   | First part of input
    )  | Second part of input


问:
Shortest code to check if a number is in a range in JavaScript
This is how I checkout to see if a number is in a range (in between two other numbers):

```<code>var a = 10,
    b = 30,
    x = 15,
    y = 35;

x < Math.max(a,b) && x > Math.min(a,b) // -> true
y < Math.max(a,b) && y > Math.min(a,b) // -> false
</code>```

I have to do this math in my code a lot and I'm looking for shorter equivalent code.

This is a shorter version I came up with. But I am sure it can get much shorter:

```<code>a < x && x < b
true
a < y && y < b
false
</code>```

But downside is I have to repeat x or y

答:
13 chars, checks both variants a<b and b<a

```<code>(x-a)*(x-b)<0
</code>```

In C may be used expression (may be also in JavaScript). 11 chars, No multiplications (fast)

```<code>(x-a^x-b)<0
</code>```

Body:
13 chars, checks both variants a<b and b<a

(x-a)*(x-b)<0

In C may be used expression (may be also in JavaScript). 11 chars, No multiplications (fast)

(x-a^x-b)<0


问:
Print the Nth non-palindromic number
A palindromic number (in case you don't know) is a number which reads the same backwards and forwards (example, 11). The first 15 non-palindromic numbers are: 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26. This is A029742. I constantly need these numbers, but my sticky note pad is very small, so your code must be as short as possible.

Rules

Each submission must be a full program or function (e.g. in C, you can't just define a function without headers, but you can define a function WITH necessary headers
).

If it is possible, provide a link to a site where your program can be tested.

Your program must not write anything to STDERR.

You can take input as an argument or from STDIN (or the closest alternative in your language).

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

Standard loopholes are forbidden.

Test Cases

```<code>1
==> 10

-----

5
==> 15

-----

12
==> 23
</code>```

Scoring

This is code-golf, so least bytes wins.

Submissions

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

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

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

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

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

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

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

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

Leaderboard

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

  });

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Java 8, <s>117</s> <s>95</s> 94 bytes

n->{int r=10;for(;n-->0;)if((++r+"").contains(new StringBuffer(r+"").reverse()))r++;return r;}
```
<p>0-indexed</p>
<p><strong>Explanation:</strong></p>
<p>Try it here.</p>
<pre class="lang-java prettyprint-override"><code>n->{             // Method with integer as both parameter and return-type
  int r=10;      //  Result-integer, starting at 10
  for(;n-->0;)   //  Loop an amount of times equal to the input
    if((++r+"")  //   First raise `r` by 1, and then check if `r`
               .contains(new StringBuffer(r+"").reverse()))
                 //   is the same as `r` reversed (and thus a palindrome)
      r++;       //    And if it is: raise `r` by 1 again
  return r;}     //  Return result-integer
</code>```

Title: Print the Nth non-palindromic number

Body:
Java 8, <s>117</s> <s>95</s> 94 bytes

n->{int r=10;for(;n-->0;)if((++r+"").contains(new StringBuffer(r+"").reverse()))r++;return r;}

0-indexed

Explanation:

Try it here.

n->{             // Method with integer as both parameter and return-type
  int r=10;      //  Result-integer, starting at 10
  for(;n-->0;)   //  Loop an amount of times equal to the input
    if((++r+"")  //   First raise `r` by 1, and then check if `r`
               .contains(new StringBuffer(r+"").reverse()))
                 //   is the same as `r` reversed (and thus a palindrome)
      r++;       //    And if it is: raise `r` by 1 again
  return r;}     //  Return result-integer

ContentLicense: CC BY-SA 4.0


问:
Missing Integer Sequence Detection -- Filesystem
The challenge is to detect missing integer sequences of files or directories. You have a directory filled with files/directories that are named as integers.

The files/directories are generated from multiple threads yet the job did not complete - there are therefore gaps in the sequence.

The input is two integers a start and an end, and your task is detect the starting integer of the next missing sequences. You may presume that all files and directories in the directory where run have only integer named files or directories.

Acceptable answer forms: functions, code snippets - they must run on the command line.

Acceptable start/end input: included on the command line, env variables/argv are okay, parameters to functions, user input is okay.

Shortest code wins.

Update -- Although I managed to squeeze out this one, there were many interesting answers. The idea in apricotboy's Bash answer was used in part to help me design my 35 Byte Bash answer. Best of luck on the next one.

```<code>E.g. Presume files 1,2,3,4,7,8,9,10,18 are present, start is 1, end is 20:

The output should be:
5
11
19
</code>```

答:
PowerShell v4+, 62 bytes

```<code>param($x,$y)$x..$y|?{$_-notin($a=(ls ".\").Name)-and$_-1-in$a}
</code>```

Save as a script in the desired directory and call it locally (see example below). Takes input $x and $y and constructs a range .., then pipes that to a Where-Object (the |?{...}) which is basically a filter. Here we're only selecting items where the current element $_ is -notin the .Name collection of the current directory, but the previous element is -in that collection (i.e., only the start of a missing range).

The ls is an alias for Get-ChildItem and is basically what you'd expect. Requires v4 for the encapsulation-select of .Name, otherwise you'd need $a=ls ".\"|select Name.

Example

```<code>PS C:\Tools\Scripts\golfing\misd> ls .\

    Directory: C:\Tools\Scripts\golfing\misd

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---         7/26/2016   7:48 AM          8 1
-a---         7/26/2016   7:48 AM         10 10
-a---         7/26/2016   7:54 AM          0 18
-a---         7/26/2016   7:48 AM          8 2
-a---         7/26/2016   7:48 AM          8 3
-a---         7/26/2016   7:48 AM          8 4
-a---         7/26/2016   7:48 AM         10 7
-a---         7/26/2016   7:48 AM          8 8
-a---         7/26/2016   7:48 AM          8 9
-a---         7/26/2016   8:18 AM        365 misd.ps1

PS C:\Tools\Scripts\golfing\misd> .\misd.ps1 1 20
5
11
19
</code>```

Body:
PowerShell v4+, 62 bytes

param($x,$y)$x..$y|?{$_-notin($a=(ls ".\").Name)-and$_-1-in$a}

Save as a script in the desired directory and call it locally (see example below). Takes input $x and $y and constructs a range .., then pipes that to a Where-Object (the |?{...}) which is basically a filter. Here we're only selecting items where the current element $_ is -notin the .Name collection of the current directory, but the previous element is -in that collection (i.e., only the start of a missing range).

The ls is an alias for Get-ChildItem and is basically what you'd expect. Requires v4 for the encapsulation-select of .Name, otherwise you'd need $a=ls ".\"|select Name.

Example

PS C:\Tools\Scripts\golfing\misd> ls .\

    Directory: C:\Tools\Scripts\golfing\misd

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---         7/26/2016   7:48 AM          8 1
-a---         7/26/2016   7:48 AM         10 10
-a---         7/26/2016   7:54 AM          0 18
-a---         7/26/2016   7:48 AM          8 2
-a---         7/26/2016   7:48 AM          8 3
-a---         7/26/2016   7:48 AM          8 4
-a---         7/26/2016   7:48 AM         10 7
-a---         7/26/2016   7:48 AM          8 8
-a---         7/26/2016   7:48 AM          8 9
-a---         7/26/2016   8:18 AM        365 misd.ps1

PS C:\Tools\Scripts\golfing\misd> .\misd.ps1 1 20
5
11
19


答:
><>, 50 bytes

```<code>1v
 1
?\::n"x"o{::n"="o}*n" "o1+:{:})
 \~1+:a=?;ao
</code>```

You can try it on the online interpreter.

Note that there is trailing spaces on each lines, which might make it incorrect (OP hasn't stated on this point as of this answer).

Title: Print this Multiplication Table

Body:
><>, 50 bytes

1v
 1
?\::n"x"o{::n"="o}*n" "o1+:{:})
 \~1+:a=?;ao

You can try it on the online interpreter.

Note that there is trailing spaces on each lines, which might make it incorrect (OP hasn't stated on this point as of this answer).


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

答:
Octave, 42bytes

Another anonymous function for Octave.

```<code>@(x)mean([x;x;x;x](:)((b=numel(x))+1:3*b))
</code>```

You can try it online. Simply enter that command, and then do ans([1 2 4 5 6 9]) or whatever numbers are required.

This one starts by creating from the input array one with 4 of each input element by first concatenating four copies vertically, and then flattening it vertically. This maintains the sort order.

Then is extracts the range of elements from the length of the input array plus 1 up to three times the length of the input array. Because the new array is four times longer, this chops off the upper and lower quartiles.

Finally the mean of the new array is returned.

Title: Interquartile Mean

Body:
Octave, 42bytes

Another anonymous function for Octave.

@(x)mean([x;x;x;x](:)((b=numel(x))+1:3*b))

You can try it online. Simply enter that command, and then do ans([1 2 4 5 6 9]) or whatever numbers are required.

This one starts by creating from the input array one with 4 of each input element by first concatenating four copies vertically, and then flattening it vertically. This maintains the sort order.

Then is extracts the range of elements from the length of the input array plus 1 up to three times the length of the input array. Because the new array is four times longer, this chops off the upper and lower quartiles.

Finally the mean of the new array is returned.


答:
Clojure, 62 bytes

```<code>#(nth(for[i(range):when(not=(seq(str i))(reverse(str i)))]i)%)
</code>```

0-indexed. Generate lazily infinite range of non-palindromic numbers using list comprehension and take ith one. See it online: https://ideone.com/54wXI3

Title: Print the Nth non-palindromic number

Body:
A palindromic number (in case you don't know) is a number which reads the same backwards and forwards (example, 11). The first 15 non-palindromic numbers are: 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26. This is A029742. I constantly need these numbers, but my sticky note pad is very small, so your code must be as short as possible.

Rules

Each submission must be a full program or function (e.g. in C, you can't just define a function without headers, but you can define a function WITH necessary headers
).

If it is possible, provide a link to a site where your program can be tested.

Your program must not write anything to STDERR.

You can take input as an argument or from STDIN (or the closest alternative in your language).

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

Standard loopholes are forbidden.

Test Cases

```<code>1
==> 10

-----

5
==> 15

-----

12
==> 23
</code>```

Scoring

This is code-golf, so least bytes wins.

Submissions

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

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

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

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

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

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

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

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

Leaderboard

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

  });

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Clojure, 62 bytes

#(nth(for[i(range):when(not=(seq(str i))(reverse(str i)))]i)%)

0-indexed. Generate lazily infinite range of non-palindromic numbers using list comprehension and take ith one. See it online: https://ideone.com/54wXI3


答:
C#, 113 bytes

```<code>void f(){for(int n=1,i=1;i<10;n=10*n+ ++i)Console.WriteLine(new string(' ',9-i)+n+" x "+"8 + "+i+" = "+(n*8+i));}
</code>```

if you have anyway to improve this solution feel free to share.

Title: Output a Magical 8 Trapezium

Body:
Your task is to output a Magical 8 Trapezium:

```<code>        1 × 8 + 1 = 9
       12 × 8 + 2 = 98
      123 × 8 + 3 = 987
     1234 × 8 + 4 = 9876
    12345 × 8 + 5 = 98765
   123456 × 8 + 6 = 987654
  1234567 × 8 + 7 = 9876543
 12345678 × 8 + 8 = 98765432
123456789 × 8 + 9 = 987654321
</code>```

Output in your chosen language in the fewest bytes possible.

Note the number of spaces at the start of each line to maintain the trapezium shape.

Trailing spaces are allowed.

You can use × or the letter x - whichever you prefer.

Body:
C#, 113 bytes

void f(){for(int n=1,i=1;i<10;n=10*n+ ++i)Console.WriteLine(new string(' ',9-i)+n+" x "+"8 + "+i+" = "+(n*8+i));}

if you have anyway to improve this solution feel free to share.


Title: Print this Multiplication Table

Body:
///, 268 bytes

/_/\/\///x/×_N/x9=_E/x8=_V/x7=_S/x6=_F/x5=_R/x4=_O/
1_t/  2_h/ 3/1x1=1Ox2=2tx2=4Ox3=3tx3=6 hx3=9OR4tR8 hR12 4R16OF5tF10hF15 4F20 5F25OS6tS12hS18 4S24 5S30 6S36OV7tV14hV21 4V28 5V35 6V42 7V49OE8tE16hE24 4E32 5E40 6E48 7E56 8E64ON9tN18hN27 4N36 5N45 6N54 7N63 8N72 9N81


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

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

Examples:

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

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

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

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

Another example, to show the difference:

```<code>Input: 10

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

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

A larger test case (CORRECT RESPONSE):

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

Rules & Guidelines:

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

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

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

The code should only output the sum.

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

Scoring:

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

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

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

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

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

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

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

答:
JavaScript (using external library) (48 bytes + 300 (penalty for library) = 348)

```<code>n=>_.Range(1,n).Sum(x=>_.From(x+"").Sum(y=>y|0))
</code>```

Link to lib: https://github.com/mvegh1/Enumerable/

Code explanation: Library creates a range starting at 1 for n elements, and sums up a complex predicate applied for each integer in the range. The predicate converts the integer to a string, and _.From converts that to a char array internally, and then those digits are summed as integers.

Title: Count sum of all digits

Body:
JavaScript (using external library) (48 bytes + 300 (penalty for library) = 348)

n=>_.Range(1,n).Sum(x=>_.From(x+"").Sum(y=>y|0))

Link to lib: https://github.com/mvegh1/Enumerable/

Code explanation: Library creates a range starting at 1 for n elements, and sums up a complex predicate applied for each integer in the range. The predicate converts the integer to a string, and _.From converts that to a char array internally, and then those digits are summed as integers.


答:
05AB1E, 15 bytes

```<code>€D€D¹gô¦¨˜DOsg/
</code>```

Explanation

```<code>€D€D             # quadruple each element in list
    ¹gô          # split into pieces the size of input
       ¦¨˜       # remove the first and last and flatten the middle 2
          DOsg/  # sum and divide by length
</code>```

Try it online

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:
05AB1E, 15 bytes

€D€D¹gô¦¨˜DOsg/

Explanation

€D€D             # quadruple each element in list
    ¹gô          # split into pieces the size of input
       ¦¨˜       # remove the first and last and flatten the middle 2
          DOsg/  # sum and divide by length

Try it online


问:
Golf the Subset-Sum Problem

Task

Given a list of space-delimited integers as input, output all unique non-empty subsets of these numbers that each subset sums to 0.

Test Case

Input:  8 −7 5 −3 −2

Output: -3 -2 5

Winning Criterion

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

答:
Python, 119 chars

```<code>def S(C,L):
 if L:S(C,L[1:]);S(C+[L[0]],L[1:])
 elif sum(map(int,C))==0and C:print' '.join(C)
S([],raw_input().split())
</code>```

Enumerates all 2^n subsets recursively and checks each one.

Title: Golf the Subset-Sum Problem

Body:
Python, 119 chars

def S(C,L):
 if L:S(C,L[1:]);S(C+[L[0]],L[1:])
 elif sum(map(int,C))==0and C:print' '.join(C)
S([],raw_input().split())

Enumerates all 2^n subsets recursively and checks each one.


答:
Java 7, <s>107</s> 106 bytes

```<code>String c(String s,int i){String x="";for(int i=-1;++i<j;)x+="$1";return s.replaceAll("(.)\\1{"+i+",}",x);}
</code>```

Previous alternative inline for-loop for String concatenation (which is 1 byte more than String s="";for(int i=-1;++i<j;)s+="$1"; unfortunately):

```<code>String c(String s,int i){return s.replaceAll("(.)\\1{"+i+",}",new String(new char[i]).replace("\0","$1")));}
</code>```

Ungolfed & test cases:

Try it here.

```<code>class Main {
  static String c(String s, int i){
    String x="";
    for(int j = -1; ++j < i;){
      x += "$1";
    }
    return s.replaceAll("(.)\\1{"+i+",}", x);
  }

  public static void main(String[] a){
    System.out.println(c("aaaaaaabbbccCCCcc", 2));
    System.out.println(c("aaabbbc", 1));
    System.out.println(c("abcdefg", 0));
    System.out.println(c("aaaaaaabccccccccCCCCCC@", 4));
    System.out.println(c("@@@@@bbbbbcccddeegffsassss", 5));
  }
}
</code>```

Output:

```<code>aabbccCCcc
abc

aaaabccccCCCC@
@@@@@bbbbbcccddeegffsassss
</code>```

Title: Truncate consecutive character runs to n length

Body:
The challenge

Given an input string, and an integer n - truncate any runs of consecutive characters to a maximum of n length. The characters can be anything, including special characters. The function should be case sensitive, and n can range from 0 to infinity.

Example inputs/outputs:

```<code>f("aaaaaaabbbccCCCcc", 2) //"aabbccCCcc"
f("aaabbbc", 1) //"abc"
f("abcdefg", 0) //""
f("aaaaaaabccccccccCCCCCC@", 4) //"aaaabccccCCCC@"
</code>```

Scoring

The scoring is based on the number of bytes used.
Thus

```<code>function f(s,n){return s.replace(new RegExp("(.)\\1{"+n+",}","g"),function(x){return x.substr(0, n);});}
</code>```

would be 104 points.

Happy golfing!

Edit: removed language restriction, but I still would love to see javascript answers

Body:
Java 7, <s>107</s> 106 bytes

String c(String s,int i){String x="";for(int i=-1;++i<j;)x+="$1";return s.replaceAll("(.)\\1{"+i+",}",x);}

Previous alternative inline for-loop for String concatenation (which is 1 byte more than String s="";for(int i=-1;++i<j;)s+="$1"; unfortunately):

String c(String s,int i){return s.replaceAll("(.)\\1{"+i+",}",new String(new char[i]).replace("\0","$1")));}

Ungolfed & test cases:

Try it here.

class Main {
  static String c(String s, int i){
    String x="";
    for(int j = -1; ++j < i;){
      x += "$1";
    }
    return s.replaceAll("(.)\\1{"+i+",}", x);
  }

  public static void main(String[] a){
    System.out.println(c("aaaaaaabbbccCCCcc", 2));
    System.out.println(c("aaabbbc", 1));
    System.out.println(c("abcdefg", 0));
    System.out.println(c("aaaaaaabccccccccCCCCCC@", 4));
    System.out.println(c("@@@@@bbbbbcccddeegffsassss", 5));
  }
}

Output:

aabbccCCcc
abc

aaaabccccCCCC@
@@@@@bbbbbcccddeegffsassss


答:
Ruby, 54 bytes

This function is 1-indexed and is partially based on Dom Hastings's Javascript answer. I think there's a way to golf this better, especially with that last ternary condition. Also, this function currently returns a string, which may need to be edited later. Any golfing suggestions are welcome.

f=->x,y=?9{x<1?y:(y.next!.reverse!=y)?f[x-1,y]:f[x,y]}
```

<p><strong>Ungolfed:</strong></p>

<pre class="lang-ruby prettyprint-override"><code>def f(x, y="9")
 if x<1
  return y
 else
  y = y.next
  if y.reverse != y
   return f(x-1, y)
  else
   return f(x, y)
  end
 end
end
</code>```

Title: Print the Nth non-palindromic number

Body:
Ruby, 54 bytes

This function is 1-indexed and is partially based on Dom Hastings's Javascript answer. I think there's a way to golf this better, especially with that last ternary condition. Also, this function currently returns a string, which may need to be edited later. Any golfing suggestions are welcome.

f=->x,y=?9{x<1?y:(y.next!.reverse!=y)?f[x-1,y]:f[x,y]}

Ungolfed:

def f(x, y="9")
 if x<1
  return y
 else
  y = y.next
  if y.reverse != y
   return f(x-1, y)
  else
   return f(x, y)
  end
 end
end


答:
Javascript (using external library) (97 bytes)

```<code>n=>_.Sequence(n,i=>{i=_.From(i+"");if(!i.Reverse().SequenceEqual(i)){return i.Write("")}}).Last()
</code>```

Link to lib: https://github.com/mvegh1/Enumerable

Code explanation: Library has static method called Sequence, where first param defines how many elements the sequence will guarantee to create, and the 2nd parameter is a predicate accepting the current iteration value, "i". The predicate converts the integer to a string, which gets converted to a char array by calling _.From. The char array is compared against the reversal of the char array, and if they are not equal the char array is joined back into a string and returned. Otherwise, nothing is returned (i.e the result is undefined, which the library will always ignore). Finally, the last element of the sequence, i.e the Nth element is returned

Title: Print the Nth non-palindromic number

Body:
Javascript (using external library) (97 bytes)

n=>_.Sequence(n,i=>{i=_.From(i+"");if(!i.Reverse().SequenceEqual(i)){return i.Write("")}}).Last()

Link to lib: https://github.com/mvegh1/Enumerable

Code explanation: Library has static method called Sequence, where first param defines how many elements the sequence will guarantee to create, and the 2nd parameter is a predicate accepting the current iteration value, "i". The predicate converts the integer to a string, which gets converted to a char array by calling _.From. The char array is compared against the reversal of the char array, and if they are not equal the char array is joined back into a string and returned. Otherwise, nothing is returned (i.e the result is undefined, which the library will always ignore). Finally, the last element of the sequence, i.e the Nth element is returned


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

```

答:
TCC, 1 byte

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

Input is 2 numbers seperated by a space

Try it online!

Title: Divisibility test

Body:
TCC, 1 byte

v

Input is 2 numbers seperated by a space

Try it online!


问:
Detriplicate a string
A lot of languages have built-in ways to get rid of duplicates, or "deduplicate" or "uniquify" a list or string. A less common task is to "detriplicate" a string. That is, for every character that appears, the first two occurrences are kept.

Here is an example where the characters that should be deleted are labelled with ^:

```<code>aaabcbccdbabdcd
  ^    ^ ^^^ ^^
aabcbcdd
</code>```

Your task is to implement exactly this operation.

Rules

Input is a single, possibly empty, string. You may assume that it only contains lowercase letters in the ASCII range.

Output should be a single string with all characters removed which have already appeared at least twice in the string (so the left-most two occurrences are kept).

Instead of strings you may work with lists of characters (or singleton strings), but the format has to be consistent between input and output.

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

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

Every pair of lines is one test case, input followed by output.

```<code>

xxxxx
xx
abcabc
abcabc
abcdabcaba
abcdabc
abacbadcba
abacbdc
aaabcbccdbabdcd
aabcbcdd
</code>```

Leaderboard

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

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

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

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

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

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

```<code>## Perl, 43 + 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

```

答:
Ruby, <s>79</s> <s>62</s> 57 bytes

This is pretty unwieldy, but I'm not sure I can golf this much better at the moment. Any golfing suggestions are welcome. Try it online!

Edit: -17 bytes thanks to Value Ink by suggesting a golfier way to remove triplicate characters. -5 bytes from removing the .uniq method.

->s{s.chars.map{|a|s[s.rindex a]=""while s.count(a)>2};s}
```

<p><strong>Ungolfed:</strong></p>

<pre class="lang-ruby prettyprint-override"><code>def g(s)
 s.chars.each do |a|
  while s.count(a) > 2
   i = s.rindex(a)
   s[i] = ""
  end
 end
 return s
end
</code>```

Title: Detriplicate a string

Body:
Ruby, <s>79</s> <s>62</s> 57 bytes

This is pretty unwieldy, but I'm not sure I can golf this much better at the moment. Any golfing suggestions are welcome. Try it online!

Edit: -17 bytes thanks to Value Ink by suggesting a golfier way to remove triplicate characters. -5 bytes from removing the .uniq method.

->s{s.chars.map{|a|s[s.rindex a]=""while s.count(a)>2};s}

Ungolfed:

def g(s)
 s.chars.each do |a|
  while s.count(a) > 2
   i = s.rindex(a)
   s[i] = ""
  end
 end
 return s
end


答:
Javascript (using external library) (74 bytes)

```<code>n=>_.Range(1,9).WriteLine(v=>_.Range(1,v).Write(" ",x=>v+"x"+x+"="+(v*x)))
</code>```

Link to lib: https://github.com/mvegh1/Enumerable

Code explanation: Create a range starting from 1, for 9 elements. For each integer in the range, write a line according to the predicate accepting the current value as the input param.

Each line in WriteLine will create a range from 1 to v, and write a space delimited string where each integer in the 1 to v sequence is mapped to the multiplication equation

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:
Javascript (using external library) (74 bytes)

n=>_.Range(1,9).WriteLine(v=>_.Range(1,v).Write(" ",x=>v+"x"+x+"="+(v*x)))

Link to lib: https://github.com/mvegh1/Enumerable

Code explanation: Create a range starting from 1, for 9 elements. For each integer in the range, write a line according to the predicate accepting the current value as the input param.

Each line in WriteLine will create a range from 1 to v, and write a space delimited string where each integer in the 1 to v sequence is mapped to the multiplication equation


答:
Kotlin, 73 bytes

```<code>(1..10).forEach{(1..it).forEach{x->print("${x}x$it=${x*it} ")};println()}
</code>```

Kotlin is the latest JVM language and I mainly wanted to try my hand at it.

You can try it on their online interpreter.

Title: Print this Multiplication Table

Body:
Kotlin, 73 bytes

(1..10).forEach{(1..it).forEach{x->print("${x}x$it=${x*it} ")};println()}

Kotlin is the latest JVM language and I mainly wanted to try my hand at it.

You can try it on their online interpreter.


答:
TCC, 11 bytes

```<code>?>!~<>;i;'T
</code>```

Try it online!

```<code>            | Printing is implicit
?>          | Find n-th number for which the following is "T":
  !~        | If not equal...
    <>;     | reverse. No value specified, so input is assumed.
       i;   | Input, since double semicolons are ignored
         'T | ... print string "T"
</code>```

Title: Print the Nth non-palindromic number

Body:
A palindromic number (in case you don't know) is a number which reads the same backwards and forwards (example, 11). The first 15 non-palindromic numbers are: 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26. This is A029742. I constantly need these numbers, but my sticky note pad is very small, so your code must be as short as possible.

Rules

Each submission must be a full program or function (e.g. in C, you can't just define a function without headers, but you can define a function WITH necessary headers
).

If it is possible, provide a link to a site where your program can be tested.

Your program must not write anything to STDERR.

You can take input as an argument or from STDIN (or the closest alternative in your language).

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

Standard loopholes are forbidden.

Test Cases

```<code>1
==> 10

-----

5
==> 15

-----

12
==> 23
</code>```

Scoring

This is code-golf, so least bytes wins.

Submissions

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

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

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

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

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

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

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

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

Leaderboard

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

  });

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
TCC, 11 bytes

?>!~<>;i;'T

Try it online!

            | Printing is implicit
?>          | Find n-th number for which the following is "T":
  !~        | If not equal...
    <>;     | reverse. No value specified, so input is assumed.
       i;   | Input, since double semicolons are ignored
         'T | ... print string "T"


Title: Print this Multiplication Table

Body:
Groovy, <s>65</s> 60 characters

1.upto(9){x->1.upto(x){printf(x+"x$it=%-3d",x*it)}println()}

Sample run:

bash-4.3$ groovy -e '1.upto(9){x->1.upto(x){printf(x+"x$it=%-3d",x*it)}println()}'
1x1=1
2x1=2  2x2=4
3x1=3  3x2=6  3x3=9
4x1=4  4x2=8  4x3=12 4x4=16
5x1=5  5x2=10 5x3=15 5x4=20 5x5=25
6x1=6  6x2=12 6x3=18 6x4=24 6x5=30 6x6=36
7x1=7  7x2=14 7x3=21 7x4=28 7x5=35 7x6=42 7x7=49
8x1=8  8x2=16 8x3=24 8x4=32 8x5=40 8x6=48 8x7=56 8x8=64
9x1=9  9x2=18 9x3=27 9x4=36 9x5=45 9x6=54 9x7=63 9x8=72 9x9=81


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

答:
Javascript (using external library) (84 bytes)

```<code>n=>_.Until((i,a)=>{l=a.length;if(a[l-1]!=n){return i<=1?i:a[l-1]+a[l-2]}}).Count()-1
</code>```

Link to lib: https://github.com/mvegh1/Enumerable

Code explanation: Library has static method that creates a sequence until the predicate has an undefined return value. The predicate has a signature of ("i"ndex, current internal "a"rray generated). At each iteration, we check if the last element of the internal array is equal to the input, n. If not, return the next value in the fib sequence. Otherwise, the predicate has an undefined result which terminates the generation of the sequence. Then, we return the length of the sequence (and subtract 1 in order to comply with the 0 based-ness as seen in the OP

Title: Fibonacci reversed!

Body:
Javascript (using external library) (84 bytes)

n=>_.Until((i,a)=>{l=a.length;if(a[l-1]!=n){return i<=1?i:a[l-1]+a[l-2]}}).Count()-1

Link to lib: https://github.com/mvegh1/Enumerable

Code explanation: Library has static method that creates a sequence until the predicate has an undefined return value. The predicate has a signature of ("i"ndex, current internal "a"rray generated). At each iteration, we check if the last element of the internal array is equal to the input, n. If not, return the next value in the fib sequence. Otherwise, the predicate has an undefined result which terminates the generation of the sequence. Then, we return the length of the sequence (and subtract 1 in order to comply with the 0 based-ness as seen in the OP


Title: Golf the Subset-Sum Problem

Body:
Task

Given a list of space-delimited integers as input, output all unique non-empty subsets of these numbers that each subset sums to 0.

Test Case

Input:  8 −7 5 −3 −2

Output: -3 -2 5

Winning Criterion

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

Body:
J, 57 53 51 49 characters

>a:-.~(#:@i.@(2&^)@#<@":@(#~0=+/)@#"1 _])".1!:1[1

Usage:

   >a:-.~(#:@i.@(2&^)@#<@":@(#~0=+/)@#"1 _])".1!:1[1
8 _7 5 _3 _2 4
5 _3 _2
_7 5 _2 4
8 _7 _3 _2 4


Title: Output a Magical 8 Trapezium

Body:
Your task is to output a Magical 8 Trapezium:

```<code>        1 × 8 + 1 = 9
       12 × 8 + 2 = 98
      123 × 8 + 3 = 987
     1234 × 8 + 4 = 9876
    12345 × 8 + 5 = 98765
   123456 × 8 + 6 = 987654
  1234567 × 8 + 7 = 9876543
 12345678 × 8 + 8 = 98765432
123456789 × 8 + 9 = 987654321
</code>```

Output in your chosen language in the fewest bytes possible.

Note the number of spaces at the start of each line to maintain the trapezium shape.

Trailing spaces are allowed.

You can use × or the letter x - whichever you prefer.

Body:
J, 51 bytes

(|."1|.\p),.' x 8 + ',"1]p,.' = ',"1]\|.p=:u:49+i.9

Creates the string 123456789 and then operates on prefixes and suffixes of it to create the output.

Usage

   (|."1|.\p),.' x 8 + ',"1]p,.' = ',"1]\|.p=:u:49+i.9
        1 x 8 + 1 = 9
       12 x 8 + 2 = 98
      123 x 8 + 3 = 987
     1234 x 8 + 4 = 9876
    12345 x 8 + 5 = 98765
   123456 x 8 + 6 = 987654
  1234567 x 8 + 7 = 9876543
 12345678 x 8 + 8 = 98765432
123456789 x 8 + 9 = 987654321


答:
Javascript (using external library) (115 bytes)

```<code>(s,r)=>_.From(s).Aggregate((c,n)=>{if(c.a!=n){c.c=1;c.a=n}else{c.c++}if(c.c<=r){c.b+=n}return c},{a:"",b:"",c:0}).b
</code>```

Link to lib: https://github.com/mvegh1/Enumerable

Code explanation: Load the string into library, which internally parses as char array. Apply an accumulator on the sequence, passing in a custom object as a seed value. Property a is the current element, b is the accumulated string, and c is the sequential count of the current element. The accumulator checks if the current iteration value, n, is equal to the last element value, c.a. If not, we reset the count to 1 and set the current element. If the count of the current element is less than or equal to the desired length, we accumulate it to the return string. Finally, we return property b, the accumulated string. Not the golfiest code, but happy I got a solution that works...

Body:
The challenge

Given an input string, and an integer n - truncate any runs of consecutive characters to a maximum of n length. The characters can be anything, including special characters. The function should be case sensitive, and n can range from 0 to infinity.

Example inputs/outputs:

```<code>f("aaaaaaabbbccCCCcc", 2) //"aabbccCCcc"
f("aaabbbc", 1) //"abc"
f("abcdefg", 0) //""
f("aaaaaaabccccccccCCCCCC@", 4) //"aaaabccccCCCC@"
</code>```

Scoring

The scoring is based on the number of bytes used.
Thus

```<code>function f(s,n){return s.replace(new RegExp("(.)\\1{"+n+",}","g"),function(x){return x.substr(0, n);});}
</code>```

would be 104 points.

Happy golfing!

Edit: removed language restriction, but I still would love to see javascript answers

Body:
Javascript (using external library) (115 bytes)

(s,r)=>_.From(s).Aggregate((c,n)=>{if(c.a!=n){c.c=1;c.a=n}else{c.c++}if(c.c<=r){c.b+=n}return c},{a:"",b:"",c:0}).b

Link to lib: https://github.com/mvegh1/Enumerable

Code explanation: Load the string into library, which internally parses as char array. Apply an accumulator on the sequence, passing in a custom object as a seed value. Property a is the current element, b is the accumulated string, and c is the sequential count of the current element. The accumulator checks if the current iteration value, n, is equal to the last element value, c.a. If not, we reset the count to 1 and set the current element. If the count of the current element is less than or equal to the desired length, we accumulate it to the return string. Finally, we return property b, the accumulated string. Not the golfiest code, but happy I got a solution that works...


答:
Perl 5.10, 48 bytes

Basically looking for the right n so that F(n) = input.

-a switch adds one byte.

```<code>$b++;while($_>$a){$c=$a;$a+=$b;$b=$c;$n++}say$n
</code>```

Try it here!

Title: Fibonacci reversed!

Body:
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>```

Body:
Perl 5.10, 48 bytes

Basically looking for the right n so that F(n) = input.

-a switch adds one byte.

$b++;while($_>$a){$c=$a;$a+=$b;$b=$c;$n++}say$n

Try it here!


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

```<code>((<.#@>)#{.@>@])]<;.1~1,2~:/\]
</code>```

Groups the input string into runs (substrings) of identical characters, and takes the minimum of the length of that run and the max length that was input for truncating the string. Then copies the first character of each run that many times.

Usage

```<code>   f =: ((<.#@>)#{.@>@])]<;.1~1,2~:/\]
   2 f 'aaaaaaabbbccCCCcc'
aabbccCCcc
   1 f 'aaabbbc'
abc
   0 f 'abcdefg'

   4 f 'aaaaaaabccccccccCCCCCC@'
aaaabccccCCCC@
</code>```

Explanation

```<code>((<.#@>)#{.@>@])]<;.1~1,2~:/\]  Input: k on LHS, s on RHS
                             ]  Get s
                        2~:/\   Test if each pair of consecutive chars are not equal
                      1,        Prepend a 1
                ]               Get s
                 <;.1~          Chop s where a 1 occurs to get the runs in s
    #@>                         Get the length of each run
  <.                            Take the min of the length and k
         {.@>@]                 Get the head of each run
        #                       Copy the head of each run min(k, len(run)) times
                                Return that string as the result
</code>```

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

((<.#@>)#{.@>@])]<;.1~1,2~:/\]

Groups the input string into runs (substrings) of identical characters, and takes the minimum of the length of that run and the max length that was input for truncating the string. Then copies the first character of each run that many times.

Usage

   f =: ((<.#@>)#{.@>@])]<;.1~1,2~:/\]
   2 f 'aaaaaaabbbccCCCcc'
aabbccCCcc
   1 f 'aaabbbc'
abc
   0 f 'abcdefg'

   4 f 'aaaaaaabccccccccCCCCCC@'
aaaabccccCCCC@

Explanation

((<.#@>)#{.@>@])]<;.1~1,2~:/\]  Input: k on LHS, s on RHS
                             ]  Get s
                        2~:/\   Test if each pair of consecutive chars are not equal
                      1,        Prepend a 1
                ]               Get s
                 <;.1~          Chop s where a 1 occurs to get the runs in s
    #@>                         Get the length of each run
  <.                            Take the min of the length and k
         {.@>@]                 Get the head of each run
        #                       Copy the head of each run min(k, len(run)) times
                                Return that string as the result


答:
Dyalog APL, <s>22</s> 20 bytes

```<code>(∊⊢↑¨⍨⎕⌊⍴¨)⊢⊂⍨1,2≠/⊢
</code>```

Prompts for n and takes input string as argument.

( the tacit function ...

    ∊ flatten

    ⊢↑¨⍨ each element of the argument (i.e. each partition) truncated to

    ⎕⌊⍴¨ the minimum of the numeric input and the current length

) [end of tacit function] applied to

⊢⊂⍨ the input partitioned at the ᴛʀᴜᴇs of

1, ᴛʀᴜᴇ prepended to (the first character is not equal to its non-extant predecessor)

2≠/⊢ the pair-wise not-equal of characters in the input

Body:
Dyalog APL, <s>22</s> 20 bytes

(∊⊢↑¨⍨⎕⌊⍴¨)⊢⊂⍨1,2≠/⊢

Prompts for n and takes input string as argument.

( the tacit function ...

    ∊ flatten

    ⊢↑¨⍨ each element of the argument (i.e. each partition) truncated to

    ⎕⌊⍴¨ the minimum of the numeric input and the current length

) [end of tacit function] applied to

⊢⊂⍨ the input partitioned at the ᴛʀᴜᴇs of

1, ᴛʀᴜᴇ prepended to (the first character is not equal to its non-extant predecessor)

2≠/⊢ the pair-wise not-equal of characters in the input


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

```

答:
Nim, <s>70</s> 56 bytes

```<code>import os,math
let x=1.paramStr.len
echo fac(x-1)^2mod x
</code>```

Uses Wilson's theorem; that is, x is prime if (x - 1)!² mod x is 1.

Takes input in unary (any character) via the first command-line argument. Outputs 1 if the input is prime, and 0 otherwise. To test:

```<code>$ nim c prime.nim
$ ./prime 11111111
0
$ ./prime 1111111
1
$ ./prime 1
0
</code>```

Note that according to the Nim os docs, this solution will not work on POSIX as paramStr isn't available for some reason.

Title: Is this number a prime?

Body:
Nim, <s>70</s> 56 bytes

import os,math
let x=1.paramStr.len
echo fac(x-1)^2mod x

Uses Wilson's theorem; that is, x is prime if (x - 1)!² mod x is 1.

Takes input in unary (any character) via the first command-line argument. Outputs 1 if the input is prime, and 0 otherwise. To test:

$ nim c prime.nim
$ ./prime 11111111
0
$ ./prime 1111111
1
$ ./prime 1
0

Note that according to the Nim os docs, this solution will not work on POSIX as paramStr isn't available for some reason.


答:
Scilab, 8 bytes

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

See the documentation. By default, discard=50, so the IQM is computed.

EDIT: You know, this is a trivial built-in answer, so I’m marking it as CW.

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:
Scilab, 8 bytes

trimmean

See the documentation. By default, discard=50, so the IQM is computed.

EDIT: You know, this is a trivial built-in answer, so I’m marking it as CW.


Title: Output a Magical 8 Trapezium

Body:
k (77 bytes)

Could probably be shortened a bit more

-1@'((|t)#\:" "),'(t#\:n),'" x 8 + ",/:n,'" = ",/:(t:"I"$'n)#\:|n:"123456789";

Example:

k)-1@'((|t)#\:" "),'(t#\:n),'" x 8 + ",/:n,'" = ",/:(t:"I"$'n)#\:|n:"123456789";
         1 x 8 + 1 = 9
        12 x 8 + 2 = 98
       123 x 8 + 3 = 987
      1234 x 8 + 4 = 9876
     12345 x 8 + 5 = 98765
    123456 x 8 + 6 = 987654
   1234567 x 8 + 7 = 9876543
  12345678 x 8 + 8 = 98765432
 123456789 x 8 + 9 = 987654321


Title: Output a Magical 8 Trapezium

Body:
Brainfuck, 232 bytes

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

Try it online!

Can be golfed much further...


问:
The Camouflage Color Changing Chameleon Challenge
Chameleon challenges are a bad thing, apparently. Too bad, chameleons are beautiful creatures. Time for a change!

As we all know, many chameleons posses a remarkable ability to blend in with their surroundings by changing the color of their skin. Which is also the objective of this challenge.

Challenge

Imagine a square of nine pixels. Eight pixels are the surroundings. At the center is the chameleon.

Like this:

The chameleon naturally tries to blend in with its surroundings. It does so by changing its color to the average of that of the surrounding pixels. So, in this case, the chameleon would change its color to .

Objective

Given the colors of the surrounding pixels, output the color of the chameleon.

The color of the chameleon is defined as the total of all red, green and blue in the pixels ÷ 8.

Input

An array of color values for the eight surrounding pixels, starting at the top left and continuing clockwise, like this:

```<code>[[<red>,<green>,<blue>],[<red>,<green>,<blue>],[<red>,<green>,<blue>],[<red>,<green>,<blue>],[<red>,<green>,<blue>],[<red>,<green>,<blue>],[<red>,<green>,<blue>],[<red>,<green>,<blue>]]
</code>```

You may choose to receive input in a different form, as long as it consists of eight triples of decimal numbers 0-255.

If you receive input in a different form, numbers must either be of a consistent length or have a non-numeric separator between them. Triples must have a separating character unless they are 0-padded to 9 digits. (E.g. 044200255044200255044200255044200255044200255044200255044200255044200255 is valid, so are 44 200 255 44 200 255 44 200 255 44 200 255 44 200 255 44 200 255 44 200 255 44 200 255 and 44?200?255$44?200?255$44?200?255$44?200?255$44?200?255$44?200?255$44?200?255$44?200?255, but 4420025544200255442002554420025544200255442002554420025544200255 is not.)

Output

An array / string / etc. containing the colors of the center pixel (in decimal), like this:

```<code>[<red>,<green>,<blue>]
</code>```

In case you output something other than an array: Numbers must either be of a consistent length or have a non-numeric separator between them. (E.g. 044200255 is valid, so is 44 200 255, but 44200255 is not.)

The numbers may not contain decimal points, so e.g. 44.0 200 255.0 is invalid.

Rounding

Output must be rounded to the nearest integer. (Halves must be rounded up.) E.g., if the sum of all red is 1620, you must output 203, not 202 or 202.5.

Examples

Pictures are for illustration only. The middle pixel is the output, the surrounding pixels are the input.

Input:

```<code>[[200,200,200],[200,200,200],[200,200,200],[200,200,200],[200,200,200],[200,200,200],[200,200,200],[200,200,200]]
</code>```

Output:

```<code>[200,200,200]
</code>```

Input:

```<code>[[0,0,0],[255,255,255],[0,0,0],[255,255,255],[255,255,255],[0,0,0],[255,255,255],[0,0,0]]
</code>```

Output:

```<code>[128,128,128]
</code>```

Input:

```<code>[[0,200,200],[200,0,200],[200,200,0],[60,200,0],[200,0,200],[0,200,220],[2,200,0],[0,0,0]]
</code>```

Output:

```<code>[83,125,103]
</code>```

Input:

```<code>[[0,56,58],[65,0,200],[33,200,0],[60,33,0],[98,0,200],[0,28,220],[2,200,0],[99,0,5]]
</code>```

Output:

```<code>[45,65,85]
</code>```

Submissions can be a full program or a function. Standard I/O and loophole rules apply.

答:
Nim, <s>134</s> <s>126</s> <s>115</s> <s>108</s> 78 bytes

```<code>import math,future
x=>lc[(lc[x[j][i]|(j<-0..7),int].sum+4)shr 3|(i<-0..2),int]
</code>```

Defines an anonymous procedure, which requires the input passed in as a double-nested sequence and outputs as a 3-element array. The procedure can only be used as an argument to another procedure; to test, use the following wrapper:

```<code>import math,future
import strutils
proc test(x: seq[seq[int]] -> seq[int]) =
 echo x(#[ Insert your input here ]#)
test(x=>lc[(lc[x[j][i]|(j<-0..7),int].sum+4)shr 3|(i<-0..2),int])
</code>```

A Nim sequence is an array with @ in front, like @[1, 2, 3]. An input to this procedure could therefore be:

```<code>@[@[0,0,0],@[255,255,255],@[0,0,0],@[255,255,255],@[255,255,255],@[0,0,0],@[255,255,255],@[0,0,0]]
</code>```

Body:
Nim, <s>134</s> <s>126</s> <s>115</s> <s>108</s> 78 bytes

import math,future
x=>lc[(lc[x[j][i]|(j<-0..7),int].sum+4)shr 3|(i<-0..2),int]

Defines an anonymous procedure, which requires the input passed in as a double-nested sequence and outputs as a 3-element array. The procedure can only be used as an argument to another procedure; to test, use the following wrapper:

import math,future
import strutils
proc test(x: seq[seq[int]] -> seq[int]) =
 echo x(#[ Insert your input here ]#)
test(x=>lc[(lc[x[j][i]|(j<-0..7),int].sum+4)shr 3|(i<-0..2),int])

A Nim sequence is an array with @ in front, like @[1, 2, 3]. An input to this procedure could therefore be:

@[@[0,0,0],@[255,255,255],@[0,0,0],@[255,255,255],@[255,255,255],@[0,0,0],@[255,255,255],@[0,0,0]]