答:
Java, 98 bytes

int[]f(int[]t){int i=0;for(;i<t.length&&t[i]%2<1;i++);return java.util.Arrays.copyOfRange(t,0,i);}
```

Ideone it!

Title: Implement Takewhile

Body:
Introduction and Credit

Today without a fancy prelude: Please implement takewhile.

A variation of this (on a non-trivial data structure) was an assignment at my university functional programming course. This assignment is now closed and has been discussed in class and I have my professor's permission to post it here (I asked explicitly).

Specification

Input

The input will be a list (or your language's equivalent concept) of positive integers.

Output

The output should be a list (or your language's equivalent concept) of positive integers.

What to do?

Your task is to implement takewhile (language built-ins are allowed) with the predicate that the number under consideration is even (to focus on takewhile).

So you iterate over the list from start to end and while the condition (is even) holds, you copy to the output-list and as soon as you hit an element that doesn't make the condition true, you abort the operation and output (a step-by-step example is below). This higher-order functionality is also called takeWhile (takewhile).

Potential corner cases

The order of the output list compared to the input list may not be changed, e.g. [14,42,2] may not become [42,14].

The empty list is a valid in- and output.

Who wins?

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

Standard rules apply of course.

Test Vectors

```<code>[14, 42, 2324, 97090, 4080622, 171480372] -> [14, 42, 2324, 97090, 4080622, 171480372]
[42, 14, 42, 2324] -> [42, 14, 42, 2324]
[7,14,42] -> []
[] -> []
[171480372, 13, 14, 42] -> [171480372]
[42, 14, 42, 43, 41, 4080622, 171480372] -> [42, 14, 42]
</code>```

Step-by-Step Example

```<code>Example Input: [42, 14, 42, 43, 41, 4080622, 171480372]

Consider first element: 42
42 is even (21*2)
Put 42 into output list, output list is now [42]

Consider second element: 14
14 is even (7*2)
Put 14 into output list, output list is now [42,14]

Consider third element: 42
42 is even (21*2)
Put 42 into output list, output list is now [42,14,42]

Consider fourth element: 43
43 is not even (2*21+1)
Drop 43 and return the current output list

return [42,14,42]
</code>```

Body:
Java, 98 bytes

int[]f(int[]t){int i=0;for(;i<t.length&&t[i]%2<1;i++);return java.util.Arrays.copyOfRange(t,0,i);}

Ideone it!


问:
Write all possible Braille characters
An interesting puzzle came to me looking at the elevator buttons this morning.

You are required to generate a list of all Braille patterns that fit in a 2x3 grid.  Use a hash # to denote a bump and a hyphen - to denote a flat area.

Expected output sample:

```<code>#-
--
--

##
--
--

#-
#-
--

(and so on...)
</code>```

Rules:

Your program must separate each pattern by at least one character or line.

The patterns may be generated in any order.

All patterns, regardless of what the Braille alphabet actually uses, should be produced.  The completely blank pattern is optional.

Only unique bump patterns should be generated.  The following patterns are considered equivilent as the bumps are in an identical arangement.  In these cases, use the pattern that is closest to the top-left corner (ie. the first option in this example.)

```<code>#-  -#  --  --
#-  -#  #-  -#
--  --  #-  -#
</code>```

Bonus points if you can make it work for any x by y sized grid. (EDIT: Within reasonable bounds.  Up to 4x4 is enough for proof of concept.)

Reading the wiki article, it appears there are 45 patterns (including the blank) that meet this puzzle's rules.

答:
Python, 120 118 113 95 118

```<code>for j in range(256):
    if j/4&48and j/4&42:print''.join('_#'[int(c)]for c in bin(j/4)[2:].rjust(6,'0'))[j%4*2:j%4*2+2]
</code>```

Edit: used Winston Ewert suggestion and added x by y grid solution

Edit: I somehow missed the last constraint about uniqueness. This script generates all the possible sequences, not just the 45.

Edit: Back up to 118 but now correct

ContentLicense: CC BY-SA 3.0

Title: Write all possible Braille characters

Body:
Python, 120 118 113 95 118

for j in range(256):
    if j/4&48and j/4&42:print''.join('_#'[int(c)]for c in bin(j/4)[2:].rjust(6,'0'))[j%4*2:j%4*2+2]

Edit: used Winston Ewert suggestion and added x by y grid solution

Edit: I somehow missed the last constraint about uniqueness. This script generates all the possible sequences, not just the 45.

Edit: Back up to 118 but now correct


问:
Print a bunch of uninteresting numbers!
An uninteresting number (which I totally didn't make up only for this challenge) is created like this:

Take a positive integer N

Create a new number O by adding the digits of N at the end of N

The final uninteresting number is O*N

For example for N=12:

O = 1212

O*N = 1212 * 12

Final number is 14544

Input

A positive integer N (N > 0) or your language's equivalent. You don't have to catch incorrect input.

Output

The corresponding uninteresting number.

Test cases

```<code>  1 -> 11
  2 -> 44
  3 -> 99
 10 -> 10100
174 -> 30306276
</code>```

Scoring

Shortest Code in Bytes wins.

答:
J, 7 bytes

```<code>*,~&.":
</code>```

Explanation

```<code>*,~&.":  Input: n
     ":  Format n as a string
 ,~&.    Reflect and join the string to make "nn"
         and parse the string to get a number
*        Multiply that number by n
</code>```

Title: Print a bunch of uninteresting numbers!

Body:
J, 7 bytes

*,~&.":

Explanation

*,~&.":  Input: n
     ":  Format n as a string
 ,~&.    Reflect and join the string to make "nn"
         and parse the string to get a number
*        Multiply that number by n


答:
Retina, <s>27</s> 20 bytes

```<code>^
$_$*: $_
:
$_$*:
:
</code>```

Gets a bit slow for large inputs, because before the last the stage the result is represented in unary.

Try it online! (The first line enables a linefeed-separated test suite.)

Explanation

I'll use 2 as an example input (because the unary representations get a bit unwieldy for larger inputs).

Stage 1: Substitution

```<code>^
$_$*: $_
</code>```

By matching the beginning of the string with ^ we simply prepend some stuff. $_ refers to the input string itself and $*: means we insert that many colons. So we get:

```<code>:: 22
</code>```

Stage 2: Substitution

```<code>:
$_$*:
</code>```

Now we match every : and again replace it with $_$*:. Of course, this time $_ doesn't evaluate to an integer (but to :: 22 in our example), but $* just looks for the first decimal in the string, so this evaluates to the input concatenated to itself (O in the challenge specification). We'll end up with N*O colons, followed by O:

```<code>:::::::::::::::::::::::::::::::::::::::::::: 22
</code>```

Stage 3: Match

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

All that's left is counting the :s to convert from unary back to decimal, which is exactly what this stage does.

Title: Print a bunch of uninteresting numbers!

Body:
An uninteresting number (which I totally didn't make up only for this challenge) is created like this:

Take a positive integer N

Create a new number O by adding the digits of N at the end of N

The final uninteresting number is O*N

For example for N=12:

O = 1212

O*N = 1212 * 12

Final number is 14544

Input

A positive integer N (N > 0) or your language's equivalent. You don't have to catch incorrect input.

Output

The corresponding uninteresting number.

Test cases

```<code>  1 -> 11
  2 -> 44
  3 -> 99
 10 -> 10100
174 -> 30306276
</code>```

Scoring

Shortest Code in Bytes wins.

Body:
Retina, <s>27</s> 20 bytes

^
$_$*: $_
:
$_$*:
:

Gets a bit slow for large inputs, because before the last the stage the result is represented in unary.

Try it online! (The first line enables a linefeed-separated test suite.)

Explanation

I'll use 2 as an example input (because the unary representations get a bit unwieldy for larger inputs).

Stage 1: Substitution

^
$_$*: $_

By matching the beginning of the string with ^ we simply prepend some stuff. $_ refers to the input string itself and $*: means we insert that many colons. So we get:

:: 22

Stage 2: Substitution

:
$_$*:

Now we match every : and again replace it with $_$*:. Of course, this time $_ doesn't evaluate to an integer (but to :: 22 in our example), but $* just looks for the first decimal in the string, so this evaluates to the input concatenated to itself (O in the challenge specification). We'll end up with N*O colons, followed by O:

:::::::::::::::::::::::::::::::::::::::::::: 22

Stage 3: Match

:

All that's left is counting the :s to convert from unary back to decimal, which is exactly what this stage does.


答:
SpecBAS - 30 bytes

```<code>1 INPUT n$: ?VAL(n$+n$)*VAL n$
</code>```

My shortest SpecBAS answer yet :-)

Title: Print a bunch of uninteresting numbers!

Body:
SpecBAS - 30 bytes

1 INPUT n$: ?VAL(n$+n$)*VAL n$

My shortest SpecBAS answer yet :-)


答:
Brachylog, 7 bytes

```<code>:?c:?*.
</code>```

Explanation

```<code>:?c      Concatenate Input to itself
   :?*.  Output is that concatenation times Input
</code>```

Title: Print a bunch of uninteresting numbers!

Body:
Brachylog, 7 bytes

:?c:?*.

Explanation

:?c      Concatenate Input to itself
   :?*.  Output is that concatenation times Input


答:
Jelly, <s>8</s> 6 bytes

```<code>ŒṘẋ2v×
</code>```

Try it online!

Explanation

```<code>ŒṘẋ2v× - Main link. Left argument: the number to convert

     × - Multiply
    v  - an evaluation of the left argument
ŒṘ     - converted to string
  ẋ    - multiplied by
   2   - two and the left argument
</code>```

Title: Print a bunch of uninteresting numbers!

Body:
Jelly, <s>8</s> 6 bytes

ŒṘẋ2v×

Try it online!

Explanation

ŒṘẋ2v× - Main link. Left argument: the number to convert

     × - Multiply
    v  - an evaluation of the left argument
ŒṘ     - converted to string
  ẋ    - multiplied by
   2   - two and the left argument


问:
Is it a sum-free set?
A set is sum-free if no two (not necessarily distinct) elements when added together are part of the set itself.

For example, {1, 5, 7} is sum-free, because all members are odd, and two odd numbers when added together are always even. On the other hand, {2, 4, 9, 13} is not sum-free, as either 2 + 2 = 4 or 4 + 9 = 13 add together to a member of the set.

Write a program or function that takes a set as input, and outputs a Truthy value if the set is sum-free, and Falsy otherwise.

Examples:

```<code>Sum-free:
{}
{4}
{1, 5, 7}
{16, 1, 4, 9}

