问:
Count up folks!

Introduction

It may sound strange, but we haven't got ONE challenge for counting from 1 to n, inclusive.

This is not the same thing. That one is a (closed) not well-explained challenge.

This is not the same thing. That one is about counting up indefinitely.

Challenge

Write a program or function that prints every integer from 1 to n inclusive.

Rules

You can get n any way.

You can assume that n will always be a positive integer.

You can get n in any base, but you should always output in decimal.

Output must be separated by any character (or pattern) not in 0123456789. Non-decimal leading or trailing characters are allowed (for example when using arrays such as [1, 2, 3, 4, 5, 6]).

Standard loopholes are denied.

We want to find the shortest approach in each language, not the shortest language, so I will not accept any answer.

You must update your answer(s) after this edit, answers posted before the last edit must comply with the change rule about standard loopholes (I didn't want to deny them, but I didn't want to make the community roar, so I denied them).

You can use any post-dating language version (or language). You cannot use any language or language version made just for this challenge.

Bonuses

20%

Your program must be able to count at least up to 18446744073709551615 (2^64-1). For example, if a new datatype is the only way to support big integers, you must construct it. If your language does not have any way to support huge integers up to 2^64-1, the upper limit of that particular language must be supported instead.

EDIT: I've changed the limit from 2^64 to 2^64-1 to allow more answers.

EDIT: I made the 2^64-1 rule a bonus, since there has not been much interest in this challenge. If your answer supports 2^64-1, you can now edit it to include the bonus. Also, you can post an answer not supporting it, if it is shorter.

答:
Sesos, 3 bytes

```<code>Hexdump of generated binary file:

0000000: 16f8ce                                            ...

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

Try it online!

Assembler:

set numin
set numout
get
jmp
sub 1
fwd 1
add 1
put
rwd 1
           ;implicit jnz
```

Brainfuck pseudocode: ,[->+.<]

Title: Count up folks!

Body:
Sesos, 3 bytes

Hexdump of generated binary file:

0000000: 16f8ce                                            ...

Size   : 3 byte(s)

Try it online!

Assembler:

set numin
set numout
get
jmp
sub 1
fwd 1
add 1
put
rwd 1
           ;implicit jnz

Brainfuck pseudocode: ,[->+.<]


答:
Emacs Lisp, 39 bytes

```<code>(lambda(n)(princ(number-sequence 1 n)))
</code>```

ContentLicense: CC BY-SA 3.0

Title: Count up folks!

Body:
Introduction

It may sound strange, but we haven't got ONE challenge for counting from 1 to n, inclusive.

This is not the same thing. That one is a (closed) not well-explained challenge.

This is not the same thing. That one is about counting up indefinitely.

Challenge

Write a program or function that prints every integer from 1 to n inclusive.

Rules

You can get n any way.

You can assume that n will always be a positive integer.

You can get n in any base, but you should always output in decimal.

Output must be separated by any character (or pattern) not in 0123456789. Non-decimal leading or trailing characters are allowed (for example when using arrays such as [1, 2, 3, 4, 5, 6]).

Standard loopholes are denied.

We want to find the shortest approach in each language, not the shortest language, so I will not accept any answer.

You must update your answer(s) after this edit, answers posted before the last edit must comply with the change rule about standard loopholes (I didn't want to deny them, but I didn't want to make the community roar, so I denied them).

You can use any post-dating language version (or language). You cannot use any language or language version made just for this challenge.

Bonuses

20%

Your program must be able to count at least up to 18446744073709551615 (2^64-1). For example, if a new datatype is the only way to support big integers, you must construct it. If your language does not have any way to support huge integers up to 2^64-1, the upper limit of that particular language must be supported instead.

EDIT: I've changed the limit from 2^64 to 2^64-1 to allow more answers.

EDIT: I made the 2^64-1 rule a bonus, since there has not been much interest in this challenge. If your answer supports 2^64-1, you can now edit it to include the bonus. Also, you can post an answer not supporting it, if it is shorter.

Body:
Emacs Lisp, 39 bytes

(lambda(n)(princ(number-sequence 1 n)))


问:
Score a game of Bowling
Your task is to sum up and output one player's score in a game of 10-pin bowling after up to 21 rolls.

The rolls are represented as a sequence of integers in your preferred method of input.
Each integer corresponds to the number of pins that were knocked down in that roll.

Scoring

After each round the number of pins knocked down in that round is counted into the final score.
If a player knocks down all ten pins in the first roll of a round, this is a strike, and the round is over.
Otherwise, the round lasts for one more roll. If the second roll of a round knocks down all the remaining pins, this is a spare.

For each strike there is a bonus equal to the sum of pins knocked down in the two next rolls.
For each spare there is a bonus equal to the number of pins knocked down in the next roll.

The 10th and final round, the player may be granted extra rolls:
In case of a strike, the player gets two more rolls to make up his strike bonus.
In case of a spare, the player gets one more roll.

Examples

```<code>Input: 4 3 8 2 7 1 10 7 3 0 10 2 2 10 10 5 4
Output: 131

Input: 10 10 9 1 7 3 2 7 10 1 9 10 7 1 10 10 10
Output: 183
</code>```

Rules

You may assumed that the input is valid.

As per Mego's comment I have loosened the requirements for the input/output methods to meet our current standard.

Answers in languages that are newer than the challenge are allowed

Shortest code wins!

答:
Perl, 140?

First attempt:

```<code>#!/usr/bin/perl
# usage: ./bowling.pl [list of scores]

@A=@ARGV;{last if(9<$n++);$a=shift@A;$S+=$a;($S+=$A[0]+$A[1])&redo if($a==10);$b=shift@A;$S+=$b;($S+=$A[0])&redo if(10==$a+$b);redo}print$S
</code>```

Sadly, there are certain cases where it fails. I will come and redo it later.

ContentLicense: CC BY-SA 4.0

Title: Score a game of Bowling

Body:
Perl, 140?

First attempt:

#!/usr/bin/perl
# usage: ./bowling.pl [list of scores]

@A=@ARGV;{last if(9<$n++);$a=shift@A;$S+=$a;($S+=$A[0]+$A[1])&redo if($a==10);$b=shift@A;$S+=$b;($S+=$A[0])&redo if(10==$a+$b);redo}print$S

Sadly, there are certain cases where it fails. I will come and redo it later.


问:
Generate Pascal's Braid
This is Pascal's Braid:

```<code> 1 4  15  56   209   780    2911    10864     40545      151316      564719
1 3 11  41  153   571   2131    7953     29681     110771      413403      1542841
 1 4  15  56   209   780    2911    10864     40545      151316      564719
</code>```

I totally made that up. Blaise Pascal didn't have a braid as far as I can tell, and if he did it was probably made of hair instead of numbers.

It's defined like this:

The first column has a single 1 in the middle.

The second column has a 1 at the top and at the bottom.

Now we alternate between putting a number in the middle or two copies of a number at the top and bottom.

If the number goes on the top or the bottom, it will be the sum of the two adjacent numbers (e.g. 56 = 15 + 41). If you tilt your head a little, this is like a step in Pascal's triangle.

If the number goes in the middle, it will be the sum of all three adjacent numbers (e.g. 41 = 15 + 11 + 15).

Your task will be to print (some part of) this braid.

Input

You should write a program or function, which receives a single integer n, giving the index of the last column to be output.

You may choose whether the first column (printing only a single 1 on the middle line) corresponds to n = 0 or n = 1. This has to be a consistent choice across all possible inputs.

Output

Output Pascal's Braid up to the nth column. The whitespace has to match exactly the example layout above, except that you may pad the shorter line(s) to the length of the longer line(s) with spaces and you may optionally output a single trailing linefeed.

In other words, every column should be exactly as wide as the number (or pair of equal numbers) in that column, numbers in successive columns should not overlap and there should be no spaces between columns.

You may either print the result to STDOUT (or the closest alternative), or if you write a function you may return either a string with the same contents or a list of three strings (one for each line).

Further Details

You may assume that n won't be less than the index of the first column (so not less than 0 or 1 depending on your indexing). You may also assume that the last number in the braid is less than 256 or the largest number representable by your language's native integer type, whichever is greater. So if your native integer type can only store bytes, you can assume that the largest n is 9 or 10 (depending on whether you use 0- or 1-based n) and if it can store signed 32-bit integers, n will be at most 33 or 34.

Standard code-golf rules apply. The shortest code wins.

OEIS

Here are a few relevant OEIS links. Of course, these contain spoilers for different ways to generate the numbers in the braid:

Top/bottom: A001353 or A010905 or A106707 or A195503

Middle: A001835 or A079935

Both: A002530

Test Cases

These test cases use 1-base indexing. Each test case is four lines, with the first being the input and the remaining three being the output.

```<code>1

1

---
2
 1
1
 1
---
3
 1
1 3
 1
---
5
 1 4
1 3 11
 1 4
---
10
 1 4  15  56   209
1 3 11  41  153
 1 4  15  56   209
---
15
 1 4  15  56   209   780    2911
1 3 11  41  153   571   2131    7953
 1 4  15  56   209   780    2911
---
24
 1 4  15  56   209   780    2911    10864     40545      151316      564719       2107560
1 3 11  41  153   571   2131    7953     29681     110771      413403      1542841
 1 4  15  56   209   780    2911    10864     40545      151316      564719       2107560
</code>```

答:
Matlab, 223 characters, 226 bytes

