答:
Racket 187 bytes

Using display pattern by @JonathanAllan

```<code>(let*((u "+---- |")(v "|     |")(sr(λ(s)(list->string(reverse(string->list s)))))(g #t)(d displayln)
(p(λ()(d(if g u(sr u)))(set! g(if g #f #t)))))(for((i(ceiling(/ n 2))))(p)(d v))(p))
</code>```

Ungolfed:

```<code>(define (f n)
  (let* ((sr (lambda(s)
               (list->string
                (reverse
                 (string->list s)))))
         (u "+---- |")
         (v "|     |")
         (g #t)
         (d displayln)
         (p (lambda()
              (d (if g u (sr u)))
              (set! g (if g #f #t)))))
    (for ((i (ceiling (/ n 2))))
      (p)
      (d v))
    (p)))
</code>```

Testing:

```<code>(f 10)
</code>```

Output:

```<code>+---- |
|     |
| ----+
|     |
+---- |
|     |
| ----+
|     |
+---- |
|     |
| ----+
</code>```

Title: Generate a one-path maze

Body:
Given an odd integer N (5 <= N <= 51), generate a maze with side length N that follows the following requirements:

The maze must be composed of the characters  | - and +. It must use the | character as a vertical wall, the - character as a horizontal wall, and if that wall turns, the character + should be used.

The width of the path must be one character.

The maze must turn at least four times.

The maze must have outer walls, that break at two points: the start and the end.

The maze must consist of one non-breaking path, from the start to the end.

For example, the following is a valid maze: (N = 5)

```<code>+---+
|   |
| | |
  |
--+--
</code>```

And for N = 7:

```<code>--+---+
  |   |
| | | |
| | | |
| | | |
|   |
+---+--
</code>```

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

Body:
Racket 187 bytes

Using display pattern by @JonathanAllan

