Title: Operator ASCII art

Body:
Challenge

Given an ASCII operator from the list below and a number n, draw an ASCII representation of the operator using that operator as the character with the line segments of the operator having length n.

Input

An ASCII character from the list = + - x / and an integer n where n >= 1.  (I'm using x instead of * and / instead of ÷, but you could use either one, whichever is easier). For + and x, you only have to handle odd numbers to avoid issues with alignment.

Output

An ASCII drawing of the operator composed of the character with segments of length n. Horizontal portions should have spaces between the characters to offset vertical/horizontal distance differences.

Rules

This is code-golf, so shortest code in bytes wins. Standard loopholes are forbidden.

Examples

Input: + 3

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

Input: = 4

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

Input: = 10

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

Input: - 2

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

Input: / 10

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

Input: x 7

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

Body:
JavaScript (ES6), <s>238</s> <s>225</s> <s>215</s> <s>202</s> 196 bytes

(c,n)=>[...Array(i=n*(c=="="?4:c+1-1?2:c<"-"?n+n:n+1))].map(_=>--i%(n+(c=='/'|c>'w'||n))?c>'w'?i%n&&~-i%(n+2)?" ":c:c<'-'?i%(n*2)-n&&(~i&1|(n/2^i/n/2))?" ":c:c=="/"?i%n?" ":c:i%2?c:" ":`
`).join``

Could probably be golfed, but it's a start.


问:
Draw a hollow square of # with given width
I got this challenge from Codingame and am curious about better solutions than mine:

Given a width via standard input draw a hollow square of '#' in given width and length.

Example:

5 results in

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

I used python to solve this so i am particulary interested in other python code. But please feel free to post your solution in any language you want.

ContentLicense: CC BY-SA 3.0

Body:
Racket 113 bytes

(let*((d display)(g(λ()(for((i n))(d"#")))))(g)(d"\n")(for((i(- n 2)))(d"#")(for((i(- n 2)))(d" "))(d"#\n"))(g))

Ungolfed:

(define (f n)
  (let* ((d display)
         (g (λ ()
              (for ((i n))
                (d "#"))
              (d "\n"))))
    (g)
    (for ((i (- n 2)))
      (d "#")
      (for ((i (- n 2)))
        (d " ") )
      (d "#\n"))
    (g)))

Testing:

(f 5)

Output:

#####
#   #
#   #
#   #
#####


答:
WinDbg, <s>206</s> <s>200</s> <s>182</s> 170 bytes

```<code>.if@$t0{r$t3=2000000;f@$t3 L@$t0 23;f2*@$t3 L@$t0 20;eb2*@$t3 23;eb2*@$t3+@$t0-1 23;da@$t3 L@$t0;j1<@$t0'.for(r$t1=@$t0-2;@$t1;r$t1=@$t1-1){da2*@$t3 L@$t0};da@$t3 L@$t0'}
</code>```

-6 bytes from removing parens from .if and using j instead of second .if

-18 bytes by using f instead of a .for to construct the strings.

-12 bytes by not NULL-terminating strings, instead passing length to da

Input is passed in through the pseudo-register $t0 (eg r $t0 = 5; {above-code}).

Explanation:

```<code>.if @$t0                                                *Verify width($t0) at least 1
{                                                       *(registers have unsigned values)
    r $t3 = 2000000;                                    *Set $t3 to address where the
                                                        *string will be constructed
    f @$t3 L@$t0 23;                                    *Put width($t0) '#' at 2000000($t3)
    f 2 * @$t3 L@$t0 20;                                *Put width($t0) ' ' at 4000000(2*$t3)
    eb 2 * @$t3 23;                                     *Put '#' on left of ' ' string
    eb 2 * @$t3 + @$t0 - 1 23;                          *Put '#' on right of ' ' string
    da @$t3 L@$t0;                                      *Print the top of the box
    j 1 < @$t0                                          *If width($t1) at least 2
    '
        .for (r $t1 = @$t0 - 2; @$t1; r $t1 = @$t1 - 1) *Loop width($t0)-2 times to...
        {
            da 2 * @$t3 L@$t0                           *...print the sides of the box
        };
        da @$t3 L@$t0                                   *Print the bottom of the box
    '
}
</code>```

Sample output:

```<code>0:000> r$t0=0
0:000> .if@$t0{r$t3=2000000;f@$t3 L@$t0 23;f2*@$t3 L@$t0 20;eb2*@$t3 23;eb2*@$t3+@$t0-1 23;da@$t3 L@$t0;j1<@$t0'.for(r$t1=@$t0-2;@$t1;r$t1=@$t1-1){da2*@$t3 L@$t0};da@$t3 L@$t0'}

0:000> r$t0=1
0:000> .if@$t0{r$t3=2000000;f@$t3 L@$t0 23;f2*@$t3 L@$t0 20;eb2*@$t3 23;eb2*@$t3+@$t0-1 23;da@$t3 L@$t0;j1<@$t0'.for(r$t1=@$t0-2;@$t1;r$t1=@$t1-1){da2*@$t3 L@$t0};da@$t3 L@$t0'}
Filled 0x1 bytes
Filled 0x1 bytes
02000000  "#"

0:000> r$t0=2
0:000> .if@$t0{r$t3=2000000;f@$t3 L@$t0 23;f2*@$t3 L@$t0 20;eb2*@$t3 23;eb2*@$t3+@$t0-1 23;da@$t3 L@$t0;j1<@$t0'.for(r$t1=@$t0-2;@$t1;r$t1=@$t1-1){da2*@$t3 L@$t0};da@$t3 L@$t0'}
Filled 0x2 bytes
Filled 0x2 bytes
02000000  "##"
02000000  "##"

0:000> r$t0=5
0:000> .if@$t0{r$t3=2000000;f@$t3 L@$t0 23;f2*@$t3 L@$t0 20;eb2*@$t3 23;eb2*@$t3+@$t0-1 23;da@$t3 L@$t0;j1<@$t0'.for(r$t1=@$t0-2;@$t1;r$t1=@$t1-1){da2*@$t3 L@$t0};da@$t3 L@$t0'}
Filled 0x5 bytes
Filled 0x5 bytes
02000000  "#####"
04000000  "#   #"
04000000  "#   #"
04000000  "#   #"
02000000  "#####"
</code>```

Title: Draw a hollow square of # with given width

Body:
I got this challenge from Codingame and am curious about better solutions than mine:

Given a width via standard input draw a hollow square of '#' in given width and length.

Example:

5 results in

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

I used python to solve this so i am particulary interested in other python code. But please feel free to post your solution in any language you want.

Body:
WinDbg, <s>206</s> <s>200</s> <s>182</s> 170 bytes

.if@$t0{r$t3=2000000;f@$t3 L@$t0 23;f2*@$t3 L@$t0 20;eb2*@$t3 23;eb2*@$t3+@$t0-1 23;da@$t3 L@$t0;j1<@$t0'.for(r$t1=@$t0-2;@$t1;r$t1=@$t1-1){da2*@$t3 L@$t0};da@$t3 L@$t0'}

-6 bytes from removing parens from .if and using j instead of second .if

-18 bytes by using f instead of a .for to construct the strings.

-12 bytes by not NULL-terminating strings, instead passing length to da

Input is passed in through the pseudo-register $t0 (eg r $t0 = 5; {above-code}).

Explanation:

.if @$t0                                                *Verify width($t0) at least 1
{                                                       *(registers have unsigned values)
    r $t3 = 2000000;                                    *Set $t3 to address where the
                                                        *string will be constructed
    f @$t3 L@$t0 23;                                    *Put width($t0) '#' at 2000000($t3)
    f 2 * @$t3 L@$t0 20;                                *Put width($t0) ' ' at 4000000(2*$t3)
    eb 2 * @$t3 23;                                     *Put '#' on left of ' ' string
    eb 2 * @$t3 + @$t0 - 1 23;                          *Put '#' on right of ' ' string
    da @$t3 L@$t0;                                      *Print the top of the box
    j 1 < @$t0                                          *If width($t1) at least 2
    '
        .for (r $t1 = @$t0 - 2; @$t1; r $t1 = @$t1 - 1) *Loop width($t0)-2 times to...
        {
            da 2 * @$t3 L@$t0                           *...print the sides of the box
        };
        da @$t3 L@$t0                                   *Print the bottom of the box
    '
}

Sample output:

0:000> r$t0=0
0:000> .if@$t0{r$t3=2000000;f@$t3 L@$t0 23;f2*@$t3 L@$t0 20;eb2*@$t3 23;eb2*@$t3+@$t0-1 23;da@$t3 L@$t0;j1<@$t0'.for(r$t1=@$t0-2;@$t1;r$t1=@$t1-1){da2*@$t3 L@$t0};da@$t3 L@$t0'}

0:000> r$t0=1
0:000> .if@$t0{r$t3=2000000;f@$t3 L@$t0 23;f2*@$t3 L@$t0 20;eb2*@$t3 23;eb2*@$t3+@$t0-1 23;da@$t3 L@$t0;j1<@$t0'.for(r$t1=@$t0-2;@$t1;r$t1=@$t1-1){da2*@$t3 L@$t0};da@$t3 L@$t0'}
Filled 0x1 bytes
Filled 0x1 bytes
02000000  "#"

0:000> r$t0=2
0:000> .if@$t0{r$t3=2000000;f@$t3 L@$t0 23;f2*@$t3 L@$t0 20;eb2*@$t3 23;eb2*@$t3+@$t0-1 23;da@$t3 L@$t0;j1<@$t0'.for(r$t1=@$t0-2;@$t1;r$t1=@$t1-1){da2*@$t3 L@$t0};da@$t3 L@$t0'}
Filled 0x2 bytes
Filled 0x2 bytes
02000000  "##"
02000000  "##"

0:000> r$t0=5
0:000> .if@$t0{r$t3=2000000;f@$t3 L@$t0 23;f2*@$t3 L@$t0 20;eb2*@$t3 23;eb2*@$t3+@$t0-1 23;da@$t3 L@$t0;j1<@$t0'.for(r$t1=@$t0-2;@$t1;r$t1=@$t1-1){da2*@$t3 L@$t0};da@$t3 L@$t0'}
Filled 0x5 bytes
Filled 0x5 bytes
02000000  "#####"
04000000  "#   #"
04000000  "#   #"
04000000  "#   #"
02000000  "#####"


答:
Pip, 16 bytes

15 bytes of code, +1 for -n flag.

```<code>(Y_Xa-2WR'#s)My
</code>```

Works for input >= 2. Try it online!

Explanation of somewhat ungolfed version

First, we define a function y that takes a string argument, repeats it a-2 times (where a is the first command-line input), and wraps the result in #.

```<code>Y _ X a-2 WR '#
  _              Identity function
    X a-2        String-repeated by a-2
          WR '#  Wrapped in #
Y                Yank the resulting function into y
</code>```

Next, we apply this function twice--once normally, then again with map--to obtain the square as a list of strings:

```<code>y M (y s)
    (y s)  Call function y with s (preinitialized to " ") as argument
y M        Map y to each character of the resulting string
</code>```

For input of 4, (y s) results in "#  #" and y M (y s) in ["####"; "#  #"; "#  #"; "####"]. This latter value is then printed, with the -n flag causing it to be newline-separated.

Golfing tricks

To get from the ungolfed to the golfed version:

Remove spaces.

Y is an operator, which means we can use it in an expression. Instead of Y... followed by (ys), we can just do (Y...s).

The problem is, we have to yank the function before we reference it again as y; so yM(Y_Xa-2WR'#s) won't work. Solution: swap the operands of the Map operator. As long as one of them is a function and the other is an iterable type, it doesn't matter what order they come in.

Body:
Pip, 16 bytes

15 bytes of code, +1 for -n flag.

(Y_Xa-2WR'#s)My

Works for input >= 2. Try it online!

Explanation of somewhat ungolfed version

First, we define a function y that takes a string argument, repeats it a-2 times (where a is the first command-line input), and wraps the result in #.

Y _ X a-2 WR '#
  _              Identity function
    X a-2        String-repeated by a-2
          WR '#  Wrapped in #
Y                Yank the resulting function into y

Next, we apply this function twice--once normally, then again with map--to obtain the square as a list of strings:

y M (y s)
    (y s)  Call function y with s (preinitialized to " ") as argument
y M        Map y to each character of the resulting string

For input of 4, (y s) results in "#  #" and y M (y s) in ["####"; "#  #"; "#  #"; "####"]. This latter value is then printed, with the -n flag causing it to be newline-separated.

Golfing tricks

To get from the ungolfed to the golfed version:

Remove spaces.

Y is an operator, which means we can use it in an expression. Instead of Y... followed by (ys), we can just do (Y...s).

The problem is, we have to yank the function before we reference it again as y; so yM(Y_Xa-2WR'#s) won't work. Solution: swap the operands of the Map operator. As long as one of them is a function and the other is an iterable type, it doesn't matter what order they come in.


答:
R, 68 <s>70</s> bytes

Works for n > 1.  Thanks to @Billywob for a couple of bytes swapping out the array for a matrix.

```<code>cat(rbind(b<-'#',cbind(b,matrix(' ',n<-scan()-2,n),b),b,'
'),sep='')
</code>```

Uses rbind and cbind to put rows and columns of #'s around an n-2 square matrix of spaces.  Newlines are bound to the rows as well.  The newline in the source is significant.  Input is from STDIN

Body:
R, 68 <s>70</s> bytes

Works for n > 1.  Thanks to @Billywob for a couple of bytes swapping out the array for a matrix.

cat(rbind(b<-'#',cbind(b,matrix(' ',n<-scan()-2,n),b),b,'
'),sep='')

Uses rbind and cbind to put rows and columns of #'s around an n-2 square matrix of spaces.  Newlines are bound to the rows as well.  The newline in the source is significant.  Input is from STDIN


问:
Palindrome polyglot
Your task is to write a program that runs in two different languages, and does the following:

In one language, it palindromizes a given string.

Take the string. abcde

Reverse the string. edcba

Remove the first character. dcba

Glue it onto the original string. abcdedcba

In another language, it depalindromizes a given string.

Take a string palidromized by the above method. abcdedcba

Get the characters from the start to the middle. abcde

Remember, this is code-golf, so the code with the fewest characters (not bytes) wins.

Leaderboards

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

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

```<code># Language 1/Language 2, N bytes
</code>```

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

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

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

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

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

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

var QUESTION_ID=98776,OVERRIDE_USER=12537;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

```

答:
Java / Brainfuck, 71 bytes

```<code>/*+[,>]<[<]>[.>]<<[.<][*/a->a.substring(0,Math.ceil(a.length()/2d));//]
</code>```

Palindromizes in BF, depalindromizes in Java.

For the sake of clarity, this is what matters to the BF interpreter:

```<code>+[,>]<[<]>[.>]<<[.<][->,..]
</code>```

where the last loop containing characters from the Java lambda is skipped because the pointer points to a null character at that point.

Title: Palindrome polyglot

Body:
Java / Brainfuck, 71 bytes

/*+[,>]<[<]>[.>]<<[.<][*/a->a.substring(0,Math.ceil(a.length()/2d));//]

Palindromizes in BF, depalindromizes in Java.

For the sake of clarity, this is what matters to the BF interpreter:

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

where the last loop containing characters from the Java lambda is skipped because the pointer points to a null character at that point.


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

Samples:

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

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

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

What is the smallest algorithm for this?

答:
Mathematica 29 + 5 = 34 bytes

```<code>SpokenStringDump`SpeakOrdinal
</code>```

+5 bytes because Speak function must be called before using this built-in.

Usage

```<code>SpokenStringDump`SpeakOrdinal[1]
</code>```

"1st "

```<code>SpokenStringDump`SpeakOrdinal[4707]
</code>```

"4,707th "

Body:
Mathematica 29 + 5 = 34 bytes

SpokenStringDump`SpeakOrdinal

+5 bytes because Speak function must be called before using this built-in.

Usage

SpokenStringDump`SpeakOrdinal[1]

"1st "

SpokenStringDump`SpeakOrdinal[4707]

"4,707th "


问:
Depalindromize this string!
Given a palindrome generated according to this challenge, depalindromize it.

Test cases

```<code>abcdedcba -> abcde
johncenanecnhoj -> johncena
ppapapp -> ppap
codegolflogedoc -> codegolf
</code>```

As this is about depalindromizing, your code cannot be a palindrome.

Remember, this is code-golf, so the code with the fewest bytes wins.

答:
R, 35 bytes

Always late to the party.

```<code>substr(x<-scan(,""),1,nchar(x)/2+1)
</code>```

Title: Depalindromize this string!

Body:
R, 35 bytes

Always late to the party.

substr(x<-scan(,""),1,nchar(x)/2+1)


问:
i love yOu i lOve you i love yOu!
XKCD #99, with the title "Binary Heart" shows a simple image of ones and zeros, with some digits colored red.

The red heart is visible to the naked eye, but the message hidden in the binary sequence is not. If you remove all the spaces and newlines and interpret the binary sequence as 8 bit ASCII-code, you'll end up with the message:

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

Cute right?

Pssst... The string isn't a pure string repetition.

Your challenge is to create this binary image with 21 digits across, and 23 digits down. There should be exactly one space between each digit in each row, and one newline for each new row. Note that the last bits are only the beginning of the letter e, since 21*23 isn't divisible by 8. You need those bits correct too.

The function or program should not take any input. Leading and trailing spaces and newlines are accepted.

The result of your code should look like this:

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

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

Leaderboard

var QUESTION_ID=94699,OVERRIDE_USER=31516;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

```

答:
Rust, 195 bytes

||for(c,i)in"iloveyOuilOveyouiloveyOuilOveyOuiloveyouilOveyouilOveyOuilOve".bytes().fold(String::new(),|a,c|format!("{}0{:b}",a,c)).chars().zip(1..484){print!("{}{}",c,if i%21!=0{' '}else{'\n'})}
```

<p>Ungolfed:</p>

<pre class="lang-rs prettyprint-override"><code>fn main(){
    // convert bytes of the string to binary numerals.
    let s = "iloveyOuilOveyouiloveyOuilOveyOuiloveyouilOveyouilOveyOuilOve"
        .bytes()
        .fold(String::new(),|a,c|format!("{}0{:b}",a,c));

    // print them over the range with newlines/spaces as appropriate
    for(c,i) in s.chars().zip(1..484) {
        print!("{}{}",c,if i%21!=0{' '}else{'\n'})
    }
}
</code>```

ContentLicense: CC BY-SA 4.0

Title: i love yOu i lOve you i love yOu!

Body:
Rust, 195 bytes

||for(c,i)in"iloveyOuilOveyouiloveyOuilOveyOuiloveyouilOveyouilOveyOuilOve".bytes().fold(String::new(),|a,c|format!("{}0{:b}",a,c)).chars().zip(1..484){print!("{}{}",c,if i%21!=0{' '}else{'\n'})}

Ungolfed:

fn main(){
    // convert bytes of the string to binary numerals.
    let s = "iloveyOuilOveyouiloveyOuilOveyOuiloveyouilOveyouilOveyOuilOve"
        .bytes()
        .fold(String::new(),|a,c|format!("{}0{:b}",a,c));

    // print them over the range with newlines/spaces as appropriate
    for(c,i) in s.chars().zip(1..484) {
        print!("{}{}",c,if i%21!=0{' '}else{'\n'})
    }
}


答:
Ruby, 20 bytes

```<code>->n{n[0,-~n.size/2]}
</code>```

anonymous lambda that returns the first half (rounded up) of a string. The -~n is a 1+n with a higher priority than the division by two, so I don't need any parentheses. Unlike the other Ruby solution, this works on strings with even lengths.

Usage:

```<code>->n{n[0,-~n.size/2]}["abba"]
->n{n[0,-~n.size/2]}["abcba"]
->n{n[0,-~n.size/2]}["a"]
</code>```

Returns:

```<code>"ab"
"abc"
"a"
</code>```

Title: Depalindromize this string!

Body:
Given a palindrome generated according to this challenge, depalindromize it.

Test cases

```<code>abcdedcba -> abcde
johncenanecnhoj -> johncena
ppapapp -> ppap
codegolflogedoc -> codegolf
</code>```

As this is about depalindromizing, your code cannot be a palindrome.

Remember, this is code-golf, so the code with the fewest bytes wins.

Body:
Ruby, 20 bytes

->n{n[0,-~n.size/2]}

anonymous lambda that returns the first half (rounded up) of a string. The -~n is a 1+n with a higher priority than the division by two, so I don't need any parentheses. Unlike the other Ruby solution, this works on strings with even lengths.

Usage:

->n{n[0,-~n.size/2]}["abba"]
->n{n[0,-~n.size/2]}["abcba"]
->n{n[0,-~n.size/2]}["a"]

Returns:

"ab"
"abc"
"a"


问:
Product catalog
This problem is about separating a string representing a product identifier into three components.

The first part consists of upper and lower letters of arbitrary length which represents the warehouse.

The second part is digits which represents the product number. This part is also of arbitrary length.

The last part is qualifiers as size and colours, and this part continues to the end of the string. The qualifiers are guaranteed to start with a capital letter and consist of alphanumeric characters.

Each part should be printed clearly separated. It is guaranteed that each part is non-empty.

The winner is the one who uses least bytes to solve this problem.

Example:

Input: UK7898S14

Output:

UK

7898

S14

Here UK is United Kingdom, 7898 is the product code, and S14 is size 14.

Example 2:

Input: cphDK1234CYELLOWS14QGOOD

Output:

cphDK

1234

CYELLOWS14QGOOD

Here cphDK is Copenhagen, Denmark, 1234 is the product code, CYELLOWS14QGOOD represents yellow colour, size 14, and good quality.

答:
Gema, <s>17</s> 12 characters

(The trick of not handling the country code explicitly shamelessly borrowed from Dada's Perl solution. Appreciation should be expressed there.)

```<code><D>*=\n$1\n*
</code>```

Sample run:

```<code>bash-4.3$ gema '<D>*=\n$1\n*' <<< 'UK7898S14'
UK
7898
S14

bash-4.3$ gema '<D>*=\n$1\n*' <<< 'cphDK1234CYELLOWS14QGOOD'
cphDK
1234
CYELLOWS14QGOOD
</code>```

Title: Product catalog

Body:
Gema, <s>17</s> 12 characters

(The trick of not handling the country code explicitly shamelessly borrowed from Dada's Perl solution. Appreciation should be expressed there.)

<D>*=\n$1\n*

Sample run:

bash-4.3$ gema '<D>*=\n$1\n*' <<< 'UK7898S14'
UK
7898
S14

bash-4.3$ gema '<D>*=\n$1\n*' <<< 'cphDK1234CYELLOWS14QGOOD'
cphDK
1234
CYELLOWS14QGOOD


问:
N-dimensional Circles!
Write a program that takes two numbers as its input. The first one is the number of dimensions - 0 for a dot, 1 for a straight line, 2 for a circle, 3 for a sphere. The second number is the radius of the object, or, if it's 1-dimensional, the number itself. Output 0 for 0 dimensions. The output is the length/area/volume of the object.

If we call the first number n, the second one r, and the output x, we get that:

for n = 0, x = 1

for n = 1, x = 2×r

for n = 2, x = r2×π

for n = 3, x = (4/3)×r3×π

and so on... if you want, though.

Notes:

Cases when one or both numbers are negative, or when the first number is not whole, don't need to be covered.

The program must not read from any file and the only input are those two numbers.

The output should use only numerals (e.g. not "14*pi"), and should be accurate to at least two decimal digits.

As for n = 0, you can output 0 if it makes the code shorter.

Extra swag for an answer covering even 4 and more-dimensional "spheres"!

It's code-golf, so the shortest answer in bytes wins!

Examples:

```<code> 1 1 -> 2

 2 3 -> 28,27

 3 1 -> 4,19

 3 4,5 -> 381,70

 1 9.379 -> 18.758

 0 48 -> 1
</code>```

答:
CJam (27 bytes with extra credit)

```<code>{1$_[2dP]*<f*\,:)-2%./1+:*}
</code>```

Online test suite. This is an anonymous block (function) which takes arguments d r on the stack and leaves the result on the stack.

Dissection

The general n-dimensional formula can be rewritten as

$$\frac{2^{\left\lceil\frac{d}{2}\right\rceil}\pi^{\left\lfloor\frac{d}{2}\right\rfloor} r^d}{d!!}$$

```<code>{            e# Begin block: stack holds d r
  1$_[2dP]*< e#   Build a list which repeats [2 pi] d times and take the first d elements
  f*         e#   Multiply each element of the list by r
  \,:)-2%    e#   Build a list [1 ... d] and take every other element starting at the end
  ./         e#   Pointwise divide. The d/2 elements of the longer list are untouched
  1+:*       e#   Add 1 to ensure the list is non-empty and multiply its elements
}
</code>```

Title: N-dimensional Circles!

Body:
CJam (27 bytes with extra credit)

{1$_[2dP]*<f*\,:)-2%./1+:*}

Online test suite. This is an anonymous block (function) which takes arguments d r on the stack and leaves the result on the stack.

Dissection

The general n-dimensional formula can be rewritten as

$$\frac{2^{\left\lceil\frac{d}{2}\right\rceil}\pi^{\left\lfloor\frac{d}{2}\right\rfloor} r^d}{d!!}$$

{            e# Begin block: stack holds d r
  1$_[2dP]*< e#   Build a list which repeats [2 pi] d times and take the first d elements
  f*         e#   Multiply each element of the list by r
  \,:)-2%    e#   Build a list [1 ... d] and take every other element starting at the end
  ./         e#   Pointwise divide. The d/2 elements of the longer list are untouched
  1+:*       e#   Add 1 to ensure the list is non-empty and multiply its elements
}


答:
Retina, <s>28</s> <s>14</s> <s>10</s> 8 bytes

Saved 4 bytes thanks to Dom Hastings.

Saved 2 bytes thanks to Martin Ender.

```<code>S1`(\d+)
</code>```

Try it online!

Title: Product catalog

Body:
This problem is about separating a string representing a product identifier into three components.

The first part consists of upper and lower letters of arbitrary length which represents the warehouse.

The second part is digits which represents the product number. This part is also of arbitrary length.

The last part is qualifiers as size and colours, and this part continues to the end of the string. The qualifiers are guaranteed to start with a capital letter and consist of alphanumeric characters.

Each part should be printed clearly separated. It is guaranteed that each part is non-empty.

The winner is the one who uses least bytes to solve this problem.

Example:

Input: UK7898S14

Output:

UK

7898

S14

Here UK is United Kingdom, 7898 is the product code, and S14 is size 14.

Example 2:

Input: cphDK1234CYELLOWS14QGOOD

Output:

cphDK

1234

CYELLOWS14QGOOD

Here cphDK is Copenhagen, Denmark, 1234 is the product code, CYELLOWS14QGOOD represents yellow colour, size 14, and good quality.

Body:
Retina, <s>28</s> <s>14</s> <s>10</s> 8 bytes

Saved 4 bytes thanks to Dom Hastings.

Saved 2 bytes thanks to Martin Ender.

S1`(\d+)

Try it online!


答:
APL, 18

```<code>{⍵⊂⍨3⌊+\1,2≠/⍵∊⎕D}'UK7898S14'
UK  7898  S14
</code>```

Works by searching the first 2 points where there is a change from character to digit or vice-versa, and using those to split the string.

Title: Product catalog

Body:
APL, 18

{⍵⊂⍨3⌊+\1,2≠/⍵∊⎕D}'UK7898S14'
UK  7898  S14

Works by searching the first 2 points where there is a change from character to digit or vice-versa, and using those to split the string.


答:
Perl, 12 bytes

11 bytes of code + 1 byte for -p flag.

s/\d+/
$&
/
```

<p>To run it : </p>

```perl -pe 's/\d+/
$&
/' <<< "CYELLOWS14QGOOD"
```

Title: Product catalog

Body:
Perl, 12 bytes

11 bytes of code + 1 byte for -p flag.

s/\d+/
$&
/

To run it :

perl -pe 's/\d+/
$&
/' <<< "CYELLOWS14QGOOD"


答:
MATLAB, <s>81</s> 73 bytes

```<code>function y=f(x)
[~,~,~,m,~,~,s]=regexp(x,'(?<=^\D+)\d+');y=[s(1) m s(2)];
</code>```

Function that accepts a string and returns a cell array of three strings. Tested in version R20105b.

Example use:

```<code>>> f('UK7898S14')
ans =
    'UK'    '7898'    'S14'

>> f('cphDK1234CYELLOWS14QGOOD')
ans =
    'cphDK'    '1234'    'CYELLOWS14QGOOD'
</code>```

Explanation

The regular expression (?<=^\D+)\d+') matches a group of digits preceded by non-digits from the start of the string; the latter are not part of the match.

The fourth output of regexp is the 'match'; and the seventh output is the 'split', that is, the two parts of the string before and after the match.

Title: Product catalog

Body:
MATLAB, <s>81</s> 73 bytes

function y=f(x)
[~,~,~,m,~,~,s]=regexp(x,'(?<=^\D+)\d+');y=[s(1) m s(2)];

Function that accepts a string and returns a cell array of three strings. Tested in version R20105b.

Example use:

>> f('UK7898S14')
ans =
    'UK'    '7898'    'S14'

>> f('cphDK1234CYELLOWS14QGOOD')
ans =
    'cphDK'    '1234'    'CYELLOWS14QGOOD'

Explanation

The regular expression (?<=^\D+)\d+') matches a group of digits preceded by non-digits from the start of the string; the latter are not part of the match.

The fourth output of regexp is the 'match'; and the seventh output is the 'split', that is, the two parts of the string before and after the match.


答:
Java 7, <s>200</s> <s>185</s> <s>174</s> 167 bytes

```<code>import java.util.regex.*;String c(String s){Matcher m=Pattern.compile("(.*?)(\\d+)(.*)").matcher(s);s="";for(int i=0;i<3;)if(m.matches())s+=m.group(++i)+" ";return s;}
</code>```

Ungolfed & test code:

Try it here.

```<code>import java.util.regex.*;
class M{
  static String c(String s){
    Matcher m = Pattern.compile("(.*?)(\\d+)(.*)").matcher(s);
    s = "";
    for(int i = 0; i < 3;){
      if(m.matches()){
        s += m.group(++i) + " ";
      }
    }
    return s;
  }

  public static void main(String[] a){
    System.out.println(c("UK7898S14"));
    System.out.println(c("cphDK1234CYELLOWS14QGOOD"));
  }
}
</code>```

Output:

```<code>UK 7898 S14
cphDK 1234 CYELLOWS14QGOOD
</code>```

Title: Product catalog

Body:
Java 7, <s>200</s> <s>185</s> <s>174</s> 167 bytes

import java.util.regex.*;String c(String s){Matcher m=Pattern.compile("(.*?)(\\d+)(.*)").matcher(s);s="";for(int i=0;i<3;)if(m.matches())s+=m.group(++i)+" ";return s;}

Ungolfed & test code:

Try it here.

import java.util.regex.*;
class M{
  static String c(String s){
    Matcher m = Pattern.compile("(.*?)(\\d+)(.*)").matcher(s);
    s = "";
    for(int i = 0; i < 3;){
      if(m.matches()){
        s += m.group(++i) + " ";
      }
    }
    return s;
  }

  public static void main(String[] a){
    System.out.println(c("UK7898S14"));
    System.out.println(c("cphDK1234CYELLOWS14QGOOD"));
  }
}

Output:

UK 7898 S14
cphDK 1234 CYELLOWS14QGOOD


答:
JavaScript (ES6), 36 bytes

s=>/(.+?)(\d+)(.*)/.exec(s).slice(1)
```

<h3>Examples</h3>

<p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>let f =

s=>/(.+?)(\d+)(.*)/.exec(s).slice(1)

console.log(f('UK7898S14'));
console.log(f('cphDK1234CYELLOWS14QGOOD'));</code>```

Title: Product catalog

Body:
JavaScript (ES6), 36 bytes

s=>/(.+?)(\d+)(.*)/.exec(s).slice(1)

Examples

let f =

s=>/(.+?)(\d+)(.*)/.exec(s).slice(1)

console.log(f('UK7898S14'));
console.log(f('cphDK1234CYELLOWS14QGOOD'));


答:
JavaScript, <s>38</s> 36 bytes

s=>/(\D+)(\d+)(.+)/.exec(s).slice(1)
```

<h3>Example</h3>

<p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const f =

s=>/(\D+)(\d+)(.+)/.exec(s).slice(1)

console.log(f("UK7898S14"));
console.log(f("cphDK1234CYELLOWS14QGOOD"));</code>```

Title: Product catalog

Body:
JavaScript, <s>38</s> 36 bytes

s=>/(\D+)(\d+)(.+)/.exec(s).slice(1)

Example

const f =

s=>/(\D+)(\d+)(.+)/.exec(s).slice(1)

console.log(f("UK7898S14"));
console.log(f("cphDK1234CYELLOWS14QGOOD"));


答:
PHP, 61 59 5655 bytes

```<code>preg_match('/(\D+)(\d+)(.+)/',$argv[1],$a);print_r($a);
</code>```

This does output the initial code as well:

```<code>Array
(
    [0] => cphDK1234CYELLOWS14QGOOD
    [1] => cphDK
    [2] => 1234
    [3] => CYELLOWS14QGOOD
)
</code>```

Edit

Thanks to @manatwork for saving a few bytes for me

Thanks to @RomanGräf for another few bytes saved

Title: Product catalog

Body:
PHP, 61 59 5655 bytes

preg_match('/(\D+)(\d+)(.+)/',$argv[1],$a);print_r($a);

This does output the initial code as well:

Array
(
    [0] => cphDK1234CYELLOWS14QGOOD
    [1] => cphDK
    [2] => 1234
    [3] => CYELLOWS14QGOOD
)

Edit

Thanks to @manatwork for saving a few bytes for me

Thanks to @RomanGräf for another few bytes saved


答:
JavaScript without regex, 84 81 79 bytes

p=>{for(i=n=o='';i<p.length;){if(n==isNaN(c=p[i++])){o+=' ';n++}o+=c}return o}

Title: Product catalog


问:
The meta-polyglot quine
In my time on PPCG, I've noticed that quine problems and polyglot problems are quite popular. Also, meta-solutions to problems, that is, scripts which generate a program which is the solution to a problem, tend to get a lot of positive feedback from the community. Therefore, I have created this challenge, which implements these three ideas.

Your task then, reader and code-golf enthusiast, is to create as short as possible a script which can run in two languages A and B to generate quines for A and B. When your program is run in language A, it should generate a program that is a quine in language B but not in language A and vice versa. The languages A and B can be different version of the same language, provided you keep in mind that the generated quines should only work in one of the versions.

Keep in mind that the standard loopholes should be considered closed and only proper quines are allowed.

Good luck, fewest characters wins!

答:
Clojure / Common Lisp, 274 bytes

```<code>(defmacro t []"((fn [s] (print (list s (list (quote quote) s)))) (quote (fn [s] (print (list s (list (quote quote) s))))))")(if '()(print(let[s clojure.string/replace](.toUpperCase(s(s(s(s(s(t)"fn""lambda")"[s]""(s)")"(quote ""'")"e)""e")")))))""))))"))))(eval '(princ(t))))
</code>```

Some spaces added for readability

```<code>(defmacro t []"((fn [s] (print (list s (list (quote quote) s))))
     (quote (fn [s] (print (list s (list (quote quote) s))))))")
