问:
Draw the national flag of Iceland
This year's UEFA Euro 2016 is over and besides a couple of negative headlines there has been a very positive surprise as well – the Iceland national football team. Let's draw their national flag.

Input

Well, obviously this challenge has no input.

Output

Draw the flag of Iceland in any applicable visual format of at least 100 x 72 pixels or 25 x 18 characters.

Save the output to a file or present it instantly – example formats are: images like png, jpg etc., vector graphics, draw on HTML canvas or even use non-whitespace characters for visualization.

Use these colors: blue: #0048e0, white: #ffffff and red: #d72828.

If your language doesn't support specific color values, use the standard values for red, blue and white from the ANSI color codes.

Draw the flag with the correct proportions, as shown in the figure below:

Boilerplate

You can write a program or a function. If it is an anonymous function, please include an example of how to invoke it.

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

Standard loopholes are disallowed.

Leaderboard

var QUESTION_ID = 85141; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 41859; // This should be the user ID of the challenge author.
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,]*[^\s,]),.*?(-?\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;var OVERRIDE_REG = /^Override\s*header:\s*/i;function getAuthorName(a) {return a.owner.display_name;}function process() {var valid = [];answers.forEach(function(a) {var body = a.body;a.comments.forEach(function(c) {if(OVERRIDE_REG.test(c.body))body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';});var match = body.match(SCORE_REG);if (match)valid.push({user: getAuthorName(a),size: +match[2],language: match[1],link: a.share_link,});});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;if (! /<a/.test(lang)) lang = '' + lang + '';lang = jQuery(lang).text().toLowerCase();languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link, uniq: lang};});var langs = [];for (var lang in languages)if (languages.hasOwnProperty(lang))langs.push(languages[lang]);langs.sort(function (a, b) {if (a.uniq > b.uniq) return 1;if (a.uniq < b.uniq) return -1;return 0;});for (var i = 0; i < langs.length; ++i){var language = jQuery("#language-template").html();var lang = langs[i];language = language.replace("{{LANGUAGE}}", lang.lang).replace("{{NAME}}", lang.user).replace("{{SIZE}}", lang.size).replace("{{LINK}}", lang.link);language = jQuery(language);jQuery("#languages").append(language);}}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body { text-align: left !important}#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;}</code>```

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

If you can't find your answer, format your language and byte count as explained in the Leaderboard's "Info Section".

This challenge is inspired by Draw the national flag of france.

答:
Maple 231 bytes

```<code>macro(t=thickness,w=white,c=color):
plots:-display(
plot([],background=blue),
plot(9,0..25.2,t=48,c=w),
plot([9,y,y=0..18.2],t=48,c=w),
plot(9,0..25.2,t=24,c=red),
plot([9,y,y=0..18.2],t=24,c=red),
scaling=constrained,view=[0..25,0..18]);
</code>```

Added newlines for readability. This code uses a couple of aliases for repeated terms.
Maple" />

Another method, which is slightly cleaner and produces a slightly more crisp image but longer (285 without aliases) is:

```<code>plots:-display(
plottools:-rectangle([0,8],[25,10],color=red),
plottools:-rectangle([8,0],[10,18],color=red),
plottools:-rectangle([0,7],[25,11],color=white),
plottools:-rectangle([7,0],[11,18],color=white),
plottools:-rectangle([0,0],[25,18],color=blue),
style=polygon,scaling=constrained);
</code>```

Title: Draw the national flag of Iceland

Body:
Maple 231 bytes

macro(t=thickness,w=white,c=color):
plots:-display(
plot([],background=blue),
plot(9,0..25.2,t=48,c=w),
plot([9,y,y=0..18.2],t=48,c=w),
plot(9,0..25.2,t=24,c=red),
plot([9,y,y=0..18.2],t=24,c=red),
scaling=constrained,view=[0..25,0..18]);

Added newlines for readability. This code uses a couple of aliases for repeated terms.

Another method, which is slightly cleaner and produces a slightly more crisp image but longer (285 without aliases) is:

plots:-display(
plottools:-rectangle([0,8],[25,10],color=red),
plottools:-rectangle([8,0],[10,18],color=red),
plottools:-rectangle([0,7],[25,11],color=white),
plottools:-rectangle([7,0],[11,18],color=white),
plottools:-rectangle([0,0],[25,18],color=blue),
style=polygon,scaling=constrained);


问:
Create output twice the length of the code

The Challenge

Write a complete program that writes twice as many bytes to standard output as the length of the program.

Rules

The program must write ASCII characters to the standard output.

The contents of the output doesn't matter.

The output, measured in bytes, must be exactly twice the length of the program, also measured in bytes, unless you fulfill the bonus.

Any trailing newline is included in the output's byte count.

Bonus

Your program can optionally take a number, n, as input. If so, the output must be exactly n * program length bytes. You can assume that n will always be a positive integer. If no input is provided, n must default to 2.

If you do this,  you can subtract 25 bytes from your score.

Shortest program wins.

Restrictions

No standard loopholes.

The program must be at least 1 byte long.

No adding unnecessary whitespace to the source code to change its length. Similarly, comments don't count.

Unless you fulfill the bonus, the program must accept no input. If you do fulfill the bonus, the integer must be the only input.

Lowest score (program length in bytes - bonus) wins.

The shortest answer for each language wins for that language.

Leaderboards

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

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

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

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

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

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

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

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

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

var QUESTION_ID=59436,OVERRIDE_USER=41505;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

```

答:
V, 2 Bytes

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

This outputs

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

Try it online!

Explanation

This is a really hacky answer, and it works by abusing the internals of V. Essentially how it works is that ÿ is a command in V that signals the program is over, and any pending commands must complete. Otherwise, some implicit endings would not work, and the interpret would hang more often. This command is automatically sent several times at the end of the program, and most of the time has no effect on the output.

é is a command that inserts a single character. However, it does it by grabbing a raw byte, so it doesn't interpret ÿ as "end", it interprets it as "this is the character you need to insert." 4é makes it insert this character 4 times instead of one.

ContentLicense: CC BY-SA 3.0

Body:
V, 2 Bytes

4é

This outputs

ÿÿÿÿ

Try it online!

Explanation

This is a really hacky answer, and it works by abusing the internals of V. Essentially how it works is that ÿ is a command in V that signals the program is over, and any pending commands must complete. Otherwise, some implicit endings would not work, and the interpret would hang more often. This command is automatically sent several times at the end of the program, and most of the time has no effect on the output.

é is a command that inserts a single character. However, it does it by grabbing a raw byte, so it doesn't interpret ÿ as "end", it interprets it as "this is the character you need to insert." 4é makes it insert this character 4 times instead of one.


问:
Hello World in 1024 characters
In exactly 1024 characters, no more, no less:

Must print Hello World.

Must not use unnecessary whitespace.

Must not use comments.

Judging should favor creativity and/or humor over simple obfuscation when voting up answers.

The earliest I will select an answer is the 11th (Sunday) of November (2012). I'm seeing some awesome entries so far, can't wait to see what else people come up with.

Title: Hello World in 1024 characters

Body:
GolfScript

I had to modify the max length of scripts on http://golfscript.apphb.com/ for this :)

1)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))1)))))))))))))))))))))))))))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))))))))))))))))1))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)))))))))))))))))))))))))1))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)))))1))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))' '1))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))1)))))))))))))))))))))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))1))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))))))))))))))))))1))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))1))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))))))){)}8*]''+

Run the program online <a href="http://golfscript.apphb.com/?c=MSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpMSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkxKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkxKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkxKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSknICcxKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkxKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkxKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkxKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkxKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKXspfTgqXScnKw==&run=true">here.


问:
Unsorted majorization of two lists

Definition

A vector a containing n elements is said to
majorize or
dominate a vector b with n
elements iff for all values k such that 1 ≤ k ≤ n, the sum of the first
element of a↓ through the kth element of a↓ is
greater than or equal to the sum of the first through kth elements of
b↓, where v↓ represents the vector v sorted in
descending order.

That is,

```<code>                          a_1 >= b_1
                    a_1 + a_2 >= b_1 + b_2
              a_1 + a_2 + a_3 >= b_1 + b_2 + b_3
                              ...
      a_1 + a_2 + ... + a_n-1 >= b_1 + b_2 + ... + b_n-1
a_1 + a_2 + ... + a_n-1 + a_n >= b_1 + b_2 + ... + b_n-1 + b_n
</code>```

where a and b are sorted in descending order.

For the purpose of this challenge, we will be using a slight generalization of
majorization: we will say a list is an unsorted majorization of another if
all of the above inequalities are true without sorting a and b. (This is,
of course, mathematically useless, but makes the challenge more interesting.)

Challenge

Given an input of two distinct lists a and b of integers in the range 0
through 255 (inclusive), both lists of length n ≥ 1, output whether the first
list unsorted-majorizes the second (a > b), the second unsorted-majorizes
the first (b > a), or neither.

You may optionally require the length of the two lists to be provided as input.
The output must always be one of three distinct values, but the values
themselves may be whatever you want (please specify which values represent a
> b, b > a, and neither in your answer).

Test cases for a > b:

```<code>[255] [254]
[3,2,1] [3,1,2]
[6,1,5,2,7] [2,5,4,3,7]
</code>```

Test cases for b > a:

```<code>[9,1] [10,0]
[6,5,4] [7,6,5]
[0,1,1,2,1,2] [0,1,2,1,2,1]
</code>```

Test cases for no majorization:

```<code>[200,100] [150,250]
[3,1,4] [2,3,3]
[9,9,9,9,9,0] [8,8,8,8,8,9]
</code>```

答:
Cheddar, <s>118</s> 114 bytes

```<code>n->[n.map(i->i[0]-i[1]).map((j,k,l)->l.slice(0,k+1).sum).map(i->i>0?1:i<0?-1:0)].map(j->j has 1?j has-1?0:1:-1)[0]
</code>```

Basically a port of my Jelly answer.

The fact that scope inside function is broken causing inability to define variable inside function means that I would need to do [xxx].map(i->yyy)[0] instead of var a=xxx;yyy.

Takes transposed array as input.

```<code>n->[n
.map(i->i[0]-i[1])                     Difference (vectorized)
.map((j,k,l)->l.slice(0,k+1).sum)      Cumulative sum.
.map(i->i>0?1:i<0?-1:0)]               Sign of every difference
.map(j->j has 1?j has-1?0:1:-1)[0]     Deduplicate and Sum
</code>```

Title: Unsorted majorization of two lists

Body:
Cheddar, <s>118</s> 114 bytes

n->[n.map(i->i[0]-i[1]).map((j,k,l)->l.slice(0,k+1).sum).map(i->i>0?1:i<0?-1:0)].map(j->j has 1?j has-1?0:1:-1)[0]

Basically a port of my Jelly answer.

The fact that scope inside function is broken causing inability to define variable inside function means that I would need to do [xxx].map(i->yyy)[0] instead of var a=xxx;yyy.

Takes transposed array as input.

n->[n
.map(i->i[0]-i[1])                     Difference (vectorized)
.map((j,k,l)->l.slice(0,k+1).sum)      Cumulative sum.
.map(i->i>0?1:i<0?-1:0)]               Sign of every difference
.map(j->j has 1?j has-1?0:1:-1)[0]     Deduplicate and Sum


答:
Brain-Flak, 128 bytes

Try it online!(You probably wont be able to finish it before the universe ends)

```<code>(((((((((((((()()()){}){}){}){}()){}){({}[()])}{}){({}[()])}{}){({}[()])}{}){({}[()])}{}){({}[()])}{}){({}[()])}{}){({}[()])}{})
</code>```

How it works

It starts simply by pushing ninety-eight to the stack:

```<code>((((((()()()){}){}){}){}()){})
</code>```

It then implements my Triangulation algorithm:

```<code>(*push n*{({}[()])}{})
</code>```

seven times.

This results in

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

The program then terminates and spits the contents of the stack to the terminal. Since insert atrociously huge number here is 256 characters long in base 10, the output is exactly twice the source code's length.

As one might tell I used a computer aided search to find this solution.  This is almost certainly the shortest solution using the triangulation method I outlined.

Title: Create output twice the length of the code

Body:
The Challenge

Write a complete program that writes twice as many bytes to standard output as the length of the program.

Rules

The program must write ASCII characters to the standard output.

The contents of the output doesn't matter.

The output, measured in bytes, must be exactly twice the length of the program, also measured in bytes, unless you fulfill the bonus.

Any trailing newline is included in the output's byte count.

Bonus

Your program can optionally take a number, n, as input. If so, the output must be exactly n * program length bytes. You can assume that n will always be a positive integer. If no input is provided, n must default to 2.

If you do this,  you can subtract 25 bytes from your score.

Shortest program wins.

Restrictions

No standard loopholes.

The program must be at least 1 byte long.

No adding unnecessary whitespace to the source code to change its length. Similarly, comments don't count.

Unless you fulfill the bonus, the program must accept no input. If you do fulfill the bonus, the integer must be the only input.

Lowest score (program length in bytes - bonus) wins.

The shortest answer for each language wins for that language.

Leaderboards

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

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

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

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

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

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

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

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

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

var QUESTION_ID=59436,OVERRIDE_USER=41505;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:
Brain-Flak, 128 bytes

Try it online!(You probably wont be able to finish it before the universe ends)

(((((((((((((()()()){}){}){}){}()){}){({}[()])}{}){({}[()])}{}){({}[()])}{}){({}[()])}{}){({}[()])}{}){({}[()])}{}){({}[()])}{})

How it works

It starts simply by pushing ninety-eight to the stack:

((((((()()()){}){}){}){}()){})

It then implements my Triangulation algorithm:

(*push n*{({}[()])}{})

seven times.

This results in

1447283887869053957595051227533274962011504066726596247765427442496031260270109555118382532157345193860142997726793245725173763195275989332247013823819162395404940274645651775376645319691872778284304403703355308050412897911161964450479105938633399903762942

The program then terminates and spits the contents of the stack to the terminal. Since insert atrociously huge number here is 256 characters long in base 10, the output is exactly twice the source code's length.

As one might tell I used a computer aided search to find this solution.  This is almost certainly the shortest solution using the triangulation method I outlined.


问:
Turtles All the Way Down
Write a program or function that takes in a positive integer and prints or returns a stack of that many ASCII-art turtles, where each turtle is larger than the one above it.

Specifically, if the input is 1, the output should be:

```<code> __
/,,\o
</code>```

If the input is 2:

```<code>  __
o/,,\
 ____
/,__,\o
</code>```

If the input is 3:

```<code>   __
  /,,\o
  ____
o/,__,\
 ______
/,____,\o
</code>```

If the input is 4:

```<code>    __
  o/,,\
   ____
  /,__,\o
  ______
o/,____,\
 ________
/,______,\o
</code>```

If the input is 5:

```<code>     __
    /,,\o
    ____
  o/,__,\
   ______
  /,____,\o
  ________
o/,______,\
 __________
/,________,\o
</code>```

And so on in the same pattern for larger inputs.

Note that:

The head (the o) of the bottom turtle is always on the right. The heads of the turtles above then alternate back and forth.

No lines may have trailing spaces.

Superfluous leading spaces are not allowed. (i.e. the back of the bottom turtle should be at the start of the line.)

A single optional trailing newline is allowed.

The shortest code in bytes wins.

Title: Turtles All the Way Down

Body:
Python 2, 147 bytes

n=input()
s=' ';r=[];i=k=0
while i<n:a=i%2;r=[s*k+s*a+s+'_'*(n-i)*2+s,s*k+'o'*a+'/,'+'_'*(n-i-1)*2+',\\'+'o'*(1-a)]+r;k+=a*2;i+=1
print'\n'.join(r)

Try it online


答:
C, <s>328</s> <s>238</s> <s>234</s> 215 bytes:

```<code>B;M(w,j,R){j=w;if(j<=B){char b[j*2-1],k[j*2+1];b[j*2-2]=k[j*2]=0;memset(b,95,j*2-2);memset(k,95,j*2);R=(B+1-j)%2;printf("%*s\n%*s/,%s,\\%s\n",j*2+B+1-j,k,B-j,R?"":"o",b,R?"o":"");j++;M(j);}}main(){scanf("%d",&B);M(1);}
</code>```

A recursive implementation using a lot of string formatting and the builtin memset function. Will try and golf this more over time as much as I can.

C It Online! (Ideone)

Title: Turtles All the Way Down

Body:
Write a program or function that takes in a positive integer and prints or returns a stack of that many ASCII-art turtles, where each turtle is larger than the one above it.

Specifically, if the input is 1, the output should be:

```<code> __
/,,\o
</code>```

If the input is 2:

```<code>  __
o/,,\
 ____
/,__,\o
</code>```

If the input is 3:

```<code>   __
  /,,\o
  ____
o/,__,\
 ______
/,____,\o
</code>```

If the input is 4:

```<code>    __
  o/,,\
   ____
  /,__,\o
  ______
o/,____,\
 ________
/,______,\o
</code>```

If the input is 5:

```<code>     __
    /,,\o
    ____
  o/,__,\
   ______
  /,____,\o
  ________
o/,______,\
 __________
/,________,\o
</code>```

And so on in the same pattern for larger inputs.

Note that:

The head (the o) of the bottom turtle is always on the right. The heads of the turtles above then alternate back and forth.

No lines may have trailing spaces.

Superfluous leading spaces are not allowed. (i.e. the back of the bottom turtle should be at the start of the line.)

A single optional trailing newline is allowed.

The shortest code in bytes wins.

Body:
C, <s>328</s> <s>238</s> <s>234</s> 215 bytes:

B;M(w,j,R){j=w;if(j<=B){char b[j*2-1],k[j*2+1];b[j*2-2]=k[j*2]=0;memset(b,95,j*2-2);memset(k,95,j*2);R=(B+1-j)%2;printf("%*s\n%*s/,%s,\\%s\n",j*2+B+1-j,k,B-j,R?"":"o",b,R?"o":"");j++;M(j);}}main(){scanf("%d",&B);M(1);}

A recursive implementation using a lot of string formatting and the builtin memset function. Will try and golf this more over time as much as I can.

C It Online! (Ideone)


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

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

Specs

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

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

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

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

Scoring

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

答:
PHP, 80 <s>83</s> bytes

Making half of the triangle then print it in reverse did the trick.

```<code>for($a="A";$a<"Z";$b.=$a++)$c.=$b.$a.strrev($b)."
";echo"$c{$b}Z".strrev($c.$b);
</code>```

Title: Alphabet triangle

Body:
PHP, 80 <s>83</s> bytes

Making half of the triangle then print it in reverse did the trick.

for($a="A";$a<"Z";$b.=$a++)$c.=$b.$a.strrev($b)."
";echo"$c{$b}Z".strrev($c.$b);


Title: Turtles All the Way Down

Body:
Retina, <s>97</s> <s>91</s> 88 bytes

Byte count assumes ISO 8859-1 encoding.

.+
  $&$*_$&$*_o
+`^( *?)(.)__(_+)(.)
$1 $4$3$2¶$&
 (.)__(_*) ?
  __$2¶$%`$1/,$2,\
Rm`^

Try it online!


答:
C, 131 bytes

```<code>i,j;f(n){char _[3*n];memset(_,95,3*n);for(i=n;i--;printf("%*.*s\n%*s/,%.*s,\\%s\n",j+n+1,j+j,_,i,"o"+1-i%2,j+j-2,_,"o"+i%2))j=n-i;}
</code>```

Try it online.

Defines a function that prints the turtles.

Heavily abuses printf's width and precision specifiers to get the spacing and repeating the underscores. Each turtle is printed using a single printf call:

```<code>printf("%*.*s\n%*s/,%.*s,\\%s\n",j+n+1,j+j,_,i,"o"+1-i%2,j+j-2,_,"o"+i%2)
</code>```

I also have a different version that's 144 bytes with whitespace removed:

```<code>c,i;f(n){for(i=n;i--;){
    char*p=" _\n o/,_,\\o\n";
    int C[]={i+1,c=n+n-i-i,1,i&~1,i%2,1,1,c-2,1,1,1-i%2,1};
    for(c=0;p[c];)C[c]--?putchar(p[c]):++c;
}}
</code>```

Title: Turtles All the Way Down

Body:
C, 131 bytes

i,j;f(n){char _[3*n];memset(_,95,3*n);for(i=n;i--;printf("%*.*s\n%*s/,%.*s,\\%s\n",j+n+1,j+j,_,i,"o"+1-i%2,j+j-2,_,"o"+i%2))j=n-i;}

Try it online.

Defines a function that prints the turtles.

Heavily abuses printf's width and precision specifiers to get the spacing and repeating the underscores. Each turtle is printed using a single printf call:

printf("%*.*s\n%*s/,%.*s,\\%s\n",j+n+1,j+j,_,i,"o"+1-i%2,j+j-2,_,"o"+i%2)

I also have a different version that's 144 bytes with whitespace removed:

c,i;f(n){for(i=n;i--;){
    char*p=" _\n o/,_,\\o\n";
    int C[]={i+1,c=n+n-i-i,1,i&~1,i%2,1,1,c-2,1,1,1-i%2,1};
    for(c=0;p[c];)C[c]--?putchar(p[c]):++c;
}}


Title: Hello World in 1024 characters

Body:
In exactly 1024 characters, no more, no less:

Must print Hello World.

Must not use unnecessary whitespace.

Must not use comments.

Judging should favor creativity and/or humor over simple obfuscation when voting up answers.

The earliest I will select an answer is the 11th (Sunday) of November (2012). I'm seeing some awesome entries so far, can't wait to see what else people come up with.

Body:
Shell :)

echo '
.@@@@......@@@@.@@@@@@@@@@@.@@.........@@...........@@@@@@@@..
..@@@......@@@..@@.......@@..@..........@..........@........@@.
..@@@......@@@..@............@..........@.........@..........@@
..@@@@@@@@@@@@..@@@@@@.......@..........@.........@..........@@
..@@@@@@@@@@@@..@@@@@@.......@..........@.........@..........@@
..@@@......@@@..@............@..........@.........@..........@@
..@@@......@@@..@@.......@@..@@@@@@@@@@.@@@@@@@@@..@.......@@@.
.@@@@......@@@@.@@@@@@@@@@@..@@@@@@@@@@.@@@@@@@@@...@@@@@@@@..
@@............@@@..@@@@@.....@@@@@@@.....@@........@@@@@@@@@@.
.@@..........@@...@.....@.....@.....@@...@@.........@@.......@.
..@@........@@...@.......@....@.....@@...@@.........@@........@
...@@..@@..@@...@.........@...@@@@@@.....@@.........@@........@
....@@@.@@.@....@........@@...@@@@.@@....@@.........@@........@
....@@...@@@....@.......@@....@.....@@...@@.........@@.......@
...@@......@@....@.....@@.....@......@@..@@@....@@..@@@@...@@.
..@@.......@@@....@@@@@@....@@.......@..@@@@@@@@...@@@@@@@@@'


问:
Smallest sum (and largest difference) of two 3-digit integers
Given six unique non-negative integers, print the two 3-digit integers comprised of those numbers that sum to the smallest amount.

Additionally,

If there is more than one set of numbers that meets the smallest-sum requirement, print the two that have the greatest difference. For example, 269 + 157 = 267 + 159 = 426; however, 269 - 157 > 267 - 159, so the first set should be printed.

Print the numbers on the same line largest -> smallest, separated by a single space.

Zero (0) cannot be used as a leading number.

Inputs will always be digits.

Testcases

```<code>input        | output
2 6 5 1 9 7  | 269 157
1 9 5 0 8 3  | 359 108
1 2 3 4 5 6  | 246 135
</code>```

Scoring

As this is code golf, shortest entry wins.

Body:
Batch, 232 bytes

@if %1 gtr %2 %0 %2 %1 %3 %4 %5 %6
@if %2 gtr %3 %0 %1 %3 %2 %4 %5 %6
@if %3 gtr %4 %0 %1 %2 %4 %3 %5 %6
@if %4 gtr %5 %0 %1 %2 %3 %5 %4 %6
@if %5 gtr %6 %0 %1 %2 %3 %4 %6 %5
@if %1==0 (echo %3%4%6 %20%5)else echo %2%4%6 %1%3%5

Mostly bubble sort.


答:
Python 2, 59 bytes

t=r=0
for x,y in zip(*input()):t+=x-y;r|=cmp(t,0)%3
print r
```

Outputs:

1 for a>b

2 for b>a

3 for neither

Iterates through the list, tracking the running sum t of differences. The number s tracks what signs have been seen as a two-bit number r: positives in the right bit and negatives in the left bit. This happens via cmp(t,0)%3, which gives

t>0  → +1 → 1

t==0 → 0  → 0

t<0  → -1 → 2

Taking the or of this and the current value of r updates the 2 bits with or, with zero values having no effect.

Title: Unsorted majorization of two lists

Body:
Definition

A vector a containing n elements is said to
majorize or
dominate a vector b with n
elements iff for all values k such that 1 ≤ k ≤ n, the sum of the first
element of a↓ through the kth element of a↓ is
greater than or equal to the sum of the first through kth elements of
b↓, where v↓ represents the vector v sorted in
descending order.

That is,

```<code>                          a_1 >= b_1
                    a_1 + a_2 >= b_1 + b_2
              a_1 + a_2 + a_3 >= b_1 + b_2 + b_3
                              ...
      a_1 + a_2 + ... + a_n-1 >= b_1 + b_2 + ... + b_n-1
a_1 + a_2 + ... + a_n-1 + a_n >= b_1 + b_2 + ... + b_n-1 + b_n
</code>```

where a and b are sorted in descending order.

For the purpose of this challenge, we will be using a slight generalization of
majorization: we will say a list is an unsorted majorization of another if
all of the above inequalities are true without sorting a and b. (This is,
of course, mathematically useless, but makes the challenge more interesting.)

Challenge

Given an input of two distinct lists a and b of integers in the range 0
through 255 (inclusive), both lists of length n ≥ 1, output whether the first
list unsorted-majorizes the second (a > b), the second unsorted-majorizes
the first (b > a), or neither.

You may optionally require the length of the two lists to be provided as input.
The output must always be one of three distinct values, but the values
themselves may be whatever you want (please specify which values represent a
> b, b > a, and neither in your answer).

Test cases for a > b:

```<code>[255] [254]
[3,2,1] [3,1,2]
[6,1,5,2,7] [2,5,4,3,7]
</code>```

Test cases for b > a:

```<code>[9,1] [10,0]
[6,5,4] [7,6,5]
[0,1,1,2,1,2] [0,1,2,1,2,1]
</code>```

Test cases for no majorization:

```<code>[200,100] [150,250]
[3,1,4] [2,3,3]
[9,9,9,9,9,0] [8,8,8,8,8,9]
</code>```

Body:
Python 2, 59 bytes

t=r=0
for x,y in zip(*input()):t+=x-y;r|=cmp(t,0)%3
print r

Outputs:

1 for a>b

2 for b>a

3 for neither

Iterates through the list, tracking the running sum t of differences. The number s tracks what signs have been seen as a two-bit number r: positives in the right bit and negatives in the left bit. This happens via cmp(t,0)%3, which gives

t>0  → +1 → 1

t==0 → 0  → 0

t<0  → -1 → 2

Taking the or of this and the current value of r updates the 2 bits with or, with zero values having no effect.


问:
Create and write to a file

Challenge

Create a new file and write the string Hello World to it.

Restrictions

Your challenge must write to a file on disk, in the file system.

The file may not be a log file generated during normal operation of the interpreter.

The file must contain only the string Hello World. It is allowed to contain a trailing newline or minimal whitespace. No other content.

No command-line flags/pipes (etc) allowed, except when necessary to run the program. (e.g. perl -p)

Notes

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

Follow the spirit, not the letter, of the rules.

答:
Awk, <s>29</s> 27 characters

BEGIN{print"Hello World">1}
```
<p>(No, not another output redirection. Just Awk's syntax is similar.)</p>
<p>Thanks to:</p>
<ul>
<li>Pedro Maimere for suggesting to use integer for file name (-2 characters)</li>
</ul>
<p>Sample run:</p>
```bash-4.3$ awk 'BEGIN{print"Hello World">1}'

bash-4.3$ cat 1
Hello World
```

ContentLicense: CC BY-SA 4.0

Title: Create and write to a file

Body:
Awk, <s>29</s> 27 characters

BEGIN{print"Hello World">1}

(No, not another output redirection. Just Awk's syntax is similar.)

Thanks to:

Pedro Maimere for suggesting to use integer for file name (-2 characters)

Sample run:

bash-4.3$ awk 'BEGIN{print"Hello World">1}'

bash-4.3$ cat 1
Hello World


答:
Groovy, 28 characters

new File("o")<<"Hello World"
```

<p>Sample run:</p>

```bash-4.3$ groovy -e 'new File("o")<<"Hello World"'

bash-4.3$ cat o
Hello World
```

Title: Create and write to a file

Body:
Challenge

Create a new file and write the string Hello World to it.

Restrictions

Your challenge must write to a file on disk, in the file system.

The file may not be a log file generated during normal operation of the interpreter.

The file must contain only the string Hello World. It is allowed to contain a trailing newline or minimal whitespace. No other content.

No command-line flags/pipes (etc) allowed, except when necessary to run the program. (e.g. perl -p)

Notes

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

Follow the spirit, not the letter, of the rules.

Body:
Groovy, 28 characters

new File("o")<<"Hello World"

Sample run:

bash-4.3$ groovy -e 'new File("o")<<"Hello World"'

bash-4.3$ cat o
Hello World


问:
Hofstadter Q-sequence

Definition

a(1) = 1

a(2) = 1

a(n) = a(n-a(n-1)) + a(n-a(n-2)) for n > 2 where n is an integer

Task

Given positive integer n, generate a(n).

Testcases

```<code>n  a(n)
1  1
2  1
3  2
4  3
5  3
6  4
7  5
8  5
9  6
10 6
11 6
12 8
13 8
14 8
15 10
16 9
17 10
18 11
19 11
20 12
</code>```

Reference

Obligatory OEIS A005185

答:
><>, 65+2 = 67 bytes

```<code>^n;
.+]{0$
v1}\
v2} @2->1[
v3}>-  /:::1-1[
>4}:2)?^~~1]{0$.
/0$1[
</code>```

Input neds to be present on the stack at program start, so +2 bytes for the -v flag. Try it online!

More ridiculously slow recursive madness. Test case for 20 on TIO takes 20.5 seconds, so use larger inputs at your own risk

Title: Hofstadter Q-sequence

Body:
><>, 65+2 = 67 bytes

^n;
.+]{0$
v1}\
v2} @2->1[
v3}>-  /:::1-1[
>4}:2)?^~~1]{0$.
/0$1[

Input neds to be present on the stack at program start, so +2 bytes for the -v flag. Try it online!

More ridiculously slow recursive madness. Test case for 20 on TIO takes 20.5 seconds, so use larger inputs at your own risk


答:
Sed, 20 characters

(19 characters code + 1 character dummy input.)

```<code>s/^/Hello World/
wo
</code>```

Seems the side effect of also displaying the string to STDOUT after the file was created is not prohibited.

Requires dummy input to work as per Are languages like sed exempt from “no input” rules?

Sample run:

```<code>bash-4.3$ sed $'s/^/Hello World/;wo' <<< ''
Hello World

bash-4.3$ cat o
Hello World
</code>```

Title: Create and write to a file

Body:
Sed, 20 characters

(19 characters code + 1 character dummy input.)

s/^/Hello World/
wo

Seems the side effect of also displaying the string to STDOUT after the file was created is not prohibited.

Requires dummy input to work as per Are languages like sed exempt from “no input” rules?

Sample run:

bash-4.3$ sed $'s/^/Hello World/;wo' <<< ''
Hello World

bash-4.3$ cat o
Hello World


答:
Java 131 bytes

Without using String (131 bytes)

```<code>public static void main(String[] args) {
    for(int i = 0 ,k=1; i>-1; i+=k){
        for(int c= 65, d = 1; c>64;){
            d = d>-1 & c < 65+i?1:-1;
            System.out.print((char)c+((c+=d)<65?"\n":""));
        }
        k = k>-1 & i < 25?1:-1;
    }
}
</code>```

Codegolfed

```<code>for(int i=0,k=1;i>-1;k=k>-1&i<25?1:-1,i+=k)for(int c=65,d=1;c>64;d=d>-1&c<65+i?1:-1,System.out.print((char)c+((c+=d)<65?"\n":"")));
</code>```

With String(173 bytes)

```<code>String a="abcdefghijklmnopqrstuvwxyz";
for(int i = 1 ,k=1; i>0; i+=k==1?1:-1){
    System.out.println(a.substring(0,i)+new StringBuilder(a).reverse().substring(27-i));
    k = k>-1 & i < 26?1:-1;
}
</code>```

Codegolfed

```<code>String a="abcdefghijklmnopqrstuvwxyz";for(int i=1,k=1;i>0;k=k>-1&i<26?1:-1,System.out.println(a.substring(0,i)+new StringBuilder(a).reverse().substring(27-i)),i+=k==1?1:-1);
</code>```

Thanks to manatwork and Kevin Cruijssen

Title: Alphabet triangle

Body:
You are to print this exact text:

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

Specs

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

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

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

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

Scoring

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

Body:
Java 131 bytes

Without using String (131 bytes)

public static void main(String[] args) {
    for(int i = 0 ,k=1; i>-1; i+=k){
        for(int c= 65, d = 1; c>64;){
            d = d>-1 & c < 65+i?1:-1;
            System.out.print((char)c+((c+=d)<65?"\n":""));
        }
        k = k>-1 & i < 25?1:-1;
    }
}

Codegolfed

for(int i=0,k=1;i>-1;k=k>-1&i<25?1:-1,i+=k)for(int c=65,d=1;c>64;d=d>-1&c<65+i?1:-1,System.out.print((char)c+((c+=d)<65?"\n":"")));

With String(173 bytes)

String a="abcdefghijklmnopqrstuvwxyz";
for(int i = 1 ,k=1; i>0; i+=k==1?1:-1){
    System.out.println(a.substring(0,i)+new StringBuilder(a).reverse().substring(27-i));
    k = k>-1 & i < 26?1:-1;
}

Codegolfed

String a="abcdefghijklmnopqrstuvwxyz";for(int i=1,k=1;i>0;k=k>-1&i<26?1:-1,System.out.println(a.substring(0,i)+new StringBuilder(a).reverse().substring(27-i)),i+=k==1?1:-1);

Thanks to manatwork and Kevin Cruijssen


Title: Alphabet triangle

Body:
brainfuck, <s>1733</s> <s>121</s> 119 bytes

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

Slightly more readable version:

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

Explanation possibly to come.


答:
F#, <s>218</s> <s>207</s> <s>202</s> <s>196</s> 187 bytes.

Shaved most of these bytes by inlining variables

```<code>let R=String.replicate
let t n=let rec L i r k=if i<n then L(i+1)(R(k+i%2+1)" "+R((n-i)*2)"_"+"\n"+R k" "+R(i%2)"o"+"/,"+R(n*2-i*2-2)"_"+",\\"+R(1-i%2)"o"+"\n"+r)(k+i%2*2)else r in L 0""0
</code>```

The logic is shamelessly stolen from this Python answer

Try it online.

Title: Turtles All the Way Down

Body:
Write a program or function that takes in a positive integer and prints or returns a stack of that many ASCII-art turtles, where each turtle is larger than the one above it.

Specifically, if the input is 1, the output should be:

```<code> __
/,,\o
</code>```

If the input is 2:

```<code>  __
o/,,\
 ____
/,__,\o
</code>```

If the input is 3:

```<code>   __
  /,,\o
  ____
o/,__,\
 ______
/,____,\o
</code>```

If the input is 4:

```<code>    __
  o/,,\
   ____
  /,__,\o
  ______
o/,____,\
 ________
/,______,\o
</code>```

If the input is 5:

```<code>     __
    /,,\o
    ____
  o/,__,\
   ______
  /,____,\o
  ________
o/,______,\
 __________
/,________,\o
</code>```

And so on in the same pattern for larger inputs.

Note that:

The head (the o) of the bottom turtle is always on the right. The heads of the turtles above then alternate back and forth.

No lines may have trailing spaces.

Superfluous leading spaces are not allowed. (i.e. the back of the bottom turtle should be at the start of the line.)

A single optional trailing newline is allowed.

The shortest code in bytes wins.

Body:
F#, <s>218</s> <s>207</s> <s>202</s> <s>196</s> 187 bytes.

Shaved most of these bytes by inlining variables

let R=String.replicate
let t n=let rec L i r k=if i<n then L(i+1)(R(k+i%2+1)" "+R((n-i)*2)"_"+"\n"+R k" "+R(i%2)"o"+"/,"+R(n*2-i*2-2)"_"+",\\"+R(1-i%2)"o"+"\n"+r)(k+i%2*2)else r in L 0""0

The logic is shamelessly stolen from this Python answer

Try it online.


问:
A newly discovered number: bleen!
"The Nobel Prize in mathematics was awarded to a California professor who has discovered a new number! The number is bleen, which he claims belongs between 6 and 7."  --George Carlin

In this challenge, you will print all Integers, inclusive, within the given input range.  Print numbers ascending or descending according to their input order.  That is, for input [n1, n2], print ascending if n1 < n2, descending if n1 > n2.

Since bleen is now an Integer number it may be used as input.  It must also be included in the output, between 6 and 7 where applicable.  Also note that -bleen exists between -7 and -6.

Input

Two Integers [n1, n2] in the range [-10, 10], inclusive, via your programming language's input of choice.

(Input may also contain bleen and -bleen!)

Output

Print all Integers starting at n1 and ending with n2, including the newly discovered bleen between 6 and 7.  Output can be a range of character separated numbers in some form your language supports - that is, comma or space separated.  One trailing space of output is okay.

Examples

```<code>Input:  1 10
Output: 1 2 3 4 5 6 bleen 7 8 9 10

Input:  -9 -4
Output: -9 -8 -7 -bleen -6 -5 -4

Input:  -8 bleen
Output: -8 -7 -bleen -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 bleen

Input:  9 1
Output: 9 8 7 bleen 6 5 4 3 2 1

Input:  2 -bleen
Output: 2 1 0 -1 -2 -3 -4 -5 -6 -bleen

Input:  -bleen 0
Output: -bleen -6 -5 -4 -3 -2 -1 0

Input:  bleen bleen
Output: bleen

Input:  2 2
Output: 2
</code>```

Additional notes

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

You may use any programming language, but standard loopholes are not allowed.

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

答:
Java 7, 251 bytes

```<code>import java.util.*;String b(Object...a){String q="bleen",r="";List l=new ArrayList();int j=-10,i,z,y,t;while(j<11)l.add(j++);l.add(4,"-"+q);l.add(18,q);z=l.indexOf(a[0]);y=l.indexOf(b[1]);if(y<z){t=z;z=y;y=t;}for(i=z;i<=y;)r+=l.get(i++)+" ";return r;}
</code>```

Different approach which is shorter than the already existing Java 7 answer.

Also, it's unfortunate that the parameters are potentially not in order, which adds some bytes to swap them around.

Ungolfed & test cases:

Try it here.

```<code>import java.util.*;
class Main{
  static String b(Object... a){
    String q = "bleen",
           r = "";
    List l = new ArrayList();
    int j = -10, i, z, y, t;
    while(j < 11){
      l.add(j++);
    }
    l.add(4, "-"+q);
    l.add(18, q);
    z = l.indexOf(a[0]);
    y = l.indexOf(a[1]);
    if(y < z){
      t = z;
      z = y;
      y = t;
    }
    for(i = z; i <= y; ){
      r += l.get(i++) + " ";
    }
    return r;
  }

  public static void main(String[] a){
    System.out.println(b(1, 10));
    System.out.println(b(-9, -4));
    System.out.println(b(-8, "bleen"));
    System.out.println(b(9, 1));
    System.out.println(b(2, "-bleen"));
    System.out.println(b("-bleen", 0));
    System.out.println(b("bleen", "bleen"));
    System.out.println(b(2, 2));
  }
}
</code>```

Output:

```<code>1 2 3 4 5 6 bleen 7 8 9 10
-9 -8 -7 -bleen -6 -5 -4
-8 -7 -bleen -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 bleen
1 2 3 4 5 6 bleen 7 8 9
-bleen -6 -5 -4 -3 -2 -1 0 1 2
-bleen -6 -5 -4 -3 -2 -1 0
bleen
2
</code>```

Title: A newly discovered number: bleen!

Body:
Java 7, 251 bytes

import java.util.*;String b(Object...a){String q="bleen",r="";List l=new ArrayList();int j=-10,i,z,y,t;while(j<11)l.add(j++);l.add(4,"-"+q);l.add(18,q);z=l.indexOf(a[0]);y=l.indexOf(b[1]);if(y<z){t=z;z=y;y=t;}for(i=z;i<=y;)r+=l.get(i++)+" ";return r;}

Different approach which is shorter than the already existing Java 7 answer.

Also, it's unfortunate that the parameters are potentially not in order, which adds some bytes to swap them around.

Ungolfed & test cases:

Try it here.

import java.util.*;
class Main{
  static String b(Object... a){
    String q = "bleen",
           r = "";
    List l = new ArrayList();
    int j = -10, i, z, y, t;
    while(j < 11){
      l.add(j++);
    }
    l.add(4, "-"+q);
    l.add(18, q);
    z = l.indexOf(a[0]);
    y = l.indexOf(a[1]);
    if(y < z){
      t = z;
      z = y;
      y = t;
    }
    for(i = z; i <= y; ){
      r += l.get(i++) + " ";
    }
    return r;
  }

  public static void main(String[] a){
    System.out.println(b(1, 10));
    System.out.println(b(-9, -4));
    System.out.println(b(-8, "bleen"));
    System.out.println(b(9, 1));
    System.out.println(b(2, "-bleen"));
    System.out.println(b("-bleen", 0));
    System.out.println(b("bleen", "bleen"));
    System.out.println(b(2, 2));
  }
}

Output:

1 2 3 4 5 6 bleen 7 8 9 10
-9 -8 -7 -bleen -6 -5 -4
-8 -7 -bleen -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 bleen
1 2 3 4 5 6 bleen 7 8 9
-bleen -6 -5 -4 -3 -2 -1 0 1 2
-bleen -6 -5 -4 -3 -2 -1 0
bleen
2


问:
Collatz Paths: Forwards and Backwards along the Collatz Conjecture
The Collatz conjecture is a very well-known conjecture. Take a positive integer; if it's even, divide by 2, else, multiply by 3 and add 1. Repeat until you reach 1 or something else happens. The conjecture is that this process always reaches 1.

You can also reverse the process. Start at 1, multiply by 2, and to branch to multiply by 3 and add 1 numbers, when you reach an even number that is 1 (mod 3), subtract 1 and divide by 3.

A Collatz path combines the two, trying to get from one number to another with those four operations.

For example, to get to 20 from 1:

```<code>1     *2
2     *2
4     *2
8     *2
16    *2
5     (-1)/3
10    *2
20    *2
</code>```

You can also get to 3 from 10 by subtracting 1 and dividing by 3.

With these tools, you can traverse a Collatz path from one number to another. For example, the path from 20 to 3 is (divide by 2), (subtract 1, divide by 3).

In short, the available operations are:

```<code>n * 2       always
n // 2      if n % 2 == 0
n * 3 + 1   if n % 2 == 1
(n-1) // 3  if n % 6 == 4
</code>```

Note: not all Collatz paths are short. a(7,3) could run

```<code>7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1, 2, 4, 8, 16, 5, 10, 3
</code>```

but a shorter path is

```<code>7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 3
</code>```

The Challenge

Find the length of the shortest Collatz path between any two positive integers, p and q.

Input is any two positive integers less than 2^20 to avoid integer overflow. The input method is left to the discretion of the golfer. The integers may be the same, in which case, the length of the Collatz path is 0.

Output should be one integer, denoting the length of the shortest Collatz path between p and q.

Test Cases

```<code>a(2,1)
1

a(4,1)
1         # 4 -> 1

a(3,1)
6         # 3 -> 10 -> 5 -> 16 -> 8 -> 4 -> 1

a(11,12)
11        # 11 -> 34 -> 17 -> 52 -> 26 -> 13
          # -> 40 -> 20 -> 10 -> 3 -> 6 -> 12

a(15,9)
20        # 46 -> 23 -> 70 -> 35 -> 106 -> 53 -> 160 -> 80 -> 40 -> 13
          # -> 26 -> 52 -> 17 -> 34 -> 11 -> 22 ->  7 -> 14 -> 28 -> 9
</code>```

Many thanks to orlp for their help in clarifying this challenge.

As always, if the problem is unclear, please let me know. Good luck and good golfing!

Body:
Python 2, 110 bytes

a=lambda p,q,s={0}:1+a(p,q,s.union(*({p,n*2,[n/2,n*3+1][n%2]}|set([~-n/3]*(n%6==4))for n in s)))if{q}-s else-1


问:
Print a 10 by 10 grid of asterisks

Background

This is a standard textbook example to demonstrate for loops.

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

Task

You are to print this exact text:

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

Specs

You may have extra trailing newlines.

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

Scoring

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

答:
Pyth, 6 bytes

```<code>VT*T\*
</code>```

T is 10 in Pyth, Vab executes statement b a times, \* is the asterisk character constant, and multiplying (*) a string and an integer repeats that string n times. Pyth's implicit printing with V means 10 lines are printed.

Title: Print a 10 by 10 grid of asterisks

Body:
Pyth, 6 bytes

VT*T\*

T is 10 in Pyth, Vab executes statement b a times, \* is the asterisk character constant, and multiplying (*) a string and an integer repeats that string n times. Pyth's implicit printing with V means 10 lines are printed.


答:
V, 7 bytes

```<code>10é*10Ä
</code>```

Try it online!

About as straightforward as an answer can be.

Explanation:

```<code>10      "10 times:
  é*    "insert an asterisk
    10Ä "make 10 copies of the current line
</code>```

5 bytes:

```<code>10O±*
</code>```

Explanation:

```<code>10O     " Insert the following on the next ten lines:
   ±    "   10 copies of
    *   "   an asterisk
</code>```

This didn't work when the challenge was posted because of a bug.

Title: Print a 10 by 10 grid of asterisks

Body:
Background

This is a standard textbook example to demonstrate for loops.

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

Task

You are to print this exact text:

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

Specs

You may have extra trailing newlines.

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

Scoring

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

Body:
V, 7 bytes

10é*10Ä

Try it online!

About as straightforward as an answer can be.

Explanation:

10      "10 times:
  é*    "insert an asterisk
    10Ä "make 10 copies of the current line

5 bytes:

10O±*

Explanation:

10O     " Insert the following on the next ten lines:
   ±    "   10 copies of
    *   "   an asterisk

This didn't work when the challenge was posted because of a bug.


答:
Java 7, 63 bytes

```<code>void f(){for(int i=0;i++<10;)System.out.println("**********");}
</code>```

Just for kicks. I can't seem to find any tricks to make this shorter. Trying to add logic for a 100-loop or returning a String instead of printing just ends up worse.

Title: Print a 10 by 10 grid of asterisks

Body:
Java 7, 63 bytes

void f(){for(int i=0;i++<10;)System.out.println("**********");}

Just for kicks. I can't seem to find any tricks to make this shorter. Trying to add logic for a 100-loop or returning a String instead of printing just ends up worse.


答:
Python 3, <s>29</s> 23 bytes

```<code>print(('*'*10+'\n')*10)
</code>```

Thanks to orlp for shaving off 6 bytes.

Title: Print a 10 by 10 grid of asterisks

Body:
Python 3, <s>29</s> 23 bytes

print(('*'*10+'\n')*10)

Thanks to orlp for shaving off 6 bytes.


Title: Print a 10 by 10 grid of asterisks

Body:
Python 2, 22 21 bytes

print('*'*10+'\n')*10


答:
Python 3, <s>25</s> 23 bytes

Hey I actually outgolfed someone :).

```<code>print(("*"*9+"*\n")*10)
</code>```

if stderr is valid, 22 bytes

```<code>exit(("*"*9+"*\n")*10)
</code>```

realised that execing didn't actually golf it down :(

25 bytes answer

```<code>exec("print('*'*10);"*10)
</code>```

Works by concatenating ten copies of print('*'*10); and execing, which in turn works by concatenating '*' 10 times and printing

Title: Print a 10 by 10 grid of asterisks

Body:
Python 3, <s>25</s> 23 bytes

Hey I actually outgolfed someone :).

print(("*"*9+"*\n")*10)

if stderr is valid, 22 bytes

exit(("*"*9+"*\n")*10)

realised that execing didn't actually golf it down :(

25 bytes answer

exec("print('*'*10);"*10)

Works by concatenating ten copies of print('*'*10); and execing, which in turn works by concatenating '*' 10 times and printing


问:
Output a shuffled deck using random input

Input/Output:

Input: A uniformly random, infinitely long, string of '0's and '1's, taken from stdin.  The string is assumed to be truly random, not pseudo-random.  It is uniform in that each character is equally likely to be a '0' or '1'.

Careful! The input is infinitely long, so you can't store it all in memory using a function like raw_input() in python.  If I'm not mistaken, golfscript will fail with infinite input, since it pushes the entire input onto the stack prior to running.

Output: A uniformly random shuffled standard deck, without jokers.  It is uniform in that all orderings are equally likely.

Each card in the output is it's rank, A, 2-9, T, J, Q or K concatenated with it's suit, c, d, h or s.  For example, the 10 of spades is Ts

The cards of the deck should be separated by spaces.

You may not use built-in random libraries or functions because they are not truly random, only pseudo-random.

Example input

You may use the following python script to pipe input into your program:

```<code>import sys, random
try:
    while True:
        sys.stdout.write(str(random.randint(0,1)))
except IOError:
    pass
</code>```

If you save the script as rand.py, test your program with python rand.py | your_program

In python 3 it runs as expected, but in python 2.7 I get an error message after my program's output, but only after everything's done, so just ignore the error message.

Example output:

Here's how the deck should be printed if it happened to be shuffled into a sorted order:

```<code>Ac 2c 3c 4c 5c 6c 7c 8c 9c Tc Jc Qc Kc Ad 2d 3d 4d 5d 6d 7d 8d 9d Td Jd Qd Kd Ah 2h 3h 4h 5h 6h 7h 8h 9h Th Jh Qh Kh As 2s 3s 4s 5s 6s 7s 8s 9s Ts Js Qs Ks
</code>```

Scoring:

This is a code golf.  Shortest code wins.

Example program:

Here is a python 2.7 solution, not golfed.

```<code>import sys
def next():
    return int(sys.stdin.read(1))==1
def roll(n):
    if n==1:
        return 0
    if n%2==0:
        r=roll(n/2)
        if next():
            r+=n/2
        return r
    else:
        r=n
        while(r==n):
            r=roll(n+1)
        return r
deck = [rank+suit for suit in 'cdhs' for rank in 'A23456789TJQK']
while len(deck)>0:
    print deck.pop(roll(len(deck))),
</code>```

Body:
Ruby, 89 87 characters

l=*0..51;l.map{l-=[i=l[gets(6).to_i 2]||redo];$><<'A23456789TJQK'[i/4]+'cdhs'[i%4]+' '}

Edit: previous version

l=*0..51;(l-=[i=l[gets(6).to_i 2]];i&&$><<'A23456789TJQK'[i/4]+'cdhs'[i%4]+' ')while l[0]


答:
JavaScript (ES6), 37 bytes

```<code>console.log(`**********
`.repeat(10))
</code>```

A straightforward answer.

Title: Print a 10 by 10 grid of asterisks

Body:
JavaScript (ES6), 37 bytes

console.log(`**********
`.repeat(10))

A straightforward answer.


答:
Jellyfish, <s>12</s> 10 bytes

Thanks to Zgarb for saving 2 bytes.

```<code>P$'*
 &;10
</code>```

Try it online!

Explanation

Using more conventional notation, this program represents the following expression:

```<code>P( $( &;(10), '* ) )
</code>```

&; takes a single value and creates a pair with two times that value, so &;(10) gives us [10 10]. Then $ is reshape which forms a 10x10 grid of asterisks. Finally, P prints the array in "matrix format" which prints each string on its own line.

Title: Print a 10 by 10 grid of asterisks

Body:
Jellyfish, <s>12</s> 10 bytes

Thanks to Zgarb for saving 2 bytes.

P$'*
 &;10

Try it online!

Explanation

Using more conventional notation, this program represents the following expression:

P( $( &;(10), '* ) )

&; takes a single value and creates a pair with two times that value, so &;(10) gives us [10 10]. Then $ is reshape which forms a 10x10 grid of asterisks. Finally, P prints the array in "matrix format" which prints each string on its own line.


答:
QBIC, 18 bytes

```<code>[1,z:?@**********|
</code>```

Explanation

```<code>`[` starts a for-loop
`@**********|` introduces the string literal "**********" and `?` prints it
`z` is short for 10
FOR-loops are auto-closed at the end of the program code.
</code>```

If you'd like me to demonstrate more features of QBIC, upvote this: Showcase of Languages

QBIC's a work-in-progress. The current state would allow us to solve this in 15 bytes:

```<code>    [|?@**********`
</code>```

[ starts a FOR-loop, but the number of arguments is flexible. When | directly follows [, the FOR loop runs from 1 to 10. One argument makes it go from 1 to N, two args runs from M to N and three args introduces an increment:

```<code>[3,11,2| --> FOR a=3 TO 11 STEP 2 (or JS-style: for(a=3;a<11;a=a+2){} )
</code>```

Title: Print a 10 by 10 grid of asterisks

Body:
QBIC, 18 bytes

[1,z:?@**********|

Explanation

`[` starts a for-loop
`@**********|` introduces the string literal "**********" and `?` prints it
`z` is short for 10
FOR-loops are auto-closed at the end of the program code.

If you'd like me to demonstrate more features of QBIC, upvote this: Showcase of Languages

QBIC's a work-in-progress. The current state would allow us to solve this in 15 bytes:

    [|?@**********`

[ starts a FOR-loop, but the number of arguments is flexible. When | directly follows [, the FOR loop runs from 1 to 10. One argument makes it go from 1 to N, two args runs from M to N and three args introduces an increment:

[3,11,2| --> FOR a=3 TO 11 STEP 2 (or JS-style: for(a=3;a<11;a=a+2){} )


答:
Python 2, 21 Bytes

```<code>exec"print'**'*5;"*10
</code>```

Works in a similar way to Destructible Watermelon's Python 3 solution.

Title: Print a 10 by 10 grid of asterisks

Body:
Python 2, 21 Bytes

exec"print'**'*5;"*10

Works in a similar way to Destructible Watermelon's Python 3 solution.


Title: Turtles All the Way Down

Body:
Python 2, 116 Bytes

m=input()
for i in range(m):r=m-i;b=r%2;h='o';a='__';u=i*a;s=' '*r;print s+u+a+'\n'+s[:b-2]+h*-~-b+"/,"+u+",\\"+b*h


答:
Retina, 12 bytes

Byte count assumes ISO 8859-1 encoding. The leading linefeed is significant.

```<code>
10$**
.
$_¶
</code>```

The first stage writes a string of ten asterisks, the second stage replaces each asterisk with the entire string and a linefeed. This prints two trailing linefeeds.

Title: Print a 10 by 10 grid of asterisks

Body:
Retina, 12 bytes

Byte count assumes ISO 8859-1 encoding. The leading linefeed is significant.

10$**
.
$_¶

The first stage writes a string of ten asterisks, the second stage replaces each asterisk with the entire string and a linefeed. This prints two trailing linefeeds.


答:
J, <s>10</s> 9 bytes

1 byte thanks to @Adám.

```<code>10 10$'*'
</code>```

Online interpreter.

Explanation

10 10 specifies the dimension to the operator $ which builds an array with the specified dimensions.

Title: Print a 10 by 10 grid of asterisks

Body:
J, <s>10</s> 9 bytes

1 byte thanks to @Adám.

10 10$'*'

Online interpreter.

Explanation

10 10 specifies the dimension to the operator $ which builds an array with the specified dimensions.


答:
CJam, <s>9</s> 8 bytes

Thanks to Lynn for saving 1 byte.

```<code>'*A*N]A*
</code>```

Try it online!

Explanation

```<code>'*A*    e# Create a string of 10 asterisks.
N       e# Push a linefeed.
]       e# Wrap both in a list.
A*      e# Repeat 10 times.
</code>```

Title: Print a 10 by 10 grid of asterisks

Body:
CJam, <s>9</s> 8 bytes

Thanks to Lynn for saving 1 byte.

'*A*N]A*

Try it online!

Explanation

'*A*    e# Create a string of 10 asterisks.
N       e# Push a linefeed.
]       e# Wrap both in a list.
A*      e# Repeat 10 times.


答:
APL, 9 bytes

Works on all APLs ever made.

10 10⍴'*'
```

10 10 ten rows and ten column

⍴ cyclically repeating

'*' a star

TryAPL online!

Title: Print a 10 by 10 grid of asterisks

Body:
APL, 9 bytes

Works on all APLs ever made.

10 10⍴'*'

10 10 ten rows and ten column

⍴ cyclically repeating

'*' a star

TryAPL online!


答:
Racket, 52 bytes

```<code>(display(string-join(make-list 10"**********")"\n"))
</code>```

If you're fine with just returning the string and not printing it, you can forego the (display) for a score of 41 bytes.

An alternate answer (longer at 73 bytes, but I like it better personally):

```<code>(display(build-string 110(λ(n)(if(eq?(remainder n 10)0)#\newline #\*))))
</code>```

Title: Print a 10 by 10 grid of asterisks

Body:
Racket, 52 bytes

(display(string-join(make-list 10"**********")"\n"))

If you're fine with just returning the string and not printing it, you can forego the (display) for a score of 41 bytes.

An alternate answer (longer at 73 bytes, but I like it better personally):

(display(build-string 110(λ(n)(if(eq?(remainder n 10)0)#\newline #\*))))


答:
C# (and without “Hello World” anywhere)

Code-golfed, so that obviously no unnecessary whitespace is used:

using System;using System.IO.Compression;using System.Runtime.Serialization;using System.Runtime.Serialization.Json;using System.Linq;using System.Net;using System.Text.RegularExpressions;class C{static void Main(){var g=WebRequest.Create("https://api.stackexchange.com/2.1/questions/8859?site=codegolf&filter=withbody");var r=(HttpWebResponse)g.GetResponse();if(r.StatusCode==HttpStatusCode.OK){var s=r.GetResponseStream();foreach(var a in r.ContentEncoding.ToLowerInvariant().Split(',').Reverse())switch(a){case"gzip":s=new GZipStream(s,CompressionMode.Decompress);break;case"deflate":s=new DeflateStream(s,CompressionMode.Decompress);break;default:throw new InvalidOperationException();}var d=new DataContractJsonSerializer(typeof(R));var q=(R)d.ReadObject(s);var e=new Regex("([^<]*)");var m=e.Match(q.I[0].B);Console.WriteLine(m.Groups[1].Value);}}}[DataContract]public class R{[DataMember(Name="items")]public I[]I{get;set;}}[DataContract]public class I{[DataMember(Name="body")]public string B{get;set;}}
```

<p>Formatted for readability:</p>

<pre class="lang-cs prettyprint-override"><code>using System;
using System.IO.Compression;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;

class C
{
    static void Main()
    {
        var g = WebRequest.Create("https://api.stackexchange.com/2.1/questions/8859?site=codegolf&filter=withbody");
        var r = (HttpWebResponse)g.GetResponse();
        if (r.StatusCode == HttpStatusCode.OK)
        {
            var s=r.GetResponseStream();
            foreach (var a in r.ContentEncoding.ToLowerInvariant().Split(',').Reverse())
            switch(a)
            {
                case "gzip":
                    s = new GZipStream(s,CompressionMode.Decompress);
                    break;
                case "deflate":
                    s = new DeflateStream(s,CompressionMode.Decompress);
                    break;
                default:
                    throw new InvalidOperationException();
            }
            var d = new DataContractJsonSerializer(typeof(R));
            var q = (R)d.ReadObject(s);
            var e = new Regex("<code>([^<]*)</code>");
            var m = e.Match(q.I[0].B);
            Console.WriteLine(m.Groups[1].Value);
        }
    }
}

[DataContract]
public class R
{
    [DataMember(Name="items")]
    public I[] I { get; set; }
}

[DataContract]
public class I
{
    [DataMember(Name="body")]
    public string B { get; set; }
}
</code>```

The program retrieves this question from Code Golf using Stack Exchange API, finds the first piece of text formatted as code (which, in case of this question, is the “Hello World” text), and prints it out.

Title: Hello World in 1024 characters

Body:
In exactly 1024 characters, no more, no less:

Must print Hello World.

Must not use unnecessary whitespace.

Must not use comments.

Judging should favor creativity and/or humor over simple obfuscation when voting up answers.

The earliest I will select an answer is the 11th (Sunday) of November (2012). I'm seeing some awesome entries so far, can't wait to see what else people come up with.

Body:
C# (and without “Hello World” anywhere)

Code-golfed, so that obviously no unnecessary whitespace is used:

using System;using System.IO.Compression;using System.Runtime.Serialization;using System.Runtime.Serialization.Json;using System.Linq;using System.Net;using System.Text.RegularExpressions;class C{static void Main(){var g=WebRequest.Create("https://api.stackexchange.com/2.1/questions/8859?site=codegolf&filter=withbody");var r=(HttpWebResponse)g.GetResponse();if(r.StatusCode==HttpStatusCode.OK){var s=r.GetResponseStream();foreach(var a in r.ContentEncoding.ToLowerInvariant().Split(',').Reverse())switch(a){case"gzip":s=new GZipStream(s,CompressionMode.Decompress);break;case"deflate":s=new DeflateStream(s,CompressionMode.Decompress);break;default:throw new InvalidOperationException();}var d=new DataContractJsonSerializer(typeof(R));var q=(R)d.ReadObject(s);var e=new Regex("<code>([^<]*)</code>");var m=e.Match(q.I[0].B);Console.WriteLine(m.Groups[1].Value);}}}[DataContract]public class R{[DataMember(Name="items")]public I[]I{get;set;}}[DataContract]public class I{[DataMember(Name="body")]public string B{get;set;}}

Formatted for readability:

using System;
using System.IO.Compression;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;

class C
{
    static void Main()
    {
        var g = WebRequest.Create("https://api.stackexchange.com/2.1/questions/8859?site=codegolf&filter=withbody");
        var r = (HttpWebResponse)g.GetResponse();
        if (r.StatusCode == HttpStatusCode.OK)
        {
            var s=r.GetResponseStream();
            foreach (var a in r.ContentEncoding.ToLowerInvariant().Split(',').Reverse())
            switch(a)
            {
                case "gzip":
                    s = new GZipStream(s,CompressionMode.Decompress);
                    break;
                case "deflate":
                    s = new DeflateStream(s,CompressionMode.Decompress);
                    break;
                default:
                    throw new InvalidOperationException();
            }
            var d = new DataContractJsonSerializer(typeof(R));
            var q = (R)d.ReadObject(s);
            var e = new Regex("<code>([^<]*)</code>");
            var m = e.Match(q.I[0].B);
            Console.WriteLine(m.Groups[1].Value);
        }
    }
}

[DataContract]
public class R
{
    [DataMember(Name="items")]
    public I[] I { get; set; }
}

[DataContract]
public class I
{
    [DataMember(Name="body")]
    public string B { get; set; }
}

The program retrieves this question from Code Golf using Stack Exchange API, finds the first piece of text formatted as code (which, in case of this question, is the “Hello World” text), and prints it out.


答:
Kotlin,  <s>99</s> <s>93</s> 88 bytes

```<code>(('A'..'Y')+'Z'.downTo('A')).map{println((('A'..it-1)+it.downTo('A')).joinToString(""))}
</code>```

That's still longer than I expected but I doubt I'll be able to golf it further.

Factorisation doesn't save the day, best I could do is 93 bytes :

```<code>fun r(a:Char,b:Char)=(a..b-1)+b.downTo(a)
r('A','Z').map{println(r('A',it).joinToString(""))}
</code>```

Title: Alphabet triangle

Body:
You are to print this exact text:

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

Specs

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

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

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

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

Scoring

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

Body:
Kotlin,  <s>99</s> <s>93</s> 88 bytes

(('A'..'Y')+'Z'.downTo('A')).map{println((('A'..it-1)+it.downTo('A')).joinToString(""))}

That's still longer than I expected but I doubt I'll be able to golf it further.

Factorisation doesn't save the day, best I could do is 93 bytes :

fun r(a:Char,b:Char)=(a..b-1)+b.downTo(a)
r('A','Z').map{println(r('A',it).joinToString(""))}


答:
Mathematica, 24 bytes

```<code>Print@"**********"~Do~10
</code>```

It's kinda unfortunate that StringRepeat alone is 12 characters long...

Title: Print a 10 by 10 grid of asterisks

Body:
Background

This is a standard textbook example to demonstrate for loops.

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

Task

You are to print this exact text:

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

Specs

You may have extra trailing newlines.

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

Scoring

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

Body:
Mathematica, 24 bytes

Print@"**********"~Do~10

It's kinda unfortunate that StringRepeat alone is 12 characters long...


Title: Print a 10 by 10 grid of asterisks

Body:
Batch, 41 bytes

@for /l %%i in (0,1,9)do @echo **********


答:
///, 25 bytes

```<code>/a/**********
/aaaaaaaaaa
</code>```

Try it online!

A simple replace command.

Title: Print a 10 by 10 grid of asterisks

Body:
///, 25 bytes

/a/**********
/aaaaaaaaaa

Try it online!

A simple replace command.


答:
C++, 76 bytes

I don't know if this could be golfed further, but just.

```<code>#include <iostream>
void a(){for(int i=0;i++<10;)std::cout<<"**********\n";}
</code>```

Title: Print a 10 by 10 grid of asterisks

Body:
C++, 76 bytes

I don't know if this could be golfed further, but just.

#include <iostream>
void a(){for(int i=0;i++<10;)std::cout<<"**********\n";}


答:
Python 2, <s>156</s> <s>179</s> <s>191</s> <s>209</s> <s>181</s> <s>172</s> <s>177</s> 171 bytes

Since a Collatz path can be imagined as a(1,p) and a(1,q) conjoined at the first number that is common to both sequences and a(1,n) is the original Collatz conjecture, this function calculates the Collatz sequence of p and q, and calculates the length from there. This isn't a pretty golf, so golfing suggestions are very much welcome. The only exception is when p or q == 1. Then, since we can skip directly from 4 to 1 as opposed to a regular Collatz sequence, we need to subtract a step from the result.

Edit: Lots of bug fixing.

Edit: Lots and lots of bug fixing

f=lambda p:[p]if p<3else f([p//2,p*3+1][p%2])+[p]
def a(p,q):
 i=1;c=f(p);d=f(q)
 if sorted((p,q))==(1,2):return 1
 while c[:i]==d[:i]!=d[:i-1]:i+=1
 return len(c+d)-2*i+2
```

Try it online!

Title: Collatz Paths: Forwards and Backwards along the Collatz Conjecture

Body:
The Collatz conjecture is a very well-known conjecture. Take a positive integer; if it's even, divide by 2, else, multiply by 3 and add 1. Repeat until you reach 1 or something else happens. The conjecture is that this process always reaches 1.

You can also reverse the process. Start at 1, multiply by 2, and to branch to multiply by 3 and add 1 numbers, when you reach an even number that is 1 (mod 3), subtract 1 and divide by 3.

A Collatz path combines the two, trying to get from one number to another with those four operations.

For example, to get to 20 from 1:

```<code>1     *2
2     *2
4     *2
8     *2
16    *2
5     (-1)/3
10    *2
20    *2
</code>```

You can also get to 3 from 10 by subtracting 1 and dividing by 3.

With these tools, you can traverse a Collatz path from one number to another. For example, the path from 20 to 3 is (divide by 2), (subtract 1, divide by 3).

In short, the available operations are:

```<code>n * 2       always
n // 2      if n % 2 == 0
n * 3 + 1   if n % 2 == 1
(n-1) // 3  if n % 6 == 4
</code>```

Note: not all Collatz paths are short. a(7,3) could run

```<code>7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1, 2, 4, 8, 16, 5, 10, 3
</code>```

but a shorter path is

```<code>7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 3
</code>```

The Challenge

Find the length of the shortest Collatz path between any two positive integers, p and q.

Input is any two positive integers less than 2^20 to avoid integer overflow. The input method is left to the discretion of the golfer. The integers may be the same, in which case, the length of the Collatz path is 0.

Output should be one integer, denoting the length of the shortest Collatz path between p and q.

Test Cases

```<code>a(2,1)
1

a(4,1)
1         # 4 -> 1

a(3,1)
6         # 3 -> 10 -> 5 -> 16 -> 8 -> 4 -> 1

a(11,12)
11        # 11 -> 34 -> 17 -> 52 -> 26 -> 13
          # -> 40 -> 20 -> 10 -> 3 -> 6 -> 12

a(15,9)
20        # 46 -> 23 -> 70 -> 35 -> 106 -> 53 -> 160 -> 80 -> 40 -> 13
          # -> 26 -> 52 -> 17 -> 34 -> 11 -> 22 ->  7 -> 14 -> 28 -> 9
</code>```

Many thanks to orlp for their help in clarifying this challenge.

As always, if the problem is unclear, please let me know. Good luck and good golfing!

Body:
Python 2, <s>156</s> <s>179</s> <s>191</s> <s>209</s> <s>181</s> <s>172</s> <s>177</s> 171 bytes

Since a Collatz path can be imagined as a(1,p) and a(1,q) conjoined at the first number that is common to both sequences and a(1,n) is the original Collatz conjecture, this function calculates the Collatz sequence of p and q, and calculates the length from there. This isn't a pretty golf, so golfing suggestions are very much welcome. The only exception is when p or q == 1. Then, since we can skip directly from 4 to 1 as opposed to a regular Collatz sequence, we need to subtract a step from the result.

Edit: Lots of bug fixing.

Edit: Lots and lots of bug fixing

f=lambda p:[p]if p<3else f([p//2,p*3+1][p%2])+[p]
def a(p,q):
 i=1;c=f(p);d=f(q)
 if sorted((p,q))==(1,2):return 1
 while c[:i]==d[:i]!=d[:i-1]:i+=1
 return len(c+d)-2*i+2

Try it online!


答:
Golisp, 34 bytes

for[range@10{(_)writeln@*["**"5]}]
```

Due to a "bug", I can't concatenate strings...

Title: Print a 10 by 10 grid of asterisks

Body:
Golisp, 34 bytes

for[range@10{(_)writeln@*["**"5]}]

Due to a "bug", I can't concatenate strings...


答:
Racket, 147 bytes

At least it beats QBasic.

```<code>((λ(x)(display(string-join(x(build-list 26(λ(n)(list->string(map integer->char(x(range 65(+ 66 n))))))))"\n")))(λ(m)(append m(cdr(reverse m)))))
</code>```

Title: Alphabet triangle

Body:
Racket, 147 bytes

At least it beats QBasic.

((λ(x)(display(string-join(x(build-list 26(λ(n)(list->string(map integer->char(x(range 65(+ 66 n))))))))"\n")))(λ(m)(append m(cdr(reverse m)))))


答:
C#, 53,122 108 bytes

Seeing that I'm seriously new to code golf... I'll give it a shot in c#

```<code>public class Program{public static void Main(){for (var i=0;i<10;i++)System.Console.Write("**********\n");}}
</code>```

try it online

Title: Print a 10 by 10 grid of asterisks

Body:
C#, 53,122 108 bytes

Seeing that I'm seriously new to code golf... I'll give it a shot in c#

public class Program{public static void Main(){for (var i=0;i<10;i++)System.Console.Write("**********\n");}}

try it online


Title: Print a 10 by 10 grid of asterisks

Body:
Pyke, 6 bytes

TVT\**

Try it here!

       - (T = 10)
TV     - repeat(10):
  T\** -  10*"*"


Title: Hello World in 1024 characters

Body:
JavaScript (1024 bytes...)

No unnecessary whitespace? What about unnecessary semicolons that JavaScript doesn't need at all? Let's add those semicolons to make people like Crockford happy.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;console.log('Hello World');;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Yes, I'm aware that this is abuse of rules.


问:
Picture of an old friend in ASCII art
I hope this picture looks familiar to you.

It's one of Pacman's ghosts in his "vulnerable" state, after Pacman has eaten a power pill.

The challenge

Picture our ghost in a little frame, using ASCII art. At normal scale (more about this later), each square in the above image should correspond to one character, and the frame should have a one-character separation up and down, and a two-character separation to the left and right of the ghost:

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

But this doesn't look very pretty. # may not be the best choice for the active pixels. Besides, character cells are not square, which makes our friend look more ghostly than he already is.

So, to have more flexibility, the picture will change according to three input parameters:

Character to be used for active pixels;

Horizontal scale factor;

Vertical scale factor.

For example, with %, 4, 2 the ouput would be the better looking picture

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

Rules

All builtins allowed.

Inputs are taken in any reasonable format and any order. The first input above (character for active pixels) is guaranteed to be a printable ASCII character (codes 32 to 126).

Trailing space after each line or trailing newlines after last line are acceptable.

Code golf, fewest bytes wins.

答:
Python 2, 244 bytes

p,w,h=raw_input().split()
for i in range(18): mystr=''.join([(p if i=='1'else' ')*int(w)for i in str(10+(i%17==0))+format(ord('\xff\x00\x03\x0f\x1f??9y\x7f\x7ffY\x7fnF\x00\xff'[i]),'08b')]);print'\n'.join([mystr+mystr[::-1]for j in[1]*int(h)])
```

Title: Picture of an old friend in ASCII art


答:
R, <s>35</s> <s>33</s> 32 bytes

Ô R, you're so verbose <s>sometimes</s>.

<s>
for(i in 1:10)cat(rep("*",10),"\n")
</s>

Interestingly, the cat function has no value (it provides NULL to STDOUT), so you can't do somethig like rep(cat(rep))), which would have been funnier !

EDIT :

New solution proposed by @LeakyNun, -2 bytes.

```<code>for(i in 1:10)cat("**********\n")
</code>```

EDIT :
Shortening it just by -1 byte, by @user5957401

```<code>for(i in 0:9)cat("**********\n")
</code>```

Title: Print a 10 by 10 grid of asterisks

Body:
R, <s>35</s> <s>33</s> 32 bytes

Ô R, you're so verbose <s>sometimes</s>.

<s>
for(i in 1:10)cat(rep("*",10),"\n")
</s>

Interestingly, the cat function has no value (it provides NULL to STDOUT), so you can't do somethig like rep(cat(rep))), which would have been funnier !

EDIT :

New solution proposed by @LeakyNun, -2 bytes.

for(i in 1:10)cat("**********\n")

EDIT :
Shortening it just by -1 byte, by @user5957401

for(i in 0:9)cat("**********\n")


答:
Haskell, <s>170 158 157 146 143 137 135 112 109 108 106 100</s> 99 bytes

```<code>a!b=length$fst$break(elem b)$iterate(>>= \n->2*n:cycle[div n 2,n*3+1]!!n:[div(n-1)3|mod n 6==4])[a]
</code>```

I did not expect that my original version was so much more golfable, this is also the work of @nimi @Lynn and @Laikoni!

Thanks @Laikoni for a byte, @Lynn for <s>11 14 20</s> 21 bytes, @nimi for 8 bytes!

This expands the the tree of visited numbers (beginning by a) step by step, and checks in each step whether we arrived at the given number b.

Body:
Haskell, <s>170 158 157 146 143 137 135 112 109 108 106 100</s> 99 bytes

a!b=length$fst$break(elem b)$iterate(>>= \n->2*n:cycle[div n 2,n*3+1]!!n:[div(n-1)3|mod n 6==4])[a]

I did not expect that my original version was so much more golfable, this is also the work of @nimi @Lynn and @Laikoni!

Thanks @Laikoni for a byte, @Lynn for <s>11 14 20</s> 21 bytes, @nimi for 8 bytes!

This expands the the tree of visited numbers (beginning by a) step by step, and checks in each step whether we arrived at the given number b.


答:
Cheddar, <s>21</s> 20 bytes

```<code>print('*'*10+'
')*10
</code>```

Yet another straightforward answer.

Title: Print a 10 by 10 grid of asterisks

Body:
Cheddar, <s>21</s> 20 bytes

print('*'*10+'
')*10

Yet another straightforward answer.


答:
Cheddar, 24 bytes

```<code>print(['*'*10]*10).vfuse
</code>```

'*'*10 builds the string **********.

Then, ['**********']*10 creates 10 copies of that string.

Then, vfuse joins by newline.

Title: Print a 10 by 10 grid of asterisks

Body:
Cheddar, 24 bytes

print(['*'*10]*10).vfuse

'*'*10 builds the string **********.

Then, ['**********']*10 creates 10 copies of that string.

Then, vfuse joins by newline.


答:
Frink, <s>40</s> 39 Bytes

```<code>for r=0 to 9
  println[repeat["*",10]]
</code>```

-1 Byte @LeakNun

Title: Print a 10 by 10 grid of asterisks

Body:
Frink, <s>40</s> 39 Bytes

for r=0 to 9
  println[repeat["*",10]]

-1 Byte @LeakNun


Title: Print a 10 by 10 grid of asterisks

Body:
Background

This is a standard textbook example to demonstrate for loops.

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

Task

You are to print this exact text:

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

Specs

You may have extra trailing newlines.

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

Scoring

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

Body:
R, 27 29 bytes

cat(rep('\r**********\n',10))

An alternate answer (34 bytes) is: cat(rep('**********',10),sep='\n')


答:
Brainfuck, 74 bytes

first brainfuck submission ever, first reasonable length program, too

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

```<code>+++>>+++>>+++++++[<+<+<<+>>>>-]<[>++++++<-] < sets tape to 10 0 10 0 42

                                           <<< moves to the first 10
            [->++++++++++[>>>.<<<-]>.<<] <
loops while the first cell of the tape is not zero:
    subtracts 1 from first cell
    sets the second cell to 10,
    loops while second cell is not zero: prints 42 cell, subtracts from second cell
    moves to third cell, prints it
</code>```

Title: Print a 10 by 10 grid of asterisks

Body:
Brainfuck, 74 bytes

first brainfuck submission ever, first reasonable length program, too

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

+++>>+++>>+++++++[<+<+<<+>>>>-]<[>++++++<-] < sets tape to 10 0 10 0 42

                                           <<< moves to the first 10
            [->++++++++++[>>>.<<<-]>.<<] <
loops while the first cell of the tape is not zero:
    subtracts 1 from first cell
    sets the second cell to 10,
    loops while second cell is not zero: prints 42 cell, subtracts from second cell
    moves to third cell, prints it


答:
05AB1E, 7 bytes

```<code>TF'*T×,
</code>```

Explanation

```<code>TF      # 10 times do:
  '*T×  # repeat asterisk 10 times
      , # print with newline
</code>```

Try it online

Title: Print a 10 by 10 grid of asterisks

Body:
05AB1E, 7 bytes

TF'*T×,

Explanation

TF      # 10 times do:
  '*T×  # repeat asterisk 10 times
      , # print with newline

Try it online