(let*((u "+---- |")(v "|     |")(sr(λ(s)(list->string(reverse(string->list s)))))(g #t)(d displayln)
(p(λ()(d(if g u(sr u)))(set! g(if g #f #t)))))(for((i(ceiling(/ n 2))))(p)(d v))(p))

Ungolfed:

(define (f n)
  (let* ((sr (lambda(s)
               (list->string
                (reverse
                 (string->list s)))))
         (u "+---- |")
         (v "|     |")
         (g #t)
         (d displayln)
         (p (lambda()
              (d (if g u (sr u)))
              (set! g (if g #f #t)))))
    (for ((i (ceiling (/ n 2))))
      (p)
      (d v))
    (p)))

Testing:

(f 10)

Output:

+---- |
|     |
| ----+
|     |
+---- |
|     |
| ----+
|     |
+---- |
|     |
| ----+


问:
Output a googol copies of a string
I am interested in seeing programs which don't ask for any input, print a googol copies of some nonempty string, no less, no more, and then stop. A googol is defined as \$10^{100}\$, i.e., 1 followed by a hundred 0's in decimal.

Example output:

```<code>111111111111111111111111111111111111111111111111111111111111111111111111...
</code>```

or

```<code>Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
...
</code>```

The string can also be entirely composed of white space or special symbols. The only exception to identical copies of a fixed string is if your language decorates the output in some way that can not be prevented, but could be trivially undone in a wrapper script, like prepending a line number to each line. The wrapper script in such cases need not be provided.

You can assume your computer will never run out of time, but other than that, your program must have a reasonable demand of resources. Also, you must respect any restrictions that the programming language of your choice poses, for example, you can not exceed a maximum value allowed for its integer types, and at no point more than 4 GB of memory must be needed.

In other words, the program should in principle be testable by running it on your computer. But because of the extent of this number you will be expected to prove that the number of copies of the string it outputs is exactly 10^100 and that the program stops afterwards. Stopping can be exiting or halting or even terminating due to an error, but if so, the error must not produce any output that could not easily be separated from the program's output.

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

Example solution (C, ungolfed, 3768 bytes)

```<code>#include <stdio.h>

int main() {
  int a00, a01, a02, a03, ..., a99;
  for(a00 = 0; a00 < 10; a00++)
  for(a01 = 0; a01 < 10; a01++)
  for(a02 = 0; a02 < 10; a02++)
  for(a03 = 0; a03 < 10; a03++)
  ...
  for(a99 = 0; a99 < 10; a99++)
    puts("1");
  return 0;
}
</code>```

答:
05AB1E, 8 bytes

```<code>TTT*mFõ,
</code>```

Prints googol newlines.

Try it online! (Not recommended)

Explanation:

```<code>TTT      # Push 10 three times
             # Stack: [10, 10, 10]
   *     # Multiply 10 by 10
             # Stack: [10, 100]
    m    # Raise 10 to 100
             # Stack: [Googol]
     F   # Do Googol times
             # Stack: []
      õ  # Push ""
             # Stack: [""]
       , # Print
             # Stack: []
</code>```

ContentLicense: CC BY-SA 4.0

Title: Output a googol copies of a string

Body:
05AB1E, 8 bytes

TTT*mFõ,

Prints googol newlines.

Try it online! (Not recommended)

Explanation:

TTT      # Push 10 three times
             # Stack: [10, 10, 10]
   *     # Multiply 10 by 10
             # Stack: [10, 100]
    m    # Raise 10 to 100
             # Stack: [Googol]
     F   # Do Googol times
             # Stack: []
      õ  # Push ""
             # Stack: [""]
       , # Print
             # Stack: []

ContentLicense: CC BY-SA 3.0


问:
Alphabet triangle strikes again

Task

Your task is to print this exact text:

```<code>A
BCD
EFGHI
JKLMNOP
QRSTUVWXY
ZABCDEFGHIJ
KLMNOPQRSTUVW
XYZABCDEFGHIJKL
MNOPQRSTUVWXYZABC
DEFGHIJKLMNOPQRSTUV
WXYZABCDEFGHIJKLMNOPQ
RSTUVWXYZABCDEFGHIJKLMN
OPQRSTUVWXYZABCDEFGHIJKLM
NOPQRSTUVWXYZABCDEFGHIJKLMN
OPQRSTUVWXYZABCDEFGHIJKLMNOPQ
RSTUVWXYZABCDEFGHIJKLMNOPQRSTUV
WXYZABCDEFGHIJKLMNOPQRSTUVWXYZABC
DEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL
MNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW
XYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ
KLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXY
ZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOP
QRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI
JKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCD
EFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZA
BCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ
</code>```

Specs

You may do it in all-lowercase instead of all-uppercase.

Trailing newlines at the end of the triangle is allowed.

Trailing spaces after each line is allowed.

You must print to STDOUT instead of outputting an array of strings.

Scoring

This is code-golf. Program with lowest byte-count wins.

答:
Pip, <s>17</s> 16 bytes

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

```<code>zX26^@(1,27)**2
</code>```

Try it online!

Explanation:

```<code>zX26             Lowercase alphabet, repeated 26 times
    ^@           Split at these indices:
       1,27        Range(1,27), i.e. numbers 1 through 26
      (    )**2    Square each number
                 Autoprint the resulting list, joined on newlines due to -n
</code>```

My first solution is longer, but I think it's pretty cute:

```<code>L26P(zy,Y++++v+y)
</code>```

Explanation:

```<code>L26               Loop 26 times:
      y             y is initially "", which is 0 in numeric context
       ,            Range from y to the following value:
         ++++v        v is initially -1; increment it twice (so it goes 1, 3, 5, ...)
        Y     +y      Add previous y to new v and yank result into y for next iteration
    (z          )   Use that range to get a slice from the lowercase alphabet (with
                    cyclical indexing)
   P                Print the slice (with trailing newline)
</code>```

Title: Alphabet triangle strikes again

Body:
Pip, <s>17</s> 16 bytes

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

zX26^@(1,27)**2

Try it online!

Explanation:

zX26             Lowercase alphabet, repeated 26 times
    ^@           Split at these indices:
       1,27        Range(1,27), i.e. numbers 1 through 26
      (    )**2    Square each number
                 Autoprint the resulting list, joined on newlines due to -n

My first solution is longer, but I think it's pretty cute:

L26P(zy,Y++++v+y)

Explanation:

L26               Loop 26 times:
      y             y is initially "", which is 0 in numeric context
       ,            Range from y to the following value:
         ++++v        v is initially -1; increment it twice (so it goes 1, 3, 5, ...)
        Y     +y      Add previous y to new v and yank result into y for next iteration
    (z          )   Use that range to get a slice from the lowercase alphabet (with
                    cyclical indexing)
   P                Print the slice (with trailing newline)


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

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

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

Therefore, any of the following would not be valid:

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

However, the following would be valid:

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

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

答:
JavaScript (REPL)

10 chars:

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

Output:

 {"": "[object Object]"}

Well, maybe. If it doesn't like the bare object:

12 chars:

```<code>({"":{}+''})
</code>```

If it doesn't print returned objects the way we need:

This is cleaner (ES2015, 13 chars, borrowing from another solution):

```<code>`{"":${9e9}}`
</code>```

{"": 9000000000}

Title: Print some JSON

Body:
JavaScript (REPL)

10 chars:

{"":{}+''}

Output:

 {"": "[object Object]"}

Well, maybe. If it doesn't like the bare object:

12 chars:

({"":{}+''})

If it doesn't print returned objects the way we need:

This is cleaner (ES2015, 13 chars, borrowing from another solution):

`{"":${9e9}}`

{"": 9000000000}


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

```

答:
CJam/Befunge, 21 bytes

```<code>"Trick"o"taerT",,,,,@
</code>```

Try it online! (CJam)

Try it online! (Befunge)

CJam:

"Trick"o push "Trick" and print it.

"taerT", push "taerT" and take length, 5.

,,,, take lengths of ranges, leaves 5.

@ tries to rotate top three elements.

CJam would normally print the stack on exit, but with only a single element the rotation causes an empty stack exception and the 5 is left unprinted.

Befunge:

"Trick" push each letter of "Trick".

o is unspecified and gets ignored.

"taerT" push each letter of "Treat" in reverse.

,,,,, pop and print 5 letters ("Treat")

@ terminates Befunge naturally.

Befunge doesn't print the stack on exit so the letters from "Trick" don't cause a problem. However, the unspecified o may be treated differently on other interpreters. For instance this one would reverse the instruction pointer and wrap back to @ with no output.

Title: Trick or Treat polyglot

Body:
CJam/Befunge, 21 bytes

"Trick"o"taerT",,,,,@

Try it online! (CJam)

Try it online! (Befunge)

CJam:

"Trick"o push "Trick" and print it.

"taerT", push "taerT" and take length, 5.

,,,, take lengths of ranges, leaves 5.

@ tries to rotate top three elements.

CJam would normally print the stack on exit, but with only a single element the rotation causes an empty stack exception and the 5 is left unprinted.

Befunge:

"Trick" push each letter of "Trick".

o is unspecified and gets ignored.

"taerT" push each letter of "Treat" in reverse.

,,,,, pop and print 5 letters ("Treat")

@ terminates Befunge naturally.

Befunge doesn't print the stack on exit so the letters from "Trick" don't cause a problem. However, the unspecified o may be treated differently on other interpreters. For instance this one would reverse the instruction pointer and wrap back to @ with no output.


问:
Add two numbers
Input: Two integers. Preferably decimal integers, but other forms of numbers can be used. These can be given to the code in standard input, as arguments to the program or function, or as a list.

Output: Their sum. Use the same format for output integers as input integers. For example, the input 5 16 would lead to the output 21.

Restrictions: No standard loopholes please. This is code-golf, answer in lowest amount of bytes wins.

Notes: This should be fairly trivial, however I'm interested to see how it can be implemented. The answer can be a complete program or a function, but please identify which one it is.

Test cases:

```<code>1 2 -> 3
14 15 -> 29
7 9 -> 16
-1 8 -> 7
8 -9 -> -1
-8 -9 -> -17
</code>```

Or as CSV:

```<code>a,b,c
1,2,3
14,15,29
7,9,16
-1,8,7
8,-9,-1
-8,-9,-17
</code>```

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Charcoal, <s>4</s> 2 bytes

```<code>Ｉ⁺
</code>```

Try it online!

Explanation

```<code>Ｉ Cast to string
 ⁺ Add
   (implicit) Input number
   (implicit) Input number
</code>```

Title: Add two numbers

Body:
Charcoal, <s>4</s> 2 bytes

Ｉ⁺

Try it online!

Explanation

Ｉ Cast to string
 ⁺ Add
   (implicit) Input number
   (implicit) Input number


答:
Ruby, <s>245</s> 241 bytes

The overhead needed to wrap everything in boxes as well as align everything is pretty heavy...

Outputs arrays of strings, with one string per line, as per the spec. Bottom-aligned instead of the top-aligned sample test cases because it saves 1 byte.

Try it online!

```<code>V=->a{a==[*a]?(k=a.map(&V);k[0]==[*k[0]]?[h=?++?-*((k.map!{|z|z[1,0]=[' '*~-z[0].size+?|]*(k.map(&:size).max-z.size);z};f=k.shift.zip(*k).map{|b|?|+b.reduce{|r,e|r+e[1..-1]}+?|})[0].size-2)+?+,*f,h]:[h="+#{?-*(f=k*' ').size}+",?|+f+?|,h]):a}
</code>```

Title: Visualize an Array

Body:
Given an array of any depth, draw its contents with borders of +-| around each subarray. Those are the ASCII characters for plus, minus, and vertical pipe.

For example, if the array is [1, 2, 3], draw

```<code>+-----+
|1 2 3|
+-----+
</code>```

For a nested array such as [[1, 2, 3], [4, 5], [6, 7, 8]], draw

```<code>+-----------------+
|+-----+---+-----+|
||1 2 3|4 5|6 7 8||
|+-----+---+-----+|
+-----------------+
</code>```

For a ragged array such as [[[1, 2, 3], [4, 5]], [6, 7, 8]], draw

```<code>+-------------------+
|+-----------+-----+|
||+-----+---+|6 7 8||
|||1 2 3|4 5||     ||
||+-----+---+|     ||
|+-----------+-----+|
+-------------------+
</code>```

Notice that there is more space after drawing [6, 7, 8]. You may either draw the contents on the top-most, center, or bottom-most line, but whichever you choose, you must remain consistent.

This challenge was inspired by the box verb < from J.

Rules

This is code-golf so the shortest code wins.

Builtins that solve this are not allowed.

The input array will contain only nonnegative integer values or arrays. Each array will be homogenous, meaning that its elements will either by only arrays or only integers, but never a mix of both.

Each subarray may be nested to any depth.

The output may either by as a string or as an array of strings where each string is a line of output.

Test Cases

```<code>[]
++
||
++

[[], []]
+---+
|+++|
|||||
|+++|
+---+

[[], [1], [], [2], [], [3], []]
+-----------+
|++-++-++-++|
|||1||2||3|||
|++-++-++-++|
+-----------+

[[[[[0]]]]]
+---------+
|+-------+|
||+-----+||
|||+---+|||
||||+-+||||
|||||0|||||
||||+-+||||
|||+---+|||
||+-----+||
|+-------+|
+---------+

[[[[[4, 3, 2, 1]]]], [[[3, 2, 1]]], [[2, 1]], [1]]
+---------------------------------+
|+-------------+---------+-----+-+|
||+-----------+|+-------+|+---+|1||
|||+---------+|||+-----+|||2 1|| ||
||||+-------+|||||3 2 1|||+---+| ||
|||||4 3 2 1|||||+-----+||     | ||
||||+-------+|||+-------+|     | ||
|||+---------+||         |     | ||
||+-----------+|         |     | ||
|+-------------+---------+-----+-+|
+---------------------------------+
</code>```

Body:
Ruby, <s>245</s> 241 bytes

The overhead needed to wrap everything in boxes as well as align everything is pretty heavy...

Outputs arrays of strings, with one string per line, as per the spec. Bottom-aligned instead of the top-aligned sample test cases because it saves 1 byte.

Try it online!

V=->a{a==[*a]?(k=a.map(&V);k[0]==[*k[0]]?[h=?++?-*((k.map!{|z|z[1,0]=[' '*~-z[0].size+?|]*(k.map(&:size).max-z.size);z};f=k.shift.zip(*k).map{|b|?|+b.reduce{|r,e|r+e[1..-1]}+?|})[0].size-2)+?+,*f,h]:[h="+#{?-*(f=k*' ').size}+",?|+f+?|,h]):a}


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

答:
CJam, 26 bytes

```<code>ri:A,_W%.e<{_S*A@2*-'**N}/
</code>```

Try it online!

```<code>ri:A     e# read integer, save as A
,_W%     e# make range and mirror (e.g.[0,1,2,3,4],[4,3,2,1,0])
.e<      e# take minimums (e.g.[0,1,2,1,0])
{        e# for each minimum "m"
  _S*    e#   push m spaces
  A@2*-  e#   calculate A-2m (rotates to spare m)
  '**    e#   push A-2m asterisks
  N      e#   push a newline
}/       e# end, prints stack
</code>```

Title: Draw an hourglass

Body:
CJam, 26 bytes

ri:A,_W%.e<{_S*A@2*-'**N}/

Try it online!

ri:A     e# read integer, save as A
,_W%     e# make range and mirror (e.g.[0,1,2,3,4],[4,3,2,1,0])
.e<      e# take minimums (e.g.[0,1,2,1,0])
{        e# for each minimum "m"
  _S*    e#   push m spaces
  A@2*-  e#   calculate A-2m (rotates to spare m)
  '**    e#   push A-2m asterisks
  N      e#   push a newline
}/       e# end, prints stack


问:
Encode the column cipher
Given a string to encode, and a number of columns (the key), encode the string as follows:

I will be using the example Hello, world! and the key 3

First, write out the number of columns:

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

Next, write the text starting from the upper left, one character per column, and when you run out of columns, go to the next line.

```<code>1 2 3
H e l
l o ,
  w o
r l d
!
</code>```

Now, to get your encoded text, read the text starting from the top left corner, but this time, first read one column, and then the next, and so on. If there is not a character in the slot, put a space.

```<code>Hl r!eowl l,od
</code>```

Note that here, there is a trailing space.

This is your encoded text.

Another test case is Programming Puzzles and Code Golf SE with key 5:

```<code>1 2 3 4 5
P r o g r
a m m i n
g   P u z
z l e s
a n d   C
o d e   G
o l f   S
E
</code>```

The encoded text is PagzaooErm lndl omPedef gius    rnz CGS.

More test cases

```<code>"abcdefghijklmnopqrstuvwxyz", 2 -> "acegikmoqsuwybdfhjlnprtvxz"
"codegolf.stackexchange.com", 4 -> "cg.ccgoooskhemdltea. efaxnc "
"Pen Pineapple Apple Pen!!!", 7 -> "PeAeeapnnpp! pl!Ple!ie  n P "
"1,1,2,3,5,8,13,21,34,55,89", 10 -> "18,,,5115,3,2,8,2931 ,, 53 ,4 "
</code>```

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

Title: Encode the column cipher

Body:
GolfSharp, 82 bytes

(s,i)=>r(0,i).m(x=>r(0,s.L()/i+1).s(n=>(n*3+x)).w(m=>m<s.L()).s(o=>s.R(o,1))).j();


问:
Next Friday the 13th
What is the shortest program that can predict the next time Friday will fall on the 13th day of the month?

Must be an complete functioning program (not just a function/subroutine)

Must print out date in the following format: YYYY-MM-DD

Allow user to provide a start date either as a command line argument or through STDIN

If user provides no start date, use today as the start date.

If the start date is a Friday the 13th, the program should find the next Friday the 13th.

If I were to run the program today (Feb 16 2011) I should get the following output.

```<code>$ ./fr13th 2013-05-09
2013-09-13
$ ./fr13th 2007-06-29
2007-07-13
$ ./fr13th 2007-07-13
2008-06-13
$ ./fr13th
2011-05-13
</code>```

答:
Ruby, <s>96</s> 75 characters

```<code>require"date"
d=Date.parse(gets||"thu")+1
d+=1 while d.wday*d.day!=65
$><<d
</code>```

Takes the date from stdin. To not specify a date press ctrl-d.

Thanks very much for Ventero's help.

Ungolfed:

```<code>require "date"
# Date.parse("thu") will return this week's thursday
date = Date.parse(gets || "thu")+1
date += 1 while d.wday * d.day != 5 * 13
$stdout << date
</code>```

Sample IO:

```<code>$ ruby fr13th.rb
2013-05-09
2013-09-13
$ ruby fr13th.rb
2007-06-29
2007-07-13
$ ruby fr13th.rb
2007-07-13
2008-06-13
$ ruby fr13th.rb
2011-05-13
</code>```

ContentLicense: CC BY-SA 2.5

Title: Next Friday the 13th

Body:
Ruby, <s>96</s> 75 characters

require"date"
d=Date.parse(gets||"thu")+1
d+=1 while d.wday*d.day!=65
$><<d

Takes the date from stdin. To not specify a date press ctrl-d.

Thanks very much for Ventero's help.

Ungolfed:

require "date"
# Date.parse("thu") will return this week's thursday
date = Date.parse(gets || "thu")+1
date += 1 while d.wday * d.day != 5 * 13
$stdout << date

Sample IO:

$ ruby fr13th.rb
2013-05-09
2013-09-13
$ ruby fr13th.rb
2007-06-29
2007-07-13
$ ruby fr13th.rb
2007-07-13
2008-06-13
$ ruby fr13th.rb
2011-05-13


问:
Count sums of two squares
Given a non-negative number n, output the number of ways to express n as the sum of two squares of integers n == a^2 + b^2 (OEIS A004018). Note that a and b can be positive, negative, or zero, and their order matters. Fewest bytes wins.

For example, n=25 gives 12 because 25 can be expressed as

```<code>(5)^2  + (0)^2
(4)^2  + (3)^2
(3)^2  + (4)^2
(0)^2  + (5)^2
(-3)^2 + (4)^2
(-4)^2 + (3)^2
(-5)^2 + (0)^2
(-4)^2 + (-3)^2
(-3)^2 + (-4)^2
(0)^2  + (-5)^2
(3)^2  + (-4)^2
(4)^2  + (-3)^2
</code>```

Here are the values up to n=25. Be careful that your code works for n=0.

```<code>0 1
1 4
2 4
3 0
4 4
5 8
6 0
7 0
8 4
9 4
10 8
11 0
12 0
13 8
14 0
15 0
16 4
17 8
18 4
19 0
20 8
21 0
22 0
23 0
24 0
25 12
</code>```

Here are the values up to n=100 as a list.

```<code>[1, 4, 4, 0, 4, 8, 0, 0, 4, 4, 8, 0, 0, 8, 0, 0, 4, 8, 4, 0, 8, 0, 0, 0, 0, 12, 8, 0, 0, 8, 0, 0, 4, 0, 8, 0, 4, 8, 0, 0, 8, 8, 0, 0, 0, 8, 0, 0, 0, 4, 12, 0, 8, 8, 0, 0, 0, 0, 8, 0, 0, 8, 0, 0, 4, 16, 0, 0, 8, 0, 0, 0, 4, 8, 8, 0, 0, 0, 0, 0, 8, 4, 8, 0, 0, 16, 0, 0, 0, 8, 8, 0, 0, 0, 0, 0, 0, 8, 4, 0, 12]
</code>```

Fun facts: The sequence contains terms that are arbitrarily high, and the limit of its running average is π.

Leaderboard:

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
PHP, 70 bytes, not competing

```<code>for($x=-1;$x++<=$n=$argv[1];)$s+=(-($n%($x-~$x)<1))**$x*4;echo$n?$s:1;
</code>```

algorithm stolen from one of the Python answers ... I forgot which one; wanted to at least partially understand what´s happening before I posted.

Title: Count sums of two squares

Body:
PHP, 70 bytes, not competing

for($x=-1;$x++<=$n=$argv[1];)$s+=(-($n%($x-~$x)<1))**$x*4;echo$n?$s:1;

algorithm stolen from one of the Python answers ... I forgot which one; wanted to at least partially understand what´s happening before I posted.


答:
PHP+HTML, not competing (<s>170</s> <s>141</s> <s>135</s> 130 bytes)

saved 29 bytes inspired by SteeveDroz

```<code><?function p($a){foreach($a as$e)$r.=(is_array($e)?p($e):" $e");return"<b style='border:1px solid;float:left;margin:1px'>$r</b>";}
</code>```

not competing because it´s no ascii output and because I let the browser do all the interesting work

Title: Visualize an Array

Body:
PHP+HTML, not competing (<s>170</s> <s>141</s> <s>135</s> 130 bytes)

saved 29 bytes inspired by SteeveDroz

<?function p($a){foreach($a as$e)$r.=(is_array($e)?p($e):" $e");return"<b style='border:1px solid;float:left;margin:1px'>$r</b>";}

not competing because it´s no ascii output and because I let the browser do all the interesting work


答:
Clojure, 36 bytes

```<code>(doseq[i(range(.pow 100M 50))](prn))
</code>```

Using java interlop cuts it down from original (reduce *'(repeat 10 100)) since clojure core does not have exponent.
dotimes can only work with longs as was pointed out in comment, sadly; I had to resort to lazy seq (+5 bytes).

Title: Output a googol copies of a string

Body:
I am interested in seeing programs which don't ask for any input, print a googol copies of some nonempty string, no less, no more, and then stop. A googol is defined as \$10^{100}\$, i.e., 1 followed by a hundred 0's in decimal.

Example output:

```<code>111111111111111111111111111111111111111111111111111111111111111111111111...
</code>```

or

```<code>Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
...
</code>```

The string can also be entirely composed of white space or special symbols. The only exception to identical copies of a fixed string is if your language decorates the output in some way that can not be prevented, but could be trivially undone in a wrapper script, like prepending a line number to each line. The wrapper script in such cases need not be provided.

You can assume your computer will never run out of time, but other than that, your program must have a reasonable demand of resources. Also, you must respect any restrictions that the programming language of your choice poses, for example, you can not exceed a maximum value allowed for its integer types, and at no point more than 4 GB of memory must be needed.

In other words, the program should in principle be testable by running it on your computer. But because of the extent of this number you will be expected to prove that the number of copies of the string it outputs is exactly 10^100 and that the program stops afterwards. Stopping can be exiting or halting or even terminating due to an error, but if so, the error must not produce any output that could not easily be separated from the program's output.

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

Example solution (C, ungolfed, 3768 bytes)

```<code>#include <stdio.h>

int main() {
  int a00, a01, a02, a03, ..., a99;
  for(a00 = 0; a00 < 10; a00++)
  for(a01 = 0; a01 < 10; a01++)
  for(a02 = 0; a02 < 10; a02++)
  for(a03 = 0; a03 < 10; a03++)
  ...
  for(a99 = 0; a99 < 10; a99++)
    puts("1");
  return 0;
}
</code>```

Body:
Clojure, 36 bytes

(doseq[i(range(.pow 100M 50))](prn))

Using java interlop cuts it down from original (reduce *'(repeat 10 100)) since clojure core does not have exponent.
dotimes can only work with longs as was pointed out in comment, sadly; I had to resort to lazy seq (+5 bytes).


问:
Find the Wavy Words!
(Note: this is an easier spin-off of my previous challenge Find the Infinity Words!, which is a spin-off of my other previous challenge Find the Swirling Words! :) )

Definition of a Wavy Word:

If you connect with curves all the characters of a Wavy Word on the alphabet (A-Z) you obtain the path of a wave continuously going toward right or toward left and never changing direction, like in the diagrams below.

A Wavy Word can be:

Raising if each consecutive character is at the right (on the alphabet) of the previous one.

Decreasing if each consecutive character is at the left (on the alphabet) of the previous one.

All the even connection must be down, all the odd connections must be up.

You can ignore upper/lowercase or consider/convert all to upper case or all to lower case.

The input words are only characters in the alphabet range of A-Z, no spaces, no punctuation, or symbols.

If a word has double characters, like "SPOON", you must collapse the doubles to one character: "SPOON" > "SPON" (because if you go from O to O is zero distance).

The Wavy Words will contain at least 3 distinct characters (even after doubles collapsing).

Here there are some examples:

Task:

Write a full program or function that will take a word from standard input and will output if it is a Wavy Word or not, and in positive case, output if it is raising or decreasing. The output can be True/False/Null, 2/1/0, 1/Null/0, -1/0/1, NO/WR/WD, etc, you decide how to represent it.

Test cases:

```<code>WAVY WORDS:
  ADEPT, BEGIN, BILL, BOSS, BOOST, CHIMP,
  KNOW, SPONGE, SPOON, TROLL, WOLF

ADEPT  > YES > RAISING
BEGIN  > YES > RAISING
BILL   > YES > RAISING
BOSS   > YES > RAISING
BOOST  > YES > RAISING
CHIMP  > YES > RAISING
KNOW   > YES > RAISING
SPONGE > YES > DECREASING
SPOON  > YES > DECREASING
TROLL  > YES > DECREASING
WOLF   > YES > DECREASING

NOT WAVY WORDS:
  WATCH, EARTH, NINON, FOO, BAR, WAVE, SELECTION,
  YES, NO, DEFINITION, WATER, WINE, CODE, AAAHHHH, I, MM, ABCA
</code>```

Rules:

Shortest code wins.

Optional Task:

Find, as a list, as many Wavy Words as you can in an English dictionary, and the longest as well. You can take for example as reference the complete list of English words here.

答:
Java 7, <s>254</s> 240 bytes

```<code>import java.util.*;int c(String s){char[]a=s.toCharArray(),x=a.clone();Arrays.sort(x);return s.replaceAll("(.)\\1{1,}","$1").length()<3?0:Arrays.equals(a,x)|Arrays.equals(x,(new StringBuffer(s).reverse()+"").toCharArray())?a[0]>a[1]?1:2:0;}
</code>```

Outputs 0 if the input string isn't wavy, 1 if it's a raising wave, and 2 if it's a decreasing wave.

Ungolfed & test code:

Try it here.

```<code>import java.util.*;
class M{
  static int c(String s){
    char[] a = s.toCharArray(),
           x = a.clone();
    Arrays.sort(x);
    return s.replaceAll("(.)\\1{1,}", "$1").length() < 3
            ? 0
            : Arrays.equals(a, x) | Arrays.equals(x, (new StringBuffer(s).reverse()+"").toCharArray())
               ? a[0] > a[1]
                  ? 1
                  : 2
               : 0;
  }

  public static void main(String[] a){
    System.out.print(c("ADEPT") + ", ");
    System.out.print(c("BEGIN") + ", ");
    System.out.print(c("BILL") + ", ");
    System.out.print(c("BOSS") + ", ");
    System.out.print(c("BOOST") + ", ");
    System.out.print(c("CHIMP") + ", ");
    System.out.println(c("KNOW"));

    System.out.print(c("SPONGE") + ", ");
    System.out.print(c("SPOON") + ", ");
    System.out.print(c("TROLL") + ", ");
    System.out.println(c("WOLF"));

    System.out.print(c("WATCH") + ", ");
    System.out.print(c("EARTH") + ", ");
    System.out.print(c("NINON") + ", ");
    System.out.print(c("FOO") + ", ");
    System.out.print(c("BAR") + ", ");
    System.out.print(c("WAVE") + ", ");
    System.out.print(c("SELECTION") + ", ");
    System.out.print(c("YES") + ", ");
    System.out.print(c("NO") + ", ");
    System.out.print(c("DEFINITION") + ", ");
    System.out.print(c("WATER") + ", ");
    System.out.print(c("WINE") + ", ");
    System.out.print(c("CODE") + ", ");
    System.out.print(c("AAAHHHH") + ", ");
    System.out.print(c("I") + ", ");
    System.out.print(c("MM") + ", ");
    System.out.println(c("ABCA"));
  }
}
</code>```

Output:

```<code>2, 2, 2, 2, 2, 2, 2
1, 1, 1, 1
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
</code>```

Title: Find the Wavy Words!

Body:
Java 7, <s>254</s> 240 bytes

import java.util.*;int c(String s){char[]a=s.toCharArray(),x=a.clone();Arrays.sort(x);return s.replaceAll("(.)\\1{1,}","$1").length()<3?0:Arrays.equals(a,x)|Arrays.equals(x,(new StringBuffer(s).reverse()+"").toCharArray())?a[0]>a[1]?1:2:0;}

Outputs 0 if the input string isn't wavy, 1 if it's a raising wave, and 2 if it's a decreasing wave.

Ungolfed & test code:

Try it here.

import java.util.*;
class M{
  static int c(String s){
    char[] a = s.toCharArray(),
           x = a.clone();
    Arrays.sort(x);
    return s.replaceAll("(.)\\1{1,}", "$1").length() < 3
            ? 0
            : Arrays.equals(a, x) | Arrays.equals(x, (new StringBuffer(s).reverse()+"").toCharArray())
               ? a[0] > a[1]
                  ? 1
                  : 2
               : 0;
  }

  public static void main(String[] a){
    System.out.print(c("ADEPT") + ", ");
    System.out.print(c("BEGIN") + ", ");
    System.out.print(c("BILL") + ", ");
    System.out.print(c("BOSS") + ", ");
    System.out.print(c("BOOST") + ", ");
    System.out.print(c("CHIMP") + ", ");
    System.out.println(c("KNOW"));

    System.out.print(c("SPONGE") + ", ");
    System.out.print(c("SPOON") + ", ");
    System.out.print(c("TROLL") + ", ");
    System.out.println(c("WOLF"));

    System.out.print(c("WATCH") + ", ");
    System.out.print(c("EARTH") + ", ");
    System.out.print(c("NINON") + ", ");
    System.out.print(c("FOO") + ", ");
    System.out.print(c("BAR") + ", ");
    System.out.print(c("WAVE") + ", ");
    System.out.print(c("SELECTION") + ", ");
    System.out.print(c("YES") + ", ");
    System.out.print(c("NO") + ", ");
    System.out.print(c("DEFINITION") + ", ");
    System.out.print(c("WATER") + ", ");
    System.out.print(c("WINE") + ", ");
    System.out.print(c("CODE") + ", ");
    System.out.print(c("AAAHHHH") + ", ");
    System.out.print(c("I") + ", ");
    System.out.print(c("MM") + ", ");
    System.out.println(c("ABCA"));
  }
}

Output:

2, 2, 2, 2, 2, 2, 2
1, 1, 1, 1
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0


问:
What's the most popular question right now?
Your task is to print the titles of the questions with the five highest scores (upvotes minus downvotes) here on CodeGolf.SE, while skipping over any closed, locked and on-hold questions.

Currently these are:

```<code>Produce the number 2014 without any numbers in your source code
Showcase your language one vote at a time
American Gothic in the palette of Mona Lisa: Rearrange the pixels
Images with all colors
Build a Compiler Bomb
</code>```

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

答:
Bash + curl + gunzip + recode + jq, 165 bytes

(Newline for clarity)

curl "api.stackexchange.com/search/advanced?sort=votes&closed=False&wiki=False&notice=False&pagesize=5&site=codegolf"
|gunzip|jq -r ".items[].title"|recode html:ascii
```

<p>Or if you don't want any output on <code>stderr</code> for 4 more bytes : </p>

<pre class="lang-bash prettyprint-override"><code>curl -s "api.stackexchange.com/search/advanced?sort=votes&closed=False&wiki=False&notice=False&pagesize=5&site=codegolf"
|gunzip|jq -r ".items[].title"|recode html..ascii
</code>```

I thought a bash solution using @Artyer's url would be shorter, turns out it's not that much.

Problems that make it longer :

The stackexchange API responds with compressed data. Using curl's --compressed flag, gzip -d or gunzip solve that, gunzip being the shortest

We need to translate HTML entities

jq outputs JSON data, where strings are enclosed in quotes. Using -r makes it output raw data.

Body:
Bash + curl + gunzip + recode + jq, 165 bytes

(Newline for clarity)

curl "api.stackexchange.com/search/advanced?sort=votes&closed=False&wiki=False&notice=False&pagesize=5&site=codegolf"
|gunzip|jq -r ".items[].title"|recode html:ascii

Or if you don't want any output on stderr for 4 more bytes :

curl -s "api.stackexchange.com/search/advanced?sort=votes&closed=False&wiki=False&notice=False&pagesize=5&site=codegolf"
|gunzip|jq -r ".items[].title"|recode html..ascii

I thought a bash solution using @Artyer's url would be shorter, turns out it's not that much.

Problems that make it longer :

The stackexchange API responds with compressed data. Using curl's --compressed flag, gzip -d or gunzip solve that, gunzip being the shortest

We need to translate HTML entities

jq outputs JSON data, where strings are enclosed in quotes. Using -r makes it output raw data.


答:
x86-64 machine code function, 30 bytes.

Uses the same recursion logic as the C answer by @Level River St.  (Max recursion depth = 100)

Uses the puts(3) function from libc, which normal executables are linked against anyway.  It's callable using the x86-64 System V ABI, i.e. from C on Linux or OS X, and doesn't clobber any registers it's not supposed to.

objdump -drwC -Mintel output, commented with explanation

```<code>0000000000400340 <g>:  ## wrapper function
  400340:       6a 64                   push   0x64
  400342:       5f                      pop    rdi       ; mov edi, 100  in 3 bytes instead of 5
  ; tailcall f by falling into it.

0000000000400343 <f>:  ## the recursive function
  400343:       ff cf                   dec    edi
  400345:       97                      xchg   edi,eax
  400346:       6a 0a                   push   0xa
  400348:       5f                      pop    rdi       ; mov edi, 10
  400349:       0f 8c d1 ff ff ff       jl     400320 <putchar>   # conditional tailcall
; if we don't tailcall, then eax=--n = arg for next recursion depth, and edi = 10 = '\n'

  40034f:       89 f9                   mov    ecx,edi   ; loop count = the ASCII code for newline; saves us one byte

0000000000400351 <f.loop>:
  400351:       50                      push   rax       ; save local state
  400352:       51                      push   rcx
  400353:       97                      xchg   edi,eax   ; arg goes in rdi
  400354:       e8 ea ff ff ff          call   400343 <f>
  400359:       59                      pop    rcx       ; and restore it after recursing
  40035a:       58                      pop    rax
  40035b:       e2 f4                   loop   400351 <f.loop>
  40035d:       c3                      ret
# the function ends here

000000000040035e <_start>:
</code>```

0x040035e - 0x0400340 = 30 bytes

```<code># not counted: a caller that passes argc-1 to f() instead of calling g
000000000040035e <_start>:
  40035e:       8b 3c 24                mov    edi,DWORD PTR [rsp]
  400361:       ff cf                   dec    edi
  400363:       e8 db ff ff ff          call   400343 <f>
  400368:       e8 c3 ff ff ff          call   400330 <exit@plt>    # flush I/O buffers, which the _exit system call (eax=60) doesn't do.
</code>```

Built with yasm -felf64 -Worphan-labels -gdwarf2 golf-googol.asm &&
 gcc -nostartfiles -o golf-googol golf-googol.o.  I can post the original NASM source, but that seemed like clutter since the asm instructions are right there in the disassembly.

putchar@plt is less than 128 bytes away from the jl, so I could have used a 2-byte short jump instead of a 6-byte near jump, but that's only true in a tiny executable, not as part of a larger program.  So I don't think I can justify not counting the size of libc's puts implementation if I also take advantage of a short jcc encoding to reach it.

Each level of recursion uses 24B of stack space (2 pushes and the return address pushed by CALL).  Every other depth will call putchar with the stack only aligned by 8, not 16, so this does violate the ABI.  A stdio implementation that used aligned stores to spill xmm registers to the stack would fault.  But glibc's putchar doesn't do that, writing to a pipe with full buffering or writing to a terminal with line buffering.  Tested on Ubuntu 15.10.  This could be fixed with a dummy push/pop in the .loop, to offset the stack by another 8 before the recursive call.

Proof that it prints the right number of newlines:

```<code>   # with a version that uses argc-1  (i.e. the shell's $i)  instead of a fixed 100
$ for i in {0..8}; do echo -n "$i: "; ./golf-googol $(seq $i) |wc -c; done
0: 1
1: 10
2: 100
3: 1000
4: 10000
5: 100000
6: 1000000
7: 10000000
8: 100000000
... output = 10^n newlines every time.
</code>```

My first version of this was 43B, and used puts() on a buffer of 9 newlines (and a terminating 0 byte), so puts would append the 10th.  That recursion base-case was even closer to the C inspiration.

Factoring 10^100 a different way could maybe have shortened the buffer, maybe down to 4 newlines, saving 5 bytes, but using putchar is better by far.  It only needs an integer arg, not a pointer, and no buffer at all.  The C standard allows implementations where it's a macro for putc(val, stdout), but in glibc it exists as a real function that you can call from asm.

Printing only one newline per call instead of 10 just means we need to increase the recursion max depth by 1, to get another factor of 10 newlines.  Since 99 and 100 can both be represented by a sign-extended 8-bit immediate, push 100 is still only 2 bytes.

Even better, having 10 in a register works as both a newline and a loop counter, saving a byte.

Ideas for saving bytes

A 32-bit version could save a byte for the dec edi, but the stack-args calling convention (for library functions like putchar) makes tail-call work less easily, and would probably require more bytes in more places.  I could use a register-arg convention for the private f(), only called by g(), but then I couldn't tail-call putchar (because f() and putchar() would take a different number of stack-args).

It would be possible to have f() preserve the caller's state, instead of doing the save/restore in the caller.  That probably sucks, though, because it would probably need to get separately in each side of the branch, and isn't compatible with tailcalling.  I tried it but didn't find any savings.

Keeping a loop counter on the stack (instead of push/popping rcx in the loop) didn't help either.  It was 1B worse with the version that used puts, and probably even more of a loss with this version that sets up rcx more cheaply.

Title: Output a googol copies of a string

Body:
x86-64 machine code function, 30 bytes.

Uses the same recursion logic as the C answer by @Level River St.  (Max recursion depth = 100)

Uses the puts(3) function from libc, which normal executables are linked against anyway.  It's callable using the x86-64 System V ABI, i.e. from C on Linux or OS X, and doesn't clobber any registers it's not supposed to.

objdump -drwC -Mintel output, commented with explanation

0000000000400340 <g>:  ## wrapper function
  400340:       6a 64                   push   0x64
  400342:       5f                      pop    rdi       ; mov edi, 100  in 3 bytes instead of 5
  ; tailcall f by falling into it.

0000000000400343 <f>:  ## the recursive function
  400343:       ff cf                   dec    edi
  400345:       97                      xchg   edi,eax
  400346:       6a 0a                   push   0xa
  400348:       5f                      pop    rdi       ; mov edi, 10
  400349:       0f 8c d1 ff ff ff       jl     400320 <putchar>   # conditional tailcall
; if we don't tailcall, then eax=--n = arg for next recursion depth, and edi = 10 = '\n'

  40034f:       89 f9                   mov    ecx,edi   ; loop count = the ASCII code for newline; saves us one byte

0000000000400351 <f.loop>:
  400351:       50                      push   rax       ; save local state
  400352:       51                      push   rcx
  400353:       97                      xchg   edi,eax   ; arg goes in rdi
  400354:       e8 ea ff ff ff          call   400343 <f>
  400359:       59                      pop    rcx       ; and restore it after recursing
  40035a:       58                      pop    rax
  40035b:       e2 f4                   loop   400351 <f.loop>
  40035d:       c3                      ret
# the function ends here

000000000040035e <_start>:

0x040035e - 0x0400340 = 30 bytes

# not counted: a caller that passes argc-1 to f() instead of calling g
000000000040035e <_start>:
  40035e:       8b 3c 24                mov    edi,DWORD PTR [rsp]
  400361:       ff cf                   dec    edi
  400363:       e8 db ff ff ff          call   400343 <f>
  400368:       e8 c3 ff ff ff          call   400330 <exit@plt>    # flush I/O buffers, which the _exit system call (eax=60) doesn't do.

Built with yasm -felf64 -Worphan-labels -gdwarf2 golf-googol.asm &&
 gcc -nostartfiles -o golf-googol golf-googol.o.  I can post the original NASM source, but that seemed like clutter since the asm instructions are right there in the disassembly.

putchar@plt is less than 128 bytes away from the jl, so I could have used a 2-byte short jump instead of a 6-byte near jump, but that's only true in a tiny executable, not as part of a larger program.  So I don't think I can justify not counting the size of libc's puts implementation if I also take advantage of a short jcc encoding to reach it.

Each level of recursion uses 24B of stack space (2 pushes and the return address pushed by CALL).  Every other depth will call putchar with the stack only aligned by 8, not 16, so this does violate the ABI.  A stdio implementation that used aligned stores to spill xmm registers to the stack would fault.  But glibc's putchar doesn't do that, writing to a pipe with full buffering or writing to a terminal with line buffering.  Tested on Ubuntu 15.10.  This could be fixed with a dummy push/pop in the .loop, to offset the stack by another 8 before the recursive call.

Proof that it prints the right number of newlines:

   # with a version that uses argc-1  (i.e. the shell's $i)  instead of a fixed 100
$ for i in {0..8}; do echo -n "$i: "; ./golf-googol $(seq $i) |wc -c; done
0: 1
1: 10
2: 100
3: 1000
4: 10000
5: 100000
6: 1000000
7: 10000000
8: 100000000
... output = 10^n newlines every time.

My first version of this was 43B, and used puts() on a buffer of 9 newlines (and a terminating 0 byte), so puts would append the 10th.  That recursion base-case was even closer to the C inspiration.

Factoring 10^100 a different way could maybe have shortened the buffer, maybe down to 4 newlines, saving 5 bytes, but using putchar is better by far.  It only needs an integer arg, not a pointer, and no buffer at all.  The C standard allows implementations where it's a macro for putc(val, stdout), but in glibc it exists as a real function that you can call from asm.

Printing only one newline per call instead of 10 just means we need to increase the recursion max depth by 1, to get another factor of 10 newlines.  Since 99 and 100 can both be represented by a sign-extended 8-bit immediate, push 100 is still only 2 bytes.

Even better, having 10 in a register works as both a newline and a loop counter, saving a byte.

Ideas for saving bytes

A 32-bit version could save a byte for the dec edi, but the stack-args calling convention (for library functions like putchar) makes tail-call work less easily, and would probably require more bytes in more places.  I could use a register-arg convention for the private f(), only called by g(), but then I couldn't tail-call putchar (because f() and putchar() would take a different number of stack-args).

It would be possible to have f() preserve the caller's state, instead of doing the save/restore in the caller.  That probably sucks, though, because it would probably need to get separately in each side of the branch, and isn't compatible with tailcalling.  I tried it but didn't find any savings.

Keeping a loop counter on the stack (instead of push/popping rcx in the loop) didn't help either.  It was 1B worse with the version that used puts, and probably even more of a loss with this version that sets up rcx more cheaply.


答:
Dyalog APL, 56 bytes

Thanks to ngn for helping removing about a third of the bytes.

{⍵≡∊⍵:⍉⍪⍉⍕⍵⋄(⊢,⊣/)⊃,/(1⊖('++','|'⍴⍨≢),'-'⍪⍣2↑)¨↓↑↓¨∇¨⍵}⊂
```

<h3>TryAPL</h3>

<p>Define the function, then run each test case and compare to the built-in <code>]Display</code> utility.
<br>
<code>[1, 2, 3]</code>
<br>
<code>[[1, 2, 3], [4, 5], [6, 7, 8]]</code>
<br>
<code>[[[1, 2, 3], [4, 5]], [6, 7, 8]]</code>
<br>
<code>[]</code>
<br>
<code>[[], []]</code>
<br>
<code>[[], [1], [], [2], [], [3], []]</code>
<br>
<code>[[[[[0]]]]]</code>
<br>
<code>[[[[[4, 3, 2, 1]]]], [[[3, 2, 1]]], [[2, 1]], [1]]</code></p>

<h1>Explanation</h1>

<p>Overall, this is an anonymous function <code>{...}</code> atop an enclose <code>⊂</code>. The latter just adds another level of nesting prompting the former to add an outer frame.</p>

<p>The anonymous function with white-space (<code>⋄</code> is the statement separator):</p>

<pre class="lang-apl prettyprint-override"><code>{
    ⍵ ≡ ∊⍵: ⍉ ⍪ ⍉ ⍕ ⍵
    (⊢ , ⊣/) ⊃ ,/ (1 ⊖ ('++' , '|' ⍴⍨ ≢) , '-' ⍪⍣2 ↑)¨ ↓ ↑ ↓¨ ∇¨ ⍵
}
</code>```

Here it is again, but with separated utility functions:

CloseBox ← ⊢ , ⊣/
CreateVertical ← '++' , '|' ⍴⍨ ≢
AddHorizontals ← 1 ⊖ CreateVertical , '-' ⍪⍣2 ↑
{
    ⍵ ≡ ∊⍵: ⍉ ⍪ ⍉ ⍕ ⍵
    CloseBox ⊃ ,/ AddHorizontals¨ ↓ ↑ ↓¨ ∇¨ ⍵
}
```

Now let me explain each function:

CloseBox takes a table and returns the same table, but with the table's first column appended on the right of the table. Thus, given the 1-by-3 table XYZ, this function returns the 1-by-4 table XYZX, as follows:

 ⊢ the argument (lit. what is on the right)

 , prepended to

 ⊣/ the leftmost column (lit. the left-reduction of each row)

CreateVertical takes a table and returns the a string consisting of the characters which would fit |s on the sides of the table, but with two +s prepended to match two rows of -. Eventually the table will be cyclically rotated one row to get a single +---... row above and below. Thus, given any  three row table, this function returns ++|||, as follows:

 '++' , two pluses prepended to

 '|' ⍴⍨ a stile reshaped by

 ≢ the (rows') tally of the argument

AddHorizontals takes a list-of-lists, makes it into a table, adds two rows of -s on top, adds the corresponding left edge characters on the left, then rotates one row to the bottom, so that the table has a border on the top, left, and bottom. As follows:

 1 ⊖ rotate one row (the top row goes to the bottom) of

 CreateVertical , the string  ++|||... prepended (as a column) to

 '-' ⍪⍣2 minus added twice to the top of

 ↑ the argument transformed from list-of-lists to table

{The anonymous function}: If the argument is a simple (not nested) list, make it into a character table (thus, given the 3-element list 1 2 3, this function returns the visually identical 1-by-five character table 1 2 3). If the argument is not a simple list, ensure the elements are simple character tables; pad them to equal height; frame each on their top, bottom, and left; combine them; and finally take the very first column and add it on the right. As follows:

 { begin the definition of an anonymous function

  ⍵ ≡ ∊⍵: if the argument is identical to the flattened argument (i.e. it is a simple list), then:

   ⍉ transpose the

   ⍪ columnized

   ⍉ transposed

   ⍕ ⍵ stringified argument; else:

  CloseBox Add the leftmost column to the right of

  ⊃ ,/ the disclosed (because reduction encloses) concatenated-across

  AddHorizontals¨ add -s on top and bottom of each of

  ↓ ↑ ↓¨ the padded-to-equal-height* of

  ∇¨ ⍵  this anonymous function applied to each of the arguments

 } end the definition of the anonymous function

* Lit. make each table into a list-of-lists, combine the lists-of-lists (padding with empty strings to fill short rows) into a table, then split the table into a list of lists-of-lists

Title: Visualize an Array

Body:
Dyalog APL, 56 bytes

Thanks to ngn for helping removing about a third of the bytes.

{⍵≡∊⍵:⍉⍪⍉⍕⍵⋄(⊢,⊣/)⊃,/(1⊖('++','|'⍴⍨≢),'-'⍪⍣2↑)¨↓↑↓¨∇¨⍵}⊂

TryAPL

Define the function, then run each test case and compare to the built-in ]Display utility.

[1, 2, 3]

[[1, 2, 3], [4, 5], [6, 7, 8]]

[[[1, 2, 3], [4, 5]], [6, 7, 8]]

[]

[[], []]

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

[[[[[0]]]]]

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

Explanation

Overall, this is an anonymous function {...} atop an enclose ⊂. The latter just adds another level of nesting prompting the former to add an outer frame.

The anonymous function with white-space (⋄ is the statement separator):

{
    ⍵ ≡ ∊⍵: ⍉ ⍪ ⍉ ⍕ ⍵
    (⊢ , ⊣/) ⊃ ,/ (1 ⊖ ('++' , '|' ⍴⍨ ≢) , '-' ⍪⍣2 ↑)¨ ↓ ↑ ↓¨ ∇¨ ⍵
}

Here it is again, but with separated utility functions:

CloseBox ← ⊢ , ⊣/
CreateVertical ← '++' , '|' ⍴⍨ ≢
AddHorizontals ← 1 ⊖ CreateVertical , '-' ⍪⍣2 ↑
{
    ⍵ ≡ ∊⍵: ⍉ ⍪ ⍉ ⍕ ⍵
    CloseBox ⊃ ,/ AddHorizontals¨ ↓ ↑ ↓¨ ∇¨ ⍵
}

Now let me explain each function:

CloseBox takes a table and returns the same table, but with the table's first column appended on the right of the table. Thus, given the 1-by-3 table XYZ, this function returns the 1-by-4 table XYZX, as follows:

 ⊢ the argument (lit. what is on the right)

 , prepended to

 ⊣/ the leftmost column (lit. the left-reduction of each row)

CreateVertical takes a table and returns the a string consisting of the characters which would fit |s on the sides of the table, but with two +s prepended to match two rows of -. Eventually the table will be cyclically rotated one row to get a single +---... row above and below. Thus, given any  three row table, this function returns ++|||, as follows:

 '++' , two pluses prepended to

 '|' ⍴⍨ a stile reshaped by

 ≢ the (rows') tally of the argument

AddHorizontals takes a list-of-lists, makes it into a table, adds two rows of -s on top, adds the corresponding left edge characters on the left, then rotates one row to the bottom, so that the table has a border on the top, left, and bottom. As follows:

 1 ⊖ rotate one row (the top row goes to the bottom) of

 CreateVertical , the string  ++|||... prepended (as a column) to

 '-' ⍪⍣2 minus added twice to the top of

 ↑ the argument transformed from list-of-lists to table

{The anonymous function}: If the argument is a simple (not nested) list, make it into a character table (thus, given the 3-element list 1 2 3, this function returns the visually identical 1-by-five character table 1 2 3). If the argument is not a simple list, ensure the elements are simple character tables; pad them to equal height; frame each on their top, bottom, and left; combine them; and finally take the very first column and add it on the right. As follows:

 { begin the definition of an anonymous function

  ⍵ ≡ ∊⍵: if the argument is identical to the flattened argument (i.e. it is a simple list), then:

   ⍉ transpose the

   ⍪ columnized

   ⍉ transposed

   ⍕ ⍵ stringified argument; else:

  CloseBox Add the leftmost column to the right of

  ⊃ ,/ the disclosed (because reduction encloses) concatenated-across

  AddHorizontals¨ add -s on top and bottom of each of

  ↓ ↑ ↓¨ the padded-to-equal-height* of

  ∇¨ ⍵  this anonymous function applied to each of the arguments

 } end the definition of the anonymous function

* Lit. make each table into a list-of-lists, combine the lists-of-lists (padding with empty strings to fill short rows) into a table, then split the table into a list of lists-of-lists


答:
T-SQL, 93 bytes

This will also provide an answer when an even number is used - the bottom row will be missing.

Golfed:

```<code>DECLARE @ INT=5

,@i INT=0z:PRINT SPACE(@/2-abs(@/2-@i))+REPLICATE('*',abs(@/2-@i)*2+1)SET
@i+=1IF @i<@ GOTO z
</code>```

Ungolfed:

```<code>DECLARE @ INT=5

,@i INT=0
z:
PRINT SPACE(@/2-abs(@/2-@i))+REPLICATE('*',abs(@/2-@i)*2+1)
SET @i+=1
IF @i<@ GOTO z
</code>```

A bit longer alternative solution without looping

```<code>USE master
DECLARE @ INT=5
SELECT top(@)SPACE(@/2-abs(@/2-number))+REPLICATE('*',abs(@/2-number)*2+1)
FROM spt_values
WHERE'P'=type
</code>```

Fiddle

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:
T-SQL, 93 bytes

This will also provide an answer when an even number is used - the bottom row will be missing.

Golfed:

DECLARE @ INT=5

,@i INT=0z:PRINT SPACE(@/2-abs(@/2-@i))+REPLICATE('*',abs(@/2-@i)*2+1)SET
@i+=1IF @i<@ GOTO z

Ungolfed:

DECLARE @ INT=5

,@i INT=0
z:
PRINT SPACE(@/2-abs(@/2-@i))+REPLICATE('*',abs(@/2-@i)*2+1)
SET @i+=1
IF @i<@ GOTO z

A bit longer alternative solution without looping

USE master
DECLARE @ INT=5
SELECT top(@)SPACE(@/2-abs(@/2-number))+REPLICATE('*',abs(@/2-number)*2+1)
FROM spt_values
WHERE'P'=type

Fiddle


答:
PHP7 (64-bit), 36 bytes

```<code><?=bcsub(bcpow(10,bcpow(10,100)),1);
</code>```

Should output 10^(10^100)-1 so 10^100 times the digit 9.

As of PHP 7.0.0, there are no particular restrictions regarding the length of a string on 64-bit builds. Source

Title: Output a googol copies of a string

Body:
PHP7 (64-bit), 36 bytes

<?=bcsub(bcpow(10,bcpow(10,100)),1);

Should output 10^(10^100)-1 so 10^100 times the digit 9.

As of PHP 7.0.0, there are no particular restrictions regarding the length of a string on 64-bit builds. Source


答:
Common Lisp, 37 bytes

```<code>(loop repeat(expt 10 100)do(print'x))
</code>```

Nothing fancy. Print X followed by newline 10^100 times.

Title: Output a googol copies of a string

Body:
Common Lisp, 37 bytes

(loop repeat(expt 10 100)do(print'x))

Nothing fancy. Print X followed by newline 10^100 times.


问:
"Hello, World!"
So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most interesting code golf in the common languages, finding the shortest solution in certain esolangs can be a serious challenge. For instance, to my knowledge it is not known whether the shortest possible Brainfuck solution has been found yet.

Furthermore, while all of <s>Wikipedia</s> (the Wikipedia entry has been deleted but there is a copy at archive.org
), esolangs and Rosetta Code have lists of "Hello, World!" programs, none of these are interested in having the shortest for each language (there is also this GitHub repository). If we want to be a significant site in the code golf community, I think we should try and create the ultimate catalogue of shortest "Hello, World!" programs (similar to how our basic quine challenge contains some of the shortest known quines in various languages). So let's do this!

The Rules

Each submission must be a full program.

The program must take no input, and print Hello, World! to STDOUT (this exact byte stream, including capitalization and punctuation) plus an optional trailing newline, and nothing else.

The program must not write anything to STDERR.

If anyone wants to abuse this by creating a language where the empty program prints Hello, World!, then congrats, they just paved the way for a very boring answer.

Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language.

Submissions are scored in bytes, in an appropriate (pre-existing) encoding, usually (but not necessarily) UTF-8. Some languages, like Folders, are a bit tricky to score - if in doubt, please ask on Meta.

This is not about finding the language with the shortest "Hello, World!" program. This is about finding the shortest "Hello, World!" program in every language. Therefore, I will not mark any answer as "accepted".

If your language of choice is a trivial variant of another (potentially more popular) language which already has an answer (think BASIC or SQL dialects, Unix shells or trivial Brainfuck-derivatives like Alphuck), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

As a side note, please don't downvote boring (but valid) answers in languages where there is not much to golf - these are still useful to this question as it tries to compile a catalogue as complete as possible. However, do primarily upvote answers in languages where the authors actually had to put effort into golfing the code.

For inspiration, check the Hello World Collection.

The Catalogue

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

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

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

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

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

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

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

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

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

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

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

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

    var lang = a.language;
    lang = jQuery(''+lang+'').text();

    languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;
    if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) return -1;
    return 0;
  });

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
Ruby, 19 Bytes

```<code>$><<"Hello, World!"
</code>```

Title: "Hello, World!"

Body:
Ruby, 19 Bytes

$><<"Hello, World!"


问:
Pythagorean Triple Sequence

A Pythagorean triple consists of three positive integers a, b, and c, such that a2 + b2 = c2. Such a triple is commonly written (a, b, c), and a well-known example is (3, 4, 5). If (a, b, c) is a Pythagorean triple, then so is (ka, kb, kc) for any positive integer k. A primitive Pythagorean triple is one in which a, b and c are coprime.

Using this knowledge, we can create a sequence by chaining together the least lengths of triples, where the next element in the sequence is the hypotenuse (largest number) of the smallest primitive Pythagorean triple containing the previous element as the smallest one of its lengths.

Start with the smallest primitive Pythagorean triple (3, 4, 5). The sequence begins with 3, and the hypotenuse (next element in the sequence) is 5. Then find the smallest primitive Pythagorean triple with 5 as a leg, and you get (5, 12, 13). So the sequence continues with 13.

Either output the sequence forever, or take an integer input n and output the first n elements of the sequence, either zero or one indexed.

You need to support output at least through and including 28455997, but if the limit of the data type you are using was suddenly raised, it would need to work for that new limit. So you cannot hard code a list of numbers.

```<code>3
5
13
85
157
12325
90733
2449525
28455997
295742792965
171480834409967437
656310093705697045
1616599508725767821225590944157
4461691012090851100342993272805
115366949386695884000892071602798585632943213
12002377162350258332845595301471273220420939451301220405
</code>```

OEIS A239381

Similar sequences (don't output these!):

A018928

A077034 (the odd terms)

答:
Python 3.5, 97 bytes

Wrong output after 28455997, because of the limits of the floating point data type. The sqrt function isn't good enough, but if the precision was magically increased, it'd work.

Pretty simple to understand. Incrementing c by two instead of one cuts the runtime in half, and only odd numbers need to be checked anyway, because the elements are always odd.

import math
c=a=3
while 1:
	c+=2;b=(c*c-a*a)**.5;i=int(b)
	if math.gcd(a,i)<2<a<b==i:print(a);a=c
```
<p><strong>Try it online</strong></p>
<p>The program cannot be run on Ideone, because Ideone uses Python 3.4</p>
<hr />
<p>For output to stay accurate longer, I'd have to use <code>decimal</code>:</p>
<pre class="lang-python prettyprint-override"><code>import math
from decimal import*
c=a=3
while 1:
	c+=2;b=Decimal(c*c-a*a).sqrt();i=int(b)
	if i==b>a>2>math.gcd(a,i):print(a);a=c
</code>```

Try it online

To stay accurate indefinitely, I could do something horrid like this (increasing the precision required every single iteration:

import math
from decimal import*
c=a=3
while 1:
	c+=2;b=Decimal(c*c-a*a).sqrt();i=int(b);getcontext().prec+=1
	if i==b>a>2>math.gcd(a,i):print(a);a=c
```

Title: Pythagorean Triple Sequence

Body:
Python 3.5, 97 bytes

Wrong output after 28455997, because of the limits of the floating point data type. The sqrt function isn't good enough, but if the precision was magically increased, it'd work.

Pretty simple to understand. Incrementing c by two instead of one cuts the runtime in half, and only odd numbers need to be checked anyway, because the elements are always odd.

import math
c=a=3
while 1:
	c+=2;b=(c*c-a*a)**.5;i=int(b)
	if math.gcd(a,i)<2<a<b==i:print(a);a=c

Try it online

The program cannot be run on Ideone, because Ideone uses Python 3.4

For output to stay accurate longer, I'd have to use decimal:

import math
from decimal import*
c=a=3
while 1:
	c+=2;b=Decimal(c*c-a*a).sqrt();i=int(b)
	if i==b>a>2>math.gcd(a,i):print(a);a=c

Try it online

To stay accurate indefinitely, I could do something horrid like this (increasing the precision required every single iteration:

import math
from decimal import*
c=a=3
while 1:
	c+=2;b=Decimal(c*c-a*a).sqrt();i=int(b);getcontext().prec+=1
	if i==b>a>2>math.gcd(a,i):print(a);a=c


答:
Sed + bash, 107 bytes

```<code>sed "s/Z/\;done/g;s/\([A-L]\)/\1=n\;while((\1--))\;do /g"<<<"n=10;An=10**9;BCDEFGHIJKLpwdZZZZZZZZZZZZ"|bash
</code>```

By removing the "|bash" at the end, you can see that the bash script generated (with newlines added for readability) is

```<code>n=10;A=n;while((A--));do n=10**9;B=n;while((B--));do C=n;while((C--));do
D=n;while((D--));do E=n;while((E--));do F=n;while((F--));do G=n;while((G--));do
H=n;while((H--));do I=n;while((I--));do J=n;while((J--));do K=n;while((K--));do
L=n;while((L--));do pwd;done;done;done;done;done;done;done;done;done;done;done;
done
</code>```

which is similar to my original bash solution, below, except that it runs 11 loops of 10^9 nested in one loop of 10, for a total of 10^100 iterations.  It never uses a value greater than 10^9, which fits in 32 bits. Each output line
is generated with the shell builtin "pwd" instead of "echo", to save a byte.

Tested by changing 10**9 to "2" or "3" and verifying that the script generates 10 * N^11 lines.

Bash, 312 bytes

```<code>n=2*10**9
a=9765625;while((a--));do
b=n;while((b--));do c=n;while((c--));do d=n;while((d--));do e=n;while((e--));do
f=n;while((f--));do g=n;while((g--));do h=n;while((h--));do i=n;while((i--));do
j=n;while((j--));do k=n;while((k--));do echo "Hello, World!"
done;done;done;done;done;done;done;done;done;done;done
</code>```

(2*10^9)^10 * 9765725 is exactly one googol.

This needs no memory because it doesn't store anything other than the 11 counters and one copy of the "Hello, World!" string.  The counters are integers that never exceed 32 bits.

Unfortunately I couldn't find a way to do this with a recursive function.

Title: Output a googol copies of a string

Body:
Sed + bash, 107 bytes

sed "s/Z/\;done/g;s/\([A-L]\)/\1=n\;while((\1--))\;do /g"<<<"n=10;An=10**9;BCDEFGHIJKLpwdZZZZZZZZZZZZ"|bash

By removing the "|bash" at the end, you can see that the bash script generated (with newlines added for readability) is

n=10;A=n;while((A--));do n=10**9;B=n;while((B--));do C=n;while((C--));do
D=n;while((D--));do E=n;while((E--));do F=n;while((F--));do G=n;while((G--));do
H=n;while((H--));do I=n;while((I--));do J=n;while((J--));do K=n;while((K--));do
L=n;while((L--));do pwd;done;done;done;done;done;done;done;done;done;done;done;
done

which is similar to my original bash solution, below, except that it runs 11 loops of 10^9 nested in one loop of 10, for a total of 10^100 iterations.  It never uses a value greater than 10^9, which fits in 32 bits. Each output line
is generated with the shell builtin "pwd" instead of "echo", to save a byte.

Tested by changing 10**9 to "2" or "3" and verifying that the script generates 10 * N^11 lines.

Bash, 312 bytes

n=2*10**9
a=9765625;while((a--));do
b=n;while((b--));do c=n;while((c--));do d=n;while((d--));do e=n;while((e--));do
f=n;while((f--));do g=n;while((g--));do h=n;while((h--));do i=n;while((i--));do
j=n;while((j--));do k=n;while((k--));do echo "Hello, World!"
done;done;done;done;done;done;done;done;done;done;done

(2*10^9)^10 * 9765725 is exactly one googol.

This needs no memory because it doesn't store anything other than the 11 counters and one copy of the "Hello, World!" string.  The counters are integers that never exceed 32 bits.

Unfortunately I couldn't find a way to do this with a recursive function.


问:
Generate a one-path maze
Given an odd integer N (5 <= N <= 51), generate a maze with side length N that follows the following requirements:

The maze must be composed of the characters  | - and +. It must use the | character as a vertical wall, the - character as a horizontal wall, and if that wall turns, the character + should be used.

The width of the path must be one character.

The maze must turn at least four times.

The maze must have outer walls, that break at two points: the start and the end.

The maze must consist of one non-breaking path, from the start to the end.

For example, the following is a valid maze: (N = 5)

```<code>+---+
|   |
| | |
  |
--+--
</code>```

And for N = 7:

```<code>--+---+
  |   |
| | | |
| | | |
| | | |
|   |
+---+--
</code>```

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

答:
T-SQL, 123/79 bytes

Golfed:

```<code>DECLARE @i INT=7

,@ INT=0z:PRINT
STUFF(CHOOSE(@%4+1,'+- |','|  |','| -+','|  |'),3,0,REPLICATE(IIF(@%2=0,'-',' '),@i))SET
@+=1IF @<@i GOTO z
</code>```

Ungolfed:

```<code>DECLARE @i INT = 9

DECLARE @i INT=7

,@ INT=0
z:
  PRINT
    STUFF(CHOOSE(@%4+1,'+- |','|  |','| -+','|  |'),3,0,
      REPLICATE(IIF(@%2=0,'-',' '),@i))
  SET @+=1
IF @<@i GOTO z
</code>```

If you cheat and only make a narrow labyrinth the script can be golfed down to 79 bytes:

Golfed:

```<code>DECLARE @i INT = 9

,@ INT=0z:PRINT CHOOSE(@%4+1,'+- |','|  |','| -+','|  |')SET @+=1IF @<@i GOTO z
</code>```

Ungolfed:

```<code>DECLARE @i INT = 9

,@ INT=0
z:
  PRINT CHOOSE(@%4+1,'+- |','|  |','| -+','|  |')
  SET @+=1
IF @<@i GOTO z
</code>```

Fiddle for the long answer

Title: Generate a one-path maze

Body:
T-SQL, 123/79 bytes

Golfed:

DECLARE @i INT=7

,@ INT=0z:PRINT
STUFF(CHOOSE(@%4+1,'+- |','|  |','| -+','|  |'),3,0,REPLICATE(IIF(@%2=0,'-',' '),@i))SET
@+=1IF @<@i GOTO z

Ungolfed:

DECLARE @i INT = 9

DECLARE @i INT=7

,@ INT=0
z:
  PRINT
    STUFF(CHOOSE(@%4+1,'+- |','|  |','| -+','|  |'),3,0,
      REPLICATE(IIF(@%2=0,'-',' '),@i))
  SET @+=1
IF @<@i GOTO z

If you cheat and only make a narrow labyrinth the script can be golfed down to 79 bytes:

Golfed:

DECLARE @i INT = 9

,@ INT=0z:PRINT CHOOSE(@%4+1,'+- |','|  |','| -+','|  |')SET @+=1IF @<@i GOTO z

Ungolfed:

DECLARE @i INT = 9

,@ INT=0
z:
  PRINT CHOOSE(@%4+1,'+- |','|  |','| -+','|  |')
  SET @+=1
IF @<@i GOTO z

Fiddle for the long answer


Title: Generate a one-path maze

Body:
Given an odd integer N (5 <= N <= 51), generate a maze with side length N that follows the following requirements:

The maze must be composed of the characters  | - and +. It must use the | character as a vertical wall, the - character as a horizontal wall, and if that wall turns, the character + should be used.

The width of the path must be one character.

The maze must turn at least four times.

The maze must have outer walls, that break at two points: the start and the end.

The maze must consist of one non-breaking path, from the start to the end.

For example, the following is a valid maze: (N = 5)

```<code>+---+
|   |
| | |
  |
--+--
</code>```

And for N = 7:

```<code>--+---+
  |   |
| | | |
| | | |
| | | |
|   |
+---+--
</code>```

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

Body:
JavaScript (ES6), 87 bytes

A recursive function. Outputs a few trailing spaces.

f=(n,w=n,s=' -'[n&1].repeat(w-3),c='|+'[n&1])=>n?`
`+(n&2?c+s+' |':'| '+s+c)+f(n-1,w):s

Test

f=(n,w=n,s=' -'[n&1].repeat(w-3),c='|+'[n&1])=>n?`
`+(n&2?c+s+' |':'| '+s+c)+f(n-1,w):s

console.log(f(9));


答:
JavaScript (ES6), 96 bytes

```<code>f=(n,w=n-3)=>(h="-".repeat(w),n&2?`+${h} |`:`| ${h}+`)+(n>1?`
| ${" ".repeat(w)}|
`+f(n-2,w):"")
</code>```

I was hoping recursion would turn out to be the shortest route, and apparently it is...

Title: Generate a one-path maze

Body:
JavaScript (ES6), 96 bytes

f=(n,w=n-3)=>(h="-".repeat(w),n&2?`+${h} |`:`| ${h}+`)+(n>1?`
| ${" ".repeat(w)}|
`+f(n-2,w):"")

I was hoping recursion would turn out to be the shortest route, and apparently it is...


问:
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, 88 bytes / 53 bytes

Using C89.

g(a){a&&g(a-1);a<2||puts("");while(a--)putchar('*');}main(int a,char**v){g(atoi(v[1]));}

With whitespace for clarity:

```<code>g(a) {
    a && g(a-1);
    a<2 || puts("");
    while (a--) putchar('*');
}
main(int a, char** v) {
    g(atoi(v[1]));
}
</code>```

Without main, this function is 53 bytes:

g(a){a&&g(a-1);a<2||puts("");while(a--)putchar('*');}

Title: Draw an asterisk triangle

Body:
C, 88 bytes / 53 bytes

Using C89.

g(a){a&&g(a-1);a<2||puts("");while(a--)putchar('*');}main(int a,char**v){g(atoi(v[1]));}

With whitespace for clarity:

g(a) {
    a && g(a-1);
    a<2 || puts("");
    while (a--) putchar('*');
}
main(int a, char** v) {
    g(atoi(v[1]));
}

Without main, this function is 53 bytes:

g(a){a&&g(a-1);a<2||puts("");while(a--)putchar('*');}


Title: Generate a one-path maze

Body:
Java 7, 228 bytes

String c(int n){String a="+x |",b="|y|\n",x,y,r=x=y="";int i=0;for(;i++<n-2;){x+=i>1?"-":"";y+=" ";}a=a.replace("x",x);b=b.replace("y",y);for(i=0;i<n;i++)r+=i%4<1?a+"\n":(i-2)%4==0?new StringBuffer(a).reverse()+"\n":b;return r;}

Used a similar vertical output as @JonathanAllan's Jelly answer.

Ungolfed & test code:

Try it here.

class M{
  static String c(int n){
    String a = "+x |",
           b = "|y|\n",
           x = "",
           y = "",
           r = "";
    int i = 0;
    for (; i++ < n-2;){
      x += i > 1
            ? "-"
            : "";
      y += " ";
    }
    a = a.replace("x", x);
    b = b.replace("y", y);
    for(i = 0; i < n; i++){
      r += i % 4 < 1
            ? a+"\n"
            : (i-2) % 4 == 0
               ? new StringBuffer(a).reverse()+"\n"
               : b;
    }
    return r;
  }

  public static void main(String[] a){
    System.out.println(c(7));
    System.out.println();
    System.out.println(c(25));
  }
}

Output:

+---- |
|     |
| ----+
|     |
+---- |
|     |
| ----+

+---------------------- |
|                       |
| ----------------------+
|                       |
+---------------------- |
|                       |
| ----------------------+
|                       |
+---------------------- |
|                       |
| ----------------------+
|                       |
+---------------------- |
|                       |
| ----------------------+
|                       |
+---------------------- |
|                       |
| ----------------------+
|                       |
+---------------------- |
|                       |
| ----------------------+
|                       |
+---------------------- |


答:
Cubix, 22 bytes

```<code>?(.;I:^;/-.@o;(!\>'*oN
</code>```

Test it online! Outputs a trailing newline.

At first I wasn't sure I could get this to fit on a 2-cube, but in the end it worked out fine:

```<code>    ? (
    . ;
I : ^ ; / - . @
o ; ( ! \ > ' *
    o N
    . .
</code>```

I'll add an explanation when I have time, hopefully later today.

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:
Cubix, 22 bytes

?(.;I:^;/-.@o;(!\>'*oN

Test it online! Outputs a trailing newline.

At first I wasn't sure I could get this to fit on a 2-cube, but in the end it worked out fine:

    ? (
    . ;
I : ^ ; / - . @
o ; ( ! \ > ' *
    o N
    . .

I'll add an explanation when I have time, hopefully later today.


答:
HTML/Foo, <s>19</s> <s>15</s> 12 bytes

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

Displays trick in HTML and prints treat in Foo.

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:
HTML/Foo, <s>19</s> <s>15</s> 12 bytes

trick<"treat

Displays trick in HTML and prints treat in Foo.