Not sum-free:
{0}
{1, 4, 5, 7}
{3, 0}
{16, 1, 4, 8}
</code>```

答:
Octave, <s>29</s> <s>21</s> 25 bytes

@(s)~[ismember(s,s+s') 0]
```
<p>Thanks to Suever! It returns an array. I added <code>0</code> at the end to make <code>[]</code> become sum-free. To verify truthy and falsey in Octave, you can do this:</p>
<pre class="lang-matlab prettyprint-override"><code>> f=@(s)~[ismember(s,s+s') 0]

> if f([]) "sum-free" else "not sum-free" end
ans = sum-free

> if f([0]) "sum-free" else "not sum-free" end
ans = not sum-free

> if f([4]) "sum-free" else "not sum-free" end
ans = sum-free

> if f([1 3]) "sum-free" else "not sum-free" end
ans = sum-free

> if f([2 4]) "sum-free" else "not sum-free" end
ans = not sum-free
</code>```

An alternative that returns 0 or 1 is:

@(s)~numel(intersect(s+s',s))
```

Title: Is it a sum-free set?

Body:
Octave, <s>29</s> <s>21</s> 25 bytes

@(s)~[ismember(s,s+s') 0]

Thanks to Suever! It returns an array. I added 0 at the end to make [] become sum-free. To verify truthy and falsey in Octave, you can do this:

> f=@(s)~[ismember(s,s+s') 0]

> if f([]) "sum-free" else "not sum-free" end
ans = sum-free

> if f([0]) "sum-free" else "not sum-free" end
ans = not sum-free

> if f([4]) "sum-free" else "not sum-free" end
ans = sum-free

> if f([1 3]) "sum-free" else "not sum-free" end
ans = sum-free

> if f([2 4]) "sum-free" else "not sum-free" end
ans = not sum-free

An alternative that returns 0 or 1 is:

@(s)~numel(intersect(s+s',s))


问:
Golf to find Boring numbers
If an integer has a digit/sequence of digits in it which repeats continuously (You will understand why I said "continuously") 5 or more times, we call It "Boring".

For example, 11111 is Boring, whereas 12345 is not.

Instructions

Take an Integer as Input

Output a truthy value if the integer is boring, and a falsey value if the integer is not boring.

Example

11111=>true or 1 (1 repeats 5 times)

12345=>false or 0

1112111=>false or 0

4242424242=>true or 1 (42 repeats 5 times)

-11111=>true or 1

3452514263534543543543543543876514264527473275=>true or 1 (543 repeats 5 times)

If you use other types of "truth" and "false", specify it.

Rules

Basic code-golf rules apply.

Good luck!

答:
Retina, 9 bytes

```<code>(.+)\1{4}
</code>```

Verify all testcases! (slightly modified to run all testcases at once.)

Title: Golf to find Boring numbers

Body:
Retina, 9 bytes

(.+)\1{4}

Verify all testcases! (slightly modified to run all testcases at once.)


答:
C# - 93 38 bytes

```<code>s=>new Regex(@"(.+)\1{4}").IsMatch(s);
</code>```

Takes a string, returns an integer.

Thanks to aloisdg for saving a lot of bytes!

Title: Golf to find Boring numbers

Body:
If an integer has a digit/sequence of digits in it which repeats continuously (You will understand why I said "continuously") 5 or more times, we call It "Boring".

For example, 11111 is Boring, whereas 12345 is not.

Instructions

Take an Integer as Input

Output a truthy value if the integer is boring, and a falsey value if the integer is not boring.

Example

11111=>true or 1 (1 repeats 5 times)

12345=>false or 0

1112111=>false or 0

4242424242=>true or 1 (42 repeats 5 times)

-11111=>true or 1

3452514263534543543543543543876514264527473275=>true or 1 (543 repeats 5 times)

If you use other types of "truth" and "false", specify it.

Rules

Basic code-golf rules apply.

Good luck!

Body:
C# - 93 38 bytes

s=>new Regex(@"(.+)\1{4}").IsMatch(s);

Takes a string, returns an integer.

Thanks to aloisdg for saving a lot of bytes!


答:
Perl, 11 bytes

```<code>$_*=$_ x2
</code>```

+ the p and l flags.

(run with perl -ple '$_*=$_ x2')

-2 bytes thanks to pipe.

Title: Print a bunch of uninteresting numbers!

Body:
Perl, 11 bytes

$_*=$_ x2

+ the p and l flags.

(run with perl -ple '$_*=$_ x2')

-2 bytes thanks to pipe.


答:
Mathematica 97

```<code>Grid /@ Cases[(#~Partition~2 & /@ Tuples[{"#", "-"}, 6]), x_ /;
         x[[All, 1]] != {"-", "-", "-"} && x[[1]] != {"-", "-"}]
</code>```

Blank is not included:

```<code>Length[%]
</code>```

44

N.B. != is a single character in Mathematica.

Title: Write all possible Braille characters

Body:
An interesting puzzle came to me looking at the elevator buttons this morning.

You are required to generate a list of all Braille patterns that fit in a 2x3 grid.  Use a hash # to denote a bump and a hyphen - to denote a flat area.

Expected output sample:

```<code>#-
--
--

##
--
--

#-
#-
--

(and so on...)
</code>```

Rules:

Your program must separate each pattern by at least one character or line.

The patterns may be generated in any order.

All patterns, regardless of what the Braille alphabet actually uses, should be produced.  The completely blank pattern is optional.

Only unique bump patterns should be generated.  The following patterns are considered equivilent as the bumps are in an identical arangement.  In these cases, use the pattern that is closest to the top-left corner (ie. the first option in this example.)

```<code>#-  -#  --  --
#-  -#  #-  -#
--  --  #-  -#
</code>```

Bonus points if you can make it work for any x by y sized grid. (EDIT: Within reasonable bounds.  Up to 4x4 is enough for proof of concept.)

Reading the wiki article, it appears there are 45 patterns (including the blank) that meet this puzzle's rules.

Body:
Mathematica 97

Grid /@ Cases[(#~Partition~2 & /@ Tuples[{"#", "-"}, 6]), x_ /;
         x[[All, 1]] != {"-", "-", "-"} && x[[1]] != {"-", "-"}]

Blank is not included:

Length[%]

44

N.B. != is a single character in Mathematica.


问:
When is Thanksgiving?

Background

Some holidays have fixed, easy-to-remember dates, like Oct 31, Dec 25, etc. Some, however, want to be troublesome. They're specified as things like "the first Monday in September" or "the fourth Thursday in November". How am I supposed to know when that is?

All I know is that Thanksgiving is fast approaching, so I need a program to help me figure out when it is. Some people even say that it's tomorrow, so your program needs to be as short as possible to make sure I can re-type it in time.

The Challenge

Create a program or function that, given an up-to-four-digit year (e.g. 2015 or 1984), outputs or returns the date of the United States' Thanksgiving in that year. Thanksgiving is defined as the fourth Thursday of November according to the Wikipedia page. (Hint: that page also includes some interesting information on the date pattern.)

Input: a decimal number with a maximum of four digits representing a year in the Common Era (C.E.). Examples: 987, 1984, 2101

Output: the date, including month and day, on which Thanksgiving falls, or would fall if it existed, in that year. This may be in any reasonable format; use your best judgment. Use the Gregorian Calendar in all cases, even if it was not in use at the time.

(Note: Make sure to handle leap years correctly!)

Test cases
Input 1:

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

Output 1:

```<code>Nov 26
</code>```

Input 2:

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

Output 2:

```<code>Nov 22
</code>```

Scoring

Submissions will be scored in bytes. I recommend this website to keep track of your byte count, though you can use any counter you like.

Bonuses

-25% to your score if you handle B.C.E. dates as negative numbers (e.g. -480 would be the year of the battle of Thermopylae).

Negative test case input:

```<code>-480
</code>```

Corresponding output:

```<code>Nov 25
</code>```

This is code-golf, so the lowest score wins!

Edit: I am marking Thomas Kwa's TI-BASIC submission  as accepted. Don't let this discourage you from submitting new entries!

Leaderboards

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

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

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

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

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

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

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

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

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
TSQL, <s>53</s> 52 bytes

```<code>DECLARE @ CHAR(4)=2000

PRINT DATEADD(d,59,DATEDIFF(d,1,DATEADD(m,9,@))/7*7)
</code>```

Fiddle

Calculating monday before or on september 2nd and adding 59 days

(better than calculating monday before or on october 4th and adding 31 days because october is the 10th month thus saving 1 byte)

Title: When is Thanksgiving?

Body:
TSQL, <s>53</s> 52 bytes

DECLARE @ CHAR(4)=2000

PRINT DATEADD(d,59,DATEDIFF(d,1,DATEADD(m,9,@))/7*7)

Fiddle

Calculating monday before or on september 2nd and adding 59 days

(better than calculating monday before or on october 4th and adding 31 days because october is the 10th month thus saving 1 byte)


答:
05AB1E, 8 bytes

Code:

```<code>Œv¹y5×åO
</code>```

Explanation:

```<code>Œ         # Compute all substrings from the input.
 v        # For each substring.
   y5×    # Repeat the substring 5 times (42 × 5 = 4242424242).
  ¹   å   # Check if it's in the input string.
       O  # Sum up the result. Non-boring numbers should give 0.
</code>```

Truthy is non-zero and falsy is zero. Uses the CP-1252 encoding.

Try it online!

Title: Golf to find Boring numbers

Body:
05AB1E, 8 bytes

Code:

Œv¹y5×åO

Explanation:

Œ         # Compute all substrings from the input.
 v        # For each substring.
   y5×    # Repeat the substring 5 times (42 × 5 = 4242424242).
  ¹   å   # Check if it's in the input string.
       O  # Sum up the result. Non-boring numbers should give 0.

Truthy is non-zero and falsy is zero. Uses the CP-1252 encoding.

Try it online!


答:
Matlab / Octave, 20 bytes

```<code>@(x)eval([x x 42 x])
</code>```

This is an anonymous function that takes the input as a string.

Example use:

```<code>>> f = @(x)eval([x x 42 x])
f =
    @(x)eval([x,x,42,x])
>> f('12')
ans =
       14544
</code>```

Or try it online with ideone.

Explanation

The code builds a string by concatenating the input string twice, then the character * (that has ASCII code 42), then the string again. The concatenated string is then evaluated.

Title: Print a bunch of uninteresting numbers!

Body:
Matlab / Octave, 20 bytes

@(x)eval([x x 42 x])

This is an anonymous function that takes the input as a string.

Example use:

>> f = @(x)eval([x x 42 x])
f =
    @(x)eval([x,x,42,x])
>> f('12')
ans =
       14544

Or try it online with ideone.

Explanation

The code builds a string by concatenating the input string twice, then the character * (that has ASCII code 42), then the string again. The concatenated string is then evaluated.


答:
Perl, <s>17</s> 15 bytes

```<code>$_=/(.+)\1{4}/
</code>```

+ the p flag.

(run with perl -pe '$_=/(.+)\1{4}/')

Thanks to Dom Hasting for the (.+) instead of (\d+).

Explanations if needed :
  (.+) will match any part of the number, and \1{4}$ searches if it is repeated 4 times consecutives.

Title: Golf to find Boring numbers

Body:
Perl, <s>17</s> 15 bytes

$_=/(.+)\1{4}/

+ the p flag.

(run with perl -pe '$_=/(.+)\1{4}/')

Thanks to Dom Hasting for the (.+) instead of (\d+).

Explanations if needed :
  (.+) will match any part of the number, and \1{4}$ searches if it is repeated 4 times consecutives.


答:
Pyth, <s>9</s> 8 bytes

1 byte thanks to Maltysen.

```
<s>sm}*5dQ.:</s>
f}*5TQ.:
```

Truthy value is a non-empty array.

Falsey value is [] (empty array).

Test suite.

```<code>f}*5TQ.:   input as a string stored in Q
f}*5TQ.:Q  implicit arguments
        Q  input
      .:   all substrings of.
f   T      filter for this condition, keep those returning true:
  *5           repeat five times
 }   Q         in Q? (True/False)
</code>```

Title: Golf to find Boring numbers

Body:
Pyth, <s>9</s> 8 bytes

1 byte thanks to Maltysen.

<s>sm}*5dQ.:</s>
f}*5TQ.:

Truthy value is a non-empty array.

Falsey value is [] (empty array).

Test suite.

f}*5TQ.:   input as a string stored in Q
f}*5TQ.:Q  implicit arguments
        Q  input
      .:   all substrings of.
f   T      filter for this condition, keep those returning true:
  *5           repeat five times
 }   Q         in Q? (True/False)


答:
Python 3.5, <s>49</s> 43 bytes:

(-6 bytes thanks to tips from Martin Ender!)

```<code>import re;lambda u:re.search(r'(.+)\1{4}',u)
</code>```

Uses a Regular Expression to match all repeating sequences of characters as long as they repeat continuously 5 or more times. Returns an re match object (such as <_sre.SRE_Match object; span=(0, 10), match='4242424242'>) if a match is found as a truthy value, and nothing or None as a falsey value.

Try It Online! (Ideone)

Title: Golf to find Boring numbers

Body:
Python 3.5, <s>49</s> 43 bytes:

(-6 bytes thanks to tips from Martin Ender!)

import re;lambda u:re.search(r'(.+)\1{4}',u)

Uses a Regular Expression to match all repeating sequences of characters as long as they repeat continuously 5 or more times. Returns an re match object (such as <_sre.SRE_Match object; span=(0, 10), match='4242424242'>) if a match is found as a truthy value, and nothing or None as a falsey value.

Try It Online! (Ideone)


答:
PHP, <s>25</s> 24 bytes

Short opening tags are useful for surprisingly few  golfing challenges, luckily this is one of them.
Unfortunately operator precedence is the opposite of the order you need to do them in so lots of brackets are needed.

```<code><?=($a=$argv[1])*"$a$a";
</code>```

edit: I realised that seeing as how I'm using brackets anyway I can effectively skip the concatenation operator by changing the written order of the operations around.

Title: Print a bunch of uninteresting numbers!

Body:
An uninteresting number (which I totally didn't make up only for this challenge) is created like this:

Take a positive integer N

Create a new number O by adding the digits of N at the end of N

The final uninteresting number is O*N

For example for N=12:

O = 1212

O*N = 1212 * 12

Final number is 14544

Input

A positive integer N (N > 0) or your language's equivalent. You don't have to catch incorrect input.

Output

The corresponding uninteresting number.

Test cases

```<code>  1 -> 11
  2 -> 44
  3 -> 99
 10 -> 10100
174 -> 30306276
</code>```

Scoring

Shortest Code in Bytes wins.

Body:
PHP, <s>25</s> 24 bytes

Short opening tags are useful for surprisingly few  golfing challenges, luckily this is one of them.
Unfortunately operator precedence is the opposite of the order you need to do them in so lots of brackets are needed.

<?=($a=$argv[1])*"$a$a";

edit: I realised that seeing as how I'm using brackets anyway I can effectively skip the concatenation operator by changing the written order of the operations around.


答:
Lua, 35 Bytes

Well, I don't see how to do better with Lua's patterns! Takes a command-line argument as input and output nil for falsy cases, and the number repeated when truthy.

print((...):match("(%d+)%1%1%1%1"))
```

Title: Golf to find Boring numbers


答:
C# – 205

class C{static void Main(){var s="---##-##";Action<int,int>W=(i,m)=>{Console.WriteLine(s.Substring((i>>m&3)*2,2));};for(int i=0;i<64;++i){if((i&3)>0&&(i&42)>0){W(i,0);W(i,2);W(i,4);Console.WriteLine();}}}}
```

<p>Readable version:</p>

<pre class="lang-cs prettyprint-override"><code>class C
{
    static void Main()
    {
        var s = "---##-##"; // all two-bit combinations
        // a function to write one two-bit pattern (one line of a Braille character)
        Action<int,int> W = (i,m) => { Console.WriteLine(s.Substring(((i >> m) & 3) * 2, 2)); };
        // for all possible 6-bit combinations (all possible Braille characters)
        for(int i = 0; i < 64; ++i)
        {
            // filter out forbidden (non-unique) characters
            if ((i & 3) > 0 && (i & 42) > 0)
            {
                // write three rows of the Braille character and an empty line
                W(i,0);
                W(i,2);
                W(i,4);
                Console.WriteLine();
            }
        }
    }
}
</code>```

Title: Write all possible Braille characters

Body:
C# – 205

class C{static void Main(){var s="---##-##";Action<int,int>W=(i,m)=>{Console.WriteLine(s.Substring((i>>m&3)*2,2));};for(int i=0;i<64;++i){if((i&3)>0&&(i&42)>0){W(i,0);W(i,2);W(i,4);Console.WriteLine();}}}}

Readable version:

class C
{
    static void Main()
    {
        var s = "---##-##"; // all two-bit combinations
        // a function to write one two-bit pattern (one line of a Braille character)
        Action<int,int> W = (i,m) => { Console.WriteLine(s.Substring(((i >> m) & 3) * 2, 2)); };
        // for all possible 6-bit combinations (all possible Braille characters)
        for(int i = 0; i < 64; ++i)
        {
            // filter out forbidden (non-unique) characters
            if ((i & 3) > 0 && (i & 42) > 0)
            {
                // write three rows of the Braille character and an empty line
                W(i,0);
                W(i,2);
                W(i,4);
                Console.WriteLine();
            }
        }
    }
}


答:
Java 8, <s>73</s> 66 bytes:

```<code>L->java.util.regex.Pattern.compile("(.+)\\1{4}").matcher(L).find();
</code>```

Hooray for Java 8 lambdas! Returns true if match is found and false otherwise.

Try It Online! (Ideone)

Title: Golf to find Boring numbers

Body:
Java 8, <s>73</s> 66 bytes:

L->java.util.regex.Pattern.compile("(.+)\\1{4}").matcher(L).find();

Hooray for Java 8 lambdas! Returns true if match is found and false otherwise.

Try It Online! (Ideone)


答:
Excel VBA, 35 Bytes

Sub called with number, msgbox returns answer

```<code>Sub B(a)
MsgBox (a & a) * a
End Sub
</code>```

Alternative Excel VBA, 42 Bytes

Number given in formula, returns answer.

```<code>Function B(a)
B = (a & a) * a
End Function
</code>```

Title: Print a bunch of uninteresting numbers!

Body:
Excel VBA, 35 Bytes

Sub called with number, msgbox returns answer

Sub B(a)
MsgBox (a & a) * a
End Sub

Alternative Excel VBA, 42 Bytes

Number given in formula, returns answer.

Function B(a)
B = (a & a) * a
End Function


问:
Determine the winner of a game of War
The card game War is interesting in that the final outcome is entirely determined by the initial arrangement of the deck, so long as certain rules are followed for the order in which cards are picked up from the playing field and moved to decks. In this challenge, there will only be 2 players, simplifying things greatly.

The Game

Each player is dealt a deck of 26 cards.

Each player places the top card in their deck face-up. The player with the higher-ranking card (Ace > King > Queen > Jack > 10 > 9 > 8 > 7 > 6 > 5 > 4 > 3 > 2) wins the round, and places their card on top of their opponent's card, flips them over, and adds them to the bottom of their deck (so their winning card is on the bottom of the deck, and the other player's losing card is just above it). This is done until one of the players runs out of cards.

If the cards are of equal rank, then each player places the top 2 cards of their deck face-up on top of their previous card (so that the card that was on top of the deck is the second card in the stack, and the card that was second-from-top is on top). Then, the ranks (of the top card of each stack) are compared again, and the winner places their entire stack on top of the loser's entire stack, turns the stack upside-down, and places it on the bottom of their deck. If there is another tie, more cards are played in the same way, until a winner is chosen or one player runs out of cards.

If at any point one of the players needs to draw a card from their deck, but their deck is empty, they immediately lose the game.

The Challenge

Given two lists of cards in the players' decks, in any convenient format, output a truthy value if Player 1 wins, and a falsey value if Player 2 wins.

For convenience, a 10 card will be represented with a T, and face cards will be abbreviated (Ace -> A, King -> K, Queen -> Q, Jack -> J), so that all cards are one character long. Alternatively, ranks may be represented with decimal integers 2-14 (Jack -> 11, Queen -> 12, King -> 13, Ace -> 14) or hex digits 2-E (10 -> A, Jack -> B, Queen -> C, King -> D, Ace -> E). Since suits don't matter, suit information will not be given.

You may assume that all games will terminate at some point (though it may take a very long time), and one player will always run out of cards before the other.

Each player places cards simultaneously, and one card at a time, so there is never any ambiguity about which player ran out of cards first.

Test Cases

The test cases use 23456789ABCDE to represent the ranks (in ascending order).

```<code>D58B35926B92C7C4C7E8D3DAA2, 8E47C38A2DEA43467EB9566B95 -> False
669D9D846D4B3BA52452C2EDEB, E747CA988CC76723935A3B8EA5 -> False
5744B95ECDC6D325B28A782A72, 68394D9DA96EBBA8533EE7C6C4 -> True
87DB6C7EBC6C8D722389923DC6, E28435DBEBEA543AA47956594A -> False
589EAB9DCD43E9EC264A5726A8, 48DC2577BD68AB9335263B7EC4 -> True
E3698D7C46A739AE5BE2C49286, BB54B7D78954ED526A83C3CDA2 -> True
32298B5E785DC394467D5C9CB2, 5ED6AAD93E873EA628B6A4BC47 -> True
B4AB985B34756C624C92DE5E97, 3EDD5BA2A68397C26CE837AD48 -> False
9A6D9A5457BB6ACBC5E8D7D4A9, 73E658CE2C3E289B837422D463 -> True
96E64D226BC8B7D6C5974BAE32, 58DC7A8C543E35978AEBA34D29 -> True
C2978A35E74D7652BA9762C458, 9A9BB332BE8C8DD44CE3DE66A5 -> False
BEDB44E947693CD284923CEA82, 8CC3B75756255A683A6AB9E7DD -> False
EEDDCCBBAA8877665544332299, EEDDCCBBAA9988776655443322 -> False
EEDDCCBBAA9988776655443322, DDCCBBAA9988776655443E3E22 -> True
</code>```

Reference Implementation

This reference implementation is written in Python 3, and takes input in the same format as the test cases (except separated by a newline instead of a comma and a space).

#!/usr/bin/env python3

from collections import deque

p1, p2 = [deque(s) for s in (input(),input())]
print(''.join(p1))
print(''.join(p2))

try:
    while p1 and p2:
        p1s = [p1.popleft()]
        p2s = [p2.popleft()]
        while p1s[-1] == p2s[-1]:
            p1s.append(p1.popleft())
            p2s.append(p2.popleft())
            p1s.append(p1.popleft())
            p2s.append(p2.popleft())
        if p1s[-1] > p2s[-1]:
            p1.extend(p2s+p1s)
        else:
            p2.extend(p1s+p2s)
except IndexError:
    pass
finally:
    print(len(p1) > 0)
```

答:
Python, 160 (155?) bytes

f=lambda x,y,z=1:f(*((x,y,z+2),(x[z:]+y[:z]+x[:z],y[z:]),(x[z:],y[z:]+x[:z]+y[:z]))[(x[z-1]>y[z-1])+(x[z-1]<y[z-1])*2])if len(y)>z<len(x)else len(x)>len(y)
```

<p>This solution is theoretically valid, but it require the default python maximum recursion depth to be increased for some of the test cases.</p>

<p>The second solution is 5 bytes longer, but work for all the test cases.</p>

<pre class="lang-py prettyprint-override"><code>f=lambda x,y,z=1:(f(x,y,z+2)if x[z-1]==y[z-1]else f(x[z:]+y[:z]+x[:z],y[z:])if x[z-1]>y[z-1]else f(x[z:],y[z:]+x[:z]+y[:z]))if len(y)>z<len(x)else len(x)>len(y)
</code>```

Edit: Ungolfed solution 1:

def f(x,y,z=1):
    if len(y)<z>len(x):
        return len(x)>len(y)
    else:
        return f(*(
            (x,y,z+2),
            (x[z:],y[z:]+x[:z]+y[:z]),
            (x[z:]+y[:z]+x[:z],y[z:])
        )[(x[z-1]>y[z-1])+(x[z-1]<y[z-1])*2])
```

Title: Determine the winner of a game of War

Body:
Python, 160 (155?) bytes

f=lambda x,y,z=1:f(*((x,y,z+2),(x[z:]+y[:z]+x[:z],y[z:]),(x[z:],y[z:]+x[:z]+y[:z]))[(x[z-1]>y[z-1])+(x[z-1]<y[z-1])*2])if len(y)>z<len(x)else len(x)>len(y)

This solution is theoretically valid, but it require the default python maximum recursion depth to be increased for some of the test cases.

The second solution is 5 bytes longer, but work for all the test cases.

f=lambda x,y,z=1:(f(x,y,z+2)if x[z-1]==y[z-1]else f(x[z:]+y[:z]+x[:z],y[z:])if x[z-1]>y[z-1]else f(x[z:],y[z:]+x[:z]+y[:z]))if len(y)>z<len(x)else len(x)>len(y)

Edit: Ungolfed solution 1:

def f(x,y,z=1):
    if len(y)<z>len(x):
        return len(x)>len(y)
    else:
        return f(*(
            (x,y,z+2),
            (x[z:],y[z:]+x[:z]+y[:z]),
            (x[z:]+y[:z]+x[:z],y[z:])
        )[(x[z-1]>y[z-1])+(x[z-1]<y[z-1])*2])


问:
Tips for golfing in Java

Are there any useful shortcuts that can be used in Java?

As shown below, import already adds at least 17 characters to a program.

import java.io.*;
```

I understand that the simple solution would be to use another language, but it seems to be a real challenge to shorten Java programs.

Tips should be specific to Java: if they're applicable to most C-like languages, they belong in the more general list of tips.

答:
Convert String to number

There are multiple ways to convert a String to an numeric value:

String s = "12";
```
<p><em>ABC.parseABC</em>:</p>
<pre class="lang-java prettyprint-override"><code>Short.parseShort(s); // 20 bytes
Integer.parseInt(s); // 20 bytes
Long.parseLong(s);   // 18 bytes
</code>```

ABC.valueOf:

Short.valueOf(s);    // 17 bytes
Integer.valueOf(s);  // 19 bytes
Long.valueOf(s);     // 16 bytes
```
<p><em>ABC.decode</em>:</p>
<pre class="lang-java prettyprint-override"><code>// Note: does not work for numeric values with leading zeros,
// since these will be converted to octal numbers instead
Short.decode(s);     // 16 bytes
Integer.decode(s);   // 18 bytes
Long.decode(s);      // 15 bytes
</code>```

new ABC:

new Short(s);        // 13 bytes
new Integer(s);      // 15 bytes
new Long(s);         // 12 bytes
```
<p>So, for code-golfing, it's best to use the constructor when converting a String to a numeric value.</p>
<p>The same applies to <code>Double</code>; <code>Float</code>; and <code>Byte</code>.</p>
<hr />
<p>This doesn't always apply when you can re-use an already present primitive as object.<br />
As example, let's say we have the following code:</p>
<pre class="lang-java prettyprint-override"><code>// NOTE: Pretty bad example, because changing the short to int would probably be shorter..
//       but it's just an example to get the point across

short f(short i,String s){
  short r=new Short(s);  // 21 bytes
  ... // Do something with both shorts
}
</code>```

You can use .decode instead of the shorter constructor by re-using the parameter as object:

short f(Short i,String s){   // Note the short parameter has changed to Short here
  short r=i.decode(s);   // 20 bytes
  ... // Do something with both shorts
}
```

Title: Tips for golfing in Java

Body:
Convert String to number

There are multiple ways to convert a String to an numeric value:

String s = "12";

ABC.parseABC:

Short.parseShort(s); // 20 bytes
Integer.parseInt(s); // 20 bytes
Long.parseLong(s);   // 18 bytes

ABC.valueOf:

Short.valueOf(s);    // 17 bytes
Integer.valueOf(s);  // 19 bytes
Long.valueOf(s);     // 16 bytes

ABC.decode:

// Note: does not work for numeric values with leading zeros,
// since these will be converted to octal numbers instead
Short.decode(s);     // 16 bytes
Integer.decode(s);   // 18 bytes
Long.decode(s);      // 15 bytes

new ABC:

new Short(s);        // 13 bytes
new Integer(s);      // 15 bytes
new Long(s);         // 12 bytes

So, for code-golfing, it's best to use the constructor when converting a String to a numeric value.

The same applies to Double; Float; and Byte.

This doesn't always apply when you can re-use an already present primitive as object.

As example, let's say we have the following code:

// NOTE: Pretty bad example, because changing the short to int would probably be shorter..
//       but it's just an example to get the point across

short f(short i,String s){
  short r=new Short(s);  // 21 bytes
  ... // Do something with both shorts
}

You can use .decode instead of the shorter constructor by re-using the parameter as object:

short f(Short i,String s){   // Note the short parameter has changed to Short here
  short r=i.decode(s);   // 20 bytes
  ... // Do something with both shorts
}


答:
Python, 51 Bytes

```<code>from math import*
g=lambda x:x*(x+x*10**(1+int(log10(x))))
</code>```

Here's the mathematical way to do it (friend of mine found the formula).
I guess using it wouldn't produce an answer shorter than 3 bytes. :)

Title: Print a bunch of uninteresting numbers!

Body:
Python, 51 Bytes

from math import*
g=lambda x:x*(x+x*10**(1+int(log10(x))))

Here's the mathematical way to do it (friend of mine found the formula).
I guess using it wouldn't produce an answer shorter than 3 bytes. :)


答:
C, <s>70</s> <s>68</s> <s>54</s> <s>53</s> <s>52</s> 44

f(n){return(pow(10,(int)log10(n)+1)*n+n)*n;}
```
<p>Previous version (48 bytes, no math functions), saved 16 bytes thanks to @LeakyNun, 1 byte thanks to @FryAmTheEggman, 4 bytes thanks to @TobySpeight:</p>
<pre class="lang-c prettyprint-override"><code>f(n,d,i){for(i=d=n;d;d/=10)i*=10;return(i+n)*n;}
</code>```

Call f() with one argument, the number, and it returns the corresponding uninteresting number.

Test program

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
    while (*++argv) {
        int n = atoi(*argv);
        printf("%d -> %d\n", n, f(n));
    }
    return 0;
}
```
<h2>Test results:</h2>
<pre class="lang-c prettyprint-override"><code>$ ./84712 1 2 3 4 10 174
1 -> 11
2 -> 44
3 -> 99
4 -> 176
10 -> 10100
174 -> 30306276
</code>```

Try it online!

Title: Print a bunch of uninteresting numbers!

Body:
C, <s>70</s> <s>68</s> <s>54</s> <s>53</s> <s>52</s> 44

f(n){return(pow(10,(int)log10(n)+1)*n+n)*n;}

Previous version (48 bytes, no math functions), saved 16 bytes thanks to @LeakyNun, 1 byte thanks to @FryAmTheEggman, 4 bytes thanks to @TobySpeight:

f(n,d,i){for(i=d=n;d;d/=10)i*=10;return(i+n)*n;}

Call f() with one argument, the number, and it returns the corresponding uninteresting number.

Test program

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
    while (*++argv) {
        int n = atoi(*argv);
        printf("%d -> %d\n", n, f(n));
    }
    return 0;
}

Test results:

$ ./84712 1 2 3 4 10 174
1 -> 11
2 -> 44
3 -> 99
4 -> 176
10 -> 10100
174 -> 30306276

Try it online!


答:
Python, 42 bytes

Pure arithmetic approach, without strings!

f=lambda n,m=1:m<=n and f(n,m*10)or-~m*n*n
```

Ideone it!

Title: Print a bunch of uninteresting numbers!

Body:
Python, 42 bytes

Pure arithmetic approach, without strings!

f=lambda n,m=1:m<=n and f(n,m*10)or-~m*n*n

Ideone it!


答:
JavaScript, 16 bytes

In node.js (60 bytes)

```<code>process.stdin.on('data',t=>console.log(/(.+)\1{4}/.test(t)))
</code>```

Wasting a ton of bytes on input/output.

JavaScript ES6 (33 bytes)

```<code>alert(/(.+)\1{4}/.test(prompt()))
</code>```

Again wasting bytes on input/output.

Preferably, as an anonymous function (22 bytes)

```<code>n=>/(.+)\1{4}/.test(n)
</code>```

Or even shorter (16 bytes)

```<code>/(.+)\1{4}/.test
</code>```

Thanks @BusinessCat for pointing out my mistakes.

Title: Golf to find Boring numbers

Body:
If an integer has a digit/sequence of digits in it which repeats continuously (You will understand why I said "continuously") 5 or more times, we call It "Boring".

For example, 11111 is Boring, whereas 12345 is not.

Instructions

Take an Integer as Input

Output a truthy value if the integer is boring, and a falsey value if the integer is not boring.

Example

11111=>true or 1 (1 repeats 5 times)

12345=>false or 0

1112111=>false or 0

4242424242=>true or 1 (42 repeats 5 times)

-11111=>true or 1

3452514263534543543543543543876514264527473275=>true or 1 (543 repeats 5 times)

If you use other types of "truth" and "false", specify it.

Rules

Basic code-golf rules apply.

Good luck!

Body:
JavaScript, 16 bytes

In node.js (60 bytes)

process.stdin.on('data',t=>console.log(/(.+)\1{4}/.test(t)))

Wasting a ton of bytes on input/output.

JavaScript ES6 (33 bytes)

alert(/(.+)\1{4}/.test(prompt()))

Again wasting bytes on input/output.

Preferably, as an anonymous function (22 bytes)

n=>/(.+)\1{4}/.test(n)

Or even shorter (16 bytes)

/(.+)\1{4}/.test

Thanks @BusinessCat for pointing out my mistakes.


问:
Reverse a string while maintaining the capitalization in the same places
The goal here is to simply reverse a string, with one twist:

Keep the capitalization in the same places.

Example Input 1: Hello, Midnightas

Example Output 1: SathginDim ,olleh

Example Input 2: .Q

Exmaple Output 2: q.

Rules:

Output to STDOUT, input from STDIN

The winner will be picked 13th of July on GMT+3 12:00 (One week)

The input may only consist of ASCII symbols, making it easier for programs that do not use any encoding that contains non-ASCII characters.

Any punctuation ending up in a position where there was an upper-case letter must be ignored.

答:
Excel VBA, 256 bytes

```<code>Function z(d)
r = Len(d)
ReDim E(1 To r)
For i = 1 To r
b = Mid(d, i, 1)
If Asc(b) > 64 And Asc(b) < 91 Then E(i) = 1
Next i
i = 1
For p = r To 1 Step -1
v = Mid(d, p, 1)
If E(i) = 1 Then z = z & UCase(v) Else z = z & LCase(v)
i = i + 1
Next p
End Function
</code>```

Body:
Excel VBA, 256 bytes

Function z(d)
r = Len(d)
ReDim E(1 To r)
For i = 1 To r
b = Mid(d, i, 1)
If Asc(b) > 64 And Asc(b) < 91 Then E(i) = 1
Next i
i = 1
For p = r To 1 Step -1
v = Mid(d, p, 1)
If E(i) = 1 Then z = z & UCase(v) Else z = z & LCase(v)
i = i + 1
Next p
End Function


答:
Java 8, 52 bytes

s->s.matches(".*(.+)\\1{4}.*")
```
<p>Outgolfed this Java 8 answer with a direct <code>String#matches</code>.</p>
<p><strong>Explanation:</strong></p>
<p>Try it here.</p>
<pre class="lang-java prettyprint-override"><code>s->              // Method with String parameter and boolean return-type
  s.matches(     //  Return whether the entire String matches the following regex:
    ".*          //   0 or more leading characters
     (.+)\\1{4}  //   group of 1 or more characters, repeated 5 times
     .*")        //   0 or more trailing characters
</code>```

Title: Golf to find Boring numbers

Body:
Java 8, 52 bytes

s->s.matches(".*(.+)\\1{4}.*")

Outgolfed this Java 8 answer with a direct String#matches.

Explanation:

Try it here.

s->              // Method with String parameter and boolean return-type
  s.matches(     //  Return whether the entire String matches the following regex:
    ".*          //   0 or more leading characters
     (.+)\\1{4}  //   group of 1 or more characters, repeated 5 times
     .*")        //   0 or more trailing characters


答:
Jelly, 4 Bytes

```<code>;DḌ×
</code>```

Try it online

Explanation

```<code>;DḌ×    Main link. argument : N

 D      Decimal; Yield the digits of N
;       Concatenate N and its digits
  Ḍ     Convert to integer; We get O
   ×    Multiply O and N
</code>```

Title: Print a bunch of uninteresting numbers!

Body:
Jelly, 4 Bytes

;DḌ×

Try it online

Explanation

;DḌ×    Main link. argument : N

 D      Decimal; Yield the digits of N
;       Concatenate N and its digits
  Ḍ     Convert to integer; We get O
   ×    Multiply O and N


答:
Perl, 46 bytes

45 bytes code + 1 byte command line (-p)

```<code>$_="$_ $_ $_"!~/(\b\d++.*)((?1))(??{$1+$2})/
</code>```

Uses a single regex match with Perl's support for 'code expressions' inside the regex to allow for evaluation within a match.

To get around the requirement that the input is unsorted, we repeat the input string three times. This guarantees that the result is after the two operands, and allows the same digit to be matched again (e.g. in the case of input 2 4).

Usage example:

```<code>echo "3 5 6 8" | perl -p entry.pl
</code>```

Title: Is it a sum-free set?

Body:
A set is sum-free if no two (not necessarily distinct) elements when added together are part of the set itself.

For example, {1, 5, 7} is sum-free, because all members are odd, and two odd numbers when added together are always even. On the other hand, {2, 4, 9, 13} is not sum-free, as either 2 + 2 = 4 or 4 + 9 = 13 add together to a member of the set.

Write a program or function that takes a set as input, and outputs a Truthy value if the set is sum-free, and Falsy otherwise.

Examples:

```<code>Sum-free:
{}
{4}
{1, 5, 7}
{16, 1, 4, 9}

Not sum-free:
{0}
{1, 4, 5, 7}
{3, 0}
{16, 1, 4, 8}
</code>```

Body:
Perl, 46 bytes

45 bytes code + 1 byte command line (-p)

$_="$_ $_ $_"!~/(\b\d++.*)((?1))(??{$1+$2})/

Uses a single regex match with Perl's support for 'code expressions' inside the regex to allow for evaluation within a match.

To get around the requirement that the input is unsorted, we repeat the input string three times. This guarantees that the result is after the two operands, and allows the same digit to be matched again (e.g. in the case of input 2 4).

Usage example:

echo "3 5 6 8" | perl -p entry.pl


答:
Fishing, 26 bytes

```<code>v+CCCCCCCCCC
  Icc{n{n}mP
</code>```

Explained column-by column

Set casting direction downwards

Increase casting length to 1

Read input to first cell on tape

Concatenate first and second (empty) cell on tape and add to end of tape

Concatenate first and second (now containing input) cell and add to end of tape

Move to second cell (containing input)

Cast cell content to number

Move to third cell (containing input twice)

Cast cell content to number

Move to second cell.

Set content of second cell to second cell multiplied by third cell

Print second cell content

Title: Print a bunch of uninteresting numbers!

Body:
An uninteresting number (which I totally didn't make up only for this challenge) is created like this:

Take a positive integer N

Create a new number O by adding the digits of N at the end of N

The final uninteresting number is O*N

For example for N=12:

O = 1212

O*N = 1212 * 12

Final number is 14544

Input

A positive integer N (N > 0) or your language's equivalent. You don't have to catch incorrect input.

Output

The corresponding uninteresting number.

Test cases

```<code>  1 -> 11
  2 -> 44
  3 -> 99
 10 -> 10100
174 -> 30306276
</code>```

Scoring

Shortest Code in Bytes wins.

Body:
Fishing, 26 bytes

v+CCCCCCCCCC
  Icc{n{n}mP

Explained column-by column

Set casting direction downwards

Increase casting length to 1

Read input to first cell on tape

Concatenate first and second (empty) cell on tape and add to end of tape

Concatenate first and second (now containing input) cell and add to end of tape

Move to second cell (containing input)

Cast cell content to number

Move to third cell (containing input twice)

Cast cell content to number

Move to second cell.

Set content of second cell to second cell multiplied by third cell

Print second cell content


答:
Actually, 7 bytes

```<code>;;+k♂≈π
</code>```

Try it online!

Explanation:

```<code>;;+k♂≈π
;;       duplicate input twice (3 total copies)
  +      concatenate two of the copies
   k♂≈   push to a list, convert all elements to ints
      π  product
</code>```

Title: Print a bunch of uninteresting numbers!

Body:
Actually, 7 bytes

;;+k♂≈π

Try it online!

Explanation:

;;+k♂≈π
;;       duplicate input twice (3 total copies)
  +      concatenate two of the copies
   k♂≈   push to a list, convert all elements to ints
      π  product


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

```<code>ddZAr^1+**
</code>```

I knew that eventually I would find a use for the Z command!

Operation is fairly simple - count the digits, take 10 raised to that power and add one.  This gives a multiplier that concatenates the number with itself.  Then just multiply.

I/O uses the stack, as usual for dc.

Full program

This is what I used for the tests:

```<code>#!/usr/bin/dc
?
ddZAr^1+**
p
</code>```

The two extra commands give us pipeline I/O.

Tests

```<code>$ for i in 1 2 3 10 174; do printf '%d -> ' $i; ./84712.dc <<<$i; done
1 -> 11
2 -> 44
3 -> 99
10 -> 10100
174 -> 30306276
</code>```

Thanks are due to Sir Biden XVII (1 byte).

Title: Print a bunch of uninteresting numbers!

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

ddZAr^1+**

I knew that eventually I would find a use for the Z command!

Operation is fairly simple - count the digits, take 10 raised to that power and add one.  This gives a multiplier that concatenates the number with itself.  Then just multiply.

I/O uses the stack, as usual for dc.

Full program

This is what I used for the tests:

#!/usr/bin/dc
?
ddZAr^1+**
p

The two extra commands give us pipeline I/O.

Tests

$ for i in 1 2 3 10 174; do printf '%d -> ' $i; ./84712.dc <<<$i; done
1 -> 11
2 -> 44
3 -> 99
10 -> 10100
174 -> 30306276

Thanks are due to Sir Biden XVII (1 byte).


问:
Implement Takewhile

Introduction and Credit

Today without a fancy prelude: Please implement takewhile.

A variation of this (on a non-trivial data structure) was an assignment at my university functional programming course. This assignment is now closed and has been discussed in class and I have my professor's permission to post it here (I asked explicitly).

Specification

Input

The input will be a list (or your language's equivalent concept) of positive integers.

Output

The output should be a list (or your language's equivalent concept) of positive integers.

What to do?

Your task is to implement takewhile (language built-ins are allowed) with the predicate that the number under consideration is even (to focus on takewhile).

So you iterate over the list from start to end and while the condition (is even) holds, you copy to the output-list and as soon as you hit an element that doesn't make the condition true, you abort the operation and output (a step-by-step example is below). This higher-order functionality is also called takeWhile (takewhile).

Potential corner cases

The order of the output list compared to the input list may not be changed, e.g. [14,42,2] may not become [42,14].

The empty list is a valid in- and output.

Who wins?

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

Standard rules apply of course.

Test Vectors

```<code>[14, 42, 2324, 97090, 4080622, 171480372] -> [14, 42, 2324, 97090, 4080622, 171480372]
[42, 14, 42, 2324] -> [42, 14, 42, 2324]
[7,14,42] -> []
[] -> []
[171480372, 13, 14, 42] -> [171480372]
[42, 14, 42, 43, 41, 4080622, 171480372] -> [42, 14, 42]
</code>```

Step-by-Step Example

```<code>Example Input: [42, 14, 42, 43, 41, 4080622, 171480372]

Consider first element: 42
42 is even (21*2)
Put 42 into output list, output list is now [42]

Consider second element: 14
14 is even (7*2)
Put 14 into output list, output list is now [42,14]

Consider third element: 42
42 is even (21*2)
Put 42 into output list, output list is now [42,14,42]

Consider fourth element: 43
43 is not even (2*21+1)
Drop 43 and return the current output list

return [42,14,42]
</code>```

答:
PHP, <s>57</s> 55 bytes

```<code>function f($i){foreach($i as $n){if($n&1)die;echo $n;}}
</code>```

Ungolfed:

```<code>function f($i){
    foreach($i as $n){
        if($n & 1) die;
        echo $n;
    }
}
</code>```

The function takes an array $i as an input parameter.

$n & 1 will return 1 if $n is odd and 0 is $n is even.

Title: Implement Takewhile

Body:
PHP, <s>57</s> 55 bytes

function f($i){foreach($i as $n){if($n&1)die;echo $n;}}

Ungolfed:

function f($i){
    foreach($i as $n){
        if($n & 1) die;
        echo $n;
    }
}

The function takes an array $i as an input parameter.

$n & 1 will return 1 if $n is odd and 0 is $n is even.


答:
Awk, 13 bytes

```<code>$0=($0$0)*$0
</code>```

Set the line to 2 of itself multiplied by itself

Title: Print a bunch of uninteresting numbers!

Body:
Awk, 13 bytes

$0=($0$0)*$0

Set the line to 2 of itself multiplied by itself


问:
Solve the chromatic puzzle
Over at our friends at Puzzling.SE, the following puzzle was posted: Is this chromatic puzzle always solvable? by Edgar G. You can play it here.

Puzzle explanation

Given a m x n grid with tiles of three different colours, you may select any two adjacent tiles, if their colours are different. These two tiles are then converted to the third colour, i.e., the one colour not represented by these two tiles. The puzzle is solved if all tiles have the same colour. Apparently, one can prove that this puzzle is always solvable, if  neither m nor n are divisible by 3.

Of course, this begs for a solving algorithm. You will write a function or program that solves this puzzle. Note that functions with 'side effects' (i.e., the output is on stdout rather than in some awkward data type return value) are explicitly allowed.

Input & Output

The input will be an m x n matrix consisting of the integers 1, 2 and 3 (or 0, 1, 2 if convenient). You may take this input in any sane format. Both m and n are >1 and not divisible by 3. You may assume the puzzle is not solved

You will then solve the puzzle. This will involve a repeated selection of two adjacent tiles to be 'converted' (see above). You will output the two coordinates of these tiles for each step your solving algorithm took. This may also be in any sane output format. You are free to choose between 0-based and 1-based indexing of your coordinates, and whether rows or columns are indexed first. Please mention this in your answer, however.

Your algorithm should run within reasonable time on the original 8x8 case. Brute-forcing it completely is explicitly disallowed, i.e. your algorithm should run under O(k^[m*(n-1)+(m-1)*n]) with k the number of steps needed for the solution. The solution however is not required to be optimal. The proof given in the linked question may give you an idea as to how to do this (e.g., first do all columns using only vertically adjacent tiles, and then do all rows)

Test cases

In these test cases, the coordinates are 1-based and rows are indexed first (like MATLAB/Octave and probably many others).

```<code>Input:
[1 2]
Output: (result: all 3's)
[1 1],[1,2]

Input:
[ 1 2
  3 1 ]
Output: (result: all 1's)
[1 1],[2 1]        (turn left column into 2's)
[2 1],[2 2]        (turn right column into 3's)
[1 1],[1 2]        (turn top row into 1's)
[2 1],[2 2]        (turn bottom row into 1's)

Input:
[1 2 3 2
 3 2 1 1]

Output: (result: all 3's)
[1 1],[1 2]
[1 3],[1 4]
[1 2],[1 3]
[1 1],[1 2]
[1 2],[1 3]
[1 1],[1 2]
[1 3],[1 4]
[2 1],[2 2]
[1 1],[2 1]
[1 2],[2 2]
[1 3],[2 3]
[1 4],[2 4]
</code>```

If desired, I may post a pastebin of larger test cases, but I think this should be sufficient.

答:
Lua, <s>594</s> <s>575</s> 559 Bytes

Warning There's still lots of work before I'm done with this golfing! I should be able to take that under 500 Bytes, at the very least. For the moment, it's the first solution that worked, and I'm still working on it.

I will provide a full explanation once I'm done.

function f(t)s=#t a=","for i=1,s do p=t[i]for i=1,s
do p.Q=p.Q and p.Q+p[i]or p[i]end p.Q=(p.Q*#p)%3 for i=1,s do for j=1,#p-1 do
x=p[j]y=p[j+1]u=x~=y and(p.S and p.R==p.S or x~=p.Q)v=(x+y)*2p[j]=u and v%3or x
p[j+1]=u and v%3or y print(i..a..j,i..a..j+1)end
p.R=p.S p.S=table.concat(p)end end
for i=1,s do Q=Q and Q+t[i][1]or t[i][1]end Q=(Q*s)%3 for i=1,s
do for j=1,s-1 do p=t[j]q=t[j+1]x=p[1]y=q[1]u=x~=y and(S and R==S or x~=Q)v=(x+y)*2
for k=1,#p do p[k]=u and v%3or x q[k]=u and v%3or y
print(j..a..k,j+1..a..k)end Y=Y and Y..x or x end
R=S S=Y end end
```

Title: Solve the chromatic puzzle


答:
Emacs, 17 bytes

(*SPACEC-SPACEC-EM-YSPACEC-YC-Y)C-J

Explanation

(*SPACE adds (*  at point (before the number);

C-SPACEC-EM-Y Select and copy the number;

SPACE adds a space character at point (after the number);

C-YC-Y pastes two times the number at point;

) adds ) at the end;

C-J interprets the line as a LISP expression and prints its result.

Exemple

Cursor represented by a pipe (|)

|174

(*SPACE (* |174

C-SPACEC-EM-Y (* 174|

SPACE (* 174 |

C-YC-Y (* 174 174174|

) (* 174 174174)|

C-J

Result

```<code>(* 174 174174)
30306276|
</code>```

Title: Print a bunch of uninteresting numbers!

Body:
Emacs, 17 bytes

(*SPACEC-SPACEC-EM-YSPACEC-YC-Y)C-J

Explanation

(*SPACE adds (*  at point (before the number);

C-SPACEC-EM-Y Select and copy the number;

SPACE adds a space character at point (after the number);

C-YC-Y pastes two times the number at point;

) adds ) at the end;

C-J interprets the line as a LISP expression and prints its result.

Exemple

Cursor represented by a pipe (|)

|174

(*SPACE (* |174

C-SPACEC-EM-Y (* 174|

SPACE (* 174 |

C-YC-Y (* 174 174174|

) (* 174 174174)|

C-J

Result

(* 174 174174)
30306276|


答:
PowerShell, <s>25</s>, 18 bytes

Thank you TessellatingHeckler for reminding me how much PS loves the pipeline.

New 18 bytes:

```<code>process{$_*"$_$_"}
</code>```

Old 25 bytes:

```<code>param($a);[int]"$a$a"*$a
</code>```

Explanation:

```<code># new
process{$_*"$_$_"}
process{         } # runs code block once for each passed item
        $_*        # multiple the first parameter
           "$_$_"  # concatenate as a string for ease
                   # in this case, the order does the typecasting for us
# old
param($a);[int]"$a$a"*$a
param($a)                 # assigns the first passed parameter to variable $a
         ;                # line terminator
          [int]           # type cast string "$a$a" to int32
               "$a$a"     # convert $a$a to string for easy concatenation
                     *$a  # multiply by $a
</code>```

Testing (save as boring.ps1):

```<code># new
12 | .\boring.ps1
14544
174 | .\boring.ps1
30306276

# old
.\boring.ps1 12
14544
.\boring.ps1 174
30306276
</code>```

Definitely not the winning answer, but fun regardless!

Title: Print a bunch of uninteresting numbers!

Body:
PowerShell, <s>25</s>, 18 bytes

Thank you TessellatingHeckler for reminding me how much PS loves the pipeline.

New 18 bytes:

process{$_*"$_$_"}

Old 25 bytes:

param($a);[int]"$a$a"*$a

Explanation:

# new
process{$_*"$_$_"}
process{         } # runs code block once for each passed item
        $_*        # multiple the first parameter
           "$_$_"  # concatenate as a string for ease
                   # in this case, the order does the typecasting for us
# old
param($a);[int]"$a$a"*$a
param($a)                 # assigns the first passed parameter to variable $a
         ;                # line terminator
          [int]           # type cast string "$a$a" to int32
               "$a$a"     # convert $a$a to string for easy concatenation
                     *$a  # multiply by $a

Testing (save as boring.ps1):

# new
12 | .\boring.ps1
14544
174 | .\boring.ps1
30306276

# old
.\boring.ps1 12
14544
.\boring.ps1 174
30306276

Definitely not the winning answer, but fun regardless!


答:
Befunge, <s>197</s> <s>368</s> <s>696</s> 754 Bytes

(yes, I'm doing some reverse code golf, the more bytes the better)

I was thinking it could be a challenge to write this algorithm in Befunge and that it could be fun

<s>I would like it to be a community program, so if anyone wants to work on it, please, do so.</s>

In the end, I made everything alone so far, so I'll finish on my own (it's almost done)

What's done yet: a troll-shaped code

```<code>&:19p&:09p:v:p94g92g90  <
 v94+1:g94&_$59g1+59p1-:|
 >p59gp1-: ^    vp95g93$<
v94\-1<v:g<     >  v
>g:1+v^_$v^90p94g92<
v5p94<   3>1+59p   ^
>9gg+\:^ %g   v93:g95<           v3_2         v
v1pg95g94<^95<>g-v>$v^           v ^-%3*2\gg9<
>9g39g+59g-1-|v-1_^ #^pg95+g92g90<1_09g:29g+5^
       ;  >  >  09g:29g+59gg\3%-# !^v         <
          ^p95<                  ^  <
     v  p96-1+g90g92<
     v                  p95_@
            >59g1+:39g-19g-^
     v    >p 79g:59gg\1+59gp$$$$$29g49pv
    > p59g^ |<<<<<<<<<<<<<<<<<<!-g96g94<
>:79^>29g49p>69g1+59gg49g:59gg\1+49p- v
^\-\6+gg95+1\g< v         !-g96:<-1g94_^
>"]",52*,::59g^v_::1+59gg\59gg-v^ <
^ .-g93g95,.-g<>:69g- v  v-g96:_1+^
>+" [,]",,,\29^       >#v_$:49g2-v
^1:.-g93g95,.-g92\,"[ ":<        <
</code>```

(yes, it's a troll, believe me)

Basically, it reads an array and computes the move to do to solve the rows, given an input as

```<code>(number of rows) (number of columns) 1 2 3 1 1 3 2 1 2 ....
</code>```

(the whole array is passed as a list [row1, row2, row3,…])

output is

```<code>[col row],[col',row']
[col2 row2],[col2',row2']
...
</code>```

rows and cols both start at 0.

Now that rows are solved, it's almost done ! Hooray !

Explanation: (will be updated later on)

So there are 5 main parts :

The first one, in green, reads the input line and writes one row of the array

The second one, in orange, passes to the next row of the array

The third, in the blue, sums a row

The fourth one, in hot pink, takes the modulus 3 of the sum, saves it at the right of the concerned row, and go to the next row

Finally, in the red, the part that computes the target color from the previously computed number. This part is really dumb and should probably be rewritten, but I didn't figure out how I could do that in a nice way (passed from 197 bytes to 368 with just that part)

Grey parts are initialisations

Here is a a deeper explanation of the module that finds the to boxes to combine (which is coded here, by the way)

```<code>                                       B
            @                          v
            |                  !-g96g94<
ENTRY>29g49p>69g1+59gg49g:59gg\1+49p- v
                v         !-g96:<-1g94_^
               v_::1+59gg\59gg-v^ <
               >:69g- v  v-g96:_1+^
                      >#v_$:49g2-v
                    CALL<        <
</code>```

The CALL part is when the instruction pointer is going to another module, to combine to boxes. It comes back to this module through the 'B' entry

Here is some pseudo code:
(currentx is related to the array reading)
    For:

```<code>    69g1+59gg  // read target color
    49g:59gg\1+49p // read current color and THEN shift the currentx to the next box
    if ( top != top ){  // if the current color is bad
        49g1-          //  put the current place  (or currentx - 1) in the stack
        While:
            if ( :top != 69g ){   // if you didn't reach the end of the list
                ::1+              // copy twice, add 1
                if ( 59gg == \59gg ){ // if the next color is the same than current
                   1+                // iterate
                   break While;
                }
            }

        : // copies j (the previous raw iterator)
        if ( top == 69g ){  // if you reached the end of the row (which mean you can't swap with the color after that point)
            $:              // discard j's copy and copy target
            49g2-           // put the place just before the color change on the stack
            combine_with_next;
        } else {
            combine_with_next;
        }
        29g49p   // back to the beginning of the row (there was some changes int the row)
    }

    if ( 49g != 69g ) // if you didn't reach the end of the list
        break For:
</code>```

Note that if you want to test it, you will have to put some trailing space and trailing new lines so that there is enough space to store the array, if you wish to use the interpret I linked.
22 + the number of rows in input as trailing lines, and 34 + the number of columns as trailing spaces on one line should be ok.

Title: Solve the chromatic puzzle

Body:
Over at our friends at Puzzling.SE, the following puzzle was posted: Is this chromatic puzzle always solvable? by Edgar G. You can play it here.

Puzzle explanation

Given a m x n grid with tiles of three different colours, you may select any two adjacent tiles, if their colours are different. These two tiles are then converted to the third colour, i.e., the one colour not represented by these two tiles. The puzzle is solved if all tiles have the same colour. Apparently, one can prove that this puzzle is always solvable, if  neither m nor n are divisible by 3.

Of course, this begs for a solving algorithm. You will write a function or program that solves this puzzle. Note that functions with 'side effects' (i.e., the output is on stdout rather than in some awkward data type return value) are explicitly allowed.

Input & Output

The input will be an m x n matrix consisting of the integers 1, 2 and 3 (or 0, 1, 2 if convenient). You may take this input in any sane format. Both m and n are >1 and not divisible by 3. You may assume the puzzle is not solved

You will then solve the puzzle. This will involve a repeated selection of two adjacent tiles to be 'converted' (see above). You will output the two coordinates of these tiles for each step your solving algorithm took. This may also be in any sane output format. You are free to choose between 0-based and 1-based indexing of your coordinates, and whether rows or columns are indexed first. Please mention this in your answer, however.

Your algorithm should run within reasonable time on the original 8x8 case. Brute-forcing it completely is explicitly disallowed, i.e. your algorithm should run under O(k^[m*(n-1)+(m-1)*n]) with k the number of steps needed for the solution. The solution however is not required to be optimal. The proof given in the linked question may give you an idea as to how to do this (e.g., first do all columns using only vertically adjacent tiles, and then do all rows)

Test cases

In these test cases, the coordinates are 1-based and rows are indexed first (like MATLAB/Octave and probably many others).

```<code>Input:
[1 2]
Output: (result: all 3's)
[1 1],[1,2]

Input:
[ 1 2
  3 1 ]
Output: (result: all 1's)
[1 1],[2 1]        (turn left column into 2's)
[2 1],[2 2]        (turn right column into 3's)
[1 1],[1 2]        (turn top row into 1's)
[2 1],[2 2]        (turn bottom row into 1's)

Input:
[1 2 3 2
 3 2 1 1]

Output: (result: all 3's)
[1 1],[1 2]
[1 3],[1 4]
[1 2],[1 3]
[1 1],[1 2]
[1 2],[1 3]
[1 1],[1 2]
[1 3],[1 4]
[2 1],[2 2]
[1 1],[2 1]
[1 2],[2 2]
[1 3],[2 3]
[1 4],[2 4]
</code>```

If desired, I may post a pastebin of larger test cases, but I think this should be sufficient.

Body:
Befunge, <s>197</s> <s>368</s> <s>696</s> 754 Bytes

(yes, I'm doing some reverse code golf, the more bytes the better)

I was thinking it could be a challenge to write this algorithm in Befunge and that it could be fun

<s>I would like it to be a community program, so if anyone wants to work on it, please, do so.</s>

In the end, I made everything alone so far, so I'll finish on my own (it's almost done)

What's done yet: a troll-shaped code

&:19p&:09p:v:p94g92g90  <
 v94+1:g94&_$59g1+59p1-:|
 >p59gp1-: ^    vp95g93$<
v94\-1<v:g<     >  v
>g:1+v^_$v^90p94g92<
v5p94<   3>1+59p   ^
>9gg+\:^ %g   v93:g95<           v3_2         v
v1pg95g94<^95<>g-v>$v^           v ^-%3*2\gg9<
>9g39g+59g-1-|v-1_^ #^pg95+g92g90<1_09g:29g+5^
       ;  >  >  09g:29g+59gg\3%-# !^v         <
          ^p95<                  ^  <
     v  p96-1+g90g92<
     v                  p95_@
            >59g1+:39g-19g-^
     v    >p 79g:59gg\1+59gp$$$$$29g49pv
    > p59g^ |<<<<<<<<<<<<<<<<<<!-g96g94<
>:79^>29g49p>69g1+59gg49g:59gg\1+49p- v
^\-\6+gg95+1\g< v         !-g96:<-1g94_^
>"]",52*,::59g^v_::1+59gg\59gg-v^ <
^ .-g93g95,.-g<>:69g- v  v-g96:_1+^
>+" [,]",,,\29^       >#v_$:49g2-v
^1:.-g93g95,.-g92\,"[ ":<        <

(yes, it's a troll, believe me)

Basically, it reads an array and computes the move to do to solve the rows, given an input as

(number of rows) (number of columns) 1 2 3 1 1 3 2 1 2 ....

(the whole array is passed as a list [row1, row2, row3,…])

output is

[col row],[col',row']
[col2 row2],[col2',row2']
...

rows and cols both start at 0.

Now that rows are solved, it's almost done ! Hooray !

Explanation: (will be updated later on)

So there are 5 main parts :

The first one, in green, reads the input line and writes one row of the array

The second one, in orange, passes to the next row of the array

The third, in the blue, sums a row

The fourth one, in hot pink, takes the modulus 3 of the sum, saves it at the right of the concerned row, and go to the next row

Finally, in the red, the part that computes the target color from the previously computed number. This part is really dumb and should probably be rewritten, but I didn't figure out how I could do that in a nice way (passed from 197 bytes to 368 with just that part)

Grey parts are initialisations

Here is a a deeper explanation of the module that finds the to boxes to combine (which is coded here, by the way)

                                       B
            @                          v
            |                  !-g96g94<
ENTRY>29g49p>69g1+59gg49g:59gg\1+49p- v
                v         !-g96:<-1g94_^
               v_::1+59gg\59gg-v^ <
               >:69g- v  v-g96:_1+^
                      >#v_$:49g2-v
                    CALL<        <

The CALL part is when the instruction pointer is going to another module, to combine to boxes. It comes back to this module through the 'B' entry

Here is some pseudo code:
(currentx is related to the array reading)
    For:

    69g1+59gg  // read target color
    49g:59gg\1+49p // read current color and THEN shift the currentx to the next box
    if ( top != top ){  // if the current color is bad
        49g1-          //  put the current place  (or currentx - 1) in the stack
        While:
            if ( :top != 69g ){   // if you didn't reach the end of the list
                ::1+              // copy twice, add 1
                if ( 59gg == \59gg ){ // if the next color is the same than current
                   1+                // iterate
                   break While;
                }
            }

        : // copies j (the previous raw iterator)
        if ( top == 69g ){  // if you reached the end of the row (which mean you can't swap with the color after that point)
            $:              // discard j's copy and copy target
            49g2-           // put the place just before the color change on the stack
            combine_with_next;
        } else {
            combine_with_next;
        }
        29g49p   // back to the beginning of the row (there was some changes int the row)
    }

    if ( 49g != 69g ) // if you didn't reach the end of the list
        break For:

Note that if you want to test it, you will have to put some trailing space and trailing new lines so that there is enough space to store the array, if you wish to use the interpret I linked.
22 + the number of rows in input as trailing lines, and 34 + the number of columns as trailing spaces on one line should be ok.


答:
TSQL, 151 bytes

Golfed:

```<code>DECLARE @t varchar(99)='11111'

,@z bit=0,@a INT=1,@ INT=1WHILE @a<LEN(@t)SELECT @z=IIF(@t LIKE'%'+replicate(SUBSTRING(@t,@a,@),5)+'%',1,@z),@=IIF(@=20,1,@+1),@a+=IIF(@=1,1,0)PRINT @z
</code>```

Ungolfed:

```<code>DECLARE @t varchar(99)='11111'

,@z bit=0,
@a INT=1,
@ INT=1
WHILE @a<LEN(@t)
  SELECT
    @z=IIF(@t LIKE'%'+replicate(SUBSTRING(@t,@a,@),5)+'%',1,@z),
    @=IIF(@=20,1,@+1),
    @a+=IIF(@=1,1,0)

PRINT @z
</code>```

Fiddle

Title: Golf to find Boring numbers

Body:
If an integer has a digit/sequence of digits in it which repeats continuously (You will understand why I said "continuously") 5 or more times, we call It "Boring".

For example, 11111 is Boring, whereas 12345 is not.

Instructions

Take an Integer as Input

Output a truthy value if the integer is boring, and a falsey value if the integer is not boring.

Example

11111=>true or 1 (1 repeats 5 times)

12345=>false or 0

1112111=>false or 0

4242424242=>true or 1 (42 repeats 5 times)

-11111=>true or 1

3452514263534543543543543543876514264527473275=>true or 1 (543 repeats 5 times)

If you use other types of "truth" and "false", specify it.

Rules

Basic code-golf rules apply.

Good luck!

Body:
TSQL, 151 bytes

Golfed:

DECLARE @t varchar(99)='11111'

,@z bit=0,@a INT=1,@ INT=1WHILE @a<LEN(@t)SELECT @z=IIF(@t LIKE'%'+replicate(SUBSTRING(@t,@a,@),5)+'%',1,@z),@=IIF(@=20,1,@+1),@a+=IIF(@=1,1,0)PRINT @z

Ungolfed:

DECLARE @t varchar(99)='11111'

,@z bit=0,
@a INT=1,
@ INT=1
WHILE @a<LEN(@t)
  SELECT
    @z=IIF(@t LIKE'%'+replicate(SUBSTRING(@t,@a,@),5)+'%',1,@z),
    @=IIF(@=20,1,@+1),
    @a+=IIF(@=1,1,0)

PRINT @z

Fiddle


答:
PowerShell, 26 bytes

```<code>$args[0]-match"(.+)\1{4}"
</code>```

I'm by no means a regex master, so credit to the other answers for that.

Title: Golf to find Boring numbers

Body:
PowerShell, 26 bytes

$args[0]-match"(.+)\1{4}"

I'm by no means a regex master, so credit to the other answers for that.


答:
PHP, 64 bytes

```<code>function f($i){$a=0;for($k=-1;($k+=2)*$k<$i;$a+=$k*$k);echo $a;}
</code>```

Expanded:

```<code>function f($i){
    $a=0;
    for($k=-1; ($k+=2)*$k<$i; $a+=$k*$k);
    echo $a;
}
</code>```

On every iteration of the for loop, it will add 2 to k and check if k2 is less than $i, if it is add k2 to $a.

Title: Sum the odd square numbers less than N

Body:
Write a program or function to output the sum of the odd square numbers (OEIS #A016754) less than an input n.

The first 44 numbers in the sequence are:

```<code>1, 9, 25, 49, 81, 121, 169, 225, 289, 361, 441, 529, 625, 729, 841, 961, 1089,
1225, 1369, 1521, 1681, 1849, 2025, 2209, 2401, 2601, 2809, 3025, 3249, 3481,
3721, 3969, 4225, 4489, 4761, 5041, 5329, 5625, 5929, 6241, 6561, 6889, 7225, 7569
</code>```

The formula for the sequence is a(n) = ( 2n + 1 ) ^ 2.

Notes

Your program's behaviour may be undefined for n < 1 (that is, all valid inputs are >= 1.)

Test cases

```<code>1 => 0
2 => 1
9 => 1
10 => 10
9801 => 156849
9802 => 166650
10000 => 166650
</code>```

Body:
PHP, 64 bytes

function f($i){$a=0;for($k=-1;($k+=2)*$k<$i;$a+=$k*$k);echo $a;}

Expanded:

function f($i){
    $a=0;
    for($k=-1; ($k+=2)*$k<$i; $a+=$k*$k);
    echo $a;
}

On every iteration of the for loop, it will add 2 to k and check if k2 is less than $i, if it is add k2 to $a.


答:
R 34 bytes

```<code>y=scan();as.numeric(paste0(y,y))*y
</code>```

Title: Print a bunch of uninteresting numbers!

Body:
R 34 bytes

y=scan();as.numeric(paste0(y,y))*y


答:
Mathematica, <s>46</s> <s>40</s> 36 bytes

```<code>b=a__;StringContainsQ[b~~b~~b~~b~~b]
</code>```

Function. Takes a string as input and outputs True or False. Tests strings against the expression a__~~a__~~a__~~a__~~a__, which represents the same character sequence repeated 5 times. For reference, the shortest solution using a regex is 45 bytes long:

```<code>StringContainsQ@RegularExpression@"(.+)\1{4}"
</code>```

curse you RegularExpression!

Title: Golf to find Boring numbers

Body:
Mathematica, <s>46</s> <s>40</s> 36 bytes

b=a__;StringContainsQ[b~~b~~b~~b~~b]

Function. Takes a string as input and outputs True or False. Tests strings against the expression a__~~a__~~a__~~a__~~a__, which represents the same character sequence repeated 5 times. For reference, the shortest solution using a regex is 45 bytes long:

StringContainsQ@RegularExpression@"(.+)\1{4}"

curse you RegularExpression!


问:
Write a JSON validator
Write a program that determines whether its input is valid JSON.

Input: ASCII text: [\x00-\x7F]*

Note: if ASCII is problematic, feel free to use another encoding, but indicate it in your post.

Output: Valid or Invalid.  Trailing newline may be omitted.

Example:

```<code> $ echo '{"key": "value"}' | ./json-validate
 Valid
 $ echo '{key: "value"}' | ./json-validate
 Invalid
</code>```

Rules:

Do not use a JSON parsing library.

Partially-correct solutions are allowed, but frowned upon.

Post your test suite score (see below).

The shortest correct solution wins.

Please run json-validate-test-suite.sh on your program, and post your score.  Example:

```<code>$ ./json-validate-test-suite.sh ./buggy-prog
fail: should be invalid:  [ 0.1e ]
fail: should be invalid:  [ 0.1e+-1 ]
fail: should be invalid:  [ 0.1e-+1 ]
score: 297/300
</code>```

Resources:

json.org - Concise definition of the JSON grammar with easy-to-follow pictures.

RFC 4627 - JSON specification

json-validate.c - A 200-line implementation that passes the testsuite.

The JSON grammar is as follows:

```<code>json: object | array

object: '{' members? '}'
    members: pair (',' pair)*
    pair:    string ':' value

array: '[' elements? ']'
    elements: value (',' value)*

value: string
     | number
     | object
     | array
     | 'true'
     | 'false'
     | 'null'

string: '"' char* '"'
    char: [^"\\\x00-\x1F]
        | '\' escape
    escape: ["\\/bfnrt]
          | u [0-9A-Fa-f]{4}

number: '-'? (0 | [1-9][0-9]*) ('.' [0-9]+)? ([Ee] [+-]? [0-9]+)?
</code>```

Also, whitespace can appear before or after any of the six structural characters {}[]:,

```<code>ws = [\t\n\r ]*
</code>```

Bear in mind the following:

Be careful with functions like isspace().  Whitespace in JSON is [\t\n\r ], but isspace() also treats \v (vertical tab) and \f (form feed) as space.  Although word has it that isdigit() can accept more than just [0-9], should be okay to use here, as we assume input is in ASCII.

\x7F is technically a control character, but the JSON RFC doesn't mention it (it only mentions [\x00-\x1F]), and most JSON parsers tend to accept \x7F characters in strings.  Because of this ambiguity, solutions may choose to either accept them or not.

答:
Scala - 390 chars

```<code>import scala.util.parsing.combinator.JavaTokenParsers
object J extends JavaTokenParsers{def j=o|a
def o:Parser[Any]="{"~repsep(p,",")~"}"
def p=s~":"~v
def a:Parser[Any]="["~repsep(v,",")~"]"
def v=s|o|a|"true"|"false"|"null"
def s=stringLiteral
def n=floatingPointNumber}
object Main{def main(a:Array[String]){print(if(J.parseAll(J.j,readLine()).successful)"Valid"else"Invalid")}}
</code>```

This is no-brainer soluton, using parser combinators. Written in 1 or 2 minutes, literally. Cannot get validator script, browser said that server not found.

Title: Write a JSON validator

Body:
Scala - 390 chars

import scala.util.parsing.combinator.JavaTokenParsers
object J extends JavaTokenParsers{def j=o|a
def o:Parser[Any]="{"~repsep(p,",")~"}"
def p=s~":"~v
def a:Parser[Any]="["~repsep(v,",")~"]"
def v=s|o|a|"true"|"false"|"null"
def s=stringLiteral
def n=floatingPointNumber}
object Main{def main(a:Array[String]){print(if(J.parseAll(J.j,readLine()).successful)"Valid"else"Invalid")}}

This is no-brainer soluton, using parser combinators. Written in 1 or 2 minutes, literally. Cannot get validator script, browser said that server not found.


Title: Reverse a string while maintaining the capitalization in the same places

Body:
The goal here is to simply reverse a string, with one twist:

Keep the capitalization in the same places.

Example Input 1: Hello, Midnightas

Example Output 1: SathginDim ,olleh

Example Input 2: .Q

Exmaple Output 2: q.

Rules:

Output to STDOUT, input from STDIN

The winner will be picked 13th of July on GMT+3 12:00 (One week)

The input may only consist of ASCII symbols, making it easier for programs that do not use any encoding that contains non-ASCII characters.

Any punctuation ending up in a position where there was an upper-case letter must be ignored.

Body:
C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char *argv[])
{
  char *a,*b,*c;

  a=c=strdup(argv[1]);
  b=&argv[1][strlen(a)-1];
  for(;*a;a++,b--){
    *a=(*a>='A'&&*a<='Z')?((*b>='a'&&*b<='z')?*b-32:*b):((*b>='A'&&*b<='Z')?*b+32:*b);
  }
  puts(c);
  free(c);
  return 0;
}


答:
PHP, <s>37</s> 33 bytes

thanks to NoOneIsHere, I forgot about <?=

program for PHP<5.4, prints 1 for boring numbers, 0 else

```<code><?=preg_match('/(.+)\1{4}/U',$n);
</code>```

usage:

set register_globals=1 in php.ini for php-cgi

then call php-cgi <filename> n=<number>;echo""

for PHP>=5.4, replace $n with $_GET[n]

non-regexp solution, <s>152</s> <s>147</s> 140 bytes

```<code><?for($e=$n+1;--$e;)for($f=$e;$f--;)for($a=str_split(substr($n,$f),$e),$k=$c='';strlen($v=array_pop($a));)$c-$v?$k=0&$c=$v:($k++<3?:die(1));
</code>```

returns exit code 1 for boring numbers, 0 else

replace die(1) with die(print 1) and append echo 0; to print instead

same usage as above, but also set short_open_tags=1 if disabled

The outer loop got an unreasonable start value in the golfing, replace $n+1 with ceil(strlen($n)/5)+1 or at least with strlen($n) for testing or it may loop like forever.

Title: Golf to find Boring numbers

Body:
PHP, <s>37</s> 33 bytes

thanks to NoOneIsHere, I forgot about <?=

program for PHP<5.4, prints 1 for boring numbers, 0 else

<?=preg_match('/(.+)\1{4}/U',$n);

usage:

set register_globals=1 in php.ini for php-cgi

then call php-cgi <filename> n=<number>;echo""

for PHP>=5.4, replace $n with $_GET[n]

non-regexp solution, <s>152</s> <s>147</s> 140 bytes

<?for($e=$n+1;--$e;)for($f=$e;$f--;)for($a=str_split(substr($n,$f),$e),$k=$c='';strlen($v=array_pop($a));)$c-$v?$k=0&$c=$v:($k++<3?:die(1));

returns exit code 1 for boring numbers, 0 else

replace die(1) with die(print 1) and append echo 0; to print instead

same usage as above, but also set short_open_tags=1 if disabled

The outer loop got an unreasonable start value in the golfing, replace $n+1 with ceil(strlen($n)/5)+1 or at least with strlen($n) for testing or it may loop like forever.


问:
Shamir's Secret Sharing
Given n (the number of players), t (the threshold value), and s (the secret), output the n secrets generated by Shamir's Secret Sharing algorithm.

The Algorithm

For the purposes of this challenge, the computations will be done in GF(251) (the finite field of size 251, otherwise known as the integers mod 251). Ordinarily, the field would be chosen such that its size is a prime much greater than n. To simplify the challenge, the field size will be constant. 251 has been chosen because it is the largest prime representable by an 8-bit unsigned integer.

Generate t-1 random integers in the (inclusive) range [0, 250]. Label these a1 through at-1.

Construct a t-1th degree polynomial using s as the constant value and the random integers from step 1 as the coefficients of the powers of x: f(x) = s + x*a1 + x2*a2 + ... + xt-1*at-1.

Output (f(z) mod 251) for each z in the (inclusive) range [1, n].

Reference Implementation

#!/usr/bin/env python
from __future__ import print_function
import random
import sys

# Shamir's Secret Sharing algorithm
# Input is taken on the command line, in the format "python shamir.py n t s"

n, t, s = [int(x) for x in sys.argv[1:4]]
if t > n:
    print("Error: t must be less than or equal to n")
    exit()
if n not in range(2, 251):
    print("Error: n must be a positive integer less than 251")
    exit()
if t not in range(2, 251):
    print("Error: t must be a positive integer less than 251")
    exit()
if s not in range(251):
    print("Error: s must be a non-negative integer less than 251")
    exit()
p = 251
a = [random.randrange(0, 251) for x in range(t-1)]

def f(x):
    return s + sum(c*x**(i+1) for i,c in enumerate(a))

# Outputting the polynomial is for explanatory purposes only, and should not be included
#  in the output for the challenge
print("f(x) = {0} + {1}".format(s, ' + '.join('{0}*x^{1}'.format(c, i+1) for i,c in enumerate(a))))
for z in range(1, n+1):
    print(f(z) % p)
```

<h2>Verification</h2>

<p>The following Stack Snippet can be used to verify outputs:</p>

<p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var validate = function() {
  $('#nts-error').attr('hidden', parseInt($('#n').val()) >= parseInt($('#t').val()));
  $('#check').prop('disabled', parseInt($('#n').val()) < parseInt($('#t').val()));
};

// the following function is taken from https://rosettacode.org/wiki/Combinations#JavaScript
var combinations = function(arr, k) {
  var i,
    subI,
    ret = [],
    sub,
    next;
  for (i = 0; i < arr.length; i++) {
    if (k === 1) {
      ret.push([arr[i]]);
    } else {
      sub = combinations(arr.slice(i + 1, arr.length), k - 1);
      for (subI = 0; subI < sub.length; subI++) {
        next = sub[subI];
        next.unshift(arr[i]);
        ret.push(next);
      }
    }
  }
  return ret;
};

// The following code is taken from https://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing#Javascript_example with the modification that the prime is 251, not 257

var prime = 251;

/* Gives the decomposition of the gcd of a and b.  Returns [x,y,z] such that x = gcd(a,b) and y*a + z*b = x */
function gcdD(a, b) {
  if (b == 0) return [a, 1, 0];
  else {
    var n = Math.floor(a / b),
      c = a % b,
      r = gcdD(b, c);
    return [r[0], r[2], r[1] - r[2] * n];
  }
}

/* Gives the multiplicative inverse of k mod prime.  In other words (k * modInverse(k)) % prime = 1 for all prime > k >= 1  */
function modInverse(k) {
  k = k % prime;
  var r = (k < 0) ? -gcdD(prime, -k)[2] : gcdD(prime, k)[2];
  return (prime + r) % prime;
}

/* Join the shares into a number */
function join(shares) {
  var accum, count, formula, startposition, nextposition, value, numerator, denominator;
  for (formula = accum = 0; formula < shares.length; formula++) {
    /* Multiply the numerator across the top and denominators across the bottom to do Lagrange's interpolation
     * Result is x0(2), x1(4), x2(5) -> -4*-5 and (2-4=-2)(2-5=-3), etc for l0, l1, l2...
     */
    for (count = 0, numerator = denominator = 1; count < shares.length; count++) {
      if (formula == count) continue; // If not the same value
      startposition = shares[formula][0];
      nextposition = shares[count][0];
      numerator = (numerator * -nextposition) % prime;
      denominator = (denominator * (startposition - nextposition)) % prime;
    }
    value = shares[formula][1];
    accum = (prime + accum + (value * numerator * modInverse(denominator))) % prime;
  }
  return accum;
}

$('#check').click(
  function() {
    var good = true;
    var problem = [];
    var n = parseInt($('#n').val());
    var t = parseInt($('#t').val());
    var s = parseInt($('#s').val());
    combinations([...Array(n + 1).keys()].slice(1), t).forEach(
      function(xArr) {
        var xfArr = xArr.map(
          function(x) {
            return [x, parseInt($('#f' + x).val())];
          }
        );
        var L = join(xfArr);
        if (L !== s) {
          good = false;
          problem.push(xArr);
        }
      }
    );
    $('#valid').html(good ? "True" : ("False (problematic secret sets: {" + problem.map(
      function(elem) {
        return "[" + elem.join(', ') + "]";
      }) + "})"));
  }
);

$('#n').change(
  function() {
    var inputHTML = "";
    for (var i = 1; i <= parseInt($('#n').val()); i++) {
      inputHTML += 'f(' + i + '): <input type="number" min="0" max="250" value="0" id="f' + i + '"><br>\r\n';
    }
    $('#inputs').html(inputHTML);
    validate();
  }
);

$('#t').change(
  function() {
    validate();
  }
);</code>```

n:
<input type="number" min="2" max="250" value="6" id="n">t:
<input type="number" min="2" max="250" value="3" id="t">s:
<input type="number" min="0" max="250" value="230" id="s">

t must be less than or equal to n!

  f(1):
  <input type="number" min="0" max="250" value="35" id="f1">

f(2):
  <input type="number" min="0" max="250" value="95" id="f2">

f(3):
  <input type="number" min="0" max="250" value="159" id="f3">

f(4):
  <input type="number" min="0" max="250" value="227" id="f4">

f(5):
  <input type="number" min="0" max="250" value="48" id="f5">

f(6):
  <input type="number" min="0" max="250" value="124" id="f6">

<input type="submit" id="check" value="Verify">

Valid:

```

Rules

s will be a non-negative integer less than 251, and n and t will be positive integers less than 251 and greater than 1. Furthermore, you are guaranteed that the inputs are valid (meaning t <= n).

Input and output can be in any reasonable, unambiguous, and consistent format.

Random numbers are to be sampled from a uniform distribution - each possible value should have equal probability of being chosen.

答:
Pyth, 24 bytes

```<code>J+EmOK251tEm%s.e*b^dkJKS
</code>```

Try it online!

Input order: n s t separated by linefeed.

Title: Shamir's Secret Sharing

Body:
Pyth, 24 bytes

J+EmOK251tEm%s.e*b^dkJKS

Try it online!

Input order: n s t separated by linefeed.