答:
MATLAB, <s>32</s> 31 bytes

```<code>@(x)conv2(ones(x),eye(3),'s')>2
</code>```

This creates an anonymous function which can then be run as ans([4 5]) within the workspace.

Input is [height, width] and output is a matrix with 1 in the center and 0 for the boundary.

The way that this works is a matrix of ones the size of the input is created. It is then convolved with a 3 x 3 identify matrix with ones on the diagonal. We use the same input to conv2 (shortened to 's' here) to keep the result the same size as the input.

We then want to convert the output to a binary value with 0 around the boundary and 1 inside. We use the inequality >2 because all edge pixels will have a result < 3 and all non-boundary elements will have a result equal to 3.

For graphical output:

```<code>@(x)imagesc(conv2(ones(x),eye(3),'s')>8)
ans([6,9])
</code>```

Title: Form tiles in a rectangular ring

Body:
Given the input tilesX and tilesY create a method that would make a rectangular ring from the tiles.

The function must order the tiles in a ring like this:

tilesX and tilesY are always positive integer values, cannot be 0

tilesX and tilesY are not always equal, expect values like: 2x5, 6x3 etc.

Checking for invalid input is not necessary

You can use any way to display the tiles, including 2d arrays, ASCII art or printed text.

There's no strict way how the input is passed as long as it's two integers.

Cannot be a line, drawing a rectangle size of tilesX and tilesY pixels is not valid

The shortest code wins

Body:
MATLAB, <s>32</s> 31 bytes

@(x)conv2(ones(x),eye(3),'s')>2

This creates an anonymous function which can then be run as ans([4 5]) within the workspace.

Input is [height, width] and output is a matrix with 1 in the center and 0 for the boundary.

The way that this works is a matrix of ones the size of the input is created. It is then convolved with a 3 x 3 identify matrix with ones on the diagonal. We use the same input to conv2 (shortened to 's' here) to keep the result the same size as the input.

We then want to convert the output to a binary value with 0 around the boundary and 1 inside. We use the inequality >2 because all edge pixels will have a result < 3 and all non-boundary elements will have a result equal to 3.

For graphical output:

@(x)imagesc(conv2(ones(x),eye(3),'s')>8)
ans([6,9])


问:
Form tiles in a rectangular ring
Given the input tilesX and tilesY create a method that would make a rectangular ring from the tiles.

The function must order the tiles in a ring like this:

tilesX and tilesY are always positive integer values, cannot be 0

tilesX and tilesY are not always equal, expect values like: 2x5, 6x3 etc.

Checking for invalid input is not necessary

You can use any way to display the tiles, including 2d arrays, ASCII art or printed text.

There's no strict way how the input is passed as long as it's two integers.

Cannot be a line, drawing a rectangle size of tilesX and tilesY pixels is not valid

The shortest code wins

答:
Jelly, 10 bytes

```<code>p%€,>1P€G
</code>```

Returns a grid of 0's (border) and 1's (interior). Try it online!

How it works

```<code>p%€,>1P€sG  Main link. Arguments: h (height), w (width)

p           Cartesian product; return all pairs in [1, ..., h] × [1, ..., w].
   ,        Yield the pair [h, w].
 %€         For each pair [i, j] in the product, compute [i % h, j % w].
    >1      Compare all resulting moduli with 1.
      P€    Compute the product of each pair of Booleans.
        s   Split the resulting flat list into rows of length w.
         G  Display the results in a 2D grid.
</code>```

ContentLicense: CC BY-SA 3.0

Title: Form tiles in a rectangular ring

Body:
Jelly, 10 bytes

p%€,>1P€G

Returns a grid of 0's (border) and 1's (interior). Try it online!

How it works

p%€,>1P€sG  Main link. Arguments: h (height), w (width)

p           Cartesian product; return all pairs in [1, ..., h] × [1, ..., w].
   ,        Yield the pair [h, w].
 %€         For each pair [i, j] in the product, compute [i % h, j % w].
    >1      Compare all resulting moduli with 1.
      P€    Compute the product of each pair of Booleans.
        s   Split the resulting flat list into rows of length w.
         G  Display the results in a 2D grid.


答:
MATL, 10 bytes

```<code>2$l3XyZ+3=
</code>```

Input arguments are height and width as integers. The output is a matrix of size height x width where the boundary tiles are 0 and the inner values are 1.

Try it Online!

Explanation

Same logic as my other answer with fewer bytes.

```<code>        % Grab two input parameters implicitly
2$l     % Create a matrix of ones that has the dimensions specified as inputs
3       % Number literal 3
Xy      % Create a 3x3 identity matrix
Z+      % Perform 2D convolution (preserving size)
3=      % Create a logical matrix where values == 3 are 1 and 0 otherwise (boundary)
        % Implicitly display output.
</code>```

Title: Form tiles in a rectangular ring

Body:
MATL, 10 bytes

2$l3XyZ+3=

Input arguments are height and width as integers. The output is a matrix of size height x width where the boundary tiles are 0 and the inner values are 1.

Try it Online!

Explanation

Same logic as my other answer with fewer bytes.

        % Grab two input parameters implicitly
2$l     % Create a matrix of ones that has the dimensions specified as inputs
3       % Number literal 3
Xy      % Create a 3x3 identity matrix
Z+      % Perform 2D convolution (preserving size)
3=      % Create a logical matrix where values == 3 are 1 and 0 otherwise (boundary)
        % Implicitly display output.


问:
Expand a C array
In the C programming language, arrays are defined like this:

```<code>int foo[] = {4, 8, 15, 16, 23, 42};      //Foo implicitly has a size of 6
</code>```

The size of the array is inferred from the initializing elements, which in this case is 6. You can also write a C array this way, explicitly sizing it then defining each element in order:

```<code>int foo[6];        //Give the array an explicit size of 6
foo[0] = 4;
foo[1] = 8;
foo[2] = 15;
foo[3] = 16;
foo[4] = 23;
foo[5] = 42;
</code>```

The challenge

You must write a program or function that expands arrays from the first way to the second. Since you are writing a program to make code longer, and you love irony, you must make your code as short as possible.

The input will be a string representing the original array, and the output will be the expanded array-definition. You can safely assume that the input will always look like this:

```<code><type> <array_name>[] = {<int>, <int>, <int> ... };
</code>```

"Type" and "array_name" will made up entirely of alphabet characters and underscores _. The elements of the list will always be a number in the range -2,147,483,648 to 2,147,483,647. Inputs in any other format do not need to be handled.

The whitespace in your output must exactly match the whitespace in the test output, although a trailing newline is allowed.

Test IO:

```<code>#in
short array[] = {4, 3, 2, 1};

#out
short array[4];
array[0] = 4;
array[1] = 3;
array[2] = 2;
array[3] = 1;

#in
spam EGGS[] = {42};

#out
spam EGGS[1];
EGGS[0] = 42;

#in
terrible_long_type_name awful_array_name[] = {7, -8, 1337, 0, 13};

#out
terrible_long_type_name awful_array_name[5];
awful_array_name[0] = 7;
awful_array_name[1] = -8;
awful_array_name[2] = 1337;
awful_array_name[3] = 0;
awful_array_name[4] = 13;
</code>```

Submissions in any language are encouraged, but bonus points if you can do it in C.

Leaderboard:

Here is a leaderboard showing the top answers:

var QUESTION_ID=77857,OVERRIDE_USER=31716;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

```

答:
C, <s>195</s> 180 bytes

195-byte original:

golfed:

char*a,*b,*c,*d;j;main(i){scanf("%ms %m[^]]%m[^;]",&a,&b,&c);
for(d=c;*d++;i+=*d==44);printf("%s %s%d];\n",a,b,i);
for(d=strtok(c,"] =,{}");j<i;j++,d=strtok(0," ,}"))printf("%s%d] = %s;\n",b,j,d);}
```
<p>ungolfed:</p>
<pre class="lang-c prettyprint-override"><code>char*a,*b,*c,*d;
j;
main(i){
    scanf("%ms %m[^]]%m[^;]",&a,&b,&c); // m-modifier does its own mallocs
    for(d=c;*d++;i+=*d==44);            // count commas
    printf("%s %s%d];\n",a,b,i);        // first line
    for(d=strtok(c,"] =,{}");j<i;j++,d=strtok(0," ,}"))
        printf("%s%d] = %s;\n",b,j,d);  // each array value
}
</code>```

The two shortcuts are using the m modifier to  to get scanf's %s to allocate its own memory (saves declaring char arrays), and using strtok (which is also available by default, without includes) to do the number-parsing part.

180-byte update:

char*a,*b,*c,e[999];i;main(){scanf("%ms %m[^]]%m[^}]",&a,&b,&c);
for(c=strtok(c,"] =,{}");sprintf(e,"%s%s%d] = %s;\n",e,b,i++,c),
c=strtok(0," ,"););printf("%s %s%d];\n%s",a,b,i,e);}
```
<p>ungolfed:</p>
<pre class="lang-c prettyprint-override"><code>char*a,*b,*c,e[999];
i;
main(){
    scanf("%ms %m[^]]%m[^}]",&a,&b,&c);
    for(c=strtok(c,"] =,{}");sprintf(e,"%s%s%d] = %s;\n",e,b,i++,c),c=strtok(0," ,"););
    printf("%s %s%d];\n%s",a,b,i,e);
}
</code>```

Uses bnf679's idea of appending to a string to avoid having to count commas.

Title: Expand a C array

Body:
C, <s>195</s> 180 bytes

195-byte original:

golfed:

char*a,*b,*c,*d;j;main(i){scanf("%ms %m[^]]%m[^;]",&a,&b,&c);
for(d=c;*d++;i+=*d==44);printf("%s %s%d];\n",a,b,i);
for(d=strtok(c,"] =,{}");j<i;j++,d=strtok(0," ,}"))printf("%s%d] = %s;\n",b,j,d);}

ungolfed:

char*a,*b,*c,*d;
j;
main(i){
    scanf("%ms %m[^]]%m[^;]",&a,&b,&c); // m-modifier does its own mallocs
    for(d=c;*d++;i+=*d==44);            // count commas
    printf("%s %s%d];\n",a,b,i);        // first line
    for(d=strtok(c,"] =,{}");j<i;j++,d=strtok(0," ,}"))
        printf("%s%d] = %s;\n",b,j,d);  // each array value
}

The two shortcuts are using the m modifier to  to get scanf's %s to allocate its own memory (saves declaring char arrays), and using strtok (which is also available by default, without includes) to do the number-parsing part.

180-byte update:

char*a,*b,*c,e[999];i;main(){scanf("%ms %m[^]]%m[^}]",&a,&b,&c);
for(c=strtok(c,"] =,{}");sprintf(e,"%s%s%d] = %s;\n",e,b,i++,c),
c=strtok(0," ,"););printf("%s %s%d];\n%s",a,b,i,e);}

ungolfed:

char*a,*b,*c,e[999];
i;
main(){
    scanf("%ms %m[^]]%m[^}]",&a,&b,&c);
    for(c=strtok(c,"] =,{}");sprintf(e,"%s%s%d] = %s;\n",e,b,i++,c),c=strtok(0," ,"););
    printf("%s %s%d];\n%s",a,b,i,e);
}

Uses bnf679's idea of appending to a string to avoid having to count commas.


答:
Julia, <s>46</s> 34 bytes

f(n,m)=[n>i>1<j<m for i=1:n,j=1:m]
```