```<code>function[]=p(n)
r=[1;1];e={(' 1 ')',('1 1')'}
for i=3:n;r(i)=sum((mod(i,2)+1)*r(i-1)+r(i-2));s=num2str(r(i));b=blanks(floor(log10(r(i)))+1);if mod(i,2);e{i}=[b;s;b];else e{i}=[s;b;s];end;end
reshape(sprintf('%s',e{:}),3,[])
</code>```

Ungolfed and commented:

```<code>function[]=p(n)
r=[1;1];                                    % start with first two
e={(' 1 ')',('1 1')'}                       % initialize string output as columns of blank, 1, blank and 1, blank, 1.
for i=3:n;                                  % for n=3 and up!
    r(i)=sum((mod(i,2)+1)*r(i-1)+r(i-2));   % get the next number by 1 if even, 2 if odd times previous plus two steps back
    s=num2str(r(i));                        % define that number as a string
    b=blanks(floor(log10(r(i)))+1);         % get a number of space characters for that number of digits
    if mod(i,2);                            % for odds
        e{i}=[b;s;b];                       % spaces, number, spaces
    else                                    % for evens
        e{i}=[s;b;s];                       % number, spaces, number
    end;
end
reshape(sprintf('%s',e{:}),3,[])            % print the cell array of strings and reshape it so it's 3 lines high
</code>```

Title: Generate Pascal's Braid

Body:
Matlab, 223 characters, 226 bytes

function[]=p(n)
r=[1;1];e={(' 1 ')',('1 1')'}
for i=3:n;r(i)=sum((mod(i,2)+1)*r(i-1)+r(i-2));s=num2str(r(i));b=blanks(floor(log10(r(i)))+1);if mod(i,2);e{i}=[b;s;b];else e{i}=[s;b;s];end;end
reshape(sprintf('%s',e{:}),3,[])

Ungolfed and commented:

function[]=p(n)
r=[1;1];                                    % start with first two
e={(' 1 ')',('1 1')'}                       % initialize string output as columns of blank, 1, blank and 1, blank, 1.
for i=3:n;                                  % for n=3 and up!
    r(i)=sum((mod(i,2)+1)*r(i-1)+r(i-2));   % get the next number by 1 if even, 2 if odd times previous plus two steps back
    s=num2str(r(i));                        % define that number as a string
    b=blanks(floor(log10(r(i)))+1);         % get a number of space characters for that number of digits
    if mod(i,2);                            % for odds
        e{i}=[b;s;b];                       % spaces, number, spaces
    else                                    % for evens
        e{i}=[s;b;s];                       % number, spaces, number
    end;
end
reshape(sprintf('%s',e{:}),3,[])            % print the cell array of strings and reshape it so it's 3 lines high


答:
QBIC, 6 bytes

```<code>:[a|?b
</code>```

Start a FOR-loop ranging from 1 (default start of FOR-loops) to a, where a is read by : from the command line parameters. At every iteration, b (our FOR-loop counter) is printed (?).

Title: Count up folks!

Body:
QBIC, 6 bytes

:[a|?b

Start a FOR-loop ranging from 1 (default start of FOR-loops) to a, where a is read by : from the command line parameters. At every iteration, b (our FOR-loop counter) is printed (?).


答:
PHP, <s>135</s> <s>124</s> <s>123</s> 120 bytes

```<code><?while($i<$argv[1]){${s.$x=!$x}.=${v.$x}=$a=$i++<2?:$v1+$v+$x*$v;${s.!$x}.=str_repeat(' ',strlen($a));}echo"$s
$s1
$s";
</code>```

taking advantage of implicit typecasts and variable variables

a third of the code (37 bytes) goes into the spaces, 64 bytes altogether used for output

breakdown

```<code>$i=0; $x=false; $v=$v1=1; $s=$s1='';    // unnecessary variable initializations
for($i=0;$i<$argv[1];$i++)  // $i is column number -1
{
    $x=!$x; // $x = current row: true (1) for inner, false (empty string or 0) for outer
    // calculate value
    $a=
        $i<2?               // first or second column: value 1
        :$v1+(1+$x)*$v      // inner-val + (inner row: 1+1=2, outer row: 1+0=1)*outer-val
    ;
    ${s.$x}.=${v.$x}=$a;    // replace target value, append to current row
    ${s.!$x}.=str_repeat(' ',strlen($a));    // append spaces to other row
}
// output
echo "$s\n$s1\n$s";
</code>```

Title: Generate Pascal's Braid

Body:
This is Pascal's Braid:

```<code> 1 4  15  56   209   780    2911    10864     40545      151316      564719
1 3 11  41  153   571   2131    7953     29681     110771      413403      1542841
 1 4  15  56   209   780    2911    10864     40545      151316      564719
</code>```

I totally made that up. Blaise Pascal didn't have a braid as far as I can tell, and if he did it was probably made of hair instead of numbers.

It's defined like this:

The first column has a single 1 in the middle.

The second column has a 1 at the top and at the bottom.

Now we alternate between putting a number in the middle or two copies of a number at the top and bottom.

If the number goes on the top or the bottom, it will be the sum of the two adjacent numbers (e.g. 56 = 15 + 41). If you tilt your head a little, this is like a step in Pascal's triangle.

If the number goes in the middle, it will be the sum of all three adjacent numbers (e.g. 41 = 15 + 11 + 15).

Your task will be to print (some part of) this braid.

Input

You should write a program or function, which receives a single integer n, giving the index of the last column to be output.

You may choose whether the first column (printing only a single 1 on the middle line) corresponds to n = 0 or n = 1. This has to be a consistent choice across all possible inputs.

Output

Output Pascal's Braid up to the nth column. The whitespace has to match exactly the example layout above, except that you may pad the shorter line(s) to the length of the longer line(s) with spaces and you may optionally output a single trailing linefeed.

In other words, every column should be exactly as wide as the number (or pair of equal numbers) in that column, numbers in successive columns should not overlap and there should be no spaces between columns.

You may either print the result to STDOUT (or the closest alternative), or if you write a function you may return either a string with the same contents or a list of three strings (one for each line).

Further Details

You may assume that n won't be less than the index of the first column (so not less than 0 or 1 depending on your indexing). You may also assume that the last number in the braid is less than 256 or the largest number representable by your language's native integer type, whichever is greater. So if your native integer type can only store bytes, you can assume that the largest n is 9 or 10 (depending on whether you use 0- or 1-based n) and if it can store signed 32-bit integers, n will be at most 33 or 34.

Standard code-golf rules apply. The shortest code wins.

OEIS

Here are a few relevant OEIS links. Of course, these contain spoilers for different ways to generate the numbers in the braid:

Top/bottom: A001353 or A010905 or A106707 or A195503

Middle: A001835 or A079935

Both: A002530

Test Cases

These test cases use 1-base indexing. Each test case is four lines, with the first being the input and the remaining three being the output.

```<code>1

1

---
2
 1
1
 1
---
3
 1
1 3
 1
---
5
 1 4
1 3 11
 1 4
---
10
 1 4  15  56   209
1 3 11  41  153
 1 4  15  56   209
---
15
 1 4  15  56   209   780    2911
1 3 11  41  153   571   2131    7953
 1 4  15  56   209   780    2911
---
24
 1 4  15  56   209   780    2911    10864     40545      151316      564719       2107560
1 3 11  41  153   571   2131    7953     29681     110771      413403      1542841
 1 4  15  56   209   780    2911    10864     40545      151316      564719       2107560
</code>```

Body:
PHP, <s>135</s> <s>124</s> <s>123</s> 120 bytes

<?while($i<$argv[1]){${s.$x=!$x}.=${v.$x}=$a=$i++<2?:$v1+$v+$x*$v;${s.!$x}.=str_repeat(' ',strlen($a));}echo"$s
$s1
$s";

taking advantage of implicit typecasts and variable variables

a third of the code (37 bytes) goes into the spaces, 64 bytes altogether used for output

breakdown

$i=0; $x=false; $v=$v1=1; $s=$s1='';    // unnecessary variable initializations
for($i=0;$i<$argv[1];$i++)  // $i is column number -1
{
    $x=!$x; // $x = current row: true (1) for inner, false (empty string or 0) for outer
    // calculate value
    $a=
        $i<2?               // first or second column: value 1
        :$v1+(1+$x)*$v      // inner-val + (inner row: 1+1=2, outer row: 1+0=1)*outer-val
    ;
    ${s.$x}.=${v.$x}=$a;    // replace target value, append to current row
    ${s.!$x}.=str_repeat(' ',strlen($a));    // append spaces to other row
}
// output
echo "$s\n$s1\n$s";


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

Challenge

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

Rules

Standard loopholes are denied

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

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

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

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

Test cases

These are the test cases:

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

These are the supposed results:

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

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

答:
Perl 5, 11 bytes

A subroutine:

```<code>{reverse@_}
</code>```

Title: Reverse a 1-dimensional array

Body:
Perl 5, 11 bytes

A subroutine:

{reverse@_}


问:
Count of "a"s and "b"s must be equal. Did you get it computer?
In the popular (and essential) computer science book, An Introduction to Formal Languages and Automata by Peter Linz, the following formal language is frequently stated:

$$\large{L=\{a^n b^n:n\in\mathbb{Z}^+\}}$$

mainly because this language can not be processed with finite-state automata.
This expression mean "Language L consists all strings of 'a's followed by 'b's, in which the number of 'a's and 'b's are equal and non-zero".

Challenge

Write a working program/function which gets a string, containing "a"s and "b"s only, as input and returns/outputs a truth value, saying if this string is valid the formal language L.

Your program cannot use any external computation tools, including network, external programs, etc. Shells are an exception to this rule; Bash, e.g., can use command line utilities.

Your program must return/output the result in a "logical" way, for example: returning 10 instead of 0, "beep" sound, outputting to stdout etc. More info here.

Standard code golf rules apply.

This is a code-golf. Shortest code in bytes wins. Good luck!

Truthy test cases

```<code>"ab"
"aabb"
"aaabbb"
"aaaabbbb"
"aaaaabbbbb"
"aaaaaabbbbbb"
</code>```

Falsy test cases

```<code>""
"a"
"b"
"aa"
"ba"
"bb"
"aaa"
"aab"
"aba"
"abb"
"baa"
"bab"
"bba"
"bbb"
"aaaa"
"aaab"
"aaba"
"abaa"
"abab"
"abba"
"abbb"
"baaa"
"baab"
"baba"
"babb"
"bbaa"
"bbab"
"bbba"
"bbbb"
</code>```

Leaderboard

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

  });

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Sed, 38 + 2 = 40 bytes