(if '()(print(let[s clojure.string/replace](.toUpperCase
    (s(s(s(s(s(t)"fn""lambda")"[s]""(s)")"(quote ""'")"e)""e")")))))""))))"))))
    (eval '(princ(t))))
</code>```

Basically defines a macro which returns a quine in Clojure. Clojure requires parameters for macro definition provided as vector ([]) whereas Common Lisp (thankfully) just ignores it. After that we differ 2 languages by evaluating '() which equals to nil and thus falsey in Common Lisp and is true in Clojure. Then we do string manipulations using Clojure which Common Lisp doesn't even try to evaluate as it goes in another if branch. Clojure on the other hand tries to check if another branch is at least correct before executing so had to use eval there to both be correct in Clojure and output correct string in Common Lisp.

Note: just returning two different string might probably be shorter but then it won't be different to a polyglot challenges about outputing different strings in different languages.  ¯\_(ツ)_/¯

Clojure original source run: https://ideone.com/SiQhPf

Common Lisp original source run: https://ideone.com/huLcty

Clojure output : ((LAMBDA (S) (PRINT (LIST S (LIST 'QUOTE S)))) '(LAMBDA (S) (PRINT (LIST S (LIST 'QUOTE S)))))

Common Lisp output : ((fn [s] (print (list s (list (quote quote) s)))) (quote (fn [s] (print (list s (list (quote quote) s))))))

Clojure output run in Common Lisp: https://ideone.com/T1DF7H

Vice versa: https://ideone.com/Fezayq

Title: The meta-polyglot quine

Body:
Clojure / Common Lisp, 274 bytes

(defmacro t []"((fn [s] (print (list s (list (quote quote) s)))) (quote (fn [s] (print (list s (list (quote quote) s))))))")(if '()(print(let[s clojure.string/replace](.toUpperCase(s(s(s(s(s(t)"fn""lambda")"[s]""(s)")"(quote ""'")"e)""e")")))))""))))"))))(eval '(princ(t))))

Some spaces added for readability

(defmacro t []"((fn [s] (print (list s (list (quote quote) s))))
     (quote (fn [s] (print (list s (list (quote quote) s))))))")
(if '()(print(let[s clojure.string/replace](.toUpperCase
    (s(s(s(s(s(t)"fn""lambda")"[s]""(s)")"(quote ""'")"e)""e")")))))""))))"))))
    (eval '(princ(t))))

Basically defines a macro which returns a quine in Clojure. Clojure requires parameters for macro definition provided as vector ([]) whereas Common Lisp (thankfully) just ignores it. After that we differ 2 languages by evaluating '() which equals to nil and thus falsey in Common Lisp and is true in Clojure. Then we do string manipulations using Clojure which Common Lisp doesn't even try to evaluate as it goes in another if branch. Clojure on the other hand tries to check if another branch is at least correct before executing so had to use eval there to both be correct in Clojure and output correct string in Common Lisp.

Note: just returning two different string might probably be shorter but then it won't be different to a polyglot challenges about outputing different strings in different languages.  ¯\_(ツ)_/¯

Clojure original source run: https://ideone.com/SiQhPf

Common Lisp original source run: https://ideone.com/huLcty

Clojure output : ((LAMBDA (S) (PRINT (LIST S (LIST 'QUOTE S)))) '(LAMBDA (S) (PRINT (LIST S (LIST 'QUOTE S)))))

Common Lisp output : ((fn [s] (print (list s (list (quote quote) s)))) (quote (fn [s] (print (list s (list (quote quote) s))))))

Clojure output run in Common Lisp: https://ideone.com/T1DF7H

Vice versa: https://ideone.com/Fezayq


问:
Operator ASCII art

Challenge

Given an ASCII operator from the list below and a number n, draw an ASCII representation of the operator using that operator as the character with the line segments of the operator having length n.

Input

An ASCII character from the list = + - x / and an integer n where n >= 1.  (I'm using x instead of * and / instead of ÷, but you could use either one, whichever is easier). For + and x, you only have to handle odd numbers to avoid issues with alignment.

Output

An ASCII drawing of the operator composed of the character with segments of length n. Horizontal portions should have spaces between the characters to offset vertical/horizontal distance differences.

Rules

This is code-golf, so shortest code in bytes wins. Standard loopholes are forbidden.

Examples

Input: + 3

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

Input: = 4

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

Input: = 10

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

Input: - 2

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

Input: / 10

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

Input: x 7

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

Title: Operator ASCII art

Body:
JavaScript (ES6), 156 bytes

(c,n)=>[...Array(n--)].map((_,i,a)=>a.map((_,j)=>({'/':a=i+j-n,x:a&&i-j,'-':a=i+i-n,'+':a&&j+j-n,'=':a+2&&a-2}[c]?' ':c)).join(c=='='|c<'/'?' ':'')).join`\n`

Where \n represents the literal newline character.


答:
jq, 47 characters

(43 characters code + 4 characters command line options.)

```<code>match("(\\D+)(\\d+)(.+)").captures[].string
</code>```

(Again the old story: fairly elegant at the beginning, then becomes painfully verbose.)

Sample run:

```<code>bash-4.3$ jq -Rr 'match("(\\D+)(\\d+)(.+)").captures[].string' <<< 'UK7898S14'
UK
7898
S14

bash-4.3$ jq -Rr 'match("(\\D+)(\\d+)(.+)").captures[].string' <<< 'cphDK1234CYELLOWS14QGOOD'
cphDK
1234
CYELLOWS14QGOOD
</code>```

On-line test (Passing -r through URL is not supported – check Raw Output yourself.)

Title: Product catalog

Body:
jq, 47 characters

(43 characters code + 4 characters command line options.)

match("(\\D+)(\\d+)(.+)").captures[].string

(Again the old story: fairly elegant at the beginning, then becomes painfully verbose.)

Sample run:

bash-4.3$ jq -Rr 'match("(\\D+)(\\d+)(.+)").captures[].string' <<< 'UK7898S14'
UK
7898
S14

bash-4.3$ jq -Rr 'match("(\\D+)(\\d+)(.+)").captures[].string' <<< 'cphDK1234CYELLOWS14QGOOD'
cphDK
1234
CYELLOWS14QGOOD

On-line test (Passing -r through URL is not supported – check Raw Output yourself.)


答:
Haskell, 36 bytes (no regex)

```<code>d c='/'<c&&c<':'
(span d<$>).break d
</code>```

This gives the result in the format ("UK",("7898","S14")).
The idea is to split at the first digit, and then split the rest at the first non-digit.
Try it on Ideone.

Title: Product catalog

Body:
Haskell, 36 bytes (no regex)

d c='/'<c&&c<':'
(span d<$>).break d

This gives the result in the format ("UK",("7898","S14")).
The idea is to split at the first digit, and then split the rest at the first non-digit.
Try it on Ideone.


答:
C#, <s>191</s> 177 bytes

Golfed:

```<code>void F(string s){var a=s.ToList();int i=a.FindIndex(char.IsDigit);int n=a.FindIndex(i,char.IsUpper);Console.Write($"{s.Substring(0,i)}\n{s.Substring(i,n-i)}\n{s.Substring(n)}");
</code>```

Ungolfed:

```<code>    void F(string s)
    {
        var a = s.ToList();
        int i = a.FindIndex(char.IsDigit);
        int n = a.FindIndex(i, char.IsUpper);

        Console.Write($"{s.Substring(0, i)}\n{s.Substring(i, n - i)}\n{s.Substring(n)}");
    }
</code>```

EDIT1: @Link Ng saved 14 bytes.

Title: Product catalog

Body:
C#, <s>191</s> 177 bytes

Golfed:

void F(string s){var a=s.ToList();int i=a.FindIndex(char.IsDigit);int n=a.FindIndex(i,char.IsUpper);Console.Write($"{s.Substring(0,i)}\n{s.Substring(i,n-i)}\n{s.Substring(n)}");

Ungolfed:

    void F(string s)
    {
        var a = s.ToList();
        int i = a.FindIndex(char.IsDigit);
        int n = a.FindIndex(i, char.IsUpper);

        Console.Write($"{s.Substring(0, i)}\n{s.Substring(i, n - i)}\n{s.Substring(n)}");
    }

EDIT1: @Link Ng saved 14 bytes.


答:
R, 63 52 bytes

Edit: Saved a bunch of bytes thanks to @JDL

Takes input from stdin and prints to stdout:

```<code>gsub("([a-z]+)(\\d+)(.+)","\\1 \\2 \\3",scan(,""),T)
</code>```

Example output:

```<code>[1] "UK 7898 S1"
[1] "cphDK 1234 CYELLOWS14QGOOD"
</code>```

Title: Product catalog

Body:
R, 63 52 bytes

Edit: Saved a bunch of bytes thanks to @JDL

Takes input from stdin and prints to stdout:

gsub("([a-z]+)(\\d+)(.+)","\\1 \\2 \\3",scan(,""),T)

Example output:

[1] "UK 7898 S1"
[1] "cphDK 1234 CYELLOWS14QGOOD"


问:
Print a 10 by 10 grid of asterisks

Background

This is a standard textbook example to demonstrate for loops.

This is one of the first programs I learnt when I started learning programming ~10 years ago.

Task

You are to print this exact text:

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

Specs

You may have extra trailing newlines.

You may have extra trailing spaces (U+0020) at the end of each line, including the extra trailing newlines.

Scoring

This is code-golf. Shortest answer in bytes wins.

Title: Print a 10 by 10 grid of asterisks

Body:
Crystal, 21 bytes

puts ("*"*10+"\n")*10

How does it work?

"*" * 10            = "**********"
"**********" + "\n" = "**********\n"
"**********\n" * 10 = "**********\n**********\n[...]"


答:
Dyalog APL, <s>91</s> 86 bytes

Needs ⎕IO←0, which is default on many systems. Takes n as left argument, and one of + - × ÷ = as right argument.

{s←⌈⍎⍕3⍵2
t←' '⍵
d←⌽∘.=⍨⍺
s∊2 6:t[d∨⌽d∧6=s]
5=s:t[↑,/2↑¨∨/¨(⌊⍺÷2)=⍳⍺ ⍺]
(2-s)(2×⍺)⍴t}
```

<h3>Explanation</h3>

<pre class="lang-apl prettyprint-override"><code>{
    s ← ⌈ ⍎ ⍕ 3 ⍵ 2             ⍝ calculate ceil(3 f 2), where f is the given symbol
    t ← ' '⍵                    ⍝ create a string with a space before the symbol
    d ← ⌽ ∘.=⍨ ⍺                ⍝ Boolean \ diagonal
    s ∊ 2 6: t[d ∨ ⌽ d ∧ 6 = s] ⍝ if ÷ or × index t with one or both diagonals
⍝ find coordinates that are in the middle of at least one dimension
⍝ pad with zeros for spacing
⍝ use that to index into t
    5 = s: t[ ↑ ,/ 2↑¨ ∨/¨ (⌊ ⍺ ÷ 2) = ⍳ ⍺ ⍺]
⍝ - or =:
    (2 - s) (2 × ⍺) ⍴ t       ⍝ one or two rows of double-spaced symbols
}
</code>```

Title: Operator ASCII art

Body:
Challenge

Given an ASCII operator from the list below and a number n, draw an ASCII representation of the operator using that operator as the character with the line segments of the operator having length n.

Input

An ASCII character from the list = + - x / and an integer n where n >= 1.  (I'm using x instead of * and / instead of ÷, but you could use either one, whichever is easier). For + and x, you only have to handle odd numbers to avoid issues with alignment.

Output

An ASCII drawing of the operator composed of the character with segments of length n. Horizontal portions should have spaces between the characters to offset vertical/horizontal distance differences.

Rules

This is code-golf, so shortest code in bytes wins. Standard loopholes are forbidden.

Examples

Input: + 3

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

Input: = 4

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

Input: = 10

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

Input: - 2

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

Input: / 10

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

Input: x 7

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

Body:
Dyalog APL, <s>91</s> 86 bytes

Needs ⎕IO←0, which is default on many systems. Takes n as left argument, and one of + - × ÷ = as right argument.

{s←⌈⍎⍕3⍵2
t←' '⍵
d←⌽∘.=⍨⍺
s∊2 6:t[d∨⌽d∧6=s]
5=s:t[↑,/2↑¨∨/¨(⌊⍺÷2)=⍳⍺ ⍺]
(2-s)(2×⍺)⍴t}

Explanation

{
    s ← ⌈ ⍎ ⍕ 3 ⍵ 2             ⍝ calculate ceil(3 f 2), where f is the given symbol
    t ← ' '⍵                    ⍝ create a string with a space before the symbol
    d ← ⌽ ∘.=⍨ ⍺                ⍝ Boolean \ diagonal
    s ∊ 2 6: t[d ∨ ⌽ d ∧ 6 = s] ⍝ if ÷ or × index t with one or both diagonals
⍝ find coordinates that are in the middle of at least one dimension
⍝ pad with zeros for spacing
⍝ use that to index into t
    5 = s: t[ ↑ ,/ 2↑¨ ∨/¨ (⌊ ⍺ ÷ 2) = ⍳ ⍺ ⍺]
⍝ - or =:
    (2 - s) (2 × ⍺) ⍴ t       ⍝ one or two rows of double-spaced symbols
}


Title: Outputting ordinal numbers (1st, 2nd, 3rd)

Body:
I would like to generate (as a return result of a function, or simply as the output of a program) the ordinal suffix of a positive integer concatenated to the number.

Samples:

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

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

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

What is the smallest algorithm for this?

Body:
Java 7, <s>91</s> 81 bytes

String d(int n){return n+(n/10%10==1|(n%=10)<1|n>3?"th":n<2?"st":n<3?"nd":"rd");}

Port from @adrianmp's C# answer.

Old answer (91 bytes):

String c(int n){return n+((n%=100)>10&n<14?"th":(n%=10)==1?"st":n==2?"nd":n==3?"rd":"th");}

Ungolfed & test code:

Try it here.

class M{
  static String c(int n){
    return n + ((n%=100) > 10 & n < 14
                ?"th"
                : (n%=10) == 1
                   ? "st"
                   : n == 2
                      ? "nd"
                      : n == 3
                         ? "rd"
                         :"th");
  }

  static String d(int n){
    return n + (n/10%10 == 1 | (n%=10) < 1 | n > 3
                 ? "th"
                 : n < 2
                    ? "st"
                    : n < 3
                       ? "nd"
                       :"rd");
  }

  public static void main(String[] a){
    for(int i = 1; i < 201; i++){
      System.out.print(c(i) + ", ");
    }
    System.out.println();
    for(int i = 1; i < 201; i++){
      System.out.print(d(i) + ", ");
    }
  }
}

Output:

1st, 2nd, 3rd, 4th, 5th, 6th, 7th, 8th, 9th, 10th, 11th, 12th, 13th, 14th, 15th, 16th, 17th, 18th, 19th, 20th, 21st, 22nd, 23rd, 24th, 25th, 26th, 27th, 28th, 29th, 30th, 31st, 32nd, 33rd, 34th, 35th, 36th, 37th, 38th, 39th, 40th, 41st, 42nd, 43rd, 44th, 45th, 46th, 47th, 48th, 49th, 50th, 51st, 52nd, 53rd, 54th, 55th, 56th, 57th, 58th, 59th, 60th, 61st, 62nd, 63rd, 64th, 65th, 66th, 67th, 68th, 69th, 70th, 71st, 72nd, 73rd, 74th, 75th, 76th, 77th, 78th, 79th, 80th, 81st, 82nd, 83rd, 84th, 85th, 86th, 87th, 88th, 89th, 90th, 91st, 92nd, 93rd, 94th, 95th, 96th, 97th, 98th, 99th, 100th, 101st, 102nd, 103rd, 104th, 105th, 106th, 107th, 108th, 109th, 110th, 111th, 112th, 113th, 114th, 115th, 116th, 117th, 118th, 119th, 120th, 121st, 122nd, 123rd, 124th, 125th, 126th, 127th, 128th, 129th, 130th, 131st, 132nd, 133rd, 134th, 135th, 136th, 137th, 138th, 139th, 140th, 141st, 142nd, 143rd, 144th, 145th, 146th, 147th, 148th, 149th, 150th, 151st, 152nd, 153rd, 154th, 155th, 156th, 157th, 158th, 159th, 160th, 161st, 162nd, 163rd, 164th, 165th, 166th, 167th, 168th, 169th, 170th, 171st, 172nd, 173rd, 174th, 175th, 176th, 177th, 178th, 179th, 180th, 181st, 182nd, 183rd, 184th, 185th, 186th, 187th, 188th, 189th, 190th, 191st, 192nd, 193rd, 194th, 195th, 196th, 197th, 198th, 199th, 200th,
1st, 2nd, 3rd, 4th, 5th, 6th, 7th, 8th, 9th, 10th, 11th, 12th, 13th, 14th, 15th, 16th, 17th, 18th, 19th, 20th, 21st, 22nd, 23rd, 24th, 25th, 26th, 27th, 28th, 29th, 30th, 31st, 32nd, 33rd, 34th, 35th, 36th, 37th, 38th, 39th, 40th, 41st, 42nd, 43rd, 44th, 45th, 46th, 47th, 48th, 49th, 50th, 51st, 52nd, 53rd, 54th, 55th, 56th, 57th, 58th, 59th, 60th, 61st, 62nd, 63rd, 64th, 65th, 66th, 67th, 68th, 69th, 70th, 71st, 72nd, 73rd, 74th, 75th, 76th, 77th, 78th, 79th, 80th, 81st, 82nd, 83rd, 84th, 85th, 86th, 87th, 88th, 89th, 90th, 91st, 92nd, 93rd, 94th, 95th, 96th, 97th, 98th, 99th, 100th, 101st, 102nd, 103rd, 104th, 105th, 106th, 107th, 108th, 109th, 110th, 111th, 112th, 113th, 114th, 115th, 116th, 117th, 118th, 119th, 120th, 121st, 122nd, 123rd, 124th, 125th, 126th, 127th, 128th, 129th, 130th, 131st, 132nd, 133rd, 134th, 135th, 136th, 137th, 138th, 139th, 140th, 141st, 142nd, 143rd, 144th, 145th, 146th, 147th, 148th, 149th, 150th, 151st, 152nd, 153rd, 154th, 155th, 156th, 157th, 158th, 159th, 160th, 161st, 162nd, 163rd, 164th, 165th, 166th, 167th, 168th, 169th, 170th, 171st, 172nd, 173rd, 174th, 175th, 176th, 177th, 178th, 179th, 180th, 181st, 182nd, 183rd, 184th, 185th, 186th, 187th, 188th, 189th, 190th, 191st, 192nd, 193rd, 194th, 195th, 196th, 197th, 198th, 199th, 200th,


答:
JavaScript (ES6), <s>28</s> 26 bytes

s=>s.replace(/\d+/,`
$&
`)
```
<p>Saved 2 bytes thanks to @Grax</p>
<h3>Examples</h3>
<p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>let f =

s=>s.replace(/\d+/,`
$&
`)

console.log(f('UK7898S14'));
console.log(f('cphDK1234CYELLOWS14QGOOD'));</code>```

Title: Product catalog

Body:
This problem is about separating a string representing a product identifier into three components.

The first part consists of upper and lower letters of arbitrary length which represents the warehouse.

The second part is digits which represents the product number. This part is also of arbitrary length.

The last part is qualifiers as size and colours, and this part continues to the end of the string. The qualifiers are guaranteed to start with a capital letter and consist of alphanumeric characters.

Each part should be printed clearly separated. It is guaranteed that each part is non-empty.

The winner is the one who uses least bytes to solve this problem.

Example:

Input: UK7898S14

Output:

UK

7898

S14

Here UK is United Kingdom, 7898 is the product code, and S14 is size 14.

Example 2:

Input: cphDK1234CYELLOWS14QGOOD

Output:

cphDK

1234

CYELLOWS14QGOOD

Here cphDK is Copenhagen, Denmark, 1234 is the product code, CYELLOWS14QGOOD represents yellow colour, size 14, and good quality.

Body:
JavaScript (ES6), <s>28</s> 26 bytes

s=>s.replace(/\d+/,`
$&
`)

Saved 2 bytes thanks to @Grax

Examples

let f =

s=>s.replace(/\d+/,`
$&
`)

console.log(f('UK7898S14'));
console.log(f('cphDK1234CYELLOWS14QGOOD'));


问:
Generate a Markdown Template for your Post
Your task is simple: Write a program (or function) that takes no input and outputs something like this:

```<code>## *name*, *length* bytes
    *code*
</code>```

Where *name* is the name of the language you are using, *length* is the number of bytes in your code, and *code* is your program's source code. If *code* contains multiple lines, it have four spaces before each line.

Here's a 124-byte example implementation in Python 3:

```<code>s = "## Python 3, 124 bytes{2}    s = {1}{0}{1}{2}print(s.format(s,chr(34),chr(10)))"
print(s.format(s,chr(34),chr(10)))
</code>```

The output is:

```<code>## Python 3, 124 bytes
    s = "## Python 3, 124 bytes{2}    s = {1}{0}{1}{2}print(s.format(s,chr(34),chr(10)))"
    print(s.format(s,chr(34),chr(10)))
</code>```

Which in Markdown is:

Python 3, 124 bytes

```<code>s = "## Python 3, 124 bytes{2}    s = {1}{0}{1}{2}print(s.format(s,chr(34),chr(10)))"
print(s.format(s,chr(34),chr(10)))
</code>```

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

答:
Python 2, 58 bytes

```<code>_='## Python 2, 58 bytes\n    _=%r;print _%%_';print _%_
</code>```

Body:
Python 2, 58 bytes

_='## Python 2, 58 bytes\n    _=%r;print _%%_';print _%_


答:
05AB1E, 39 37 16 bytes

Saved a lot of bytes thanks to Emigna.

It uses CP-1252 encoding.

```<code>TvDSdykF¬?¦}¶?}?