<p>This is a function that accepts two integers and returns a 2-dimensional boolean array.</p>

<p>We construct an <em>n</em> × <em>m</em> matrix using an array comprehension with a double <code>for</code> loop. For each index from 1 to <em>n</em> and 1 to <em>m</em>, i.e. each element of the matrix, we set the value to <code>true</code> if <em>n</em> > <em>i</em> > 1 and 1 < <em>j</em> < <em>m</em>. This is true everywhere but the boundaries, so the resulting array will have <code>true</code>s in the middle and <code>false</code>s around the border.</p>

<p>Examples:</p>

```julia> f(n,m)=[n>i>1<j<m for i=1:n,j=1:m]
f (generic function with 1 method)

julia> f(4,4)
4x4 Array{Bool,2}:
 false  false  false  false
 false   true   true  false
 false   true   true  false
 false  false  false  false

julia> f(1,1)
1x1 Array{Bool,2}:
 false

julia> f(2,5)
2x5 Array{Bool,2}:
 false  false  false  false  false
 false  false  false  false  false
```

Saved 12 bytes thanks to Dennis!

Title: Form tiles in a rectangular ring

Body:
Julia, <s>46</s> 34 bytes

f(n,m)=[n>i>1<j<m for i=1:n,j=1:m]

This is a function that accepts two integers and returns a 2-dimensional boolean array.

We construct an n × m matrix using an array comprehension with a double for loop. For each index from 1 to n and 1 to m, i.e. each element of the matrix, we set the value to true if n > i > 1 and 1 < j < m. This is true everywhere but the boundaries, so the resulting array will have trues in the middle and falses around the border.

Examples:

julia> f(n,m)=[n>i>1<j<m for i=1:n,j=1:m]
f (generic function with 1 method)

julia> f(4,4)
4x4 Array{Bool,2}:
 false  false  false  false
 false   true   true  false
 false   true   true  false
 false  false  false  false

julia> f(1,1)
1x1 Array{Bool,2}:
 false

julia> f(2,5)
2x5 Array{Bool,2}:
 false  false  false  false  false
 false  false  false  false  false

Saved 12 bytes thanks to Dennis!


问:
Full Width Text
Full width text is text that has a space after every character, including the last one. For instance, the first sentence of this question becomes:

```<code>F u l l   w i d t h   t e x t   i s   t e x t   t h a t   h a s   a   s p a c e   a f t e r   e v e r y   c h a r a c t e r ,   i n c l u d i n g   t h e   l a s t   o n e .
</code>```

Write a program that takes a line in text from standard input and outputs it as full-width text to standard out.

Leaderboard

var QUESTION_ID=75979,OVERRIDE_USER=52353;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

```

答:
C, 50 bytes

Little bit of main() recursion :)

main(c){~(c=getchar())?printf("%c ",c),main():0;}
```

Try it online! - If using this on your own machine, use Ctrl+D to signify EOF.

Title: Full Width Text

Body:
C, 50 bytes

Little bit of main() recursion :)

main(c){~(c=getchar())?printf("%c ",c),main():0;}

Try it online! - If using this on your own machine, use Ctrl+D to signify EOF.


答:
Hoon, 41 bytes

```<code>|*
*
`tape`(turn +< |=(@ (cat 3 +< ' ')))
</code>```

Takes advantage of not having to specify the tape of a wet gate (|*), and that arguments are places at +< to prevent having to name them.

There are actually two different types of strings in Hoon: tapes, and cords. tapes are (list @tD), while cords are simply @t.
Think the difference between a vector and an array: tapes can be indexed into and manipulated easily, while cords are "static" and basically just bignums.

This entry maps over the characters in the tape it gets as input, and adds on the value of ' ' to the end of the atom and then casts the result back to a tape.

Technically, this should probably be a type error: tape is a list of characters, and we are stuffing two in the space of only one. Luckily, while Hoon has syntax to say what you should expect the size of an atom to be, it doesn't actually enforce that expectation. Even slamming a too-big atom with a specific sized verification gate doesn't give back the default value like it should. Naturally, we abuse this and it even prints correctly in the console, as long as you don't try to full-width text any UTF-8 characters.

Usage:

```<code>> %.  "Full width text is text that has a space after every character, including the last one."
  |*
  *
  `tape`(turn +< |=(@ (cat 3 +< ' ')))
"F u l l   w i d t h   t e x t   i s   t e x t   t h a t   h a s   a   s p a c e   a f t e r   e v e r y   c h a r a c t e r ,   i n c l u d i n g   t h e   l a s t   o n e . "
</code>```

Title: Full Width Text

Body:
Full width text is text that has a space after every character, including the last one. For instance, the first sentence of this question becomes:

```<code>F u l l   w i d t h   t e x t   i s   t e x t   t h a t   h a s   a   s p a c e   a f t e r   e v e r y   c h a r a c t e r ,   i n c l u d i n g   t h e   l a s t   o n e .
</code>```

Write a program that takes a line in text from standard input and outputs it as full-width text to standard out.

Leaderboard

var QUESTION_ID=75979,OVERRIDE_USER=52353;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:
Hoon, 41 bytes

|*
*
`tape`(turn +< |=(@ (cat 3 +< ' ')))

Takes advantage of not having to specify the tape of a wet gate (|*), and that arguments are places at +< to prevent having to name them.

There are actually two different types of strings in Hoon: tapes, and cords. tapes are (list @tD), while cords are simply @t.
Think the difference between a vector and an array: tapes can be indexed into and manipulated easily, while cords are "static" and basically just bignums.

This entry maps over the characters in the tape it gets as input, and adds on the value of ' ' to the end of the atom and then casts the result back to a tape.

Technically, this should probably be a type error: tape is a list of characters, and we are stuffing two in the space of only one. Luckily, while Hoon has syntax to say what you should expect the size of an atom to be, it doesn't actually enforce that expectation. Even slamming a too-big atom with a specific sized verification gate doesn't give back the default value like it should. Naturally, we abuse this and it even prints correctly in the console, as long as you don't try to full-width text any UTF-8 characters.

Usage:

> %.  "Full width text is text that has a space after every character, including the last one."
  |*
  *
  `tape`(turn +< |=(@ (cat 3 +< ' ')))
"F u l l   w i d t h   t e x t   i s   t e x t   t h a t   h a s   a   s p a c e   a f t e r   e v e r y   c h a r a c t e r ,   i n c l u d i n g   t h e   l a s t   o n e . "


答:
Dyalog APL, 8 bytes

```<code>×/¨1<⊂|⍳
</code>```

This monadic function train takes height and width as right arguments and returns a 2D array of 0's (border) and 1's (interior). Test it on TryAPL.

How it works

```<code>×/¨1<⊂|⍳  Right argument: h w

       ⍳  Generate all index pairs (1-based) of a h×w array.
     ⊂    Enclose (h w), so it depth matches the one of the index array.
      |   For each pair (i j) compute the remainders of the division by (h w).
   1<     Compare all remainders with 1.
×/¨       Reduce each pair of Booleans by multiplication.
</code>```

Title: Form tiles in a rectangular ring

Body:
Dyalog APL, 8 bytes

×/¨1<⊂|⍳

This monadic function train takes height and width as right arguments and returns a 2D array of 0's (border) and 1's (interior). Test it on TryAPL.

How it works

×/¨1<⊂|⍳  Right argument: h w

       ⍳  Generate all index pairs (1-based) of a h×w array.
     ⊂    Enclose (h w), so it depth matches the one of the index array.
      |   For each pair (i j) compute the remainders of the division by (h w).
   1<     Compare all remainders with 1.
×/¨       Reduce each pair of Booleans by multiplication.


问:
Print N Squared
Write a program or function that takes in a non-negative integer N from stdin or as a function argument. It must print or return a string of a hollow ASCII-art square whose sides are each made with N copies of the number N.

Specifically:

If N is 0, no copies of N are used, so there should be no output (or only a single trailing newline).

If N is 1, the output is:

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

If N is 2:

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

If N is 3:

```<code>333
3 3
333
</code>```

If N is 4:

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

If N is 5:

```<code>55555
5   5
5   5
5   5
55555
</code>```

The pattern continues for 6 through 9.

If N is 10, the output is:

```<code>10101010101010101010
10                10
10                10
10                10
10                10
10                10
10                10
10                10
10                10
10101010101010101010
</code>```

Notice that this is not actually square. It is 10 rows tall but 20 columns wide because 10 is two characters long. This is intended. The point is that each side of the "square" contains N copies of N. So all inputs beyond 9 will technically be ASCII rectangles.

For example, if N is 23, the output is:

```<code>2323232323232323232323232323232323232323232323
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
2323232323232323232323232323232323232323232323</code>```

