答:
sed / Hexagony 251 Bytes

```<code>/$/cThis program wasn't written in sed, it was built for Hexagony!
#...>32;p;r;o;g;r;\+/;a;w;23+;m;a<.;.>s;n;+39;t;+32\s/;n;e;;t;i;r;w;<. |.>+32;i;n;+32;H;e\ ;/4+;y;n;o;g;a;x;< i>4;+32;i;t;+32;\;/u;b;23+;s;a;w<h>;i;l;t;+32;f\;/;s;23+;r;o;< T>e;d;+33;@
</code>```

sed: Try it Online!

Hexagony: Try it Online!

In sed, it prints the correct string if it matches the empty string at the end (always). The second line is a comment. This does require a string on STDIN, but it can be empty (allowed based on this consensus).

Example:

```<code>echo '' | sed -f whatLanguage.sed
</code>```

In Hexagony, the first / redirects to the bottom left, it follows the left side up to where the sed part starts, then just wraps left to right, down a line, right to left, down a line, and so on. The expanded hex looks like this:

```<code>         / $ / c T h i s p r
        o g r a m w a s n ' t
       w r i t t e n i n s e d
      , i t w a s b u i l t f o
     r H e x a g o n y ! # . . .
    > 3 2 ; p ; r ; o ; g ; r ; \
   + / ; a ; w ; 2 3 + ; m ; a < .
  ; . > s ; n ; + 3 9 ; t ; + 3 2 \
 s / ; n ; e ; ; t ; i ; r ; w ; < .
| . > + 3 2 ; i ; n ; + 3 2 ; H ; e \
 ; / 4 + ; y ; n ; o ; g ; a ; x ; <
  i > 4 ; + 3 2 ; i ; t ; + 3 2 ; \
   ; / u ; b ; 2 3 + ; s ; a ; w <
    h > ; i ; l ; t ; + 3 2 ; f \
     ; / ; s ; 2 3 + ; r ; o ; <
      T > e ; d ; @ . . . . . .
       . . . . . . . . . . . .
        . . . . . . . . . . .
         . . . . . . . . . .
</code>```

Title: I'm not the language you're looking for!

Body:
Isn't it annoying when you find a piece of code and you don't know what language it was written in? This challenge attempts to somewhat solve this.

Challenge

You will have to write a program that when run in two different languages, will output the string:

This program wasn't written in <language program compiled/interpreted in>, it was built for <other language the program can be run in>!

In the output, language names should have official capitalization. eg: CJam, C++

Neither program should take any input from the user.

When run in both languages, output should be to stdout or equivalent.

There should be no output to stderr in either program.

You may use comments in either language.

Two different versions of the same language count as different languages.

If this is done, the program should output the major version number, and if running on two different minor versions, should report the minor version also.

You should not use prebuilt version functions (this includes variables that have already been evaluated at runtime).

Example output:

Perl and Ruby:

Perl: This program wasn't written in Perl, it was built for Ruby!

Ruby: This program wasn't written in Ruby, it was built for Perl!

Python and C:

Python: This program wasn't written in Python, it was built for C!

C: This program wasn't written in C, it was built for Python!

Python 2 and Python 3:

Python 2: This program wasn't written in Python 2, it was built for Python 3!

Python 3: This program wasn't written in Python 3, it was built for Python 2!

Python 2.4 and Python 2.7:

Python 2.4: This program wasn't written in Python 2.4, it was built for Python 2.7!

Python 2.7: This program wasn't written in Python 2.7, it was built for Python 2.4!

This is code golf so the shortest code in bytes wins.

Body:
sed / Hexagony 251 Bytes

/$/cThis program wasn't written in sed, it was built for Hexagony!
#...>32;p;r;o;g;r;\+/;a;w;23+;m;a<.;.>s;n;+39;t;+32\s/;n;e;;t;i;r;w;<. |.>+32;i;n;+32;H;e\ ;/4+;y;n;o;g;a;x;< i>4;+32;i;t;+32;\;/u;b;23+;s;a;w<h>;i;l;t;+32;f\;/;s;23+;r;o;< T>e;d;+33;@

sed: Try it Online!

Hexagony: Try it Online!

In sed, it prints the correct string if it matches the empty string at the end (always). The second line is a comment. This does require a string on STDIN, but it can be empty (allowed based on this consensus).

Example:

echo '' | sed -f whatLanguage.sed

In Hexagony, the first / redirects to the bottom left, it follows the left side up to where the sed part starts, then just wraps left to right, down a line, right to left, down a line, and so on. The expanded hex looks like this:

         / $ / c T h i s p r
        o g r a m w a s n ' t
       w r i t t e n i n s e d
      , i t w a s b u i l t f o
     r H e x a g o n y ! # . . .
    > 3 2 ; p ; r ; o ; g ; r ; \
   + / ; a ; w ; 2 3 + ; m ; a < .
  ; . > s ; n ; + 3 9 ; t ; + 3 2 \
 s / ; n ; e ; ; t ; i ; r ; w ; < .
| . > + 3 2 ; i ; n ; + 3 2 ; H ; e \
 ; / 4 + ; y ; n ; o ; g ; a ; x ; <
  i > 4 ; + 3 2 ; i ; t ; + 3 2 ; \
   ; / u ; b ; 2 3 + ; s ; a ; w <
    h > ; i ; l ; t ; + 3 2 ; f \
     ; / ; s ; 2 3 + ; r ; o ; <
      T > e ; d ; @ . . . . . .
       . . . . . . . . . . . .
        . . . . . . . . . . .
         . . . . . . . . . .


问:
The Rule of Thumb for Title Capitalization
According to this site a general rule recommended by The U.S. Government Printing Office Style Manual is

Capitalize all words in titles of publications and documents, except
  a, an, the, at, by, for, in, of, on, to, up, and, as, but, or, and
  nor.

This might not be true as I'm unable to find such a recommendation in the Style Manual, but let's use this rule anyway.

The Challenge

Given an input string consisting of lower case words delimited by spaces, output the capitalization of the string according to the following rules

The first and last word is capitalized.

All other words are capitalized, except a, an, the, at, by, for, in, of, on, to, up, and, as, but, or, and nor.

The input string will contain at least one word and each word contains at least one letter and only characters from a to z.

This is a code golf challenge, so try to use as few bytes as possible in the language of your choice. You may write a full program or a function to accomplish the task.

Testcases

```<code>"the rule of thumb for title capitalization" -> "The Rule of Thumb for Title Capitalization"
"programming puzzles and code golf" -> "Programming Puzzles and Code Golf"
"the many uses of the letter a" -> "The Many Uses of the Letter A"
"title" -> "Title"
"and and and" -> "And and And"
"a an and as at but by for in nor of on or the to up" -> "A an and as at but by for in nor of on or the to Up"
"on computable numbers with an application to the entscheidungsproblem" -> "On Computable Numbers With an Application to the Entscheidungsproblem"
</code>```

答:
Groovy, 131 129

Two bytes saved thanks to carusocomputing

```<code>{it.split()*.with{a->a in "a an the at by for in of on to up and as but or nor".split()?a:a.capitalize()}.join(" ").capitalize()}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Groovy, 131 129

Two bytes saved thanks to carusocomputing

{it.split()*.with{a->a in "a an the at by for in of on to up and as but or nor".split()?a:a.capitalize()}.join(" ").capitalize()}


答:
GNU sed <s>81 74</s> 73 Bytes

Includes +1 for -r

```<code>s/\b./\u&/g
:;s/.(And?|A[st]?|The|By|But|[FN]or|In|O[fnr]|To|Up) /\L&/;t
</code>```

The first line capitalizes the first letter of every word. The second switches all of the required words back to lowercase.

Try it Online!

Body:
According to this site a general rule recommended by The U.S. Government Printing Office Style Manual is

Capitalize all words in titles of publications and documents, except
  a, an, the, at, by, for, in, of, on, to, up, and, as, but, or, and
  nor.

This might not be true as I'm unable to find such a recommendation in the Style Manual, but let's use this rule anyway.

The Challenge

Given an input string consisting of lower case words delimited by spaces, output the capitalization of the string according to the following rules

The first and last word is capitalized.

All other words are capitalized, except a, an, the, at, by, for, in, of, on, to, up, and, as, but, or, and nor.

The input string will contain at least one word and each word contains at least one letter and only characters from a to z.

This is a code golf challenge, so try to use as few bytes as possible in the language of your choice. You may write a full program or a function to accomplish the task.

Testcases

```<code>"the rule of thumb for title capitalization" -> "The Rule of Thumb for Title Capitalization"
"programming puzzles and code golf" -> "Programming Puzzles and Code Golf"
"the many uses of the letter a" -> "The Many Uses of the Letter A"
"title" -> "Title"
"and and and" -> "And and And"
"a an and as at but by for in nor of on or the to up" -> "A an and as at but by for in nor of on or the to Up"
"on computable numbers with an application to the entscheidungsproblem" -> "On Computable Numbers With an Application to the Entscheidungsproblem"
</code>```

Body:
GNU sed <s>81 74</s> 73 Bytes

Includes +1 for -r

s/\b./\u&/g
:;s/.(And?|A[st]?|The|By|But|[FN]or|In|O[fnr]|To|Up) /\L&/;t

The first line capitalizes the first letter of every word. The second switches all of the required words back to lowercase.

Try it Online!


答:
PHP, 158 Bytes

10 Bytes saved by @Titus

```<code>foreach($w=explode(" ",$argv[1])as$k=>$v)echo" "[!$k],$k&&$k+1<count($w)&&preg_match("#^(a[snt]?|and|[fn]or|up|by|but|the|to|in|o[rnf])$#",$v)?$v:ucfirst($v);
</code>```

Previous version PHP, 174 Bytes

```<code>foreach($w=explode(" ",$argv[1])as$k=>$v)$k&&$k+1<count($w)&&in_array($v,[a,an,the,at,by,"for",in,of,on,to,up,"and","as",but,"or",nor])?:$w[$k]=ucfirst($v);echo join(" ",$w);
</code>```

Title: The Rule of Thumb for Title Capitalization

Body:
PHP, 158 Bytes

10 Bytes saved by @Titus

foreach($w=explode(" ",$argv[1])as$k=>$v)echo" "[!$k],$k&&$k+1<count($w)&&preg_match("#^(a[snt]?|and|[fn]or|up|by|but|the|to|in|o[rnf])$#",$v)?$v:ucfirst($v);

Previous version PHP, 174 Bytes

foreach($w=explode(" ",$argv[1])as$k=>$v)$k&&$k+1<count($w)&&in_array($v,[a,an,the,at,by,"for",in,of,on,to,up,"and","as",but,"or",nor])?:$w[$k]=ucfirst($v);echo join(" ",$w);


答:
05AB1E, <s>68</s> 61 bytes

Saved 7 bytes thanks to Adnan

```<code>™ð¡Dg<UvyN__NXQ_“a€¤€€€›€‹€‡€†€‚€‰€„€¾€ƒ€œ€³€—š¯“#™yå&&il})ðý
</code>```

Try it online!

Explanation

“a€¤€€€›€‹€‡€†€‚€‰€„€¾€ƒ€œ€³€—š¯“ is a dictionary string translated as a an the at by for in of on to up and as but or nor.

```<code>™                          # title case input string
ð¡                         # split on spaces
Dg<U                       # store index of last word in X

