答:
J, 10 bytes

```<code>(%1-^@-)t:
</code>```

Computes the nth Bernoulli number by finding the nth coefficient of the exponential generating function of x/(1 - e-x).

Usage

If the input is given integer or floats as an argument, it will output a float. If given an extended integer, marked with a suffix x, it will output either an extended integer or a rational, two extended integers separated by r.

```<code>   f =: (%1-^@-)t:
   f 1
0.5
   f 1x
1r2
   (,.f"0) i. 10x
0     1
1   1r2
2   1r6
3     0
4 _1r30
5     0
6  1r42
7     0
8 _1r30
9     0
</code>```

Explanation

```<code>(%1-^@-)t: Input: n
(      )t: Takes a monad and creates a new monad that
           computes the coefficients of its egf
(      )   A monad that operates on x
      -      Negate x
    ^@       Computes its exponential, e^-x
  1-         Subtract it from 1
 %           Divide x by it, x/(1 - e^-x)
</code>```

Title: Bernoulli Numbers

Body:
The Bernoulli numbers (specifically, the second Bernoulli numbers) are defined by the following recursive definition:

Where  denotes a combination.

Given a nonnegative integer m as input, output the decimal representation OR a reduced fraction for the mth second Bernoulli number. If you output a decimal representation, you must have at least 6 decimal places (digits after the decimal point) of precision, and it must be accurate when rounded to 6 decimal places. For example, for m = 2, 0.166666523 is acceptable because it rounds to 0.166667. 0.166666389 is not acceptable, because it rounds to 0.166666. Trailing zeroes may be omitted. Scientific notation may be used for decimal representations.

Here is the input and expected output for m up to and including 60, in scientific notation rounded to 6 decimal places, and as reduced fractions:

```<code>0 -> 1.000000e+00 (1/1)
1 -> 5.000000e-01 (1/2)
2 -> 1.666667e-01 (1/6)
3 -> 0.000000e+00 (0/1)
4 -> -3.333333e-02 (-1/30)
5 -> 0.000000e+00 (0/1)
6 -> 2.380952e-02 (1/42)
7 -> 0.000000e+00 (0/1)
8 -> -3.333333e-02 (-1/30)
9 -> 0.000000e+00 (0/1)
10 -> 7.575758e-02 (5/66)
11 -> 0.000000e+00 (0/1)
12 -> -2.531136e-01 (-691/2730)
13 -> 0.000000e+00 (0/1)
14 -> 1.166667e+00 (7/6)
15 -> 0.000000e+00 (0/1)
16 -> -7.092157e+00 (-3617/510)
17 -> 0.000000e+00 (0/1)
18 -> 5.497118e+01 (43867/798)
19 -> 0.000000e+00 (0/1)
20 -> -5.291242e+02 (-174611/330)
21 -> 0.000000e+00 (0/1)
22 -> 6.192123e+03 (854513/138)
23 -> 0.000000e+00 (0/1)
24 -> -8.658025e+04 (-236364091/2730)
25 -> 0.000000e+00 (0/1)
26 -> 1.425517e+06 (8553103/6)
27 -> 0.000000e+00 (0/1)
28 -> -2.729823e+07 (-23749461029/870)
29 -> 0.000000e+00 (0/1)
30 -> 6.015809e+08 (8615841276005/14322)
31 -> 0.000000e+00 (0/1)
32 -> -1.511632e+10 (-7709321041217/510)
33 -> 0.000000e+00 (0/1)
34 -> 4.296146e+11 (2577687858367/6)
35 -> 0.000000e+00 (0/1)
36 -> -1.371166e+13 (-26315271553053477373/1919190)
37 -> 0.000000e+00 (0/1)
38 -> 4.883323e+14 (2929993913841559/6)
39 -> 0.000000e+00 (0/1)
40 -> -1.929658e+16 (-261082718496449122051/13530)
41 -> 0.000000e+00 (0/1)
42 -> 8.416930e+17 (1520097643918070802691/1806)
43 -> 0.000000e+00 (0/1)
44 -> -4.033807e+19 (-27833269579301024235023/690)
45 -> 0.000000e+00 (0/1)
46 -> 2.115075e+21 (596451111593912163277961/282)
47 -> 0.000000e+00 (0/1)
48 -> -1.208663e+23 (-5609403368997817686249127547/46410)
49 -> 0.000000e+00 (0/1)
50 -> 7.500867e+24 (495057205241079648212477525/66)
51 -> 0.000000e+00 (0/1)
52 -> -5.038778e+26 (-801165718135489957347924991853/1590)
53 -> 0.000000e+00 (0/1)
54 -> 3.652878e+28 (29149963634884862421418123812691/798)
55 -> 0.000000e+00 (0/1)
56 -> -2.849877e+30 (-2479392929313226753685415739663229/870)
57 -> 0.000000e+00 (0/1)
58 -> 2.386543e+32 (84483613348880041862046775994036021/354)
59 -> 0.000000e+00 (0/1)
60 -> -2.139995e+34 (-1215233140483755572040304994079820246041491/56786730)
</code>```

Reference implementation (in Python 3):

def factorial(n):
    if n < 1:
        return 1
    else:
        return n * factorial(n - 1)

def combination(m,k):
    if k <= m:
        return factorial(m)/(factorial(k) * factorial(m - k))
    else:
        return 0

def Bernoulli(m):
    if m == 0:
        return 1
    else:
        t = 0
        for k in range(0, m):
            t += combination(m, k) * Bernoulli(k) / (m - k + 1)
        return 1 - t
```

<h3>Rules</h3>

<ul>
<li>This is code-golf, so shortest code in bytes wins</li>
<li>You may not use any functions, either built-in or included in an external library, that compute either type of Bernoulli numbers or Bernoulli polynomials.</li>
<li>Your answer must give correct output for all inputs up to and including 60.</li>
</ul>

<h1>Leaderboard</h1>

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

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

```## Language Name, N bytes
```

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

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

<p>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 <em>last</em> number in the header:</p>

```## Perl, 43 + 2 (-p flag) = 45 bytes
```

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

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

<p><div class="snippet" data-lang="js" data-hide="true" data-console="false" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-html lang-html prettyprint-override"><code><style>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; }</style><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="language-list"> <h2>Shortest Solution by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr> </thead> <tbody id="languages"> </tbody> </table> </div> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr> </thead> <tbody id="answers"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td>Link</td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td>Link</td></tr> </tbody> </table><script>var QUESTION_ID = 65382; var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk"; var OVERRIDE_USER = 45941; var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page; function answersUrl(index) { return "https://api.stackexchange.com/2.2/questions/" + QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER; } function commentUrl(index, answers) { return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER; } function getAnswers() { jQuery.ajax({ url: answersUrl(answer_page++), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { answers.push.apply(answers, data.items); answers_hash = []; answer_ids = []; data.items.forEach(function(a) { a.comments = []; var id = +a.share_link.match(/\d+/); answer_ids.push(id); answers_hash[id] = a; }); if (!data.has_more) more_answers = false; comment_page = 1; getComments(); } }); } function getComments() { jQuery.ajax({ url: commentUrl(comment_page++, answer_ids), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { data.items.forEach(function(c) { if (c.owner.user_id === OVERRIDE_USER) answers_hash[c.post_id].comments.push(c); }); if (data.has_more) getComments(); else if (more_answers) getAnswers(); else process(); } }); } getAnswers(); var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/; var OVERRIDE_REG = /^Override\s*header:\s*/i; function getAuthorName(a) { return a.owner.display_name; } function process() { var valid = []; answers.forEach(function(a) { var body = a.body; a.comments.forEach(function(c) { if(OVERRIDE_REG.test(c.body)) body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>'; }); var match = body.match(SCORE_REG); if (match) valid.push({ user: getAuthorName(a), size: +match[2], language: match[1], link: a.share_link, }); else console.log(body); }); valid.sort(function (a, b) { var aB = a.size, bB = b.size; return aB - bB }); var languages = {}; var place = 1; var lastSize = null; var lastPlace = 1; valid.forEach(function (a) { if (a.size != lastSize) lastPlace = place; lastSize = a.size; ++place; var answer = jQuery("#answer-template").html(); answer = answer.replace("{{PLACE}}", lastPlace + ".") .replace("{{NAME}}", a.user) .replace("{{LANGUAGE}}", a.language) .replace("{{SIZE}}", a.size) .replace("{{LINK}}", a.link); answer = jQuery(answer); jQuery("#answers").append(answer); var lang = a.language; lang = jQuery('<a>'+lang+'</a>').text(); languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang.toLowerCase(), user: a.user, size: a.size, link: a.link}; }); var langs = []; for (var lang in languages) if (languages.hasOwnProperty(lang)) langs.push(languages[lang]); langs.sort(function (a, b) { if (a.lang_raw > b.lang_raw) return 1; if (a.lang_raw < b.lang_raw) 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); } }</script></code>```

Body:
J, 10 bytes

(%1-^@-)t:

Computes the nth Bernoulli number by finding the nth coefficient of the exponential generating function of x/(1 - e-x).

Usage

If the input is given integer or floats as an argument, it will output a float. If given an extended integer, marked with a suffix x, it will output either an extended integer or a rational, two extended integers separated by r.

   f =: (%1-^@-)t:
   f 1
0.5
   f 1x