Here are Pastebins of the required outputs for 99, 100, 111, and 123 (they may look wrong in a browser but in a text editor they'll look correct). The output for 1000 is to large for Pastebin but it would have 1000 rows and 4000 columns. Numbers with 4 or more digits must work just like smaller numbers.

Details:

N must be written in the usual decimal number representation, with no + sign or other non-digits.

The hollow area must only be filled with spaces.

No lines should have leading or trailing spaces.

A single newline after the squares' last line is optionally allowed.

Languages written after this challenge was made are welcome, they just aren't eligible to win.

The shortest code in bytes wins!

答:
Pip -l, 21 bytes

Uses language features newer than the question, which is allowed per current policy; if the wording of the question is interpreted to override said policy, see 25-byte answer below.

```<code>Yq{MN++g%y>1?sMyy}MCy
</code>```

Try it online!

Thanks to Luis Mendo's MATL answer for the (a+1)%n<2 trick.

Explanation

Yq reads a line from stdin and yanks it into y. Then:

```<code>{              }MCy  Map this function to each coordinate pair in a y-by-y grid
                     (Inside the function, the list of both coords is g)
   ++g                Increment both coordinates
      %y              Take them mod y
 MN     >1?           Test whether the min of the resulting list is 2 or greater
           sMy         If so, it's in the center; use len(y) spaces
              y        If not, it's an edge; use the number y
                     Print result with newlines between rows (implicit, -l flag)
</code>```

Original 2016 answer, 25 bytes (plus -l flag):

```<code>Yq{MN++*a%y<2?ysX#y}MMCGy
</code>```

Changelog:

MC was added more recently; at the time, I used MMCG (map-map + coordinate-grid).

There was a bug in the current interpreter that prevented using ++ on lists, so I had to do ++* (apply ++ to each element) instead.

Map has been extended: now <string1> M <string2> returns a list of len(<string2>) copies of <string1>; at the time, I used sX#y, string-repeating space by len(y).

Title: Print N Squared

Body:
Pip -l, 21 bytes

Uses language features newer than the question, which is allowed per current policy; if the wording of the question is interpreted to override said policy, see 25-byte answer below.

Yq{MN++g%y>1?sMyy}MCy

Try it online!

Thanks to Luis Mendo's MATL answer for the (a+1)%n<2 trick.

Explanation

Yq reads a line from stdin and yanks it into y. Then:

{              }MCy  Map this function to each coordinate pair in a y-by-y grid
                     (Inside the function, the list of both coords is g)
   ++g                Increment both coordinates
      %y              Take them mod y
 MN     >1?           Test whether the min of the resulting list is 2 or greater
           sMy         If so, it's in the center; use len(y) spaces
              y        If not, it's an edge; use the number y
                     Print result with newlines between rows (implicit, -l flag)

Original 2016 answer, 25 bytes (plus -l flag):

Yq{MN++*a%y<2?ysX#y}MMCGy

Changelog:

MC was added more recently; at the time, I used MMCG (map-map + coordinate-grid).

There was a bug in the current interpreter that prevented using ++ on lists, so I had to do ++* (apply ++ to each element) instead.

Map has been extended: now <string1> M <string2> returns a list of len(<string2>) copies of <string1>; at the time, I used sX#y, string-repeating space by len(y).

ContentLicense: CC BY-SA 4.0


问:
Golf you a quine for great good!
Using your language of choice, golf a quine.

A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output.

No cheating -- that means that you can't just read the source file and print it. Also, in many languages, an empty file is also a quine: that isn't considered a legit quine either.

No error quines -- there is already a separate challenge for error quines.

Points for:

Smallest code (in bytes)

Most obfuscated/obscure solution

Using esoteric/obscure languages

Successfully using languages that are difficult to golf in

The following Stack Snippet can be used to get a quick view of the current score in each language, and thus to know which languages have existing answers and what sort of target you have to beat:

var QUESTION_ID=69;
var OVERRIDE_USER=98;

var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk";var answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,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:!0,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=!1;comment_page=1;getComments()}})}
function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,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=(function(){var headerTag=String.raw `h\d`
var score=String.raw `\-?\d+\.?\d*`
var normalText=String.raw `[^\n<>]*`
var strikethrough=String.raw `<s>${normalText}</s>|<strike>${normalText}</strike>|<del>${normalText}</del>`
var noDigitText=String.raw `[^\n\d<>]*`
var htmlTag=String.raw `<[^\n<>]+>`
return new RegExp(String.raw `<${headerTag}>`+String.raw `\s*([^\n,]*[^\s,]),.*?`+String.raw `(${score})`+String.raw `(?=`+String.raw `${noDigitText}`+String.raw `(?:(?:${strikethrough}|${htmlTag})${noDigitText})*`+String.raw `</${headerTag}>`+String.raw `)`)})();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;lang=jQuery(''+a.language+'').text().toLowerCase();languages[lang]=languages[lang]||{lang:a.language,user:a.user,size:a.size,link:a.link,uniq:lang}});var langs=[];for(var lang in languages)
if(languages.hasOwnProperty(lang))
langs.push(languages[lang]);langs.sort(function(a,b){if(a.uniq>b.uniq)return 1;if(a.uniq<b.uniq)return-1;return 0});for(var i=0;i<langs.length;++i)
{var language=jQuery("#language-template").html();var lang=langs[i];language=language.replace("{{LANGUAGE}}",lang.lang).replace("{{NAME}}",lang.user).replace("{{SIZE}}",lang.size).replace("{{LINK}}",lang.link);language=jQuery(language);jQuery("#languages").append(language)}}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list{padding:10px;float:left}#language-list{padding:10px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

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

Winners by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

 ```

答:
GolfScript, 2 bytes

```<code>1