vy                         # for each word
  N__                      # is it not first index?
     NXQ_                  # is it not last index
         “...“             # the compressed string
              #            # split on spaces
               ™           # convert to title case
                yå         # is current word in this list?
                  &&       # and the 3 previous conditions together
                    il     # if all are true, convert to lower case
                      }    # end loop
)ðý                        # wrap stack in list and join by spaces
</code>```

Body:
05AB1E, <s>68</s> 61 bytes

Saved 7 bytes thanks to Adnan

™ð¡Dg<UvyN__NXQ_“a€¤€€€›€‹€‡€†€‚€‰€„€¾€ƒ€œ€³€—š¯“#™yå&&il})ðý

Try it online!

Explanation

“a€¤€€€›€‹€‡€†€‚€‰€„€¾€ƒ€œ€³€—š¯“ is a dictionary string translated as a an the at by for in of on to up and as but or nor.

™                          # title case input string
ð¡                         # split on spaces
Dg<U                       # store index of last word in X

vy                         # for each word
  N__                      # is it not first index?
     NXQ_                  # is it not last index
         “...“             # the compressed string
              #            # split on spaces
               ™           # convert to title case
                yå         # is current word in this list?
                  &&       # and the 3 previous conditions together
                    il     # if all are true, convert to lower case
                      }    # end loop
)ðý                        # wrap stack in list and join by spaces


答:
JavaScript (ES6), <s>141</s> <s>138</s> <s>135</s> 133 bytes

Saved 3 bytes thanks to mbomb007

s=>s.replace(/(\w+)( ?)/g,(a,w,n,i)=>i&&n&&/^(a[nst]?|the|by|in|of|on|to|up|and|but|[fn]?or)$/.exec(w)?a:a[0].toUpperCase()+a.slice(1))
```

<h3>Test cases</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(/(\w)(\w*)( ?)/g,(a,l,w,n,i)=>i&&n&&/^(a[nst]?|the|by|in|of|on|to|up|and|but|[fn]?or)$/.exec(l+w)?a:l.toUpperCase()+w+n)

console.log(f("the rule of thumb for title capitalization"));
console.log(f("programming puzzles and code golf"));
console.log(f("the many uses of the letter a"));
console.log(f("title"));
console.log(f("and and and"));
console.log(f("a an and as at but by for in nor of on or the to up"));
console.log(f("on computable numbers with an application to the entscheidungsproblem"));</code>```

Body:
JavaScript (ES6), <s>141</s> <s>138</s> <s>135</s> 133 bytes

Saved 3 bytes thanks to mbomb007

s=>s.replace(/(\w+)( ?)/g,(a,w,n,i)=>i&&n&&/^(a[nst]?|the|by|in|of|on|to|up|and|but|[fn]?or)$/.exec(w)?a:a[0].toUpperCase()+a.slice(1))

Test cases

let f =

s=>s.replace(/(\w)(\w*)( ?)/g,(a,l,w,n,i)=>i&&n&&/^(a[nst]?|the|by|in|of|on|to|up|and|but|[fn]?or)$/.exec(l+w)?a:l.toUpperCase()+w+n)

console.log(f("the rule of thumb for title capitalization"));
console.log(f("programming puzzles and code golf"));
console.log(f("the many uses of the letter a"));
console.log(f("title"));
console.log(f("and and and"));
console.log(f("a an and as at but by for in nor of on or the to up"));
console.log(f("on computable numbers with an application to the entscheidungsproblem"));


问:
Print some JSON
This challenge is straightforward, but hopefully, there are plenty of avenues you can approach it:

You need to print/return a valid JSON object of at least 15 characters, not counting unessential whitespace.  Your program should work without any input.

In the interest of clarity, a JSON object starts and ends with curly braces {}, and contains zero or more key:value pairs separated by commas.  The full JSON specification can be found at json.org, and the output of your code must pass this validator.

Therefore, any of the following would not be valid:

```<code>4                               //Too short, not an object
"really, really long string"    //A string, not an object
["an","array","of","values"]    //An array is not a JSON object
{"this":4      }                //You can't count unessential whitespace
{"1":1,"2":3}                   //Too short
{"a really long string"}        //Not valid JSON, it needs a value
{'single-quoted':3}             //JSON requires double-quotes for strings
</code>```

However, the following would be valid:

```<code>{"1":1,"2":2,"3":3,"4":4}       //Long enough
{"whitespace      ":4}          //This whitespace isn't unessential
</code>```

Non-programming languages are allowed on this challenge.  You may return a string from a function, or print it out.  This is a code-golf, so answer it with as little code as possible!

答:
Javascript, 14 bytes

```<code>'{"":'+1e9+'}'
</code>```

Gives:

```<code>{"":1000000000}
</code>```

I know that this doesn't actually print out anything, it merely returns. But so do all other Javascript solutions here.

Title: Print some JSON

Body:
Javascript, 14 bytes

'{"":'+1e9+'}'

Gives:

{"":1000000000}

I know that this doesn't actually print out anything, it merely returns. But so do all other Javascript solutions here.


问:
Draw an alphabet party hat
Your task is to print this exact text:

```<code>            z
            yz
           xyz
           wxyz
          vwxyz
          uvwxyz
         tuvwxyz
         stuvwxyz
        rstuvwxyz
        qrstuvwxyz
       pqrstuvwxyz
       opqrstuvwxyz
      nopqrstuvwxyz
      mnopqrstuvwxyz
     lmnopqrstuvwxyz
     klmnopqrstuvwxyz
    jklmnopqrstuvwxyz
    ijklmnopqrstuvwxyz
   hijklmnopqrstuvwxyz
   ghijklmnopqrstuvwxyz
  fghijklmnopqrstuvwxyz
  efghijklmnopqrstuvwxyz
 defghijklmnopqrstuvwxyz
 cdefghijklmnopqrstuvwxyz
bcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
</code>```

Case does not matter.

Remember, this is code-golf, so the code with the smallest number of bytes wins.

Title: Draw an alphabet party hat

Body:
Ruby, 64 bytes

(0..26).each{|x|puts' '*(12-x/2)+('a'..'z').to_a[~x..-1].join()}


答:
QBIC, 57 bytes

```<code>[25,0,-1|Y=Z[1,a/2|Y=Y+@ |]X=Z[a,25|X=X+$CHR$(65+|c)]?Y+X
</code>```

This one works surprisingly well with QBIC' FOR loops.
Explanation (of previous version - same principle applies):

```<code>[26,1,-1|          Loops from 26 to 1, decrementing 'a'
                   'a' is used to determine the number of spaces per line and the last letter we want to print
Y=Z                Z is always an empty string in this program,
                   Y will hold the spaces we need to center this line
[1,a/2|Y=Y+@ |]    Add a space to Y equal to half the value of 'a', giving us a center alignment
X=Z                X holds the characters we need on this line, reset it
[a,26|             FOR c = a to 26 --> loop over the last part of the alphabet
X=X+$CHR$(64+|c)]  Convert c+64 to ASCII and append
?Y+X               Print the spaces and the letters

<outer FOR loop is closed by QBIC>
</code>```

Output:

```<code>            Z
            YZ
           XYZ
           WXYZ
          VWXYZ
          UVWXYZ
         TUVWXYZ
         STUVWXYZ
        RSTUVWXYZ
        QRSTUVWXYZ
       PQRSTUVWXYZ
       OPQRSTUVWXYZ
      NOPQRSTUVWXYZ
      MNOPQRSTUVWXYZ
     LMNOPQRSTUVWXYZ
     KLMNOPQRSTUVWXYZ
    JKLMNOPQRSTUVWXYZ
    IJKLMNOPQRSTUVWXYZ
   HIJKLMNOPQRSTUVWXYZ
   GHIJKLMNOPQRSTUVWXYZ
  FGHIJKLMNOPQRSTUVWXYZ
  EFGHIJKLMNOPQRSTUVWXYZ
 DEFGHIJKLMNOPQRSTUVWXYZ
 CDEFGHIJKLMNOPQRSTUVWXYZ
BCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
</code>```

Title: Draw an alphabet party hat

Body:
Your task is to print this exact text:

```<code>            z
            yz
           xyz
           wxyz
          vwxyz
          uvwxyz
         tuvwxyz
         stuvwxyz
        rstuvwxyz
        qrstuvwxyz
       pqrstuvwxyz
       opqrstuvwxyz
      nopqrstuvwxyz
      mnopqrstuvwxyz
     lmnopqrstuvwxyz
     klmnopqrstuvwxyz
    jklmnopqrstuvwxyz
    ijklmnopqrstuvwxyz
   hijklmnopqrstuvwxyz
   ghijklmnopqrstuvwxyz
  fghijklmnopqrstuvwxyz
  efghijklmnopqrstuvwxyz
 defghijklmnopqrstuvwxyz
 cdefghijklmnopqrstuvwxyz
bcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
</code>```

Case does not matter.

Remember, this is code-golf, so the code with the smallest number of bytes wins.

Body:
QBIC, 57 bytes

[25,0,-1|Y=Z[1,a/2|Y=Y+@ |]X=Z[a,25|X=X+$CHR$(65+|c)]?Y+X

This one works surprisingly well with QBIC' FOR loops.
Explanation (of previous version - same principle applies):

[26,1,-1|          Loops from 26 to 1, decrementing 'a'
                   'a' is used to determine the number of spaces per line and the last letter we want to print
Y=Z                Z is always an empty string in this program,
                   Y will hold the spaces we need to center this line
[1,a/2|Y=Y+@ |]    Add a space to Y equal to half the value of 'a', giving us a center alignment
X=Z                X holds the characters we need on this line, reset it
[a,26|             FOR c = a to 26 --> loop over the last part of the alphabet
X=X+$CHR$(64+|c)]  Convert c+64 to ASCII and append
?Y+X               Print the spaces and the letters

<outer FOR loop is closed by QBIC>

Output:

            Z
            YZ
           XYZ
           WXYZ
          VWXYZ
          UVWXYZ
         TUVWXYZ
         STUVWXYZ
        RSTUVWXYZ
        QRSTUVWXYZ
       PQRSTUVWXYZ
       OPQRSTUVWXYZ
      NOPQRSTUVWXYZ
      MNOPQRSTUVWXYZ
     LMNOPQRSTUVWXYZ
     KLMNOPQRSTUVWXYZ
    JKLMNOPQRSTUVWXYZ
    IJKLMNOPQRSTUVWXYZ
   HIJKLMNOPQRSTUVWXYZ
   GHIJKLMNOPQRSTUVWXYZ
  FGHIJKLMNOPQRSTUVWXYZ
  EFGHIJKLMNOPQRSTUVWXYZ
 DEFGHIJKLMNOPQRSTUVWXYZ
 CDEFGHIJKLMNOPQRSTUVWXYZ
BCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ


问:
Capitalize first letter of each word of input
This is a relatively quick one, but I'm sure you'll like it.

Codegolf a program that will take input in the form of a sentence and then provide the output with the first letter capitalized in each word.

Rules:

Submissions may not be in the form of a function. So no:

function x(y){z=some_kind_of_magic(y);return z;} as your final answer... Your code must show that it takes input, and provides output.

The code must preserve any other capital letters the input has. So

```<code>eCommerce and eBusiness are cool, don't you agree, Richard III?
</code>```

will be rendered as

```<code>ECommerce And EBusiness Are Cool, Don't You Agree, Richard III?
</code>```

Some of you may be thinking, "Easy, I'll just use regex!" and so using the native regex in your chosen golfing language will incur a 30 character penalty which will be applied to your final code count. Evil laugh

A "word" in this case is anything separated by a space. Therefore palate cleanser is two words, whereas pigeon-toed is considered one word. if_you_love_her_then_you_should_put_a_ring_on_it is considered one word. If a word starts with a non-alphabetical character, the word is preserved, so _this after rendering remains as _this. (Kudos to Martin Buttner for pointing this test case out).

4b. There is no guarantee that words in the input phrase will be separated by a single space.

Test Case, (please use to test your code):

Input:

```<code>eCommerce rocks. crazyCamelCase stuff. _those  pigeon-toed shennanigans. Fiery trailblazing 345 thirty-two Roger. The quick brown fox jumped over the lazy dogs. Clancy Brown would have been cool as Lex Luthor. good_bye
</code>```

Output:

```<code>ECommerce Rocks. CrazyCamelCase Stuff. _those  Pigeon-toed Shennanigans. Fiery Trailblazing 345 Thirty-two Roger. The Quick Brown Fox Jumped Over The Lazy Dogs. Clancy Brown Would Have Been Cool As Lex Luthor. Good_bye
</code>```

This is code golf, shortest code wins...

Good luck...

答:
s-lang, 8 bytes + 30 = 38

```<code>c![[^ ]*
</code>```

s-lang

Procedure:

Capitalize the first letter of every range matched by the regex.

Any number of Every character not in Space.

Body:
s-lang, 8 bytes + 30 = 38

c![[^ ]*

s-lang

Procedure:

Capitalize the first letter of every range matched by the regex.

Any number of Every character not in Space.


答:
Retina, <s>69</s> 66 bytes

Capitalize the first letter of every word, then change the selected words to lowercase if they're not the first or last word. There's a space at the end of the last line.

```<code>T`l`L`\b.
+T`L`l` (And?|A[st]?|The|By|But|[FN]or|In|O[fnr]|To|Up)
</code>```

Try it online

This also works with a . instead of the first space.

There are a lot of regexes with the same length, but I can't find a way to trim it anymore...

Body:
Retina, <s>69</s> 66 bytes

Capitalize the first letter of every word, then change the selected words to lowercase if they're not the first or last word. There's a space at the end of the last line.

T`l`L`\b.
+T`L`l` (And?|A[st]?|The|By|But|[FN]or|In|O[fnr]|To|Up)

Try it online

This also works with a . instead of the first space.

There are a lot of regexes with the same length, but I can't find a way to trim it anymore...


答:
Ruby (cheap), 22 bytes

```<code>->{'{"aaaa":"bbbbb"}'}
</code>```

Lambda function that returns the String object '{"aaaa":"bbbbb"}'

Title: Print some JSON

Body:
This challenge is straightforward, but hopefully, there are plenty of avenues you can approach it:

You need to print/return a valid JSON object of at least 15 characters, not counting unessential whitespace.  Your program should work without any input.

In the interest of clarity, a JSON object starts and ends with curly braces {}, and contains zero or more key:value pairs separated by commas.  The full JSON specification can be found at json.org, and the output of your code must pass this validator.

Therefore, any of the following would not be valid:

```<code>4                               //Too short, not an object
"really, really long string"    //A string, not an object
["an","array","of","values"]    //An array is not a JSON object
{"this":4      }                //You can't count unessential whitespace
{"1":1,"2":3}                   //Too short
{"a really long string"}        //Not valid JSON, it needs a value
{'single-quoted':3}             //JSON requires double-quotes for strings
</code>```

However, the following would be valid:

```<code>{"1":1,"2":2,"3":3,"4":4}       //Long enough
{"whitespace      ":4}          //This whitespace isn't unessential
</code>```

Non-programming languages are allowed on this challenge.  You may return a string from a function, or print it out.  This is a code-golf, so answer it with as little code as possible!

Body:
Ruby (cheap), 22 bytes

->{'{"aaaa":"bbbbb"}'}

Lambda function that returns the String object '{"aaaa":"bbbbb"}'


问:
Generate alphabet with 4 copies of each letter
Note that this is not the same as Print the alphabet four times.

This task is to write a program to generate four copies of each letter of the English alphabet, one letter per line, on standard output:

```<code>A
A
A
A
B
B
B
B
</code>```

etc.

The output should include newlines after each letter.

Lowercase letters and/or extra whitespace are acceptable.

The solution must be a complete program.

This is code-golf so answers will be scored in bytes with a lower score being the goal.

答:
Jelly, 5 bytes

```<code>ØAx4Y
</code>```

Try it online!

Explanation:

```<code>ØAx4Y Main link
ØA    “ABCDEFGHIJKLMNOPQRSTUVWXYZ”
   4  4
  x   Repeat each element of x y times
    Y Join x with newlines
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Jelly, 5 bytes

ØAx4Y

Try it online!

Explanation:

ØAx4Y Main link
ØA    “ABCDEFGHIJKLMNOPQRSTUVWXYZ”
   4  4
  x   Repeat each element of x y times
    Y Join x with newlines


问:
Trick or Treat polyglot
Since Halloween is coming up I thought I might start a fun little code golf challenge!

The challenge is quite simple. You have to write a program that outputs either trick or treat.

"The twist?" you may ask. Well let me explain:

Your program has to do the following:

Be compilable/runnable in two different languages. Different versions of the same language don't count.

When you run the program in one language it should output trick and the other should output treat. The case is irrelevant and padding the string with whitespace characters are allowed (see examples).

This is code-golf,  so the solution with the fewest bytes wins.

A few explanations:

Valid outputs (Just for the words not for running the code in the two languages. Also adding quotes to signalize the beginning or end of the output. Do not include them in your solution!):

```<code>"trick"

"Treat"

"    TReAt"

"
     tRICk          "
</code>```

Invalid outputs:

```<code>"tri ck"

"tr
eat"

"trck"
</code>```

I'm interested to see what you can come up with! Happy Golfing!

I'd like to note that this is my first challenge so if you have suggestions on this question please leave them in the form of a comment.

Leaderboards

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

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

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

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

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

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

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

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

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

var QUESTION_ID=97472,OVERRIDE_USER=23417;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,TAGS_REG = /(<([^>]+)>)/ig;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:400px;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

```

答:
/// / Javascript, <s>32</s> 26 bytes

/*//trick/*/alert("treat")
```

<p>Try it online! Slashes | Javascript</p>

<p><em>-6 bytes thanks to BrainStone</em></p>

<p><strong>Explanation:</strong></p>

<ul>
<li><p><strong>///</strong></p>

```/*//                        Replace * with nothing
   trick                    Print "trick"
        /*/alert("treat")   This is the start of a replacement,
                            but the third slash is missing,
                            so it doesn't do anything.
```</li>
<li><p><strong>Javascript</strong></p>

```/*                          Start of multiline comment
  //trick/                  Comment
          */                End of multiline comment
            alert("treat")  Print "treat"
```

Title: Trick or Treat polyglot

Body:
/// / Javascript, <s>32</s> 26 bytes

/*//trick/*/alert("treat")

Try it online! Slashes | Javascript

-6 bytes thanks to BrainStone

Explanation:

///

/*//                        Replace * with nothing
   trick                    Print "trick"
        /*/alert("treat")   This is the start of a replacement,
                            but the third slash is missing,
                            so it doesn't do anything.

Javascript

/*                          Start of multiline comment
  //trick/                  Comment
          */                End of multiline comment
            alert("treat")  Print "treat"


答:
2sable / pl, 8 bytes

```<code>0000000: 74 72 65 61 74 93 d0 cb                          treat...
</code>```

Both programs have been tested locally with the same 8 byte file, so this is a proper polyglot.

2sable: trick

This is the program in code page 1252.

```<code>treat“ÐË
</code>```

Try it online!

pl: treat

This is the program in code page 437.

```<code>treatô╨╦
</code>```

Try it online!

How it works

2sable: trick

```<code>t         Square root. Errors since there is no input. The exception is caught, the
          stack left unaltered, and the interpreter pretends nothing happened.
 r        Reverse stack.
          Reversed empty stack is still empty stack. ;(
  e       Compute nCr. Errors since there is no input.
   a      Alphanumeric test. Errors since there is no input.
    t     Square root. Errors since there is no input.
     “    Begin a lowercase string literal.
      Ð     Excluding ‘, ’, “, and ”, Ð is the 71st non-ASCII character in CP1252.
       Ë    Excluding ‘, ’, “, and ”, Ë is the 66th non-ASCII character in CP1252.
          (implicit) End string literal.
          Both characters together fetch the dictionary word at index
          71 * 100 + 66 = 7166, which is 'trick'.
</code>```

pl: treat

```<code>treat     Bareword; push the string "treat" on the stack.
     ô    Unimplemented. Does nothing.
      ╨   Flatten the stack. This doesn't affect the output.
       ╦  Unimplemented. Does nothing.
</code>```

Title: Trick or Treat polyglot

Body:
Since Halloween is coming up I thought I might start a fun little code golf challenge!

The challenge is quite simple. You have to write a program that outputs either trick or treat.

"The twist?" you may ask. Well let me explain:

Your program has to do the following:

Be compilable/runnable in two different languages. Different versions of the same language don't count.

When you run the program in one language it should output trick and the other should output treat. The case is irrelevant and padding the string with whitespace characters are allowed (see examples).

This is code-golf,  so the solution with the fewest bytes wins.

A few explanations:

Valid outputs (Just for the words not for running the code in the two languages. Also adding quotes to signalize the beginning or end of the output. Do not include them in your solution!):

```<code>"trick"

"Treat"

"    TReAt"

"
     tRICk          "
</code>```

Invalid outputs:

```<code>"tri ck"

"tr
eat"

"trck"
</code>```

I'm interested to see what you can come up with! Happy Golfing!

I'd like to note that this is my first challenge so if you have suggestions on this question please leave them in the form of a comment.

Leaderboards

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

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

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

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

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

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

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

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

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

var QUESTION_ID=97472,OVERRIDE_USER=23417;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,TAGS_REG = /(<([^>]+)>)/ig;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:400px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
2sable / pl, 8 bytes

0000000: 74 72 65 61 74 93 d0 cb                          treat...

Both programs have been tested locally with the same 8 byte file, so this is a proper polyglot.

2sable: trick

This is the program in code page 1252.

treat“ÐË

Try it online!

pl: treat

This is the program in code page 437.

treatô╨╦

Try it online!

How it works

2sable: trick

t         Square root. Errors since there is no input. The exception is caught, the
          stack left unaltered, and the interpreter pretends nothing happened.
 r        Reverse stack.
          Reversed empty stack is still empty stack. ;(
  e       Compute nCr. Errors since there is no input.
   a      Alphanumeric test. Errors since there is no input.
    t     Square root. Errors since there is no input.
     “    Begin a lowercase string literal.
      Ð     Excluding ‘, ’, “, and ”, Ð is the 71st non-ASCII character in CP1252.
       Ë    Excluding ‘, ’, “, and ”, Ë is the 66th non-ASCII character in CP1252.
          (implicit) End string literal.
          Both characters together fetch the dictionary word at index
          71 * 100 + 66 = 7166, which is 'trick'.

pl: treat

treat     Bareword; push the string "treat" on the stack.
     ô    Unimplemented. Does nothing.
      ╨   Flatten the stack. This doesn't affect the output.
       ╦  Unimplemented. Does nothing.


答:
Groovy, 53 bytes

```<code>('z'..'a').each{println((it..'z').join().center(26))}
</code>```

Output:

```<code>            z
            yz
           xyz
           wxyz
          vwxyz
          uvwxyz
         tuvwxyz
         stuvwxyz
        rstuvwxyz
        qrstuvwxyz
       pqrstuvwxyz
       opqrstuvwxyz
      nopqrstuvwxyz
      mnopqrstuvwxyz
     lmnopqrstuvwxyz
     klmnopqrstuvwxyz
    jklmnopqrstuvwxyz
    ijklmnopqrstuvwxyz
   hijklmnopqrstuvwxyz
   ghijklmnopqrstuvwxyz
  fghijklmnopqrstuvwxyz
  efghijklmnopqrstuvwxyz
 defghijklmnopqrstuvwxyz
 cdefghijklmnopqrstuvwxyz
bcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
</code>```

Title: Draw an alphabet party hat

Body:
Groovy, 53 bytes

('z'..'a').each{println((it..'z').join().center(26))}

Output:

            z
            yz
           xyz
           wxyz
          vwxyz
          uvwxyz
         tuvwxyz
         stuvwxyz
        rstuvwxyz
        qrstuvwxyz
       pqrstuvwxyz
       opqrstuvwxyz
      nopqrstuvwxyz
      mnopqrstuvwxyz
     lmnopqrstuvwxyz
     klmnopqrstuvwxyz
    jklmnopqrstuvwxyz
    ijklmnopqrstuvwxyz
   hijklmnopqrstuvwxyz
   ghijklmnopqrstuvwxyz
  fghijklmnopqrstuvwxyz
  efghijklmnopqrstuvwxyz
 defghijklmnopqrstuvwxyz
 cdefghijklmnopqrstuvwxyz
bcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz


问:
Perform several mathematic operations

The task:

You have to input 2 numbers and output the results of several operations done with them.

Details:

Input 2 floating point numbers, x != 0 and y != 0 via stdin, command line or function arguments.
Output x+y,

       x*y,

       x^y (pow(x,y), not x XOR y),

       x-y,

       y-x,

       x/y and

       y/x on STDOUT separated by newlines, commas or spaces.

For languages which doesn't support floats, you may use an external library, implement them yourself or you can not participate :(
Standard loopholes apply, the shortest code in bytes wins. Good luck!

Title: Perform several mathematic operations

Body:
Haskell, 44 bytes

x#y=mapM print[x+y,x*y,x**y,x-y,y-x,x/y,y/x]

Example: 4 # 5 prints

9.0
20.0
1024.0
-1.0
1.0
0.8
1.25


Title: Draw an alphabet party hat

Body:
C, <s>72</s> 68 bytes

m(i){for(char*k=&k[i=26];i;printf("%*c%s\n",--i/2+1,0,k))*--k=64+i;}


问:
Interpret /// (pronounced 'slashes')
Because we can't get enough of esoteric language golfs, can we?

///—pronounced slashes—is a fun little language based on the s/// regex-replacement function of Perl fame. It contains only two special characters, slash / and backslash \. You can find a full article on it at the esolangs wiki, but I will reproduce a description of the language below, as well as some examples.

In short, it works by identifying /pattern/repl/rest in the program and making the substitution as many times as possible. No characters are special except / and \: / demarcates patterns and replacements in the program, while \ allows you to insert literal / or \ characters into your code. Notably, these are not regular expressions, just plain string substitutions.

Your challenge is to produce an interpreter for the /// language, as either a program reading STDIN or a function taking a string argument, in as few characters as possible.

You may use any language except for /// itself. You may not use any libraries that interpret ///; you may, however, use regexes, regex libraries, or string-matching libraries.

Execution

There are four states, print, pattern, replacement, and substitution. In every state except substitution:

If the program is empty, execution halts.

Else, if the first character is \, do something with the next character (if present) and remove both from the program.

Else, if the first character is /, remove it, and change to the next state.

Else, do something with the first character and remove it from the program.

Repeat.

The states cycle through print, pattern, replacement, and substitution in order.

In print mode, 'do something' means output the character.

In pattern mode, 'do something' means add the character to the current Pattern.

In replacement mode, 'do something' means add the character to the current Replacement.

In substitution mode, you follow a different set of rules. Repeatedly substitute the first occurrence of the current Pattern with the current Replacement in the program, until no more substitutions are possible. At that point, clear the Pattern and Replacement and return to print mode.

In the program /foo/foobar/foo foo foo, the following happens:

```<code>/foo/foobar/foo foo foo
foo foo foo
foobar foo foo
foobarbar foo foo
foobarbarbar foo foo
...
</code>```

This loops forever and never exits substitution mode. Similarly, if the Pattern is empty, then the first occurrence of the empty string—at the beginning of the program—always matches, so substitution mode loops forever, never halting.

Examples

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

Output: no.

```<code>/ world! world!/Hello,/ world! world! world!
</code>```

Output: Hello, world!.

```<code>/foo/Hello, world!//B\/\\R/foo/B/\R
</code>```

Output: Hello, world!.

```<code>a/ab/bbaa/abb
</code>```

Output: a. Program does not halt.

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

Output: none.

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

Output: none. Program does not halt.

```<code>/\\/good/\/
</code>```

Output: good.

There is also a quine on the wiki you can try.

答:
BaCon, <s>391</s> <s>387</s> 395 bytes

From the contributions on this page I only got the Python program to work. The others work for some /// samples, or do not work at all. Therefore, I decided to add my version, which is an implementation in BASIC.

To compete in a CodeGolf contest with BASIC is not easy, as BASIC uses long words as statements. The only abbreviation commonly found in BASIC is the '?' sign, which means PRINT.

So the below program may never win, but at least it works with all demonstration code on this Codegolf page and on the Esolangs Wiki. Including all versions of the "99 bottles of beer".

```<code>p$=""
r$=""
INPUT i$
WHILE LEN(i$)
t$=LEFT$(i$,1)
i$=MID$(i$,2)
IF NOT(e) THEN
IF t$="\\" THEN
e=1
CONTINUE
ELIF t$="/" THEN
o=IIF(o<2,o+1,0)
IF o>0 THEN CONTINUE
FI
FI
IF o=1 THEN
p$=p$&t$
ELIF o=2 THEN
r$=r$&t$
ELIF o=0 THEN
IF LEN(p$) THEN i$=REPLACE$(i$,p$,r$)
IF NOT(INSTR(t$&i$,"/")) THEN
?t$;
BREAK
ELSE
?LEFT$(i$,INSTR(i$,"/")-1);
i$=MID$(i$,INSTR(i$,"/"))
FI
p$=""
r$=""
FI
e=0
WEND
?i$
</code>```

Title: Interpret /// (pronounced 'slashes')

Body:
BaCon, <s>391</s> <s>387</s> 395 bytes

From the contributions on this page I only got the Python program to work. The others work for some /// samples, or do not work at all. Therefore, I decided to add my version, which is an implementation in BASIC.

To compete in a CodeGolf contest with BASIC is not easy, as BASIC uses long words as statements. The only abbreviation commonly found in BASIC is the '?' sign, which means PRINT.

So the below program may never win, but at least it works with all demonstration code on this Codegolf page and on the Esolangs Wiki. Including all versions of the "99 bottles of beer".

p$=""
r$=""
INPUT i$
WHILE LEN(i$)
t$=LEFT$(i$,1)
i$=MID$(i$,2)
IF NOT(e) THEN
IF t$="\\" THEN
e=1
CONTINUE
ELIF t$="/" THEN
o=IIF(o<2,o+1,0)
IF o>0 THEN CONTINUE
FI
FI
IF o=1 THEN
p$=p$&t$
ELIF o=2 THEN
r$=r$&t$
ELIF o=0 THEN
IF LEN(p$) THEN i$=REPLACE$(i$,p$,r$)
IF NOT(INSTR(t$&i$,"/")) THEN
?t$;
BREAK
ELSE
?LEFT$(i$,INSTR(i$,"/")-1);
i$=MID$(i$,INSTR(i$,"/"))
FI
p$=""
r$=""
FI
e=0
WEND
?i$


答:
Ruby, 40 bytes

```<code>->x,y{puts x+y,x*y,x**y,x-y,y-x,x/y,y/x}
</code>```

Title: Perform several mathematic operations

Body:
The task:

You have to input 2 numbers and output the results of several operations done with them.

Details:

Input 2 floating point numbers, x != 0 and y != 0 via stdin, command line or function arguments.
Output x+y,

       x*y,

       x^y (pow(x,y), not x XOR y),

       x-y,

       y-x,

       x/y and

       y/x on STDOUT separated by newlines, commas or spaces.

For languages which doesn't support floats, you may use an external library, implement them yourself or you can not participate :(
Standard loopholes apply, the shortest code in bytes wins. Good luck!

Body:
Ruby, 40 bytes

->x,y{puts x+y,x*y,x**y,x-y,y-x,x/y,y/x}


答:
Dyalog APL, 15 bytes

Takes x as left argument and y as right argument.

+,×,*,-,-⍨,÷,÷⍨
```

Simply a long train of forks (3-trains):

+, the sum, followed by

×, the product, followed by

*, the exponentiation, followed by

-, the difference, followed by

-⍨, the swapped difference, followed by

÷, the ratio, followed by

÷⍨ the swapped ratio

TryAPL online!

Title: Perform several mathematic operations

Body:
Dyalog APL, 15 bytes

Takes x as left argument and y as right argument.

+,×,*,-,-⍨,÷,÷⍨

Simply a long train of forks (3-trains):

+, the sum, followed by

×, the product, followed by

*, the exponentiation, followed by

-, the difference, followed by

-⍨, the swapped difference, followed by

÷, the ratio, followed by

÷⍨ the swapped ratio

TryAPL online!


答:
Scala, 68 bytes

```<code>(x:Float,y:Float)=>Seq(x+y,x*y,math.pow(x,y),x-y,x/y,y/x)map println
</code>```

Pretty striaghtforward.

Title: Perform several mathematic operations

Body:
Scala, 68 bytes

(x:Float,y:Float)=>Seq(x+y,x*y,math.pow(x,y),x-y,x/y,y/x)map println

Pretty striaghtforward.


Title: Perform several mathematic operations

Body:
Groovy, 36 bytes

{a,b->print([a+b,a-b,a/b,a*b,a**b])}

Output:

({a,b->print([a+b,a-b,a/b,a*b,a**b])})(5.034,2.0568)

Results in:

[7.0908, 2.9772, 2.4474912485, 10.3539312, 27.777623862468822]


答:
Befunge-98/DOS .COM file, 27 bytes

```<code>00000000  22 20 b4 09 ba 0b 01 cd  21 c3 20 74 72 65 61 74  |" ......!. treat|
00000010  24 6b 63 69 72 74 22 34  6b 2c 40                 |$kcirt"4k,@|
0000001b
</code>```

The Befunge-98 part pushes the characters of a string to the stack, and then outputs the top 5 characters in the stack and ends.

The DOS part is:

```<code>00000000  2220              and ah,[bx+si]
00000002  B409              mov ah,0x9
00000004  BA0B01            mov dx,0x10b
00000007  CD21              int 0x21
00000009  C3                ret
</code>```

Where the first instruction is just some dummy non important instruction, and the rest calls INT 21h function 09h, which prints a $-terminated string pointed to by DS:DX.

Title: Trick or Treat polyglot

Body:
Befunge-98/DOS .COM file, 27 bytes

00000000  22 20 b4 09 ba 0b 01 cd  21 c3 20 74 72 65 61 74  |" ......!. treat|
00000010  24 6b 63 69 72 74 22 34  6b 2c 40                 |$kcirt"4k,@|
0000001b

The Befunge-98 part pushes the characters of a string to the stack, and then outputs the top 5 characters in the stack and ends.

The DOS part is:

00000000  2220              and ah,[bx+si]
00000002  B409              mov ah,0x9
00000004  BA0B01            mov dx,0x10b
00000007  CD21              int 0x21
00000009  C3                ret

Where the first instruction is just some dummy non important instruction, and the rest calls INT 21h function 09h, which prints a $-terminated string pointed to by DS:DX.


答:
J, 15 bytes

Equivalent to this.

Takes x as left argument and y as right argument.

```<code>+,*,^,-,-~,%,%~
</code>```

Simply a long train of forks (3-trains):

+, the sum, followed by

*, the product, followed by

^, the exponentiation, followed by

-, the difference, followed by

-~, the swapped difference, followed by

%, the ratio, followed by

%~ the swapped ratio

Title: Perform several mathematic operations

Body:
J, 15 bytes

Equivalent to this.

Takes x as left argument and y as right argument.

+,*,^,-,-~,%,%~

Simply a long train of forks (3-trains):

+, the sum, followed by

*, the product, followed by

^, the exponentiation, followed by

-, the difference, followed by

-~, the swapped difference, followed by

%, the ratio, followed by

%~ the swapped ratio


Title: Trick or Treat polyglot

Body:
Linux ELF x86 / DOS .COM file, 73 bytes

00000000  7f 45 4c 46 01 00 00 00  1a 00 00 00 1a 00 43 05  |.ELF..........C.|
00000010  02 00 03 00 1a 00 43 05  1a 00 43 05 04 00 00 00  |......C...C.....|
00000020  eb 0c b4 09 ba 41 01 cd  21 c3 20 00 01 00 b2 05  |.....A..!. .....|
00000030  b9 3b 00 43 05 cd 80 2c  04 cd 80 74 72 69 63 6b  |.;.C...,...trick|
00000040  00 74 72 65 61 74 24 eb  d9                       |.treat$..|
00000049

NASM source:

ORG 0x05430000

BITS 32                                         ;
                                                ;   ELF HEADER    --   PROGRAM HEADER
; ELF HEADER                                    ; +-------------+
DB 0x7f,'E','L','F'                             ; | magic       |    +--------------------+
                                                ; |             |    |                    |
; PROGRAM HEADERS                               ; |             |    |                    |
DD 1                                            ; |*class 32b   | -- | type: PT_LOAD      |
                                                ; |*data none   |    |                    |
                                                ; |*version 0   |    |                    |
                                                ; |*ABI SysV    |    |                    |
DD 0x01a        ; offset = vaddr & (PAGE_SIZE-1); |*ABI vers    | -- | offset             |
                                                ; |             |    |                    |
entry:  DD 0x0543001a                           ; |*PADx7       | -- | vaddr = 0x0543001a |
DW 2                                            ; | ET_EXEC     | -- |*paddr LO           |
DW 3                                            ; | EM_386      | -- |*paddr HI           |
DD 0x0543001a                                   ; |*version     | -- | filesz             |
;       inc     ebx     ; STDOUT_FILENO         ; |             |    |                    |
;       mov     eax, 4  ; SYS_WRITE             ; |             |    |                    |
DD 0x0543001a                                   ; | entry point | -- | memsz              |
DD 4                                            ; | ph offset   | -- | flags: RX          |
                                                ; |             |    |                    |
        jmp     short skip                      ; |*sh offset   | -- |*align              |
BITS 16                                         ; |             |    |                    |
treat:  mov     ah, 9                           ; |             | -- |                    |
        mov     dx, trick + 0x100 + 6           ; |*flags ______|    |                    |
        int     0x21                            ; |______/      |    +--------------------+
        ret                                     ; |*ehsize      |
BITS 32                                         ; |             |
DW 32                                           ; | phentsize   |
DW 1                                            ; | phnum       |
skip:                                           ; |             |
        mov     dl, 5   ; strlen("trick")       ; |*shentsize   |
        mov     ecx, trick                      ; |*shnum       |
                                                ; |*shstrndx    |
                                                ; +-------------+
        int     0x80
        sub     al, 4   ; SYS_EXIT
        int     0x80

trick:  DB      "trick/treat$"

BITS 16
        jmp     short treat

This uses the fact that the ELF header starts with 7F 45, which, interpreted as x86 code, is a jump.

The relevant parts for the DOS .COM:

-u100 l2
07D2:0100 7F45          JG      0147
-u147 l2
07D2:0147 EBD9          JMP     0122
-u122 l8
07D2:0122 B409          MOV     AH,09
07D2:0124 BA4101        MOV     DX,0141
07D2:0127 CD21          INT     21
07D2:0129 C3            RET
-d141 l6
07D2:0140     74 72 65 61 74 24   -                           treat$


问:
The Last Monday
Monday, October 31st, is Halloween. And it got me thinking -- I wonder what other months have the last day of the month also be a Monday?

Input

A positive integer in any convenient format representing a year, 10000 > y > 0.

The input can be padded with zeros (e.g., 0025 for year 25) if
required.

Output

A list of the months of that year where the last day of the month is a Monday.

This can be as month names (e.g., January, March, October), or shortnames (Jan, Mar, Oct), or numbers (1, 3, 10), as separate lines or a list or delimited, etc., just so long as it's unambiguous to the reader.

The output format must be consistent:

For all years input (meaning, you can't output month names for some inputs, and month numbers for other inputs)

As well as consistent per output (meaning, you can't output 1 for January in the same output as Jul for July)

Basically, pick one format and stick to it.

Rules

Assume the Gregorian calendar for input/output, even down to y = 1.

Leap years must be properly accounted for (as a reminder: every year divisible by 4, except not years divisible by 100, unless also divisible by 400 -- 1700, 1800, 1900 all weren't leap years, but 2000 was).

You may use any built-ins or other date calculation tools you like.

Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.

Standard loopholes are forbidden.

This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Examples

```<code>   1 --> Apr, Dec
 297 --> May
1776 --> Sep
2000 --> Jan, Jul
2016 --> Feb, Oct
3385 --> Jan, Feb, Oct
</code>```

Leaderboard

var QUESTION_ID=97585,OVERRIDE_USER=42963;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

```

答:
JavaScript (Firefox 30-57), <s>67</s> <s>65</s> <s>64</s> <s>63</s> 61 bytes

```<code>y=>[for(_ of(m='')+1e11)if(new Date(y+400,++m).getDay()==2)m]
</code>```

Saved <s>2</s> <s>4</s> 6 bytes thanks to @ETHproductions. <s>Saved another byte by outputting the months in reverse order.</s>

Title: The Last Monday

Body:
JavaScript (Firefox 30-57), <s>67</s> <s>65</s> <s>64</s> <s>63</s> 61 bytes

y=>[for(_ of(m='')+1e11)if(new Date(y+400,++m).getDay()==2)m]

Saved <s>2</s> <s>4</s> 6 bytes thanks to @ETHproductions. <s>Saved another byte by outputting the months in reverse order.</s>


答:
PowerShell v2+, 66 bytes

```<code>param($x,$y)$x+$y;$x*$y;[math]::Pow($x,$y);$x-$y;$y-$x;$x/$y;$y/$x
</code>```

Very boring, does exactly what it says on the tin. Each statement (separated by ;) is evaluated and left on the pipeline. At program completion, everything left on the pipeline is implicitly printed via Write-Output.

Long because PowerShell uses $ to delineate variables, and it also doesn't have a ^ or ** or equivalent operator, so we need a .NET call.

Note that the Write-Output will display as integer values, even if the input is floats. Running a .GetType() will show the output to be System.Double however.

```<code>PS C:\Tools\Scripts\golfing> .\perform-several-mathematic-operations.ps1 5.0 6.0
11
30
15625
-1
1
0.833333333333333
1.2
</code>```

Title: Perform several mathematic operations

Body:
PowerShell v2+, 66 bytes

param($x,$y)$x+$y;$x*$y;[math]::Pow($x,$y);$x-$y;$y-$x;$x/$y;$y/$x

Very boring, does exactly what it says on the tin. Each statement (separated by ;) is evaluated and left on the pipeline. At program completion, everything left on the pipeline is implicitly printed via Write-Output.

Long because PowerShell uses $ to delineate variables, and it also doesn't have a ^ or ** or equivalent operator, so we need a .NET call.

Note that the Write-Output will display as integer values, even if the input is floats. Running a .GetType() will show the output to be System.Double however.

PS C:\Tools\Scripts\golfing> .\perform-several-mathematic-operations.ps1 5.0 6.0
11
30
15625
-1
1
0.833333333333333
1.2


答:
C# - 106 bytes

```<code>void r(float x,float y){System.Console.WriteLine($"{x+y} {x*y} {Math.Pow(x,y)} {x-y} {y-x} {x/y} {y/x}");}
</code>```

Title: Perform several mathematic operations

Body:
C# - 106 bytes

void r(float x,float y){System.Console.WriteLine($"{x+y} {x*y} {Math.Pow(x,y)} {x-y} {y-x} {x/y} {y/x}");}


答:
sed / Hexagony 32 bytes

```<code>/$/ctrick
#$@$a</;r;e;/t;....\t;
</code>```

sed

Try it Online!

The first line prints trick if there is an empty string at the end of input. (sed doesn't do anything if there isn't input, but a blank line on stdin is allowed in this case)

Example run:

```<code>$ echo | sed -f TrickOrTreat.sed
trick
</code>```

Hexagony

Try it Online!

The first / redirects the instruction pointer up and the the left, so it wraps the the bottom left, skipping the text used for sed. It reuses the r from the sed code and runs a few others to no effect. The expanded hex looks like this:

```<code>   / $ / c
  t r i c k
 # $ @ $ a <
/ ; r ; e ; /
 t ; . . . .
  \ t ; . .
   . . . .
</code>```

Output:

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

Title: Trick or Treat polyglot

Body:
Since Halloween is coming up I thought I might start a fun little code golf challenge!

The challenge is quite simple. You have to write a program that outputs either trick or treat.

"The twist?" you may ask. Well let me explain:

Your program has to do the following:

Be compilable/runnable in two different languages. Different versions of the same language don't count.

When you run the program in one language it should output trick and the other should output treat. The case is irrelevant and padding the string with whitespace characters are allowed (see examples).

This is code-golf,  so the solution with the fewest bytes wins.

A few explanations:

Valid outputs (Just for the words not for running the code in the two languages. Also adding quotes to signalize the beginning or end of the output. Do not include them in your solution!):

```<code>"trick"

"Treat"

"    TReAt"

"
     tRICk          "
</code>```

Invalid outputs:

```<code>"tri ck"

"tr
eat"

"trck"
</code>```

I'm interested to see what you can come up with! Happy Golfing!

I'd like to note that this is my first challenge so if you have suggestions on this question please leave them in the form of a comment.

Leaderboards

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

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

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

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

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

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

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

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

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

var QUESTION_ID=97472,OVERRIDE_USER=23417;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,TAGS_REG = /(<([^>]+)>)/ig;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:400px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
sed / Hexagony 32 bytes

/$/ctrick
#$@$a</;r;e;/t;....\t;

sed

Try it Online!

The first line prints trick if there is an empty string at the end of input. (sed doesn't do anything if there isn't input, but a blank line on stdin is allowed in this case)

Example run:

$ echo | sed -f TrickOrTreat.sed
trick

Hexagony

Try it Online!

The first / redirects the instruction pointer up and the the left, so it wraps the the bottom left, skipping the text used for sed. It reuses the r from the sed code and runs a few others to no effect. The expanded hex looks like this:

   / $ / c
  t r i c k
 # $ @ $ a <
/ ; r ; e ; /
 t ; . . . .
  \ t ; . .
   . . . .

Output:

treat


答:
Dip/05AB1E, 15 bytes

```<code>"trick"q"treat"
</code>```

Prints treat in Dip and trick in 05AB1E.

Title: Trick or Treat polyglot

Body:
Dip/05AB1E, 15 bytes

"trick"q"treat"

Prints treat in Dip and trick in 05AB1E.


答:
Python 2, 118 bytes

Look ma, no regex!

```<code>for w in`input()`.split():print[w.title(),w][`w`in"'a'an'and'as'at'the'by'but'for'nor'in'of'on'or'to'up'"].strip("'"),
</code>```

Input must be wrapped in quotes. Output has a trailing space and no trailing newline (I assume that's okay). Verify all test cases on Ideone.

Explanation

Let's take the input a or an as our example.

Using Python 2's `x` shortcut for repr, we wrap the input in single quotes: 'a or an'. Then we split on whitespace and iterate over the words.

Inside the loop, we take the repr again. For the first and last words, this gives "'a" and "an'". For other words, it gives 'or'. We want to avoid capitalizing words if they fit the latter pattern and are in the short-words list. So we can represent the word list as the string "'a'an'...'up'" and know that the repr of any short word will be a substring.

`w` in "..." gives a boolean value, which we can treat as 0 or 1 for the purposes of indexing into the list [w.title(), w]. In short, we title-case the word if it is at the beginning, at the end, or not in the list of short words. Otherwise, we leave it alone. Fortunately, title() still works as expected with input like 'a.

Finally, we strip any single quotes from the word and print it with a trailing space.

Body:
According to this site a general rule recommended by The U.S. Government Printing Office Style Manual is

Capitalize all words in titles of publications and documents, except
  a, an, the, at, by, for, in, of, on, to, up, and, as, but, or, and
  nor.

This might not be true as I'm unable to find such a recommendation in the Style Manual, but let's use this rule anyway.

The Challenge

Given an input string consisting of lower case words delimited by spaces, output the capitalization of the string according to the following rules

The first and last word is capitalized.

All other words are capitalized, except a, an, the, at, by, for, in, of, on, to, up, and, as, but, or, and nor.

The input string will contain at least one word and each word contains at least one letter and only characters from a to z.

This is a code golf challenge, so try to use as few bytes as possible in the language of your choice. You may write a full program or a function to accomplish the task.

Testcases

```<code>"the rule of thumb for title capitalization" -> "The Rule of Thumb for Title Capitalization"
"programming puzzles and code golf" -> "Programming Puzzles and Code Golf"
"the many uses of the letter a" -> "The Many Uses of the Letter A"
"title" -> "Title"
"and and and" -> "And and And"
"a an and as at but by for in nor of on or the to up" -> "A an and as at but by for in nor of on or the to Up"
"on computable numbers with an application to the entscheidungsproblem" -> "On Computable Numbers With an Application to the Entscheidungsproblem"
</code>```

Body:
Python 2, 118 bytes

Look ma, no regex!

for w in`input()`.split():print[w.title(),w][`w`in"'a'an'and'as'at'the'by'but'for'nor'in'of'on'or'to'up'"].strip("'"),

Input must be wrapped in quotes. Output has a trailing space and no trailing newline (I assume that's okay). Verify all test cases on Ideone.

Explanation

Let's take the input a or an as our example.

Using Python 2's `x` shortcut for repr, we wrap the input in single quotes: 'a or an'. Then we split on whitespace and iterate over the words.

Inside the loop, we take the repr again. For the first and last words, this gives "'a" and "an'". For other words, it gives 'or'. We want to avoid capitalizing words if they fit the latter pattern and are in the short-words list. So we can represent the word list as the string "'a'an'...'up'" and know that the repr of any short word will be a substring.

`w` in "..." gives a boolean value, which we can treat as 0 or 1 for the purposes of indexing into the list [w.title(), w]. In short, we title-case the word if it is at the beginning, at the end, or not in the list of short words. Otherwise, we leave it alone. Fortunately, title() still works as expected with input like 'a.

Finally, we strip any single quotes from the word and print it with a trailing space.


问:
Draw an asterisk triangle
Inspired by a task for Programming 101, here's a challenge that hopefully isn't too easy (or a duplicate).

Input:

A positive integer n >= 1.

Output:

n lines of asterisks, where every new line has one asterisk more than the line before, and starting with one asterisk in the first line.

Test case (n=5):

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

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

答:
Dip, <s>6</s> 5 bytes

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

-1 byte thanks to Oliver

Explanation:

```<code>`**    Push "*" repeated input times
   E   Prefixes
    n  Join by newlines
</code>```

Title: Draw an asterisk triangle

Body:
Dip, <s>6</s> 5 bytes

`**En

-1 byte thanks to Oliver

Explanation:

`**    Push "*" repeated input times
   E   Prefixes
    n  Join by newlines


答:
JavaScript (Firefox 30+), <s>112</s> <s>109</s> <s>103</s> 95 bytes

Look ma, no built-ins!

```<code>y=>[for(m of(i=0,y%4|y%400*!(y%100)&&6)+"63153042641")if((i++,y+(y>>2)-(y/100|0)*3/4|0)%7==m)i]
</code>```

Here's a 107-byte ES6 version:

```<code>y=>[...(y%4|y%400*!(y%100)&&6)+"63153042641"].map((m,i)=>(y+(y>>2)-(y/100|0)*3/4|0)%7-m?0:i+1).filter(x=>x)
</code>```

And here's my previous attempt, <s>123</s> 113 bytes of ES6:

```<code>y=>[(l=y%4|y%400*!(y%100))?[7]:[1,7],[4,12],[9],[3,6],[8,11],[5],l?[1,2,10]:[2,10]][(y+(y>>2)-(y/100|0)*3/4|0)%7]
</code>```

Explanation

The day of the week of a particular year is calculated like so:

```<code>y+(y>>2)-(y/100|0)*3/4|0)%7
</code>```

In other words:

Take y.

Add the number of 4th years before y (y>>2).

Subtract the number of 100th years before y (y/100|0).

Add back in the number of 400th years before y; this is 1/4 of y/100|0, so we use *3/4|0.

Then we modulo the result by 7. If we let 0 mean Sunday, 1 mean Monday, etc., the result corresponds to the day of the week of December 31st of that year. Therefore, for December, we want to check if the result is 1. This gives us the last char in the string.

The last day of November is 31 days before the last day of December. This means that for the last day of November to be a Monday, Dec 31 needs to be a (1 + 31) % 7 = 4 = Thursday.

This procedure is repeated until we get back to March (a 3). Whether or not there is a leap day, the last day of February is 31 days before the last day of March, so we can calculate that too (it's (3 + 31) % 7 = 6). The tricky part is finding the correct value for January:

If it is a leap year, the last day of January is 29 days before the last day of Feb, resulting in (6 + 29) % 7 = 0.

Otherwise, it is 28 days before the last day of Feb, resulting in (6 + 28) % 7 = 6.

We can calculate whether or not it is a leap year with the following snippet:

```<code>!(y%400)|y%100*!(y%4)
</code>```

This gives 0 if y is not a leap year, and a positive integer otherwise. This leads us to

```<code>!(y%400)|y%100*!(y%4)?0:6
</code>```

for calculating the day for January. However, we can do better by reversing the conditions:

```<code>y%4|y%400*!(y%100)?6:0
</code>```

Since the falsy result is always 0 anyway, we can reduce it to

```<code>y%4|y%400*!(y%100)&&6
</code>```

saving one more precious byte.

Putting it all together, we loop through each char in the string, checking if each is equal to the day of the week of Dec 31st. We keep the indexes of the ones that match, returning this array in the end. And that is how you do leap year calculations without built-ins.

Title: The Last Monday

Body:
Monday, October 31st, is Halloween. And it got me thinking -- I wonder what other months have the last day of the month also be a Monday?

Input

A positive integer in any convenient format representing a year, 10000 > y > 0.

The input can be padded with zeros (e.g., 0025 for year 25) if
required.

Output

A list of the months of that year where the last day of the month is a Monday.

This can be as month names (e.g., January, March, October), or shortnames (Jan, Mar, Oct), or numbers (1, 3, 10), as separate lines or a list or delimited, etc., just so long as it's unambiguous to the reader.

The output format must be consistent:

For all years input (meaning, you can't output month names for some inputs, and month numbers for other inputs)

As well as consistent per output (meaning, you can't output 1 for January in the same output as Jul for July)

Basically, pick one format and stick to it.

Rules

Assume the Gregorian calendar for input/output, even down to y = 1.

Leap years must be properly accounted for (as a reminder: every year divisible by 4, except not years divisible by 100, unless also divisible by 400 -- 1700, 1800, 1900 all weren't leap years, but 2000 was).

You may use any built-ins or other date calculation tools you like.

Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.

Standard loopholes are forbidden.

This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Examples

```<code>   1 --> Apr, Dec
 297 --> May
1776 --> Sep
2000 --> Jan, Jul
2016 --> Feb, Oct
3385 --> Jan, Feb, Oct
</code>```

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
JavaScript (Firefox 30+), <s>112</s> <s>109</s> <s>103</s> 95 bytes

Look ma, no built-ins!

y=>[for(m of(i=0,y%4|y%400*!(y%100)&&6)+"63153042641")if((i++,y+(y>>2)-(y/100|0)*3/4|0)%7==m)i]

Here's a 107-byte ES6 version:

y=>[...(y%4|y%400*!(y%100)&&6)+"63153042641"].map((m,i)=>(y+(y>>2)-(y/100|0)*3/4|0)%7-m?0:i+1).filter(x=>x)

And here's my previous attempt, <s>123</s> 113 bytes of ES6:

y=>[(l=y%4|y%400*!(y%100))?[7]:[1,7],[4,12],[9],[3,6],[8,11],[5],l?[1,2,10]:[2,10]][(y+(y>>2)-(y/100|0)*3/4|0)%7]

Explanation

The day of the week of a particular year is calculated like so:

y+(y>>2)-(y/100|0)*3/4|0)%7

In other words:

Take y.

Add the number of 4th years before y (y>>2).

Subtract the number of 100th years before y (y/100|0).

Add back in the number of 400th years before y; this is 1/4 of y/100|0, so we use *3/4|0.

Then we modulo the result by 7. If we let 0 mean Sunday, 1 mean Monday, etc., the result corresponds to the day of the week of December 31st of that year. Therefore, for December, we want to check if the result is 1. This gives us the last char in the string.

The last day of November is 31 days before the last day of December. This means that for the last day of November to be a Monday, Dec 31 needs to be a (1 + 31) % 7 = 4 = Thursday.

This procedure is repeated until we get back to March (a 3). Whether or not there is a leap day, the last day of February is 31 days before the last day of March, so we can calculate that too (it's (3 + 31) % 7 = 6). The tricky part is finding the correct value for January:

If it is a leap year, the last day of January is 29 days before the last day of Feb, resulting in (6 + 29) % 7 = 0.

Otherwise, it is 28 days before the last day of Feb, resulting in (6 + 28) % 7 = 6.

We can calculate whether or not it is a leap year with the following snippet:

!(y%400)|y%100*!(y%4)

This gives 0 if y is not a leap year, and a positive integer otherwise. This leads us to

!(y%400)|y%100*!(y%4)?0:6

for calculating the day for January. However, we can do better by reversing the conditions:

y%4|y%400*!(y%100)?6:0

Since the falsy result is always 0 anyway, we can reduce it to

y%4|y%400*!(y%100)&&6

saving one more precious byte.

Putting it all together, we loop through each char in the string, checking if each is equal to the day of the week of Dec 31st. We keep the indexes of the ones that match, returning this array in the end. And that is how you do leap year calculations without built-ins.


问:
Draw an hourglass
Again inspired by a task for Programming 101 here's another challenge.

Input:

A positive integer n >= 3. (has to be odd)

Output:

n lines of asterisks, where the first line has n asterisks and every new line has two asterisks less than the line before. Until hitting 1 asterisk. From there every new line has two asterisks more than the line before until getting back to n asterisks. Spaces or something like spaces have to used to align the asterisks so that it really will look like an hourglass.

General rules:

Trailing newlines are allowed but do not have to be used.

indentation is a must.

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

Since the course is taught in C++, I'm eager to see solutions in C++.

Test case (n=5):

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

答:
PHP - 95 bytes

```<code>$c=2;for($i=$a=$argv[1];$i<=$a;$i-=$c*=$i<2?-1:1)echo str_pad(str_repeat("*",$i),$a," ",2)."
";
</code>```

Saved a byte by using an actual new line instead of an "\r"

Title: Draw an hourglass

Body:
PHP - 95 bytes

$c=2;for($i=$a=$argv[1];$i<=$a;$i-=$c*=$i<2?-1:1)echo str_pad(str_repeat("*",$i),$a," ",2)."
";

Saved a byte by using an actual new line instead of an "\r"


答:
Swift 3, 86 bytes

```<code>for i in 1...Int(CommandLine.arguments[1])!{print(String(repeatElement("*",count:i)))}
</code>```

Yuck.  If I can drop the Int and String initializers I might be able to get this shorter than Java.  Open to any optimizations.

Ungolfed:

```<code>import Foundation

guard CommandLine.argc > 1, let a = Int(CommandLine.arguments[1]) else {
    fatalError("Invalid or nonexistent argument")
}

for i in 1...a {
    print(String(repeatElement("*", count: i)))
}
</code>```

Usage:

```<code>➜ ~ swift asterisk.swift 5
*
**
***
****
*****
</code>```

Title: Draw an asterisk triangle

Body:
Inspired by a task for Programming 101, here's a challenge that hopefully isn't too easy (or a duplicate).

Input:

A positive integer n >= 1.

Output:

n lines of asterisks, where every new line has one asterisk more than the line before, and starting with one asterisk in the first line.

Test case (n=5):

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

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

Body:
Swift 3, 86 bytes

for i in 1...Int(CommandLine.arguments[1])!{print(String(repeatElement("*",count:i)))}

Yuck.  If I can drop the Int and String initializers I might be able to get this shorter than Java.  Open to any optimizations.

Ungolfed:

import Foundation

guard CommandLine.argc > 1, let a = Int(CommandLine.arguments[1]) else {
    fatalError("Invalid or nonexistent argument")
}

for i in 1...a {
    print(String(repeatElement("*", count: i)))
}

Usage:

➜ ~ swift asterisk.swift 5
*
**
***
****
*****


答:
Charcoal and Pip, 13 bytes

```<code>trick©"treat"
</code>```

Charcoal

Charcoal's code page reads this as trick»"treat". trick prints the string to the canvas. » closes a block; apparently, if it is unmatched, it ends the program. The canvas is then printed to the screen.

Try it online

Pip

```<code>t              Variable (no-op)
 r             Generate random number (and do nothing with it)
  i            Variable (no-op)
   c           Variable (no-op)
    k          Variable (no-op)
     ©         Unrecognized character, ignored
      "treat"  String, output implicitly
</code>```

Try it online

Title: Trick or Treat polyglot

Body:
Charcoal and Pip, 13 bytes

trick©"treat"

Charcoal

Charcoal's code page reads this as trick»"treat". trick prints the string to the canvas. » closes a block; apparently, if it is unmatched, it ends the program. The canvas is then printed to the screen.

Try it online

Pip

t              Variable (no-op)
 r             Generate random number (and do nothing with it)
  i            Variable (no-op)
   c           Variable (no-op)
    k          Variable (no-op)
     ©         Unrecognized character, ignored
      "treat"  String, output implicitly

Try it online


问:
Implement a Truth-Machine
A truth-machine (credits goes to this guy for coming up with it) is a very simple program designed to demonstrate the I/O and control flow of a language. Here's what a truth-machine does:

Gets a number (either 0 or 1) from STDIN.

If that number is 0, print out 0 and terminate.

If that number is 1, print out 1 forever.

Challenge

Write a truth-machine as described above in your language of choice. The truth-machine must be a full program that follows these rules:

take input from STDIN or an acceptable alternative

If your language cannot take input from STDIN, it may take input from a hardcoded variable or suitable equivalent in the program

must output to STDOUT or an acceptable alternative

If your language is incapable of outputting the characters 0 or 1, byte or unary I/O is acceptable.

when the input is 1, it must continually print 1s and only stop if the program is killed or runs out of memory

the output must only be either a 0 followed by either one or no newline or space, or infinite 1s with each 1 followed by either one or no newline or space. No other output can be generated, except constant output of your language's interpreter that cannot be suppressed (such as a greeting, ANSI color codes or indentation). Your usage of newlines or spaces must be consistent: for example, if you choose to output 1 with a newline after it all 1s must have a newline after them.

if and only if your language cannot possibly terminate on an input of 0 it is acceptable for the code to enter an infinite loop in which nothing is outputted.

Since this is a catalog, languages created after this challenge are allowed to compete. Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language. Other than that, all the standard rules of code-golf must be obeyed. Submissions in most languages will be scored in bytes in an appropriate preexisting encoding (usually UTF-8).

Catalog

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
Crystal, <s>48</s> <s>37</s> 36 bytes

<s>y=gets;y=="0\n"&&(p 0;exit);y=="1\n"&&loop{p 1}</s>

<s>y=gets;y=="0\n"&&(p 0;exit);loop{p 1}</s>

y=gets;y=="0\n"&&(p 0;1/0);loop{p 1}

Edit: Shaved off 10 bytes because the post doesn't specify what should happen on invalid input (like 2). If it does and I misunderstood, let me know.

Edit: Shaved off 1 byte by dying with an error instead of normal exit.

Crystal is statically typed, so I couldn't just do gets.chomp (gets can return nil, and nil doesn't have chomp). The alternative was gets.try &.chomp, but that takes much more space than just having the newlines.

In Crystal (and Ruby) you can do something like puts 0 if y=="0\n", however you can also shave off 2 bytes by doing y=="0\n"&&puts 0 as the && operator returns the last object it tests for truthiness.

loop is a method in the standard lib that infinitely runs the block. It's a much shorter way of writing while true;CODE;end.

p prints the result of .inspect on its arguments to the output. Here I abuse it as a shorter puts because for numbers it'll just return the number.

Title: Implement a Truth-Machine


答:
Charcoal, 6 bytes

```<code>Ｇ↘←↗Ｎ*
</code>```

Dead simple. Draw a polyGon of *, with side length taken from an input Number, where the sides go down-and-right, horizontally left, and up-and-right:

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

Then autocomplete the outline and fill it.

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

Try it online!

Title: Draw an hourglass

Body:
Again inspired by a task for Programming 101 here's another challenge.

Input:

A positive integer n >= 3. (has to be odd)

Output:

n lines of asterisks, where the first line has n asterisks and every new line has two asterisks less than the line before. Until hitting 1 asterisk. From there every new line has two asterisks more than the line before until getting back to n asterisks. Spaces or something like spaces have to used to align the asterisks so that it really will look like an hourglass.

General rules:

Trailing newlines are allowed but do not have to be used.

indentation is a must.

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

Since the course is taught in C++, I'm eager to see solutions in C++.

Test case (n=5):

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

Body:
Charcoal, 6 bytes

Ｇ↘←↗Ｎ*

Dead simple. Draw a polyGon of *, with side length taken from an input Number, where the sides go down-and-right, horizontally left, and up-and-right:

*   *
 * *
  *
 * *
*****

Then autocomplete the outline and fill it.

*****
 ***
  *
 ***
*****

Try it online!


Title: The Last Monday

Body:
Batch, <s>160</s> 152 bytes

@set/ay=%1,m=0,j=6*!(!(y%%4)*(y%%100)+(y%%400)),y=(y*5/4-y/100*3/4)%%7
@for %%d in (%j% 6 3 1 5 3 0 4 2 6 4 1)do @set/am+=1&if %%d==%y% call echo %%m%%

Port of @ETHproduction's answer. With month abbreviations for <s>197</s> 189 bytes:

@set/ay=%1,j=6*!(!(y%%4)*(y%%100)+(y%%400)),y=(y*5/4-y/100*3/4)%%7
@for %%m in (Jan.%j% Feb.6 Mar.3 Apr.1 May.5 Jun.3 Jul.0 Aug.4 Sep.2 Oct.6 Nov.4 Dec.1)do @if %%~xm==.%y% call echo %%~nm


答:
Python 2, 122 bytes

Ugh. Math with dates isn't as simple as I'd like.

from datetime import*
lambda y:[m+1for m in range(12)if(date(y,12,31)if m>10else(date(y,m+2,1)-timedelta(1))).weekday()<1]
```
<p><strong>Try it online</strong></p>
<p><strong>Same length:</strong></p>
<pre class="lang-python prettyprint-override"><code>from datetime import*
lambda y:[m-1for m in range(2,14)if(date(y,12,31)if m>12else(date(y,m,1)-timedelta(1))).weekday()<1]
</code>```

Title: The Last Monday

Body:
Python 2, 122 bytes

Ugh. Math with dates isn't as simple as I'd like.

from datetime import*
lambda y:[m+1for m in range(12)if(date(y,12,31)if m>10else(date(y,m+2,1)-timedelta(1))).weekday()<1]

Try it online

Same length:

from datetime import*
lambda y:[m-1for m in range(2,14)if(date(y,12,31)if m>12else(date(y,m,1)-timedelta(1))).weekday()<1]


Title: The Last Monday

Body:
Perl+cal, 46 bytes

say`cal $_ $ARGV[0]`=~/\n.{5}\n/&&$_ for 1..12

Example:

$ perl -E 'say`cal $_ $ARGV[0]`=~/\n.{5}\n/&&$_ for 1..12' 2016

2

10

$


答:
Bash+cal, 58 bytes

```<code>$ cat t.sh
for A in {1..12};do cal $A $1|grep -qx .....&&echo $A;done
$ bash t.sh 2016
2
10
$
</code>```

Title: The Last Monday

Body:
Bash+cal, 58 bytes

$ cat t.sh
for A in {1..12};do cal $A $1|grep -qx .....&&echo $A;done
$ bash t.sh 2016
2
10
$


答:
Ruby, 54 + 6 = 60 bytes

```<code>λ cat monday.rb
p (1..12).select{|m|Date.new($*[0].to_i,m,-1).monday?}
λ ruby -rdate monday.rb 2016
[2, 10]
</code>```

6 bytes for -rdate on the command line to get the Date class from the standard library.

Explanation: pretty straightforward thanks to the Ruby stdlib's great Date class. Not only does it have methods like monday?, tuesday?, etc, the constructor will take negative numbers for any field past year to mean 'count this field backwards from the end of the period represented by the previous field'. $* is shorthand for ARGV, so $*[0] is a quick way to get the first command line argument.

Title: The Last Monday

Body:
Ruby, 54 + 6 = 60 bytes

λ cat monday.rb
p (1..12).select{|m|Date.new($*[0].to_i,m,-1).monday?}
λ ruby -rdate monday.rb 2016
[2, 10]

6 bytes for -rdate on the command line to get the Date class from the standard library.

Explanation: pretty straightforward thanks to the Ruby stdlib's great Date class. Not only does it have methods like monday?, tuesday?, etc, the constructor will take negative numbers for any field past year to mean 'count this field backwards from the end of the period represented by the previous field'. $* is shorthand for ARGV, so $*[0] is a quick way to get the first command line argument.


答:
Crystal, 31 bytes

n=5;(1..n).each{|x|puts "*"*x}

Output:

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

Really demonstrates the beauty of Crystal/Ruby. n is the integer input, (1..n) is an inclusive range from 1 to n ([1, n]). .each is a method on Range that runs the provided block for every integer in the range.

Title: Draw an asterisk triangle

Body:
Crystal, 31 bytes

n=5;(1..n).each{|x|puts "*"*x}

Output:

*
**
***
****
*****

Really demonstrates the beauty of Crystal/Ruby. n is the integer input, (1..n) is an inclusive range from 1 to n ([1, n]). .each is a method on Range that runs the provided block for every integer in the range.