T                push "10"
 v               for each element (i.e., 1 and 0). Element is stored in 'y'
  DS             split string (input during the first iteration)
    d            for each character, 1 if digit or 0 otherwise
     yk          get index of the first occurrence of 'y'
       F         for 0 <= i < string.firstIndexOf(y)
        ¬?       print the first character of the string
          ¦      remove it from the string
           }     end inner for
            ¶?   display a newline
              }  end outer for
               ? display the remaining string
</code>```

Try it online!

(This is my first post here!)

Title: Product catalog

Body:
05AB1E, 39 37 16 bytes

Saved a lot of bytes thanks to Emigna.

It uses CP-1252 encoding.

TvDSdykF¬?¦}¶?}?

T                push "10"
 v               for each element (i.e., 1 and 0). Element is stored in 'y'
  DS             split string (input during the first iteration)
    d            for each character, 1 if digit or 0 otherwise
     yk          get index of the first occurrence of 'y'
       F         for 0 <= i < string.firstIndexOf(y)
        ¬?       print the first character of the string
          ¦      remove it from the string
           }     end inner for
            ¶?   display a newline
              }  end outer for
               ? display the remaining string

Try it online!

(This is my first post here!)


问:
GO OUT AND VOTE
Today is November 8th, 2016, Election Day in the United States of America.

If you are a U.S. citizen eligible to vote, then go out and vote if you haven't already before answering this challenge. Do not discuss who you voted for. It only matters that you voted.

If you are not a U.S. citizen or not eligible to vote, then, before answering this challenge, do the U.S. a favor by telling anyone you know who is an eligible citizen to go out and vote if they haven't already.

Challenge

Write a program that indicates that you voted, like a digital "I Voted" sticker.

It should take no input and must output in a reasonable way the phrase I Voted where the I, o, and e are red (#FF0000) and the V, t, and d are blue (#0000FF). The background must be white (#FFFFFF).

For example:

These colors are of course representative of the American flag (though not the official colors). Red comes first simply because it comes first in the common idiom "red white and blue".

To be valid, an answer must:

Use the colors specified in the arrangement specified.

Use a single legible font and font size. The example uses 72pt Times New Roman bold but any common font above 6pt is probably fine.

Have just the phrase I Voted on a single line, capitalized correctly, with a clear space between the two words. It shouldn't look like IVoted.

Not indicate who the answerer voted for or supports for president or any down-ballot races. Let's not start any internet debates. This is about celebrating voting, not candidates.

Any reasonable way of displaying or producing the output is valid, such as:

Drawing the text to an image that is then displayed, saved, or output raw.

Writing the text to a console using color formatting. In this case you may approximate pure red and blue if necessary, and it's ok if only the area directly behind the text can be made white.

Displaying the text on a WPF/Windows form.

Outputting an HTML/RTF/PDF file with the text.

Please post an image of your output.

The shortest answer in bytes wins.

答:
Mathematica (REPL image output), <s>65</s> 49 bytes

```<code>Overlay@{"I  o e"~Style~Red,"  V t d"~Style~Blue}
</code>```

Graphical REPL expression.

Title: GO OUT AND VOTE

Body:
Mathematica (REPL image output), <s>65</s> 49 bytes

Overlay@{"I  o e"~Style~Red,"  V t d"~Style~Blue}

Graphical REPL expression.


答:
Google Blockly, <s>10</s> 14 blocks, <s>28</s> <s>41</s> 35 blytes

Code

Output

Try it here

Not counting the hide turtle block because it's just aesthetics.

A blyte is a combination of a block and a byte, there's no meta post yet as how to count this, but I'll create one later. As for now, this is how I count:

I   o  e, 8 blytes

V  t   d, 10 blytes (2 leading spaces here)

Colours, 1 blyte each, 2 total

90, 2 blytes

999, 3 blytes

0, 1 blyte

turn right, 2 blytes

move forward, 2 blytes

normal blocks, 1 blyte each, 5 total

Since Google Blockly is rarely used for golfing and I'm thinking waaay outside of the box for this challenge, I hope this is a valid submission.

Title: GO OUT AND VOTE

Body:
Today is November 8th, 2016, Election Day in the United States of America.

If you are a U.S. citizen eligible to vote, then go out and vote if you haven't already before answering this challenge. Do not discuss who you voted for. It only matters that you voted.

If you are not a U.S. citizen or not eligible to vote, then, before answering this challenge, do the U.S. a favor by telling anyone you know who is an eligible citizen to go out and vote if they haven't already.

Challenge

Write a program that indicates that you voted, like a digital "I Voted" sticker.

It should take no input and must output in a reasonable way the phrase I Voted where the I, o, and e are red (#FF0000) and the V, t, and d are blue (#0000FF). The background must be white (#FFFFFF).

For example:

These colors are of course representative of the American flag (though not the official colors). Red comes first simply because it comes first in the common idiom "red white and blue".

To be valid, an answer must:

Use the colors specified in the arrangement specified.

Use a single legible font and font size. The example uses 72pt Times New Roman bold but any common font above 6pt is probably fine.

Have just the phrase I Voted on a single line, capitalized correctly, with a clear space between the two words. It shouldn't look like IVoted.

Not indicate who the answerer voted for or supports for president or any down-ballot races. Let's not start any internet debates. This is about celebrating voting, not candidates.

Any reasonable way of displaying or producing the output is valid, such as:

Drawing the text to an image that is then displayed, saved, or output raw.

Writing the text to a console using color formatting. In this case you may approximate pure red and blue if necessary, and it's ok if only the area directly behind the text can be made white.

Displaying the text on a WPF/Windows form.

Outputting an HTML/RTF/PDF file with the text.

Please post an image of your output.

The shortest answer in bytes wins.


答:
Windows 10 Batch, <s>51</s> 50 bytes

```<code>@color fc&echo I ␛[94mV␛[91mo␛[94mt␛[91me␛[94md␛[m
</code>```

Where ␛ represents the ANSI Escape 0x1B character. Outputs using colour formatting. Edit: Saved 1 byte thanks to @brianush1. I tried writing the code to generate this but it took 97 bytes. Output:

Title: GO OUT AND VOTE

Body:
Windows 10 Batch, <s>51</s> 50 bytes

@color fc&echo I ␛[94mV␛[91mo␛[94mt␛[91me␛[94md␛[m

Where ␛ represents the ANSI Escape 0x1B character. Outputs using colour formatting. Edit: Saved 1 byte thanks to @brianush1. I tried writing the code to generate this but it took 97 bytes. Output:


答:
HTML, 52 bytes

```<code>I <c>V<e>o<c>t<e>e<c>d<style>*{color:red}c{color:0ff
</code>```

Title: GO OUT AND VOTE

Body:
HTML, 52 bytes

I <c>V<e>o<c>t<e>e<c>d<style>*{color:red}c{color:0ff


答:
C, <s>82</s> <s>80</s> <s>78</s> <s>74</s> 54 bytes

Thanks to @WillihamTotland and @criptych for saving 2 bytes each!

f(){puts("␛[47;31mI␛[34m V␛[31mo␛[34mt␛[31me␛[34md");}
```
<p>Where the ␛s represent 0x1B bytes (escape key). As this code contains unprintable control characters, here is a reversible hexdump:</p>
```00000000: 6628 297b 7075 7473 2822 1b5b 3437 3b33  f(){puts(".[47;3
00000010: 316d 491b 5b33 346d 2056 1b5b 3331 6d6f  1mI.[34m V.[31mo
00000020: 1b5b 3334 6d74 1b5b 3331 6d65 1b5b 3334  .[34mt.[31me.[34
00000030: 6d64 2229 3b7d                           md");}
```

Output on my phone:

Title: GO OUT AND VOTE

Body:
C, <s>82</s> <s>80</s> <s>78</s> <s>74</s> 54 bytes

Thanks to @WillihamTotland and @criptych for saving 2 bytes each!

f(){puts("␛[47;31mI␛[34m V␛[31mo␛[34mt␛[31me␛[34md");}

Where the ␛s represent 0x1B bytes (escape key). As this code contains unprintable control characters, here is a reversible hexdump:

00000000: 6628 297b 7075 7473 2822 1b5b 3437 3b33  f(){puts(".[47;3
00000010: 316d 491b 5b33 346d 2056 1b5b 3331 6d6f  1mI.[34m V.[31mo
00000020: 1b5b 3334 6d74 1b5b 3331 6d65 1b5b 3334  .[34mt.[31me.[34
00000030: 6d64 2229 3b7d                           md");}

Output on my phone:


答:
Python, 91 bytes + termcolor

Not gonna win, but posted it for fun.

from termcolor import*
for c in'I Voted':cprint(c,'brleude'[ord(c)%2::2],'on_white',end='')
```

Half the credit goes to Sp3000.

Title: GO OUT AND VOTE

Body:
Python, 91 bytes + termcolor

Not gonna win, but posted it for fun.

from termcolor import*
for c in'I Voted':cprint(c,'brleude'[ord(c)%2::2],'on_white',end='')

Half the credit goes to Sp3000.


答:
Jolf, 53 bytes

```<code>"<z>I <w>V<z>o<w>t<z>e<w>d<style>w{ΞΩ4blue}z{ΞΩ4red
</code>```

There are unprintables. Try it here!

Jolf's output is HTML capable. I tried doing something clever like modulus 2 to decide color, but that only wound up longer (around 69 bytes). So, the output is in HTML.

Output:

(larger version)

Title: GO OUT AND VOTE

Body:
Jolf, 53 bytes

"<z>I <w>V<z>o<w>t<z>e<w>d<style>w{ΞΩ4blue}z{ΞΩ4red

There are unprintables. Try it here!

Jolf's output is HTML capable. I tried doing something clever like modulus 2 to decide color, but that only wound up longer (around 69 bytes). So, the output is in HTML.

Output:

(larger version)


答:
MATLAB, 74 bytes

We create a white 50x50 (one column for each state) background using imshow of an array of ones. We then display a text, using my trick of shortening property names to get the colours. Since the default font is not fixed width, the text is padded with spaces.

```<code>imshow(ones(50))
text(2,9,'I   o e','Co','r')
text(8,9,'V  t  d','Co','b')
</code>```

MATLAB, 99 bytes, fixed width font

The first version uses fiddling with spaces and coordinates to get a proper kerning on the default font, and might not display properly on your computer. Instead, we can use a fixed width font, like Courier (or, for some more bytes, FixedWidth which works on any system that has a fixed width font installed). This does come at the cost of quite a few extra bytes. We can mitigate this slightly by using a for loop to print the text. The text and corresponding colours are stored in a cell array. The background needs to be a little bit larger.

```<code>imshow(ones(80))
for y={'I  o e ','  V t d';'r','b'}
text(9,9,y{1},'Co',y{2},'FontN','Courier')
end
</code>```

Matlab, 80 bytes bonus edition

Sadly, underlined blue text is not allowed. Otherwise, this answer would have highlighted some interesting behaviour in MATLAB. You can print red text using fprintf(2,txt), and you can print blue underlined text with fprintf('txt'). Combining this works... sometimes. Completely at random, it may also create red underlined text. You can issue drawnow between consecutive f calls if this is the case on your system.

```<code>f=@(p)fprintf(2,'%s<a href>%s</a>',p(1:end-1),p(end));f('I V');f('ot');f('ed');fprintf('\n')
</code>```

Title: GO OUT AND VOTE

Body:
MATLAB, 74 bytes

We create a white 50x50 (one column for each state) background using imshow of an array of ones. We then display a text, using my trick of shortening property names to get the colours. Since the default font is not fixed width, the text is padded with spaces.

imshow(ones(50))
text(2,9,'I   o e','Co','r')
text(8,9,'V  t  d','Co','b')

MATLAB, 99 bytes, fixed width font

The first version uses fiddling with spaces and coordinates to get a proper kerning on the default font, and might not display properly on your computer. Instead, we can use a fixed width font, like Courier (or, for some more bytes, FixedWidth which works on any system that has a fixed width font installed). This does come at the cost of quite a few extra bytes. We can mitigate this slightly by using a for loop to print the text. The text and corresponding colours are stored in a cell array. The background needs to be a little bit larger.

imshow(ones(80))
for y={'I  o e ','  V t d';'r','b'}
text(9,9,y{1},'Co',y{2},'FontN','Courier')
end

Matlab, 80 bytes bonus edition

Sadly, underlined blue text is not allowed. Otherwise, this answer would have highlighted some interesting behaviour in MATLAB. You can print red text using fprintf(2,txt), and you can print blue underlined text with fprintf('<a href="">txt</a>'). Combining this works... sometimes. Completely at random, it may also create red underlined text. You can issue drawnow between consecutive f calls if this is the case on your system.

f=@(p)fprintf(2,'%s<a href>%s</a>',p(1:end-1),p(end));f('I V');f('ot');f('ed');fprintf('\n')


Title: GO OUT AND VOTE

Body:
sh, <s>61</s> 49 bytes

echo "[47;31;1mI [34mV[31mo[34mt[31me[34md"

Because this contains unprintables, here is a reversible xxd hexdump:
00000000: 6563 686f 2022 1b5b 3437 3b33 313b 316d  echo ".[47;31;1m
00000010: 4920 1b5b 3334 6d56 1b5b 3331 6d6f 1b5b  I .[34mV.[31mo.[
00000020: 3334 6d74 1b5b 3331 6d65 1b5b 3334 6d64  34mt.[31me.[34md
00000030: 22                                       "

Xterm(322)

Thanks to 4198 (manatwork) for -12 bytes.


答:
Python 2, <s>103</s> <s>94</s> 88 bytes

Solution without using regex

a,b=input(),""
for f in a:
 if ord(f)<58:b+=f
 elif b"":c,d=a.split(b);print c,b,d;break
```
<p>Simply extracts the numbers from the middle then slices the input using the number as an index. Requires quotes around the input but I didn't see anywhere that quotes are disallowed.</p>
<p>-9 by splitting a on the middle number then print the components with b in the middle</p>
<p>-6 Thanks to @Shebang</p>
<p>Test Cases</p>
```D:\>python codes.py
"UK7898S14"
UK 7898 S14

D:\>python codes.py
"cphDK1234CYELLOWS14QGOOD"
cphDK 1234 CYELLOWS14QGOOD
```

Title: Product catalog

Body:
Python 2, <s>103</s> <s>94</s> 88 bytes

Solution without using regex

a,b=input(),""
for f in a:
 if ord(f)<58:b+=f
 elif b"":c,d=a.split(b);print c,b,d;break

Simply extracts the numbers from the middle then slices the input using the number as an index. Requires quotes around the input but I didn't see anywhere that quotes are disallowed.

-9 by splitting a on the middle number then print the components with b in the middle

-6 Thanks to @Shebang

Test Cases

D:\>python codes.py
"UK7898S14"
UK 7898 S14

D:\>python codes.py
"cphDK1234CYELLOWS14QGOOD"
cphDK 1234 CYELLOWS14QGOOD


答:
C#, <s>154</s> 152 bytes

Golfed:

```<code>void F(int n){Console.Write($"{new string('#',n)}\n");for(int i=2;i<n;i++)Console.Write($"#{new string(' ',n-2)}#\n");Console.Write(new string('#',n));}
</code>```

Ungolfed:

```<code>    void F(int n)
    {
        Console.Write($"{new string('#', n)}\n");

        for (int i = 2; i < n; i++)
            Console.Write($"#{new string(' ', n - 2)}#\n");

        Console.Write(new string('#', n));
    }
</code>```

EDIT1: Loop range optimization.

Body:
I got this challenge from Codingame and am curious about better solutions than mine:

Given a width via standard input draw a hollow square of '#' in given width and length.

Example:

5 results in

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

I used python to solve this so i am particulary interested in other python code. But please feel free to post your solution in any language you want.

Body:
C#, <s>154</s> 152 bytes

Golfed:

void F(int n){Console.Write($"{new string('#',n)}\n");for(int i=2;i<n;i++)Console.Write($"#{new string(' ',n-2)}#\n");Console.Write(new string('#',n));}

Ungolfed:

    void F(int n)
    {
        Console.Write($"{new string('#', n)}\n");

        for (int i = 2; i < n; i++)
            Console.Write($"#{new string(' ', n - 2)}#\n");

        Console.Write(new string('#', n));
    }

EDIT1: Loop range optimization.


答:
Python 2, 40 Bytes

I don't know much Regex, but thankfully this problem is simple enough :) Seperates the input string into a list of length 3 which contains each part.

import re
lambda k:re.split('(\d+)',k,1)
```

Title: Product catalog


答:
PowerShell v2+, <s>71</s> <s>59</s> <s>57</s> 55 bytes

```<code>"I Voted"[0..6]|%{Write-Host -b w -n -f (9,12)[$_%2]$_}
</code>```

Saved two bytes thanks to @flashbang ... saved two more thanks to @ConnorLSW

Takes "I Voted" and turns it into a char-array, then loops |%{...}. Each letter, we execute Write-Host with the -background color to White, -noNewLine, and the -foreground color to be the appropriate index. This leverages the fact that odd ASCII values are Red, while even ASCII values are Blue via $_%2 as the index.

Console colors in PowerShell are very limited, so this is the closest approximation I could get. It would be golfier to use 4 (DarkRed) for the red, but it doesn't look right, so I'm sacrificing a couple bytes for the sake of color accuracy.

Below is the output, followed by the 16 available colors the console can display. Note that the background isn't truly white, since Microsoft in their wisdom opted to have the background colors ever-so-slightly-off from the foreground colors.

Title: GO OUT AND VOTE

Body:
PowerShell v2+, <s>71</s> <s>59</s> <s>57</s> 55 bytes

"I Voted"[0..6]|%{Write-Host -b w -n -f (9,12)[$_%2]$_}

Saved two bytes thanks to @flashbang ... saved two more thanks to @ConnorLSW

Takes "I Voted" and turns it into a char-array, then loops |%{...}. Each letter, we execute Write-Host with the -background color to White, -noNewLine, and the -foreground color to be the appropriate index. This leverages the fact that odd ASCII values are Red, while even ASCII values are Blue via $_%2 as the index.

Console colors in PowerShell are very limited, so this is the closest approximation I could get. It would be golfier to use 4 (DarkRed) for the red, but it doesn't look right, so I'm sacrificing a couple bytes for the sake of color accuracy.

Below is the output, followed by the 16 available colors the console can display. Note that the background isn't truly white, since Microsoft in their wisdom opted to have the background colors ever-so-slightly-off from the foreground colors.


答:
CJam / Fission, 22 bytes

```<code>"'!+OR'")5-"{'_'~}_~";
</code>```

Try it in CJam. Try it in Fission.

In CJam, this prints the standard Fission quine:

```<code>'!+OR"
</code>```

Try the Fission quine.

In Fission, this prints a "-less variant of the standard CJam quine:

```<code>{'_'~}_~
</code>```

Try the CJam quine.

This also works for 22 bytes (printing the same quines):

```<code>"& *NQ!":)R"{'_'~}_~";
</code>```

Explanation

In CJam:

```<code>"'!+OR'"    e# Push this string.
)           e# Pull off the last character.
5-          e# Subtract 5, turning ' into ".
"{'_'~}_~"  e# Push this string.
;           e# And discard it again.
</code>```

So at the end of the program, the stack contains the string "'!+OR" and the character ", both of which are implicitly printed.

In Fission, program flow starts at the R with a right-going atom. '" just changes the atoms mass, ), 5 and - are ignored for various reasons. Then the atom enters print mode at the " and prints {'_'~}_~. ; destroys the atom and terminates the program.

Title: The meta-polyglot quine

Body:
In my time on PPCG, I've noticed that quine problems and polyglot problems are quite popular. Also, meta-solutions to problems, that is, scripts which generate a program which is the solution to a problem, tend to get a lot of positive feedback from the community. Therefore, I have created this challenge, which implements these three ideas.

Your task then, reader and code-golf enthusiast, is to create as short as possible a script which can run in two languages A and B to generate quines for A and B. When your program is run in language A, it should generate a program that is a quine in language B but not in language A and vice versa. The languages A and B can be different version of the same language, provided you keep in mind that the generated quines should only work in one of the versions.

Keep in mind that the standard loopholes should be considered closed and only proper quines are allowed.

Good luck, fewest characters wins!

Body:
CJam / Fission, 22 bytes

"'!+OR'")5-"{'_'~}_~";

Try it in CJam. Try it in Fission.

In CJam, this prints the standard Fission quine:

'!+OR"

Try the Fission quine.

In Fission, this prints a "-less variant of the standard CJam quine:

{'_'~}_~

Try the CJam quine.

This also works for 22 bytes (printing the same quines):

"& *NQ!":)R"{'_'~}_~";

Explanation

In CJam:

"'!+OR'"    e# Push this string.
)           e# Pull off the last character.
5-          e# Subtract 5, turning ' into ".
"{'_'~}_~"  e# Push this string.
;           e# And discard it again.

So at the end of the program, the stack contains the string "'!+OR" and the character ", both of which are implicitly printed.

In Fission, program flow starts at the R with a right-going atom. '" just changes the atoms mass, ), 5 and - are ignored for various reasons. Then the atom enters print mode at the " and prints {'_'~}_~. ; destroys the atom and terminates the program.


答:
R, 113 85 81 74 73 55 bytes

Edit: Saved a bunch of bytes thanks to @rturnbull and @JDL

```<code>plot(8:1,0:7*0,pc=el(strsplit("detoV  I","")),co=2:1*2)
</code>```

The size of the output (and spacing etc) depends on the resolution of the currently open graphics device. Tested in RGui and RStudio on my monitor and produces:

Title: GO OUT AND VOTE

Body:
R, 113 85 81 74 73 55 bytes

Edit: Saved a bunch of bytes thanks to @rturnbull and @JDL

plot(8:1,0:7*0,pc=el(strsplit("detoV  I","")),co=2:1*2)

The size of the output (and spacing etc) depends on the resolution of the currently open graphics device. Tested in RGui and RStudio on my monitor and produces:


答:
SpecBAS - 57 bytes

```<code>1 INPUT n: a$="#"*n,n-=2,b$="#"+" "*n+"#"#13: ?a$'b$*n;a$
</code>```

? is shorthand for PRINT, #13 is carriage return which can be tacked on to the end of a string without needing a + to join them.

The apostrophe moves print cursor down one line.

Body:
SpecBAS - 57 bytes

1 INPUT n: a$="#"*n,n-=2,b$="#"+" "*n+"#"#13: ?a$'b$*n;a$

? is shorthand for PRINT, #13 is carriage return which can be tacked on to the end of a string without needing a + to join them.

The apostrophe moves print cursor down one line.


答:
Mathematica, 39 bytes

```<code>StringSplit[#,a:DigitCharacter..:>a,2]&
</code>```

Anonymous function. Takes a string as input, and returns a list of strings as output.

Title: Product catalog

Body:
This problem is about separating a string representing a product identifier into three components.

The first part consists of upper and lower letters of arbitrary length which represents the warehouse.

The second part is digits which represents the product number. This part is also of arbitrary length.

The last part is qualifiers as size and colours, and this part continues to the end of the string. The qualifiers are guaranteed to start with a capital letter and consist of alphanumeric characters.

Each part should be printed clearly separated. It is guaranteed that each part is non-empty.

The winner is the one who uses least bytes to solve this problem.

Example:

Input: UK7898S14

Output:

UK

7898

S14

Here UK is United Kingdom, 7898 is the product code, and S14 is size 14.

Example 2:

Input: cphDK1234CYELLOWS14QGOOD

Output:

cphDK

1234

CYELLOWS14QGOOD

Here cphDK is Copenhagen, Denmark, 1234 is the product code, CYELLOWS14QGOOD represents yellow colour, size 14, and good quality.

Body:
Mathematica, 39 bytes

StringSplit[#,a:DigitCharacter..:>a,2]&

Anonymous function. Takes a string as input, and returns a list of strings as output.


答:
Processing, <s>83</s> <s>85</s> 83 bytes

Had to increase byte count to include spaces to avoid overlapping letters

Then I reduced byte count by changing the positions and removing spaces

Processing is basically Java, but more artistic and less verbose (emphasis on less verbose).

```<code>background(255);fill(#ff0000);text("I   o e",2,9);fill(#0000ff);text("V  t d",9,9);
</code>```

Explanation:

```<code>background(255); //sets background colour to white
fill(#ff0000); //setting the text colour to red
text("I   o e",2,9); //Display text "I   o e" (in red) at position (2,9) [Origin is top left]
fill(#0000ff); //set the text colour to blue
text("V  t d"); //Display text "  V  t d" (in blue) at position (9,9)
</code>```

Title: GO OUT AND VOTE

Body:
Today is November 8th, 2016, Election Day in the United States of America.

If you are a U.S. citizen eligible to vote, then go out and vote if you haven't already before answering this challenge. Do not discuss who you voted for. It only matters that you voted.

If you are not a U.S. citizen or not eligible to vote, then, before answering this challenge, do the U.S. a favor by telling anyone you know who is an eligible citizen to go out and vote if they haven't already.

Challenge

Write a program that indicates that you voted, like a digital "I Voted" sticker.

It should take no input and must output in a reasonable way the phrase I Voted where the I, o, and e are red (#FF0000) and the V, t, and d are blue (#0000FF). The background must be white (#FFFFFF).

For example:

These colors are of course representative of the American flag (though not the official colors). Red comes first simply because it comes first in the common idiom "red white and blue".

To be valid, an answer must:

Use the colors specified in the arrangement specified.

Use a single legible font and font size. The example uses 72pt Times New Roman bold but any common font above 6pt is probably fine.

Have just the phrase I Voted on a single line, capitalized correctly, with a clear space between the two words. It shouldn't look like IVoted.

Not indicate who the answerer voted for or supports for president or any down-ballot races. Let's not start any internet debates. This is about celebrating voting, not candidates.

Any reasonable way of displaying or producing the output is valid, such as:

Drawing the text to an image that is then displayed, saved, or output raw.

Writing the text to a console using color formatting. In this case you may approximate pure red and blue if necessary, and it's ok if only the area directly behind the text can be made white.

Displaying the text on a WPF/Windows form.

Outputting an HTML/RTF/PDF file with the text.

Please post an image of your output.

The shortest answer in bytes wins.

Body:
Processing, <s>83</s> <s>85</s> 83 bytes

Had to increase byte count to include spaces to avoid overlapping letters

Then I reduced byte count by changing the positions and removing spaces

Processing is basically Java, but more artistic and less verbose (emphasis on less verbose).

background(255);fill(#ff0000);text("I   o e",2,9);fill(#0000ff);text("V  t d",9,9);

Explanation:

background(255); //sets background colour to white
fill(#ff0000); //setting the text colour to red
text("I   o e",2,9); //Display text "I   o e" (in red) at position (2,9) [Origin is top left]
fill(#0000ff); //set the text colour to blue
text("V  t d"); //Display text "  V  t d" (in blue) at position (9,9)


答:
LÖVE, <s>152 142</s> 136 bytes

Let's show some löve for a fun little prototyping language! It's not perfect for the task of golfing (c'mon, it's LUA based), but it's easy to write.

```<code>function love.draw()l=love.graphics
a=255
l.setBackgroundColor(a,a,a)s=l.setColor
p=l.print
s(a,0,0)p('I   o e')s(0,0,a)p('  V  t d')end
</code>```

Screenshot:

Fully ungolfed version:

```<code>function love.draw()
    love.graphics.setBackgroundColor(255,255,255)
    love.graphics.setColor(255,0,0)
    love.graphics.print('I   o e')
    love.graphics.setColor(0,0,255)
    love.graphics.print('  V  t d')
end
</code>```

Title: GO OUT AND VOTE

Body:
LÖVE, <s>152 142</s> 136 bytes

Let's show some löve for a fun little prototyping language! It's not perfect for the task of golfing (c'mon, it's LUA based), but it's easy to write.

function love.draw()l=love.graphics
a=255
l.setBackgroundColor(a,a,a)s=l.setColor
p=l.print
s(a,0,0)p('I   o e')s(0,0,a)p('  V  t d')end

Screenshot:

Fully ungolfed version:

function love.draw()
    love.graphics.setBackgroundColor(255,255,255)
    love.graphics.setColor(255,0,0)
    love.graphics.print('I   o e')
    love.graphics.setColor(0,0,255)
    love.graphics.print('  V  t d')
end


答:
Jelly / GolfScript, <s>18</s> 16 bytes

```<code>0000000: 3a 6e 22 ff cc cc 22 7d 7f fe 22 3a 6e 60 ff 3b  :n"..."}..":n`.;
</code>```

Verification

Testing all involved programs with the exact byte streams can only be done locally.

```<code>$ LANG=en_US # Latin-1. Jelly doesn't care about the exact encoding,
$            # as longs as it's not UTF-8.
$
$ xxd -g 1 mpquine
0000000: 3a 6e 22 ff cc cc 22 7d 7f fe 22 3a 6e 60 ff 3b  :n"..."}..":n`.;
$
$ jelly f mpquine | tee quine.gs | xxd -g 1
0000000: 22 3a 6e 60 22 3a 6e 60                          ":n`":n`
$ golfscript quine.gs | xxd -g 1
0000000: 22 3a 6e 60 22 3a 6e 60                          ":n`":n`
$ jelly f quine.gs 2> /dev/null | xxd -g 1
$
$ golfscript mpquine | tee quine.jelly | xxd -g 1
0000000: ff cc cc                                         ...
$ jelly f quine.jelly | xxd -g 1
0000000: ff cc cc                                         ...
$ golfscript quine.jelly | xxd -g 1
0000000: 0a
</code>```

Jelly

With Jelly's code page, the program looks as follows.

```<code>:n"”ṘṘ"}
“":n`”;
</code>```

This prints (Try it online!)

```<code>":n`":n`
</code>```

which is a quine in GolfScript (Try it online!), but a parser error in Jelly (Try it online!).

GolfScript

In Latin-1, the program looks as follows, with an unprintable DEL character between } and þ.

```<code>:n"ÿÌÌ"} þ":n`ÿ;
</code>```

This prints (Try it online!)

```<code>ÿÌÌ
</code>```

or, visualized with Jelly's code page,

```<code>”ṘṘ
</code>```

which is a quine in Jelly (Try it online!), but only prints a linefeed in GolfScript (Try it online!).

Title: The meta-polyglot quine

Body:
Jelly / GolfScript, <s>18</s> 16 bytes

0000000: 3a 6e 22 ff cc cc 22 7d 7f fe 22 3a 6e 60 ff 3b  :n"..."}..":n`.;

Verification

Testing all involved programs with the exact byte streams can only be done locally.

$ LANG=en_US # Latin-1. Jelly doesn't care about the exact encoding,
$            # as longs as it's not UTF-8.
$
$ xxd -g 1 mpquine
0000000: 3a 6e 22 ff cc cc 22 7d 7f fe 22 3a 6e 60 ff 3b  :n"..."}..":n`.;
$
$ jelly f mpquine | tee quine.gs | xxd -g 1
0000000: 22 3a 6e 60 22 3a 6e 60                          ":n`":n`
$ golfscript quine.gs | xxd -g 1
0000000: 22 3a 6e 60 22 3a 6e 60                          ":n`":n`
$ jelly f quine.gs 2> /dev/null | xxd -g 1
$
$ golfscript mpquine | tee quine.jelly | xxd -g 1
0000000: ff cc cc                                         ...
$ jelly f quine.jelly | xxd -g 1
0000000: ff cc cc                                         ...
$ golfscript quine.jelly | xxd -g 1
0000000: 0a

Jelly

With Jelly's code page, the program looks as follows.

:n"”ṘṘ"}
“":n`”;

This prints (Try it online!)

":n`":n`

which is a quine in GolfScript (Try it online!), but a parser error in Jelly (Try it online!).

GolfScript

In Latin-1, the program looks as follows, with an unprintable DEL character between } and þ.

:n"ÿÌÌ"} þ":n`ÿ;

This prints (Try it online!)

ÿÌÌ

or, visualized with Jelly's code page,

”ṘṘ

which is a quine in Jelly (Try it online!), but only prints a linefeed in GolfScript (Try it online!).


答:
Java, <s>322</s> <s>319</s> <s>318</s> <s>309</s> <s>304</s> <s>229</s> 217 bytes

-9 Bytes thanks to kevin.

-75 Bytes thanks to Angzuril, nice callout on the old awt classes, always forget those exist.

-12 Bytes thanks to user902383.

```<code>import java.awt.*;
void n(){new Frame(){{add(new Panel(){public void paint(Graphics g){int i=0;for(String c:"IVoted".split("")){g.setColor(i%2<1?Color.RED:Color.BLUE);g.drawString(c,i++*8,10);}}});setVisible(0<1);}};}
</code>```

Output:

Title: GO OUT AND VOTE

Body:
Java, <s>322</s> <s>319</s> <s>318</s> <s>309</s> <s>304</s> <s>229</s> 217 bytes

-9 Bytes thanks to kevin.

-75 Bytes thanks to Angzuril, nice callout on the old awt classes, always forget those exist.

-12 Bytes thanks to user902383.

import java.awt.*;
void n(){new Frame(){{add(new Panel(){public void paint(Graphics g){int i=0;for(String c:"IVoted".split("")){g.setColor(i%2<1?Color.RED:Color.BLUE);g.drawString(c,i++*8,10);}}});setVisible(0<1);}};}

Output:


答:
JavaScript, 71 bytes

```<code>console.log('%cI %cV%co%ct%ce%cd',r='color:red',b='color:blue',r,b,r,b)
</code>```

Makes use of console.log's ability to print in color. Doesn't work in a stack snippet so you should paste this answer to the console to test it.

Picture credits to @Mast

Title: GO OUT AND VOTE

Body:
JavaScript, 71 bytes

console.log('%cI %cV%co%ct%ce%cd',r='color:red',b='color:blue',r,b,r,b)

Makes use of console.log's ability to print in color. Doesn't work in a stack snippet so you should paste this answer to the console to test it.

Picture credits to @Mast


答:
Racket 274 bytes

```<code>(let((g 0)(j'())(k'())(l'())(m list->string)(r reverse)(n char-numeric?)(c cons))(for((i(string->list s)))
(when(and(= g 0)(n i))(set! g 1))(when(and(= g 1)(not(n i)))(set! g 2))(match g[0(set! j(c i j))]
[1(set! k(c i k))][2(set! l(c i l))]))(list(m(r j))(m(r k))(m(r l))))
</code>```

Ungolfed:

```<code>(define (f s)
  (let ((g 0)
        (j '())
        (k '())
        (l '())
        (m list->string)
        (r reverse)
        (n char-numeric?)
        (c cons))
    (for ((i (string->list s)))
      (when (and (= g 0) (n i)) (set! g 1)  )
      (when (and (= g 1) (not (n i))) (set! g 2) )
      (match g
        [0 (set! j (c i j))]
        [1 (set! k (c i k))]
        [2 (set! l (c i l))]))
    (list (m (r j)) (m (r k)) (m (r l)))))
</code>```

Testing:

```<code>(f "UK7898S14")
(f "cphDK1234CYELLOWS14QGOOD")
</code>```

Output:

```<code>'("UK" "7898" "S14")
'("cphDK" "1234" "CYELLOWS14QGOOD")
</code>```

Title: Product catalog

Body:
Racket 274 bytes

(let((g 0)(j'())(k'())(l'())(m list->string)(r reverse)(n char-numeric?)(c cons))(for((i(string->list s)))
(when(and(= g 0)(n i))(set! g 1))(when(and(= g 1)(not(n i)))(set! g 2))(match g[0(set! j(c i j))]
[1(set! k(c i k))][2(set! l(c i l))]))(list(m(r j))(m(r k))(m(r l))))

Ungolfed:

(define (f s)
  (let ((g 0)
        (j '())
        (k '())
        (l '())
        (m list->string)
        (r reverse)
        (n char-numeric?)
        (c cons))
    (for ((i (string->list s)))
      (when (and (= g 0) (n i)) (set! g 1)  )
      (when (and (= g 1) (not (n i))) (set! g 2) )
      (match g
        [0 (set! j (c i j))]
        [1 (set! k (c i k))]
        [2 (set! l (c i l))]))
    (list (m (r j)) (m (r k)) (m (r l)))))

Testing:

(f "UK7898S14")
(f "cphDK1234CYELLOWS14QGOOD")

Output:

'("UK" "7898" "S14")
'("cphDK" "1234" "CYELLOWS14QGOOD")


问:
Fizz Buzz for Turtles

Problem Description

Imagine you're a turtle on a grid.  You're given two numbers f and b, and you're facing east. You perform a march across the grid, counting each of the cells you encounter, according to the following rules:

By default, you write the count to the cell you're in, then walk forward.

If the count is divisible by f, you write F to the cell you're in, then turn right, then walk forward.

If the count is divisible by b, you write B to the cell you're in, then turn left, then walk forward.

If the count is divisible by both f and b, you write FB to the cell you're in, then walk forward.

If you reach a square you've already been to, you stop.

For example, following these rules using f = 3 and b = 5 will generate a pattern like this:

```<code>    F 28 29 FB  1  2  F
   26                 4
 F  B                 B  F
23                       7
22                       8
 F  B                 B  F
   19                11
    F 17 16 FB 14 13  F
</code>```

The challenge

Write a program or function that accepts two numbers as input, corresponding to f and b, and produces as output the pattern for these numbers given by the rules above.

Formatting requirements:

Each cell is two characters wide

Cell contents are right aligned within these two characters

Cells on the same row are delimited by a space

The first column of cells must contain a non-empty cell

All rows must contain non-empty cells

Trailing whitespace is not required, but allowed

However, the total width of each row must not exceed 3 times the number of non-empty columns

Your code must work for provided test cases.

Standard loopholes are disallowed.

This is code golf; shortest answer in bytes wins.

Test cases

(f=3, b=5 case repeated here as a courtesy convenience).

```<code>f=3, b=5 ->
    F 28 29 FB  1  2  F
   26                 4
 F  B                 B  F
23                       7
22                       8
 F  B                 B  F
   19                11
    F 17 16 FB 14 13  F

f=4, b=10 ->
 F 25 26 27  F
23          29
22        1  2  3  F
21                 5
FB                 6
19                 7
18           B  9  F
17          11
 F 15 14 13  F

f=3, b=11 ->
 F 16 17  F
14       19
13     1  2  F
 F  B        4
   10        5
    F  8  7  F

f=5, b=9 ->
    F 41 42 43 44  1  2  3  4  F
   39                          6
   38                          7
   37                          8
 F  B                          B  F
34                               11
33                               12
32                               13
31                               14
 F 29 28  B              B 17 16  F
         26             19
          F 24 23 22 21  F

f=5, b=13 ->
    F 31 32 33 34  F
   29             36
   28        1  2  3  4  F
   27                    6
 F  B                    7
24                       8
23                       9
22              B 12 11  F
21             14
 F 19 18 17 16  F
</code>```

答:
Excel VBA, <s>284</s> <s>278</s> <s>277</s> <s>261</s> <s>259</s> <s> 255</s> <s>254</s> <s>253</s> 251 Bytes

Subroutine that takes input as values, F, B and outputs to cells on the Sheets(1) Object (which is restricted to the Sheets(1) object to save 2 Bytes)

Sub G(F,B)
Set A=Sheet1
R=99:C=R
Do
I=I+1
Y=Cells(R,C)
If Y<>""Then A.UsedRange.Cut:[A1].Select:A.Paste:End
If I Mod F=0Then Y="F":J=J+1
If I Mod B=0Then Y=Y+"B":J=J+3
Cells(R,C)=IIf(Y="",i,Y)
K=J Mod 4
If K Mod 2Then R=R-K+2 Else C=C+1-K
Loop
End Sub
```

<h3>Usage:</h3>

<pre class="lang-vb prettyprint-override"><code>Call G(3, 4)
</code>```

Title: Fizz Buzz for Turtles

Body:
Excel VBA, <s>284</s> <s>278</s> <s>277</s> <s>261</s> <s>259</s> <s> 255</s> <s>254</s> <s>253</s> 251 Bytes

Subroutine that takes input as values, F, B and outputs to cells on the Sheets(1) Object (which is restricted to the Sheets(1) object to save 2 Bytes)

Sub G(F,B)
Set A=Sheet1
R=99:C=R
Do
I=I+1
Y=Cells(R,C)
If Y<>""Then A.UsedRange.Cut:[A1].Select:A.Paste:End
If I Mod F=0Then Y="F":J=J+1
If I Mod B=0Then Y=Y+"B":J=J+3
Cells(R,C)=IIf(Y="",i,Y)
K=J Mod 4
If K Mod 2Then R=R-K+2 Else C=C+1-K
Loop
End Sub

Usage:

Call G(3, 4)


答:
LaTeX, <s>147</s> 126 bytes

```<code>\documentclass{proc}\input color\begin{document}\def\z{\color{red}}\def\y{\color{blue}}\z I \y V\z o\y t\z e\y d\end{document}
</code>```

Saved 21 bytes and got better kerning thanks to @AndreïKostyrka.

This prints an a4 page with this on the first line (note that this also prints page 1 on the bottom):

Title: GO OUT AND VOTE

Body:
LaTeX, <s>147</s> 126 bytes

\documentclass{proc}\input color\begin{document}\def\z{\color{red}}\def\y{\color{blue}}\z I \y V\z o\y t\z e\y d\end{document}

Saved 21 bytes and got better kerning thanks to @AndreïKostyrka.

This prints an a4 page with this on the first line (note that this also prints page 1 on the bottom):