</code>```

(note trailing newline) This pushes the number 1 onto the stack. At the end of the program, GolfScript prints out all items in the stack (with no spaces in between), then prints a newline.

This is a true quine (as listed in the question), because it actually executes the code; it doesn't just "read the source file and print it" (unlike the PHP submission).

For another example, here's a GolfScript program to print 12345678:

```<code>9,(;
</code>```

9: push 9 to the stack

,: consume the 9 as an argument, push the array [0 1 2 3 4 5 6 7 8] to the stack

(: consume the array as an argument, push the array [1 2 3 4 5 6 7 8] and the item 0 to the stack

;: discard the top item of the stack

The stack now contains the array [1 2 3 4 5 6 7 8]. This gets written to standard output with no spaces between the elements, followed by a newline.

Title: Golf you a quine for great good!

Body:
GolfScript, 2 bytes

1

(note trailing newline) This pushes the number 1 onto the stack. At the end of the program, GolfScript prints out all items in the stack (with no spaces in between), then prints a newline.

This is a true quine (as listed in the question), because it actually executes the code; it doesn't just "read the source file and print it" (unlike the PHP submission).

For another example, here's a GolfScript program to print 12345678:

9,(;

9: push 9 to the stack

,: consume the 9 as an argument, push the array [0 1 2 3 4 5 6 7 8] to the stack

(: consume the array as an argument, push the array [1 2 3 4 5 6 7 8] and the item 0 to the stack

;: discard the top item of the stack

The stack now contains the array [1 2 3 4 5 6 7 8]. This gets written to standard output with no spaces between the elements, followed by a newline.


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

—taken nearly verbatim from marcog's question.

答:
Want to find the maximum or minimum of a collection of values? Tried

```<code>(...|measure -ma).Maximum
</code>```

or

```<code>(...|measure -mi).Minimum
</code>```

already?

Just sort and use the last or first item:

```<code>(...|sort)[-1]  # maximum
(...|sort)[0]   # minimum
</code>```

Title: Tips for golfing in PowerShell

Body:
Want to find the maximum or minimum of a collection of values? Tried

(...|measure -ma).Maximum

or

(...|measure -mi).Minimum

already?

Just sort and use the last or first item:

(...|sort)[-1]  # maximum
(...|sort)[0]   # minimum

ContentLicense: CC BY-SA 2.5


问:
Convert to Roman Numeral!
Your task is to convert a given positive integer from Arabic numeral to Roman numeral.

Things get difficult when you count to 4000.

The romans did this by adding a line above a symbol to multiply that symbol by 1 000. However, overlines aren't exactly displayable in ASCII. Also, there are double overlines to multiply a symbol by 1 000 000, and then triple overline to multiply a symbol by 1 000 000 000, etc...

Therefore, I decided to use parentheses to replace overlines.

The symbols can be individually placed in parentheses. For example, both (VI) and (V)(I) are valid representations of 6 000. (V)M is also a valid representation of 6000.

(I) is a valid way to represent 1 000.

Testcases

```<code>Input: 1
Output: I
Input: 2
Output: II
Input: 3
Output: III
Input: 4
Output: IV
Input: 15
Output: XV
Input: 40
Output: XL
Input: 60
Output: LX
Input: 67
Output: LXVII
Input: 400
Output: CD
Input: 666
Output: DCLXVI
Input: 3000
Output: MMM
Input: 3999
Output: MMMCMXCIX
Input: 4000
Output: M(V)
Input: 4999
Output: M(V)CMXCIX
Input: 6000
Output: (VI)
Input: 6000000
Output: ((VI))
Input: 6006000
Output: ((VI)VI)
Input: 6666666666
Output: (((VI)DCLXVI)DCLXVI)DCLXVI
</code>```

Scoring

This is code-golf. Shortest code in bytes win.

答:
Ruby, <s>137</s> <s>134</s> 130 bytes

Recursive function that returns the string. I'm trying to golf down the numeral encodings a bit more if possible, but I'm not sure how.

Whoops, it's practically a direct port of @Neil's ES6 answer now.

```<code>f=->x{(x<t=1e3)?"CM900D500CD400C100XC90L50XL40X10IX9V5IV4I1".gsub(/(\D+)(\d+)/){v=$2.to_i;s=x/v;x%=v;$1*s}:"(#{f[x/t]})#{f[x%t]}"}
</code>```

Title: Convert to Roman Numeral!

Body:
Ruby, <s>137</s> <s>134</s> 130 bytes

Recursive function that returns the string. I'm trying to golf down the numeral encodings a bit more if possible, but I'm not sure how.

Whoops, it's practically a direct port of @Neil's ES6 answer now.

f=->x{(x<t=1e3)?"CM900D500CD400C100XC90L50XL40X10IX9V5IV4I1".gsub(/(\D+)(\d+)/){v=$2.to_i;s=x/v;x%=v;$1*s}:"(#{f[x/t]})#{f[x%t]}"}


问:
Generate Recamán's sequence
Recamán's sequence (A005132) is a mathematical sequence, defined as such:

```<code>A(0) = 0
A(n) = A(n-1) - n if A(n-1) - n > 0 and is new, else
A(n) = A(n-1) + n
</code>```

A pretty LaTex version of the above (might be more readable):

$$A(n) = \begin{cases}0 & \textrm{if } n = 0 \\
A(n-1) - n & \textrm{if } A(n-1) - n \textrm{ is positive and not already in the sequence} \\
% Seems more readable than
%A(n-1) - n & \textrm{if } A(n-1) > n \wedge \not\exists m < n: A(m) = A(n-1)-n \\
A(n-1) + n & \textrm{otherwise}
\end{cases}$$

The first few terms are 0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11

To clarify, is new means whether the number is already in the sequence.

Given an integer n, via function argument or STDIN, return the first n terms of the Recamán sequence.

This is a code-golf challenge, so shortest code wins.

Title: Generate Recamán's sequence

Body:
Mathematica - 81 bytes

Fold[#~Append~(#[[-1]]+If[#[[-1]]>#2&&FreeQ[#,#[[-1]]-#2],-#2,#2])&,{0},Range@#]&

Usage

Fold[#~Append~(#[[-1]]+If[#[[-1]]>#2&&FreeQ[#,#[[-1]]-#2],-#2,#2])&,{0},Range@#]&[30]
{0,1,3,6,2,7,13,20,12,21,11,22,10,23,9,24,8,25,43,62,42,63,41,18,42,17,43,16,44,15,45}


答:
Actually, 23 bytes

```<code>;'#*;))¬' *'#;)@+(+nXX(
</code>```

Try it online!

This approach is very similar to my approach in this related challenge.

Explanation:

```<code>;'#*;))¬' *'#;)@+(+nXX(
                         (implicit) push all input to stack
;'#*                     push a string containing X #s
    ;))                  dupe, and push both to bottom of stack
       ¬' *              push a string containing (X-2) spaces
           '#;)@+(+      add a # to the front and the back of the string
                   nXX   make (Y-2) copies
                      (  bring one of the "#"*X strings back to the top
                         (implicit) pop and print each stack item, separated by newlines
</code>```

Title: Form tiles in a rectangular ring

Body:
Actually, 23 bytes

;'#*;))¬' *'#;)@+(+nXX(

Try it online!

This approach is very similar to my approach in this related challenge.

Explanation:

;'#*;))¬' *'#;)@+(+nXX(
                         (implicit) push all input to stack
;'#*                     push a string containing X #s
    ;))                  dupe, and push both to bottom of stack
       ¬' *              push a string containing (X-2) spaces
           '#;)@+(+      add a # to the front and the back of the string
                   nXX   make (Y-2) copies
                      (  bring one of the "#"*X strings back to the top
                         (implicit) pop and print each stack item, separated by newlines


问:
Which dominoes are missing?
A standard domino set has 28 unique pieces:

Given a list of 28 or fewer unique dominoes, output the list required to make a complete set.

Input and output dominoes are specified by two digits - the number of pips on each side of the domino, e.g. 00, 34, 40, 66.

The digits may be given in any order, so 34 is the same domino as 43

Example Inputs

```<code>00 01 02 03 04 05 06 11 12 13 14 15 16 22 23 24 25 26 33 34 35 36 44 45 46 55 56 66
00 10 11 20 21 22 30 31 32 33 40 41 42 43 44 50 51 52 53 54 55 60 61 62 63 64 65 66
00 01 02 03 04 05 06 11 12 13 14 15 16 22 23 24 25 26 34 35 36 44 45 46 55 56 66
00 02 03 04 05 06 11 13 14 15 16 22 24 25 26 33 35 36 44 46 55 66
<empty list>
</code>```

Corresponding Example Outputs

```<code><empty list>
<empty list>
33
01 12 23 34 45 56
00 01 02 03 04 05 06 11 12 13 14 15 16 22 23 24 25 26 33 34 35 36 44 45 46 55 56 66
</code>```

答:
Seriously, 16 bytes

```<code>,`S`M7r;∙`εjS`M-
</code>```

Takes input as a list of strings, outputs a list of strings

Try it online!

Explanation:

```<code>,`S`M7r;∙`εjS`M-
,`S`M             map: sort each input string
     7r;∙         cartesian product of range(0,7) ([0,1,2,3,4,5,6]) with itself
         `εjS`M   map: join on empty string, sort (results in all valid dominoes with some duplicates)
               -  set difference (all values present in valid dominoes set not present in input, with duplicates removed)
</code>```

Actually, 13 bytes (non-competing)

```<code>♂S7r;∙`εjS`M-
</code>```

This is identical to the Seriously answer (with the exception of implicit input and ♂S being a shorter way to short each input string).

Try it online!

Title: Which dominoes are missing?

Body:
Seriously, 16 bytes

,`S`M7r;∙`εjS`M-

Takes input as a list of strings, outputs a list of strings

Try it online!

Explanation:

,`S`M7r;∙`εjS`M-
,`S`M             map: sort each input string
     7r;∙         cartesian product of range(0,7) ([0,1,2,3,4,5,6]) with itself
         `εjS`M   map: join on empty string, sort (results in all valid dominoes with some duplicates)
               -  set difference (all values present in valid dominoes set not present in input, with duplicates removed)

Actually, 13 bytes (non-competing)

♂S7r;∙`εjS`M-

This is identical to the Seriously answer (with the exception of implicit input and ♂S being a shorter way to short each input string).

Try it online!


问:
Collatz Conjecture (OEIS A006577)
This is the Collatz Conjecture (OEIS A006577):

Start with an integer n > 1.

Repeat the following steps:

If n is even, divide it by 2.

If n is odd, multiply it by 3 and add 1.

It is proven that for all positive integers up to 5 * 260, or about 5764000000000000000, n will eventually become 1.

Your task is to find out how many iterations it takes (of halving or tripling-plus-one) to reach 1.

Relevant xkcd :)

Rules:

Shortest code wins.

If a number < 2 is input, or a non-integer, or a non-number, output does not matter.

Test cases

```<code>2  -> 1
16 -> 4
5  -> 5
7  -> 16
</code>```

答:
Jelly, 12 bytes

```<code>×3‘$HḂ?ß0’?‘
</code>```

Try it online!

How it works

```<code>×3‘$HḂ?ß0’?‘  Main link. Argument: n (integer)

     Ḃ?       Yield the last bit of n is 1:
   $            Evaluate the three links to the left as a monadic chain:
×3                Multiply n by 3.
  ‘               Increment the product by 1.
    H           Else, halve n.
         ’?   If n-1 is non-zero:
       ß        Recursively call the main link.
        0     Else, yield 0.
           ‘  Increment the result by 1.
</code>```

Title: Collatz Conjecture (OEIS A006577)

Body:
Jelly, 12 bytes

×3‘$HḂ?ß0’?‘

Try it online!

How it works

×3‘$HḂ?ß0’?‘  Main link. Argument: n (integer)

     Ḃ?       Yield the last bit of n is 1:
   $            Evaluate the three links to the left as a monadic chain:
×3                Multiply n by 3.
  ‘               Increment the product by 1.
    H           Else, halve n.
         ’?   If n-1 is non-zero:
       ß        Recursively call the main link.
        0     Else, yield 0.
           ‘  Increment the result by 1.


问:
Numbers with Rotational Symmetry
Given an integer, output a truthy value if it is the same upside-down (rotated 180°) or a falsy value otherwise.

0, 1, and 8 have rotational symmetry. 6 becomes 9 and vice versa.

Sequence of numbers producing truthy results: OEIS A000787

```<code>0, 1, 8, 11, 69, 88, 96, 101, 111, 181, 609, 619, 689, 808, 818, 888, 906, 916, 986, 1001, 1111, 1691, 1881, 1961, 6009, 6119, 6699, 6889, 6969, 8008, 8118, 8698, 8888, 8968, 9006, 9116, 9696, 9886, 9966, 10001, 10101, 10801, 11011, 11111, 11811, 16091, ...
</code>```

This question is inspired by my own reputation at the time of posting: 6009.

答:
TSQL, 122 bytes

I am new to code golf, so not quite sure how to count the characters. Counting it as 1 here since the number used in this case is 8

This will return 1 when the reversed value match and nothing when it doesn't match:

```<code>SELECT 1FROM(values(8))x(x)WHERE(x)NOT like'%[23457]%'and REPLACE(REPLACE(x,6,4),9,6)=REVERSE(REPLACE(REPLACE(x,9,4),9,6))
</code>```

Human readable:

```<code>SELECT 1
FROM
  (values(808))x(x)
WHERE(x)
  NOT like'%[23457]%'
  and REPLACE(REPLACE(x,6,4),9,6)=REVERSE(REPLACE(REPLACE(x,9,4),9,6))
</code>```

Title: Numbers with Rotational Symmetry

Body:
TSQL, 122 bytes

I am new to code golf, so not quite sure how to count the characters. Counting it as 1 here since the number used in this case is 8

This will return 1 when the reversed value match and nothing when it doesn't match:

SELECT 1FROM(values(8))x(x)WHERE(x)NOT like'%[23457]%'and REPLACE(REPLACE(x,6,4),9,6)=REVERSE(REPLACE(REPLACE(x,9,4),9,6))

Human readable:

SELECT 1
FROM
  (values(808))x(x)
WHERE(x)
  NOT like'%[23457]%'
  and REPLACE(REPLACE(x,6,4),9,6)=REVERSE(REPLACE(REPLACE(x,9,4),9,6))


答:
Oracle SQL 11.2, 122 bytes

WITH v(n,i)AS(SELECT:1,0 FROM DUAL UNION ALL SELECT DECODE(MOD(n,2),0,n/2,n*3+1),i+1 FROM v WHERE n>1)SELECT MAX(i)FROM v;
```
<p>Un-golfed :</p>
<pre class="lang-sql prettyprint-override"><code>WITH v(n,i)AS   -- Recursive view, n=>current value, i=>iterations count
(
  SELECT :1,0 FROM DUAL -- Initialize with parameter and 0 iteration count
  UNION ALL
  SELECT DECODE(MOD(n,2),0,n/2,n*3+1),i+1 -- Compute the next value
  FROM   v WHERE n>1 -- End when it reaches 1
)
SELECT MAX(i)FROM v -- Return only the last iteration count
</code>```

Title: Collatz Conjecture (OEIS A006577)

Body:
This is the Collatz Conjecture (OEIS A006577):

Start with an integer n > 1.

Repeat the following steps:

If n is even, divide it by 2.

If n is odd, multiply it by 3 and add 1.

It is proven that for all positive integers up to 5 * 260, or about 5764000000000000000, n will eventually become 1.

Your task is to find out how many iterations it takes (of halving or tripling-plus-one) to reach 1.

Relevant xkcd :)

Rules:

Shortest code wins.

If a number < 2 is input, or a non-integer, or a non-number, output does not matter.

Test cases

```<code>2  -> 1
16 -> 4
5  -> 5
7  -> 16
</code>```

Body:
Oracle SQL 11.2, 122 bytes

WITH v(n,i)AS(SELECT:1,0 FROM DUAL UNION ALL SELECT DECODE(MOD(n,2),0,n/2,n*3+1),i+1 FROM v WHERE n>1)SELECT MAX(i)FROM v;

Un-golfed :

WITH v(n,i)AS   -- Recursive view, n=>current value, i=>iterations count
(
  SELECT :1,0 FROM DUAL -- Initialize with parameter and 0 iteration count
  UNION ALL
  SELECT DECODE(MOD(n,2),0,n/2,n*3+1),i+1 -- Compute the next value
  FROM   v WHERE n>1 -- End when it reaches 1
)
SELECT MAX(i)FROM v -- Return only the last iteration count


问:
Find the program that prints this integer sequence (Cops' thread)
This is the cops' thread. The robbers' thread goes here.

The last cops-and-robbers thread was already 4 months ago.

The cop's task

The cop's task is to write a program/function that takes a positive (or non-negative) integer and outputs/returns another integer.

The cop must state it if the program is intolerant towards zero.

The cop will provide at least 2 sample inputs/outputs.

For example, if I have decided to write the Fibonacci sequence, I would write this in my answer:

```
a(0) returns 0
a(3) returns 2
```

The number of examples is up to the cop's discretion.

However, the sequence must actually exist in the On-Line Encyclopedia of Integer Sequences®, so no pseudo-random number generator for you. :(

The cop can hide as many characters as is so wished.

For example, if my program is:

```<code>function a(n)
    if n>2 then
        return n
    else
        return a(n-1) + a(n-2)
    end
end
</code>```

Then I would hide these characters as I want:

```<code>function a(n)
    if ### then
        ########
    else
        ######################
    end
end
</code>```

The robber's task

is obviously to find the original source code.

However, any proposed source code that produces the same set of output also counts as valid, as long as it is also found in OEIS.

Tips for the cops

<s>The search function in the OEIS only works for consecutive terms, so if you want to hide your sequence, then just leave a hole anywhere.</s>

Apparently there is no way to hide the sequence. Put this in mind when you choose the sequence.

Your score is the number of bytes in your code.

The winner will be the submission with the lowest score that hasn't been cracked in 7 days.

Only submissions that are posted in 2016 April are eligible for the win. Submissions that are posted later than this are welcome, but cannot win.

In order to claim the win you need to reveal the full code and the OEIS sequence (after 7 days).

Your post should be formatted like this (NN is the number of characters):

Lua, 98 bytes

Output:

```<code>a(0) returns 0
a(3) returns 2
</code>```

Code (# marks unrevealed characters):

```<code>function a(n)
    if ### then
        ########
    else
        ######################
    end
end
</code>```

If the code is cracked, insert [Cracked](link to cracker) in the header.
If the submission is safe, insert "Safe" in the header and reveal the full code in your answer. Only answers that have revealed the full code will be eligible for the win.

答:
05AB1E, 4 bytes, cracked

Outputs:

```<code>a(0) = 1
a(2) = 4
a(10) = 4444
</code>```

Code:

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

_ indicates an obfuscated character. Try it online!.

Body:
05AB1E, 4 bytes, cracked

Outputs:

a(0) = 1
a(2) = 4
a(10) = 4444

Code:

____

_ indicates an obfuscated character. Try it online!.


答:
Mathcad, 36 "bytes"

From user perspective, Mathcad is effectively a 2D whiteboard, with expressions evaluated from left-to-right,top-to-bottom. Mathcad does not support a conventional "text" input, but instead makes use of a combination of text and special keys / toolbar / menu items to insert an expression, text, plot or component.   For example, type ":" to enter the definition operator (shown on screen as ":=") or "ctl-]" to enter the while loop operator (inclusive of placeholders for the controlling condition and one body expression).  What you see in the image above is exactly what appears on the user interface and as "typed" in.

For golfing purposes, the "byte" count is the equivalent number of keyboard operations required to enter an expression.

Title: Collatz Conjecture (OEIS A006577)


问:
Choose The Powerball Numbers!
Powerball is an American lottery that has recently gained attention because the current jackpot (as of January 11, 2016) is the largest lotto prize in history, at about $1.5 billion (USD).

Powerball players choose 5 distinct numbers from 69 numbered white balls, and 1 one "Powerball" number from 26 numbered red balls. They win the jackpot if their five white ball choices match what was drawn in any order, and if they chose the correct "Powerball" number.

So the chances of winning the jackpot are 1 in (69 choose 5)*(26 choose 1) or ((69*68*67*66*65)/(5*4*3*2*1))*26, which is 1 in 292,201,338

No one won the jackpot in the most recent drawing on January 9, 2016, but perhaps someone will win the next drawing on January 13, 2016, 10:59 pm ET.

Challenge

Write a program or function that simulates a Powerball drawing, taking no input but outputting 5 distinct random numbers from 1 to 69 inclusive, and then one random "Powerball" number from 1 to 26 inclusive (which could be a repeat of one of the 5 initial numbers).

The "Powerball" number should always be the last number in the output, but otherwise the order of the first 5 numbers does not matter.

The 6 numbers should be output in decimal, either space separated or newline separated, with an optional single trailing newline. Commas, brackets, and other characters are not allowed in the output.

So these would be  valid outputs (using the numbers from the last drawing):

```<code>32 16 19 57 34 13</code>```
```<code>32
16
19
57
34
13</code>```

All 292201338 possible outcomes should be possible with uniform probability. You may use built-in pseudo-random number generators and assume they meet this standard.

Here is an ungolfed reference implementation that works in Python 2 or 3:

import random
print(' '.join(map(str, random.sample(range(1,70), 5) + [random.randint(1, 26)])))
```

The shortest code in bytes wins.

Note that I have no affiliation with Powerball and don't really suggest that you play. But if you win anything from numbers generated by one of the programs here, I'm sure we'd love to hear about it. :D

答:
C++, 252 bytes

Golfed:

#include<iostream>
#include <random>

int main(){std::random_device rd;std::mt19937 gen(rd());std::uniform_int_distribution<> dis(1,69);for(int c=0;c<=5;c++){std::cout<<dis(gen)<<" ";}int x=dis(gen);while(x>26||x<1){x=dis(gen);}std::cout<<x;return 0;}
```

<h3>Ungolfed:</h3>

<pre class="lang-cpp prettyprint-override"><code>#include<iostream>
#include <random>

int main()
{
    std::random_device rd;
    std::mt19937 gen(rd());
    std::uniform_int_distribution<> dis(1, 69);
    for(int c = 0; c <= 5; c++){
        std::cout<<dis(gen)<<" ";
    }
    int x = dis(gen);
    while (x > 26 || x < 1){
        x = dis(gen);
    }
    std::cout<<x;
    return 0;
}
</code>```

Title: Choose The Powerball Numbers!

Body:
C++, 252 bytes

Golfed:

#include<iostream>
#include <random>

int main(){std::random_device rd;std::mt19937 gen(rd());std::uniform_int_distribution<> dis(1,69);for(int c=0;c<=5;c++){std::cout<<dis(gen)<<" ";}int x=dis(gen);while(x>26||x<1){x=dis(gen);}std::cout<<x;return 0;}

Ungolfed:

#include<iostream>
#include <random>

int main()
{
    std::random_device rd;
    std::mt19937 gen(rd());
    std::uniform_int_distribution<> dis(1, 69);
    for(int c = 0; c <= 5; c++){
        std::cout<<dis(gen)<<" ";
    }
    int x = dis(gen);
    while (x > 26 || x < 1){
        x = dis(gen);
    }
    std::cout<<x;
    return 0;
}


答:
PHP, 143 bytes

Golfed

```<code><?$t=count($n=explode(' ',preg_replace('/[^\s\w]/','',$argv[1])))-3;echo"$n[0] {$n[1]}[$t];";for($i=2;$t>$j=++$i-3;)echo$n[1]."[$j] = $n[$i];";
</code>```

Ungolfed

```<code><?
$t = count(                                  // Get the number of elements for our array...
    $n = explode(' ',                            // After split the input on whitespace...
    preg_replace('/[^\s\w]/','',$argv[1])))-3;  // After removing all special characters.
echo "$n[0] {$n[1]}[$t];";                     // First line is type, name, and count.
for($i=2;                                        // Loop through array elements
    $t > $j = ++$i-3;)                         // Assign j to be the actual index for our new array
    echo $n[1]."[$j] = $n[$i];";                // Print each line
</code>```

Input is taken through command line argument. Sample:

```<code>C:\(filepath)>php Expand.php "int foo[] = {4,8,15,16,23,42};"
</code>```

Output:

```<code>int foo[6];foo[0] = 4;foo[1] = 8;foo[2] = 15;foo[3] = 16;foo[4] = 23;foo[5] = 42;
</code>```

Title: Expand a C array

Body:
In the C programming language, arrays are defined like this:

```<code>int foo[] = {4, 8, 15, 16, 23, 42};      //Foo implicitly has a size of 6
</code>```

The size of the array is inferred from the initializing elements, which in this case is 6. You can also write a C array this way, explicitly sizing it then defining each element in order:

```<code>int foo[6];        //Give the array an explicit size of 6
foo[0] = 4;
foo[1] = 8;
foo[2] = 15;
foo[3] = 16;
foo[4] = 23;
foo[5] = 42;
</code>```

The challenge

You must write a program or function that expands arrays from the first way to the second. Since you are writing a program to make code longer, and you love irony, you must make your code as short as possible.

The input will be a string representing the original array, and the output will be the expanded array-definition. You can safely assume that the input will always look like this:

```<code><type> <array_name>[] = {<int>, <int>, <int> ... };
</code>```

"Type" and "array_name" will made up entirely of alphabet characters and underscores _. The elements of the list will always be a number in the range -2,147,483,648 to 2,147,483,647. Inputs in any other format do not need to be handled.

The whitespace in your output must exactly match the whitespace in the test output, although a trailing newline is allowed.

Test IO:

```<code>#in
short array[] = {4, 3, 2, 1};

#out
short array[4];
array[0] = 4;
array[1] = 3;
array[2] = 2;
array[3] = 1;

#in
spam EGGS[] = {42};

#out
spam EGGS[1];
EGGS[0] = 42;

#in
terrible_long_type_name awful_array_name[] = {7, -8, 1337, 0, 13};

#out
terrible_long_type_name awful_array_name[5];
awful_array_name[0] = 7;
awful_array_name[1] = -8;
awful_array_name[2] = 1337;
awful_array_name[3] = 0;
awful_array_name[4] = 13;
</code>```

Submissions in any language are encouraged, but bonus points if you can do it in C.

Leaderboard:

Here is a leaderboard showing the top answers:

var QUESTION_ID=77857,OVERRIDE_USER=31716;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:
PHP, 143 bytes

Golfed

<?$t=count($n=explode(' ',preg_replace('/[^\s\w]/','',$argv[1])))-3;echo"$n[0] {$n[1]}[$t];";for($i=2;$t>$j=++$i-3;)echo$n[1]."[$j] = $n[$i];";

Ungolfed

<?
$t = count(                                  // Get the number of elements for our array...
    $n = explode(' ',                            // After split the input on whitespace...
    preg_replace('/[^\s\w]/','',$argv[1])))-3;  // After removing all special characters.
echo "$n[0] {$n[1]}[$t];";                     // First line is type, name, and count.
for($i=2;                                        // Loop through array elements
    $t > $j = ++$i-3;)                         // Assign j to be the actual index for our new array
    echo $n[1]."[$j] = $n[$i];";                // Print each line

Input is taken through command line argument. Sample:

C:\(filepath)>php Expand.php "int foo[] = {4,8,15,16,23,42};"

Output:

int foo[6];foo[0] = 4;foo[1] = 8;foo[2] = 15;foo[3] = 16;foo[4] = 23;foo[5] = 42;


答:
TSQL, <s>107</s> <s>105</s> 97 bytes

```<code>DECLARE @ INT=3,@y INT=5

PRINT REPLICATE(1,@)+ISNULL('
'+REPLICATE('1'+ISNULL(SPACE(@-2),'')+'1
',@y-2)+REPLICATE(1,@),'')
</code>```

generating first line

adding hollow lines + line breaks

adding last line(when needed)

Title: Form tiles in a rectangular ring

Body:
Given the input tilesX and tilesY create a method that would make a rectangular ring from the tiles.

The function must order the tiles in a ring like this:

tilesX and tilesY are always positive integer values, cannot be 0

tilesX and tilesY are not always equal, expect values like: 2x5, 6x3 etc.

Checking for invalid input is not necessary

You can use any way to display the tiles, including 2d arrays, ASCII art or printed text.

There's no strict way how the input is passed as long as it's two integers.

Cannot be a line, drawing a rectangle size of tilesX and tilesY pixels is not valid

The shortest code wins

Body:
TSQL, <s>107</s> <s>105</s> 97 bytes

DECLARE @ INT=3,@y INT=5

PRINT REPLICATE(1,@)+ISNULL('
'+REPLICATE('1'+ISNULL(SPACE(@-2),'')+'1
',@y-2)+REPLICATE(1,@),'')

generating first line

adding hollow lines + line breaks

adding last line(when needed)


问:
Identify the Conic Section
Given 5 distinct points on a two-dimensional plane, determine the type of conic section formed by the points. The output shall be one of circle, hyperbola, ellipse, or parabola.

Rules

The points will be in general linear position, meaning that no three points are collinear, and thus the conic passing through them will be unique.

The coordinates of the 5 points will be decimal numbers between -10 and 10, inclusive.

The precision for the decimal/float values should be the precision of your language's native float/decimal type. If your language/data type is arbitrary-precision, you may use 12 digits after the decimal point as the maximum required precision, rounding toward zero (e.g. 1.0000000000005 == 1.000000000000).

Capitalization of the output does not matter.

Outputting ellipse when the conic section is actually a circle is not allowed. All circles are ellipses, but you must output the most specific one.

On floating point inaccuracies and precision:

I'm trying to make this as simple as possible, so that issues with floating point inaccuracies don't get in the way. The goal is, if the data type was "magical infinite precision value" instead of float/double, then everything would work perfectly. But, since "magical infinite precision value" doesn't exist, you write code that assumes that your values are infinite precision, and any issues that crop up as a result of floating point inaccuracies are features, not bugs.

Test Cases

```<code>(0, 0), (1, 5), (2, 3), (4, 8), (9, 2) => hyperbola
(1.2, 5.3), (4.1, 5.6), (9.1, 2.5), (0, 1), (4.2, 0) => ellipse
(5, 0), (4, 3), (3, 4), (0, 5), (0, -5) => circle
(1, 0), (0, 1), (2, 1), (3, 4), (4, 9) => parabola
</code>```

答:
C, 500

My JavaScript answer ported to C. Just to see if it can be done.

Usage: read 10 values from standard input

echo 1 0 0 1 2 1 3 4 4 9 | conic

Output:

Parabola

Test (ideone)

double D(m,k)double*m;{double t=0;for(int s=1,b=1,x=0;x<6;x++,b+=b)k&b||(t+=s*m[x]*(k+b>62?1:D(m+6,k+b)),s=-s);return t;}i,u,h;double m[36],*t=m+6,w[6],s[3],b,d;main(){for(;i++<5;*t++=d*d,*t++=d*b,*t++=b*b,*t++=d,*t++=b,*t++=1)scanf("%lf%lf",&d,&b);for(u=4;u;u/=2)for(m[0]=u&1,m[1]=u&2,m[2]=u&4,d=D(m,0),h=0;d&&h<3;h++){for(i=0;i<6;i++)w[i]=m[i*6+h],m[i*6+h]=i?0:u;s[h]=D(m,0)/d;for(;i--;)m[i*6+h]=w[i];}b=s[1];d=b*b-4*s[0]*s[2];puts(d?d<0?!b&(s[2]==s[0])?"Circle":"Ellipse":"Hyperbola":"Parabola");}
```
<p><strong>Less golfed</strong></p>
<pre class="lang-c prettyprint-override"><code>// Calc determinant of a matrix of side d
// In the golfed code, d is fix to 6
double D(m, d, k)
double*m;
{
    int s = 1, b = 1, x = 0;
    double t = 0;
    for (; x < d; x++, b += b)
        k&b || (
            t += s*m[x] *(k+b+1==1<<d? 1: D(  m + d, d, k + b)), s = -s
        );
    return t;
}

double m[36],d, *t = m + 6, w[6], s[3], a, b, c;
i,u,h;
main()
{
    for (; i++ < 5; )
    {
        scanf("%lf%lf", &a, &b);
        *t++ = a*a, *t++ = a*b, *t++ = b*b, *t++ = a, *t++ = b, *t++ = 1;
    }
    for (u = 4; u; u /= 2)
    {
        m[0] = u & 1, m[1] = u & 2, m[2] = u & 4;
        d = D(m, 6, 0);
        if (d)
            for (h = 0; h < 3; h++)
            {
                for (i = 0; i < 6; i++)
                    w[i] = m[i * 6 + h],
                    m[i * 6 + h] = i ? 0 : u;
                s[h] = D(m, 6, 0)/d;
                for (; i--; )
                    m[i * 6 + h] = w[i];
            }
    }
    a = s[0], b = s[1], c = s[2];
    d = b*b - 4 * a * c;
    puts(d ? d < 0 ? !b&(c == a) ? "Circle" : "Ellipse" : "Hyperbola" : "Parabola");
}
</code>```

Title: Identify the Conic Section

Body:
C, 500

My JavaScript answer ported to C. Just to see if it can be done.

Usage: read 10 values from standard input

echo 1 0 0 1 2 1 3 4 4 9 | conic

Output:

Parabola

Test (ideone)

double D(m,k)double*m;{double t=0;for(int s=1,b=1,x=0;x<6;x++,b+=b)k&b||(t+=s*m[x]*(k+b>62?1:D(m+6,k+b)),s=-s);return t;}i,u,h;double m[36],*t=m+6,w[6],s[3],b,d;main(){for(;i++<5;*t++=d*d,*t++=d*b,*t++=b*b,*t++=d,*t++=b,*t++=1)scanf("%lf%lf",&d,&b);for(u=4;u;u/=2)for(m[0]=u&1,m[1]=u&2,m[2]=u&4,d=D(m,0),h=0;d&&h<3;h++){for(i=0;i<6;i++)w[i]=m[i*6+h],m[i*6+h]=i?0:u;s[h]=D(m,0)/d;for(;i--;)m[i*6+h]=w[i];}b=s[1];d=b*b-4*s[0]*s[2];puts(d?d<0?!b&(s[2]==s[0])?"Circle":"Ellipse":"Hyperbola":"Parabola");}

Less golfed

// Calc determinant of a matrix of side d
// In the golfed code, d is fix to 6
double D(m, d, k)
double*m;
{
    int s = 1, b = 1, x = 0;
    double t = 0;
    for (; x < d; x++, b += b)
        k&b || (
            t += s*m[x] *(k+b+1==1<<d? 1: D(  m + d, d, k + b)), s = -s
        );
    return t;
}

double m[36],d, *t = m + 6, w[6], s[3], a, b, c;
i,u,h;
main()
{
    for (; i++ < 5; )
    {
        scanf("%lf%lf", &a, &b);
        *t++ = a*a, *t++ = a*b, *t++ = b*b, *t++ = a, *t++ = b, *t++ = 1;
    }
    for (u = 4; u; u /= 2)
    {
        m[0] = u & 1, m[1] = u & 2, m[2] = u & 4;
        d = D(m, 6, 0);
        if (d)
            for (h = 0; h < 3; h++)
            {
                for (i = 0; i < 6; i++)
                    w[i] = m[i * 6 + h],
                    m[i * 6 + h] = i ? 0 : u;
                s[h] = D(m, 6, 0)/d;
                for (; i--; )
                    m[i * 6 + h] = w[i];
            }
    }
    a = s[0], b = s[1], c = s[2];
    d = b*b - 4 * a * c;
    puts(d ? d < 0 ? !b&(c == a) ? "Circle" : "Ellipse" : "Hyperbola" : "Parabola");
}


答:
TSQL, <s>112</s> 104 bytes

```<code>DECLARE @ varchar(10)='12'

PRINT REPLICATE(@,@)+ISNULL('
'+REPLICATE(@+ISNULL(SPACE((@-2)*len(@))+@,'')+'
',@-2)+REPLICATE(@,@),'')
</code>```

```<code>1. generating first line
2. adding hollow lines + line breaks
3. adding last line(when needed)
</code>```

Title: Print N Squared

Body:
Write a program or function that takes in a non-negative integer N from stdin or as a function argument. It must print or return a string of a hollow ASCII-art square whose sides are each made with N copies of the number N.

Specifically:

If N is 0, no copies of N are used, so there should be no output (or only a single trailing newline).

If N is 1, the output is:

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

If N is 2:

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

If N is 3:

```<code>333
3 3
333
</code>```

If N is 4:

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

If N is 5:

```<code>55555
5   5
5   5
5   5
55555
</code>```

The pattern continues for 6 through 9.

If N is 10, the output is:

```<code>10101010101010101010
10                10
10                10
10                10
10                10
10                10
10                10
10                10
10                10
10101010101010101010
</code>```

Notice that this is not actually square. It is 10 rows tall but 20 columns wide because 10 is two characters long. This is intended. The point is that each side of the "square" contains N copies of N. So all inputs beyond 9 will technically be ASCII rectangles.

For example, if N is 23, the output is:

```<code>2323232323232323232323232323232323232323232323
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
23                                          23
2323232323232323232323232323232323232323232323</code>```

Here are Pastebins of the required outputs for 99, 100, 111, and 123 (they may look wrong in a browser but in a text editor they'll look correct). The output for 1000 is to large for Pastebin but it would have 1000 rows and 4000 columns. Numbers with 4 or more digits must work just like smaller numbers.

Details:

N must be written in the usual decimal number representation, with no + sign or other non-digits.

The hollow area must only be filled with spaces.

No lines should have leading or trailing spaces.

A single newline after the squares' last line is optionally allowed.

Languages written after this challenge was made are welcome, they just aren't eligible to win.

The shortest code in bytes wins!

Body:
TSQL, <s>112</s> 104 bytes

DECLARE @ varchar(10)='12'

PRINT REPLICATE(@,@)+ISNULL('
'+REPLICATE(@+ISNULL(SPACE((@-2)*len(@))+@,'')+'
',@-2)+REPLICATE(@,@),'')

1. generating first line
2. adding hollow lines + line breaks
3. adding last line(when needed)


答:
Visual Basic for Applications, <s>150</s> 111 bytes

Usable in console or as an UDF.

```<code>Function c(b)
c=(Not b Like"*[!01869]*")And b=Replace(Replace(Replace(StrReverse(b),9,7),6,9),7,6)
End Function
</code>```

Improved by taking advantage of implicit type conversions and by doing three steps swapping instead of two steps on each side of the equation. Count includes Function and End Function statements.

Title: Numbers with Rotational Symmetry

Body:
Given an integer, output a truthy value if it is the same upside-down (rotated 180°) or a falsy value otherwise.

0, 1, and 8 have rotational symmetry. 6 becomes 9 and vice versa.

Sequence of numbers producing truthy results: OEIS A000787

```<code>0, 1, 8, 11, 69, 88, 96, 101, 111, 181, 609, 619, 689, 808, 818, 888, 906, 916, 986, 1001, 1111, 1691, 1881, 1961, 6009, 6119, 6699, 6889, 6969, 8008, 8118, 8698, 8888, 8968, 9006, 9116, 9696, 9886, 9966, 10001, 10101, 10801, 11011, 11111, 11811, 16091, ...
</code>```

This question is inspired by my own reputation at the time of posting: 6009.

Body:
Visual Basic for Applications, <s>150</s> 111 bytes

Usable in console or as an UDF.

Function c(b)
c=(Not b Like"*[!01869]*")And b=Replace(Replace(Replace(StrReverse(b),9,7),6,9),7,6)
End Function

Improved by taking advantage of implicit type conversions and by doing three steps swapping instead of two steps on each side of the equation. Count includes Function and End Function statements.


答:
Mathcad, 54 "bytes"

From user perspective, Mathcad is effectively a 2D whiteboard, with expressions evaluated from left-to-right,top-to-bottom. Mathcad does not support a conventional "text" input, but instead makes use of a combination of text and special keys / toolbar / menu items to insert an expression, text, plot or component. For example, type ":" to enter the definition operator (shown on screen as ":=") or "ctl-shft-#" to enter the for loop operator (inclusive of placeholders for the iteration variable, iteration values and one body expression). What you see in the image above is exactly what appears on the user interface and as "typed" in.

For golfing purposes, the "byte" count is the equivalent number of keyboard operations required to enter an expression.

Title: Generate Recamán's sequence

Body:
Recamán's sequence (A005132) is a mathematical sequence, defined as such:

```<code>A(0) = 0
A(n) = A(n-1) - n if A(n-1) - n > 0 and is new, else
A(n) = A(n-1) + n
</code>```

A pretty LaTex version of the above (might be more readable):

$$A(n) = \begin{cases}0 & \textrm{if } n = 0 \\
A(n-1) - n & \textrm{if } A(n-1) - n \textrm{ is positive and not already in the sequence} \\
% Seems more readable than
%A(n-1) - n & \textrm{if } A(n-1) > n \wedge \not\exists m < n: A(m) = A(n-1)-n \\
A(n-1) + n & \textrm{otherwise}
\end{cases}$$

The first few terms are 0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11

To clarify, is new means whether the number is already in the sequence.

Given an integer n, via function argument or STDIN, return the first n terms of the Recamán sequence.

This is a code-golf challenge, so shortest code wins.


答:
Julia 0.6, <s>29</s> 27 bytes

!n=n>1&&1+!(n%2>0?3n+1:n/2)
```

I can't seem to compile Julia 0.1 on my machine, so there's a chance this is non-competing.

Try it online!

Title: Collatz Conjecture (OEIS A006577)

Body:
Julia 0.6, <s>29</s> 27 bytes

!n=n>1&&1+!(n%2>0?3n+1:n/2)

I can't seem to compile Julia 0.1 on my machine, so there's a chance this is non-competing.

Try it online!


问:
In-between fractions

In-between fractions

The challenge:

You will need to create code that takes atleast 3 inputs; 2 integers and "a fraction representation" - whichever type suits your language for representing the fraction increments) ie. If you choose string the input would be "1/4" or you could choose 2 extra integer inputs or a tuple or w/e.

Input can be anywhere reasonable (STDIN, function arguments, from a file, etc.), and so can output (STDOUT, function return value, to a file, etc.)

Rules:

The input "fraction" will always be a valid fraction, less than 1; example "1/4"

The second input integer will always have a higher value than the first integer. I.E the first input integer will always have a lower value than the second.

The input integers can be negative.

Outputted fractions should be reduced as much as possible (simplified)

The code will need to output every "fraction step" between the 2 numbers in increments of the input fraction.

The code should be a program or function as stated here

Example 1:

Input: -2,3,"1/2"

Output:

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

Example 2:

Input: 1,2,"2/3"

Output:

```<code>1
5/3
2
</code>```

or

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

Note: Counting can start from either direction (thank you @Mego)

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

答:
R - 71 bytes

Assumes you have already installed the MASS package

```<code>f=function(x,y,z)MASS::fractions(union(seq(x,y,eval(parse(text=z))),y))

> f(1, 2, '1/3')
[1]   1 4/3 5/3   2
> f(2, 5, '1/2')
[1]   2 5/2   3 7/2   4 9/2   5
</code>```

Title: In-between fractions

Body:
R - 71 bytes

Assumes you have already installed the MASS package

f=function(x,y,z)MASS::fractions(union(seq(x,y,eval(parse(text=z))),y))

> f(1, 2, '1/3')
[1]   1 4/3 5/3   2
> f(2, 5, '1/2')
[1]   2 5/2   3 7/2   4 9/2   5


问:
A Numpad's Knight Numbers
For the non-zero digits on a standard numpad

```<code>789
456
123
</code>```

consider placing a chess knight at any digit and moving it around with any number of normal L-shaped jumps, tracing out a positive decimal integer. What positive integers can be expressed in such a way?

One of them is 38, since the knight could start on the 3 and move left and up to the 8. 381 and 383 are also possible.

3 itself is possible if no jumps are taken (which is allowed). 5 is as well, but no other digits can be reached from the 5, so it is the only number where the digit 5 appears.

Write a program or function that takes in a positive decimal integer (you may take it as a string if desired) and prints or returns a truthy value if the number can be expressed by a knight on a numpad in the way described, but otherwise outputs a falsy value.

The shortest code in bytes wins. Tiebreaker is earlier answer

Examples

Truthy:

```<code>1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 18, 38, 61, 81, 294, 349, 381, 383, 729, 767, 38183, 38383, 18349276, 183492761, 618349276
</code>```

Falsy:

```<code>10, 11, 50, 53, 55, 65, 95, 100, 180, 182, 184, 185, 186, 187, 188, 189, 209, 305, 2009, 5030, 3838384, 4838383, 183492760
</code>```

答:
Retina, <s>58</s> 40 bytes

Thanks to Sp3000 for suggesting this idea:

```<code>M&!`..
O%`.
A`16|18|27|29|34|38|49|67
^$
</code>```

Try it online! (Slightly modified to run the entire test suite at once.)

Prints 1 for truthy and 0 for falsy results.

Explanation

```<code>M&!`..
</code>```

Find all overlapping matches of .., i.e. all consecutive pairs of digits, and join them with linefeeds.

```<code>O%`.
</code>```

Sort the digits in each line, so that we only need to check half as many pairs.

```<code>A`16|18|27|29|34|38|49|67
</code>```

Remove all lines which correspond to a valid move.

```<code>^$
</code>```

Count the matches of this regex. That is, if all lines were removed, this matches the resulting empty string once, otherwise it fails to match and gives zero instead.

Title: A Numpad's Knight Numbers

Body:
Retina, <s>58</s> 40 bytes

Thanks to Sp3000 for suggesting this idea:

M&!`..
O%`.
A`16|18|27|29|34|38|49|67
^$

Try it online! (Slightly modified to run the entire test suite at once.)

Prints 1 for truthy and 0 for falsy results.

Explanation

M&!`..

Find all overlapping matches of .., i.e. all consecutive pairs of digits, and join them with linefeeds.

O%`.

Sort the digits in each line, so that we only need to check half as many pairs.

A`16|18|27|29|34|38|49|67

Remove all lines which correspond to a valid move.

^$

Count the matches of this regex. That is, if all lines were removed, this matches the resulting empty string once, otherwise it fails to match and gives zero instead.


问:
Enumerate all palindromic numbers (in decimal) between 0 and n
Given a non-negative integer n, enumerate all palindromic numbers (in decimal) between 0 and n (inclusive range). A palindromic number remains the same when its digits are reversed.

The first palindromic numbers (in base 10) are given here:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 101,
  111, 121, 131, 141, 151, 161, 171, 181, 191, 202, 212, 222, 232, 242,
  252, 262, 272, 282, 292, 303, 313, 323, 333, 343, 353, 363, 373, 383,
  393, 404, 414, 424, 434, 444, 454, 464, 474, 484, 494, 505, 515, ...

This is a code golf with the prize going to fewest characters. The palindromic numbers should be output one per line to stdout. The program should read n from the commandline or stdin.

答:
Pyke, 6 bytes

```<code>S#`D_q
</code>```

Explanation:

```<code>S      - range(1, input()+1)
 #     - filter where True
  `D_q -  str(num) == str(num)[::-1]
</code>```

Try it here!

Body:
Pyke, 6 bytes

S#`D_q

Explanation:

S      - range(1, input()+1)
 #     - filter where True
  `D_q -  str(num) == str(num)[::-1]

Try it here!


答:
MATL, <s>38</s> <s>37</s> 29 bytes

This uses @QPaysTaxes idea.

```<code>I:8JK5:7Pvj!Uttnqh?)d|2:EQm}h
</code>```

The output is a 2D, complex, non-empty array. It is truthy if all its values have nonzero real part, and falsy otherwise.

Try it online!

Title: A Numpad's Knight Numbers

Body:
For the non-zero digits on a standard numpad

```<code>789
456
123
</code>```

consider placing a chess knight at any digit and moving it around with any number of normal L-shaped jumps, tracing out a positive decimal integer. What positive integers can be expressed in such a way?

One of them is 38, since the knight could start on the 3 and move left and up to the 8. 381 and 383 are also possible.

3 itself is possible if no jumps are taken (which is allowed). 5 is as well, but no other digits can be reached from the 5, so it is the only number where the digit 5 appears.

Write a program or function that takes in a positive decimal integer (you may take it as a string if desired) and prints or returns a truthy value if the number can be expressed by a knight on a numpad in the way described, but otherwise outputs a falsy value.

The shortest code in bytes wins. Tiebreaker is earlier answer

Examples

Truthy:

```<code>1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 18, 38, 61, 81, 294, 349, 381, 383, 729, 767, 38183, 38383, 18349276, 183492761, 618349276
</code>```

Falsy:

```<code>10, 11, 50, 53, 55, 65, 95, 100, 180, 182, 184, 185, 186, 187, 188, 189, 209, 305, 2009, 5030, 3838384, 4838383, 183492760
</code>```

Body:
MATL, <s>38</s> <s>37</s> 29 bytes

This uses @QPaysTaxes idea.

I:8JK5:7Pvj!Uttnqh?)d|2:EQm}h

The output is a 2D, complex, non-empty array. It is truthy if all its values have nonzero real part, and falsy otherwise.

Try it online!


问:
Numbers that are actually letters
Given a non-negative integer input, write a program that converts the number to hexadecimal and returns a truthy value if the hexadecimal form of the number contains only the characters A through F and a falsey value otherwise.

Test cases

```<code>10
==> True (A in hexadecimal)

100
==> False (64 in hexadecimal)

161
==> False (A1 in hexadecimal)

11259375
==> True (ABCDEF in hexadecimal)

0
==> False (0 in hexadecimal)
</code>```

Bonus: -40 bytes if your program prints Only letters for the challenge described above, Only numbers if the hexadecimal version of the number only contains the digits 0-9 and Mix if the hexadecimal number contains at least one number and at least one letter.

This is code golf. Standard rules apply. Shortest code in bytes wins. Either functions or full programs are allowed.

答:
Pyke, 6 bytes

```<code>b16G-!
</code>```

Try it here!

Or 10 bytes with the bonus

```<code>b16\9L>]0}DlRs*"Only numbers,Only letters,Mix"\,c@
</code>```

Explanation:

```<code>b16                                                -      base_16(input())
   \9L<                                            -     map("9">char for char in ^)
       ]0                                          -    list(^)
         }                                         -   set(^)
          DlRs*                                    -  len(^)*sum(^)
                                                 @ - V[^]
               "Only numbers,Only letters,Mix"\,c  -  str.split(",")