```<code>s/.*/c&d/;:x;s/ca(.*)bd/c\1d/;tx;/cd/p
</code>```

A non empty string output is truthy

Finite state automata can not do this, you say? What about finite state automata with loops. :P

Run with r and n flags.

Explanation

```<code>s/.*/c&d/        #Wrap the input in 'c' and 'd' (used as markers)
:x               #Define a label named 'x'
s/ca(.*)bd/c\1d/ #Deletes 'a's preceded by 'c's and equivalently for 'b's and 'd's. This shifts the markers to the center
tx               #If the previous substitution was made, jump to label x
/cd/p            #If the markers are next to one another, print the string
</code>```

Body:
Sed, 38 + 2 = 40 bytes

s/.*/c&d/;:x;s/ca(.*)bd/c\1d/;tx;/cd/p

A non empty string output is truthy

Finite state automata can not do this, you say? What about finite state automata with loops. :P

Run with r and n flags.

Explanation

s/.*/c&d/        #Wrap the input in 'c' and 'd' (used as markers)
:x               #Define a label named 'x'
s/ca(.*)bd/c\1d/ #Deletes 'a's preceded by 'c's and equivalently for 'b's and 'd's. This shifts the markers to the center
tx               #If the previous substitution was made, jump to label x
/cd/p            #If the markers are next to one another, print the string


答:
MySQL, 64 bytes

```<code>set@=1;select a from(select a,@:=@+1 n from t order by n desc)u;
</code>```

Tested on 5.6.24.

My first SQL answer; please provide feedback!

Title: Reverse a 1-dimensional array

Body:
Note: This challenge is not the same.

Challenge

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

Rules

Standard loopholes are denied

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

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

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

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

Test cases

These are the test cases:

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

These are the supposed results:

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

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

Body:
MySQL, 64 bytes

set@=1;select a from(select a,@:=@+1 n from t order by n desc)u;

Tested on 5.6.24.

My first SQL answer; please provide feedback!


问:
Draw the EU Estimated Sign
The specification of the "estimated" sign used by the European Union Directive (U+212e in Unicode, which you may not simply print for this challenge) is quite precise.

To copy some restrictions from this question: Render the symbol to file or screen using vector or raster graphics. If your output is rasterised, your image must have dimensions of 264 pixels × 240 pixels or more. Any other helping lines or length indicators must not be drawn.

答:
Haml + Sass, 20 + 722 = 742 bytes

I'm sure this could be golfed a lot more, but I'm happy enough with it. Demo on CodePen.

Note: Because of default margins, this needs a browser window at least 1,000-some pixels wide.

Haml

#u
#v
 #w
 #x
 #y
#z
```

<h2>Sass</h2>

<pre class="lang-sass prettyprint-override"><code>$w: 1000px
$h: 900px
$a: 183px
$b: 25px
$p: 85px
$q: 13px
$d: 846px
$e: $w - 2*$a
$f: 143px
$s: 50%
$t: $p/5.5
=d($w:$w,$h:$h)
 width: $w
 height: $h
=m($c)
 background-color: $c
=k
 +m(#000)
 position: absolute
 content: ''
=l
 +k
 +m(#fff)
=o($o:$p)
 +d($o,$p)
=r($a)
 border-radius: $a
*
 +k
html,body
 +l
 position: relative
#u
 +d
 clip-path: ellipse($s $s)
#v
 +d($e)
 left: $a
 clip-path: circle(($d/2) at $s $s)
#v::before,#v::after
 +l
 +d($e,($h -$b)/2)
 +r($q)
#v::after
 bottom: 0
#w,#x
 +o($t)
 top: $f
#w::before,#x::before,#y::before
 +l
 +o
 +r($s 0)
#x,#x::before
 right: 0
#x::before
 +r(0 $s 0 0)
#y
 +o($t)
 bottom: $f
 z-index: 9
#y::before
 +r(0 0 0 $s)
#z
 +l
 +d($s,267px)
 top: ($h+$b)/2
 right: 0
</code>```

Title: Draw the EU Estimated Sign

Body:
Haml + Sass, 20 + 722 = 742 bytes

I'm sure this could be golfed a lot more, but I'm happy enough with it. Demo on CodePen.

Note: Because of default margins, this needs a browser window at least 1,000-some pixels wide.

Haml

#u
#v
 #w
 #x
 #y
#z

Sass

$w: 1000px
$h: 900px
$a: 183px
$b: 25px
$p: 85px
$q: 13px
$d: 846px
$e: $w - 2*$a
$f: 143px
$s: 50%
$t: $p/5.5
=d($w:$w,$h:$h)
 width: $w
 height: $h
=m($c)
 background-color: $c