1r2
   (,.f"0) i. 10x
0     1
1   1r2
2   1r6
3     0
4 _1r30
5     0
6  1r42
7     0
8 _1r30
9     0

Explanation

(%1-^@-)t: Input: n
(      )t: Takes a monad and creates a new monad that
           computes the coefficients of its egf
(      )   A monad that operates on x
      -      Negate x
    ^@       Computes its exponential, e^-x
  1-         Subtract it from 1
 %           Divide x by it, x/(1 - e^-x)


问:
Find the odd one out in a sequence
The Challenge:

Consider the function F(N) = 2^N + 1 where N is a positive integer less than 31. The sequence defined by this function is:

```<code>3, 5, 9, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097, 8193, 16385, 32769, 65537, 131073, 262145, 524289, 1048577, 2097153, 4194305, 8388609, 16777217, 33554433, 67108865, 134217729, 268435457, 536870913, 1073741825
</code>```

An input will be generated as follows:

Take 5 contiguous integers from the above sequence.

Replace one of them with a different, positive integer (which may or may not be part of the above sequence).

Optionally reorder the the 5 resulting numbers.

Given such a list of 5 integers, find the one that was swapped in and is therefore not part of the original 5 contiguous integers.

Example:

Original sublist: 5, 9, 17, 33, 65.

Replace one: 5, 7, 17, 33, 65.

Reorder: 33, 17, 5, 7, 65.

The expected output would be 7.

The 5 values in the input will always be distinct and there will always be a unique solution. (For instance, you won't have to deal with inputs like 3, 9, 17, 33, 129 where either 3 or 129 might have been swapped in.)

Test Cases:

```<code>5,9,17,33,829
o/p: 829

9,5,17,829,33
o/p: 829

33, 17, 5, 7, 65
o/p: 7

5,9,177,33,65
o/p: 177

65,129,259,513,1025
o/p: 259

129,259,513,1025,65
o/p: 259

63,129,257,513,1025
o/p: 63

65,129,257,513,4097
o/p: 4097

5, 9, 2, 17, 33
o/p: 2

536870913, 67108865, 1073741825, 1, 268435457
o/p: 1
</code>```

答:
Python 2, 73 bytes

s=set(input());i,=d={1}
while~-len(s-d):i*=2;d=d-{i/32+1}|{i+1}
print s-d
```

<p>Iterates through sets <code>d</code> of five consecutive sequence elements until it finds one that contains all but one of the input elements, and then prints the difference, which is the output in a singleton set.</p>

<p>The sets <code>d</code> of five consecutive elements are built up from nothing by repeatedly adding a new element <code>i+1</code> and deleting any old element <code>i/32+1</code> that comes before the current window of 5. Here's what its progress looks like.</p>

<pre class="lang-python prettyprint-override"><code>{1}
{3}
{3, 5}
{3, 5, 9}
{3, 5, 9, 17}
{3, 5, 9, 17, 33}
{5, 9, 17, 33, 65}
{9, 17, 33, 65, 129}
{17, 33, 65, 129, 257}
{33, 65, 129, 257, 513}
</code>```

There's a stray 1 at the start from initialization, but it's harmless because it's immediately removed. The smaller sets as it builds up to 5 elements are also harmless.

ContentLicense: CC BY-SA 3.0

Title: Find the odd one out in a sequence

Body:
Python 2, 73 bytes

s=set(input());i,=d={1}
while~-len(s-d):i*=2;d=d-{i/32+1}|{i+1}
print s-d

Iterates through sets d of five consecutive sequence elements until it finds one that contains all but one of the input elements, and then prints the difference, which is the output in a singleton set.

The sets d of five consecutive elements are built up from nothing by repeatedly adding a new element i+1 and deleting any old element i/32+1 that comes before the current window of 5. Here's what its progress looks like.

{1}
{3}
{3, 5}
{3, 5, 9}
{3, 5, 9, 17}
{3, 5, 9, 17, 33}
{5, 9, 17, 33, 65}
{9, 17, 33, 65, 129}
{17, 33, 65, 129, 257}
{33, 65, 129, 257, 513}

There's a stray 1 at the start from initialization, but it's harmless because it's immediately removed. The smaller sets as it builds up to 5 elements are also harmless.


问:
The Solitude of Prime Numbers
Recently I read the novel "The Solitude of Prime Numbers" where the main characters are somewhat compared to twin prime numbers ("always together, but never touching").

A twin prime is a prime number that is either \$\require{cancel}2\$ less or \$2\$ more than another prime number —for example, the twin prime pair \$(41, 43)\$. In other words, a twin prime is a prime that has a prime gap of two. Sometimes the term twin prime is used for a pair of twin primes; an alternative name for this is prime twin or prime pair. Wikipedia

Although I didn't like much the depressing novel, and since I have fallen into PPCG lately, that raised a question in my mind...

Task:

Given a positive integer number \$N > 4\$, find the lonely prime numbers (AKA isolated prime numbers) between the closest couples of twin primes.

Please note that in this case with the term lonely prime numbers, I mean all the prime numbers that are not twin primes and between couples of twin primes. That's why \$N > 4\$ because the first two couples of prime numbers are \$(3, 5)\$ and \$(5, 7)\$.

Example:

\$N = 90\$.

Find the first two couples of twin primes \$< N\$ and \$> N\$. They are: \$(71, 73)\$ and \$(101, 103)\$.

Find the lonely primes in the range \$> 73\$ and \$< 101\$.

They are: \$79, 83, 89, 97\$.

Special cases:

- If N is in between two twin prime numbers, find the closest couples of twin primes \$> N+1\$ and \$< N-1\$. Example: \$N=72\$, find the closest couples of twin primes \$> 73\$ and \$< 71\$ then exclude from the list \$71\$ and \$73\$ because they are not *lonely primes*. So for \$N = 72\$ the expected result is:  \$67, \cancel{71}, \cancel{73}, 79, 83, 89, 97\$
- If N belongs to a couple of twin primes, for example \$N = 73\$, the closest couples of twin primes are \$(71, 73)\$ and \$(101, 103)\$. If \$N = 71\$, the closest couples of twin primes are \$(59, 61)\$ and \$(71, 73)\$.

Test cases:

```<code>N = 70   >  Lonely primes are:  67
N = 71   >  Lonely primes are:  67
N = 72   >  Lonely primes are:  67, 79, 83, 89, 97 (not the twins 71 and 73)
N = 73   >  Lonely primes are:  79, 83, 89, 97
N = 90   >  Lonely primes are:  79, 83, 89, 97
N = 201  >  Lonely primes are:  211, 223
N = 499  >  Lonely primes are:  467, 479, 487, 491, 499, 503, 509
</code>```

Rules:

Write a full program or function that will take the number N from standard input.

Output the list of lonely primes in a readable format as csv, list, array, etc.

Shortest code wins.

Please include (when possible) a testable online fiddle.

答:
Racket 245 bytes

```<code>(λ(n)(let((pl(reverse(let lp((n n)(t 0)(ol '()))(set! t(prev-prime n))(if(and(>(length ol)0)
(= 2(-(car ol)t)))(cdr ol)(lp t 0(cons t ol)))))))(let lq((n n)(t 0)(ol pl))(set! t(next-prime n))
(if(= 2(- t(car ol)))(cdr ol)(lq t 0(cons t ol))))))
</code>```

Ungolfed version:

```<code>(require math)
(define f
  (lambda(n)
    (let ((pl
           (reverse
            (let loop ((n n) (t 0) (ol '()))
              (set! t (prev-prime n))
              (if (and
                   (> (length ol) 0)
                   (= 2 (- (car ol) t)))
                  (cdr ol)
                  (loop t 0 (cons t ol)))))))
      (let loop2 ((n n) (t 0) (ol pl))
        (set! t (next-prime n))
        (if (= 2 (- t (car ol)))
            (cdr ol)
            (loop2 t 0 (cons t ol))))))
  )

(f 90)
</code>```

Output:

```<code>'(97 89 83 79)
</code>```

ContentLicense: CC BY-SA 4.0

Title: The Solitude of Prime Numbers

Body:
Racket 245 bytes

(λ(n)(let((pl(reverse(let lp((n n)(t 0)(ol '()))(set! t(prev-prime n))(if(and(>(length ol)0)
(= 2(-(car ol)t)))(cdr ol)(lp t 0(cons t ol)))))))(let lq((n n)(t 0)(ol pl))(set! t(next-prime n))
(if(= 2(- t(car ol)))(cdr ol)(lq t 0(cons t ol))))))

Ungolfed version:

(require math)
(define f
  (lambda(n)
    (let ((pl
           (reverse
            (let loop ((n n) (t 0) (ol '()))
              (set! t (prev-prime n))
              (if (and
                   (> (length ol) 0)
                   (= 2 (- (car ol) t)))
                  (cdr ol)
                  (loop t 0 (cons t ol)))))))
      (let loop2 ((n n) (t 0) (ol pl))
        (set! t (next-prime n))
        (if (= 2 (- t (car ol)))
            (cdr ol)
            (loop2 t 0 (cons t ol))))))
  )

(f 90)

Output:

'(97 89 83 79)


问:
Let's make a word-search!
In this challenge, we will together create a word-search containing many programs in different languages.

I have started us off with a grid of 60-by-25 blanks (·), some of which are replaced by the characters of a Ruby program.

To answer, choose a language that was not yet used. Using your chosen language, write a program that reads a character, token, line, or all input from the console, and prints it. Then, insert your program into the word-search.

For example, suppose you choose Python 3 for your answer, and write the program print(input()). Now you have to insert that program into the grid.

If the grid before your answer looks like this:

```<code>···a·24··········
··z····t·········
</code>```

Then you can just put your program in the second line, overlapping with the existing t:

```<code>···a·24··········
··zprint(input())
</code>```

Note that you can place your program in any direction: forward, backward, upward, downward, or diagonally, as long as it's in a straight line.

But what if the existing grid looks like this:

```<code>···a·24··········
··z····q·········
</code>```

There's no way to fit the print(input()) here without changing existing characters, which is forbidden. Instead, you can change the program:

```<code>print(
 input())
</code>```

This two-line program fits neatly:

```<code>···a·24·print(···
··z····q input())
</code>```

Here you replace a blank (·) with a space (). However, a space is just like any other character, and can not be overwritten in future programs.

Just like a one-liner, a multi-line program can be placed in any direction. For example, in a larger grid, you could do the following, by rotating the program 135° clockwise.

```<code>··········
········ ·
·······i·p
······n·r·
·····p·i··
····u·n···
···t·t····
··(·(·····
·)········
)·········
</code>```

Scoring

Your score for each answer is thirty divided by the number of characters added. Do not count characters that already existed in the grid, even if you use them yourself.

Your total score is the sum of the scores for all of your answers, multiplied by the number of answers. Highest score wins.

Rules

Every answer must be written in a different language. Languages that differ only in version number (e.g., Python 2 and Python 3) are considered the same.

Every answer must build off of the most recent valid answer. That is, take the grid of the most recent such answer, and insert your program into it.

To insert your program, replace at least one of the blanks (·) with characters of your choice. You may use existing characters from the grid in your answer, but you may not change or move any of them.

You may not insert more than 500 characters in total, across all your answers.

All characters you insert must be part of your program.

Your program may consist only of printable ASCII and newlines, but there may not be two or more consecutive newlines back-to-back.

Newlines do not count towards your score.

A full program, not just a function or snippet, is required.

The same user may not write two consecutive answers.

If someone's answer violates a rule, leave a comment. If the mistake is not fixed in 30 minutes, it should be deleted.

Used language snippet

This is a Stack Snippet, made by ETHproductions, FryAmTheEggman, and Mauris, that keeps track of users' scores and the used languages. It was originally copied from Martin Büttner's amazing template.

Original leaderboard:

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

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

Leaderboard

	Author	Score

Languages

Language	User	Score

{{PLACE}}	{{NAME}}	{{SCORE}}

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

```
</div>
</div>
</p>

<p>New (experimental) version, using a modified formula:</p>

<p><div class="snippet" data-lang="js" data-hide="true">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,r){return"http://api.stackexchange.com/2.2/answers/"+r.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var r=+e.share_link.match(/\d+/);answer_ids.push(r),answers_hash[r]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[],r={},x={};answers.forEach(function(s){var a=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(a="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var n=a.match(SCORE_REG);if(n){var t=getAuthorName(s);e.push({user:getAuthorName(s),size:+n[2],language:n[1],link:s.share_link}),r[t]=r[t]||0,r[t]+=30/+n[2]+20,x[t]=x[t]||0,x[t]++}});var s=Object.keys(r).sort(function(e,s){return r[s]-r[e]});e.sort(function(e,r){var s=e.size,a=r.size;return s-a});var a={},t=null;e.forEach(function(e){t=e.size;var r=e.language;/<a/.test(r)&&(r=jQuery(r).text()),a[r]=a[r]||{lang:e.language,user:e.user,size:e.size,link:e.link}});for(var c=0,o=1;c<s.length;c++){var i=jQuery("#author-template").html();r[s[c]]!==r[s[c-1]]&&(o=c+1);i=i.replace("{{PLACE}}",o+'.').replace("{{NAME}}",s[c]).replace("{{SCORE}}",r[s[c]].toFixed(2)),jQuery("#authors").append(jQuery(i))}var u=[];for(var m in a)a.hasOwnProperty(m)&&u.push(a[m]);u.sort(function(e,r){var s=e.lang.replace(/<.*?>/g,"").toLowerCase(),a=r.lang.replace(/<.*?>/g,"").toLowerCase();return s>a?1:a>s?-1:0});for(var l=0;l<u.length;++l){var h=jQuery("#language-template").html(),m=u[l];h=h.replace("{{LANGUAGE}}",m.lang).replace("{{NAME}}",m.user).replace("{{SIZE}}",m.size).replace("{{LINK}}",m.link),h=jQuery(h),jQuery("#languages").append(h)}}var QUESTION_ID=57327,ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",OVERRIDE_USER=16294,answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;</code>```

body{text-align:left!important}#author-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}```
<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> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="author-list"> <h2>Leaderboard</h2> <table class="author-list"> <thead> <tr><td></td><td>Author</td><td>Score</td></tr></thead> <tbody id="authors"> </tbody> </table> </div><div id="language-list"> <h2>Languages</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="author-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{SCORE}}</td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td>Link</td></tr></tbody> </table></code>```

To ensure your submission is recognized by the snippet, please use the following header template:

```<code># Language, X characters added
</code>```

答:
GNU bc, 4 characters added

read()          # the printing is implicit
```

<p><em>bc</em> is a calculator language. The only input token recognized by <code>read()</code> is a number, an allowed limitation. A trailing newline is needed when saving the code to a file.</p>

<p><strong>Run example:</strong></p>

<pre class="lang-sh prettyprint-override"><code>bc --quiet program.bc <<< 35
</code>```

New grid: my characters are added horizontally, left to right, starting from (row = 10, column = 52)

```<code>·········v---H\OIv+C+<D_Include C by GS Psgv···········;····
G`····,.·>qir@uH·  IaP.C.%······LAMBDA·USE: io·········>····
Get a chr!?pio;p···Ol···Z: say TZEROYALreadln(write(···;····
Outputs it,u··a$ ohce····.··c······ ·L·print(readline())····
and 'BZam..t···a daer····x··a·····ai ··string))·o<v;i:j;p:j·
G·······~,@s······s t=" " r t#50:20 w !,t,!······?a?·:,Eu-··
G·····main( ){printf("%c",  (getchar()));}·······pr>>:.;tg··
O·········)g·>    input('','s'))(enildr ,tnirp···h_··)·P(e··
a··········e·····n··r·····^·c···puts [gets stdin]pd····;Ct··
·······(write(read-host)····a)········r·input n$!?uread()(··
·······))E·s··w·····m·······n)···KVGH·e·print n$!·m····;.C··
········C·E·········p·······((···TIIA{print;exit}·pYEK·*·)··
$'main'H·TUPTUO·····t·00····,t···HSMI· ···r·······(······,··
 \/\I^O= ·TUPNI···S (I\\/\]]'u···XIM ·-···········$·········
  \/· ·/(println··FO) /·····'p···BBE1·main = interact id····
   \%·PQ  (read-line))······)n···YLH.·1··print(io.read())···
   A\     /-io-\············)io··EE 4n ··@.,`·····g·········
  % A\-e-<     |··········)#_(o··· V-·.··di _r(a)^v·········
 $ =      \----#·············t\·c&V ···$;di $a····)·········
{elbaworhT sworht )a][gnirtS(niam diov citats cilbup{C ssalc
;))(txen.)ni.metsyS(rennacS.litu.avaj wen(nltnirp.tuo.metsyS
··`[x.````?10xx][x.````?10xx]r··e···a b c d e f g h i·····}}
··········;>maertsoi<edulcni#p·h···=b c d e f g h i·········
····;s gnirts::dts{)(niam tni····v<   o<Ook. Ook! Ook! Ook.·
···};s<<tuoc::dts;s>>nic::dts···o>i:1+?/;][gnirtStupnI@tnirP
</code>```

Title: Let's make a word-search!

Body:
GNU bc, 4 characters added

read()          # the printing is implicit

bc is a calculator language. The only input token recognized by read() is a number, an allowed limitation. A trailing newline is needed when saving the code to a file.

Run example:

bc --quiet program.bc <<< 35

New grid: my characters are added horizontally, left to right, starting from (row = 10, column = 52)

·········v---H\OIv+C+<D_Include C by GS Psgv···········;····
G`····,.·>qir@uH·  IaP.C.%······LAMBDA·USE: io·········>····
Get a chr!?pio;p···Ol···Z: say TZEROYALreadln(write(···;····
Outputs it,u··a$ ohce····.··c······ ·L·print(readline())····
and 'BZam..t···a daer····x··a·····ai ··string))·o<v;i:j;p:j·
G·······~,@s······s t=" " r t#50:20 w !,t,!······?a?·:,Eu-··
G·····main( ){printf("%c",  (getchar()));}·······pr>>:.;tg··
O·········)g·>    input('','s'))(enildr ,tnirp···h_··)·P(e··
a··········e·····n··r·····^·c···puts [gets stdin]pd····;Ct··
·······(write(read-host)····a)········r·input n$!?uread()(··
·······))E·s··w·····m·······n)···KVGH·e·print n$!·m····;.C··
········C·E·········p·······((···TIIA{print;exit}·pYEK·*·)··
$'main'H·TUPTUO·····t·00····,t···HSMI· ···r·······(······,··
 \/\I^O= ·TUPNI···S (I\\/\]]'u···XIM ·-···········$·········
  \/· ·/(println··FO) /·····'p···BBE1·main = interact id····
   \%·PQ  (read-line))······)n···YLH.·1··print(io.read())···
   A\     /-io-\············)io··EE 4n ··@.,`·····g·········
  % A\-e-<     |··········)#_(o··· V-·.··di _r(a)^v·········
 $ =      \----#·············t\·c&V ···$;di $a····)·········
{elbaworhT sworht )a][gnirtS(niam diov citats cilbup{C ssalc
;))(txen.)ni.metsyS(rennacS.litu.avaj wen(nltnirp.tuo.metsyS
··`[x.````?10xx][x.````?10xx]r··e···a b c d e f g h i·····}}
··········;>maertsoi<edulcni#p·h···=b c d e f g h i·········
····;s gnirts::dts{)(niam tni····v<   o<Ook. Ook! Ook! Ook.·
···};s<<tuoc::dts;s>>nic::dts···o>i:1+?/;][gnirtStupnI@tnirP


答:
Racket 228 bytes

```<code>(λ(n)(let*((t 0)(lr(λ(l i)(list-ref l i)))(pl(drop(reverse(for/list((i(in-naturals))#:when(prime? i)#:final(and(> i n)
(= 2(- i t))))(set! t i)i))2)))(for/list((i(length pl))#:break(= 2(-(lr pl i)(lr pl(add1 i)))))(lr pl i))))
</code>```

Disadvantage of this version is that it finds all prime numbers till N and not just those around N.

Ungolfed version:

```<code>(define (f n)
  (let* ((t 0)
         (lr (λ(l i) (list-ref l i)))
         (pl (drop(reverse
                   (for/list ((i (in-naturals))
                              #:when (prime? i)
                              #:final (and
                                       (> i n)
                                       (= 2 (- i t))))
                     (set! t i)
                     i)) 2)))
    (for/list ((i (length pl))
               #:break (= 2 (- (lr pl i) (lr pl (add1 i)))) )
      (lr pl i)))
)
</code>```

Testing:

```<code>(f 90)
</code>```

Output:

```<code>'(97 89 83 79)
</code>```

Title: The Solitude of Prime Numbers

Body:
Recently I read the novel "The Solitude of Prime Numbers" where the main characters are somewhat compared to twin prime numbers ("always together, but never touching").

A twin prime is a prime number that is either \$\require{cancel}2\$ less or \$2\$ more than another prime number —for example, the twin prime pair \$(41, 43)\$. In other words, a twin prime is a prime that has a prime gap of two. Sometimes the term twin prime is used for a pair of twin primes; an alternative name for this is prime twin or prime pair. Wikipedia

Although I didn't like much the depressing novel, and since I have fallen into PPCG lately, that raised a question in my mind...

Task:

Given a positive integer number \$N > 4\$, find the lonely prime numbers (AKA isolated prime numbers) between the closest couples of twin primes.

Please note that in this case with the term lonely prime numbers, I mean all the prime numbers that are not twin primes and between couples of twin primes. That's why \$N > 4\$ because the first two couples of prime numbers are \$(3, 5)\$ and \$(5, 7)\$.

Example:

\$N = 90\$.

Find the first two couples of twin primes \$< N\$ and \$> N\$. They are: \$(71, 73)\$ and \$(101, 103)\$.

Find the lonely primes in the range \$> 73\$ and \$< 101\$.

They are: \$79, 83, 89, 97\$.

Special cases:

- If N is in between two twin prime numbers, find the closest couples of twin primes \$> N+1\$ and \$< N-1\$. Example: \$N=72\$, find the closest couples of twin primes \$> 73\$ and \$< 71\$ then exclude from the list \$71\$ and \$73\$ because they are not *lonely primes*. So for \$N = 72\$ the expected result is:  \$67, \cancel{71}, \cancel{73}, 79, 83, 89, 97\$
- If N belongs to a couple of twin primes, for example \$N = 73\$, the closest couples of twin primes are \$(71, 73)\$ and \$(101, 103)\$. If \$N = 71\$, the closest couples of twin primes are \$(59, 61)\$ and \$(71, 73)\$.

Test cases:

```<code>N = 70   >  Lonely primes are:  67
N = 71   >  Lonely primes are:  67
N = 72   >  Lonely primes are:  67, 79, 83, 89, 97 (not the twins 71 and 73)
N = 73   >  Lonely primes are:  79, 83, 89, 97
N = 90   >  Lonely primes are:  79, 83, 89, 97
N = 201  >  Lonely primes are:  211, 223
N = 499  >  Lonely primes are:  467, 479, 487, 491, 499, 503, 509
</code>```

Rules:

Write a full program or function that will take the number N from standard input.

Output the list of lonely primes in a readable format as csv, list, array, etc.

Shortest code wins.

Please include (when possible) a testable online fiddle.

Body:
Racket 228 bytes

(λ(n)(let*((t 0)(lr(λ(l i)(list-ref l i)))(pl(drop(reverse(for/list((i(in-naturals))#:when(prime? i)#:final(and(> i n)
(= 2(- i t))))(set! t i)i))2)))(for/list((i(length pl))#:break(= 2(-(lr pl i)(lr pl(add1 i)))))(lr pl i))))

Disadvantage of this version is that it finds all prime numbers till N and not just those around N.

Ungolfed version:

(define (f n)
  (let* ((t 0)
         (lr (λ(l i) (list-ref l i)))
         (pl (drop(reverse
                   (for/list ((i (in-naturals))
                              #:when (prime? i)
                              #:final (and
                                       (> i n)
                                       (= 2 (- i t))))
                     (set! t i)
                     i)) 2)))
    (for/list ((i (length pl))
               #:break (= 2 (- (lr pl i) (lr pl (add1 i)))) )
      (lr pl i)))
)

Testing:

(f 90)

Output:

'(97 89 83 79)


问:
Mutilating the Query
I know you've always thought about the trials and tribulations of experiencing the joys of life as a web proxy. Honestly, who hasn't? Today you're tasked with realizing this goal (at least a part of it). Website X gets a lot of traffic on the daily and is looking for a PaaS (clearly this refers to Proxy as a Service) because of the large number of users who insist on passing sensitive information via query parameters (users are silly). Your task is to remove any and all sensitive query parameters from the request before forwarding the request through to its original destination.

Input

A well-formed absolute HTTP URL that follows the URI grammar in RFC3986 Section 3.

You can assume there is no fragment

Brief format example where anything in square brackets denotes optional: http[s]://[user:pass@]host.name.com[:port]/[?param1=value1&param2=value2...]

A list of query parameters to be removed.

Output

The modified HTTP URL without the parameters defined in the input list.

Examples

```<code>http://example.com/ [foo]
> http://example.com/

http://example.com/?foo=bar []
> http://example.com/?foo=bar

http://example.com/ []
> http://example.com/

http://example.com/?foo=1&bar=2&baz=3 [foo,baz]
> http://example.com/?bar=2

http://example.com/?foo=1&bar=2&baz=3 [foo,bar,baz]
> http://example.com/

http://example.com/?foo&bar=2&baz= [foo,baz]
> http://example.com/?bar=2

http://example.com/?abc=1&def=2&baz=foo [foo,bar]
> http://example.com/?abc=1&def=2&baz=foo

http://example.com/?foobar=baz [foo]
> http://example.com/?foobar=baz

http://foo:foo@foo.com:8080/?foo=1&bar=foo [foo]
> http://foo:foo@foo.com:8080/?bar=foo
</code>```

Scoring

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

答:
PHP, not competing

Heck, PHP was made for this; why not use the actual URL?

```<code><?foreach($_GET[x]as$w)unset($_GET[$w]);
echo http,s[$_SERVER[SERVER_PORT]-443],"://",
$u=$_SERVER[PHP_AUTH_USER],($p=$_SERVER[PHP_AUTH_PW])?":$p":"","@"[!$u&!$p],
"$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]?",http_build_query($_GET);
</code>```

Save to file, call with your wanted query string plus &x[]=x&x[]=<exclude1>&x[]=<exclude2>&....

May fail on username and password (depending on wether your browser removes them or not).

Will fail if password is 0.

Title: Mutilating the Query

Body:
PHP, not competing

Heck, PHP was made for this; why not use the actual URL?

<?foreach($_GET[x]as$w)unset($_GET[$w]);
echo http,s[$_SERVER[SERVER_PORT]-443],"://",
$u=$_SERVER[PHP_AUTH_USER],($p=$_SERVER[PHP_AUTH_PW])?":$p":"","@"[!$u&!$p],
"$_SERVER[HTTP_HOST]$_SERVER[SCRIPT_NAME]?",http_build_query($_GET);

Save to file, call with your wanted query string plus &x[]=x&x[]=<exclude1>&x[]=<exclude2>&....

May fail on username and password (depending on wether your browser removes them or not).

Will fail if password is 0.


答:
R, 97 bytes

This turned out to be more difficult than I thought. I'm sure this can be golfed significantly though.

```<code>m=match(x<-sort(scan()),2^(1:31)+1);l=diff(m);ifelse(NA%in%m,x[is.na(m)],x[ifelse(l[4]>1,5,l>1)])
</code>```

Ungolfed and explained

```<code>x<-sort(scan())                  # read input from stdin and sort, store as vector
m=match(x, 2^(1:31)+1)           # generate a vector of indices for which input matches the sequence
l=diff(m)                        # vector of the difference of indices (will only contain 4 elements)
ifelse(NA%in%m,                  # if m contains NA do:
       x[is.na(m)],              # return x where no match has been found, else:
       x[ifelse(l[4]>1,5,l>1)])  # return x by index where diff>1 unless it's the last object, then return x[5]
</code>```

The match() function will return NA if the any element of the input vector is not in the sequence and consequently we can just find the index where NAexist in the input and return this: x[is.na(m)]

It gets a bit more complicated if input is part of the sequence but misplaced. Because input has been sorted, the distance between each pair of  indices should be 1. We can therefore find the misplaced element by investigating the 1st difference of the matched indices l=diff(m) and select the index for which  l>1. This would be just enough if it weren't for the fact that l contains 4 elements rather than 5. This is only a problem if the last element in the sorted input is a member of the sequence BUT not a part of the subsequence (as in the final test case). Consequently, if the 4th element >1 fetch the 5th entry in the sorted input else look for the index in the 4-length vector: x[ifelse(l[4]>1,5,l>1)]

Title: Find the odd one out in a sequence

Body:
The Challenge:

Consider the function F(N) = 2^N + 1 where N is a positive integer less than 31. The sequence defined by this function is:

```<code>3, 5, 9, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097, 8193, 16385, 32769, 65537, 131073, 262145, 524289, 1048577, 2097153, 4194305, 8388609, 16777217, 33554433, 67108865, 134217729, 268435457, 536870913, 1073741825
</code>```

An input will be generated as follows:

Take 5 contiguous integers from the above sequence.

Replace one of them with a different, positive integer (which may or may not be part of the above sequence).

Optionally reorder the the 5 resulting numbers.

Given such a list of 5 integers, find the one that was swapped in and is therefore not part of the original 5 contiguous integers.

Example:

Original sublist: 5, 9, 17, 33, 65.

Replace one: 5, 7, 17, 33, 65.

Reorder: 33, 17, 5, 7, 65.

The expected output would be 7.

The 5 values in the input will always be distinct and there will always be a unique solution. (For instance, you won't have to deal with inputs like 3, 9, 17, 33, 129 where either 3 or 129 might have been swapped in.)

Test Cases:

```<code>5,9,17,33,829
o/p: 829

9,5,17,829,33
o/p: 829

33, 17, 5, 7, 65
o/p: 7

5,9,177,33,65
o/p: 177

65,129,259,513,1025
o/p: 259

129,259,513,1025,65
o/p: 259

63,129,257,513,1025
o/p: 63

65,129,257,513,4097
o/p: 4097

5, 9, 2, 17, 33
o/p: 2

536870913, 67108865, 1073741825, 1, 268435457
o/p: 1
</code>```

Body:
R, 97 bytes

This turned out to be more difficult than I thought. I'm sure this can be golfed significantly though.

m=match(x<-sort(scan()),2^(1:31)+1);l=diff(m);ifelse(NA%in%m,x[is.na(m)],x[ifelse(l[4]>1,5,l>1)])

Ungolfed and explained

x<-sort(scan())                  # read input from stdin and sort, store as vector
m=match(x, 2^(1:31)+1)           # generate a vector of indices for which input matches the sequence
l=diff(m)                        # vector of the difference of indices (will only contain 4 elements)
ifelse(NA%in%m,                  # if m contains NA do:
       x[is.na(m)],              # return x where no match has been found, else:
       x[ifelse(l[4]>1,5,l>1)])  # return x by index where diff>1 unless it's the last object, then return x[5]

The match() function will return NA if the any element of the input vector is not in the sequence and consequently we can just find the index where NAexist in the input and return this: x[is.na(m)]

It gets a bit more complicated if input is part of the sequence but misplaced. Because input has been sorted, the distance between each pair of  indices should be 1. We can therefore find the misplaced element by investigating the 1st difference of the matched indices l=diff(m) and select the index for which  l>1. This would be just enough if it weren't for the fact that l contains 4 elements rather than 5. This is only a problem if the last element in the sorted input is a member of the sequence BUT not a part of the subsequence (as in the final test case). Consequently, if the 4th element >1 fetch the 5th entry in the sorted input else look for the index in the 4-length vector: x[ifelse(l[4]>1,5,l>1)]


问:
Perform Dempster's Rule of Combination

Crash Course on DST

Dempster–Shafer theory (DST) provides a method to combine various sources of evidence to form a belief.  Given a list of possible statement (one of which is the true answer), each possible combination of statements is assigned a "mass" indicating the degree of supporting evidence.  The total mass of all combinations is always equal to 1.

From these mass assignments, we can create a reasonable lower bound (belief) and upper bound (plausibility) on the truth of that combination.  The belief bel(X) of any set X is the sum of the masses of all of X's subsets (including itself).  The plausibility pl(X) of any set X is "1 - the sum of the masses of all sets disjoint to X". The diagram below illustrates how belief and plausibility are related to uncertainty.

For example, let's say that there is a traffic light that could be one of either Green, Yellow, or Red.  The list of options and a possible mass assignment is shown below:

```<code>binary    interpretation    m(X)    bel(X)  pl(x)
000       null              0       0       0
001       R                 0.2     0.2     0.7
010       Y                 0.1     0.1     0.3
011       Y||R              0.05    0.35    0.8
100       G                 0.2     0.2     0.65
101       G||R              0.3     0.7     0.9
110       G||Y              0       0.3     0.8
111       G||Y||R           0.15    1       1
</code>```

These masses can be notated by an array [0, 0.2, 0.1, 0.05, 0.2, 0.3, 0, 0.15].

Now the question is, how do we decide what the masses are?  Let's say that we had a sensor looking at the light, and this sensor indicates that the light not green; however, we know that there's a 20% chance that the sensor sent a random, spurious signal.  This piece of evidence can be described by the mass distribution [0, 0, 0, 0.8, 0, 0, 0, 0.2] where {Y,R} has a mass of 0.8 and {G,Y,R} has a mass of 0.2.

Similarly, let's say that some second sensor indicates that the light is not red, but we also know that there's a 30% chance the sensor is wrong and the light is actually red.  This piece of evidence can be describe by [0, 0.3, 0, 0, 0, 0, 0.7, 0] where {G,Y} has a mass of 0.7 and {R} has a mass of 0.3.

To assimilate these two pieces of evidence to form a single mass distribution, we can use Dempster's Rule of Combination.

Dempster's Rule of Combination

Two mass assignment m1 and m2 can be combined to form m1,2 using the following formulas, where A, B and C represent possible combinations (rows of the table above).

where K is a measure of "conflict," used for renormalization, and is calculated by:

It is also possible to describe this process geometrically, as in the image below.  If A = 011 (Yellow or Red) and B = 101 (Green or Red), then the value of m1(A) * m2(B) contributes to (is added to) the value of m1,2(001) (Red).  This process is repeated for all possible combinations of A and B where A&B != 0.  Finally, the array is renormalized so that the values add up to a total of 1.

Here is a simple Java method that combines two arrays following Dempster's rule:

```<code>public static double[] combine(double[] a, double[] b) {
  double[] res = new double[a.length];
  for (int i = 0; i < a.length; i++) {
    for (int j = 0; j < b.length; j++) {
      res[i & j] += a[i] * b[j];
    }
  }
  for (int i = 1; i < res.length; i++) {
    res[i] /= 1 - res[0];
  }
  res[0] = 0;
  return res;
}
</code>```

To see how this works in practice, consider the traffic light sensors above, which independently give the masses [0, 0, 0, 0.8, 0, 0, 0, 0.2] and [0, 0.3, 0, 0, 0, 0, 0.7, 0].  After performing Dempster's rule, the resulting joint mass is [0, 0.3, 0.56, 0, 0, 0, 0.14, 0].  The majority of mass is assigned to "Yellow", which makes intuitive sense given that the two sensors returned "not green" and "not red" respectively.  The other two masses (0.3 for "Red" and 0.14 for "Green or Yellow") are due to the uncertainty of the measurements.

The Challenge

Write a program that takes two lists of real numbers and outputs the result of applying Dempster's rule to the two input lists.  The lengths of the two input lists will equal, and that length will be a power of 2, and will be at least 4.  For each list, the first value will always be 0 and the remaining values will all be non-negative and add up to 1.

Output should be a list with the same length as the input lists.  You can assume that a solution exists (it is possible for a solution to not exist when there is total conflict between evidence and thus K=1).  To place a minimum requirement on precision, your program must be able to produce results that are accurate when rounded to four decimal places.

Example I/O

```<code>in:
[0, 0, 0, 0.8, 0, 0, 0, 0.2]
[0, 0.3, 0, 0, 0, 0, 0.7, 0]
out:
[0.0, 0.3, 0.56, 0.0, 0.0, 0.0, 0.14, 0.0]

in:
[0.0, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.4]
[0.0, 0.2, 0.0, 0.2, 0.0, 0.2, 0.0, 0.4]
out:
[0.0, 0.2889, 0.0889, 0.1556, 0.0889, 0.1556, 0.0444, 0.1778]

in:
[0.0, 0.0, 0.5, 0.5]
[0.0, 0.7, 0.1, 0.2]
out:
[0.0, 0.53846, 0.30769, 0.15385]

in:
[0.0, 0.055, 0.042, 0.098, 0.0, 0.152, 0.0, 0.038, 0.031, 0.13, 0.027, 0.172, 0.016, 0.114, 0.058, 0.067]
[0.0, 0.125, 0.013, 0.001, 0.012, 0.004, 0.161, 0.037, 0.009, 0.15, 0.016, 0.047, 0.096, 0.016, 0.227, 0.086]
out: (doesn't have to be this precise)
[0.0, 0.20448589713416732, 0.11767361551134202, 0.028496524069011694, 0.11809792349331062, 0.0310457664246791, 0.041882026540181416, 0.008093533320057205, 0.12095719354780314, 0.11306959103499466, 0.06412594818690368, 0.02944697394862137, 0.06398564368086611, 0.014369896989336852, 0.03774983253978312, 0.006519633578941643]

in:
[0.0, 0.0, 0.1, 0.1, 0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.1, 0.0, 0.1, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0]
[0.0, 0.0, 0.1, 0.0, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.1, 0.0, 0.0, 0.0, 0.1, 0.1, 0.0, 0.0, 0.0, 0.1, 0.0, 0.0, 0.1, 0.0, 0.0, 0.1, 0.0, 0.1, 0.0]
out:
[0.0, 0.09090909090909094, 0.23376623376623382, 0.0, 0.07792207792207795, 0.025974025974026, 0.03896103896103895, 0.0, 0.10389610389610393, 0.05194805194805199, 0.02597402597402597, 0.0, 0.012987012987012984, 0.012987012987012993, 0.012987012987012984, 0.0, 0.09090909090909094, 0.038961038961038995, 0.06493506493506492, 0.0, 0.07792207792207796, 0.0, 0.0, 0.0, 0.012987012987012984, 0.012987012987013, 0.012987012987012984, 0.0, 0.0, 0.0, 0.0, 0.0]
</code>```

答:
Perl, 68 bytes

Includes +2 for -an

Give the first set as row and the second as a column on STDIN

```<code>perl -M5.010 dempster.pl
0.0  0.0  0.5  0.5
0.0
0.7
0.1
0.2
^D
^D
</code>```

dempster.pl:

```<code>#!/usr/bin/perl -an
/$/,map$H[$m%@F&$m++/@F]+=$_*$`,@F for<>;say$%++&&$_/(1-"@H")for@H
</code>```

A pretty standard golf solution. Doesn't work if I replace @H by @;

Title: Perform Dempster's Rule of Combination

Body:
Perl, 68 bytes

Includes +2 for -an

Give the first set as row and the second as a column on STDIN

perl -M5.010 dempster.pl
0.0  0.0  0.5  0.5
0.0
0.7
0.1
0.2
^D
^D

dempster.pl:

#!/usr/bin/perl -an
/$/,map$H[$m%@F&$m++/@F]+=$_*$`,@F for<>;say$%++&&$_/(1-"@H")for@H

A pretty standard golf solution. Doesn't work if I replace @H by @;


答:
PHP, 207 bytes

<s>47</s> 54 bytes for the is_prime function that PHP does not have.
I´d beat Mathematica without that. :-D

```<code>function p($n){for($i=$n>1?$n:4;$n%--$i;);return$i<2;}if(p($n=$argv[1])&p($n+2)|$z=p($n-1)&p($n+1))$n-=2;for($n|=1;!p($n)|!p($n-2);$n--);for($z++;$z--;$n+=2)for(;$n+=2;)if(p($n)){if(p($n+2))break;echo"$n,";}
</code>```

run with -r. prints a trailing comma.

breakdown

```<code>// is_prime function:
// loops from $n-1 down to 1, breaks if it finds a divisor.
// returns true if divisor is <2 (==1)
// special case $n==1: initialize $i=4 to prevent warnings
function p($n){for($i=$n>1?$n:4;$n%--$i;);return$i<2;}

// is $n between primes?
if($z=p(1+$n=$argv[1])&p($n-1)) // set $z to go to the _second_ twin pair above
    $n-=2;
// no:
else
    if(p($n)&p($n+2))$n-=2;     // $n is part of the upper pair
    // p($n)&p($n-2):           // $n is part of the lower pair
    // else:                    // this is a lonely (isolated) prime

// 1. find closest twins <=$n
for($n|=1;!p($n)|!p($n-2);$n--);

// 2. list primes until the next twin primes
L:
for(;$n+=2;)if(p($n))
    if(p($n+2))break;       // next twin primes found: break loop
    else echo"$n,";         // isolated prime: print

// 3. if ($z) repeat (once)
$n+=2;  // skip twin pair
if($z--)goto L;
</code>```

Note:

The is_prime function actually returns true for $n<2; but at least it doesn´t produce a warning.
Insert $n= before $n>1 to fix.

Title: The Solitude of Prime Numbers

Body:
PHP, 207 bytes

<s>47</s> 54 bytes for the is_prime function that PHP does not have.
I´d beat Mathematica without that. :-D

function p($n){for($i=$n>1?$n:4;$n%--$i;);return$i<2;}if(p($n=$argv[1])&p($n+2)|$z=p($n-1)&p($n+1))$n-=2;for($n|=1;!p($n)|!p($n-2);$n--);for($z++;$z--;$n+=2)for(;$n+=2;)if(p($n)){if(p($n+2))break;echo"$n,";}

run with -r. prints a trailing comma.

breakdown

// is_prime function:
// loops from $n-1 down to 1, breaks if it finds a divisor.
// returns true if divisor is <2 (==1)
// special case $n==1: initialize $i=4 to prevent warnings
function p($n){for($i=$n>1?$n:4;$n%--$i;);return$i<2;}

// is $n between primes?
if($z=p(1+$n=$argv[1])&p($n-1)) // set $z to go to the _second_ twin pair above
    $n-=2;
// no:
else
    if(p($n)&p($n+2))$n-=2;     // $n is part of the upper pair
    // p($n)&p($n-2):           // $n is part of the lower pair
    // else:                    // this is a lonely (isolated) prime

// 1. find closest twins <=$n
for($n|=1;!p($n)|!p($n-2);$n--);

// 2. list primes until the next twin primes
L:
for(;$n+=2;)if(p($n))
    if(p($n+2))break;       // next twin primes found: break loop
    else echo"$n,";         // isolated prime: print

// 3. if ($z) repeat (once)
$n+=2;  // skip twin pair
if($z--)goto L;

Note:

The is_prime function actually returns true for $n<2; but at least it doesn´t produce a warning.
Insert $n= before $n>1 to fix.


问:
Outputting ordinal numbers (1st, 2nd, 3rd)
I would like to generate (as a return result of a function, or simply as the output of a program) the ordinal suffix of a positive integer concatenated to the number.

Samples:

```<code>1st
2nd
3rd
4th
...
11th
12th
13th
...
20th
21st
22nd
23rd
24th
</code>```

And so on, with the suffix repeating the initial 1-10 subpattern every 10 until 100, where the pattern ultimately starts over.

The input would be the number and the output the ordinal string as shown above.

What is the smallest algorithm for this?

答:
C#, 62 bytes

```<code>n=>n+(n/10%10==1||(n%=10)<1||n>3?"th":n<2?"st":n<3?"nd":"rd");
</code>```

Full program and verification:

```<code>using System;

namespace OutputOrdinalNumbers
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<int,string>f= n=>n+(n/10%10==1||(n%=10)<1||n>3?"th":n<2?"st":n<3?"nd":"rd");

            for (int i=1; i<=124; i++)
                Console.WriteLine(f(i));
        }
    }
}
</code>```

Body:
C#, 62 bytes

n=>n+(n/10%10==1||(n%=10)<1||n>3?"th":n<2?"st":n<3?"nd":"rd");

Full program and verification:

using System;

namespace OutputOrdinalNumbers
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<int,string>f= n=>n+(n/10%10==1||(n%=10)<1||n>3?"th":n<2?"st":n<3?"nd":"rd");

            for (int i=1; i<=124; i++)
                Console.WriteLine(f(i));
        }
    }
}


问:
Alphabet Spiral
You are to write a program or function that outputs this exact text:

```<code>OPQRSTU
NQPONMV
MREDCLW
LSFABKX
KTGHIJY
JUVWXYZA
IHGFEDCB
</code>```

May also be lowercase and trailing spaces and newlines are allowed.

Standard loopholes are disallowed

This is code-golf, so smallest byte count wins.

答:
///, 57 bytes

```<code>OPQRSTU
NQPONMV
MREDCLW
LSFABKX
KTGHIJY
JUVWXYZA
IHGFEDCB
</code>```

Try it online!

Just another boring answer. Move on!

Title: Alphabet Spiral

Body:
///, 57 bytes

OPQRSTU
NQPONMV
MREDCLW
LSFABKX
KTGHIJY
JUVWXYZA
IHGFEDCB

Try it online!

Just another boring answer. Move on!


Title: The Solitude of Prime Numbers

Body:
Haskell, 105 bytes

p x=all((>0).mod x)[2..x-1]
a%x=until(\z->p z&&p(z+2*a))(+a)x
f n=[x|x<-[(-1)%n+1..1%n-1],p x,1%x>x,(-1)%x<x]

Try it Online


问:
Output a string's cumulative slope

Challenge

Given a string such as Hello World!, break it down into its character values: 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33.

Then calculate the difference between each consecutive pair of characters: 29, 7, 0, 3, -79, 55, 24, 3, -6, -8, -67.

Finally, sum them and print the final result: -39.

Rules

Standard loopholes apply

No using pre-made functions that perform this exact task

Creative solutions encouraged

Have fun

This is marked as code-golf, the shortest answer in bytes wins but will not be selected.

答:
Racket 121 bytes

```<code>(λ(s)(let((l(map char->integer(string->list s))))(for/sum((i(range 1(length l))))(-(list-ref l i)(list-ref l(- i 1))))))
</code>```

Ungolfed version

```<code>(define f
  (λ(s)
    (let ((l (map char->integer
                   (string->list s))))
      (for/sum ((i (range 1 (length l))))
        (- (list-ref l i)
           (list-ref l (- i 1)))))))
</code>```

Testing

```<code>(f "Hello World!")

-39
</code>```

Title: Output a string's cumulative slope

Body:
Racket 121 bytes

(λ(s)(let((l(map char->integer(string->list s))))(for/sum((i(range 1(length l))))(-(list-ref l i)(list-ref l(- i 1))))))

Ungolfed version

(define f
  (λ(s)
    (let ((l (map char->integer
                   (string->list s))))
      (for/sum ((i (range 1 (length l))))
        (- (list-ref l i)
           (list-ref l (- i 1)))))))

Testing

(f "Hello World!")

-39


答:
TSQL, 115 bytes

After some golfing I was finally able to replace -IIF(@<0,@,@+1)/2 with (@+ABS(@%2))/-2 saving 2 bytes.

Golfed:

```<code>DECLARE @i varchar(max)='*///*-*+-+'
,@ INT=0WHILE @i>''SELECT @+=CHOOSE(CHARINDEX(LEFT(@i,1),'+-*/'),1,-1,@,(@+ABS(@%2))/-2),@i=STUFF(@i,1,1,'')PRINT @
</code>```

Ungolfed:

```<code>DECLARE @i varchar(max)='*///*-*+-+'

,@ INT=0
WHILE @i>''
  SELECT @+=CHOOSE(CHARINDEX(LEFT(@i,1),'+-*/'),1,-1,@,(@+ABS(@%2))/-2),
  @i=STUFF(@i,1,1,'')
PRINT @
</code>```

Fiddle

Title: Simple integer operation calculator

Body:
Implement a simple integer operation scriptable calculator.

Concept

The accumulator starts at 0 and has operations performed on it. At the end of the program output the value of the accumulator.

Operations:

+ adds 1 to the accumulator

- subtracts 1 from the accumulator

* multiplies the accumulator by 2

/ divides the accumulator by 2

Sample script

The input ++**--/ should give the output 3.

Example implementation

```<code>def calc(s)
    i = 0
    s.chars.each do |o|
        case o
            when '+'
                i += 1
            when '-'
                i -= 1
            when '*'
                i *= 2
            when '/'
                i /= 2
        end
    end
    return i
end
</code>```

Rules

This is code-golf, so lowest answer in bytes wins, but is not selected.

Creative implementations are encouraged.

Standard loopholes are prohibited.

You get the program via stdin or arguments, and you can output the answer via return value or stdout.

Have fun.

Division truncates down because it is integer division.

The program -/ returns -1.

Test cases

```<code>*///*-*+-+
-1
/*+/*+++/*///*/+-+//*+-+-/----*-*-+++*+**+/*--///+*-/+//*//-+++--++/-**--/+--/*-/+*//*+-*-*/*+*+/+*-
-17
+++-+--/-*/---++/-+*-//+/++-*--+*+/*/*/++--++-+//++--*/***-*+++--+-*//-*/+*/+-*++**+--*/*//-*--**-/-*+**-/*-**/*+*-*/--+/+/+//-+*/---///+**////-*//+-+-/+--/**///*+//+++/+*++**++//**+**+-*/+/*/*++-/+**+--+*++++/-*-/*+--/++*/-++/-**++++/-/+/--*/-/+---**//*///-//*+-*----+//--/-/+*/-+++-+*-*+*+-/-//*-//+/*-+//+/+/*-/-/+//+**/-****/-**-//+/+-+/*-+*++*/-/++*/-//*--+*--/-+-+/+/**/-***+/-/++-++*+*-+*+*-+-//+/-++*+/*//*-+/+*/-+/-/*/-/-+*+**/*//*+/+---+*+++*+/+-**/-+-/+*---/-*+/-++*//*/-+-*+--**/-////*/--/*--//-**/*++*+/*+/-+/--**/*-+*+/+-*+*+--*///+-++/+//+*/-+/**--//*/+++/*+*////+-*-//--*+/*/-+**/*//+*+-//+--+*-+/-**-*/+//*+---*+//*/+**/*--/--+/*-*+*++--*+//+*+-++--+-*-*-+--**+/+*-/+*+-/---+-*+-+-/++/+*///*/*-+-*//-+-++/++/*/-++/**--+-////-//+/*//+**/*+-+/+/+///*+*///*-/+/*/-//-*-**//-/-+--+/-*--+-++**++//*--/*++--*-/-///-+/+//--+*//-**-/*-*/+*/-*-*//--++*//-*/++//+/-++-+-*/*-+++**-/-*++++**+-+++-+-***-+//+-/**-+/*+****-*+++*/-*-/***/-/*+/*****++*+/-/-**-+-*-*-++**/*+-/*-+*++-/+/-++*-/*-****-*
18773342
</code>```

Body:
TSQL, 115 bytes

After some golfing I was finally able to replace -IIF(@<0,@,@+1)/2 with (@+ABS(@%2))/-2 saving 2 bytes.

Golfed:

DECLARE @i varchar(max)='*///*-*+-+'
,@ INT=0WHILE @i>''SELECT @+=CHOOSE(CHARINDEX(LEFT(@i,1),'+-*/'),1,-1,@,(@+ABS(@%2))/-2),@i=STUFF(@i,1,1,'')PRINT @

Ungolfed:

DECLARE @i varchar(max)='*///*-*+-+'

,@ INT=0
WHILE @i>''
  SELECT @+=CHOOSE(CHARINDEX(LEFT(@i,1),'+-*/'),1,-1,@,(@+ABS(@%2))/-2),
  @i=STUFF(@i,1,1,'')
PRINT @

Fiddle


问:
Match the Stack Exchange URLs

Prologue

After installing an anti-XSS browser extension, Stack Snippets suddenly stopped working all across the Stack Exchange network. I could no longer learn from Stack Overflow, see working demos on User Experience and, worst of all, could not test JavaScript answers on Programming Puzzles and Code Golf! Desperately I searched for a remedy, and found a small input box in the settings, in which could place a single regex. I couldn't fit all of the Stack Exchange sites in this one, small box, so I asked for help. This is that question.

Task

Your task is to create a regular expression that matches all of the Stack Exchange website URLs, without matching any domains not owned by Stack Overflow Inc..

Your regular expression must match all URLs with the following parts:

protocol: this will either be http:// or https://.

domain: this will be an item from this list:

```<code>stackoverflow.com
www.stackoverflow.com
facebook.stackoverflow.com
serverfault.com
superuser.com
meta.stackexchange.com
webapps.stackexchange.com
nothingtoinstall.com
meta.webapps.stackexchange.com
meta.nothingtoinstall.com
gaming.stackexchange.com
arqade.com
thearqade.com
meta.gaming.stackexchange.com
meta.arqade.com
meta.thearqade.com
webmasters.stackexchange.com
webmaster.stackexchange.com
meta.webmasters.stackexchange.com
meta.webmaster.stackexchange.com
cooking.stackexchange.com
seasonedadvice.com
meta.cooking.stackexchange.com
meta.seasonedadvice.com
gamedev.stackexchange.com
meta.gamedev.stackexchange.com
photo.stackexchange.com
photography.stackexchange.com
photos.stackexchange.com
meta.photo.stackexchange.com
meta.photography.stackexchange.com
meta.photos.stackexchange.com
stats.stackexchange.com
statistics.stackexchange.com
crossvalidated.com
meta.stats.stackexchange.com
meta.statistics.stackexchange.com
math.stackexchange.com
maths.stackexchange.com
mathematics.stackexchange.com
meta.math.stackexchange.com
diy.stackexchange.com
meta.diy.stackexchange.com
meta.superuser.com
meta.serverfault.com
gis.stackexchange.com
meta.gis.stackexchange.com
tex.stackexchange.com
meta.tex.stackexchange.com
askubuntu.com
ubuntu.stackexchange.com
meta.askubuntu.com
meta.ubuntu.stackexchange.com
money.stackexchange.com
basicallymoney.com
www.basicallymoney.com
meta.money.stackexchange.com
english.stackexchange.com
elu.stackexchange.com
meta.english.stackexchange.com
stackapps.com
ux.stackexchange.com
ui.stackexchange.com
meta.ux.stackexchange.com
meta.ui.stackexchange.com
unix.stackexchange.com
linux.stackexchange.com
meta.unix.stackexchange.com
meta.linux.stackexchange.com
wordpress.stackexchange.com
meta.wordpress.stackexchange.com
cstheory.stackexchange.com
meta.cstheory.stackexchange.com
apple.stackexchange.com
askdifferent.com
meta.apple.stackexchange.com
rpg.stackexchange.com
meta.rpg.stackexchange.com
bicycles.stackexchange.com
bicycle.stackexchange.com
cycling.stackexchange.com
bikes.stackexchange.com
meta.bicycles.stackexchange.com
meta.bicycle.stackexchange.com
programmers.stackexchange.com
programmer.stackexchange.com
meta.programmers.stackexchange.com
electronics.stackexchange.com
chiphacker.com
www.chiphacker.com
meta.electronics.stackexchange.com
android.stackexchange.com
meta.android.stackexchange.com
boardgames.stackexchange.com
boardgame.stackexchange.com
meta.boardgames.stackexchange.com
physics.stackexchange.com
meta.physics.stackexchange.com
homebrew.stackexchange.com
homebrewing.stackexchange.com
brewadvice.com
meta.homebrew.stackexchange.com
meta.homebrewing.stackexchange.com
security.stackexchange.com
itsecurity.stackexchange.com
meta.security.stackexchange.com
meta.itsecurity.stackexchange.com
writers.stackexchange.com
writer.stackexchange.com
writing.stackexchange.com
meta.writers.stackexchange.com
video.stackexchange.com
avp.stackexchange.com
meta.video.stackexchange.com
meta.avp.stackexchange.com
graphicdesign.stackexchange.com
graphicsdesign.stackexchange.com
graphicdesigns.stackexchange.com
meta.graphicdesign.stackexchange.com
dba.stackexchange.com
meta.dba.stackexchange.com
scifi.stackexchange.com
sciencefiction.stackexchange.com
fantasy.stackexchange.com
meta.scifi.stackexchange.com
codereview.stackexchange.com
meta.codereview.stackexchange.com
codegolf.stackexchange.com
meta.codegolf.stackexchange.com
quant.stackexchange.com
meta.quant.stackexchange.com
pm.stackexchange.com
meta.pm.stackexchange.com
skeptics.stackexchange.com
skeptic.stackexchange.com
skepticexchange.com
meta.skeptics.stackexchange.com
fitness.stackexchange.com
meta.fitness.stackexchange.com
drupal.stackexchange.com
meta.drupal.stackexchange.com
mechanics.stackexchange.com
garage.stackexchange.com
meta.mechanics.stackexchange.com
meta.garage.stackexchange.com
parenting.stackexchange.com
meta.parenting.stackexchange.com
sharepoint.stackexchange.com
sharepointoverflow.com
www.sharepointoverflow.com
meta.sharepoint.stackexchange.com
music.stackexchange.com
guitars.stackexchange.com
guitar.stackexchange.com
meta.music.stackexchange.com
sqa.stackexchange.com
meta.sqa.stackexchange.com
judaism.stackexchange.com
mi.yodeya.com
yodeya.com
yodeya.stackexchange.com
miyodeya.com
meta.judaism.stackexchange.com
german.stackexchange.com
deutsch.stackexchange.com
meta.german.stackexchange.com
japanese.stackexchange.com
meta.japanese.stackexchange.com
philosophy.stackexchange.com
meta.philosophy.stackexchange.com
gardening.stackexchange.com
landscaping.stackexchange.com
meta.gardening.stackexchange.com
travel.stackexchange.com
meta.travel.stackexchange.com
productivity.stackexchange.com
meta.productivity.stackexchange.com
crypto.stackexchange.com
cryptography.stackexchange.com
meta.crypto.stackexchange.com
meta.cryptography.stackexchange.com
dsp.stackexchange.com
signals.stackexchange.com
meta.dsp.stackexchange.com
french.stackexchange.com
meta.french.stackexchange.com
christianity.stackexchange.com
meta.christianity.stackexchange.com
bitcoin.stackexchange.com
meta.bitcoin.stackexchange.com
linguistics.stackexchange.com
linguist.stackexchange.com
meta.linguistics.stackexchange.com
hermeneutics.stackexchange.com
meta.hermeneutics.stackexchange.com
history.stackexchange.com
meta.history.stackexchange.com
bricks.stackexchange.com
meta.bricks.stackexchange.com
spanish.stackexchange.com
espanol.stackexchange.com
meta.spanish.stackexchange.com
scicomp.stackexchange.com
meta.scicomp.stackexchange.com
movies.stackexchange.com
meta.movies.stackexchange.com
chinese.stackexchange.com
meta.chinese.stackexchange.com
biology.stackexchange.com
meta.biology.stackexchange.com
poker.stackexchange.com
meta.poker.stackexchange.com
mathematica.stackexchange.com
meta.mathematica.stackexchange.com
cogsci.stackexchange.com
meta.cogsci.stackexchange.com
outdoors.stackexchange.com
meta.outdoors.stackexchange.com
martialarts.stackexchange.com
meta.martialarts.stackexchange.com
sports.stackexchange.com
meta.sports.stackexchange.com
academia.stackexchange.com
academics.stackexchange.com
meta.academia.stackexchange.com
cs.stackexchange.com
computerscience.stackexchange.com
meta.cs.stackexchange.com
workplace.stackexchange.com
meta.workplace.stackexchange.com
windowsphone.stackexchange.com
meta.windowsphone.stackexchange.com
chemistry.stackexchange.com
meta.chemistry.stackexchange.com
chess.stackexchange.com
meta.chess.stackexchange.com
raspberrypi.stackexchange.com
meta.raspberrypi.stackexchange.com
russian.stackexchange.com
meta.russian.stackexchange.com
islam.stackexchange.com
meta.islam.stackexchange.com
salesforce.stackexchange.com
meta.salesforce.stackexchange.com
patents.stackexchange.com
askpatents.com
askpatents.stackexchange.com
meta.patents.stackexchange.com
meta.askpatents.com
meta.askpatents.stackexchange.com
genealogy.stackexchange.com
meta.genealogy.stackexchange.com
robotics.stackexchange.com
meta.robotics.stackexchange.com
expressionengine.stackexchange.com
meta.expressionengine.stackexchange.com
politics.stackexchange.com
meta.politics.stackexchange.com
anime.stackexchange.com
meta.anime.stackexchange.com
magento.stackexchange.com
meta.magento.stackexchange.com
ell.stackexchange.com
meta.ell.stackexchange.com
sustainability.stackexchange.com
meta.sustainability.stackexchange.com
tridion.stackexchange.com
meta.tridion.stackexchange.com
reverseengineering.stackexchange.com
meta.reverseengineering.stackexchange.com
networkengineering.stackexchange.com
meta.networkengineering.stackexchange.com
opendata.stackexchange.com
meta.opendata.stackexchange.com
freelancing.stackexchange.com
meta.freelancing.stackexchange.com
blender.stackexchange.com
meta.blender.stackexchange.com
mathoverflow.net
mathoverflow.stackexchange.com
mathoverflow.com
meta.mathoverflow.net
space.stackexchange.com
thefinalfrontier.stackexchange.com
meta.space.stackexchange.com
sound.stackexchange.com
socialsounddesign.com
sounddesign.stackexchange.com
meta.sound.stackexchange.com
astronomy.stackexchange.com
meta.astronomy.stackexchange.com
tor.stackexchange.com
meta.tor.stackexchange.com
pets.stackexchange.com
meta.pets.stackexchange.com
ham.stackexchange.com
meta.ham.stackexchange.com
italian.stackexchange.com
meta.italian.stackexchange.com
pt.stackoverflow.com
br.stackoverflow.com
stackoverflow.com.br
meta.pt.stackoverflow.com
meta.br.stackoverflow.com
aviation.stackexchange.com
meta.aviation.stackexchange.com
ebooks.stackexchange.com
meta.ebooks.stackexchange.com
alcohol.stackexchange.com
beer.stackexchange.com
dranks.stackexchange.com
meta.alcohol.stackexchange.com
meta.beer.stackexchange.com
softwarerecs.stackexchange.com
meta.softwarerecs.stackexchange.com
arduino.stackexchange.com
meta.arduino.stackexchange.com
cs50.stackexchange.com
meta.cs50.stackexchange.com
expatriates.stackexchange.com
expats.stackexchange.com
meta.expatriates.stackexchange.com
matheducators.stackexchange.com
meta.matheducators.stackexchange.com
meta.stackoverflow.com
earthscience.stackexchange.com
meta.earthscience.stackexchange.com
joomla.stackexchange.com
meta.joomla.stackexchange.com
datascience.stackexchange.com
meta.datascience.stackexchange.com
puzzling.stackexchange.com
meta.puzzling.stackexchange.com
craftcms.stackexchange.com
meta.craftcms.stackexchange.com
buddhism.stackexchange.com
meta.buddhism.stackexchange.com
hinduism.stackexchange.com
meta.hinduism.stackexchange.com
communitybuilding.stackexchange.com
moderator.stackexchange.com
moderators.stackexchange.com
meta.communitybuilding.stackexchange.com
meta.moderators.stackexchange.com
startups.stackexchange.com
meta.startups.stackexchange.com
worldbuilding.stackexchange.com
meta.worldbuilding.stackexchange.com
ja.stackoverflow.com
jp.stackoverflow.com
meta.ja.stackoverflow.com
emacs.stackexchange.com
meta.emacs.stackexchange.com
hsm.stackexchange.com
meta.hsm.stackexchange.com
economics.stackexchange.com
meta.economics.stackexchange.com
lifehacks.stackexchange.com
meta.lifehacks.stackexchange.com
engineering.stackexchange.com
meta.engineering.stackexchange.com
coffee.stackexchange.com
meta.coffee.stackexchange.com
vi.stackexchange.com
vim.stackexchange.com
meta.vi.stackexchange.com
musicfans.stackexchange.com
meta.musicfans.stackexchange.com
woodworking.stackexchange.com
meta.woodworking.stackexchange.com
civicrm.stackexchange.com
meta.civicrm.stackexchange.com
health.stackexchange.com
meta.health.stackexchange.com
ru.stackoverflow.com
hashcode.ru
stackoverflow.ru
meta.ru.stackoverflow.com
meta.hashcode.ru
rus.stackexchange.com
russ.hashcode.ru
russ.stackexchange.com
meta.rus.stackexchange.com
mythology.stackexchange.com
meta.mythology.stackexchange.com
law.stackexchange.com
meta.law.stackexchange.com
opensource.stackexchange.com
meta.opensource.stackexchange.com
elementaryos.stackexchange.com
meta.elementaryos.stackexchange.com
portuguese.stackexchange.com
meta.portuguese.stackexchange.com
computergraphics.stackexchange.com
meta.computergraphics.stackexchange.com
hardwarerecs.stackexchange.com
meta.hardwarerecs.stackexchange.com
es.stackoverflow.com
meta.es.stackoverflow.com
3dprinting.stackexchange.com
threedprinting.stackexchange.com
meta.3dprinting.stackexchange.com
ethereum.stackexchange.com
meta.ethereum.stackexchange.com
latin.stackexchange.com
meta.latin.stackexchange.com
languagelearning.stackexchange.com
meta.languagelearning.stackexchange.com
retrocomputing.stackexchange.com
meta.retrocomputing.stackexchange.com
crafts.stackexchange.com
meta.crafts.stackexchange.com
korean.stackexchange.com
meta.korean.stackexchange.com
monero.stackexchange.com
meta.monero.stackexchange.com
ai.stackexchange.com
meta.ai.stackexchange.com
esperanto.stackexchange.com
meta.esperanto.stackexchange.com
sitecore.stackexchange.com
meta.sitecore.stackexchange.com
</code>```

page: this will either be the empty string, / or / followed by any string

The url will be the string created by appending protocol, domain and page to each other, in that order.

Testcases

Your regex must match:

```<code>https://codegolf.stackexchange.com/
http://retrocomputing.stackexchange.com
https://facebook.stackoverflow.com/questions/1234
http://meta.nothingtoinstall.com/thisisa404.php?file=command.com
</code>```

Your regex must not match:

```<code>http//codegolf.stackexchange.com/
https://meta.stackoverflow.com.fakesite.dodgy/cgi-bin/virus.cgi?vector=apt
file://www.stackoverflow.com/
http://ripoff.com/stackoverflow.com/q/1234/
</code>```

Your regex may match:

```<code>http://panda.stackexchange.com/
https://www.meta.codegolf.stackexchange.com
http://alpha.beta.charlie.delta.chiphacker.com
https://stackexchange.com/sites/
</code>```

because these are owned by Stack Exchange Inc. and so will not be vulnerable to XSS attacks.

This is a code-golf challenge, so the shortest regular expression wins!

答:
<s>142</s> <s>140</s> 334 bytes

```<code>#^https?:\/\/([^\/]*\.)?(hashcode\.ru|mathoverflow\.(com|net)|stackoverflow\.(ru|com(\.br)?)|((stack|skeptic)exchange|stackapps|ask(different|patents|ubuntu)|(brew|seasoned)advice|(the)?arqade|basicallymoney|chiphacker|crossvalidated|nothingtoinstall|serverfault|sharepointoverflow|socialsounddesign|superuser|(mi)?yodeya)\.com)(/|$)#
</code>```

matches everything on the specified second level domains, path or no path

uses # as delimiter so / needs no escaping (saved two bytes)

compressed manually

Title: Match the Stack Exchange URLs

Body:
<s>142</s> <s>140</s> 334 bytes

#^https?:\/\/([^\/]*\.)?(hashcode\.ru|mathoverflow\.(com|net)|stackoverflow\.(ru|com(\.br)?)|((stack|skeptic)exchange|stackapps|ask(different|patents|ubuntu)|(brew|seasoned)advice|(the)?arqade|basicallymoney|chiphacker|crossvalidated|nothingtoinstall|serverfault|sharepointoverflow|socialsounddesign|superuser|(mi)?yodeya)\.com)(/|$)#

matches everything on the specified second level domains, path or no path

uses # as delimiter so / needs no escaping (saved two bytes)

compressed manually


问:
Checkers: King Me?

Challenge:

Given a checkerboard, output the smallest amount of moves it would take (assuming black does not move at all) to king a red piece, if possible.

Rules:

Red's side will always be on the bottom, however their pieces may start in any row (even the king's row they need to get to).  Black pieces are stationary, meaning they do not move in between red's movements, but they are removed from the board when captured.  Note that pieces can start on any space on the board, including right next to each other.  This is not how normal checkers is played, but your program must be able to solve these.  (See input 5)  However, checker pieces must only move diagonally (see input 3).  Backward-capturing is allowed if the first capture is forward in the chain (see input 7).

Input:

An 8x8 checkerboard, with board spaces defined as the following characters(feel free to use alternatives as long as they're consistent):

. - Empty

R - Red piece(s)

B - Black piece(s)

Output:

The smallest number of moves it would take a red piece to be 'kinged' by entering the king's row on the top row of the board (black's side), 0 if no moves are required (a red piece started on king's row), or a negative number if it is impossible to king a red piece (ie black occupies it's entire first row).

Input 1:

```<code>. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
R . . . . . . .
</code>```

Output 1:

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

Input 2:

```<code>. . . . . . . .
. . . . . . . .
. . . . . B . .
. . . . . . . .
. . . B . . . .
. . . . . . . .
. B . . . . . .
R . . . . . . .
</code>```

Output 2:

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

Input 3:

```<code>. B . B . B . B
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
R . . . . . . .
</code>```

Output 3:

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

Input 4:

```<code>. . . . . . . R
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
R . . . . . . .
</code>```

Output 4:

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

Input 5:

```<code>. . . . . . . .
. . . . . . . .
. . . . . . . .
. B . . B . . .
B . . . . B . .
. B . B . . . .
. . B . . B . .
. . . R R . . .
</code>```

Output 5:

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

Input 6:

```<code>7
</code>```0

Output 6:

```<code>7
</code>```1

Input 7:

```<code>7
</code>```2

Output 7:

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

Scoring:

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

Title: Checkers: King Me?

Body:
JavaScript (ES6), <s>354</s> 322 bytes

Takes an array as input with:

0 = empty square

1 = red piece

2 = black piece

Returns the optimal number of moves, or 99 if there's no solution.

It's very fast but could be golfed much more.

F=(b,n=0,C=-1,i)=>b.map((v,f,X,T,x=f&7,y=f>>3)=>v-1||(y&&n<m?[-9,-7,7,9].map(d=>(N=c=X=-1,r=(d&7)<2,T=(t=f+d)>=0&t<64&&(x||r)&&(x<7||!r)?(!b[t]&d<0)?t:b[t]&1?N:b[t]&2&&(d<0&y>1|d>0&C==f)?(X=t,x>1||r)&&(x<6|!r)&&!b[t+=d]?c=t:N:N:N)+1&&(b[f]=b[X]=0,b[T]=1,F(b,n+!(C==f&c>N),c,1),b[f]=1,b[X]=2,b[T]=0)):m=n<m?n:m),m=i?m:99)|m

var test = [
  [ 0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    1,0,0,0,0,0,0,0
  ],
  [ 0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,2,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,2,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,2,0,0,0,0,0,0,
    1,0,0,0,0,0,0,0
  ],
  [ 0,2,0,2,0,2,0,2,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    1,0,0,0,0,0,0,0
  ],
  [ 0,0,0,0,0,0,0,1,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    1,0,0,0,0,0,0,0
  ],
  [ 0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,2,0,0,2,0,0,0,
    2,0,0,0,0,2,0,0,
    0,2,0,2,0,0,0,0,
    0,0,2,0,0,2,0,0,
    0,0,0,1,1,0,0,0
  ],
  [ 0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,2,0,0,0,0,0,0,
    0,0,2,0,0,0,0,0,
    0,2,0,2,0,0,0,0,
    0,0,0,0,1,0,0,0,
    0,0,0,2,0,0,0,0,
    0,0,0,0,1,0,0,0
  ],
  [ 0,0,0,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,2,0,0,0,0,0,
    0,0,0,0,0,0,0,0,
    0,0,2,0,0,0,0,0,
    0,2,0,2,0,2,0,0,
    0,0,0,0,2,0,0,0,
    0,0,0,0,0,1,0,1
  ]
];

test.forEach((b, n) => {
  console.log("Test #" + (n + 1) + " : " + F(b));
});


Title: Simple integer operation calculator

Body:
Racket 116 bytes

(λ(s)(let((l(string->list s))(a 0))(for((i l))(set! a(match i[#\+(+ a 1)][#\-(- a 1)][#\*(* a 2)][#\/(/ a 2)])))a))

Ungolfed version:

(define f
  (lambda(s)
    (let ((l (string->list s))
          (a 0))
      (for ((i l))
        (set! a (match i
                  [#\+ (+ a 1)]
                  [#\- (- a 1)]
                  [#\* (* a 2)]
                  [#\/ (/ a 2)]
                )))
      a)))

Testing:

(f "++**--/")

3


问:
Simple cat program
One of the most common standard tasks (especially when showcasing esoteric programming languages) is to implement a "cat program": read all of STDIN and print it to STDOUT. While this is named after the Unix shell utility cat it is of course much less powerful than the real thing, which is normally used to print (and concatenate) several files read from disc.

Task

You should write a full program which reads the contents of the standard input stream and writes them verbatim to the standard output stream. If and only if your language does not support standard input and/or output streams (as understood in most languages), you may instead take these terms to mean their closest equivalent in your language (e.g. JavaScript's prompt and alert). These are the only admissible forms of I/O, as any other interface would largely change the nature of the task and make answers much less comparable.

The output should contain exactly the input and nothing else. 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. This also applies to trailing newlines. If the input does not contain a trailing newline, the output shouldn't include one either! (The only exception being if your language absolutely always prints a trailing newline after execution.)

Output to the standard error stream is ignored, so long as the standard output stream contains the expected output. In particular, this means your program can terminate with an error upon hitting the end of the stream (EOF), provided that doesn't pollute the standard output stream. If you do this, I encourage you to add an error-free version to your answer as well (for reference).

As this is intended as a challenge within each language and not between languages, there are a few language specific rules:

If it is at all possible in your language to distinguish null bytes in the standard input stream from the EOF, your program must support null bytes like any other bytes (that is, they have to be written to the standard output stream as well).

If it is at all possible in your language to support an arbitrary infinite input stream (i.e. if you can start printing bytes to the output before you hit EOF in the input), your program has to work correctly in this case. As an example yes | tr -d \\n | ./my_cat should print an infinite stream of ys. It is up to you how often you print and flush the standard output stream, but it must be guaranteed to happen after a finite amount of time, regardless of the stream (this means, in particular, that you cannot wait for a specific character like a linefeed before printing).

Please add a note to your answer about the exact behaviour regarding null-bytes, infinite streams, and extraneous output.

Additional rules

This is not about finding the language with the shortest solution for this (there are some where the empty program does the trick) - this is about finding the shortest solution 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.

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

Feel free to use a language (or language version) even if it's newer than this challenge. Languages specifically written to submit a 0-byte answer to this challenge are fair game but not particularly interesting.

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.

Also note that languages do have to fulfil our usual criteria for programming languages.

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.

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 catalogue as complete as possible. However, do primarily upvote answers in languages where the author actually had to put effort into golfing the code.

Catalogue

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

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

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

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

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

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

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

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

```<code>## [><>](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

```

答:
Jelly, 5 bytes

```<code>ƈȮøL¿
</code>```

Try it online!

This one is valid, unlike the other 1-byte one, which is 100% invalid:

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

(command-line arg, not STDIN)

Title: Simple cat program

Body:
Jelly, 5 bytes

ƈȮøL¿

Try it online!

This one is valid, unlike the other 1-byte one, which is 100% invalid:

¹

(command-line arg, not STDIN)


答:
JavaScript, <s>186</s> <s>183</s> <s>168</s> 158 Bytes

// solution:
function d(d){function p(n){for(i=n;n%--i;);return!--i}u=d;for(;!p(d--)||!p(--d););for(;!p(u++)||!p(++u););for(;++d<u;)if(p(d)&&!p(d-2)&&!p(d+2))console.log(d)}

// runnable test cases:
console.info('Test ' + 70);
d(70);
console.info('Test ' + 71);
d(71);
console.info('Test ' + 72);
d(72);
console.info('Test ' + 73);
d(73);
console.info('Test ' + 90);
d(90);
console.info('Test ' + 201);
d(201);
console.info('Test ' + 499);
d(499);```

Title: The Solitude of Prime Numbers

Body:
Recently I read the novel "The Solitude of Prime Numbers" where the main characters are somewhat compared to twin prime numbers ("always together, but never touching").

A twin prime is a prime number that is either \$\require{cancel}2\$ less or \$2\$ more than another prime number —for example, the twin prime pair \$(41, 43)\$. In other words, a twin prime is a prime that has a prime gap of two. Sometimes the term twin prime is used for a pair of twin primes; an alternative name for this is prime twin or prime pair. Wikipedia

Although I didn't like much the depressing novel, and since I have fallen into PPCG lately, that raised a question in my mind...

Task:

Given a positive integer number \$N > 4\$, find the lonely prime numbers (AKA isolated prime numbers) between the closest couples of twin primes.

Please note that in this case with the term lonely prime numbers, I mean all the prime numbers that are not twin primes and between couples of twin primes. That's why \$N > 4\$ because the first two couples of prime numbers are \$(3, 5)\$ and \$(5, 7)\$.

Example:

\$N = 90\$.

Find the first two couples of twin primes \$< N\$ and \$> N\$. They are: \$(71, 73)\$ and \$(101, 103)\$.

Find the lonely primes in the range \$> 73\$ and \$< 101\$.

They are: \$79, 83, 89, 97\$.

Special cases:

- If N is in between two twin prime numbers, find the closest couples of twin primes \$> N+1\$ and \$< N-1\$. Example: \$N=72\$, find the closest couples of twin primes \$> 73\$ and \$< 71\$ then exclude from the list \$71\$ and \$73\$ because they are not *lonely primes*. So for \$N = 72\$ the expected result is:  \$67, \cancel{71}, \cancel{73}, 79, 83, 89, 97\$
- If N belongs to a couple of twin primes, for example \$N = 73\$, the closest couples of twin primes are \$(71, 73)\$ and \$(101, 103)\$. If \$N = 71\$, the closest couples of twin primes are \$(59, 61)\$ and \$(71, 73)\$.

Test cases:

```<code>N = 70   >  Lonely primes are:  67
N = 71   >  Lonely primes are:  67
N = 72   >  Lonely primes are:  67, 79, 83, 89, 97 (not the twins 71 and 73)
N = 73   >  Lonely primes are:  79, 83, 89, 97
N = 90   >  Lonely primes are:  79, 83, 89, 97
N = 201  >  Lonely primes are:  211, 223
N = 499  >  Lonely primes are:  467, 479, 487, 491, 499, 503, 509
</code>```

Rules:

Write a full program or function that will take the number N from standard input.

Output the list of lonely primes in a readable format as csv, list, array, etc.

Shortest code wins.

Please include (when possible) a testable online fiddle.


问:
Shortest way to strip the commas from column n given a .csv file/input
Ok, so the input here is going to be a .csv file and so is the output. Now, given a .csv file/input like so

```<code>"apple","banana","apple,banana","orange"
"grape","orange","grape,orange","sprout"
# 0       1        2              3
</code>```

strip out all commas for a given nth column's entries (index starts at 0). So, for the input above, the program would output a .csv file like so for n = 2:

```<code>"apple","banana","applebanana","orange"
"grape","orange","grapeorange","sprout"
</code>```

If the particular column's entries do not have commas, then it does nothing. Could have any allowable/manageable number of columns, and if you somehow find that creating a program that takes more than one argument, say, a, b, c, ..., z like this

```<code>program(a=1,b=4,c=65, ..., z=0, mycsv.csv)
</code>```

for respective columns 2, 5, and 66, which all strip out commas for each, to be shorter, then do that.

Shortest code measured in bytes wins, and it doesn't have to be a file that is output/input.

答:
Vim, 32 keystrokes (excluding column index)

This uses 1-based column indices (which might make this answer invalid).

The problem here is that Vim does not start from the current character but rather from the following one... So it's not "easy" to match the 1st set of quotes. Instead, it finds the closing quotes and selects backwards.

Solution

qq + the column index + /\v"(,"|$)<cr>vF":s/\%V,//<cr><cr>@qq@q

Explanation

qq starts recording macro q

/\v"(,"|$)<cr> searches for the next ending quote or end if line. Preceded by the input column number, it finds the nth occurrence

vF" visually selects the previous quote

":s/\%V,//<cr> substitutes in the visual selection (\%V) every comma by nothing

<cr> goes to the next line

@qq@q makes the macro recursive, stops it and then play it until the end of the file.

Gotchas

If a column only contains commas, it will be detected as a column end and will break. This is a gray zone, I will adapt the answer is the question adds this to the test cases.


问:
Iterated Dice Rolling
Given an input n where 3 <= n <= 25, perform the following steps, starting with a single n-sided die (faces in the range [1, n], inclusive):

Print the result of rolling the current n-sided dice in play, in the form kdn: X (where X is the result and k is the number of dice in play).

If X is greater than or equal to n/2 times the number of dice in play, add a die. Else, remove a die.

If the number of dice in play is equal to 0 or n, stop. Else, go to step 1.

Example runs (note that the output in parentheses is for explanation and is not required):

6-sided:

```<code>1d6: 4 (avg: 3.0, add)
2d6: 6 (avg: 6.0, add)
3d6: 9 (avg: 9.0, add)
4d6: 16 (avg: 12.0, add)
5d6: 13 (avg: 15.0, remove)
4d6: 9 (avg: 12.0, remove)
3d6: 5 (avg: 9.0, remove)
2d6: 7 (avg: 6.0, add)
3d6: 11 (avg: 9.0, add)
4d6: 14 (avg: 12.0, add)
5d6: 17 (avg: 15.0, add)
</code>```

9-sided:

```<code>1d9: 7 (avg: 4.5, add)
2d9: 14 (avg: 9.0, add)
3d9: 18 (avg: 13.5, add)
4d9: 18 (avg: 18.0, add)
5d9: 28 (avg: 22.5, add)
6d9: 26 (avg: 27.0, remove)
5d9: 28 (avg: 22.5, add)
6d9: 34 (avg: 27.0, add)
7d9: 33 (avg: 31.5, add)
8d9: 30 (avg: 36.0, remove)
7d9: 29 (avg: 31.5, remove)
6d9: 35 (avg: 27.0, add)
7d9: 32 (avg: 31.5, add)
8d9: 42 (avg: 36.0, add)
</code>```

Rules

Outputs must be exactly in the format kdn: X, with newlines separating each roll

You must actually simulate rolling multiple dice; simply returning a random integer in the range [1, n] (inclusive) multiplied by the number of dice currently in play is not allowed, as that does not accurately simulate rolling multiple dice.

Standard loopholes are forbidden

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

Leaderboard

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
QBIC, 83 bytes

```<code>:c=a{e=0[1,q|e=e+_rq,a|]?!q$+@d|!+a$+@:|+!e$~e<c/2|q=q-1\q=q+1]c=q*a~q=a|_X]~q=0|_X
</code>```

Explanation:

```<code>q                    Tracks the number of dice (is implicitly 1 at the start)
:                    Takes input from a CMD line parameter
[1,q|e=e+_rq,a|]     Rolls the dice separately
?!q$+@d|!+a$+@:|+!e$ Prints the roll result (requires an unfortunate amount of casting...)
~e<c/2|q=q-1\q=q+1]  Checks whether to increase or decrease
~q=a|_X]~q=0|_X      Tests the amount of dice and quits on either boundary.
</code>```

Title: Iterated Dice Rolling

Body:
QBIC, 83 bytes

:c=a{e=0[1,q|e=e+_rq,a|]?!q$+@d|!+a$+@:|+!e$~e<c/2|q=q-1\q=q+1]c=q*a~q=a|_X]~q=0|_X

Explanation:

q                    Tracks the number of dice (is implicitly 1 at the start)
:                    Takes input from a CMD line parameter
[1,q|e=e+_rq,a|]     Rolls the dice separately
?!q$+@d|!+a$+@:|+!e$ Prints the roll result (requires an unfortunate amount of casting...)
~e<c/2|q=q-1\q=q+1]  Checks whether to increase or decrease
~q=a|_X]~q=0|_X      Tests the amount of dice and quits on either boundary.