答:
R, 93 bytes

```<code>function(m){if(m==0){1}else{v=c();for(k in 0:(m-1))v=c(v,choose(m,k)*f(k)/(m-k+1));1-sum(v)}}
</code>```

Not really original as a solution. If any comment, please feel free !

Ungolfed :

```<code>function(m)
    if(m==0){1}
    else
         v=c()
         for(k in 0:(m-1))
            v=c(v,choose(m,k)*f(k)/(m-k+1))

1-sum(v)
</code>```

Title: Bernoulli Numbers

Body:
The Bernoulli numbers (specifically, the second Bernoulli numbers) are defined by the following recursive definition:

Where  denotes a combination.

Given a nonnegative integer m as input, output the decimal representation OR a reduced fraction for the mth second Bernoulli number. If you output a decimal representation, you must have at least 6 decimal places (digits after the decimal point) of precision, and it must be accurate when rounded to 6 decimal places. For example, for m = 2, 0.166666523 is acceptable because it rounds to 0.166667. 0.166666389 is not acceptable, because it rounds to 0.166666. Trailing zeroes may be omitted. Scientific notation may be used for decimal representations.

Here is the input and expected output for m up to and including 60, in scientific notation rounded to 6 decimal places, and as reduced fractions:

```<code>0 -> 1.000000e+00 (1/1)
1 -> 5.000000e-01 (1/2)
2 -> 1.666667e-01 (1/6)
3 -> 0.000000e+00 (0/1)
4 -> -3.333333e-02 (-1/30)
5 -> 0.000000e+00 (0/1)
6 -> 2.380952e-02 (1/42)
7 -> 0.000000e+00 (0/1)
8 -> -3.333333e-02 (-1/30)
9 -> 0.000000e+00 (0/1)
10 -> 7.575758e-02 (5/66)
11 -> 0.000000e+00 (0/1)
12 -> -2.531136e-01 (-691/2730)
13 -> 0.000000e+00 (0/1)
14 -> 1.166667e+00 (7/6)
15 -> 0.000000e+00 (0/1)
16 -> -7.092157e+00 (-3617/510)
17 -> 0.000000e+00 (0/1)
18 -> 5.497118e+01 (43867/798)
19 -> 0.000000e+00 (0/1)
20 -> -5.291242e+02 (-174611/330)
21 -> 0.000000e+00 (0/1)
22 -> 6.192123e+03 (854513/138)
23 -> 0.000000e+00 (0/1)
24 -> -8.658025e+04 (-236364091/2730)
25 -> 0.000000e+00 (0/1)
26 -> 1.425517e+06 (8553103/6)
27 -> 0.000000e+00 (0/1)
28 -> -2.729823e+07 (-23749461029/870)
29 -> 0.000000e+00 (0/1)
30 -> 6.015809e+08 (8615841276005/14322)
31 -> 0.000000e+00 (0/1)
32 -> -1.511632e+10 (-7709321041217/510)
33 -> 0.000000e+00 (0/1)
34 -> 4.296146e+11 (2577687858367/6)
35 -> 0.000000e+00 (0/1)
36 -> -1.371166e+13 (-26315271553053477373/1919190)
37 -> 0.000000e+00 (0/1)
38 -> 4.883323e+14 (2929993913841559/6)
39 -> 0.000000e+00 (0/1)
40 -> -1.929658e+16 (-261082718496449122051/13530)
41 -> 0.000000e+00 (0/1)
42 -> 8.416930e+17 (1520097643918070802691/1806)
43 -> 0.000000e+00 (0/1)
44 -> -4.033807e+19 (-27833269579301024235023/690)
45 -> 0.000000e+00 (0/1)
46 -> 2.115075e+21 (596451111593912163277961/282)
47 -> 0.000000e+00 (0/1)
48 -> -1.208663e+23 (-5609403368997817686249127547/46410)
49 -> 0.000000e+00 (0/1)
50 -> 7.500867e+24 (495057205241079648212477525/66)
51 -> 0.000000e+00 (0/1)
52 -> -5.038778e+26 (-801165718135489957347924991853/1590)
53 -> 0.000000e+00 (0/1)
54 -> 3.652878e+28 (29149963634884862421418123812691/798)
55 -> 0.000000e+00 (0/1)
56 -> -2.849877e+30 (-2479392929313226753685415739663229/870)
57 -> 0.000000e+00 (0/1)
58 -> 2.386543e+32 (84483613348880041862046775994036021/354)
59 -> 0.000000e+00 (0/1)
60 -> -2.139995e+34 (-1215233140483755572040304994079820246041491/56786730)
</code>```

Reference implementation (in Python 3):

def factorial(n):
    if n < 1:
        return 1
    else:
        return n * factorial(n - 1)

def combination(m,k):
    if k <= m:
        return factorial(m)/(factorial(k) * factorial(m - k))
    else:
        return 0

def Bernoulli(m):
    if m == 0:
        return 1
    else:
        t = 0
        for k in range(0, m):
            t += combination(m, k) * Bernoulli(k) / (m - k + 1)
        return 1 - t
```

<h3>Rules</h3>

<ul>
<li>This is code-golf, so shortest code in bytes wins</li>
<li>You may not use any functions, either built-in or included in an external library, that compute either type of Bernoulli numbers or Bernoulli polynomials.</li>
<li>Your answer must give correct output for all inputs up to and including 60.</li>
</ul>

<h1>Leaderboard</h1>

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

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

```## Language Name, N bytes
```

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

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

<p>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 <em>last</em> number in the header:</p>

```## Perl, 43 + 2 (-p flag) = 45 bytes
```

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

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

<p><div class="snippet" data-lang="js" data-hide="true" data-console="false" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-html lang-html prettyprint-override"><code><style>body { text-align: left !important} #answer-list { padding: 10px; width: 290px; float: left; } #language-list { padding: 10px; width: 290px; float: left; } table thead { font-weight: bold; } table td { padding: 5px; }</style><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="language-list"> <h2>Shortest Solution by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr> </thead> <tbody id="languages"> </tbody> </table> </div> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr> </thead> <tbody id="answers"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td>Link</td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td>Link</td></tr> </tbody> </table><script>var QUESTION_ID = 65382; var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk"; var OVERRIDE_USER = 45941; 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 = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>'; }); 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('<a>'+lang+'</a>').text(); languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang.toLowerCase(), 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 > b.lang_raw) return 1; if (a.lang_raw < b.lang_raw) 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); } }</script></code>```

Body:
R, 93 bytes

function(m){if(m==0){1}else{v=c();for(k in 0:(m-1))v=c(v,choose(m,k)*f(k)/(m-k+1));1-sum(v)}}

Not really original as a solution. If any comment, please feel free !

Ungolfed :

function(m)
    if(m==0){1}
    else
         v=c()
         for(k in 0:(m-1))
            v=c(v,choose(m,k)*f(k)/(m-k+1))

1-sum(v)


问:
Tips for golfing in Ruby
What general tips can you give for golfing in Ruby?

I'm looking for ideas that can be applied to code golf problems in general that are specific to Ruby. (For example, "Remove comments" would not be an answer.)

Please post one tip per answer.

答:
To subtract one (-1), instead of doing this

```<code>(i - 1) * 2
</code>```

do the following

```<code>~-i * 2
</code>```

which will save you 2 bytes in cases where you otherwise have to use brackets (e.g. arithmetics).

ContentLicense: CC BY-SA 3.0

Title: Tips for golfing in Ruby

Body:
To subtract one (-1), instead of doing this

(i - 1) * 2

do the following

~-i * 2

which will save you 2 bytes in cases where you otherwise have to use brackets (e.g. arithmetics).


问:
Tips for golfing in R
I'm looking for tips for golfing in the R statistical language.  R is perhaps an unconventional choice for Golf.  However, it does certain things very compactly (sequences, randomness, vectors, and lists), many of the built-in functions have very short names, and it has an optional line terminator (;).  What tips and tricks can you give to help solve code golf problems in R?</p>

答:
Abuse outer to apply an arbitrary function to all the combinations of two lists. Imagine a matrix with i, j indexed by the first args, then you can define an arbitrary function(i,j) for each pair.

Use Map as a shortcut for mapply. My claim is that mapply is cheaper than a for loop in situations where you need to access the index. Abuse the list structure in R. unlist is expensive. methods::el allows you to cheaply unlist the first element. Try to use functions with list support natively.

Use do.call to generalize function calls with arbitrary inputs.

The accumulate args for Reduce is extremely helpful for code golf.

Writing to console line by line with cat(blah, "\n") is cheaper with write(blah, 1). Hard coded strings with "\n" may be cheaper in some situations.

If a function comes with default arguments, you can use function(,,n-arg) to specify the n-th argument directly. Example:seq(1, 10, , 101) In some functions, partial argument matching is supported. Example: seq(1, 10, l = 101).

If you see a challenge involving string manipulation, just press the back button and read the next question. strsplit is single handily responsible for ruining R golf.

Now for some newly discovered tips from 2018

A[cbind(i,j)] = z can be a good way to manipulate matrices. This operation is very byte efficient assuming you design i, j, z as vectors with correct lengths. You may save even more by calling the actual index/assign function "[<-"(cbind(i,j), z). This way of calling returns the modified matrix.

Use a new line instead of \n for line breaks.

Squeezing down line counts can save you bytes. In-line assignment lapply(A<-1:10,function(y) blah) and function args assignment function(X, U = X^2, V = X^3) are ways of doing this.

So "[<-" is a function in R (and is related to my ancient question on SO)! That is the underlying function responsible for operations such as x[1:5] = rnorm(5). The neat property of calling the function by name allows you to return the modified vector. In order words "[<-"(x, 1:5, normr(5)) does almost the same thing as the code above except it returns the modified x. The related "length<-", "names<-", "anything<-" all return modified output

Title: Tips for golfing in R