</code>```

Try it here!

Title: Numbers that are actually letters

Body:
Pyke, 6 bytes

b16G-!

Try it here!

Or 10 bytes with the bonus

b16\9L>]0}DlRs*"Only numbers,Only letters,Mix"\,c@

Explanation:

b16                                                -      base_16(input())
   \9L<                                            -     map("9">char for char in ^)
       ]0                                          -    list(^)
         }                                         -   set(^)
          DlRs*                                    -  len(^)*sum(^)
                                                 @ - V[^]
               "Only numbers,Only letters,Mix"\,c  -  str.split(",")

Try it here!


问:
Can I string all my cords and adapters together?
Suppose one day you are digging through your big box of unused computer cords and adapters (USB to USB mini, VGA to DVI, etc.). There are tangled cords everywhere making quite a mess, and you wonder if you could simplify things by attaching all the cords together in one long strand, and then just rolling it up.

The question is, is it possible to connect all of your cords and adapters in one long line like this? It's obviously not always possible, e.g. if you only had two cords with completely different plugs, they could not be connected together. But if you had a third cord that can connect to both of them, then you could string all your cords together.

You don't care about what type of plugs are on the ends of the all-cord strand. They don't need to plug into one another to form a loop. You only want to know if making the all-cord strand is possible, and if it is, how to do it.

Challenge

Write a program or function that takes in a multiline string where every line depicts one of the cords you own. A cord is made up of one or more dashes (-), with a plug on either end. A plug is always one of the 8 characters ()[]{}<>.

So these are some valid cords:

```<code>>->
(--[
}-{
<-----]
(---)
</code>```

But these are not:

```<code>-->
(--
)--
[{
---
</code>```

When connecting cords, only plugs with the exact same bracket type can be connected together.

So these are some valid cord connections:

```<code>...---((---...
...---))---...
...---]]---...
...---{{---...
...---<<---...
</code>```

And these are invalid:

```<code>...---()---...
...---)(---...
...---{]---...
...---{[---...
...---><---...
...--->)---...
</code>```

If all the cords in the input can be rearranged and attached together in one long strand, then output that strand to stdout on one line (with an optional trailing newline). When there are multiple solutions you can choose any one of them to output. If making a single strand is not possible, then output nothing (or output an empty string with an optional trailing newline).

For example, if the input is

```<code>[-->
{---]
>----{
</code>```

the output could be

```<code>[-->>----{{---]
</code>```

where all the cords are strung together.

However if the input were

```<code>[-->
{---]
</code>```

the cords cannot be connected so there would be no output.

Note that cords can be flipped around as much necessary to make connections. e.g. [--> and <--] are effectively the same cord because they can make the same type of connections. Some outputs may depend on flipping the input cords.

For example

```<code>(-[
}--]
</code>```

could have output

```<code>(-[[--{
</code>```

where the second cord is flipped, or

```<code>}--]]-)
</code>```

where the first cord is flipped.

(Note that in general flipping the entire output is valid because it's the same as initially flipping every cord individually.)

The lengths of the cords in the output should of course match the lengths of the corresponding input cords. But the cords may be reordered and flipped  around as much as you want in order to make the all-cord strand. The input will always contain at least one cord.

The shortest code in bytes wins.

Test Cases

Cases with output:

```<code>[-->
{---]
>----{
gives
[-->>----{{---]
or
[---}}----<<--]

(-[
}--]
gives
(-[[--{
or
}--]]-)

(-)
gives
(-)

[--{
gives
[--{
or
}--]

[-]
]-[
gives
[-]]-[
or
]-[[-]

[----->
)------------[
{--<
}---)
could give
[----->>--}}---))------------[
or
>--}}---))------------[[----->
or
}---))------------[[----->>--}
or
{--<<-----]]------------((---{
etc.

>-->
>->
>--->
could give
>-->>->>--->
or
>--->>-->>->
or
>->>-->>--->
or
<--<<---<<-<
etc.

(-]
]->
>-}
}-)
)-[
[-<
<-{
{-(
could give
(-]]->>-}}-))-[[-<<-{{-(
or
{-((-]]->>-}}-))-[[-<<-{
or
<-{{-((-]]->>-}}-))-[[->
etc.
</code>```

Cases without output:

```<code>[-->
{---]

[-]
[-]

(-]
]->
}-)

>->
>-->
]---]

[-------------------]
]-------------------[
[-----------------]
[-----------------]

{--[
]--}
</code>```

答:
Lua, 477 bytes

```<code>function r(s)return s:reverse():gsub("[()%[%]{}<>]",{["("]=")",[")"]="(",["["]="]",["]"]="[",["{"]="}",["}"]="{",["<"]=">",[">"]="<"})end
function a(c,b)for i, v in next,b do
m=c:sub(-1,-1)n=v:sub(1,1)o=r(c):sub(-1,-1)p=r(v):sub(1,1)l=table.remove(b,i)if m==n then
return a(c..v,b)elseif o==n then
return a(r(c)..v,b)elseif m==p then
return a(c..r(v),b)elseif o==p then
return a(r(c)..r(v),b)end
table.insert(b,i,l)end
return#b>0 and""or c
end
print(a(table.remove(arg,1),arg))
</code>```

Accepts cords as command line arguments

Body:
Lua, 477 bytes

function r(s)return s:reverse():gsub("[()%[%]{}<>]",{["("]=")",[")"]="(",["["]="]",["]"]="[",["{"]="}",["}"]="{",["<"]=">",[">"]="<"})end
function a(c,b)for i, v in next,b do
m=c:sub(-1,-1)n=v:sub(1,1)o=r(c):sub(-1,-1)p=r(v):sub(1,1)l=table.remove(b,i)if m==n then
return a(c..v,b)elseif o==n then
return a(r(c)..v,b)elseif m==p then
return a(c..r(v),b)elseif o==p then
return a(r(c)..r(v),b)end
table.insert(b,i,l)end
return#b>0 and""or c
end
print(a(table.remove(arg,1),arg))

Accepts cords as command line arguments


答:
Pyth - <s>35</s> 28 bytes

```<code>!s.bt/@c`C"_xÖ({Î¶z"2tsNYztz
</code>```

Test Suite.

Title: A Numpad's Knight Numbers

Body:
Pyth - <s>35</s> 28 bytes

!s.bt/@c`C"_xÖ({Î¶z"2tsNYztz

Test Suite.


Title: A Numpad's Knight Numbers

Body:
Ruby, 57 bytes

Anonymous function. Argument is a string.

->n{(0..n.size).count{|i|!"16729438183492761"[n[i,2]]}<1}

Program with the test suite:

f=->n{(0..n.size).count{|i|!"16729438183492761"[n[i,2]]}<1}

a=%w{1 2 3 4 5 6 7 8 9 16 18 38 61 81 294 349 381 383 729 767 38183 38383 18349276 183492761 618349276
10 11 50 53 55 65 95 100 180 182 184 185 186 187 188 189 209 305 2009 5030 3838384 4838383 183492760}

a.each {|e|p [e, f[e]]}

I just encoded all the possible knight moves into a string and checked if every 2 digits within the input existed in that string.


答:
Gogh, 17 bytes

This answer is non-competing, as the language was created after the challenge was posted.

```<code>G{÷÷sR=¦?}m0%{Ƥ}m
</code>```

Usage:

```<code>$ ./gogh i 'G{÷÷sR=¦?}m0%{Ƥ}m' <input>
</code>```

Explanation

```<code>        “ Implicit input.                                      ”
G       “ Push an inclusive list.                              ”
{       “ Open a code block.                                   ”
 ÷÷     “ Push two copies of the TOS.                          ”
 sR=    “ Check if the integer is palindromic.                 ”
 ¦?     “ If n is palindromic, yield n. If not, yield 0.       ”
}m      “ Close the code block and map it to the TOS.          ”
0%      “ Remove non-palindromic integers (denoted by zeroes). ”
{       “ Open a code block.                                   ”
 Ƥ      “ Print.                                               ”
}m      “ Close the code block and map it to the TOS.          ”
        “ Implicit output.                                     ”
</code>```

Title: Enumerate all palindromic numbers (in decimal) between 0 and n

Body:
Given a non-negative integer n, enumerate all palindromic numbers (in decimal) between 0 and n (inclusive range). A palindromic number remains the same when its digits are reversed.

The first palindromic numbers (in base 10) are given here:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 101,
  111, 121, 131, 141, 151, 161, 171, 181, 191, 202, 212, 222, 232, 242,
  252, 262, 272, 282, 292, 303, 313, 323, 333, 343, 353, 363, 373, 383,
  393, 404, 414, 424, 434, 444, 454, 464, 474, 484, 494, 505, 515, ...

This is a code golf with the prize going to fewest characters. The palindromic numbers should be output one per line to stdout. The program should read n from the commandline or stdin.

Body:
Gogh, 17 bytes

This answer is non-competing, as the language was created after the challenge was posted.

G{÷÷sR=¦?}m0%{Ƥ}m

Usage:

$ ./gogh i 'G{÷÷sR=¦?}m0%{Ƥ}m' <input>

Explanation

        “ Implicit input.                                      ”
G       “ Push an inclusive list.                              ”
{       “ Open a code block.                                   ”
 ÷÷     “ Push two copies of the TOS.                          ”
 sR=    “ Check if the integer is palindromic.                 ”
 ¦?     “ If n is palindromic, yield n. If not, yield 0.       ”
}m      “ Close the code block and map it to the TOS.          ”
0%      “ Remove non-palindromic integers (denoted by zeroes). ”
{       “ Open a code block.                                   ”
 Ƥ      “ Print.                                               ”
}m      “ Close the code block and map it to the TOS.          ”
        “ Implicit output.                                     ”


答:
05AB1E, 5 bytes

```<code>ƒNÂQ–
</code>```

Explanation:

```<code>ƒ      # For N in range(0, input() + 1)
 N     #   Push N
  Â    #   Bifurcate (pushes N and N[::-1])
   Q   #   Check for equality
    –  #   If true, pop and print N
</code>```

Uses CP-1252 encoding. Try it online!.

Body:
05AB1E, 5 bytes

ƒNÂQ–

Explanation:

ƒ      # For N in range(0, input() + 1)
 N     #   Push N
  Â    #   Bifurcate (pushes N and N[::-1])
   Q   #   Check for equality
    –  #   If true, pop and print N

Uses CP-1252 encoding. Try it online!.


答:
Visual Basic for Applications, 66 bytes

Callable from the immediate window.

```<code>Sub u(b)
For i=0To b
If StrReverse(i)=i Then Debug.?i
Next
End Sub
</code>```

Body:
Visual Basic for Applications, 66 bytes

Callable from the immediate window.

Sub u(b)
For i=0To b
If StrReverse(i)=i Then Debug.?i
Next
End Sub