=k
 +m(#000)
 position: absolute
 content: ''
=l
 +k
 +m(#fff)
=o($o:$p)
 +d($o,$p)
=r($a)
 border-radius: $a
*
 +k
html,body
 +l
 position: relative
#u
 +d
 clip-path: ellipse($s $s)
#v
 +d($e)
 left: $a
 clip-path: circle(($d/2) at $s $s)
#v::before,#v::after
 +l
 +d($e,($h -$b)/2)
 +r($q)
#v::after
 bottom: 0
#w,#x
 +o($t)
 top: $f
#w::before,#x::before,#y::before
 +l
 +o
 +r($s 0)
#x,#x::before
 right: 0
#x::before
 +r(0 $s 0 0)
#y
 +o($t)
 bottom: $f
 z-index: 9
#y::before
 +r(0 0 0 $s)
#z
 +l
 +d($s,267px)
 top: ($h+$b)/2
 right: 0


问:
Tips for golfing in PHP
What general tips do you have for golfing in PHP? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to PHP (e.g. "remove comments" is not an answer). Please post one tip per answer.</p>

答:
use deprecated functions

If you can use POSIX instead of PERL regex without wasting more than 5 bytes on the expression, use ereg or eregi instead of preg_match, split or spliti instead of preg_split.

split Can also be used as a synonym for explode for most delimiters.

These functions are marked deprecated and will throw E_DEPRECATED notices, but (cannot find the source now) I think I have read that warnings and notices are ok.

Title: Tips for golfing in PHP


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

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

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

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

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Title: Print numbers from 1 to 10

Body:
Kona, 5 bytes

Code:

1+!10

Output:

1 2 3 4 5 6 7 8 9 10


问:
Make a simple IRC bot.

Task

Make a simple IRC bot which does simple task like greeting user.

Detail

(You may see this RFC document.)

Write a complete program that perform these:

The program inputs nickname and realname from the user.

All nickname and realname which form is [A-Za-z0-9]+ should be allowed, but it isn't  important whether other forms are allowed. For example, if the user wants 1234qwerty as nickname and 5319009 as realname, the program should use those names, but it isn't important whether the program can use ^^☆Rick Astley☆^^ (which includes non-alphabet&decimals) as (nickname or realname) or not, even thought this name may be rejected by the server.

The program inputs serverAddress from the user.

The form of serverAddress is serverIP:serverPort, where serverIP is the IP address of the server and serverPort is the port num of the server.

The program connects to port serverPort at IRC server serverIP, and it should set it's nickname as nickname and realname as realname by sending USER realname 0 * :realname and NICK nickname.

The program inputs a single channelName which doesn't include #, and join to the channel #channelName.

Send a private message Hello, world! to the #channelName channel like this: PRIVMSG #channelName :Hello, world!

Then, the program does these:

A. If someone joins, greeting him by saying Hello, @! to #channelName, where @ is the nickname of him/her.

B. If the program is kicked, try re-joining.

C. If a person is kicked or banned, say POW HAHA.

D. If a person leaves (PART or QUIT), say Goodbye, @!, where @ is the nickname of him/her.

E. If someone says some text including Turing test or turing test, say I'm a human!.

F. If someone says some text including 6*9, quit by sending QUIT :42 to the server.

G. If someone says some text including all your base are belong to us(case-insensitive), quit by sending QUIT :What you say! to the server.

H. If someone says some text preceding with a space and above acts aren't performed by the text, say the sum of charcode of all (except the first space) chars in the text.

If an error is occurred

If an error (such as connection error or invalid nickname) is occurred, you can do what you want to do. For example, if the nickname is already in use, the program may stop, gets a new nickname from the user, or automatically change the nickname and retry.

Restriction

The program

Should not use any internal functions or libraries which is for IRC client/bot making. i.e. something like IRC client libraries

Should prompt what it'll input, before it gets an input. For example, before inputs serverAddress, it should prompt Write the address of server:, serverIP:serverPort > , serverAddress >, or some text that the user can recognize.

Should work on several IRC servers using UTF-8. (i.e. not for single server)

's messages send to server shouldn't be NOTICE. (RFC 2812, 3.3.2 Notice : The difference between NOTICE and PRIVMSG is that automatic replies MUST NEVER be sent in response to a NOTICE message.)

Should send a message where the request came from (#channelName or nickname).

Should PONG when PINGed, of course.

PS

Well, I just made this, because there was no puzzle about IRC bot.

Edit

After reading @dmckee's comment, I changed the rule for choosing winner.

Default bonus = +0

If somehow the program can connect to a channel (even if it's not #channelName), bonus = 1

If the program can perform step 1~5, bonus *= 2.

For each tasks A~H in step 6, if the program implements, bonus *= 1.2.

For each six restrictions, if the program follows that, bonus *= 1.05.

and score = int(codelength/bonus).

Program with lowest score is winner. If two answers have same score, then the answer with highest votes wins.

EDIT Edit : I think 1.2 and 1.05 in step 4 and 5 should be adjusted slightly bigger.. What do you think about this?

The winner is decided, however, I think there was too few entries.

Anyone still may submit the code.. :P

答:
Ruby, 65 points

574 Chars

Steps 1-5, 6(A-G) and restrictions on libs, UTF-8, no NOTICE & PONG

Takes commandline args in the form of server:6667 botnick botuser channel

Score

```<code>bonus = 0       # We've done nothing yet
bonus += 1      # Connects to channel
bonus *= 2      # Step 1 - 5

for n in 1..7
    bonus *= 1.2    # A - G
end

for n in 1..4
    bonus *= 1.05   # 4 constraints
end

puts (574/bonus).to_i
> 65
</code>```

Code

```<code>require'socket'
a=ARGV
c="##{a[3]}"
h,p=a[0].split':'
s=TCPSocket.open(h,p)
m="PRIVMSG #{c} :"
s.puts"USER #{a[2]} 0 * :#{a[2]}\nNICK #{a[1]}\nJOIN #{c}\n#{m}Hello, world!"
while l=s.gets
case l
when/\:(.+?)!(.+)JOIN/
s.puts"#{m}Hello, #{$1}!"
when/KICK (.+?) (.+?) \:(.+)/
if $2==a[1]
s.puts"JOIN #{c}"
else
s.puts"#{m}POW HAHA"
end
when/\:(.+?)\!(.+)(PART|QUIT)/
s.puts"#{m}Goodbye, #{$1}!"
when/turing test/i
s.puts"#{m}I'm a human!"
when/6\*9/
s.puts"QUIT :42"
when/all your base are belong to us/i
s.puts"QUIT :What you say!"
when/PING \:(.+)/
puts"PONG #{$1}"
end
end
</code>```

Title: Make a simple IRC bot.

Body:
Ruby, 65 points

574 Chars

Steps 1-5, 6(A-G) and restrictions on libs, UTF-8, no NOTICE & PONG

Takes commandline args in the form of server:6667 botnick botuser channel

Score

bonus = 0       # We've done nothing yet
bonus += 1      # Connects to channel
bonus *= 2      # Step 1 - 5

for n in 1..7
    bonus *= 1.2    # A - G
end

for n in 1..4
    bonus *= 1.05   # 4 constraints
end

puts (574/bonus).to_i
> 65

Code

require'socket'
a=ARGV
c="##{a[3]}"
h,p=a[0].split':'
s=TCPSocket.open(h,p)
m="PRIVMSG #{c} :"
s.puts"USER #{a[2]} 0 * :#{a[2]}\nNICK #{a[1]}\nJOIN #{c}\n#{m}Hello, world!"
while l=s.gets
case l
when/\:(.+?)!(.+)JOIN/
s.puts"#{m}Hello, #{$1}!"
when/KICK (.+?) (.+?) \:(.+)/
if $2==a[1]
s.puts"JOIN #{c}"
else
s.puts"#{m}POW HAHA"
end
when/\:(.+?)\!(.+)(PART|QUIT)/
s.puts"#{m}Goodbye, #{$1}!"
when/turing test/i
s.puts"#{m}I'm a human!"
when/6\*9/
s.puts"QUIT :42"
when/all your base are belong to us/i
s.puts"QUIT :What you say!"
when/PING \:(.+)/
puts"PONG #{$1}"
end
end


答:
PHP, 17 bytes

```<code>$r=array_reverse;
</code>```

call $r($array)

non-built-in version, 53 bytes:

```<code>function r($a){while($a)$b[]=array_pop($a);return$b;}
</code>```

call r($array)

generator for PHP >= 5.5, 45 bytes

```<code>function y($a){while($a)yield array_pop($a);}
</code>```

usage: foreach(y($array)as$v)var_dump($v);

Title: Reverse a 1-dimensional array

Body:
PHP, 17 bytes

$r=array_reverse;

call $r($array)

non-built-in version, 53 bytes:

function r($a){while($a)$b[]=array_pop($a);return$b;}

call r($array)

generator for PHP >= 5.5, 45 bytes

function y($a){while($a)yield array_pop($a);}

usage: foreach(y($array)as$v)var_dump($v);


问:
Given a truth table, output a Stackylogic program that satisfies it
Stackylogic is a programming language I made up in a previous challenge: Run Stackylogic. Read that post for full details and examples, but here is how it works paraphrased:

Stackylogic takes 0's and 1's for input and outputs a single 0
  or 1 upon completion.

A program consists of lines that only contain the characters 01? as
  well as exactly one < at the end of one of the lines. Lines may not
  be empty and the line with the < must have at least one 0, 1, or
  ? before it.

Here's a sample program that computes the NAND of two bits:

```<code>1
?<
11
?
0
</code>```

Every line in a program is considered a stack, with the
  bottom on the left and the top on the right. Implicitly, there is an
  empty stack (i.e. empty line) before the first line in a program and after the last
  line.

The <, called the cursor, marks the stack to start on
  when a program is run. Execution proceeds as follows:

Pop the top character off the stack the cursor is currently pointing to.

If the character is ?, prompt the user for a 0 or a 1 and act as if that was the character.

If the character is 0, move the cursor one stack up (to the line above the current line).

If the character is 1, move the cursor one stack down (to the line below the current line).

If the stack the cursor moves to is empty, output the last value that was popped off a stack (always a 0 or 1), and end the
  program.

Else, if the stack the cursor moves to is not empty, go back to step 1 and repeat the process.

The key thing to realize for this challenge is that all Stackylogic programs equate to a truth table. Some predetermined number of boolean values are input and exactly one boolean is deterministically output.

So your task is to produce a Stackylogic program that satisfies or simulates, i.e. has the same output as any given truth table. But it's not obvious that Stackylogic can simulate any truth table, so here's a proof by induction:

Base Case

The two 0-input truth tables are the tables that always output 0 or
  1. The Stackylogic equivalents of these tables are 0< and 1<
  respectively.

Inductive Step

Assume Stackylogic can simulate any N-input truth table. Let M = N +
  1.

An M-input table, T, can be expressed as two N-input tables,
  T0 and T1, plus the additional input bit B. When
  B is 0, the result of T0 is used. When B is 1, the result
  of T1 is used.

For example, the 3-input truth table corresponding to the pseudocode

```<code>if B:
    result = x OR y
else:
    result = x NAND y
</code>```

is

```<code>B x y | result
0 0 0 | 1
0 0 1 | 1
0 1 0 | 1
0 1 1 | 0
1 0 0 | 0
1 0 1 | 1
1 1 0 | 1
1 1 1 | 1
</code>```

which is really the two 2-input truth tables for NAND and OR stacked
  atop each other with the muxing bit B.

Let S0 and S1 be the Stackylogic programs that
  satisfy T0 and T1 respectively (we know these exist based on the first assumption). Program S that
  satisfies T can then be constructed as:

```<code>[lines of S<sub>0</sub> excluding the cursor, with 0 appended to all lines below the cursor]
?<
[lines of S<sub>1</sub> excluding the cursor, with 1 appended to all lines above the cursor]</code>```

This arrangement effectively muxes between S0 and
  S1 based on the first input bit (from line ?<). If it is
  0, the cursor will ride the appended 0's up to the original cursor
  position of S0, which will then be bordered top and bottom by
  empty stacks, and thus run exactly identical to the original
  S0. Likewise, if 1 is input, the cursor will ride the
  1's down to S1's cursor position and proceed to execute
  it as if it were alone.

For example, Stackylogic programs for OR and NAND are

```<code>?
?<
</code>```

and

```<code>1
?<
11
?
0
</code>```

They can be combined to simulate

```<code>if B:
    result = x OR y
else:
    result = x NAND y
</code>```

like so:

```<code>1
?
110
?0
00
0
?<
?1
?
</code>```

Thus, any truth table can be simulated by a Stackylogic program.

Challenge

Write a program or function that takes in an N input truth table (N > 0) in the form of a list of 2N boolean values that represent the outputs of the table in ascending binary order.

Any reasonable input format is alright. e.g. for an OR truth table

```<code>x y | OR
0 0 | 0
0 1 | 1
1 0 | 1
1 1 | 1
</code>```

any of these styles of inputs would be fine:

0111

0, 1, 1, 1

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

[False, True, True, True]

Print or return a Stackylogic program that satisfies the truth table, i.e. has the exact same output given the same input. Any finite program that satisfies that table is valid output. You do not need to follow the inductive proof's method of construction. The Stackylogic programs do not need to be optimally short.

For example, if the input were 11100111, one valid output would be

```<code>if B:
    result = x OR y
else:
    result = x NAND y
</code>```0

but there are many others.

The shortest code in bytes wins.

See the original Stackylogic challenge if you need an interpreter.

答:
Python 3, <s>352</s> <s>208</s> 205 bytes

<s>This is still very ungolfed, and I will try to add an explanation later.</s> After some modifications, I managed to remove <s>144</s> 147 bytes.

```<code>f=lambda x,l=len,r=range:'\n'.join(*x)if l(x)<2 else f([[x[i][j]+['0',''][j<=l(x[i])//2]for j in r(l(x[i]))]+[['?','?<'][l(x)<3]]+[x[i+1][j]+['1',''][j>=l(x[i])//2]for j in r(l(x[i]))]for i in r(0,l(x),2)])
</code>```

A function f that takes input of the truth table values as a list of Booleans of the form ['1','1','1','0','0','1'...], where '1' is truthy and '0' is falsey, and returns a Stackylogic program.

Try it on Ideone

If you want to test a produced program, you can use GamrCorps's Convex interpreter here.

How it works

This is a recursive function and uses the inductive method described in the question.

At the zero-indexed recursion level a, the function creates n/2  a+1-input Stackylogic programs from the n a-input programs in the list. This is done by joining all adjacent pairs of two programs in the list with ?; since the cursor is always at the middle element of each constituent program, the required appending of 0 or 1 can be performed by iterating over each line of the programs being joined, and appending if the index of the current line is less than or equal to/greater than or equal to the middle index as appropriate. If the list contains only two programs, the next recursive call will give the final program; since this requires a cursor, joining instead occurs on ?<.

When the list has length 1, the list must contain just one element containing the full program. Hence, all lines in the program are joined on a newline, and then returned.

An example helps to illustrate this:

```<code>Take the input ['1', '1', '1', '0', '0', '1', '1', '1'].

Level  Return value

0  [['1', '?', '1'], ['1', '?', '0'], ['0', '?', '1'], ['1', '?', '1']]
1  [['1', '?', '10', '?', '11', '?', '0'], ['0', '?', '10', '?', '11', '?', '1']]
2  [['1', '?', '10', '?', '110', '?0', '00', '?<', '01', '?1', '101', '?', '11', '?', '1']]
3  '1\n?\n10\n?\n110\n?0\n00\n?<\n01\n?1\n101\n?\n11\n?\n1'

which when printed gives:

1
?
10
?
110
?0
00
?<
01
?1
101
?
11
?
1
</code>```

Body:
Python 3, <s>352</s> <s>208</s> 205 bytes

<s>This is still very ungolfed, and I will try to add an explanation later.</s> After some modifications, I managed to remove <s>144</s> 147 bytes.

f=lambda x,l=len,r=range:'\n'.join(*x)if l(x)<2 else f([[x[i][j]+['0',''][j<=l(x[i])//2]for j in r(l(x[i]))]+[['?','?<'][l(x)<3]]+[x[i+1][j]+['1',''][j>=l(x[i])//2]for j in r(l(x[i]))]for i in r(0,l(x),2)])

A function f that takes input of the truth table values as a list of Booleans of the form ['1','1','1','0','0','1'...], where '1' is truthy and '0' is falsey, and returns a Stackylogic program.

Try it on Ideone

If you want to test a produced program, you can use GamrCorps's Convex interpreter here.

How it works

This is a recursive function and uses the inductive method described in the question.

At the zero-indexed recursion level a, the function creates n/2  a+1-input Stackylogic programs from the n a-input programs in the list. This is done by joining all adjacent pairs of two programs in the list with ?; since the cursor is always at the middle element of each constituent program, the required appending of 0 or 1 can be performed by iterating over each line of the programs being joined, and appending if the index of the current line is less than or equal to/greater than or equal to the middle index as appropriate. If the list contains only two programs, the next recursive call will give the final program; since this requires a cursor, joining instead occurs on ?<.

When the list has length 1, the list must contain just one element containing the full program. Hence, all lines in the program are joined on a newline, and then returned.

An example helps to illustrate this:

Take the input ['1', '1', '1', '0', '0', '1', '1', '1'].

Level  Return value

0  [['1', '?', '1'], ['1', '?', '0'], ['0', '?', '1'], ['1', '?', '1']]
1  [['1', '?', '10', '?', '11', '?', '0'], ['0', '?', '10', '?', '11', '?', '1']]
2  [['1', '?', '10', '?', '110', '?0', '00', '?<', '01', '?1', '101', '?', '11', '?', '1']]
3  '1\n?\n10\n?\n110\n?0\n00\n?<\n01\n?1\n101\n?\n11\n?\n1'

which when printed gives:

1
?
10
?
110
?0
00
?<
01
?1
101
?
11
?
1


问:
Divisibility test

Task

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

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

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

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

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

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

Test cases

```<code> n,  d    output

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

Leaderboard

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
dc, <s>8</s> 7 bytes

Input is delimited by a space: n d

```<code>?~/z1-n
</code>```

If false, it outputs 0. If true, it outputs 1 and throws an error about division by zero.

Explanation:

```<code>?   # Take input from stdin.
~   # Pop two values from stack. Push quotient. Push remainder.
/   # Attempt to divide quotient by remainder.
    #   If input is divisible, then remainder is 0.
    #     Division fails, throwing an error and leaving both numbers on stack.
    #     (Stack depth is 2.)
    #   If input is not divisible, then remainder is not 0.
    #     Division succeeds, and result is pushed on stack. (Stack depth is 1.)
z   # Push stack depth on stack. (If divisible, push 2; if indivisible, push 1.)
1-  # Subtract 1 from top of stack. ToS is now 1 or 0.
n   # Pop top of stack and print it as a number.
</code>```

Title: Divisibility test

Body:
dc, <s>8</s> 7 bytes

Input is delimited by a space: n d

?~/z1-n

If false, it outputs 0. If true, it outputs 1 and throws an error about division by zero.

Explanation:

?   # Take input from stdin.
~   # Pop two values from stack. Push quotient. Push remainder.
/   # Attempt to divide quotient by remainder.
    #   If input is divisible, then remainder is 0.
    #     Division fails, throwing an error and leaving both numbers on stack.
    #     (Stack depth is 2.)
    #   If input is not divisible, then remainder is not 0.
    #     Division succeeds, and result is pushed on stack. (Stack depth is 1.)
z   # Push stack depth on stack. (If divisible, push 2; if indivisible, push 1.)
1-  # Subtract 1 from top of stack. ToS is now 1 or 0.
n   # Pop top of stack and print it as a number.


答:
PHP, <s>61</s> 40 bytes

new approach inspired by Didz´ answer: regexp with a recursive pattern

```<code><?=preg_match('#^(a(?1)?b)$#',$argv[1]);
</code>```

P.S.: I see now that I am not the first one with this pattern. You never stop learning.

Josh´s C solution translated to PHP comes at the same size (with one byte lost in translation, one byte golfed for PHP with bitwise and, one byte golfed for C and PHP):

<?=strlen($s=$argv[1])==2*strspn($s,a)&$s[strrpos($s,a)+1]>a; (61 bytes)

My second own approach, a little longer: build a string with (input length / 2) of a, one of b and compare the concatenation to input:

<?=str_repeat(a,$n=strlen($s=$argv[1])/2).str_repeat(b,$n)==$s; (63 bytes)

Could save 3 bytes on that if I could use ($r=str_repeat) for a function call directly ... if.

all versions:

take the string as argument from cli

print 1 for true, nothing for false

testing

replace <?= with <?function f($s){return

remove =$argv[1] (or replace $argv[1] with $s)

append } and my test suite (below)

call in a web browser

```<code>function out($a){if(is_object($a)){foreach($a as$v)$r[]=$v;return'{'.implode(',',$r).'}';}if(!is_array($a))return$a;$r=[];foreach($a as$v)$r[]=out($v);return'['.join(',',$r).']';}
function test($x,$e,$y){static $h='<table border=1><tr><th>input</th><th>output</th><th>expected</th><th>ok?</th></tr>';echo"$h<tr><td>",out($x),'</td><td>',out($y),'</td><td>',out($e),'</td><td>',$e==$y?'Y':'N',"</td></tr>";$h='';}
$cases=[
    1=>[ab,aabb,aaabbb,aaaabbbb,aaaaabbbbb,aaaaaabbbbbb],
    0=>['',a,b,aa,ba,bb,aaa,aab,aba,abb,baa,bab,bba,bbb,aaaa,aaab,aaba,
        abaa,abab,abba,abbb,baaa,baab,baba,babb,bbaa,bbab,bbba,bbbb]
];
foreach($cases as$e=>$a)foreach($a as$x)test($x,$e,f($x)|0);
</code>```

Title: Count of "a"s and "b"s must be equal. Did you get it computer?

Body:
In the popular (and essential) computer science book, An Introduction to Formal Languages and Automata by Peter Linz, the following formal language is frequently stated:

$$\large{L=\{a^n b^n:n\in\mathbb{Z}^+\}}$$

mainly because this language can not be processed with finite-state automata.
This expression mean "Language L consists all strings of 'a's followed by 'b's, in which the number of 'a's and 'b's are equal and non-zero".

Challenge

Write a working program/function which gets a string, containing "a"s and "b"s only, as input and returns/outputs a truth value, saying if this string is valid the formal language L.

Your program cannot use any external computation tools, including network, external programs, etc. Shells are an exception to this rule; Bash, e.g., can use command line utilities.

Your program must return/output the result in a "logical" way, for example: returning 10 instead of 0, "beep" sound, outputting to stdout etc. More info here.

Standard code golf rules apply.

This is a code-golf. Shortest code in bytes wins. Good luck!

Truthy test cases

```<code>"ab"
"aabb"
"aaabbb"
"aaaabbbb"
"aaaaabbbbb"
"aaaaaabbbbbb"
</code>```

Falsy test cases

```<code>""
"a"
"b"
"aa"
"ba"
"bb"
"aaa"
"aab"
"aba"
"abb"
"baa"
"bab"
"bba"
"bbb"
"aaaa"
"aaab"
"aaba"
"abaa"
"abab"
"abba"
"abbb"
"baaa"
"baab"
"baba"
"babb"
"bbaa"
"bbab"
"bbba"
"bbbb"
</code>```

Leaderboard

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

  });

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
PHP, <s>61</s> 40 bytes

new approach inspired by Didz´ answer: regexp with a recursive pattern

<?=preg_match('#^(a(?1)?b)$#',$argv[1]);

P.S.: I see now that I am not the first one with this pattern. You never stop learning.

Josh´s C solution translated to PHP comes at the same size (with one byte lost in translation, one byte golfed for PHP with bitwise and, one byte golfed for C and PHP):

<?=strlen($s=$argv[1])==2*strspn($s,a)&$s[strrpos($s,a)+1]>a; (61 bytes)

My second own approach, a little longer: build a string with (input length / 2) of a, one of b and compare the concatenation to input:

<?=str_repeat(a,$n=strlen($s=$argv[1])/2).str_repeat(b,$n)==$s; (63 bytes)

Could save 3 bytes on that if I could use ($r=str_repeat) for a function call directly ... if.

all versions:

take the string as argument from cli

print 1 for true, nothing for false

testing

replace <?= with <?function f($s){return

remove =$argv[1] (or replace $argv[1] with $s)

append } and my test suite (below)

call in a web browser

function out($a){if(is_object($a)){foreach($a as$v)$r[]=$v;return'{'.implode(',',$r).'}';}if(!is_array($a))return$a;$r=[];foreach($a as$v)$r[]=out($v);return'['.join(',',$r).']';}
function test($x,$e,$y){static $h='<table border=1><tr><th>input</th><th>output</th><th>expected</th><th>ok?</th></tr>';echo"$h<tr><td>",out($x),'</td><td>',out($y),'</td><td>',out($e),'</td><td>',$e==$y?'Y':'N',"</td></tr>";$h='';}
$cases=[
    1=>[ab,aabb,aaabbb,aaaabbbb,aaaaabbbbb,aaaaaabbbbbb],
    0=>['',a,b,aa,ba,bb,aaa,aab,aba,abb,baa,bab,bba,bbb,aaaa,aaab,aaba,
        abaa,abab,abba,abbb,baaa,baab,baba,babb,bbaa,bbab,bbba,bbbb]
];
foreach($cases as$e=>$a)foreach($a as$x)test($x,$e,f($x)|0);


问:
Compute the maximum number of runs possible for as large a string as possible
[This question is a follow up to Compute the runs of a string ]

A period p of a string w is any positive integer p such that w[i]=w[i+p]
  whenever both sides of this equation are defined. Let per(w) denote
  the size of the smallest period of w . We say that a string w is
  periodic iff per(w) <= |w|/2.

So informally a periodic string is just a string that is made up from another string repeated at least once.  The only complication is that at the end of the string we don't require a full copy of the repeated string as long as it is repeated in its entirety at least once.

For, example consider the string x = abcab. per(abcab) = 3 as x[1] = x[1+3] = a, x[2]=x[2+3] = b and there is no smaller period. The string abcab is therefore not periodic.  However, the string ababa is periodic as per(ababa) = 2.

As more examples, abcabca, ababababa and abcabcabc are also periodic.

For those who like regexes, this one detects if a string is periodic or not:

```<code>\b(\w*)(\w+\1)\2+\b
</code>```

The task is to find all maximal periodic substrings in a longer string.  These are sometimes called runs in the literature.

A substring w is a maximal periodic substring (run) if it is periodic and neither w[i-1] = w[i-1+p] nor w[j+1] = w[j+1-p].  Informally, the "run" cannot be contained in a larger "run"
  with the same period.

Because two runs can represent the same string of characters occurring in different places in the overall string, we will represent runs by intervals. Here is the above definition repeated in terms of intervals.

A run (or maximal periodic substring) in a string T is an interval
  [i...j] with j>=i, such that

T[i...j] is a periodic word with the period p = per(T[i...j])

It is maximal. Formally, neither T[i-1] = T[i-1+p] nor T[j+1] = T[j+1-p].  Informally, the run cannot be contained in a larger run
  with the same period.

Denote by RUNS(T) the set of runs in string T.

Examples of runs

The four maximal periodic substrings (runs) in string T = atattatt are T[4,5] = tt, T[7,8] = tt, T[1,4] = atat, T[2,8] = tattatt.

The string T = aabaabaaaacaacac contains the following 7 maximal periodic substrings (runs):
T[1,2] = aa, T[4,5] = aa, T[7,10] = aaaa, T[12,13] = aa, T[13,16] = acac, T[1,8] = aabaabaa, T[9,15] = aacaaca.

The string T = atatbatatb contains the following three runs. They are:
T[1, 4] = atat, T[6, 9] = atat and  T[1, 10] = atatbatatb.

Here I am using 1-indexing.

The task

Write code so that for each integer n starting at 2, you output the largest numbers of runs contained in any binary string of length n.

Score

Your score is the highest n you reach in 120 seconds such that for all k <= n, no one else has posted a higher correct answer than you.  Clearly if you have all optimum answers then you will get the score for the highest n you post. However, even if your answer is not the optimum, you can still get the score if no one else can beat it.

Languages and libraries

You can use any available language and libraries you like. Where feasible, it would be good to be able to run your code so please include a full explanation for how to run/compile your code in Linux if at all possible.

Example optima

In the following: n, optimum number of runs, example string.

```<code>2 1 00
3 1 000
4 2 0011
5 2 00011
6 3 001001
7 4 0010011
8 5 00110011
9 5 000110011
10 6 0010011001
11 7 00100110011
12 8 001001100100
13 8 0001001100100
14 10 00100110010011
15 10 000100110010011
16 11 0010011001001100
17 12 00100101101001011
18 13 001001100100110011
19 14 0010011001001100100
20 15 00101001011010010100
21 15 000101001011010010100
22 16 0010010100101101001011
</code>```

What exactly should my code output?

For each n your code should output a single string and the number of runs it contains.

My Machine The timings will be run on my machine. This is a standard ubuntu install on an AMD FX-8350 Eight-Core Processor.  This also means I need to be able to run your code.

Leading answers

49 by Anders Kaseorg in C. Single threaded and run with L = 12 (2GB of RAM).

27 by cdlane in C.

答:
Since it's not a race if there's only one horse, I'm submitting my solution though it's only a fraction the speed of Anders Kaseorg's and a only a third as cryptic.  Compile with:

gcc -O2 run-count.c -o run-count

The heart of my algorithm is a simple shift and XOR scheme:

A run of zeros in the XOR result that's greater than or equal to the current period/shift indicates a run in the original string for this period.  From this you can tell how long the run was and where it starts and ends.  The rest of the code is overhead, setting up the situation and decoding the results.

I'm hoping it will make at least 28 after two minutes on Lembik's machine.  (I wrote a pthread version, but only managed to make it run even slower.)

```<code>#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>

enum { START = 0, WIDTH } ;

// Compare and shuffle just one thing while storing two
typedef union {
    uint16_t token;
    uint8_t data[sizeof(uint16_t)];
} overlay_t;

#define SENTINAL (0)  // marks the end of an array of overlay_t

#define NUMBER_OF_BITS (8 * sizeof(uint64_t))

void period_runs(uint64_t xor_bits, uint8_t nbits, uint8_t period, overlay_t *results) {

    overlay_t *results_ptr = results;
    uint8_t count = 0;

    for (uint8_t position = 0; position < nbits; position++) {

        if (xor_bits & 1ULL) {

            if ((nbits - position) < period) {
                break;  // no room left to succeed further
            }

            if (count >= period) {  // we found a run

                results_ptr->data[START] = position - (count - 1);
                results_ptr->data[WIDTH] = period + count;
                results_ptr++;
            }

            count = 0;
        } else {

            count++;
        }

        xor_bits >>= 1;
    }

    if (count >= period) {  // process the final run, if any

        results_ptr->data[START] = 0;
        results_ptr->data[WIDTH] = period + count;
        results_ptr++;
    }

    results_ptr->token = SENTINAL;
}

void number_runs(uint64_t number, uint8_t bit_length, overlay_t *results) {

    overlay_t sub_results[bit_length];
    uint8_t limit = bit_length / 2 + 1;
    uint64_t mask = (1ULL << (bit_length - 1)) - 1;

    overlay_t *results_ptr = results;
    results_ptr->token = SENTINAL;

    for (uint8_t period = 1; period < limit; period++) {

        uint64_t xor_bits = mask & (number ^ (number >> period));  // heart of the code
        period_runs(xor_bits, bit_length - period, period, sub_results);

        for (size_t i = 0; sub_results[i].token != SENTINAL; i++) {

            bool stop = false;  // combine previous and current results

            for (size_t j = 0; !stop && results[j].token != SENTINAL; j++) {

                // lower period result disqualifies higher period result over the same span
                stop = (sub_results[i].token == results[j].token);
            }

            if (!stop) {

                (results_ptr++)->token = sub_results[i].token;
                results_ptr->token = SENTINAL;
            }
        }

        mask >>= 1;
    }
}

int main() {

    overlay_t results[NUMBER_OF_BITS];

    for (uint8_t bit_length = 2; bit_length < 25; bit_length++) {

        int best_results = -1;
        uint64_t best_number = 0;

        for (uint64_t number = 1ULL << (bit_length - 1); number < (1ULL << bit_length); number++) {

            // from the discussion comments, I should be able to solve this
            // with just bit strings that begin "11...", so toss the rest
            if ((number & (1ULL << (bit_length - 2))) == 0ULL) {

                continue;
            }

            uint64_t reversed = 0;

            for (uint8_t i = 0; i < bit_length; i++) {

                if (number & (1ULL << i)) {

                    reversed |= (1ULL << ((bit_length - 1) - i));
                }
            }

            if (reversed > number) {

                continue;  // ~ 1/4 of bit_strings are simply reversals, toss 'em
            }

            number_runs(number, bit_length, results);
            overlay_t *results_ptr = results;
            int count = 0;

            while ((results_ptr++)->token != SENTINAL) {

                count++;
            }

            if (count > best_results) {

                best_results = count;
                best_number = number;
            }
        }

        char *best_string = malloc(bit_length + 1);
        uint64_t number = best_number;
        char *string_ptr = best_string;

        for (int i = bit_length - 1; i >= 0; i--) {

            *(string_ptr++) = (number & (1ULL << i)) ? '1' : '0';
        }

        *string_ptr = '\0';

        printf("%u %d %s\n", bit_length, best_results, best_string);

        free(best_string);
    }

    return 0;
}
</code>```

Output:

```<code>> gcc -O2 run-count.c -o run-count
> ./run-count
2 1 11
3 1 110
4 2 1100
5 2 11000
6 3 110011
7 4 1100100
8 5 11001100
9 5 110010011
10 6 1100110011
11 7 11001100100
12 8 110110011011
13 8 1100100010011
14 10 11001001100100
15 10 110010011001000
16 11 1100100110010011
17 12 11001100100110011
18 13 110011001001100100
19 14 1101001011010010100
20 15 11010110100101101011
21 15 110010011001001100100
22 16 1100101001011010010100
23 17 11010010110100101001011
24 18 110100101001011010010100
25 19 1100100110010001001100100
26 20 11010010100101101001010010
27 21 110010011001000100110010011
28 22 1101001010010110100101001011
</code>```

Body:
Since it's not a race if there's only one horse, I'm submitting my solution though it's only a fraction the speed of Anders Kaseorg's and a only a third as cryptic.  Compile with:

gcc -O2 run-count.c -o run-count

The heart of my algorithm is a simple shift and XOR scheme:

A run of zeros in the XOR result that's greater than or equal to the current period/shift indicates a run in the original string for this period.  From this you can tell how long the run was and where it starts and ends.  The rest of the code is overhead, setting up the situation and decoding the results.

I'm hoping it will make at least 28 after two minutes on Lembik's machine.  (I wrote a pthread version, but only managed to make it run even slower.)

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

enum { START = 0, WIDTH } ;

// Compare and shuffle just one thing while storing two
typedef union {
    uint16_t token;
    uint8_t data[sizeof(uint16_t)];
} overlay_t;

#define SENTINAL (0)  // marks the end of an array of overlay_t

#define NUMBER_OF_BITS (8 * sizeof(uint64_t))

void period_runs(uint64_t xor_bits, uint8_t nbits, uint8_t period, overlay_t *results) {

    overlay_t *results_ptr = results;
    uint8_t count = 0;

    for (uint8_t position = 0; position < nbits; position++) {

        if (xor_bits & 1ULL) {

            if ((nbits - position) < period) {
                break;  // no room left to succeed further
            }

            if (count >= period) {  // we found a run

                results_ptr->data[START] = position - (count - 1);
                results_ptr->data[WIDTH] = period + count;
                results_ptr++;
            }

            count = 0;
        } else {

            count++;
        }

        xor_bits >>= 1;
    }

    if (count >= period) {  // process the final run, if any

        results_ptr->data[START] = 0;
        results_ptr->data[WIDTH] = period + count;
        results_ptr++;
    }

    results_ptr->token = SENTINAL;
}

void number_runs(uint64_t number, uint8_t bit_length, overlay_t *results) {

    overlay_t sub_results[bit_length];
    uint8_t limit = bit_length / 2 + 1;
    uint64_t mask = (1ULL << (bit_length - 1)) - 1;

    overlay_t *results_ptr = results;
    results_ptr->token = SENTINAL;

    for (uint8_t period = 1; period < limit; period++) {

        uint64_t xor_bits = mask & (number ^ (number >> period));  // heart of the code
        period_runs(xor_bits, bit_length - period, period, sub_results);

        for (size_t i = 0; sub_results[i].token != SENTINAL; i++) {

            bool stop = false;  // combine previous and current results

            for (size_t j = 0; !stop && results[j].token != SENTINAL; j++) {

                // lower period result disqualifies higher period result over the same span
                stop = (sub_results[i].token == results[j].token);
            }

            if (!stop) {

                (results_ptr++)->token = sub_results[i].token;
                results_ptr->token = SENTINAL;
            }
        }

        mask >>= 1;
    }
}

int main() {

    overlay_t results[NUMBER_OF_BITS];

    for (uint8_t bit_length = 2; bit_length < 25; bit_length++) {

        int best_results = -1;
        uint64_t best_number = 0;

        for (uint64_t number = 1ULL << (bit_length - 1); number < (1ULL << bit_length); number++) {

            // from the discussion comments, I should be able to solve this
            // with just bit strings that begin "11...", so toss the rest
            if ((number & (1ULL << (bit_length - 2))) == 0ULL) {

                continue;
            }

            uint64_t reversed = 0;

            for (uint8_t i = 0; i < bit_length; i++) {

                if (number & (1ULL << i)) {

                    reversed |= (1ULL << ((bit_length - 1) - i));
                }
            }

            if (reversed > number) {

                continue;  // ~ 1/4 of bit_strings are simply reversals, toss 'em
            }

            number_runs(number, bit_length, results);
            overlay_t *results_ptr = results;
            int count = 0;

            while ((results_ptr++)->token != SENTINAL) {

                count++;
            }

            if (count > best_results) {

                best_results = count;
                best_number = number;
            }
        }

        char *best_string = malloc(bit_length + 1);
        uint64_t number = best_number;
        char *string_ptr = best_string;

        for (int i = bit_length - 1; i >= 0; i--) {

            *(string_ptr++) = (number & (1ULL << i)) ? '1' : '0';
        }

        *string_ptr = '\0';

        printf("%u %d %s\n", bit_length, best_results, best_string);

        free(best_string);
    }

    return 0;
}

Output:

> gcc -O2 run-count.c -o run-count
> ./run-count
2 1 11
3 1 110
4 2 1100
5 2 11000
6 3 110011
7 4 1100100
8 5 11001100
9 5 110010011
10 6 1100110011
11 7 11001100100
12 8 110110011011
13 8 1100100010011
14 10 11001001100100
15 10 110010011001000
16 11 1100100110010011
17 12 11001100100110011
18 13 110011001001100100
19 14 1101001011010010100
20 15 11010110100101101011
21 15 110010011001001100100
22 16 1100101001011010010100
23 17 11010010110100101001011
24 18 110100101001011010010100
25 19 1100100110010001001100100
26 20 11010010100101101001010010
27 21 110010011001000100110010011
28 22 1101001010010110100101001011


问:
Dijkstra's Challenge

Presented in honor of APL as an interactive tool turning 50 this year

Background

Ken [Iverson] presented his paper Formalism in Programming Languages in August 1963 at a Working Conference on Mechanical Language Structures, Princeton, N.J. The list of conferees is full of famous and soon-to-be famous names, and a few future Turing Award winners (Backus, Curry, Dijkstra, Floyd, Iverson, Newell, Perlis, Wilkes). The paper also records the discussion that occurred after the presentation, ending with an exchange between Ken and [Edsger] Dijkstra, in which Ken’s reply to Dijkstra’s question was a one-liner.

Challenge

How would you represent a more complex operation, for example, the sum of all elements of a matrix M which are equal to the sum of the corresponding row and column indices?

Write a snippet or expression (no need for a full program or function) to calculate the sum of each element in a given integer matrix which is equal to the sum of its indices. Or, as FryAmTheEggman puts it: given a matrix M with elements aij return the sum of each aij where aij = i + j.

You may assume the matrix already being in a variable or memory location, or you may take it as an argument or input. You may use either 0 or 1 based indices.

Test cases

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

0 for empty matrix

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

0 for 0 based indices or 2 for 1-based

```<code>1 5 2
9 4 2
5 9 6
</code>```

2 for 0 based or 10 for 1 based

```<code> 0 3  0  4
 0 4  1  4
 4 3  1  2
-2 4 -2 -1
</code>```

11

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

6 for 0 based or 3 for 1 based

Anecdote

Iverson's answer was ++/(M = ⍳¹ ⨢ ⍳¹)//M, which is neither valid in the Iverson Notation as defined in A Programming Language, nor in what eventually became APL. In Iverson notation, it would have been +/(M = ⍳¹(μ(M)) ⨢ ⍳¹(ν(M)))/M. In the very first versions of APL it was +/(,M=(⍳1↑⍴M)∘.+⍳1↓⍴M)/,M.

答:
k4, 24 bytes

Assumes the matrix is stored in m.

```<code>+//7h$m*m=(!#m)+/:\:!#*m
</code>```

This is one of those puzzles where the simplifications involved in designing k from APL (and J) really hurt—k’s ! is the equivalent of APL’s ⍳ but only works on vectors, so I have to assemble the matrix of indices myself; inner product is one character in APL but five in k; and I lose three characters to handling the empty matrix properly because k doesn’t have strongly-typed matrices.

Title: Dijkstra's Challenge

Body:
k4, 24 bytes

Assumes the matrix is stored in m.

+//7h$m*m=(!#m)+/:\:!#*m

This is one of those puzzles where the simplifications involved in designing k from APL (and J) really hurt—k’s ! is the equivalent of APL’s ⍳ but only works on vectors, so I have to assemble the matrix of indices myself; inner product is one character in APL but five in k; and I lose three characters to handling the empty matrix properly because k doesn’t have strongly-typed matrices.


答:
Sesos, 16 bytes

Hexdump:

```<code>0000000: d6659c af71e7 a0fbf8 70cedc ae8de7 1e             .e..q....p......
</code>```

Try it online!

Assembler:

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

Brainfuck: ,>,<[>->+<[>>]>[-<+>]<<<[<]>-]>>>>+<<[>]>>.

Title: Divisibility test

Body:
Task

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

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

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

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

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

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

Test cases

```<code> n,  d    output

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

Leaderboard

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

Body:
Sesos, 16 bytes

Hexdump:

0000000: d6659c af71e7 a0fbf8 70cedc ae8de7 1e             .e..q....p......

Try it online!

Assembler:

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

Brainfuck: ,>,<[>->+<[>>]>[-<+>]<<<[<]>-]>>>>+<<[>]>>.


答:
Ruby, 28 points

249 Chars

Same bot as my other solution, but slightly cheating maybe by applying compression.

http://coolfire.insomnia247.nl/golfbot-inflate.rb (As pasting this code probably won't work too well.)

Score

```<code>bonus = 0       # We've done nothing yet
bonus += 1      # Connects to channel
bonus *= 2      # Step 1 - 5

for n in 1..7
    bonus *= 1.2    # A - G
end

for n in 1..4
    bonus *= 1.05   # 4 constraints
end

puts (249/bonus).to_i
>  28
</code>```

Code

```<code>require 'zlib'
b=<<'E'
x�]�_o�0���)��q�-KFBcdf��߃�P�S�B�����(N�Л��s~�� ��(�_$U6��5G�)�r�BB������J�{��� nNhlO�f)QQdJ�g��'�yP�!!����K�ɫ��[Ё�Ə{0�F]ѽ�m�2���GŐP��p`   ��I����E�+�* z�                                                                                )jrmKR�ˮ�%�
#��nQaJ�H��<�ZT���虦T3.�$D('�hw��a�/'��&�_ei�}o��1���M$����H��J�$��������V"���"��'��|A�`<��3L)Y��Z|� e�� ���m�é��ǚ�ڎu��J�����Vq~(ح�
E
eval Zlib::Inflate.new.inflate b
</code>```

Title: Make a simple IRC bot.

Body:
Task

Make a simple IRC bot which does simple task like greeting user.

Detail

(You may see this RFC document.)

Write a complete program that perform these:

The program inputs nickname and realname from the user.

All nickname and realname which form is [A-Za-z0-9]+ should be allowed, but it isn't  important whether other forms are allowed. For example, if the user wants 1234qwerty as nickname and 5319009 as realname, the program should use those names, but it isn't important whether the program can use ^^☆Rick Astley☆^^ (which includes non-alphabet&decimals) as (nickname or realname) or not, even thought this name may be rejected by the server.

The program inputs serverAddress from the user.

The form of serverAddress is serverIP:serverPort, where serverIP is the IP address of the server and serverPort is the port num of the server.

The program connects to port serverPort at IRC server serverIP, and it should set it's nickname as nickname and realname as realname by sending USER realname 0 * :realname and NICK nickname.

The program inputs a single channelName which doesn't include #, and join to the channel #channelName.

Send a private message Hello, world! to the #channelName channel like this: PRIVMSG #channelName :Hello, world!

Then, the program does these:

A. If someone joins, greeting him by saying Hello, @! to #channelName, where @ is the nickname of him/her.

B. If the program is kicked, try re-joining.

C. If a person is kicked or banned, say POW HAHA.

D. If a person leaves (PART or QUIT), say Goodbye, @!, where @ is the nickname of him/her.

E. If someone says some text including Turing test or turing test, say I'm a human!.

F. If someone says some text including 6*9, quit by sending QUIT :42 to the server.

G. If someone says some text including all your base are belong to us(case-insensitive), quit by sending QUIT :What you say! to the server.

H. If someone says some text preceding with a space and above acts aren't performed by the text, say the sum of charcode of all (except the first space) chars in the text.

If an error is occurred

If an error (such as connection error or invalid nickname) is occurred, you can do what you want to do. For example, if the nickname is already in use, the program may stop, gets a new nickname from the user, or automatically change the nickname and retry.

Restriction

The program

Should not use any internal functions or libraries which is for IRC client/bot making. i.e. something like IRC client libraries

Should prompt what it'll input, before it gets an input. For example, before inputs serverAddress, it should prompt Write the address of server:, serverIP:serverPort > , serverAddress >, or some text that the user can recognize.

Should work on several IRC servers using UTF-8. (i.e. not for single server)

's messages send to server shouldn't be NOTICE. (RFC 2812, 3.3.2 Notice : The difference between NOTICE and PRIVMSG is that automatic replies MUST NEVER be sent in response to a NOTICE message.)

Should send a message where the request came from (#channelName or nickname).

Should PONG when PINGed, of course.

PS

Well, I just made this, because there was no puzzle about IRC bot.

Edit

After reading @dmckee's comment, I changed the rule for choosing winner.

Default bonus = +0

If somehow the program can connect to a channel (even if it's not #channelName), bonus = 1

If the program can perform step 1~5, bonus *= 2.

For each tasks A~H in step 6, if the program implements, bonus *= 1.2.

For each six restrictions, if the program follows that, bonus *= 1.05.

and score = int(codelength/bonus).

Program with lowest score is winner. If two answers have same score, then the answer with highest votes wins.

EDIT Edit : I think 1.2 and 1.05 in step 4 and 5 should be adjusted slightly bigger.. What do you think about this?

The winner is decided, however, I think there was too few entries.

Anyone still may submit the code.. :P

Body:
Ruby, 28 points

249 Chars

Same bot as my other solution, but slightly cheating maybe by applying compression.

http://coolfire.insomnia247.nl/golfbot-inflate.rb (As pasting this code probably won't work too well.)

Score

bonus = 0       # We've done nothing yet
bonus += 1      # Connects to channel
bonus *= 2      # Step 1 - 5

for n in 1..7
    bonus *= 1.2    # A - G
end

for n in 1..4
    bonus *= 1.05   # 4 constraints
end

puts (249/bonus).to_i
>  28

Code

require 'zlib'
b=<<'E'
x�]�_o�0���)��q�-KFBcdf��߃�P�S�B�����(N�Л��s~�� ��(�_$U6��5G�)�r�BB������J�{��� nNhlO�f)QQdJ�g��'�yP�!!����K�ɫ��[Ё�Ə{0�F]ѽ�m�2���GŐP��p`   ��I����E�+�* z�                                                                                )jrmKR�ˮ�%�
#��nQaJ�H��<�ZT���虦T3.�$D('�hw��a�/'��&�_ei�}o��1���M$����H��J�$��������V"���"��'��|A�`<��3L)Y��Z|� e�� ���m�é��ǚ�ڎu��J�����Vq~(ح�
E
eval Zlib::Inflate.new.inflate b


答:
ROOP, 15 bytes

```<code>123456789
h(10)
</code>```

Solution with hardcoded numbers, I'm still trying to find a shorter program.

In this language each digit becomes an individual object. Number 10 is written in parenthesis to make it a single object. The operator h prints all objects that are currently in the program, separated by a space, then halt.

Title: Print numbers from 1 to 10

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

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

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

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

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
ROOP, 15 bytes

123456789
h(10)

Solution with hardcoded numbers, I'm still trying to find a shorter program.

In this language each digit becomes an individual object. Number 10 is written in parenthesis to make it a single object. The operator h prints all objects that are currently in the program, separated by a space, then halt.


答:
ROOP, 24 bytes

```<code>I
w
 w
R #H
 #
N
 #
W
O#
</code>```

The I is the input object. When the object is on the operator w wait the entry of a number that puts it under. Then the I moves to the right and falls on the second w waiting for the second number. The operator R removes those two numbers, and make the remainder of divide them below. The N operator removes that number and creates a 1 if the number was 0, and 0 otherwise. Then the W operator puts that number in the O object representing the output. At the same time the I reached the operator H that ends execution.

Title: Divisibility test

Body:
ROOP, 24 bytes

I
w
 w
R #H
 #
N
 #
W
O#

The I is the input object. When the object is on the operator w wait the entry of a number that puts it under. Then the I moves to the right and falls on the second w waiting for the second number. The operator R removes those two numbers, and make the remainder of divide them below. The N operator removes that number and creates a 1 if the number was 0, and 0 otherwise. Then the W operator puts that number in the O object representing the output. At the same time the I reached the operator H that ends execution.