答:
><> / Fishing, 38 bytes

```<code>_"kcirt"ooooo;
[+vCCCCCCCC
   `treat`N
</code>```

For the sake of making a ><> / Fishing polyglot.

It's my first piece of Fishing code after having played for a long time with ><>.

My first impression : as in nature, the fisherman has less physical capabilities than its pray but makes up for it with its tool !

Here the code is extremely simple : ><> will only execute the first line, where _ is a vertical mirror and has no effect since the fish starts swimming horizontally. It just pushes trick on the stack then print it before stopping.

For Fishing, the _ instructs to go down. The fisherman will follow the deck that is the second line while catching the characters of the third line. These will push treat on the tape then print it, stopping as it reaches the end of the deck.

If erroring out is allowed, you could go down to 35 bytes with the following code which will throw an error when run as ><> once the trick is printed off the stack :

```<code>_"kcirt">o<
[+vCCCCCCCC
   `treat`N
</code>```

You should also check my themed languages answers, #hell / Agony and evil / ZOMBIE !

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:
><> / Fishing, 38 bytes

_"kcirt"ooooo;
[+vCCCCCCCC
   `treat`N

For the sake of making a ><> / Fishing polyglot.

It's my first piece of Fishing code after having played for a long time with ><>.

My first impression : as in nature, the fisherman has less physical capabilities than its pray but makes up for it with its tool !

Here the code is extremely simple : ><> will only execute the first line, where _ is a vertical mirror and has no effect since the fish starts swimming horizontally. It just pushes trick on the stack then print it before stopping.

For Fishing, the _ instructs to go down. The fisherman will follow the deck that is the second line while catching the characters of the third line. These will push treat on the tape then print it, stopping as it reaches the end of the deck.

If erroring out is allowed, you could go down to 35 bytes with the following code which will throw an error when run as ><> once the trick is printed off the stack :

_"kcirt">o<
[+vCCCCCCCC
   `treat`N

You should also check my themed languages answers, #hell / Agony and evil / ZOMBIE !


问:
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.

答:
Perl, 44 bytes

This is a port of @xnor's answer.

```<code>$n=26;say$"x($n/2),$@=chr(97+$n).$@while$n--
</code>```

Needs -E (or -M5.010) to run :

```<code>perl -E '$n=26;say$"x($n/2),$@=chr(97+$n).$@while$n--';
</code>```

ContentLicense: CC BY-SA 3.0

Title: Draw an alphabet party hat

Body:
Perl, 44 bytes

This is a port of @xnor's answer.

$n=26;say$"x($n/2),$@=chr(97+$n).$@while$n--

Needs -E (or -M5.010) to run :

perl -E '$n=26;say$"x($n/2),$@=chr(97+$n).$@while$n--';


问:
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

```

答:
C / Java 7, <s>165</s> <s>155</s> <s>128</s> <s>123</s> <s>122</s> <s>120</s> 103 bytes

```<code>//\
class a{public static void main(String[] s){System.out.print("treat"/*
main(){{puts("trick"/**/);}}
</code>```

//\ makes the next line also a comment in C but is a regular one line comment in Java, so you can make C ignore code meant for Java and by adding /* in the second line you can make a comment for Java that is parsed as code by C.

Edit:
I improved it a little bit by reorganizing the lines and comments.

Edit2:
I did some more reorganizing and shortened it even more.

Edit3:
I added corrections suggested by BrainStone to remove 5 bytes, thanks :)

Edit4:
One newline turned out to be unnecessary so I removed it.

Edit5:
I changed printf to puts.

Edit6:
I added a correction suggested by Ray Hamel.

Title: Trick or Treat polyglot

Body:
C / Java 7, <s>165</s> <s>155</s> <s>128</s> <s>123</s> <s>122</s> <s>120</s> 103 bytes

//\
class a{public static void main(String[] s){System.out.print("treat"/*
main(){{puts("trick"/**/);}}

//\ makes the next line also a comment in C but is a regular one line comment in Java, so you can make C ignore code meant for Java and by adding /* in the second line you can make a comment for Java that is parsed as code by C.

Edit:
I improved it a little bit by reorganizing the lines and comments.

Edit2:
I did some more reorganizing and shortened it even more.

Edit3:
I added corrections suggested by BrainStone to remove 5 bytes, thanks :)

Edit4:
One newline turned out to be unnecessary so I removed it.

Edit5:
I changed printf to puts.

Edit6:
I added a correction suggested by Ray Hamel.


问:
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.

答:
C++, 63 bytes

```<code>void s(int n){if(n)s(n-1),cout<<setfill('*')<<setw(n+1)<<"\n";}
</code>```

Usage:

```<code>#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
    s(5);
}
</code>```

Overrides the filling character (which is usually a space), and outputs an empty string (or actually a newline).

One weird thing about this code is the usage of if (...) - I cannot find a way to replace it by a conditional operator ... ? ... : ....

ContentLicense: CC BY-SA 4.0

Title: Draw an asterisk triangle

Body:
C++, 63 bytes

void s(int n){if(n)s(n-1),cout<<setfill('*')<<setw(n+1)<<"\n";}

Usage:

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
    s(5);
}

Overrides the filling character (which is usually a space), and outputs an empty string (or actually a newline).

One weird thing about this code is the usage of if (...) - I cannot find a way to replace it by a conditional operator ... ? ... : ....


问:
Bingo card generator
A Bingo card is five columns of five squares each, with the middle square designated "FREE".  Numbers cannot duplicate.

The five columns are populated with the following range of numbers:

B:1-15

I:16-30

N:31-45

G:46-60

O:61-75

In as few characters as possible, output a string that can be interpreted as a randomized Bingo card.
For example:

1,2,3,4,5,16,17,18,19,20,31,32,33,34,35,46,47,48,49,50,61,62,63,64,65

This example is not randomized so that I can show that column 1 is populated with 1,2,3,4,5.  Also note that the free space has not been given any special treatment because the front-end that interprets this string will skip it.

Another example would be:

1,16,31,46,61,2,17,32,47,62...

In this example, the output is by row instead of by column.

A third example might be:

01020304051617181920313233343546474849506162636465

This is the same output as the 1st example except in fixed length.

Title: Bingo card generator

Body:
PHP, 86

for($o=[];25>$i=count($o);){$n=rand(1,15)+($i-$i%5)*3;$o[$n]=$n;}echo implode(",",$o);


答:
Dyalog APL, 8 bytes

↑'*'⍴⍨¨⍳
```

↑ matrify the list consisting of

'*' the string "*"

⍴⍨ reshaped by

¨ each of

⍳ the integers 1 through the argument.

TryAPL online!

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:
Dyalog APL, 8 bytes

↑'*'⍴⍨¨⍳

↑ matrify the list consisting of

'*' the string "*"

⍴⍨ reshaped by

¨ each of

⍳ the integers 1 through the argument.

TryAPL online!


答:
Scala / Javascript, 33 bytes

```<code>if(0==false)"trick"; else "treat"
</code>```

0==false returns true in javascript, but false in scala

Title: Trick or Treat polyglot

Body:
Scala / Javascript, 33 bytes

if(0==false)"trick"; else "treat"

0==false returns true in javascript, but false in scala


问:
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>for($c=str_pad,$m=$n=$argv[1];$n<=$m;$n+=$d=$d>0||$n<2?2:-2)echo$c($c('',$n,'*'),$m,' ',2)."
";
</code>```

Instead of storing the rows in an array and then outputting everything, the for loop goes down until 1, and then goes back up to the original number.

Title: Draw an hourglass

Body:
PHP, 95 bytes

for($c=str_pad,$m=$n=$argv[1];$n<=$m;$n+=$d=$d>0||$n<2?2:-2)echo$c($c('',$n,'*'),$m,' ',2)."
";

Instead of storing the rows in an array and then outputting everything, the for loop goes down until 1, and then goes back up to the original number.


答:
LiveScript + JavaScript ES6, 29 bytes

```<code>alert(/.*/=='trick'||'treat')
</code>```

In LiveScript comparing a regular expression with a string literal return an array with the matches of the expression in the string. In JavaScript it only returns true the string representation of both are the same. alert will convert it's input to string, displaying ['trick'] as just trick.

Title: Trick or Treat polyglot

Body:
LiveScript + JavaScript ES6, 29 bytes

alert(/.*/=='trick'||'treat')

In LiveScript comparing a regular expression with a string literal return an array with the matches of the expression in the string. In JavaScript it only returns true the string representation of both are the same. alert will convert it's input to string, displaying ['trick'] as just trick.


问:
Code Golf Golf Golf

Golf Challenge

Given the below ASCII "Green".

```<code>|          |
|  |>      |
|  |       |
|  O       |
|          |
|          |
|          |
|          |
|          |
|          |
</code>```

Let | Denote a wall

Let | Denote half the flag pole

Let > Denote the flag on the pole

Let O Denote the hole

Let o Denote the ball

The dimensions of the "Green" is 10x10. There are ten spaces between the two walls |.

There are also ten spaces, empty or not between the top and the bottom of the green.

Challenge

Input an x and y value or
generate two random numbers to "shoot" a golf ball onto the green.

If the x, y generated does not touch the hole or the flag pole/flag output "Try Again!"

If the x, y generated hits the hole output "Hole in One!"

if the x, y generated hits the pole output "Lucky Shot!"

if the x, y generated hits the flag output "Close One!"

After the shot, output the location of the ball on the green with a o, replacing any character it hit. Also output the respective saying above.

Examples:

```<code>//Hole in one example, the O was replaced with a o
Randomed x = 3
Randomed y = 4

"Hole in One!"

|          |
|  |>      |
|  |       |
|  o       |
|          |
|          |
|          |
|          |
|          |
|          |

//Clone example, the top half of the pole was replaced with a o
Randomed x = 3
Randomed y = 2

"Lucky Shot!"

|          |
|  o>      |
|  |       |
|  O       |
|          |
|          |
|          |
|          |
|          |
|          |

//Lucky Shot example, the > was replaced with a o
Randomed x = 4
Randomed y = 2

"Close One!"

|          |
|  |o      |
|  |       |
|  O       |
|          |
|          |
|          |
|          |
|          |
|          |

//Try Again example, the <space> was replaced with a o
Randomed x = 5
Randomed y = 1

"Try Again!"

|     o    |
|  |>      |
|  |       |
|  O       |
|          |
|          |
|          |
|          |
|          |
|          |
</code>```

Have fun and good luck and as this is code-golf the shortest code wins!

答:
Dyalog APL, 147 (or 127) bytes

Takes (y,x) as argument.

{G←10 10⍴''
G[⍳4;3]←' ||O'
G[2;4]←'>'
G[⊃⍵;⊃⌽⍵]←'o'               ⍝ G[y;x]←
⎕←'|',G,'|'                 ⍝ Print G with sides
4 3≡⍵:'Hole in One!'        ⍝ If (y,x) ≡ (4,3)
(⊂⍵)∊2 3∘.,3:'Lucky Shot!'  ⍝ If (y,x) ∊ {(2,3), (2,3)}
2 4≡⍵:'Close One!'
'Try Again!'}               ⍝ Else
```
<p>From version 16.0, we can almost halve the byte-count with the new <code>@</code> operator;</p>
<p><code>@</code> puts the left operand into the right-operand positions in the right argument: <code>NewChars @ Positions ⊢ Data</code></p>
<pre class="lang-apl prettyprint-override"><code>{⎕←'|','|',⍨' ||O>o'@((2 4)⍵,⍨3,⍨¨⍳4)⊢10 10⍴''
4 3≡⍵:'Hole in One!'
(⊂⍵)∊2 3∘.,3:'Lucky Shot!'
2 4≡⍵:'Close One!'
'Try Again!'}
</code>```

Slightly modified code to make permissible in TryAPL:

Hole in One, Lucky Shot 1, Lucky Shot 2, Close One, Random

Title: Code Golf Golf Golf

Body:
Dyalog APL, 147 (or 127) bytes

Takes (y,x) as argument.

{G←10 10⍴''
G[⍳4;3]←' ||O'
G[2;4]←'>'
G[⊃⍵;⊃⌽⍵]←'o'               ⍝ G[y;x]←
⎕←'|',G,'|'                 ⍝ Print G with sides
4 3≡⍵:'Hole in One!'        ⍝ If (y,x) ≡ (4,3)
(⊂⍵)∊2 3∘.,3:'Lucky Shot!'  ⍝ If (y,x) ∊ {(2,3), (2,3)}
2 4≡⍵:'Close One!'
'Try Again!'}               ⍝ Else

From version 16.0, we can almost halve the byte-count with the new @ operator;

@ puts the left operand into the right-operand positions in the right argument: NewChars @ Positions ⊢ Data

{⎕←'|','|',⍨' ||O>o'@((2 4)⍵,⍨3,⍨¨⍳4)⊢10 10⍴''
4 3≡⍵:'Hole in One!'
(⊂⍵)∊2 3∘.,3:'Lucky Shot!'
2 4≡⍵:'Close One!'
'Try Again!'}

Slightly modified code to make permissible in TryAPL:

<a href="http://tryapl.org/?a=%7BG%u219010%2010%u2374%27%27%20%u22C4%20G%5B%u23734%3B3%5D%u2190%27%20%7C%7CO%27%20%u22C4%20G%5B2%3B4%5D%u2190%27%3E%27%20%u22C4%20G%5B%u2283%u2375%3B%u2283%u233D%u2375%5D%u2190%27o%27%20%u22C4%20%u2206%u2190%27%7C%27%2CG%2C%27%7C%27%20%u22C4%204%203%u2261%u2375%3A%u2206%27Hole%20in%20One%21%27%20%u22C4%20%28%u2282%u2375%29%u220A2%203%u2218.%2C3%3A%u2206%27Lucky%20Shot%21%27%20%u22C4%202%204%u2261%u2375%3A%u2206%27Close%20One%21%27%20%u22C4%20%u2206%27Try%20Again%21%27%7D%204%203&run" rel="nofollow noreferrer">Hole in One, <a href="http://tryapl.org/?a=%7BG%u219010%2010%u2374%27%27%20%u22C4%20G%5B%u23734%3B3%5D%u2190%27%20%7C%7CO%27%20%u22C4%20G%5B2%3B4%5D%u2190%27%3E%27%20%u22C4%20G%5B%u2283%u2375%3B%u2283%u233D%u2375%5D%u2190%27o%27%20%u22C4%20%u2206%u2190%27%7C%27%2CG%2C%27%7C%27%20%u22C4%204%203%u2261%u2375%3A%u2206%27Hole%20in%20One%21%27%20%u22C4%20%28%u2282%u2375%29%u220A2%203%u2218.%2C3%3A%u2206%27Lucky%20Shot%21%27%20%u22C4%202%204%u2261%u2375%3A%u2206%27Close%20One%21%27%20%u22C4%20%u2206%27Try%20Again%21%27%7D%202%203&run" rel="nofollow noreferrer">Lucky Shot 1, <a href="http://tryapl.org/?a=%7BG%u219010%2010%u2374%27%27%20%u22C4%20G%5B%u23734%3B3%5D%u2190%27%20%7C%7CO%27%20%u22C4%20G%5B2%3B4%5D%u2190%27%3E%27%20%u22C4%20G%5B%u2283%u2375%3B%u2283%u233D%u2375%5D%u2190%27o%27%20%u22C4%20%u2206%u2190%27%7C%27%2CG%2C%27%7C%27%20%u22C4%204%203%u2261%u2375%3A%u2206%27Hole%20in%20One%21%27%20%u22C4%20%28%u2282%u2375%29%u220A2%203%u2218.%2C3%3A%u2206%27Lucky%20Shot%21%27%20%u22C4%202%204%u2261%u2375%3A%u2206%27Close%20One%21%27%20%u22C4%20%u2206%27Try%20Again%21%27%7D%203%203&run" rel="nofollow noreferrer">Lucky Shot 2, <a href="http://tryapl.org/?a=%7BG%u219010%2010%u2374%27%27%20%u22C4%20G%5B%u23734%3B3%5D%u2190%27%20%7C%7CO%27%20%u22C4%20G%5B2%3B4%5D%u2190%27%3E%27%20%u22C4%20G%5B%u2283%u2375%3B%u2283%u233D%u2375%5D%u2190%27o%27%20%u22C4%20%u2206%u2190%27%7C%27%2CG%2C%27%7C%27%20%u22C4%204%203%u2261%u2375%3A%u2206%27Hole%20in%20One%21%27%20%u22C4%20%28%u2282%u2375%29%u220A2%203%u2218.%2C3%3A%u2206%27Lucky%20Shot%21%27%20%u22C4%202%204%u2261%u2375%3A%u2206%27Close%20One%21%27%20%u22C4%20%u2206%27Try%20Again%21%27%7D%202%204&run" rel="nofollow noreferrer">Close One, <a href="http://tryapl.org/?a=%7BG%u219010%2010%u2374%27%27%20%u22C4%20G%5B%u23734%3B3%5D%u2190%27%20%7C%7CO%27%20%u22C4%20G%5B2%3B4%5D%u2190%27%3E%27%20%u22C4%20G%5B%u2283%u2375%3B%u2283%u233D%u2375%5D%u2190%27o%27%20%u22C4%20%u2206%u2190%27%7C%27%2CG%2C%27%7C%27%20%u22C4%204%203%u2261%u2375%3A%u2206%27Hole%20in%20One%21%27%20%u22C4%20%28%u2282%u2375%29%u220A2%203%u2218.%2C3%3A%u2206%27Lucky%20Shot%21%27%20%u22C4%202%204%u2261%u2375%3A%u2206%27Close%20One%21%27%20%u22C4%20%u2206%27Try%20Again%21%27%7D%20%3F2/10&run" rel="nofollow noreferrer">Random


答:
PHP/Perl, 28 bytes

```<code>print defined&x?trick:treat;
</code>```

defined&x

gives something truthy in PHP (no idea why, but it does).

In Perl it checks if function x is defined - which is not.

--> trick in PHP, treat in Perl.

Title: Trick or Treat polyglot

Body:
PHP/Perl, 28 bytes

print defined&x?trick:treat;

defined&x

gives something truthy in PHP (no idea why, but it does).

In Perl it checks if function x is defined - which is not.

--> trick in PHP, treat in Perl.


答:
R, <s>63</s> <s>51</s> <s>50</s> <s>49</s> 45 bytes

Thanks to Billywob for ongoing suggestions and encouraging my competitive streak.

```<code>cat(sapply(split(n<-1:75,cut(n,5)),sample,5))
</code>```

5 14 15 3 1 20 30 28 18 27 32 45 42 43 41 49 54 50 56 47 68 66 64 73 71

Title: Bingo card generator

Body:
A Bingo card is five columns of five squares each, with the middle square designated "FREE".  Numbers cannot duplicate.

The five columns are populated with the following range of numbers:

B:1-15

I:16-30

N:31-45

G:46-60

O:61-75

In as few characters as possible, output a string that can be interpreted as a randomized Bingo card.
For example:

1,2,3,4,5,16,17,18,19,20,31,32,33,34,35,46,47,48,49,50,61,62,63,64,65

This example is not randomized so that I can show that column 1 is populated with 1,2,3,4,5.  Also note that the free space has not been given any special treatment because the front-end that interprets this string will skip it.

Another example would be:

1,16,31,46,61,2,17,32,47,62...

In this example, the output is by row instead of by column.

A third example might be:

01020304051617181920313233343546474849506162636465

This is the same output as the 1st example except in fixed length.

Body:
R, <s>63</s> <s>51</s> <s>50</s> <s>49</s> 45 bytes

Thanks to Billywob for ongoing suggestions and encouraging my competitive streak.

cat(sapply(split(n<-1:75,cut(n,5)),sample,5))

5 14 15 3 1 20 30 28 18 27 32 45 42 43 41 49 54 50 56 47 68 66 64 73 71


答:
Scala / CSS, 64 bytes

```<code>/*\u002A/ print("trick")//*/
/*/**/
*:after {content:'treat';}*/
</code>```

Try it: jsfiddle ideone (warning: wrong syntax highlighting)

Scala, like java, evaluates unicode escapes (\u002A, asterisk) before anything else, so scalac parses the code like

```<code>/**/                          //block comment
print("trick")                //code
//*/                          //eol-comment
/*                            //scala supports nested block comments, so this comment...
  /*
  */
  p:after {content:'treat';}
*/                            //...ends here
</code>```

The CSS is parsed like this:

```<code>/*hello\u002A/ print("trick")//*/  //block comment
/*                                 //a block comment
  /*                                 //with a slash and an asterisk
*/                                 //ending here
p:after {content:'treat';}         //code
*/                                 //invalid css syntax, jsfiddle silently ignores this
</code>```

Title: Trick or Treat polyglot

Body:
Scala / CSS, 64 bytes

/*\u002A/ print("trick")//*/
/*/**/
*:after {content:'treat';}*/

Try it: jsfiddle ideone (warning: wrong syntax highlighting)

Scala, like java, evaluates unicode escapes (\u002A, asterisk) before anything else, so scalac parses the code like

/**/                          //block comment
print("trick")                //code
//*/                          //eol-comment
/*                            //scala supports nested block comments, so this comment...
  /*
  */
  p:after {content:'treat';}
*/                            //...ends here

The CSS is parsed like this:

/*hello\u002A/ print("trick")//*/  //block comment
/*                                 //a block comment
  /*                                 //with a slash and an asterisk
*/                                 //ending here
p:after {content:'treat';}         //code
*/                                 //invalid css syntax, jsfiddle silently ignores this


答:
VBA/Windows Batch, 21 Bytes

```<code>?"trick"'||echo.treat
</code>```

For VBA, use the immediate window.  ? is print, ' makes the remainder of the line a comment
For Windows Batch, the || is an OR and makes the second bit run even if the first errors

Title: Trick or Treat polyglot

Body:
VBA/Windows Batch, 21 Bytes

?"trick"'||echo.treat

For VBA, use the immediate window.  ? is print, ' makes the remainder of the line a comment
For Windows Batch, the || is an OR and makes the second bit run even if the first errors


问:
Alphabet triangle
You are to print this exact text:

```<code>A
ABA
ABCBA
ABCDCBA
ABCDEDCBA
ABCDEFEDCBA
ABCDEFGFEDCBA
ABCDEFGHGFEDCBA
ABCDEFGHIHGFEDCBA
ABCDEFGHIJIHGFEDCBA
ABCDEFGHIJKJIHGFEDCBA
ABCDEFGHIJKLKJIHGFEDCBA
ABCDEFGHIJKLMLKJIHGFEDCBA
ABCDEFGHIJKLMNMLKJIHGFEDCBA
ABCDEFGHIJKLMNONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXYXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXYZYXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXYXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNONMLKJIHGFEDCBA
ABCDEFGHIJKLMNMLKJIHGFEDCBA
ABCDEFGHIJKLMLKJIHGFEDCBA
ABCDEFGHIJKLKJIHGFEDCBA
ABCDEFGHIJKJIHGFEDCBA
ABCDEFGHIJIHGFEDCBA
ABCDEFGHIHGFEDCBA
ABCDEFGHGFEDCBA
ABCDEFGFEDCBA
ABCDEFEDCBA
ABCDEDCBA
ABCDCBA
ABCBA
ABA
A
</code>```

Specs

Extra trailing newlines are allowed at the end of the output.

Extra trailing spaces (U+0020) are allowed at the end of each line, including the extra trailing newlines.

You can use all lowercase instead of all uppercase, but you cannot print partially lowercase partially uppercase.

You can return the text as a function output instead of printing it in a full program.

Scoring

Since this is a triangle, and a triangle has 3 sides, and 3 is a small number, your code should be small in terms of byte-count.

答:
PHP, 78 Bytes

foreach(range(A,Z)as$r)$o.="\n$t".strrev($t.=$r);echo$o.substr(strrev($o),51);
```

Title: Alphabet triangle


答:
#hell / Agony, 43 bytes

So much ><> everywhere, what is this, an April Fools challenge? Here's an answer with appropriately themed languages.

```<code>--<.<.<.<.<.$
io.write("trick")--+<~}~@+{+<
</code>```

#hell is a subset of LUA which fortunately accepts io.write output calls. We use LUA's -- comments so that it only executes this fragment.

Agony is a Brainfuck derivative, which has the particularity to have its code and working memory on the same tape. The first line only prints 5 characters (10 cells) from the end of the code segment, where I encoded treat as Agony commands. LUA's comment opening -- modifies the value of a cell which isn't used.

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:
#hell / Agony, 43 bytes

So much ><> everywhere, what is this, an April Fools challenge? Here's an answer with appropriately themed languages.

--<.<.<.<.<.$
io.write("trick")--+<~}~@+{+<

#hell is a subset of LUA which fortunately accepts io.write output calls. We use LUA's -- comments so that it only executes this fragment.

Agony is a Brainfuck derivative, which has the particularity to have its code and working memory on the same tape. The first line only prints 5 characters (10 cells) from the end of the code segment, where I encoded treat as Agony commands. LUA's comment opening -- modifies the value of a cell which isn't used.


答:
PHP, 158 bytes

(-2 if I can omit the start tag)

```<code><?$v=$argv[1]/2;while($c++<$v){$a="";$b=$v+.5;while(--$b)$a.=$b<$c?" ":"*";$z[]=strrev($a)."*$a";}$c=array_pop($z);$a=join($z,"
");echo"$a
$c
".strrev($a);
</code>```

A similar approach to the one @hd took but uses manual concatenation instead of built-in string functions with overly long names. I wish I could call $z->pop()

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:
PHP, 158 bytes

(-2 if I can omit the start tag)

<?$v=$argv[1]/2;while($c++<$v){$a="";$b=$v+.5;while(--$b)$a.=$b<$c?" ":"*";$z[]=strrev($a)."*$a";}$c=array_pop($z);$a=join($z,"
");echo"$a
$c
".strrev($a);

A similar approach to the one @hd took but uses manual concatenation instead of built-in string functions with overly long names. I wish I could call $z->pop()


答:
Haskell / Standard ML, 56 bytes

fun putStr x=print"treat";val main=();main=putStr"trick"
```
<p><strong>Haskell view</strong></p>
<p>The semicolons allow multiple declarations in one line and act like linebreaks, so we get</p>
<pre class="lang-haskell prettyprint-override"><code>fun putStr x=print"treat"
val main=()
main=putStr"trick"
</code>```

A Haskell program is executed by calling the main function, so in the last row putStr"trick" is executed which just prints trick.

The first two rows are interpreted as function declarations following the pattern <functionName> <argumentName1> ... <argumentNameN> = <functionBody>. So in the first row a function named fun is declared which takes two arguments named putStr and x and the function body print"treat". This is a valid Haskell function with type fun :: t -> t1 -> IO (), meaning it takes an argument of an arbitrary type t and a second one of some type t1 an then returns an IO-action. The types t and t1 don't matter as the arguments aren't used in the function body. The IO-action type results from print"treat", which prints "treat" to StdOut (notice the ", that's why putStr instead of print is used in main). However as it's only a function declaration, nothing is actually printed as fun is not called in main.

The same happens in the second line val main=();, a function val is declared which takes an arbitrary argument named main and returns unit, the empty tuple (). It's type is val :: t -> () (Both the value and the type of unit are denoted with ()).

Try it on Ideone.

Standard ML view

Standard ML is a primarily functional language with a syntax related to, but not the same as Haskell. In particular, function declarations are prefixed with the keyword fun if they take any arguments, and the keyword val if they don't. Also it's possible to have an expression at top level (meaning not inside any declaration) which is executed when the program is run. (In Haskell writing 1+2 outside a declaration throws a naked expression at top level-error). Finally the symbol for testing equality is = instead of == in Haskell. (There are many more differences, but those are the only ones that matter for this program.)

So SML sees two declarations

fun putStr x=print"treat";
val main=();
```
<p>followed by an expression</p>
<pre class="lang-haskell prettyprint-override"><code>main=putStr"trick"
</code>```

which is then evaluated. To determine whether main equals putStr"trick", both sides have to be evaluated and both must have the same type, as SML (as well as Haskell) is statically typed.
Let us first have a look at the right side: putStr is not a library function in SML, but we declared a function named putStr in the line fun putStr x=print"treat"; - it takes an argument x (this is the string "trick" in our case) and immediately forgets it again, as it does not occur in the function body. Then the body print"treat" is executed which prints treat (without enclosing ", SML's print is different from Haskell's print).

print has the type string -> unit, so putStr has the type a -> unit and therefore putStr"trick" has just type unit. In order to be well-typed, main must have type unit too. The value for unit is in SML the same as in Haskell (), so we declare val main=(); and everything is well-typed.

Try it on codingground.

Note: The output in the console is

val putStr = fn : 'a -> unit
val main = () : unit
treatval it = true : bool
```

because in SML\NJ the value and type of every statement is displayed after each declaration. So first the types of putStr and main are shown, then the expressions gets evaluated causing treat to be printed, then the value of the expression (true as both sides  of = are ()) is bound to the implicit result variable it which is then also displayed.

Title: Trick or Treat polyglot

Body:
Haskell / Standard ML, 56 bytes

fun putStr x=print"treat";val main=();main=putStr"trick"

Haskell view

The semicolons allow multiple declarations in one line and act like linebreaks, so we get

fun putStr x=print"treat"
val main=()
main=putStr"trick"

A Haskell program is executed by calling the main function, so in the last row putStr"trick" is executed which just prints trick.

The first two rows are interpreted as function declarations following the pattern <functionName> <argumentName1> ... <argumentNameN> = <functionBody>. So in the first row a function named fun is declared which takes two arguments named putStr and x and the function body print"treat". This is a valid Haskell function with type fun :: t -> t1 -> IO (), meaning it takes an argument of an arbitrary type t and a second one of some type t1 an then returns an IO-action. The types t and t1 don't matter as the arguments aren't used in the function body. The IO-action type results from print"treat", which prints "treat" to StdOut (notice the ", that's why putStr instead of print is used in main). However as it's only a function declaration, nothing is actually printed as fun is not called in main.

The same happens in the second line val main=();, a function val is declared which takes an arbitrary argument named main and returns unit, the empty tuple (). It's type is val :: t -> () (Both the value and the type of unit are denoted with ()).

Try it on Ideone.

Standard ML view

Standard ML is a primarily functional language with a syntax related to, but not the same as Haskell. In particular, function declarations are prefixed with the keyword fun if they take any arguments, and the keyword val if they don't. Also it's possible to have an expression at top level (meaning not inside any declaration) which is executed when the program is run. (In Haskell writing 1+2 outside a declaration throws a naked expression at top level-error). Finally the symbol for testing equality is = instead of == in Haskell. (There are many more differences, but those are the only ones that matter for this program.)

So SML sees two declarations

fun putStr x=print"treat";
val main=();

followed by an expression

main=putStr"trick"

which is then evaluated. To determine whether main equals putStr"trick", both sides have to be evaluated and both must have the same type, as SML (as well as Haskell) is statically typed.
Let us first have a look at the right side: putStr is not a library function in SML, but we declared a function named putStr in the line fun putStr x=print"treat"; - it takes an argument x (this is the string "trick" in our case) and immediately forgets it again, as it does not occur in the function body. Then the body print"treat" is executed which prints treat (without enclosing ", SML's print is different from Haskell's print).

print has the type string -> unit, so putStr has the type a -> unit and therefore putStr"trick" has just type unit. In order to be well-typed, main must have type unit too. The value for unit is in SML the same as in Haskell (), so we declare val main=(); and everything is well-typed.

Try it on codingground.

Note: The output in the console is

val putStr = fn : 'a -> unit
val main = () : unit
treatval it = true : bool

because in SML\NJ the value and type of every statement is displayed after each declaration. So first the types of putStr and main are shown, then the expressions gets evaluated causing treat to be printed, then the value of the expression (true as both sides  of = are ()) is bound to the implicit result variable it which is then also displayed.


答:
HTML / HTML+JavaScript, 53 bytes

```<code>treat<script>document.body.innerHTML='trick'</script>
</code>```

treat is the document´s text content in HTML.

If JS is enabled, it will replace the HTML content with trick.

Title: Trick or Treat polyglot

Body:
HTML / HTML+JavaScript, 53 bytes

treat<script>document.body.innerHTML='trick'</script>

treat is the document´s text content in HTML.

If JS is enabled, it will replace the HTML content with trick.


答:
Pyke, <s>18</s> 12 bytes

```<code>26Fed*Gi>+)X
</code>```

Try it here!

```<code>26F       )  -  for i in range(26):
   ed*       -    (i//2)*" "
         +   -   concatenate ↑ and ↓
      Gi>    -    alphabet[i:]
           X - splat(^) (print list reversed with newlines)
</code>```

Or 10 bytes noncompetitive

```<code>26DXF2GR>c
</code>```

Try it here!

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:
Pyke, <s>18</s> 12 bytes

26Fed*Gi>+)X

Try it here!

26F       )  -  for i in range(26):
   ed*       -    (i//2)*" "
         +   -   concatenate ↑ and ↓
      Gi>    -    alphabet[i:]
           X - splat(^) (print list reversed with newlines)

Or 10 bytes noncompetitive

26DXF2GR>c

Try it here!


问:
I'm not the language you're looking for!
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.

答:
Python 2/C, 179 bytes

```<code>#if/*
"""*/1
main(){char*//"""
s="This program wasn't written in %s, it was built for %s!"
#if/*
"""*/1
;printf(s,"C","Python");}
#endif
#endif/*"""
print s%("Python","C")
#*/
</code>```

Syntax-highlighted version:

Python:

#if/*
"""*/1
main(){char*//"""
s="This program wasn't written in %s, it was built for %s!"
#if/*
"""*/1
;printf(s,"C","Python");}
#endif
#endif/*"""
print s%("Python","C")
#*/
```
<p>C (poor highlighting, sorry)</p>
<pre class="lang-c prettyprint-override"><code>#if/*
"""*/1
main(){char*//"""
s="This program wasn't written in %s, it was built for %s!"
#if/*
"""*/1
;printf(s,"C","Python");}
#endif
#endif/*"""
print s%("Python","C")
#*/
</code>```

Body:
Python 2/C, 179 bytes

#if/*
"""*/1
main(){char*//"""
s="This program wasn't written in %s, it was built for %s!"
#if/*
"""*/1
;printf(s,"C","Python");}
#endif
#endif/*"""
print s%("Python","C")
#*/

Syntax-highlighted version:

Python:

#if/*
"""*/1
main(){char*//"""
s="This program wasn't written in %s, it was built for %s!"
#if/*
"""*/1
;printf(s,"C","Python");}
#endif
#endif/*"""
print s%("Python","C")
#*/

C (poor highlighting, sorry)

#if/*
"""*/1
main(){char*//"""
s="This program wasn't written in %s, it was built for %s!"
#if/*
"""*/1
;printf(s,"C","Python");}
#endif
#endif/*"""
print s%("Python","C")
#*/


答:
CJam / Stuck, <s>19</s> 17 Bytes

Stuck makes a comeback!

```<code>"trick"e#"treat"p
</code>```

CJam will print trick, and Stuck will print treat! Here's an explanation in both languages.

CJam:

```<code>"trick"            e# pushes the strings "trick" to the stack
       e#"treat"p  e# the e# comments everything else out, stack implicitly prints
</code>```

Stuck: note that Stuck does not have comments so you can't run the below

```<code>"trick"e#"treat"    | pushes the values "trick", e^2, "treat" to the stack
                p   | prints the top stack value
</code>```

 Old Versions:

19 Bytes: "tr""ick""eat";e#yy

Title: Trick or Treat polyglot

Body:
CJam / Stuck, <s>19</s> 17 Bytes

Stuck makes a comeback!

"trick"e#"treat"p

CJam will print trick, and Stuck will print treat! Here's an explanation in both languages.

CJam:

"trick"            e# pushes the strings "trick" to the stack
       e#"treat"p  e# the e# comments everything else out, stack implicitly prints

Stuck: note that Stuck does not have comments so you can't run the below

"trick"e#"treat"    | pushes the values "trick", e^2, "treat" to the stack
                p   | prints the top stack value

 Old Versions:

19 Bytes: "tr""ick""eat";e#yy


答:
evil / ZOMBIE, 109 bytes

Another spooky answer !

```<code>xf is a vampire summon task f say "trick" stumble say "jzuueeueeawuuwzaeeaeeaeawuuuuwzuueeueeaw" animate bind
</code>```

The ZOMBIE code defines a vampire named xf whose only task f is activated at instanciation and will output trick once before being deactivated by stumble. The other say call is dead code (how appropriate !) for ZOMBIE, but contains most of the evil code.

For evil, the xf name is a call to jump to the next j, which precedes the zuueeueeawuuwzaeeaeeaeawuuuuwzuueeueeaw zombie moan that crafts and output treat. The code following is either executed (lowercase letters) or ignored but since there's no w no output should be produced.

Title: Trick or Treat polyglot

Body:
evil / ZOMBIE, 109 bytes

Another spooky answer !

xf is a vampire summon task f say "trick" stumble say "jzuueeueeawuuwzaeeaeeaeawuuuuwzuueeueeaw" animate bind

The ZOMBIE code defines a vampire named xf whose only task f is activated at instanciation and will output trick once before being deactivated by stumble. The other say call is dead code (how appropriate !) for ZOMBIE, but contains most of the evil code.

For evil, the xf name is a call to jump to the next j, which precedes the zuueeueeawuuwzaeeaeeaeawuuuuwzuueeueeaw zombie moan that crafts and output treat. The code following is either executed (lowercase letters) or ignored but since there's no w no output should be produced.


答:
R, <s>230</s> 226 bytes

```<code>M=matrix("|",10,10);M[2:9,]=" ";M[34]="0";M[4,2:3]="f";M[15]=">";function(x,y){m=switch(M[y,x],">"="Close One","f"="Lucky Shot","0"="Hole In One","Try again");M[y,x]="o";cat(m,"!\n",sep="");cat(gsub("f","|",M),sep="",fill=10)}
</code>```

Thanks to @billywob for -2 bytes, noticing M[a,b] is equivalent to M[c] in a couple of cases.

Annoyingly, the two cat calls (!) can't be concatenated into one, since the fill argument messes up the message. Argh!

Title: Code Golf Golf Golf

Body:
Golf Challenge

Given the below ASCII "Green".

```<code>|          |
|  |>      |
|  |       |
|  O       |
|          |
|          |
|          |
|          |
|          |
|          |
</code>```

Let | Denote a wall

Let | Denote half the flag pole

Let > Denote the flag on the pole

Let O Denote the hole

Let o Denote the ball

The dimensions of the "Green" is 10x10. There are ten spaces between the two walls |.

There are also ten spaces, empty or not between the top and the bottom of the green.

Challenge

Input an x and y value or
generate two random numbers to "shoot" a golf ball onto the green.

If the x, y generated does not touch the hole or the flag pole/flag output "Try Again!"

If the x, y generated hits the hole output "Hole in One!"

if the x, y generated hits the pole output "Lucky Shot!"

if the x, y generated hits the flag output "Close One!"

After the shot, output the location of the ball on the green with a o, replacing any character it hit. Also output the respective saying above.

Examples:

```<code>//Hole in one example, the O was replaced with a o
Randomed x = 3
Randomed y = 4

"Hole in One!"

|          |
|  |>      |
|  |       |
|  o       |
|          |
|          |
|          |
|          |
|          |
|          |

//Clone example, the top half of the pole was replaced with a o
Randomed x = 3
Randomed y = 2

"Lucky Shot!"

|          |
|  o>      |
|  |       |
|  O       |
|          |
|          |
|          |
|          |
|          |
|          |

//Lucky Shot example, the > was replaced with a o
Randomed x = 4
Randomed y = 2

"Close One!"

|          |
|  |o      |
|  |       |
|  O       |
|          |
|          |
|          |
|          |
|          |
|          |

//Try Again example, the <space> was replaced with a o
Randomed x = 5
Randomed y = 1

"Try Again!"

|     o    |
|  |>      |
|  |       |
|  O       |
|          |
|          |
|          |
|          |
|          |
|          |
</code>```

Have fun and good luck and as this is code-golf the shortest code wins!

Body:
R, <s>230</s> 226 bytes

M=matrix("|",10,10);M[2:9,]=" ";M[34]="0";M[4,2:3]="f";M[15]=">";function(x,y){m=switch(M[y,x],">"="Close One","f"="Lucky Shot","0"="Hole In One","Try again");M[y,x]="o";cat(m,"!\n",sep="");cat(gsub("f","|",M),sep="",fill=10)}

Thanks to @billywob for -2 bytes, noticing M[a,b] is equivalent to M[c] in a couple of cases.

Annoyingly, the two cat calls (!) can't be concatenated into one, since the fill argument messes up the message. Argh!


问:
N in a row (or column)!

N in a row

Input:

The character and a 2-Dimensional array.

The array with a size of N x N where 1 <= N <= 26, it will be filled randomly like so:

N = 1

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

N = 2

```<code>B | A
-----
A | B
</code>```

N = 3

```<code>A | B | C
----------
B | A | B
----------
C | A | C
</code>```

As N increases by 1, so does the number of letters. A = 1, B = 2, C = 3. There will always be N number of each letter.

N = 3, there will be 3 As... 3 Bs... 3 Cs...

N = 4, there will be 4 As... 4 Bs... 4 Cs... 4 Ds...

N = 5, there will be 5 As... 5 Bs... 5 Cs... 5 Ds... 5 Es...

Output:

The original matrix as well as a manipulated matrix where any given letter has N in a row (or column).

Manipulations occur by swapping two letters within the 2-D grid that are adjacent on the x or y axis. You may not swap characters over the boundaries of the array. I.E. You cannot swap Array[0][N-1] with Array[0][0]. You also may not swap characters diagonally.

Objective:

Your job is to pick a character C to solve for given N. Swap characters within the matrix so that there are N of C in the same row or column.

Examples:

N = 3, C = A

```<code><b>A</b> | <b>B</b> | C
----------
B | A | B
----------
C | A | C
</code>```

Swap array[0][0] (A) with array[1][0] (B)
resulting in

```<code>B | <b>A</b> | C
----------
B | <b>A</b> | B
----------
C | <b>A</b> | C
</code>```

Complete

N = 4, C = B

```<code>A | <b>B</b> | C | D
--------------
B | <b>D</b> | B | A
--------------
D | A | C | C
--------------
A | C | B | D
</code>```

swap array[1][0] (B) with array[1][1] (D)

```<code>A | D | C | D
--------------
B | B | B | A
--------------
D | A | C | C
--------------
A | C | <b>B</b> | <b>D</b>
</code>```

swap array[2][3] (B) with array[3][3] (D)

```<code>A | D | C | D
--------------
B | B | B | A
--------------
D | A | C | <b>C</b>
--------------
A | C | D | <b>B</b>
</code>```

swap array[3][3] (B) with array[3][2] (C)

```<code>A | D | C | D
--------------
B | B | B | <b>A</b>
--------------
D | A | C | <b>B</b>
--------------
A | C | D | C
</code>```

swap array[3][2] (B) with array[3][1] (A)

```<code>A | D | C | D
--------------
<b>B</b> | <b>B</b> | <b>B</b> | <b>B</b>
--------------
D | A | C | A
--------------
A | C | D | C
</code>```

Complete!

Any letter can be chosen to solve for. As this is code-golf the shortest code wins!

Have Fun and Good Luck!

答:
Python 2, 270 bytes

from random import*
e=lambda s,n:all(sum(map(ord,l))!=n*65for l in s)
R,C,d=randint,choice,[-1,1]
def w(a):
 print a;n=len(a);
 while e(a,n)and e(zip(*a),n):
    if n==2:x,y,w,z=0,0,0,1
    else:x,y=R(1,n-2),R(1,n-2);w,z=x+C(d),y+C(d)
    a[y][x],a[z][w]=a[z][w],a[y][x]
 print a
```
<p>Always chooses <code>A</code> as character to complete a row/col. Performs random swaps until goal is reached.</p>
<p>Accepts the matrix as list of lists, usage for testing:</p>
<pre class="lang-python prettyprint-override"><code>A="""ADCD
BBBA
DACC
ACDB"""
a=[[c for c in l] for l in A.split('\n')]
w(a)
</code>```

Title: N in a row (or column)!

Body:
Python 2, 270 bytes

from random import*
e=lambda s,n:all(sum(map(ord,l))!=n*65for l in s)
R,C,d=randint,choice,[-1,1]
def w(a):
 print a;n=len(a);
 while e(a,n)and e(zip(*a),n):
    if n==2:x,y,w,z=0,0,0,1
    else:x,y=R(1,n-2),R(1,n-2);w,z=x+C(d),y+C(d)
    a[y][x],a[z][w]=a[z][w],a[y][x]
 print a

Always chooses A as character to complete a row/col. Performs random swaps until goal is reached.

Accepts the matrix as list of lists, usage for testing:

A="""ADCD
BBBA
DACC
ACDB"""
a=[[c for c in l] for l in A.split('\n')]
w(a)


答:
R, <s>41</s> 40 bytes

This answer provides valid output, although it does not follow the algorithm suggested. Since a limitless number of swapping manipulations are permitted, restrictions on what manipulations are allowed (e.g. the diagonal restriction) are irrelevant, as any permutation of the matrix can be arrived at through a (possibly large) number of swaps. So, I've bypassed the "switching around" part of the matrix manipulation and just went straight to outputting a solved matrix.

Anonymous function that takes a matrix as input, and returns a list of the original matrix and the "solved" matrix.

```<code>function(m)list(m,array(sort(m),dim(m)))
</code>```

Example input:

```<code>matrix(c("A","B","A","C","C","B","A","C","B"),3)
</code>```

That is,

[,1] [,2] [,3]

[1,] "A"  "C"  "A"

[2,] "B"  "C"  "C"

[3,] "A"  "B"  "B"

Gives the following output:

```<code>[[1]]
     [,1] [,2] [,3]
[1,] "A"  "C"  "A"
[2,] "B"  "C"  "C"
[3,] "A"  "B"  "B"

[[2]]
     [,1] [,2] [,3]
[1,] "A"  "B"  "C"
[2,] "A"  "B"  "C"
[3,] "A"  "B"  "C"
</code>```

While we're at it, here's a function to generate possible input matrices:

```<code>make_matrix = function(N) matrix(sample(rep(LETTERS[1:N], N)), N)
</code>```

This function takes the first N letters of the alphabet, repeated N times (i.e. N*N characters) and randomly samples from them. The characters are then arranged into a matrix with N rows (and, implicitly, N columns).

Examples:

```<code>make_matrix(1)
     [,1]
[1,] "A"
> make_matrix(3)
     [,1] [,2] [,3]
[1,] "C"  "B"  "C"
[2,] "C"  "A"  "B"
[3,] "A"  "B"  "A"
</code>```

And used with our function above (named f):

```<code>> f(make_matrix(10))
[[1]]
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,] "J"  "C"  "D"  "G"  "E"  "C"  "H"  "G"  "I"  "J"
 [2,] "C"  "D"  "A"  "C"  "H"  "A"  "A"  "E"  "H"  "I"
 [3,] "C"  "B"  "E"  "G"  "C"  "F"  "J"  "A"  "H"  "J"
 [4,] "I"  "E"  "F"  "I"  "B"  "G"  "E"  "F"  "F"  "C"
 [5,] "H"  "I"  "F"  "D"  "B"  "G"  "H"  "A"  "J"  "H"
 [6,] "J"  "E"  "D"  "J"  "A"  "D"  "B"  "D"  "G"  "B"
 [7,] "D"  "B"  "E"  "A"  "G"  "H"  "C"  "C"  "J"  "B"
 [8,] "H"  "D"  "I"  "J"  "B"  "I"  "I"  "F"  "E"  "I"
 [9,] "G"  "F"  "F"  "A"  "J"  "E"  "B"  "A"  "E"  "D"
[10,] "H"  "G"  "A"  "B"  "D"  "I"  "C"  "G"  "F"  "F"

[[2]]
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [2,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [3,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [4,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [5,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [6,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [7,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [8,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [9,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
[10,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
</code>```

Title: N in a row (or column)!

Body:
N in a row

Input:

The character and a 2-Dimensional array.

The array with a size of N x N where 1 <= N <= 26, it will be filled randomly like so:

N = 1

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

N = 2

```<code>B | A
-----
A | B
</code>```

N = 3

```<code>A | B | C
----------
B | A | B
----------
C | A | C
</code>```

As N increases by 1, so does the number of letters. A = 1, B = 2, C = 3. There will always be N number of each letter.

N = 3, there will be 3 As... 3 Bs... 3 Cs...

N = 4, there will be 4 As... 4 Bs... 4 Cs... 4 Ds...

N = 5, there will be 5 As... 5 Bs... 5 Cs... 5 Ds... 5 Es...

Output:

The original matrix as well as a manipulated matrix where any given letter has N in a row (or column).

Manipulations occur by swapping two letters within the 2-D grid that are adjacent on the x or y axis. You may not swap characters over the boundaries of the array. I.E. You cannot swap Array[0][N-1] with Array[0][0]. You also may not swap characters diagonally.

Objective:

Your job is to pick a character C to solve for given N. Swap characters within the matrix so that there are N of C in the same row or column.

Examples:

N = 3, C = A

```<code><b>A</b> | <b>B</b> | C
----------
B | A | B
----------
C | A | C
</code>```

Swap array[0][0] (A) with array[1][0] (B)
resulting in

```<code>B | <b>A</b> | C
----------
B | <b>A</b> | B
----------
C | <b>A</b> | C
</code>```

Complete

N = 4, C = B

```<code>A | <b>B</b> | C | D
--------------
B | <b>D</b> | B | A
--------------
D | A | C | C
--------------
A | C | B | D
</code>```

swap array[1][0] (B) with array[1][1] (D)

```<code>A | D | C | D
--------------
B | B | B | A
--------------
D | A | C | C
--------------
A | C | <b>B</b> | <b>D</b>
</code>```

swap array[2][3] (B) with array[3][3] (D)

```<code>A | D | C | D
--------------
B | B | B | A
--------------
D | A | C | <b>C</b>
--------------
A | C | D | <b>B</b>
</code>```

swap array[3][3] (B) with array[3][2] (C)

```<code>A | D | C | D
--------------
B | B | B | <b>A</b>
--------------
D | A | C | <b>B</b>
--------------
A | C | D | C
</code>```

swap array[3][2] (B) with array[3][1] (A)

```<code>A | D | C | D
--------------
<b>B</b> | <b>B</b> | <b>B</b> | <b>B</b>
--------------
D | A | C | A
--------------
A | C | D | C
</code>```

Complete!

Any letter can be chosen to solve for. As this is code-golf the shortest code wins!

Have Fun and Good Luck!

Body:
R, <s>41</s> 40 bytes

This answer provides valid output, although it does not follow the algorithm suggested. Since a limitless number of swapping manipulations are permitted, restrictions on what manipulations are allowed (e.g. the diagonal restriction) are irrelevant, as any permutation of the matrix can be arrived at through a (possibly large) number of swaps. So, I've bypassed the "switching around" part of the matrix manipulation and just went straight to outputting a solved matrix.

Anonymous function that takes a matrix as input, and returns a list of the original matrix and the "solved" matrix.

function(m)list(m,array(sort(m),dim(m)))

Example input:

matrix(c("A","B","A","C","C","B","A","C","B"),3)

That is,

[,1] [,2] [,3]

[1,] "A"  "C"  "A"

[2,] "B"  "C"  "C"

[3,] "A"  "B"  "B"

Gives the following output:

[[1]]
     [,1] [,2] [,3]
[1,] "A"  "C"  "A"
[2,] "B"  "C"  "C"
[3,] "A"  "B"  "B"

[[2]]
     [,1] [,2] [,3]
[1,] "A"  "B"  "C"
[2,] "A"  "B"  "C"
[3,] "A"  "B"  "C"

While we're at it, here's a function to generate possible input matrices:

make_matrix = function(N) matrix(sample(rep(LETTERS[1:N], N)), N)

This function takes the first N letters of the alphabet, repeated N times (i.e. N*N characters) and randomly samples from them. The characters are then arranged into a matrix with N rows (and, implicitly, N columns).

Examples:

make_matrix(1)
     [,1]
[1,] "A"
> make_matrix(3)
     [,1] [,2] [,3]
[1,] "C"  "B"  "C"
[2,] "C"  "A"  "B"
[3,] "A"  "B"  "A"

And used with our function above (named f):

> f(make_matrix(10))
[[1]]
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,] "J"  "C"  "D"  "G"  "E"  "C"  "H"  "G"  "I"  "J"
 [2,] "C"  "D"  "A"  "C"  "H"  "A"  "A"  "E"  "H"  "I"
 [3,] "C"  "B"  "E"  "G"  "C"  "F"  "J"  "A"  "H"  "J"
 [4,] "I"  "E"  "F"  "I"  "B"  "G"  "E"  "F"  "F"  "C"
 [5,] "H"  "I"  "F"  "D"  "B"  "G"  "H"  "A"  "J"  "H"
 [6,] "J"  "E"  "D"  "J"  "A"  "D"  "B"  "D"  "G"  "B"
 [7,] "D"  "B"  "E"  "A"  "G"  "H"  "C"  "C"  "J"  "B"
 [8,] "H"  "D"  "I"  "J"  "B"  "I"  "I"  "F"  "E"  "I"
 [9,] "G"  "F"  "F"  "A"  "J"  "E"  "B"  "A"  "E"  "D"
[10,] "H"  "G"  "A"  "B"  "D"  "I"  "C"  "G"  "F"  "F"

[[2]]
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [2,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [3,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [4,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [5,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [6,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [7,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [8,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
 [9,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"
[10,] "A"  "B"  "C"  "D"  "E"  "F"  "G"  "H"  "I"  "J"


答:
Ruby / C, 64 62 51 48 bytes

```<code>#define tap main()
tap{puts(0?"trick":"treat");}
</code>```

What Ruby sees:

```<code>tap{puts(0?"trick":"treat");}
</code>```

The tap method takes a block and executes it once. It's a short identifier that we can create a #define macro for in C. It also allows us to put a braces-enclosed block in the shared code, even though Ruby doesn't allow {}s in most contexts.

The only falsy values in Ruby are false and nil. In particular, 0 is truthy. Thus, Ruby will print "trick."

What C sees (after the pre-processor):

```<code>main(){puts(0?"trick":"treat");}
</code>```

0 is falsy in C, so C will print "treat."

2 bytes saved thanks to daniero.

Title: Trick or Treat polyglot

Body:
Ruby / C, 64 62 51 48 bytes

#define tap main()
tap{puts(0?"trick":"treat");}

What Ruby sees:

tap{puts(0?"trick":"treat");}

The tap method takes a block and executes it once. It's a short identifier that we can create a #define macro for in C. It also allows us to put a braces-enclosed block in the shared code, even though Ruby doesn't allow {}s in most contexts.

The only falsy values in Ruby are false and nil. In particular, 0 is truthy. Thus, Ruby will print "trick."

What C sees (after the pre-processor):

main(){puts(0?"trick":"treat");}

0 is falsy in C, so C will print "treat."

2 bytes saved thanks to daniero.


Title: Draw an alphabet party hat

Body:
Python 2, <s>66</s> 64 bytes

i=91;exec'i-=1;print`map(chr,range(i,91))`[2::5].center(26);'*26


答:
SQL, 153 Bytes

Golfed:

```<code>CREATE PROCEDURE P @n INT AS BEGIN DECLARE @a INT;SET @a=0;DECLARE @o VARCHAR(1000);SET @o='*'WHILE @a<@n BEGIN PRINT @o;SET @o=@o+'*'SET @a=@a+1;END;END
</code>```

Ungolfed:

```<code>CREATE PROCEDURE P
@n INT
AS
BEGIN
DECLARE @a INT;
SET @a=0;
DECLARE @o VARCHAR(1000);
SET @o='*'
WHILE @a<@n
    BEGIN
    PRINT @o;
    SET @o=@o+'*'
    SET @a=@a+1;
END;
END
</code>```

Testing:

```<code>EXEC P '6'
</code>```

Output:

```<code>*
**
***
****
*****
******
</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:
SQL, 153 Bytes

Golfed:

CREATE PROCEDURE P @n INT AS BEGIN DECLARE @a INT;SET @a=0;DECLARE @o VARCHAR(1000);SET @o='*'WHILE @a<@n BEGIN PRINT @o;SET @o=@o+'*'SET @a=@a+1;END;END

Ungolfed:

CREATE PROCEDURE P
@n INT
AS
BEGIN
DECLARE @a INT;
SET @a=0;
DECLARE @o VARCHAR(1000);
SET @o='*'
WHILE @a<@n
    BEGIN
    PRINT @o;
    SET @o=@o+'*'
    SET @a=@a+1;
END;
END

Testing:

EXEC P '6'

Output:

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


问:
Hello World 0.0!

 source: Dilbert, September 8, 1992

I'm hoping to add a new twist on the classic "Hello World!" program.

Code a program that outputs Hello World! without:

String/Character literals

Numbers (any base)

Pre-built functions that return "Hello World!"

RegEx literals

With the exceptions of "O"† and 0.

†"O" is capitalized, "o" is not acceptable.

答:
Dyalog APL, 115 bytes

Needs ⎕IO←0 which is default on many systems.

Inspiration.

Plain ASCII encoding using 0 for 0 and O for 1.

⎕UCS(⍴⍬⍬)⊥'0O'⍳'OOOOO0OOOOO00OOOOO0OOOOO000000O0O000O0OOO00O0O000OOOO0OO0OO00000O0OOO0000O00O0OO000O'⍴⍨≢¨⎕TS(⎕D,⍬⍬)
```

⎕UCS Convert Unicode code points to character

(⍴⍬⍬)⊥ base-2 decode of (⍴⍬⍬ is the length of a list of two empty lists, i.e. 2)

'0O'⍳ indices into 0O for each character in

'OOO...00O' the 7×12 character encoded string

⍴⍨ reshaped into a matrix of dimensions

≢¨ the tally of each of

⎕TS(⎕D,⍬⍬) the Time Stamp and the Digits appended with two empty lists

TryAPL online!

Title: Hello World 0.0!

Body:
Dyalog APL, 115 bytes

Needs ⎕IO←0 which is default on many systems.

Inspiration.

Plain ASCII encoding using 0 for 0 and O for 1.

⎕UCS(⍴⍬⍬)⊥'0O'⍳'OOOOO0OOOOO00OOOOO0OOOOO000000O0O000O0OOO00O0O000OOOO0OO0OO00000O0OOO0000O00O0OO000O'⍴⍨≢¨⎕TS(⎕D,⍬⍬)

⎕UCS Convert Unicode code points to character

(⍴⍬⍬)⊥ base-2 decode of (⍴⍬⍬ is the length of a list of two empty lists, i.e. 2)

'0O'⍳ indices into 0O for each character in

'OOO...00O' the 7×12 character encoded string

⍴⍨ reshaped into a matrix of dimensions

≢¨ the tally of each of

⎕TS(⎕D,⍬⍬) the Time Stamp and the Digits appended with two empty lists

TryAPL online!


问:
Chaining Programs

Challenge

In this challenge, you will be writing the first program, p1, of an infinite sequence of programs, in which running pn outputs/generates program pn+1. When concatenating the first n >= 2 programs, the sequence should output n.

Example

Let's say the first 4 programs are:

```<code>p1 p2 p3 p4
</code>```

If I were to run p1, it should output:

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

If I were to run p1p2, it should output:

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

If I were to run p1p2p3p4 it should output:

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

If I were to run p4, it should generate the next program in the sequence:

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

Scoring

Your score is the byte count of the first 10 programs.

答:
PHP, 1470 bytes

Program 1: 219 bytes:

```<code>class O{public$n=1;function __destruct(){echo($n=$this->n)>1?$n:'if(!$o->n++)echo str_replace(chr(9),$a=aWYoISRvLT5uKyspZWNobyBzdHJfcmVwbGFjZShjaHIoOSksJGE9CSxiYXNlNjRfZGVjb2RlKCRhKSk7,base64_decode($a));';}}$o=new O();
</code>```

progam 2 and beyond 139 bytes:

```<code>if(!$o->n++)echo str_replace(chr(9),$a=aWYoISRvLT5uKyspZWNobyBzdHJfcmVwbGFjZShjaHIoOSksJGE9CSxiYXNlNjRfZGVjb2RlKCRhKSk7,base64_decode($a));
</code>```

use like:

```<code>php -r "class O{public$n=1;function __destruct(){echo($n=$this->n)>1?$n:'if(!$o->n++)echo str_replace(chr(9),$a=aWYoISRvLT5uKyspZWNobyBzdHJfcmVwbGFjZShjaHIoOSksJGE9CSxiYXNlNjRfZGVjb2RlKCRhKSk7,base64_decode($a));';}}$o=new O();"
</code>```

Uses a slightly golfed version the php quine technique detailed here: http://10types.co.uk/the-lab/a-minimal-php-quine/

Title: Chaining Programs

Body:
PHP, 1470 bytes

Program 1: 219 bytes:

class O{public$n=1;function __destruct(){echo($n=$this->n)>1?$n:'if(!$o->n++)echo str_replace(chr(9),$a=aWYoISRvLT5uKyspZWNobyBzdHJfcmVwbGFjZShjaHIoOSksJGE9CSxiYXNlNjRfZGVjb2RlKCRhKSk7,base64_decode($a));';}}$o=new O();

progam 2 and beyond 139 bytes:

if(!$o->n++)echo str_replace(chr(9),$a=aWYoISRvLT5uKyspZWNobyBzdHJfcmVwbGFjZShjaHIoOSksJGE9CSxiYXNlNjRfZGVjb2RlKCRhKSk7,base64_decode($a));

use like:

php -r "class O{public$n=1;function __destruct(){echo($n=$this->n)>1?$n:'if(!$o->n++)echo str_replace(chr(9),$a=aWYoISRvLT5uKyspZWNobyBzdHJfcmVwbGFjZShjaHIoOSksJGE9CSxiYXNlNjRfZGVjb2RlKCRhKSk7,base64_decode($a));';}}$o=new O();"

Uses a slightly golfed version the php quine technique detailed here: http://10types.co.uk/the-lab/a-minimal-php-quine/


问:
Alphabet Pattern Matching
We've had a lot of alphabet challenges.  For this challenge, you are passed the output of an alphabet challenge, and you need to output the pattern scaled to size N.

For example, if N=5 and you were passed the L-phabet:

```<code>ABCDEFGHIJKLMNOPQRSTUVWXYZ
BBCDEFGHIJKLMNOPQRSTUVWXYZ
CCCDEFGHIJKLMNOPQRSTUVWXYZ
DDDDEFGHIJKLMNOPQRSTUVWXYZ
EEEEEFGHIJKLMNOPQRSTUVWXYZ
FFFFFFGHIJKLMNOPQRSTUVWXYZ
GGGGGGGHIJKLMNOPQRSTUVWXYZ
HHHHHHHHIJKLMNOPQRSTUVWXYZ
IIIIIIIIIJKLMNOPQRSTUVWXYZ
JJJJJJJJJJKLMNOPQRSTUVWXYZ
KKKKKKKKKKKLMNOPQRSTUVWXYZ
LLLLLLLLLLLLMNOPQRSTUVWXYZ
MMMMMMMMMMMMMNOPQRSTUVWXYZ
NNNNNNNNNNNNNNOPQRSTUVWXYZ
OOOOOOOOOOOOOOOPQRSTUVWXYZ
PPPPPPPPPPPPPPPPQRSTUVWXYZ
QQQQQQQQQQQQQQQQQRSTUVWXYZ
RRRRRRRRRRRRRRRRRRSTUVWXYZ
SSSSSSSSSSSSSSSSSSSTUVWXYZ
TTTTTTTTTTTTTTTTTTTTUVWXYZ
UUUUUUUUUUUUUUUUUUUUUVWXYZ
VVVVVVVVVVVVVVVVVVVVVVWXYZ
WWWWWWWWWWWWWWWWWWWWWWWXYZ
XXXXXXXXXXXXXXXXXXXXXXXXYZ
YYYYYYYYYYYYYYYYYYYYYYYYYZ
ZZZZZZZZZZZZZZZZZZZZZZZZZZ
</code>```

You would need to output:

```<code>ABCDE
BBCDE
CCCDE
DDDDE
EEEEE
</code>```

For the purposes of explanation, I'll be using only ABCD, instead of the full alphabet.  You need to be able to match the L-phabet (above), as well as the following patterns:

The single line:

```<code>ABCD    or     A
               B
               C
               D
</code>```

The single line repeated N times

```<code>ABCD    or    AAAA
ABCD          BBBB
ABCD          CCCC
ABCD          DDDD
</code>```

The Tabula Recta:

```<code>ABCD
BCDA
CDAB
DABC
</code>```

This alphabet triangle:

```<code>A      or   AAAAAAA
AB           BBBBB
ABC           CCC
ABCD           D
ABC
AB
A
</code>```

We also have half triangles in lots of varieties:

```<code>A           AAAA      A        ABCD
BB          BBB       AB       ABC
CCC         CC        ABC      AB
DDDD        D         ABCD     A
</code>```

Finally, the square:

```<code>AAAAAAA
ABBBBBA
ABCCCBA
ABCDCBA
ABCCCBA
ABBBBBA
AAAAAAA
</code>```

All of the above patterns are of size 4.  However, you will be passed a pattern of size 26, as well as an N between 1 and 26, and you need to scale the pattern.  You do not need to handle any other patterns.

The output for 1 will always be the single character A

The output for 26 will always be the same, full-sized pattern passed in.

Trailing spaces are allowed at the end of each line, as well as a trailing newline at the end

You can find all patterns of size 26 here

This is a code-golf, so do it in as few bytes as possible!

答:
JavaScript (ES6), <s>382</s> <s>380</s> 370 bytes

```<code>f=(a,N)=>{X=Y=0
if(a[1]){Y=a[1].trim()[0]=='B'
X=z=a[0][1]==a[1][0]?1:!Y
l="ABCDEFGHIJKLMNOPQRSTUVWXYZ"[s='slice'](0,N)
if(z){if(a[0][1]=='A'){for(a=[],i=0,L=l;i<N;i++)a[N-i]=a[N+i]=L[s](0,-1)+l[N-i-1].repeat(i*2)+[...L].reverse().join``
L=L[s](0,-1)
return a}if(a[1][1]=='C')for(i=0;a[i++]=l,i<N;)l=l[s](1)+l[0]}}else X=1
a=X?a.map(l=>l[s](0,N)):a
return Y?a[s](0,N):a}
</code>```

Pass an array of strings to the function f(), like this:

```<code>f(
`AAAAAAA
ABBBBBA
ABCCCBA
ABCDCBA
ABCCCBA
ABBBBBA
AAAAAAA`.split('\n'), 3)
</code>```

Less golfed version with comments:

```<code>f=(a,N)=>{
    // Whether to truncate array horizontally to width N.
    X=0

    // Whether to truncate array vertically to height N.
    Y=0

    // If a second row exists...
    if(I=a[1]){
        // If the first non-whitespace character in the second row == 'B', truncate vertically.
        if(I.trim()[0]=='B')Y=1

        // Truncate horizontally if 2nd character in row 1 == 1st character in row 2; otherwise, if not truncating vertically.
        X=z=a[0][1]==I[0]?1:!Y

        // If 2nd character in row 1 == 1st character in row 2
        if(z){
            // Make an alphabet.
            l="ABCDEFGHIJKLMNOPQRSTUVWXYZ".slice(0,N)

            // If 2nd character in row 1 == 'A', forget everything we just did. Make a new array, generate a Square pattern, then return it.
            if(a[0][1]=='A'){
                for(a=[],i=0,L=l;i<N;i++)
                    a[N-i]=a[N+i]=L.slice(0,-1)+l[N-i-1].repeat(i*2)+[...L].reverse().join``,
                    L=L.slice(0,-1)
                return a
            }

            // If 2nd character in row 2 == 'C', fill array with a Tabula Recta.
            if(I[1]=='C')
                for(i=0;a[i++]=l,i<N;)
                    l=l.slice(1)+l[0]
        }
    }else{
        // If a second row doesn't exist, it's a horizontal line; truncate horizontally.
        X=1
    }

    // Truncate array horizontally if necessary.
    a=X?a.map(l=>l.slice(0,N)):a

    // Truncate array vertically if necessary.
    return Y?a.slice(0,N):a
}
</code>```

Title: Alphabet Pattern Matching

Body:
JavaScript (ES6), <s>382</s> <s>380</s> 370 bytes

f=(a,N)=>{X=Y=0
if(a[1]){Y=a[1].trim()[0]=='B'
X=z=a[0][1]==a[1][0]?1:!Y
l="ABCDEFGHIJKLMNOPQRSTUVWXYZ"[s='slice'](0,N)
if(z){if(a[0][1]=='A'){for(a=[],i=0,L=l;i<N;i++)a[N-i]=a[N+i]=L[s](0,-1)+l[N-i-1].repeat(i*2)+[...L].reverse().join``
L=L[s](0,-1)
return a}if(a[1][1]=='C')for(i=0;a[i++]=l,i<N;)l=l[s](1)+l[0]}}else X=1
a=X?a.map(l=>l[s](0,N)):a
return Y?a[s](0,N):a}

Pass an array of strings to the function f(), like this:

f(
`AAAAAAA
ABBBBBA
ABCCCBA
ABCDCBA
ABCCCBA
ABBBBBA
AAAAAAA`.split('\n'), 3)

Less golfed version with comments:

f=(a,N)=>{
    // Whether to truncate array horizontally to width N.
    X=0

    // Whether to truncate array vertically to height N.
    Y=0

    // If a second row exists...
    if(I=a[1]){
        // If the first non-whitespace character in the second row == 'B', truncate vertically.
        if(I.trim()[0]=='B')Y=1

        // Truncate horizontally if 2nd character in row 1 == 1st character in row 2; otherwise, if not truncating vertically.
        X=z=a[0][1]==I[0]?1:!Y

        // If 2nd character in row 1 == 1st character in row 2
        if(z){
            // Make an alphabet.
            l="ABCDEFGHIJKLMNOPQRSTUVWXYZ".slice(0,N)

            // If 2nd character in row 1 == 'A', forget everything we just did. Make a new array, generate a Square pattern, then return it.
            if(a[0][1]=='A'){
                for(a=[],i=0,L=l;i<N;i++)
                    a[N-i]=a[N+i]=L.slice(0,-1)+l[N-i-1].repeat(i*2)+[...L].reverse().join``,
                    L=L.slice(0,-1)
                return a
            }

            // If 2nd character in row 2 == 'C', fill array with a Tabula Recta.
            if(I[1]=='C')
                for(i=0;a[i++]=l,i<N;)
                    l=l.slice(1)+l[0]
        }
    }else{
        // If a second row doesn't exist, it's a horizontal line; truncate horizontally.
        X=1
    }

    // Truncate array horizontally if necessary.
    a=X?a.map(l=>l.slice(0,N)):a

    // Truncate array vertically if necessary.
    return Y?a.slice(0,N):a
}


问:
Print the alphabet without using each vowel
Inspiration: in 1939, a man named Ernest Vincent Wright wrote a novel called Gadsby without using the letter 'e'.

Your task is to write a set of (up to 5) programs in any language (which has a text-based syntax*) to output all 26 letters of the alphabet in order.  However for each vowel aeiou, at least one of the programs must not include any occurrence of the vowel.

So there must be

a program that does not use 'a' or 'A' anywhere in the syntax of the program.

a program that does not use 'e' or 'E' anywhere in the syntax of the program.

a program that does not use 'i'  or 'I' anywhere in the syntax of the program.

a program that does not use 'o' or 'O' anywhere in the syntax of the program.

a program that does not use 'u' or 'U' anywhere in the syntax of the program.

All of them must output abcdefghijklmnopqrstuvwxyz.

The winner shall be the solution where the length of all programs is the shortest.

* since the constraint wouldn't be much of a challenge in Piet or Whitespace

答:
Java 8, <s>517</s> 262 characters

-255 bytes thanks to @OlivierGrégoire.

No aeio (165):

```<code>\u0069nt\u0065rf\u0061c\u0065 M{st\u0061t\u0069c v\u006F\u0069d m\u0061\u0069n(Str\u0069ng[]b){f\u006Fr(ch\u0061r c=97;c<123;)Syst\u0065m.\u006Fut.pr\u0069nt(c++);}}
</code>```

Try it online.

No u (97):

```<code>interface A{static void main(String[]a){for(char c=97;c<123;)System.console().printf("%c",c++);}}
</code>```

Note that the program for u makes use of System.console(), which will return null (and thus cause the code to throw a NullPointerException) if you call it from anything other than your OS' native terminal (cmd on Windows, bash on Linux/OSX, etc.)

Body:
Java 8, <s>517</s> 262 characters

-255 bytes thanks to @OlivierGrégoire.

No aeio (165):

\u0069nt\u0065rf\u0061c\u0065 M{st\u0061t\u0069c v\u006F\u0069d m\u0061\u0069n(Str\u0069ng[]b){f\u006Fr(ch\u0061r c=97;c<123;)Syst\u0065m.\u006Fut.pr\u0069nt(c++);}}

Try it online.

No u (97):

interface A{static void main(String[]a){for(char c=97;c<123;)System.console().printf("%c",c++);}}

Note that the program for u makes use of System.console(), which will return null (and thus cause the code to throw a NullPointerException) if you call it from anything other than your OS' native terminal (cmd on Windows, bash on Linux/OSX, etc.)


答:
05AB1E, 4 bytes

```<code>žpRl
</code>```

Try it online!

Explanation:

```<code>žp     Push 'ZYXWVUTSRQPONMLKJIHGFEDCBA'
  R    Reverse string - 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
   l   Lowercase - 'abcdefghijklmnopqrstuvwxyz'
       Implicitly print
</code>```

Title: Print the alphabet without using each vowel

Body:
Inspiration: in 1939, a man named Ernest Vincent Wright wrote a novel called Gadsby without using the letter 'e'.

Your task is to write a set of (up to 5) programs in any language (which has a text-based syntax*) to output all 26 letters of the alphabet in order.  However for each vowel aeiou, at least one of the programs must not include any occurrence of the vowel.

So there must be

a program that does not use 'a' or 'A' anywhere in the syntax of the program.

a program that does not use 'e' or 'E' anywhere in the syntax of the program.

a program that does not use 'i'  or 'I' anywhere in the syntax of the program.

a program that does not use 'o' or 'O' anywhere in the syntax of the program.

a program that does not use 'u' or 'U' anywhere in the syntax of the program.

All of them must output abcdefghijklmnopqrstuvwxyz.

The winner shall be the solution where the length of all programs is the shortest.

* since the constraint wouldn't be much of a challenge in Piet or Whitespace

Body:
05AB1E, 4 bytes

žpRl

Try it online!

Explanation:

žp     Push 'ZYXWVUTSRQPONMLKJIHGFEDCBA'
  R    Reverse string - 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
   l   Lowercase - 'abcdefghijklmnopqrstuvwxyz'
       Implicitly print


问:
Traveling Pumpkin Problem

Background:

Jack is a pumpkin that enjoys spooking the citizens of the villages near his pumpkin patch every Halloween.  However, every year after someone lights the candle inside of him, he has a limited amount of time to spook everyone before the candle burns out, thus being unable to spook any more villagers because nobody can see him.  In past years, he has only been able to spook a small amount of villages due to his poor decision making, but now that he has you to help him, he will be able to spook as many villages as possible!

Task:

Given a list of village locations and a candle lifespan, output the maximum number of villages Jack can visit.  You do not have to print the path itself.

Input:

The lifespan of the candle and a list of village locations in a Cartesian coordinate system.  The pumpkin patch Jack originates from will always be at 0,0.  You may format the input in anyway you wish.  To simplify Jack's movements, he can only move horizontally, vertically, or diagonally, meaning his candle will either lose 1 or 1.5 (he takes a bit longer diagonally) units of life every move.  The candle burns out when the lifespan is less than or equal to 0.

Output:

An integer equal to the maximum number of villages Jack can visit before the candle burns out.

Rules:

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

Test cases:

```<code>// Format [lifespan] [list of village coordinates] -> [maximum visit-able villages]

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

答:
JavaScript (ES6), 145

Anonymous recursive function, parameter s is the candle lifespan, parameter l is the village coordinate list.

A Depth First Search, stopping when the distance reachs the candle lifespan

f=(s,l,x=0,y=0,v=0,A=Math.abs,X=Math.max)=>X(v,...l.map(([t,u],i,[h,...l],q=A(t-x),p=A(u-y),d=(l[i-1]=h,p+q+X(p,q))/2)=>s<=d?v:f(s-d,l,t,u,1+v)))
```
<p><em>Less golfed</em> see the snippet below</p>
<p><strong>Test</strong></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>f=(s,l,x=0,y=0,v=0,A=Math.abs,X=Math.max)=>
  X(v,...l.map(
      ([t,u],i,[h,...l],q=A(t-x),p=A(u-y),d=(l[i-1]=h,p+q+X(p,q))/2)=>
      s<=d?v:f(s-d,l,t,u,1+v)
  ))

// ungolfed version

F=(s, l,
   x=0, y=0, // current position
   v=0 // current number of visited sites
  ) =>
   Math.max(v, ...l.map(
     (
       [t,u], i, [h,...l], // lambda arguments
       q = Math.abs(t-x), p = Math.abs(u-y), // locals
       d = (p+q+Math.max(p,q))/2
     ) => (
       l[i-1] = h,
       s <= d
         ? v
         : F(s-d, l, t, u, v+1)
     )
  ))

;[[4,[[-1,0],[1,0],[2,0],[3,0],[4,0],[5,0]], 3]
,[4, [[1,1],[2,2],[3,3]], 2]
,[5, [[1,1],[2,1],[3,1],[4,1],[5,0],[5,1]], 4]
].forEach(test=>{
  var span=test[0],list=test[1],check=test[2],
      result = f(span, list)
  console.log(result==check?'OK':'KO',span, list+'', result)
})</code>```

Title: Traveling Pumpkin Problem

Body:
JavaScript (ES6), 145

Anonymous recursive function, parameter s is the candle lifespan, parameter l is the village coordinate list.

A Depth First Search, stopping when the distance reachs the candle lifespan

f=(s,l,x=0,y=0,v=0,A=Math.abs,X=Math.max)=>X(v,...l.map(([t,u],i,[h,...l],q=A(t-x),p=A(u-y),d=(l[i-1]=h,p+q+X(p,q))/2)=>s<=d?v:f(s-d,l,t,u,1+v)))

Less golfed see the snippet below

Test

f=(s,l,x=0,y=0,v=0,A=Math.abs,X=Math.max)=>
  X(v,...l.map(
      ([t,u],i,[h,...l],q=A(t-x),p=A(u-y),d=(l[i-1]=h,p+q+X(p,q))/2)=>
      s<=d?v:f(s-d,l,t,u,1+v)
  ))

// ungolfed version

F=(s, l,
   x=0, y=0, // current position
   v=0 // current number of visited sites
  ) =>
   Math.max(v, ...l.map(
     (
       [t,u], i, [h,...l], // lambda arguments
       q = Math.abs(t-x), p = Math.abs(u-y), // locals
       d = (p+q+Math.max(p,q))/2
     ) => (
       l[i-1] = h,
       s <= d
         ? v
         : F(s-d, l, t, u, v+1)
     )
  ))

;[[4,[[-1,0],[1,0],[2,0],[3,0],[4,0],[5,0]], 3]
,[4, [[1,1],[2,2],[3,3]], 2]
,[5, [[1,1],[2,1],[3,1],[4,1],[5,0],[5,1]], 4]
].forEach(test=>{
  var span=test[0],list=test[1],check=test[2],
      result = f(span, list)
  console.log(result==check?'OK':'KO',span, list+'', result)
})


问:
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!

答:
C#, 76 bytes

using System;public class P{public void Main(){Console.Write("{\"\":"+1/3d+"}");}}
```

<p>Output: </p>

<pre class="lang-js prettyprint-override"><code>{"":0.333333333333333}
</code>```

Title: Print some JSON

Body:
C#, 76 bytes

using System;public class P{public void Main(){Console.Write("{\"\":"+1/3d+"}");}}

Output:

{"":0.333333333333333}


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:
Brain-Flak, 244 bytes

((((((()()()()())){}{}){}){}()){})((((()()()){}){}()){}){(({}[()]<>)<({}<(<>({})<>)>){({}[()]<(({})[()])>)}({}({})<>[({})]<>(((()()()){}){}){}())((<>)<>{<({}[()])><>([{}]())<>}<>[{}]<>{}){({}[()]<((((()()()()){}){}){})>)}((()()()()()){})><>)}<>

Try it online!

This should be readable enough as is. If you need it, I have a full explanation:

push 122 (z): ((((((()()()()())){}{}){}){}()){})
push 26:      ((((()()()){}){}()){})
loop 26 times (i = 25..0): {
 (
  i--, push to b stack:({}[()]<>)
  <
   put 122 from a stack under i: ({}<(<>({})<>)>)
   i times push letter-1: {({}[()]<(({})[()])>)}
   replace top 0 with 26-i: ({}({})<>[({})]<>(((()()()){}){}){}())
   devide by two: ((<>)<>{<({}[()])><>([{}]())<>}<>[{}]<>{})
   add spaces: {({}[()]<((((()()()()){}){}){})>)}
   push 10 (\n): ((()()()()()){})
  >
  flip stack back: <>
 push i--: )
}
flip to results stack: <>