答:
To join an array, instead of this

```<code>[...].join
</code>```

do this

```<code>[...]*''
</code>```

which saves 2 bytes.
To join with a separator use

```<code>[...]*?,
</code>```

Title: Tips for golfing in Ruby

Body:
What general tips can you give for golfing in Ruby?

I'm looking for ideas that can be applied to code golf problems in general that are specific to Ruby. (For example, "Remove comments" would not be an answer.)

Please post one tip per answer.

Body:
To join an array, instead of this

[...].join

do this

[...]*''

which saves 2 bytes.
To join with a separator use

[...]*?,


问:
This isn't rocket science
Write a program or function that takes in a single-line string. You can assume it only contains printable ASCII. Print or return a string of an ASCII art rocket such as

```<code>  |
 /_\
 |E|
 |a|
 |r|
 |t|
 |h|
 |_|
/___\
 VvV
</code>```

with the input string written from top to bottom on the fuselage. In this case the input was Earth. The height of the rocket (including flames) is always the length of the string plus five.

Each line in the output may have up to two trailing spaces and there may be a single optional trailing newline. The shortest code in bytes wins.

More Examples:

```<code>[empty string]

  |
 /_\
 |_|
/___\
 VvV

a

  |
 /_\
 |a|
 |_|
/___\
 VvV

|0

  |
 /_\
 |||
 |0|
 |_|
/___\
 VvV

\/\

  |
 /_\
 |\|
 |/|
 |\|
 |_|
/___\
 VvV

 _ _ [note trailing space]

  |
 /_\
 | |
 |_|
 | |
 |_|
 | |
 |_|
/___\
 VvV

    [4 spaces]

  |
 /_\
 | |
 | |
 | |
 | |
 |_|
/___\
 VvV

SPACEY

  |
 /_\
 |S|
 |P|
 |A|
 |C|
 |E|
 |Y|
 |_|
/___\
 VvV
</code>```

Leaderboard

var QUESTION_ID=91182,OVERRIDE_USER=26997;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

```

答:
PHP, <s>73</s> <s>72</s> <s>69</s> 62 bytes

```<code>  |
 /_\
 |<?=join('|
 |',str_split($argv[1]._))?>|
/___\
 VvV
</code>```

Takes the string to print on the fuselage as the first argument from the command line when the script is called.

Improvements:

Saved a byte by replacing \n with a real LF newline in the first argument of join.

Saved three more bytes by appending the rocket base with a single underscore to the input

Thanks to Ismael Miguel: Saved 7 more bytes by taking advantage of the fact that PHP used to be the "Hypertext preprocessor" so you can output as much text as you want and start the code somewhere in the middle.

Try it online!

This was fun! :-)

Sample calls:

```<code>php rocket.php ""
php rocket.php EARTH
php rocket.php "This is a very long rocket"
</code>```

Title: This isn't rocket science

Body:
PHP, <s>73</s> <s>72</s> <s>69</s> 62 bytes

  |
 /_\
 |<?=join('|
 |',str_split($argv[1]._))?>|
/___\
 VvV

Takes the string to print on the fuselage as the first argument from the command line when the script is called.

Improvements:

Saved a byte by replacing \n with a real LF newline in the first argument of join.

Saved three more bytes by appending the rocket base with a single underscore to the input

Thanks to Ismael Miguel: Saved 7 more bytes by taking advantage of the fact that PHP used to be the "Hypertext preprocessor" so you can output as much text as you want and start the code somewhere in the middle.

Try it online!

This was fun! :-)

Sample calls:

php rocket.php ""
php rocket.php EARTH
php rocket.php "This is a very long rocket"


问:
Non-palindromic numbers
A strictly non-palindromic number N is a number that isn't a palindrome in any base (in bases 2 to N-2).  These numbers are listed on OEIS

For example, the number 19 in base 2,3,4,5,6,...17 is: 10011,201,103,34,31,...12.  None of these representations is palindromic, so the number is strictly non-palindromic.

For this challenge, you need to return a truthy value if the number is non-palindromic, otherwise a falsy value.

You may assume the number passed to you is greater than or equal to 0.

Your program should work for values up to your languages' integer size.

Test cases:

Truthy:

```<code>0
1
2
3
4
6
11
19
47
53
79
103
389
997
1459
</code>```

Falsy:

```<code>5
7
8
9
10
13
16
43
48
61
62
101
113
211
1361
</code>```

This is a code-golf, so make your answers as short as possible!

Title: Non-palindromic numbers

Body:
C, 129 bytes

f(n,b,k,j){int a[99];for(b=2;b+2<n;++b){for(j=0,k=n;a[j]=k%b,k/=b;++j);for(;k<j&&a[k]==a[j];++k,--j);if(k>=j)return 0;}return 1;}


答:
R, 116 bytes

Golfed

```<code>write(c("  |"," /_\\",sapply(strsplit(scan(,""),"")[[1]],function(y)paste0(" |",y,"|"))," |_|","/___\\"," VvV"),1,1)
</code>```

Ungolfed

```<code>write(                                             # Write to console
      x = c("  |"," /_\\",                         # Add in stock rocket part
        sapply(X = strsplit(scan(,""),"")[[1]],    # Take in rocket part specification, split string, loop over all specs
               FUN = function(y) {
                 paste0(" |",y,"|"))               # Custom build rocket body
                },
        " |_|","/___\\"," VvV"),                   # Add stock parts
      file = 1,                                    # Print to console
      ncolumns = 1)

  |
 /_\
 |s|
 |t|
 |r|
 |s|
 |p|
 |l|
 |i|
 |t|
 |!|
 |_|
/___\
 VvV
</code>```

Title: This isn't rocket science

Body:
Write a program or function that takes in a single-line string. You can assume it only contains printable ASCII. Print or return a string of an ASCII art rocket such as

```<code>  |
 /_\
 |E|
 |a|
 |r|
 |t|
 |h|
 |_|
/___\
 VvV
</code>```

with the input string written from top to bottom on the fuselage. In this case the input was Earth. The height of the rocket (including flames) is always the length of the string plus five.

Each line in the output may have up to two trailing spaces and there may be a single optional trailing newline. The shortest code in bytes wins.

More Examples:

```<code>[empty string]

  |
 /_\
 |_|
/___\
 VvV

a

  |
 /_\
 |a|
 |_|
/___\
 VvV

|0

  |
 /_\
 |||
 |0|
 |_|
/___\
 VvV

\/\

  |
 /_\
 |\|
 |/|
 |\|
 |_|
/___\
 VvV

 _ _ [note trailing space]

  |
 /_\
 | |
 |_|
 | |
 |_|
 | |
 |_|
/___\
 VvV

    [4 spaces]

  |
 /_\
 | |
 | |
 | |
 | |
 |_|
/___\
 VvV

SPACEY

  |
 /_\
 |S|
 |P|
 |A|
 |C|
 |E|
 |Y|
 |_|
/___\
 VvV
</code>```

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
R, 116 bytes

Golfed

write(c("  |"," /_\\",sapply(strsplit(scan(,""),"")[[1]],function(y)paste0(" |",y,"|"))," |_|","/___\\"," VvV"),1,1)

Ungolfed

write(                                             # Write to console
      x = c("  |"," /_\\",                         # Add in stock rocket part
        sapply(X = strsplit(scan(,""),"")[[1]],    # Take in rocket part specification, split string, loop over all specs
               FUN = function(y) {
                 paste0(" |",y,"|"))               # Custom build rocket body
                },
        " |_|","/___\\"," VvV"),                   # Add stock parts
      file = 1,                                    # Print to console
      ncolumns = 1)

  |
 /_\
 |s|
 |t|
 |r|
 |s|
 |p|
 |l|
 |i|
 |t|
 |!|
 |_|
/___\
 VvV


问:
Output the Current Time

Challenge

You must output the current time continuously (until cancelled by an interrupt), once every second, by any of the following means:

It must be in 24-hour or AM/PM format.

If it is the former, it must be spaced out with colons (i.e. 15:47:36).

If it is the latter, it must be spaced out with colons and have the AM/PM following (i.e. 3:47:36 PM)

It may be pulled from the internet.

It may be the system time.

It must output any naturally accessible form of output which supports text that you choose.

Output may have extra information aside of the time in it, but you must guarantee one, and only one, output of time per second.

The continuous output must be a second apart - if you choose to wait until the second changes between outputs, that is fine. If you wait a second between each output, that is perfectly acceptable, despite the eventual loss of accuracy.

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

Catalog

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

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

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

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

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

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

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

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

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

var QUESTION_ID=65020,OVERRIDE_USER=44713;function answersUrl(e){return"//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"//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;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

```

答:
Nim, <s>55</s> 54 bytes

```<code>import os,times
while on:echo getClockStr();sleep 1000
</code>```

on is an alias for true. Prints the result of the times module's getClockStr proc, which formats the time nicely in 24-hour format, then uses the os module's sleep proc to sleep a second.

Title: Output the Current Time

Body:
Nim, <s>55</s> 54 bytes

import os,times
while on:echo getClockStr();sleep 1000

on is an alias for true. Prints the result of the times module's getClockStr proc, which formats the time nicely in 24-hour format, then uses the os module's sleep proc to sleep a second.


问:
Holiday Gift Exchange
Another problem from our internal golfing...this one around the holidays last year.

PROBLEM

Andy, Barb, Carl, Didi, Earl, and Fran are buying gifts for each other. Draw names for a gift exchange.

Each person buys one gift and receives one gift.

Nobody buys their own gift.

Running the solution multiple times should produce different results (giver-receiver pair should not be predictable or identical from run to run).

INPUT

None.

OUTPUT

Formatted as in this example:

Andy buys for Barb

  Barb buys for Carl

  Carl buys for Didi

  Didi buys for Earl

  Earl buys for Fran

  Fran buys for Andy

答:
c99 -- 252 characters

```<code>#include <stdio.h>
#define G for(i=0;i<6;i++)
char*n="Andy\0Barb\0Carl\0Didi\0Earl\0Fran",*p[7];int i,j;int main()
{FILE*r=fopen("/dev/random","r");G p[i]=n+5*i;G{j=fgetc(r)%6;p[7]=p[j]
;p[j]=p[i];p[i]=p[7];}G printf("%s buys for %s\n",p[i],p[(i+1)%6]);}
</code>```

Slight improvement by taking advantage of the circular nature of the permutation. This version always builds a loop-like buying strategy, so it is less random than the previous (271 character) version, but I believe it still meets the spec.

Requires a platform that has a working /dev/random. I ought to be able to knock about 8 off by omitting the \0s in the big string, but my libc doesn't seem to be dealing with %4s print specifiers the way the man page says.

The shuffle is bad, but doing it that way prevents me from having to check on "Foo buys for Foo" conditions.

Readable:

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

char *n="Andy\0Barb\0Carl\0Didi\0Earl\0Fran",
  *p[7]; /* 7th cell for temp */
int i,j;

int main(){
  FILE*r=fopen("/dev/random","r");
  for(i=0;i<6;i++)
    p[i]=n+5*i;   /* Initialize the pointers */
  for(i=0;i<6;i++){
    j=fgetc(r)%6; /* Poor numeric properties. Cest le Code Golf */
    p[7]=p[j];
    p[j]=p[i];
    p[i]=p[7];
  }
  for(i=0;i<6;i++)
    printf("%s buys for %s\n",p[i],p[(i+1)%6]);
}
</code>```

ContentLicense: CC BY-SA 2.5

Title: Holiday Gift Exchange

Body:
c99 -- 252 characters

#include <stdio.h>
#define G for(i=0;i<6;i++)
char*n="Andy\0Barb\0Carl\0Didi\0Earl\0Fran",*p[7];int i,j;int main()
{FILE*r=fopen("/dev/random","r");G p[i]=n+5*i;G{j=fgetc(r)%6;p[7]=p[j]
;p[j]=p[i];p[i]=p[7];}G printf("%s buys for %s\n",p[i],p[(i+1)%6]);}

Slight improvement by taking advantage of the circular nature of the permutation. This version always builds a loop-like buying strategy, so it is less random than the previous (271 character) version, but I believe it still meets the spec.

Requires a platform that has a working /dev/random. I ought to be able to knock about 8 off by omitting the \0s in the big string, but my libc doesn't seem to be dealing with %4s print specifiers the way the man page says.

The shuffle is bad, but doing it that way prevents me from having to check on "Foo buys for Foo" conditions.

Readable:

#include <stdio.h>

char *n="Andy\0Barb\0Carl\0Didi\0Earl\0Fran",
  *p[7]; /* 7th cell for temp */
int i,j;

int main(){
  FILE*r=fopen("/dev/random","r");
  for(i=0;i<6;i++)
    p[i]=n+5*i;   /* Initialize the pointers */
  for(i=0;i<6;i++){
    j=fgetc(r)%6; /* Poor numeric properties. Cest le Code Golf */
    p[7]=p[j];
    p[j]=p[i];
    p[i]=p[7];
  }
  for(i=0;i<6;i++)
    printf("%s buys for %s\n",p[i],p[(i+1)%6]);
}


Title: This isn't rocket science

Body:
PowerShell, 70 bytes

"  |`n /_\`n$(([char[]]$a|%{" |$_|"})-join("`n"))`n |_|`n/___\`n VvV

Set $a to input.

If it has to take input other than a variable it can be piped in:

"Hello World"|%{"  |`n /_\`n$(([char[]]$_|%{" |$_|"})-join("`n"))`n |_|`n/___\`n VvV "}

Example:

  |
 /_\
 |H|
 |e|
 |l|
 |l|
 |o|
 | |
 |W|
 |o|
 |r|
 |l|
 |d|
 |_|
/___\
 VvV


答:
PHP, <s>36</s> 34 bytes

```<code>a:echo'
'.date(r);sleep(1);goto a;
</code>```

The line break can be \n but it's nicer to convert the script to the old Macintosh line format and make it \r, then the time is neatly updated on the same line.

Updates:

Removed short open tag as per this meta answer

Title: Output the Current Time

Body:
Challenge

You must output the current time continuously (until cancelled by an interrupt), once every second, by any of the following means:

It must be in 24-hour or AM/PM format.

If it is the former, it must be spaced out with colons (i.e. 15:47:36).

If it is the latter, it must be spaced out with colons and have the AM/PM following (i.e. 3:47:36 PM)

It may be pulled from the internet.

It may be the system time.

It must output any naturally accessible form of output which supports text that you choose.

Output may have extra information aside of the time in it, but you must guarantee one, and only one, output of time per second.

The continuous output must be a second apart - if you choose to wait until the second changes between outputs, that is fine. If you wait a second between each output, that is perfectly acceptable, despite the eventual loss of accuracy.

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

Catalog

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

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

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

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

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

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

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

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

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

var QUESTION_ID=65020,OVERRIDE_USER=44713;function answersUrl(e){return"//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"//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;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
PHP, <s>36</s> 34 bytes

a:echo'
'.date(r);sleep(1);goto a;

The line break can be \n but it's nicer to convert the script to the old Macintosh line format and make it \r, then the time is neatly updated on the same line.

Updates:

Removed short open tag as per this meta answer


答:
C#, 102 bytes

```<code>using System;class P{static void Main(){for(var s="";;)if(s!=(s=DateTime.Now+"\n"))Console.Write(s);}}
</code>```

An infinite loop that prints whenever the time changes. Default precision for C# date printing is to the second, so that works out nicely.

Title: Output the Current Time

Body:
C#, 102 bytes

using System;class P{static void Main(){for(var s="";;)if(s!=(s=DateTime.Now+"\n"))Console.Write(s);}}

An infinite loop that prints whenever the time changes. Default precision for C# date printing is to the second, so that works out nicely.


问:
Highlight the Bounding Box, Part I: Cartesian Grid
You're given a rectangular grid of the characters . and #, like this:

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

Your task is to fill the entire axis-aligned bounding box of the # with further #:

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

The axis-aligned bounding box is the smallest rectangle which contains all the #.

Want more? Try Part II!

Rules

You may use any two distinct printable ASCII characters (0x20 to 0x7E, inclusive), in place of # and .. I'll continue referring to them as # and . for the remainder of the specification though.

Input and output may either be a single linefeed-separated string or a list of strings (one for each line), but the format has to be consistent.

You may assume that the input contains at least one # and all lines are the same length.

You may write a program or a function and use any of the our standard methods of receiving input and providing output.

You may use any programming language, but note that these loopholes are forbidden by default.

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

Test Cases

Each test case has input and output next to each other.

```<code>#    #

...    ...
#..    #..
...    ...

...    ...
#..    ###
..#    ###

.#.    ###
#..    ###
..#    ###

.....    .....
.#.#.    .###.
.....    .....

...    ...
.#.    .#.
...    .#.
.#.    .#.
...    ...

..........    ..........
..........    ..........
....#.....    ....#.....
..........    ..........

..........    ..........
..........    ..........
....#.....    ...##.....
...#......    ...##.....

..........    ..........
..#.......    ..###.....
....#.....    ..###.....
...#......    ..###.....

..........    ..........
..#.......    ..######..
....#..#..    ..######..
...#......    ..######..

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

答:
Python 3, 153 bytes

```<code>r=lambda w:list(zip(*w[::-1]))
f=lambda w,n=4:list(map(''.join,n and(('#'in w[0])and r(r(r(f(r(w),n-1))))or[w[0]]+foo(w[1:],n))or['#'*len(w[0])]*len(w)))
</code>```

Input and output are a list of strings.

ungolfed

```<code>r=lambda w:list(zip(*w[::-1]))   # rotate grid cw 90 degrees

def f(w,n=4):
    if n:
        if '#' in w[0]:
            u = r(r(r(f(r(w), n-1))))

        else:
            u = [w[0]] + foo(w[1:], n)

    else:
        u = ['#'*len(w[0])]*len(w)

 return list(map(''.join,u))
</code>```

theory of operation

The main idea is to remove rows and columns around the outside of the array if they don't have a '#'.  Whatever is left should be filled in with '#'s.

It is implemented using a recursive function.

Case 1: row 0 doesn't contain a '#'. Result is row 0 + recursive call on remaining rows.

Case 2: row 0 does contain a '#'.  No more rows can be removed.  Rotate array cw so that column 0 is now row 0.  Then recursively process the rotated array.  The result is rotated ccw.

Base case: The array has been rotated 4 times, meaning that all outer rows/columns have been removed if possible.  Whatever remains should be filled in with '#'s

Body:
Python 3, 153 bytes

r=lambda w:list(zip(*w[::-1]))
f=lambda w,n=4:list(map(''.join,n and(('#'in w[0])and r(r(r(f(r(w),n-1))))or[w[0]]+foo(w[1:],n))or['#'*len(w[0])]*len(w)))

Input and output are a list of strings.

ungolfed

r=lambda w:list(zip(*w[::-1]))   # rotate grid cw 90 degrees

def f(w,n=4):
    if n:
        if '#' in w[0]:
            u = r(r(r(f(r(w), n-1))))

        else:
            u = [w[0]] + foo(w[1:], n)

    else:
        u = ['#'*len(w[0])]*len(w)

 return list(map(''.join,u))

theory of operation

The main idea is to remove rows and columns around the outside of the array if they don't have a '#'.  Whatever is left should be filled in with '#'s.

It is implemented using a recursive function.

Case 1: row 0 doesn't contain a '#'. Result is row 0 + recursive call on remaining rows.

Case 2: row 0 does contain a '#'.  No more rows can be removed.  Rotate array cw so that column 0 is now row 0.  Then recursively process the rotated array.  The result is rotated ccw.

Base case: The array has been rotated 4 times, meaning that all outer rows/columns have been removed if possible.  Whatever remains should be filled in with '#'s


问:
Exploded view of a string
Don't you love those exploded-view diagrams  in which a machine or object is taken apart into its smallest pieces?

Let's do that to a string!

The challenge

Write a program or function that

inputs a string containing only printable ASCII characters;

dissects the string into groups of non-space equal characters (the "pieces" of the string);

outputs those groups in any convenient format, with some separator between groups.

For example, given the string

```<code>Ah, abracadabra!
</code>```

the output would be the following groups:

```
!
,
A
aaaaa
bb
c
d
h
rr
```

Each group in the output contains equal characters, with spaces removed. A newline has been used as separator between groups. More about allowed formats below.

Rules

The input should be a string or an array of chars. It will only contain printable ASCII chars (the inclusive range from space to tilde). If your language does not support that, you can take the input in the form of numbers representing ASCII codes.

You can assume that the input contains at least one non-space character.

The output should consist of characters (even if the input is by means of ASCII codes). There has to be an unambiguous separator between groups, different than any non-space character that may appear in the input.

If the output is via function return, it may also be an array or strings, or an array of arrays of chars, or similar structure. In that case the structure provides the necessary separation.

A separator between characters of each group is optional. If there is one, the same rule applies: it can't be a non-space character that may appear in the input. Also, it can't be the same separator as used between groups.

Other than that, the format is flexible. Here are some examples:

The groups may be strings separated by newlines, as shown above.

The groups may be separated by any non-ASCII character, such as  ¬. The output for the above input would be the string:

```<code>!¬,¬A¬aaaaa¬bb¬c¬d¬h¬rr
</code>```

The groups may be separated by n>1 spaces (even if n is variable), with chars between each group separated by a single space:

```<code>!  ,    A   a a a a a    b b  c       d   h  r r
</code>```

The output may also be an array or list of strings returned by a function:

```<code>['!', 'A', 'aaaaa', 'bb', 'c', 'd', 'h', 'rr']
</code>```

Or an array of char arrays:

```<code>[['!'], ['A'], ['a', 'a', 'a', 'a', 'a'], ['b', 'b'], ['c'], ['d'], ['h'], ['r', 'r']]
</code>```

Examples of formats that are not allowed, according to the rules:

A comma can't be used as separator (!,,,A,a,a,a,a,a,b,b,c,d,h,r,r), because the input may contain commas.

It's not accepted to drop the separator between groups (!,Aaaaaabbcdhrr) or to use the same separator between groups and within groups (! , A a a a a a b b c d h r r).

The groups may appear in any order in the output. For example: alphabetical order (as in the examples above), order of first appearance in the string, ... The order need not be consistent or even deterministic.

Note that the input cannot contain newline characters, and A and a are different characters (grouping is case-sentitive).

Shortest code in bytes wins.

Test cases

In each test case, first line is input, and the remaining lines are the output, with each group in a different line.

Test case 1:

```
Ah, abracadabra!
!
,
A
aaaaa
bb
c
d
h
rr
```

Test case 2:

```
\o/\o/\o/
///
\\\
ooo
```

Test case 3:

```
A man, a plan, a canal: Panama!
!
,,
:
A
P
aaaaaaaaa
c
ll
mm
nnnn
p
```

Test case 4:

```
"Show me how you do that trick, the one that makes me scream" she said
""
,
S
aaaaa
cc
dd
eeeeeee
hhhhhh
ii
kk
mmmm
n
ooooo
rr
ssss
tttttt
u
ww
y
```

答:
PowerShell, 65

@TimmyD has the shorter answer but I don't have enough rep to comment. Here's my answer in 65 bytes.

I didn't think to use group and I didn't know that you could stick -join in front of something instead of -join"" on the end and save two characters (using that would make my method 63).

```<code>([char[]]$args[0]-ne32|sort|%{if($l-ne$_){"`n"};$_;$l=$_})-join""
</code>```

My method sorts the array, then loops through it and concatenates characters if they match the preceding entry, inserting a newline if they do not.

Title: Exploded view of a string

Body:
PowerShell, 65

@TimmyD has the shorter answer but I don't have enough rep to comment. Here's my answer in 65 bytes.

I didn't think to use group and I didn't know that you could stick -join in front of something instead of -join"" on the end and save two characters (using that would make my method 63).

([char[]]$args[0]-ne32|sort|%{if($l-ne$_){"`n"};$_;$l=$_})-join""

My method sorts the array, then loops through it and concatenates characters if they match the preceding entry, inserting a newline if they do not.


问:
How does math work in Anastasiya's world?

Background:

Standard operation math like basic addition and multiplication in the real world work like these:

```<code>12 + 123 = 135
</code>```

and

```<code>12 * 123 = 1476
</code>```

That's not interesting and boring! Many schools are already interpreting this as practice, practice, practice of formal algorithms. That implies a pretty rigid and boring mathematical diet and is not what is intended in this challenge. Get ready to play some fun on our beloved site.

Consider the process of adding two positive integer numbers, then adding again all the digits of its result. Repeating with the addition until only a single digit is obtained. For example:

The result of 12 + 123 is 135.

Adding all the digits of 135 we obtain 1 + 3 + 5 = 9.

The number of steps required to obtain a single digit value 9 in this repeated addition is 2.

As with the previous process of the addition, the multiplication of two positive integer numbers follows the same process. Multiply all the digits of its result and then repeating this process until only a single digit remains. Take the above example:

The result of 12 * 123 is 1476.

Multiply all the digits of 1476 we obtain 1 * 4 * 7 * 6 = 168.

Multiply again all the digits of 168 we obtain 1 * 6 * 8 = 48.

Multiply again all the digits of 48 we obtain 4 * 8 = 32.

Multiply once again all the digits of 32 we obtain 3 * 2 = 6.

The number of steps required to obtain a single digit value 6 this repeated multiplication is 5.

For this challenge's sake and avoiding any misuse of math notations, I introduce these two dummy notations: (+) and (*), but you may use any notation you like, which work like the followings:

The operation of repeated addition process to obtain a single value is 12 (+) 123 = 9.

The operation of repeated multiplication process to obtain a single value is 12 (*) 123  = 6.

Challenge:

The challenge is to write either a program or a function which can perform both of operations as explained in the background section: (+) and (*).

Input:

The inputs of the program or the function are two positive integers and one operation either (+) and (*). The format of the input is an arbitrary choice of the programmer. You may format the input, for example, a (+) b or F(a, (+), b) or any format you wish.

Output:

The output of the program or the function must contain the result of operation and the number of steps required with freestyle format as you wish.

Test Cases (ignore the input and output format):

```<code>    81 (+) 31       -->   (4 ; 2)
    351 (+) 14568   -->   (6 ; 3)
    21 (*) 111      -->   (8 ; 3)
    136 (*) 2356    -->   (0 ; 2)
</code>```

General rules:

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

Don't let esolangs discourage you from posting an answer with regular languages. Enjoy this challenge by providing an answer as short as possible with your programming language. If you post a clever answer and a clear explanation, your answer will be appreciated (hence the upvotes) regardless of the programming language you use.

Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/ method with the proper parameters, full programs, etc. The choice is yours.

If possible, your program can properly handle large numbers. If not, that will just be fine.

Let the game begin!!

答:
Clojure 126 bytes

```<code>(defn f [o a b] (loop [n (o a b) c 1] (if (< n 10) [n c] (recur (reduce #(o %1 %2) (map #(- (int %) 48) (str n))) (inc c)))))
</code>```

Function is called like so:

```<code>(f + 81 31)
</code>```

Here is the code ungolfed:

```<code>(defn f [o a b]
  (loop [n (o a b) c 1]
    (if (< n 10)
      [n c]
      (recur (reduce #(o %1 %2)
                     (map #(- (int %) 48) (str n)))
             (inc c)))))

(def test-cases [[+ 81 31]
                 [+ 351 14568]
                 [* 21 111]
                 [* 136 2356]])

(map #(apply f %) test-cases)
;;=> ([4 2] [6 3] [8 3] [0 2])
</code>```

Bear in mind that Clojure is still new to me, so this is likely not the best solution. The challenge was fun all the same. Additionally, the code ran with very large numbers without any difficulty.

Body:
Clojure 126 bytes

(defn f [o a b] (loop [n (o a b) c 1] (if (< n 10) [n c] (recur (reduce #(o %1 %2) (map #(- (int %) 48) (str n))) (inc c)))))

Function is called like so:

(f + 81 31)

Here is the code ungolfed:

(defn f [o a b]
  (loop [n (o a b) c 1]
    (if (< n 10)
      [n c]
      (recur (reduce #(o %1 %2)
                     (map #(- (int %) 48) (str n)))
             (inc c)))))

(def test-cases [[+ 81 31]
                 [+ 351 14568]
                 [* 21 111]
                 [* 136 2356]])

(map #(apply f %) test-cases)
;;=> ([4 2] [6 3] [8 3] [0 2])

Bear in mind that Clojure is still new to me, so this is likely not the best solution. The challenge was fun all the same. Additionally, the code ran with very large numbers without any difficulty.


Title: This isn't rocket science

Body:
MATL, <s>47</s> <s>42</s> 41 bytes

95h"' |'@yPhh]v'   /|_ \'2ew'/ _V_v_V\'2e

Try it online!


问:
Hook length product
A Young diagram is an arrangement of boxes in left-justified rows and top-justified columns. For each box, all the spaces above it and to its left are occupied.

```<code>XXXXX
XXX
XXX
X
</code>```

The hook length of a box is the number of boxes to its right in its row, and below it in its column, also counting itself once. For example, the second box has a hook length of 6:

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

Here are all the hook lengths:

```<code>86521
532
421
1
</code>```

Your goal is compute the product of the hook lengths, here 8*6*5*2*1*5*3*2*4*2*1*1 = 115200.

(Read about the hook length formula if you're interested in why this expression matters.)

Input: A collection of row-sizes as numbers like [5,3,3,1] or as a repeated unary symbol like [[1,1,1,1,1], [1,1,1], [1,1,1], [1]] or "XXXXX XXX XXX X". You can expect the list to be sorted ascending or descending, as you wish. The list will be non-empty and only contain positive integers.

Output: The product of hook lengths, which is a positive integer. Don't worry about integer overflows or runtime.

Built-ins dealing specifically with Young diagrams or integer partitions are not allowed.

Test cases:

```<code>[1] 1
[2] 2
[1, 1] 2
[5] 120
[2, 1] 3
[5, 4, 3, 2, 1] 4465125
[5, 3, 3, 1] 115200
[10, 5] 798336000
</code>```

答:
R, 174 bytes

So... This solution is quite long and could probably be more golfed. I'll think about it !

```<code>v=c();d=length;m=matrix(-1,l<-d(a<-scan()),M<-max(a));for(i in 1:l)m[i,(1:a[i])]=c(a[i]:1);for(j in 1:M)m[,j]=m[,j]+c((((p=d(which(m[,j]>0)))-1)):0,rep(0,(l-p)));abs(prod(m))
</code>```

Ungolfed :

```<code>v=c()          #Empty vector
d=length       #Alias

m=matrix(-1,l<-d(a<-scan()),M<-max(a)) #Builds a matrix full of `-1`

for(i in 1:l)
    m[i,(1:a[i])]=c(a[i]:1) #Replaces each row of the matrix by `n` to 1, `n` being the
                            #corresponding input : each number is the number of non-empty
                            #cells at its left + itself

for(j in 1:M)
    m[,j]=m[,j]+c((((p=d(which(m[,j]>0)))-1)):0,rep(0,(l-p)))

    #This part calculates the number of "non-empty" (i.e. without `-1` in a column), -1,
    #because the count for the cell itself is already done.
    # Then, it creates a vector of those count, appending 0's at the end if necessary
    #(this avoids recycling)

abs(prod(m)) #Outputs the absolute value of the product (because of the `-1`'s)
</code>```

Title: Hook length product

Body:
R, 174 bytes

So... This solution is quite long and could probably be more golfed. I'll think about it !

v=c();d=length;m=matrix(-1,l<-d(a<-scan()),M<-max(a));for(i in 1:l)m[i,(1:a[i])]=c(a[i]:1);for(j in 1:M)m[,j]=m[,j]+c((((p=d(which(m[,j]>0)))-1)):0,rep(0,(l-p)));abs(prod(m))

Ungolfed :

v=c()          #Empty vector
d=length       #Alias

m=matrix(-1,l<-d(a<-scan()),M<-max(a)) #Builds a matrix full of `-1`

for(i in 1:l)
    m[i,(1:a[i])]=c(a[i]:1) #Replaces each row of the matrix by `n` to 1, `n` being the
                            #corresponding input : each number is the number of non-empty
                            #cells at its left + itself

for(j in 1:M)
    m[,j]=m[,j]+c((((p=d(which(m[,j]>0)))-1)):0,rep(0,(l-p)))

    #This part calculates the number of "non-empty" (i.e. without `-1` in a column), -1,
    #because the count for the cell itself is already done.
    # Then, it creates a vector of those count, appending 0's at the end if necessary
    #(this avoids recycling)

abs(prod(m)) #Outputs the absolute value of the product (because of the `-1`'s)


答:
05AB1E, 13 bytes

```<code>[žažbžc)':ý,w
</code>```

Should work, but I don't have Python 3, so I can't test.

Title: Output the Current Time

Body:
05AB1E, 13 bytes

[žažbžc)':ý,w

Should work, but I don't have Python 3, so I can't test.


问:
Is this number a prime?
Believe it or not, we do not yet have a code golf challenge for a simple primality test. While it may not be the most interesting challenge, particularly for "usual" languages, it can be nontrivial in many languages.

Rosetta code features lists by language of idiomatic approaches to primality testing, one using the Miller-Rabin test specifically and another using trial division. However, "most idiomatic" often does not coincide with "shortest." In an effort to make Programming Puzzles and Code Golf the go-to site for code golf, this challenge seeks to compile a catalog of the shortest approach in every language, similar to "Hello, World!" and Golf you a quine for great good!.

Furthermore, the capability of implementing a primality test is part of our definition of programming language, so this challenge will also serve as a directory of proven programming languages.

Task

Write a full program that, given a strictly positive integer n as input, determines whether n is prime and prints a truthy or falsy value accordingly.

For the purpose of this challenge, an integer is prime if it has exactly two strictly positive divisors. Note that this excludes 1, who is its only strictly positive divisor.

Your algorithm must be deterministic (i.e., produce the correct output with probability 1) and should, in theory, work for arbitrarily large integers. In practice, you may assume that the input can be stored in your data type, as long as the program works for integers from 1 to 255.

Input

If your language is able to read from STDIN, accept command-line arguments or any other alternative form of user input, you can read the integer as its decimal representation, unary representation (using a character of your choice), byte array (big or little endian) or single byte (if this is your languages largest data type).

If (and only if) your language is unable to accept any kind of user input, you may hardcode the input in your program.

In this case, the hardcoded integer must be easily exchangeable. In particular, it may appear only in a single place in the entire program.

For scoring purposes, submit the program that corresponds to the input 1.

Output

Output has to be written to STDOUT or closest alternative.

If possible, output should consist solely of a truthy or falsy value (or a string representation thereof), optionally followed by a single newline.

The only exception to this rule is constant output of your language's interpreter that cannot be suppressed, such as a greeting, ANSI color codes or indentation.

Additional rules

This is not about finding the language with the shortest approach for prime testing, this is about finding the shortest approach in every language. Therefore, no answer will be marked as accepted.

Submissions in most languages will be scored in bytes in an appropriate preexisting encoding, usually (but not necessarily) UTF-8.

The language Piet, for example, will be scored in codels, which is the natural choice for this language.

Some languages, like Folders, are a bit tricky to score. If in doubt, please ask on Meta.

Unlike our usual rules, feel free to use a language (or language version) even if it's newer than this challenge. If anyone wants to abuse this by creating a language where the empty program performs a primality test, then congrats for paving 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.

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 Headsecks or Unary), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

Built-in functions for testing primality are allowed. This challenge is meant to catalog the shortest possible solution in each language, so if it's shorter to use a built-in in your language, go for it.

Unless they have been overruled earlier, all standard code-golf rules apply, including the http://meta.codegolf.stackexchange.com/q/1061.

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 catalog as complete as possible. However, do primarily upvote answers in languages where the author actually had to put effort into golfing the code.

Catalog

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

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

Saved 3 bytes thanks to ETHproductions:

for(i=n=prompt();n%--i;);alert(1==i)
```

<p>Displays true for a prime, false otherwise.</p>

<p>The <em>for</em> loop tests every number <em>i</em> from <em>n-1</em> until <em>i</em> is a divisor.
If the first divisor found is <em>1</em> then it's a prime number.</p>

<hr>

<p><strong>Previous solution (39 bytes):</strong></p>

<pre class="lang-js prettyprint-override"><code>for(i=n=prompt();n%--i&&i;);alert(1==i)
</code>```

How was left an unneeded test:

for(i=2,n=prompt();n%i>0&&i*i<n;i++);alert(n%i>0) //49: Simple implementation: loop from 2 to sqrt(n) to test the modulo.
for(i=2,n=prompt();n%i>0&&i<n;i++);alert(n==i)    //46: Replace i*i<n by i<n (loop from 2 to n) and replace n%i>0 by n==i
for(i=2,n=prompt();n%i&&i<n;i++);alert(n==i)      //44: Replace n%i>0 by n%i
for(i=2,n=prompt();n%i&&i++<n;);alert(n==i)       //43: Shorten loop increment
for(i=n=prompt();n%--i&&i>0;);alert(1==i)         //41: Loop from n to 1. Better variable initialization.
for(i=n=prompt();n%--i&&i;);alert(1==i)           //39: \o/ Replace i>0 by i
```

I only posted the 39 bytes solution because the best JavaScript answer was already 40 bytes.

Title: Is this number a prime?

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

Saved 3 bytes thanks to ETHproductions:

for(i=n=prompt();n%--i;);alert(1==i)

Displays true for a prime, false otherwise.

The for loop tests every number i from n-1 until i is a divisor.
If the first divisor found is 1 then it's a prime number.

Previous solution (39 bytes):

for(i=n=prompt();n%--i&&i;);alert(1==i)

How was left an unneeded test:

for(i=2,n=prompt();n%i>0&&i*i<n;i++);alert(n%i>0) //49: Simple implementation: loop from 2 to sqrt(n) to test the modulo.
for(i=2,n=prompt();n%i>0&&i<n;i++);alert(n==i)    //46: Replace i*i<n by i<n (loop from 2 to n) and replace n%i>0 by n==i
for(i=2,n=prompt();n%i&&i<n;i++);alert(n==i)      //44: Replace n%i>0 by n%i
for(i=2,n=prompt();n%i&&i++<n;);alert(n==i)       //43: Shorten loop increment
for(i=n=prompt();n%--i&&i>0;);alert(1==i)         //41: Loop from n to 1. Better variable initialization.
for(i=n=prompt();n%--i&&i;);alert(1==i)           //39: \o/ Replace i>0 by i

I only posted the 39 bytes solution because the best JavaScript answer was already 40 bytes.


问:
There Was A Stream

 Challenge

Write a program that generates the song "There Was A Stream", detailed below.

 Description

The song "There Was a Stream" is a camping song. It takes N parameters and generates a song of length O(N2) lines. A sample song (first 3 verses) is given here.

 Rules

Your entry must take a list of strings and output a valid song. It may be a function (that takes an array of strings) or a program (that takes strings from ARGV or STDIN). Output may be a return value or output to STDOUT or STDERR.

It must run within 1/2 second on my machine (1.66GHz Intel Atom, 1GB RAM, Ubuntu 12.04) for all invocations with less than 15 parameters.

Verses must be separated by a blank line.

No inbuilt compression function (e.g. gzip), whether from the core or from libraries. Things like rot13, md5, base64 etc. are okay though.

You may include a data file (that is placed in the same directory and named whatever you wish), but its score will be added to the total for the program.

Scoring

Count the number of characters (if you use ASCII) or raw bytes (if you use something else).

Command-line flags (without the hyphens) are included, but not the interpreter name, for example #!/usr/bin/perl -n adds 1 to the character count. All whitespace is included.
As with all code-golf, the entry with the lowest character count wins.
Deadline: 14 December 2012

Example
```
INPUT: bank house
OUTPUT: (given above)```

Reference implementation (ungolfed, very ugly code): http://pastebin.com/VeR4Qttn

答:
Perl 239 + 2 = 241 bytes

This is a mostly binary solution, so as usual, this is a program to generate it:

generator.pl

```<code>use MIME::Base64;

$data = <<EOD;
JF89bGMgcGFjayB1NjAsJ8MqbtCBITBInQmKJcpWt4c2oWhLBPwjAkyBIiUwjBI3Ql9c9GoWtJZbuTd5
ZbuWhPwjAkyBIyQjDBFXQlLpGtKJWhP2t4c2r7mhFQjAqdM2t4eTjjk2aJcpWtKJWrb77ms6Kbpc2qKZ
6E1rmtKJWo7JYcmorNZWhM6+U1LpGobLGt4c2osqZ6NGobpGp4eTk0wiTBIXQlLpGr7mtKIdGhPwjBIT
nQkyBISUwjBFXQtKJWhPxAjBLHR7KdNLJWh5r8ms9MpYbTIFQyc7eS8zLTovCkFGSUpUVyAvO2V2YWw=
EOD

print decode_base64($data);
</code>```

Accepts input from STDIN, space separated, two extra bytes for the -na option. Sample usage:

```<code>$ perl generator.pl > out.pl

$ stat -c %s out.pl
239

$ echo bank house | perl -na out.pl
There was a stream
(There was a stream)
Just a teeny-weeny stream
(Just a teeny-weeny stream)
And the stream was on its way...
Where the moon shines high
In the clear blue sky
And all was bright and gay.

And on that stream
(And on that stream)
There was a little bank
(There was a little bank)
Just a teeny-weeny bank
(Just a teeny-weeny bank)
And the bank was on the stream
And the stream was on its way...
Where the moon shines high
In the clear blue sky
And all was bright and gay.

And on that bank
(And on that bank)
There was a little house
(There was a little house)
Just a teeny-weeny house
(Just a teeny-weeny house)
And the house was on the bank
And the bank was on the stream
And the stream was on its way...
Where the moon shines high
In the clear blue sky
And all was bright and gay.
</code>```

Method

Consider the following UU-Encoded string:

```<code>\PRINT($A,$B="8HERE:WAS:A:$L$_","3($B)3",$C="7UST:A:TEENY-WEENY:$_","3($C)",,$5="
\4ND:THE:$_:WAS:ON:$5","ITS:WAY...39HERE:THE:MOON:SHINES:HIGH36N:THE:CLEAR:BLUE:$
\SKY34ND:ALL:WAS:BRIGHT:AND:GAY.33"),$A="4ND:ON:THAT:$_",$A.="3($A)3",$5="THE:$_$
5",$L='LITTLE:'FOR:STREAM,@5#
</code>```

After applying a lc,y/3-:/\nAFIJTW / it becomes this:

```<code>\print($a,$b="There was a $l$_","
($b)
",$c="Just a teeny-weeny $_","
($c)",,$F="
\And the $_ was on $F","its way...
Where the moon shines high
In the clear blue $
\sky
And all was bright and gay.

"),$a="And on that $_",$a.="
($a)
",$F="the $_$
F",$l='little 'for stream,@F#
</code>```

Which is basically the 269 byte solution below.

There's a few problems with this method, though. UU-Encoded strings are limited to characters 33-96, which excludes space, newline, and { | } ~, as well as all lower-case letters. The solution I chose, is to apply lc after the pack u, and then translate 8 characters: space, newline, and the 6 upper-cased I needed. This leaves an 18 byte footprint, which is fairly excessive, but it produces the desired result.

The other problem is that each line needs to begin with the same character (here I chose \ corresponding to a decoded length of 60 (92 - 32), which is an encoded length of 80), except for the last line, which needs to begin with the character reflecting its length. Here I ended up with 21 (padding with a # to be evenly divisible by 3), corresponding to 5. No problem, I'm replacing 5 anyway, so I chose it as one of my variables. Perl seems to be incredibly lenient about where you can place backslashes. This program even begins with one.

It is possible to instruct perl to use a other characters to begin each line, such as M (the default value), but none seem quite as flexible as a backslash. As an aside, this method should be equally as effective in Ruby. If I had any skill in the language, I might be tempted to try it.

For reference, my previous solutions remain below.

Perl 267 + 2 = 269 bytes

```<code>(print$a,$b="There was a $l$_","
($b)
",$c="Just a teeny-weeny $_","
($c)",$d="
And the $_ was on $d",'its way...
Where the moon shines high
In the clear blue sky
And all was bright and gay.

'),$a="And on that $_",$a.="
($a)
",$d="the $_$d",$l='little 'for stream,@F
</code>```

Accepts input from STDIN, space separated, two extra bytes for the -na option. Sample usage:

```<code>$ echo bank house | perl -na stream-song.pl
</code>```

PHP 286 bytes

No real attempt at compression, just output reusage.

```<code><?for($w=stream;$w;$a="And on that $w",$a.="
($a)
",$l='little ',$d="the $w$d",$w=next($argv))echo$a,$b="There was a $l$w","
($b)
",$c="Just a teeny-weeny $w","
($c)",$d="
And the $w was on $d",'its way...
Where the moon shines high
In the clear blue sky
And all was bright and gay.

';
</code>```

Accepts input as command line arguments. Sample usage:

```<code>$ php stream-song.php bank house
</code>```

Title: There Was A Stream

Body:
Perl 239 + 2 = 241 bytes

This is a mostly binary solution, so as usual, this is a program to generate it:

generator.pl

use MIME::Base64;

$data = <<EOD;
JF89bGMgcGFjayB1NjAsJ8MqbtCBITBInQmKJcpWt4c2oWhLBPwjAkyBIiUwjBI3Ql9c9GoWtJZbuTd5
ZbuWhPwjAkyBIyQjDBFXQlLpGtKJWhP2t4c2r7mhFQjAqdM2t4eTjjk2aJcpWtKJWrb77ms6Kbpc2qKZ
6E1rmtKJWo7JYcmorNZWhM6+U1LpGobLGt4c2osqZ6NGobpGp4eTk0wiTBIXQlLpGr7mtKIdGhPwjBIT
nQkyBISUwjBFXQtKJWhPxAjBLHR7KdNLJWh5r8ms9MpYbTIFQyc7eS8zLTovCkFGSUpUVyAvO2V2YWw=
EOD

print decode_base64($data);

Accepts input from STDIN, space separated, two extra bytes for the -na option. Sample usage:

$ perl generator.pl > out.pl

$ stat -c %s out.pl
239

$ echo bank house | perl -na out.pl
There was a stream
(There was a stream)
Just a teeny-weeny stream
(Just a teeny-weeny stream)
And the stream was on its way...
Where the moon shines high
In the clear blue sky
And all was bright and gay.

And on that stream
(And on that stream)
There was a little bank
(There was a little bank)
Just a teeny-weeny bank
(Just a teeny-weeny bank)
And the bank was on the stream
And the stream was on its way...
Where the moon shines high
In the clear blue sky
And all was bright and gay.

And on that bank
(And on that bank)
There was a little house
(There was a little house)
Just a teeny-weeny house
(Just a teeny-weeny house)
And the house was on the bank
And the bank was on the stream
And the stream was on its way...
Where the moon shines high
In the clear blue sky
And all was bright and gay.

Method

Consider the following UU-Encoded string:

\PRINT($A,$B="8HERE:WAS:A:$L$_","3($B)3",$C="7UST:A:TEENY-WEENY:$_","3($C)",,$5="
\4ND:THE:$_:WAS:ON:$5","ITS:WAY...39HERE:THE:MOON:SHINES:HIGH36N:THE:CLEAR:BLUE:$
\SKY34ND:ALL:WAS:BRIGHT:AND:GAY.33"),$A="4ND:ON:THAT:$_",$A.="3($A)3",$5="THE:$_$
5",$L='LITTLE:'FOR:STREAM,@5#

After applying a lc,y/3-:/\nAFIJTW / it becomes this:

\print($a,$b="There was a $l$_","
($b)
",$c="Just a teeny-weeny $_","
($c)",,$F="
\And the $_ was on $F","its way...
Where the moon shines high
In the clear blue $
\sky
And all was bright and gay.

"),$a="And on that $_",$a.="
($a)
",$F="the $_$
F",$l='little 'for stream,@F#

Which is basically the 269 byte solution below.

There's a few problems with this method, though. UU-Encoded strings are limited to characters 33-96, which excludes space, newline, and { | } ~, as well as all lower-case letters. The solution I chose, is to apply lc after the pack u, and then translate 8 characters: space, newline, and the 6 upper-cased I needed. This leaves an 18 byte footprint, which is fairly excessive, but it produces the desired result.

The other problem is that each line needs to begin with the same character (here I chose \ corresponding to a decoded length of 60 (92 - 32), which is an encoded length of 80), except for the last line, which needs to begin with the character reflecting its length. Here I ended up with 21 (padding with a # to be evenly divisible by 3), corresponding to 5. No problem, I'm replacing 5 anyway, so I chose it as one of my variables. Perl seems to be incredibly lenient about where you can place backslashes. This program even begins with one.

It is possible to instruct perl to use a other characters to begin each line, such as M (the default value), but none seem quite as flexible as a backslash. As an aside, this method should be equally as effective in Ruby. If I had any skill in the language, I might be tempted to try it.

For reference, my previous solutions remain below.

Perl 267 + 2 = 269 bytes

(print$a,$b="There was a $l$_","
($b)
",$c="Just a teeny-weeny $_","
($c)",$d="
And the $_ was on $d",'its way...
Where the moon shines high
In the clear blue sky
And all was bright and gay.

'),$a="And on that $_",$a.="
($a)
",$d="the $_$d",$l='little 'for stream,@F

Accepts input from STDIN, space separated, two extra bytes for the -na option. Sample usage:

$ echo bank house | perl -na stream-song.pl

PHP 286 bytes

No real attempt at compression, just output reusage.

<?for($w=stream;$w;$a="And on that $w",$a.="
($a)
",$l='little ',$d="the $w$d",$w=next($argv))echo$a,$b="There was a $l$w","
($b)
",$c="Just a teeny-weeny $w","
($c)",$d="
And the $w was on $d",'its way...
Where the moon shines high
In the clear blue sky
And all was bright and gay.

';

Accepts input as command line arguments. Sample usage:

$ php stream-song.php bank house


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

答:
Combine Local Variable Assignments

Instead of:

```<code>local a=42
local b=17
local c=99
</code>```

Use parallel assignment:

```<code>local a,b,c=42,17,19
</code>```

6 bytes saved for each variable!

Declare Local Variables via Unused Function Parameters

Instead of:

```<code>function foo(a,b) local c,d ... end
function bar(a,b) local c,d=42,17 ... end
</code>```

Use

```<code>function foo(a,b,c,d) ... end
function bar(a,b,c,d) c,d=42,17 ... end
</code>```

6 bytes saved (minus 1-2 bytes for each variable that might be duplicated).

Title: Tips for golfing in Lua

Body:
Combine Local Variable Assignments

Instead of:

local a=42
local b=17
local c=99

Use parallel assignment:

local a,b,c=42,17,19

6 bytes saved for each variable!

Declare Local Variables via Unused Function Parameters

Instead of:

function foo(a,b) local c,d ... end
function bar(a,b) local c,d=42,17 ... end

Use

function foo(a,b,c,d) ... end
function bar(a,b,c,d) c,d=42,17 ... end

6 bytes saved (minus 1-2 bytes for each variable that might be duplicated).


答:
GNU sed, <s>54</s> <s>49</s> 48 bytes

This was my first answer to a challenge on this site. The solution is simple, mainly printing, so I spent some time making sure that it can't be golfed anymore.

s:.:\n |&|:g
s::  |& /_\\&:
a\ |_|\n/___\\\n VvV
```

<p><strong>Try it online!</strong></p>

<p>Fast forward half a year later, I rewrote the script, used a trick for good measure and golfed it down to 1 byte shorter. Now that's progress!</p>

<p><strong>Explanation:</strong> the pattern space at each step is mentioned for clarity, given the input example "GO"</p>

<pre class="lang-sed prettyprint-override"><code>s:.:\n |&|:g
   # turn each input char into a section of the rocket (\n |G|\n |O|)
s::  |& /_\\&:
   # 's::' is a trick; the search part is actually the one from the previous 's'
   #command, i.e. a char. Only the first char, '\n', the modifier 'g' is not
   #inherited. The replace part is the head of the rocket. (  |\n /_\\n |G|\n |O|)
a\ |_|\n/___\\\n VvV
   # append the tail of the rocket, plus implicit printing at the end

  |
 /_\
 |G|
 |O|
 |_|
/___\
 VvV
</code>```

Title: This isn't rocket science

Body:
Write a program or function that takes in a single-line string. You can assume it only contains printable ASCII. Print or return a string of an ASCII art rocket such as

```<code>  |
 /_\
 |E|
 |a|
 |r|
 |t|
 |h|
 |_|
/___\
 VvV
</code>```

with the input string written from top to bottom on the fuselage. In this case the input was Earth. The height of the rocket (including flames) is always the length of the string plus five.

Each line in the output may have up to two trailing spaces and there may be a single optional trailing newline. The shortest code in bytes wins.

More Examples:

```<code>[empty string]

  |
 /_\
 |_|
/___\
 VvV

a

  |
 /_\
 |a|
 |_|
/___\
 VvV

|0

  |
 /_\
 |||
 |0|
 |_|
/___\
 VvV

\/\

  |
 /_\
 |\|
 |/|
 |\|
 |_|
/___\
 VvV

 _ _ [note trailing space]

  |
 /_\
 | |
 |_|
 | |
 |_|
 | |
 |_|
/___\
 VvV

    [4 spaces]

  |
 /_\
 | |
 | |
 | |
 | |
 |_|
/___\
 VvV

SPACEY

  |
 /_\
 |S|
 |P|
 |A|
 |C|
 |E|
 |Y|
 |_|
/___\
 VvV
</code>```

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
GNU sed, <s>54</s> <s>49</s> 48 bytes

This was my first answer to a challenge on this site. The solution is simple, mainly printing, so I spent some time making sure that it can't be golfed anymore.

s:.:\n |&|:g
s::  |& /_\\&:
a\ |_|\n/___\\\n VvV

Try it online!

Fast forward half a year later, I rewrote the script, used a trick for good measure and golfed it down to 1 byte shorter. Now that's progress!

Explanation: the pattern space at each step is mentioned for clarity, given the input example "GO"

s:.:\n |&|:g
   # turn each input char into a section of the rocket (\n |G|\n |O|)
s::  |& /_\\&:
   # 's::' is a trick; the search part is actually the one from the previous 's'
   #command, i.e. a char. Only the first char, '\n', the modifier 'g' is not
   #inherited. The replace part is the head of the rocket. (  |\n /_\\n |G|\n |O|)
a\ |_|\n/___\\\n VvV
   # append the tail of the rocket, plus implicit printing at the end

  |
 /_\
 |G|
 |O|
 |_|
/___\
 VvV


问:
What does this button do?
Currently at my work we moved to a new building. It's supposed to be state of the art and has automatic lights, automatic roll-down shutters, and is now known as the most eco-friendly building in this town.

However, it doesn't really work all that well.. The roll-down shutters sometimes go down on cloudy days and up when the sun starts to shine, and the lights sometimes cause disco effects by alternating turning on and off every 5-10 minutes. Also, we don't have any manual way of controlling these roll-down shutters, nor the temperature, BUT we do have a remote for the lights.

These remotes however came without instruction manual and contain little over 20 buttons doing all kind of stuff except for what you seem to want..

PS: I wrote this challenge 1.5 months ago in the Sandbox. Currently we, kinda, know how the remotes work..

One big advantage about this building, it's 30+ degrees Celcius outside, but inside it stays the same 21 room temperature at all time.

So, that was the intro, and the remote control for the lights inspired this challenge.

Challenge:

Let's say we initially have a lamp turned off:

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

Then we push all kind of buttons and output the state of the lamp afterwards.

We use the following numbers for the different functions of the remote control for the lamp. When a minus symbol is in front of that number, we do the opposite.

1 = ON; -1 = OFF.

2 = Increase strength by 25%; -2 = Decrease (dim) strength by 25%.

3 = Increase spread by 50%; -3 = Decrease spread by 50%.

4 = Toggling the type of light.

So, this is all pretty vague, so let's go a little more in depth what each thing means:

So, -1 (OFF) is pretty obvious, and 1 will go to the initial ON-state (50% for 2 and 50% for 3):

```<code>   //
  //
L ====
  \\
   \\
</code>```

2 and -2 is how far the light travels (== is appended for every 25%):

```<code>0% (equal to a light bulb that is OFF)
L

25%
L ==

50%
L ====

75%
L ======

100%
L ========
</code>```

3 and -3 is how far the light spreads:

```<code>0%:
L ====

50%:
   //
  //
L ====
  \\
   \\

100%:
|| //
||//
L ====
||\\
|| \\
</code>```

(NOTE: When 2 and 3 are both at 100%, you'll have this state:

```<code>||   //
||  //
|| //
||//
L ========
||\\
|| \\
||  \\
||   \\
</code>```

4 is to toggle the type of light.

```<code>Default:
  //
L ==
  \\

After toggling (note the single space before '/' instead of two):
 /
L --
 \
</code>```

Input:

You will receive an input containing the possible button-presses. For example:

```<code>12-34
</code>```

Output:

The state of the light lamp after all the buttons of the input are sub-sequential pressed. So with the example input above, we have the following output:

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

Challenge rules:

The input only contains 1234- (and never a - before the 4).

You can never go below 0% or above 100%. If a number would increase/decrease beyond these boundaries you can ignore it.

When the lamp is turned off, you can ignore any actions and when turned back on again it resets back to the initial ON-state (50% for both 2 and 3, and default 4). For example: 12-1-341 will just print the initial ON-state mentioned above. (TIP: You can ignore everything before the final 1 of the input - excluding -1.)

Trailing spaces equal to the length of the light or a single trailing new line is uninhibited. Adding extra unnecessary new lines isn't however.

You are allowed to take the input as a list of integers instead of a single string. So instead of 12-34, you can have [1,2,-3,4] as input.

General rules:

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

Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.

Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters, full programs. Your call.

Default Loopholes are forbidden.

If possible, please add a link with a test for your code.

Also, please add an explanation if necessary.

Test cases:

```<code>12-34
L ------

12-1-341
   //
  //
L ====
  \\
   \\

14-3224333-2
||  //
|| //
||//
L ======
||\\
|| \\
||  \\

142-1-314-3-322
L --------

1324-2-3
  /
 /
L ----
 \
  \

134
| /
|/
L ----
|\
| \

1-2-2-214-3-3-3
L ----
</code>```

答:
Batch, 552 bytes

```<code>@echo off
for %%a in (1 %*) do call:l %%a
set/aw*=o,l*=o
if %w% gtr 0 for /l %%a in (%l%,-1,1)do call:w %%a /
set s=----
if %t%==1 set s=====
call echo L %%s:~-%l%%%%%s:~-%l%%%
if %w% gtr 0 for /l %%a in (1,1,%l%)do call:w %%a \
exit/b
:w
set v=
set u=%2
if %w%==2 set v=l
if %t%==1 set u=%2%2&set v=%v%%v%
set s=
call set s=%%s:~-%1%%
echo %v:l=^|%%s:~1%%u%
exit/b
:l
if %1==1 set/ao=w=t=1,l=2
if %1==-1 set/ao=0
if %1==2 set/al+=1-l/4
if %1==-2 set/al-=!!l
if %1==3 set/aw+=1-w/2
if %1==-3 set/aw-=!!w
if %1==4 set/at^=1
</code>```

Note: set v= contains one trailing space and set s= contains three. This was really awkward, as you can't easily print a variable number of |s in Batch, so you have to use a placeholder and replace it in the echo statement.

Title: What does this button do?

Body:
Batch, 552 bytes

@echo off
for %%a in (1 %*) do call:l %%a
set/aw*=o,l*=o
if %w% gtr 0 for /l %%a in (%l%,-1,1)do call:w %%a /
set s=----
if %t%==1 set s=====
call echo L %%s:~-%l%%%%%s:~-%l%%%
if %w% gtr 0 for /l %%a in (1,1,%l%)do call:w %%a \
exit/b
:w
set v=
set u=%2
if %w%==2 set v=l
if %t%==1 set u=%2%2&set v=%v%%v%
set s=
call set s=%%s:~-%1%%
echo %v:l=^|%%s:~1%%u%
exit/b
:l
if %1==1 set/ao=w=t=1,l=2
if %1==-1 set/ao=0
if %1==2 set/al+=1-l/4
if %1==-2 set/al-=!!l
if %1==3 set/aw+=1-w/2
if %1==-3 set/aw-=!!w
if %1==4 set/at^=1

Note: set v= contains one trailing space and set s= contains three. This was really awkward, as you can't easily print a variable number of |s in Batch, so you have to use a placeholder and replace it in the echo statement.


Title: This isn't rocket science

Body:
Clojure (83 bytes)

#(str "  |\n /_\\\n |" (clojure.string/join "|\n |" (str % \_)) "|\n/___\\\n VvV")

And here's a rocket for you:

  |
 /_\
 |W|
 |e|
 |l|
 |c|
 |o|
 |m|
 |e|
 | |
 |t|
 |a|
 | |
 |E|
 |a|
 |r|
 |f|
 |_|
/___\
 VvV


答:
Lua, 69 68 bytes

```<code>print([[  |
 /_\
]]..(...):gsub('.',' |%0|\n')..[[ |_|
/___\
 VvV]])
</code>```

Should work with Lua 5.1 - 5.3 (tested with 5.3).

I don't have enough rep to comment on nolan's answer, but this is quite similar.

I'm using [[long string]] syntax to save a few bytes by avoiding needing to escape newlines and backslashes.

gsub doesn't need to specify a capture because %0 can be used. (Actually, %1 still works without a capture as well, but this isn't strictly documented.)

I also trimmed away the input validation; not sure why it was there -- an empty string input (as opposed to empty input) will work fine. Handling a missing arg[1] can be done more briefly just by (arg[1]or''):gsub(...) anyway, although at this point it is briefer just to switch to io.read() and get the input from stdin. Anyway, ... is a shorter way to get command-line input (even if parens are needed).

Title: This isn't rocket science

Body:
Lua, 69 68 bytes

print([[  |
 /_\
]]..(...):gsub('.',' |%0|\n')..[[ |_|
/___\
 VvV]])

Should work with Lua 5.1 - 5.3 (tested with 5.3).

I don't have enough rep to comment on nolan's answer, but this is quite similar.

I'm using [[long string]] syntax to save a few bytes by avoiding needing to escape newlines and backslashes.

gsub doesn't need to specify a capture because %0 can be used. (Actually, %1 still works without a capture as well, but this isn't strictly documented.)

I also trimmed away the input validation; not sure why it was there -- an empty string input (as opposed to empty input) will work fine. Handling a missing arg[1] can be done more briefly just by (arg[1]or''):gsub(...) anyway, although at this point it is briefer just to switch to io.read() and get the input from stdin. Anyway, ... is a shorter way to get command-line input (even if parens are needed).


答:
S.I.L.O.S, 206 bytes

```<code>GOTO e
lbld
c - 1
GOTO c
lble
readIO
n = i
i - 3
b = i
b + 1
GOTO f
lbla
a = n
r = 0
lblb
m = a
m % b
r * b
r + m
a / b
if a b
r - n
r |
if r d
lblc
c + 1
i - 1
b - 1
lblf
if i a
c / c
c - 1
c |
printInt c
</code>```

Try it online!

Port of my answer in C.

Title: Non-palindromic numbers

Body:
A strictly non-palindromic number N is a number that isn't a palindrome in any base (in bases 2 to N-2).  These numbers are listed on OEIS

For example, the number 19 in base 2,3,4,5,6,...17 is: 10011,201,103,34,31,...12.  None of these representations is palindromic, so the number is strictly non-palindromic.

For this challenge, you need to return a truthy value if the number is non-palindromic, otherwise a falsy value.

You may assume the number passed to you is greater than or equal to 0.

Your program should work for values up to your languages' integer size.

Test cases:

Truthy:

```<code>0
1
2
3
4
6
11
19
47
53
79
103
389
997
1459
</code>```

Falsy:

```<code>5
7
8
9
10
13
16
43
48
61
62
101
113
211
1361
</code>```

This is a code-golf, so make your answers as short as possible!

Body:
S.I.L.O.S, 206 bytes

GOTO e
lbld
c - 1
GOTO c
lble
readIO
n = i
i - 3
b = i
b + 1
GOTO f
lbla
a = n
r = 0
lblb
m = a
m % b
r * b
r + m
a / b
if a b
r - n
r |
if r d
lblc
c + 1
i - 1
b - 1
lblf
if i a
c / c
c - 1
c |
printInt c

Try it online!

Port of my answer in C.


问:
Creating a Crossed Square

Creating a Crossed Square

You are to take input of an integer of one or more and output a square made of any printable character of your choice with a diagonal cross through the centre.

The general idea is for the output to be a hollow square that has a diagonal cross through it.:

```<code>Input: 7
Output:
*******
*#   #*
* # # *
*  #  *
* # # *
*#   #*
*******
</code>```

In the above example the '*'s represent the outer box and the '#'s represent the diagonal cross.

Note that the above example uses two different characters so that it is easier to see what the output looks like, your program should use one character only.

Input

An integer of 1 or more, it is guaranteed to be odd.

Output

A square that is made up of a character of your choice with a cross through the middle.

The cross must be diagonal

The square may be output via the function or written to output

Trailing newlines are okay

Can output as a graphic, diagram or image if you wish too

Examples

```<code>Input: 1
Output:
*

Input: 3
Output:
***
***
***

Input: 5
Output:
*****
** **
* * *
** **
*****

Input: 7
Output:
*******
**   **
* * * *
*  *  *
* * * *
**   **
*******
</code>```

Specs

Functions or full programs are allowed

You can get input by your preferred means

Standard loopholes are disallowed

Programs must work without any additional statements i.e. usings in C#, they must be included in the entry

You can output from a function or print the result

This is code golf so the shortest solution wins.

答:
S.I.L.O.S, 212 bytes

```<code>readIO
a = i
lbla
a - 1
t = a
t + 1
t % i
t * a
b = i
lblb
b - 1
u = b
u + 1
u % i
u * b
u * t
v = a
v - b
u * v
v = a
v + b
v + 1
v % i
u * v
u |
if u c
print #
GOTO d
lblc
print .
lbld
if b b
printLine
if a a
</code>```

Try it online!

Title: Creating a Crossed Square

Body:
S.I.L.O.S, 212 bytes

readIO
a = i
lbla
a - 1
t = a
t + 1
t % i
t * a
b = i
lblb
b - 1
u = b
u + 1
u % i
u * b
u * t
v = a
v - b
u * v
v = a
v + b
v + 1
v % i
u * v
u |
if u c
print #
GOTO d
lblc
print .
lbld
if b b
printLine
if a a

Try it online!


问:
Russian Roulette
Write a program which plays Russian Roulette!

If the program is started,

there should be a 5 in 6 chance of it ending normally after printing "I survived!"

there should be a 1 in 6 chance of the program crashing. (segmentation fault, etc.)

No input, and no other outputs are allowed.

The randomness must be fair: it must have a uniform probability distribution. This means an uninitialized variable (or a RNG without seed) MOD 6 will not be sufficient.

If the solution works with only one dedicated operating system / platform, you will receive a 6 byte penalty to the score.

Shortest code wins, not sooner than 10 days after first valid answer.

答:
PHP - 30 bytes

```<code><?rand(0,5)?:~[]?>I survived!
</code>```

Requires PHP 5.4+ for the short array syntax, invalid operator idea shamelessly stolen from @primo.

As stated, rand() is automatically seeded on first use.

Title: Russian Roulette

Body:
PHP - 30 bytes

<?rand(0,5)?:~[]?>I survived!

Requires PHP 5.4+ for the short array syntax, invalid operator idea shamelessly stolen from @primo.

As stated, rand() is automatically seeded on first use.