答:
PowerShell v2+, <s>379</s> <s>340</s> <s>289</s> 286 bytes

```<code>nal n New-Object
Add-Type -A *.Dr*g,S*ms
$x='$g.FillRectangle((n Drawing.SolidBrush '
($f=n Windows.Forms.Form).Add_paint({$g=$args[1].Graphics;"$x'#0048e0'),0,0,100,72);$x white),28,0,16,72);$x white),0,28,100,16);$x'#d72828'),32,0,8,72);$x'#d72828'),0,32,100,8)"|iex})
$f.ShowDialog()
</code>```

Linebreaks and semicolons count the same, so linebreaks left in for clarity. ;-)

So, drawing in PowerShell is not its strong suit -- it needs to use lengthy .NET assembly imports and GDI+ function calls.

Saved 39 bytes saved thanks to TessellatingHeckler's answer, and another 51 bytes thanks to Joey's impressive golfing commentary. Thanks to them both!

We start with creating a New-Alias n and assign it New-Object. We can thus reference just n instead of New-Object elsewhere in the program. Next is the import calls, with wildcards -- we're importing System.Drawing and System.Windows.Forms. We then create a variable $x that we use for several repeated calls in the future, so we're not needing to type it out every time.

The next line is the meat-and-potatoes of the program. We start with setting $f as a new Windows.Forms.Form and immediately call the Add_paint() routine on it.

Inside the paint routine, the first line is to create our graphics component, $g, that we'll use as our canvas. The next line is actually a constructed string that we pass to iex (similar to eval) so that we can leverage the $x variable from above. We're simply drawing the blue background, then two white rectangles, followed by two red rectangles. We adjust the values appropriately each time and pipe it to the Invoke-Expression.

The final line simply shows the dialog form as we've drawn it above.

Note that since we're creating a form object, and PowerShell is all about the pipeline, closing the pop-up form will pass along a System.Enum.DialogResult object of Cancel, since that's technically what the user did. Since we're not capturing or otherwise doing anything with that result, the word Cancel will be displayed to STDOUT when the program concludes, as it was left on the pipeline. That can be suppressed by adding >$a to the end of the last line, if so required, so the output redirects into a throwaway variable.

Title: Draw the national flag of Iceland

Body:
PowerShell v2+, <s>379</s> <s>340</s> <s>289</s> 286 bytes

nal n New-Object
Add-Type -A *.Dr*g,S*ms
$x='$g.FillRectangle((n Drawing.SolidBrush '
($f=n Windows.Forms.Form).Add_paint({$g=$args[1].Graphics;"$x'#0048e0'),0,0,100,72);$x white),28,0,16,72);$x white),0,28,100,16);$x'#d72828'),32,0,8,72);$x'#d72828'),0,32,100,8)"|iex})
$f.ShowDialog()

Linebreaks and semicolons count the same, so linebreaks left in for clarity. ;-)

So, drawing in PowerShell is not its strong suit -- it needs to use lengthy .NET assembly imports and GDI+ function calls.

Saved 39 bytes saved thanks to TessellatingHeckler's answer, and another 51 bytes thanks to Joey's impressive golfing commentary. Thanks to them both!

We start with creating a New-Alias n and assign it New-Object. We can thus reference just n instead of New-Object elsewhere in the program. Next is the import calls, with wildcards -- we're importing System.Drawing and System.Windows.Forms. We then create a variable $x that we use for several repeated calls in the future, so we're not needing to type it out every time.

The next line is the meat-and-potatoes of the program. We start with setting $f as a new Windows.Forms.Form and immediately call the Add_paint() routine on it.

Inside the paint routine, the first line is to create our graphics component, $g, that we'll use as our canvas. The next line is actually a constructed string that we pass to iex (similar to eval) so that we can leverage the $x variable from above. We're simply drawing the blue background, then two white rectangles, followed by two red rectangles. We adjust the values appropriately each time and pipe it to the Invoke-Expression.

The final line simply shows the dialog form as we've drawn it above.

Note that since we're creating a form object, and PowerShell is all about the pipeline, closing the pop-up form will pass along a System.Enum.DialogResult object of Cancel, since that's technically what the user did. Since we're not capturing or otherwise doing anything with that result, the word Cancel will be displayed to STDOUT when the program concludes, as it was left on the pipeline. That can be suppressed by adding >$a to the end of the last line, if so required, so the output redirects into a throwaway variable.


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

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

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

If that number is 1, print out 1 forever.

Challenge

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

take input from STDIN or an acceptable alternative

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

must output to STDOUT or an acceptable alternative

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

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

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

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

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

Catalog

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
JAISBaL, <s>15</s> 6 bytes

```<code>˗Y1˄N0
</code>```

Explanation:

```<code># \# enable verbose parsing #\
while               \# [0] start while loop #\
    printnumln 1    \# [1] print 1 #\
end                 \# [2] end current language construct #\
printnum 0          \# [3] print 0 #\
</code>```

ContentLicense: CC BY-SA 3.0

Title: Implement a Truth-Machine

Body:
JAISBaL, <s>15</s> 6 bytes

˗Y1˄N0

Explanation:

# \# enable verbose parsing #\
while               \# [0] start while loop #\
    printnumln 1    \# [1] print 1 #\
end                 \# [2] end current language construct #\
printnum 0          \# [3] print 0 #\


问:
Narayana-Zidek-Capell numbers
Generate the nth Narayana-Zidek-Capell number given an input n. Fewest bytes win.

f(1)=1, f(n) is the sum of the previous floor(n/2) Narayana-Zidek-Capell terms.

Test Cases:

```<code>f(1)=1

f(9)=42

f(14)=1308

f(15)=2605

f(23)=664299
</code>```

答:
C, 38

A translation of the OEIS algorithm. There's just not enough C code around here!

```<code>f(n){return n<3?:2*f(n-1)-n%2*f(n/2);}
</code>```

Title: Narayana-Zidek-Capell numbers

Body:
C, 38

A translation of the OEIS algorithm. There's just not enough C code around here!

f(n){return n<3?:2*f(n-1)-n%2*f(n/2);}


问:
Walk the labyrinth
Or maybe it's not really a labyrinth, but still.

Rules:

Input is a two-line string, consisting of *, 1, x and X. That string is a labyrinth to walk through. The lines have the equal length.

You could take the input as a string with , (comma) or any convenient separator between these two lines. Or you could take both lines as separate arguments to your function.

Output is the number of steps you have to take to exit the string (last step is the step which moves you out of the string).

You start in the top left corner (the higher line), before the first symbol.

For each step, you move forward by one symbol (from nth to (n+1)th position). Then, depending on the character you step on, the outcome is different. Here's what each char does:

* - nothing. You just step on it normally.

x - once you stepped on it, switch the line, but remain on the same horizontal distance from the beginning. For example, you stepped on the third position of the higher line, and met a lowercase x here. Then you immediately move to the lower line, but again at the third position.

X - switch the line and go to the next position. The example is the same there, but you also move from the third to the forth position (thus you're on the second line at the forth position).

1 - just move forward by yet another position.

Once each character does its job, it's replaced with a space and no longer "works".

Examples follow.

Input:

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

As said before, you start before the first symbol of the first line. The first step moves you on letter x and this letter switches you to the second line. The letter x no longer functions as x, but replaced with *. This will be more relevant in the latter examples. You're now on an asterisk on the lower line, and it did nothing to you.

The second step is moving you forward and you exit the string, so the labyrinth is completed, and it took 2 steps.

Output 2.

Input:

```<code>xX*
x1*
</code>```

1st step: you move on x, which moves you on the x of the lower line. Here comes the rule which says that the used character is replaced with asterisk. Then you move back on the first line, but it's no longer x there, since it has been used and became an asterisk. So you move safely on this asterisk and the step is completed (you are now on the first position of the first line).

2nd step: you move on X, it pushes you to the lower line and then pushes you forward. You now reside on the third position of the second line (asterisk), having never visited the second position (which contains 1).

3rd step: you move forward, exiting the string.

Output: 3.

Test cases:

Input:

```<code>*1*
xxx
</code>```

Output: 3. (because 1 makes you jump on the third position). There you never visit the second line, but it's required part of the input.

Input:

```<code>*X*1*x
x*1xx*
</code>```

Output: 4.

Input:

```<code>1x1x
***X
</code>```

Output: 3.

Input:

```<code>1*x1xxx1*x
x*x1*11X1x
</code>```

Output: 6.

Input:

```<code>xXXXxxx111*
**xxx11*xxx
</code>```

Output: 6.

答:
Haskell, <s>68</s> <s>66</s> 65 bytes

```<code>(a:b)#l@(c:d)|a<'+'=1+b#d|a>'w'=l#('*':b)|a>'W'=d#b|1<2=b#d
_#_=1
</code>```

Function # takes both lines as separate parameters. Usage example: "1x1x" # "***X" -> 3.

We just have to count the stars * we step on plus 1 for leaving.

```<code>(a:b)#l@(c:d)             -- bind: a -> first char of first line
                                   b -> rest of first line
                                   l -> whole second line
                                   c -> first char of second line (never used)
                                   d -> rest of second line
   |a < '+' = 1+b#d       -- stepped on a *, so add 1 and go on
   |a > 'w' = l#('*':b)   -- x switches lines and replaces the x with *
   |a > 'W' = d#b         -- X switch lines and go on
   |1<2     = b#d         -- the rest (-> 1) simply walks forward
_#_=1                     -- base case: the empty string counts 1 for leaving
</code>```

Edit: @feersum saved a byte. Thanks!

Title: Walk the labyrinth

Body:
Haskell, <s>68</s> <s>66</s> 65 bytes

(a:b)#l@(c:d)|a<'+'=1+b#d|a>'w'=l#('*':b)|a>'W'=d#b|1<2=b#d
_#_=1

Function # takes both lines as separate parameters. Usage example: "1x1x" # "***X" -> 3.

We just have to count the stars * we step on plus 1 for leaving.

(a:b)#l@(c:d)             -- bind: a -> first char of first line
                                   b -> rest of first line
                                   l -> whole second line
                                   c -> first char of second line (never used)
                                   d -> rest of second line
   |a < '+' = 1+b#d       -- stepped on a *, so add 1 and go on
   |a > 'w' = l#('*':b)   -- x switches lines and replaces the x with *
   |a > 'W' = d#b         -- X switch lines and go on
   |1<2     = b#d         -- the rest (-> 1) simply walks forward
_#_=1                     -- base case: the empty string counts 1 for leaving

Edit: @feersum saved a byte. Thanks!


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

Title: Draw the national flag of Iceland

Body:
Mathematica <s>174</s> 157 bytes

Without builtins:

157 bytes

r=Rectangle;c=RGBColor;Graphics@{c[{0,72,224}/255],r[{0,0},{25,18}],White,r[{7,0},{11,18}],r[{0,7},{25,11}],c[{43,8,8}/51],r[{8,0},{10,18}],r[{0,8},{25,10}]}

or alternatively

232 bytes

x=Join[Unitize/@Range@7,{0},{2,2},{0},Unitize/@Range@14]&/@Range@7;y=Join[ConstantArray[0,8],{2,2},ConstantArray[0,15]];z=ConstantArray[2,25];ArrayPlot[Join[x,{y},{z,z},{y},x]/.{2->RGBColor[{43,8,8}/51],1->RGBColor[{0,72,224}/255]}]


答:
HTML+CSS, <s>276</s> <s>258</s> <s>254</s> 234 bytes

<s>Ridiculously</s> quite long compared to the SVG+JS solution.

*{position:fixed;background:#fff}e,f{background:#d72828}a{background:#0048e0}c{top:36px;height:16px}d{left:36px;width:16px}e{top:40px;height:8px}f{left:40px;width:8px;}d,f,a{height:72px;top:8px}a,c,e{left:8px;width:100px```
<pre class="snippet-code-html lang-html prettyprint-override"><code><a><c><d><e><f</code>```

Title: Draw the national flag of Iceland

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

Body:
HTML+CSS, <s>276</s> <s>258</s> <s>254</s> 234 bytes

<s>Ridiculously</s> quite long compared to the SVG+JS solution.

*{position:fixed;background:#fff}e,f{background:#d72828}a{background:#0048e0}c{top:36px;height:16px}d{left:36px;width:16px}e{top:40px;height:8px}f{left:40px;width:8px;}d,f,a{height:72px;top:8px}a,c,e{left:8px;width:100px

<a><c><d><e><f


Title: Draw the national flag of Iceland

Body:
R, 258 bytes

plot(c(0,250),c(0,180),type="n",ann=F)
rect(0,110,70,180,col="blue")
rect(0,0,70,70,col="blue")
rect(110,0,250,70,col="blue")
rect(110,110,250,180,col="blue")
rect(0,80,250,100,col="red",border="transparent")
rect(80,0,100,180,col="red",border="transparent")


问:
Can I live here?
In the game Terraria, one of the game mechanics involves building houses so that an NPC can move in. There is a strict set of rules for what counts as a valid house or not. Here is the list of rules:

The total area in the house must be at least 60 square tiles, but less than 750. Also, the size of the house including the outer frame must be at least one of these:

```<code>5x12
6x10
7x9
8x8
9x7
10x6
12x5
15x4
</code>```

for simplicity's sake, you can safely assume that: a) All input houses will be rectangles, and b) no solid tile # will be inside of the house. Here is our 12x6 frame (drawn in beautiful ASCII):

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

The house must be covered in background walls. These are not solid tiles, but rather a wall behind the house in the third dimension. Holes are allowed, but no holes can be larger than 4x4. If there is a row or column of 5 or more space characters in a row, this is a hole larger than 4x4, and the house is invalid. Multiple holes are also allowed, but there must be at least a single wall apart.

```<code>############
#**********#
#**********#
#**********#
#**********#
############

############
#*    *    #
#*    *    #
#*    *    #
#******    #
############  (Still acceptable since neither hole is larger than 4x4 and there is a separator)

############
#    ******#
#***    ***#
#    ******#
#***    ***#
############  (Also still valid. No row or column of blank spaces is longer or taller than 4.)
</code>```

There must be an entrance. This can be a door | on the sides or a platform - on the floor or ceiling. If the only entrance is on a corner, the NPC is unable to enter. Also, if you have a platform as the floor, you must have at least a single solid block for the NPC to stand on. This solid block cannot be directly adjacent to the side walls on the left or the right. These are all valid houses with entrances:

```<code>############
#**********#
|**********#
#**********#
#**********|
############  (Multiple doors, or doors up high are okay)

############
#**********#
#**********#
#**********#
#**********#
#######----#

#----#######
#**********#
#**********#
#**********#
#**********#
############
</code>```

There must be at least one light source $, table T and chair C, although more is allowed. The light source can be in the air or on the ground, but the table and chair both must be on the ground, e.g on the lowest row.

```<code>############
#**********#
#**********#
#***$******|
#****TC****|
############
</code>```

Also, you can assume that there is a wall behind any furniture, so a torch, chair or table can count as a separator between two holes.

```<code>############
#*    *    #
#*    *    #
#*    $    #
#**TC******|
############
</code>```

The challenge

You must write the shortest function that takes a house as an ASCII string, and returns true/false whether or not it is valid housing. You can take this as a newline delimited string, a list of strings, or any other way as long as it is reasonable. For my sake, please include a short program so I can test if it works right or not.

For reference, these are all invalid inputs:

```<code>############
-**********#
-****$*****#
-**********#
-******TC**#
############  (You can't have platforms on the sidewalls)

###########-
#**********#
#**********#
#****$*****#
#**T***C***#
###########|  (NPC can't enter because the only entrances are on the corner)

############
#**********#
#******$***#
#**********#
#T****C****#
##--------##  (NPC has nowhere to stand)

############
#**********#
#**********#
#**********#
#**$**TC***#
##########|#  (Door cannot be in the floor or ceiling)

############
#**********#
#**********#
#**********#
|**   T C  #
############  (Since table and chair do not count as a background wall, the hole in background is too wide)

####### ####
#**********#
#**********#
#****$*****#
#**T***C***|
############  (There's a hole in the frame.)

###########################################################################
#                                                                         #
#                                                                         #
#                                                                         #
#                                                                         #
#                                                                         #
#                                                                         #
#                                                                         #
#                                                                         #
#                                                                         #
###########################################################################  (House is 75x11, which is too big.)
</code>```

Leaderboard

var QUESTION_ID=68237,OVERRIDE_USER=31716;function answersUrl(e){return"http://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"http://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

```

答:
Python 2, <s>503</s> 439 bytes

Not super short, but it's a solution. Let me know if you see something to golf. I'd recommend looking at my ungolfed version as well, since it's actually readable.

Edit: All the ifs outside a loop have been combined at the bottom.

def f(s):
 s=s.split("\n");e=l=0;h=len(s);w=len(s[0])
 for c in s[0][1:-1]+s[-1][1:-1]:
    if(c in"#-")<1:return 0
    if"-"==c:e=1
 for r in s[1:-1]:
    if(r[0]in"#|")*(r[-1]in"#|")<1or" "*5in r:return 0
    if"$"in r:l=1
 for r in zip(*s):
    if" "*5in`r`[2::5]:return 0
 if(h*w<60)+(h*w>749)+(w<5)+(h<4)or" "in s[0][0]+s[0][-1]+s[-1][0]+s[-1][-1]or("T"in s[-2])*("C"in s[-2])*l<1or("#"in s[-1][2:-2])<1or"|"in"".join(s[1:-1])<1>e:return 0
 return 1
```
<p><strong>Try it online</strong></p>
<h3>Ungolfed:</h3>
<p>Also outputs the reason the result is <code>False</code>, for debugging purposes.</p>
<pre class="lang-python prettyprint-override"><code>def f(s):

    # check dimensions
    s=s.split("\n")
    h=len(s)
    w=len(s[0])
    if h*w < 60 or h*w > 749 or w<5 or h<4: return False,"Size"

    # top / bottom
    e=0
    for c in s[0][1:-1]+s[-1][1:-1]:
        if(c in"#-")<1:return False,"T/B"

        # entrance
        if"-"==c:e=1

    # no spaces in corners -_-
    if" "in s[0][0]+s[0][-1]+s[-1][0]+s[-1][-1]: return False,"Corner"

    # light, table, chair
    l=t=c=0

    # left / right
    for r in s[1:-1]:
        if(r[0]in"#|")*(r[-1]in"#|")<1: return False,"L/R"

        # walls, put above
        if" "*5in r: return False,"Walls"

        # light
        if"$"in r:l=1

    # table, chair
    if"T"in s[-2]:t=1
    if"C"in s[-2]:c=1

    if l*t*c<1: return False,"L/T/C"

    # wall columns
    for r in zip(*s): # Transpose
        if" "*5in`r`[2::5]: # Tuple to string
            return False,"Walls"

    # entrance
    if"|"in"".join(s[1:-1])<1>e: return False,"Entrance"

    # place to stand
    if("#"in s[-1][2:-2])<1: return False,"Stand"

    return True
</code>```

Ungolfed version online

Title: Can I live here?

Body:
Python 2, <s>503</s> 439 bytes

Not super short, but it's a solution. Let me know if you see something to golf. I'd recommend looking at my ungolfed version as well, since it's actually readable.

Edit: All the ifs outside a loop have been combined at the bottom.

def f(s):
 s=s.split("\n");e=l=0;h=len(s);w=len(s[0])
 for c in s[0][1:-1]+s[-1][1:-1]:
    if(c in"#-")<1:return 0
    if"-"==c:e=1
 for r in s[1:-1]:
    if(r[0]in"#|")*(r[-1]in"#|")<1or" "*5in r:return 0
    if"$"in r:l=1
 for r in zip(*s):
    if" "*5in`r`[2::5]:return 0
 if(h*w<60)+(h*w>749)+(w<5)+(h<4)or" "in s[0][0]+s[0][-1]+s[-1][0]+s[-1][-1]or("T"in s[-2])*("C"in s[-2])*l<1or("#"in s[-1][2:-2])<1or"|"in"".join(s[1:-1])<1>e:return 0
 return 1

Try it online

Ungolfed:

Also outputs the reason the result is False, for debugging purposes.

def f(s):

    # check dimensions
    s=s.split("\n")
    h=len(s)
    w=len(s[0])
    if h*w < 60 or h*w > 749 or w<5 or h<4: return False,"Size"

    # top / bottom
    e=0
    for c in s[0][1:-1]+s[-1][1:-1]:
        if(c in"#-")<1:return False,"T/B"

        # entrance
        if"-"==c:e=1

    # no spaces in corners -_-
    if" "in s[0][0]+s[0][-1]+s[-1][0]+s[-1][-1]: return False,"Corner"

    # light, table, chair
    l=t=c=0

    # left / right
    for r in s[1:-1]:
        if(r[0]in"#|")*(r[-1]in"#|")<1: return False,"L/R"

        # walls, put above
        if" "*5in r: return False,"Walls"

        # light
        if"$"in r:l=1

    # table, chair
    if"T"in s[-2]:t=1
    if"C"in s[-2]:c=1

    if l*t*c<1: return False,"L/T/C"

    # wall columns
    for r in zip(*s): # Transpose
        if" "*5in`r`[2::5]: # Tuple to string
            return False,"Walls"

    # entrance
    if"|"in"".join(s[1:-1])<1>e: return False,"Entrance"

    # place to stand
    if("#"in s[-1][2:-2])<1: return False,"Stand"

    return True

Ungolfed version online


问:
Is case sensitivity important?
Tom is going to implement a new programming language of his invention.  But before actually starting working on it, he wants to know whether his language should be case sensitive or not.

On one hand, case insensitivity seems more easy to implement to him, but he worries that it could cause a lack in the possibilities of combinations of characters that form a variable, meaning that longer variable names should then be used to avoid naming clashes (for an example, you can use Hello, HEllo, heLLo and a bunch of other possibilities if the language is case sensitive, but only HELLO if not).

But Tom is a meticulous person, so just a worry isn't enough for him. He wants to know the numbers.

The challenge

Write a function (or a full program if your language doesn't support them) that, given an integer n as the input, outputs (or returns) the difference in the number of permutations possible for a string of length n with case sensitivity and without.

In Tom's language, variable names can include all alphabet letters, underscores and, starting from the second character, digits.

Testcases

```<code>Input (length of the variable) -> Output (difference between the possibilities with case sensitivity and the possibilities with case insensitivity)
0 -> 0
1 -> 26
2 -> 2340
5 -> 784304586
8 -> 206202813193260
9 -> 13057419408922746
</code>```

Non-competing C++ reference implementation

void diff(int n) {
    long long total[2] = {0, 0}; //array holding the result for case insensivity ([0]) and case sensitivity ([1])

    for (int c = 1; c <= 2; c ++) //1 = insensitivity, 2 = sensitivity
        for (int l = 1; l <= n; l ++) //each character of the name
            if (l == 1)
                total[c - 1] = 26 * c + 1; //first character can't be a number
            else
                total[c - 1] *= 26 * c + 1 + 10; //starting from the second character, characters can include numbers

    std::cout << total[1] - total[0] << std::endl;
}
```

Scoring

Tom likes golf, so the shortest program in bytes wins.

Note

It's okay if maybe the last two testcases aren't right because of numerical precision. After all, I am not even sure my code handled number 9 correctly.

Title: Is case sensitivity important?

Body:
Factor, 54 bytes

[ 1 - [ 63 swap ^ 53 * ] [ 37 swap ^ 27 * ] bi - ⌊ ]

Test output (too lazy to make a test suite right now)

To 100 because I can:

0   0
1   26
2   2340
3   173394
4   11884860
5   784304586
6   50726849940
7   3244471004034
8   206202813193260
9   13057419408922746
10  825083183338785540
11  52071473691679633074
12  3283878468805254213660
13  207009241705220196670506
14  13046203459736972095009140
15  822081803558828931061964514
16  51797480091236011152730146060
17  3263475325027970876967575323866
18  205607606410125945699743561920740
19  12953599658372394455762938112142354
20  816088635295235866150191568376990460
21  51414022725857535138635748098295218826
22  3239099663712558709867478263942757120340
23  204063879397281956578587897577149556950594
24  12856046623614221305157697924464388847546860
25  809931759486357889731081403194103267502851386
26  51025731268991039110785546457483836346653407940
27  3214622195536403670115403894902928918116194213234
28  202521239965622254844299280697898069287570327415260
29  12758839658766868529390921590771079620628184030477546
30  803806955516821376897030535770307562553491969842783540
31  50639840307096567147692815348943369659664900009235194274
32  3190310017399946085222303356013750037654300219219990995660
33  200989533984152510500958383022988009088751140000471861713306
34  12662340747855976725442649179430749571102940189045387160447140
35  797727471068538170566530927116489907924415111563438806390997714
36  50256830823601535309646277474395913542200557575679083168097488060
37  3166180347299391055374044156331053378848244132513532459112333134666
38  199469362080123926730618942840288463417954913542445303046398068798740
39  12566569818457512122984997355621160915700234281355486142448958342967554
40  791693898836982339089426979801403683342770524668108612843741935926892460
41  49876715636873773150264669144187442239779806356971223086325671695231877626
42  3142233085498371482609012624501672238105982542695761132093804716877601438340
43  197960684400284383047634318675066295949671525651476192195155330966174637087794
44  12471523117731734378801823439793231607942107258123800020604874301575774756008860
45  785705956436110540996146747147743624935526399518788998053580353675424396549238186
46  49499475256178381262627624276616339615439587933192321957328073370569308698667165940
47  3118466941165264455200744360060243571819246756040935041269911532639516601510442382434
48  196463417294374638796889443817231669538334996131822201644459414237154601574451074437260
49  12377195289581232434616009278422739187922835424850800583245777641132746959324266250272346
50  779763303244935960426051634304306897098424666501802506291342869526467319662381170513981540
51  49125088104479743237515245802427284662794337274853034469588379271166298804053252422013315474
52  3094880550584028599998398220679389089143005829869601804793717698250434558272314733733240577660
53  194977474686860578513191784102480908365326982799277757130761257743954813314983341977611019396106
54  12283580905274687184722912157844434869740351690501733906101969819773718376165568553428918153085140
55  773865597032396709958041167041560489574457972145056938738392490176213167779330685193080529096190914
56  48753532613044375168215008464220671276081037423946152138715557367728779243091128221265244694777630060
57  3071472554621920785909306886048189626410042209324487489672362842172125030215492994941453756154541985466
58  193502770941185640073821503874720577896459322697230268331890319993036718605903879610376090231927542876740
59  12190674569294866655427556036093727770484123879787646494762754214200448415158073789829080317596516919552754
60  768012497865582938530677678077399109971765706771520893994639085516276250445445435611121365429028589509594460
61  48384787365531959679266134687605431564178077913367085420171928478326379788811073557020550322585378011481976426
62  3048241604028522138211603801162125831073621928852293338115689139494198039092774045292531129443472159001332956340
63  192039221053797215808791020159404322131263093269170657697148148666441012621558792067838210142400699755368808584994
64  12098470926389236476707853555431516900893696610762369998567143482483125633030622907206930951507336372904773737270860
65  762203668362522337620493487551580215201395390665800196764662013706838562882208746410562227308797606160712680915464986
66  48018831106838923534843342117447155624156332266892935209806189913015690437626492644356866682916159530830240509968123940
67  3025186359730852784490963892261982080781180571047313262322191837350928353684220676552666116434808733122402791782863511634
68  190586740663043747689376558750428888318209646590603894258160955047853260958314713301270755405603305445874988549550654259260
69  12006964661771756928289219042180208601520032747949102211343066331920312103393552933082810823150791387679177947309210580307146
70  756438773691620716964985145770771121482256588592212543618533446975485259045523696603018951464617833773583196421918482952379540
71  47655642742572106296656344989755045898082462523751897107212657077842278391541997773285863117697288652678155847014078432541996674
72  3002305492782042738420254124183837105633106144366742271546464242884371700319084040546949135905704694741593153841915859492202959660
73  189145246045268694064519472247264698574880394293808554997733720639986819101224007245165566663218089624766534104801769122964901718906
74  11916150500851927783194334861253945564257269006861979264798563913835211476678615826001618230525611319033999768874671043820165072923140
75  750717481553671452455038596317020544047680701587330184780139088571711872342908421711680887160599764988069185889174180556385321385544114
76  47295201337881301582877865070119107294484376103737744811768456374021309282152988680758316620704776514138665127670559852493727353570572060
77  2979597684286522002615091538996935841273293894973707820454341421941470553783979337065903514099119599226677240459390970372438551207353876266
78  187714654110050886271820850421245945023886308799558098889201870386303383441699317091742715367049125868210495633339022021080976659562384154740
79  11826023208933205839086306664722737056380582810772096959441117184084770483299475874473650445339864801023664915823061850169943403091896529897954
80  745039462162791968009016264140349407787379295265439767433382158538003861527346479306512775013394967703567826260992924685854583715749735525096460
81  46937486116255893989991445578566240700314790994634218730880971697698786156163569667253198313252271919170619707315735295839320298967762741317515226
82  2957061625324121321570127646145469600479097962199681775200883358217791614396112323461838552769003522200045367717199022141204995255363640622751674340
83  186294882395419643266342704970909052975476018411475813658404790794443290909593951451816650008709306376417822233966923239519043908642509112264039442194
84  11736577590911437526054302953925815658830824491260123147847219971438656837802057319192119334366383427393476471247901403340755546923998264934769791332860
85  739404388227420564151585450105392563397247850208862193146980429802018372669942231085027322266336949575917703497413242262756663341354137752789503193531786
86  46582476458327495541925964824938180038990133131758872257066173226778328178077627497465902058225655188337576695262466055088365154255573819716001935756281940
87  2934696016874632219155250798298147938620028574339029453481005940809327991114127409087391517619734089372293502673776337794350733176860886869847861631505600834
88  184885849063101829807295655822883896191116857103773014116879344289312516128313791212146134064249406693214458990720825405024094143116346113226785650902666881260
89  11647808490975415277878675971455406774188399103593023755623709580904708065544348130631903778853340506994629744339509897103777855276371884029063199627227132581946
90  733811934931451162507061423422398315397346516450407479655925206552083331459335365747677739381568683697580070526580745691266622080032985612974682610468596757977540
91  46230151900681423237970948652777278349101493334565409591233653622119458645149661082264806229649731647953525118602676998977756027354075699625721942715793229749237874
92  2912499569742929663993134687280117361718934603610641124045403705739039618883255370668643812466536563096293367462807981691433106666850680498728209106577023932078141660
93  183487472893804568831603187418387900340137879398192142647374723980743503786481677084105117925340131838249669694817958084526161366922717594045263062187188374662340681706
94  11559710792309687836392321785788836463846951378802809804587636359996649027031299439381903065674516455247507129925990403129885565051842823161990850791287794680559919961140
95  728261779915510333692765148706621450691833741003095095947733154400551795376841154655141276683483798209790732933978380017958074358887427604479576881170443366718075867057314
96  45880492134677151022646012787988367271956130436320159940279535084902990655674156472314911622261081963797134173540354372100044183752897139657357014922552487271422413276314060
97  2890471004484660514426765717163702125632948593353801325373787525582612830543998915730356846276907462752691218884931833388144147044723120219693807782246945239322406481520807066
98  182099673282533612408888715907569328452365119288317839716587156275352411836023432836069625636200164217658002129970617297449211712144308789428081576440224676102555002804992632740
99  11472279416799617581760080704048343190386108757724073082212416905402170675604281811039500754948545126089276981776285626117157164453181285710701891703604838257394970772074262003154
100 722753603258375907650888473624290214416147782711338423841877029262370595570657559163071778136871929817566895212667053691361603944309744782913331015678320105744441365668988373398460


问:
Code golf for the lazy
Your goal in this code golf is to take two strings, language and code (if the golfed code you wrote for this is multiline, then this variable would be multiline.), and one integer, bytes. They represent the variables for a programming language, number of bytes it takes, and the code itself.

After that, you are going to format it like a code golfer does it.

The output variable is a multiline string called answer.

You can use multiline strings on:

C++

Python

Perl

JavaScript

If you search Stack Overflow, you should be able to find more programming languages that support it.

Here is a template of the output markdown. The code variable is in a code block, and there is a second-level header.

```<code>## {language}, {bytes} bytes

     {code}
</code>```

Here is what the output would look like when pasted into a Markdown parser.

{language}, {bytes} bytes

```<code>    {code}
</code>```

Variables are assumed to be filled out already as the language you coded your code golf entry in, the number of bytes it takes, and the actual code for it.

Here is another example of the output as code, this time with variables filled out:

```<code>## JavaScript, 1337 bytes

document.getElementById("foo").innerHTML = bar;
</code>```

Here is the version as a blockquote:

JavaScript, 1337 bytes

```<code>    document.getElementById("foo").innerHTML = bar;
</code>```

Bytes can be taken off from your code if you use a way to set the text of a
 element in HTML by the id result, like the following JavaScript code:

```<code>document.getElementById("result").innerHTML = answer;
</code>```

Make sure to also include the

 in the HTML section of JSFiddle for this to work.

Scoring

Like all code-golf questions, the code that uses the least amount of bytes is the best.

答:
Emacs Lisp, 97 bytes

```<code>(lambda(l c)(format"## %s, %s bytes\n\n%s"l(string-bytes c)(replace-regexp-in-string"^""    "c)))
</code>```

Also, since it can sometimes be tough to escape quotes and what not, a usage example that copies the string to the clipboard. (Mark region and use M-:)

Emacs Lisp, 184 bytes

```<code>(kill-new ((lambda(l c)(format"## %s, %s bytes\n\n%s"l(string-bytes c)(replace-regexp-in-string"^""    "c)))"Emacs Lisp"(buffer-substring-no-properties(region-beginning)(region-end))))
</code>```

Title: Code golf for the lazy

Body:
Emacs Lisp, 97 bytes

(lambda(l c)(format"## %s, %s bytes\n\n%s"l(string-bytes c)(replace-regexp-in-string"^""    "c)))

Also, since it can sometimes be tough to escape quotes and what not, a usage example that copies the string to the clipboard. (Mark region and use M-:)

Emacs Lisp, 184 bytes

(kill-new ((lambda(l c)(format"## %s, %s bytes\n\n%s"l(string-bytes c)(replace-regexp-in-string"^""    "c)))"Emacs Lisp"(buffer-substring-no-properties(region-beginning)(region-end))))


答:
Python 3, 36 bytes

```<code>lambda n:n and 53*63**~-n-27*37**~-n
</code>```

An anonymous function that takes input via argument and returns the output.

Hooray for operator precedence!

How it works

```<code>lambda n:   Function with input string length n
n and ...   Base case: return 0 if n=0

(Case sensitive)

53*...      The first character can be any of [a-z], [A-Z] and _ , giving 53 possibilities
...63**~-n  63^(n-1): the remaining n-1 characters can be any of above and [0-9], giving
            63 possibilities

(Case insensitive)

27*...      The first character can be any of [A-Z] and _ , giving 27 possibilities
...37**~-n  37^(n-1): the remaining n-1 characters can be any of above and [0-9], giving
            37 possibilities
...-...     Subtract the case insensitive value from the case sensitive value
:...        Return the above
</code>```

Try it on Ideone

Title: Is case sensitivity important?

Body:
Tom is going to implement a new programming language of his invention.  But before actually starting working on it, he wants to know whether his language should be case sensitive or not.

On one hand, case insensitivity seems more easy to implement to him, but he worries that it could cause a lack in the possibilities of combinations of characters that form a variable, meaning that longer variable names should then be used to avoid naming clashes (for an example, you can use Hello, HEllo, heLLo and a bunch of other possibilities if the language is case sensitive, but only HELLO if not).

But Tom is a meticulous person, so just a worry isn't enough for him. He wants to know the numbers.

The challenge

Write a function (or a full program if your language doesn't support them) that, given an integer n as the input, outputs (or returns) the difference in the number of permutations possible for a string of length n with case sensitivity and without.

In Tom's language, variable names can include all alphabet letters, underscores and, starting from the second character, digits.

Testcases

```<code>Input (length of the variable) -> Output (difference between the possibilities with case sensitivity and the possibilities with case insensitivity)
0 -> 0
1 -> 26
2 -> 2340
5 -> 784304586
8 -> 206202813193260
9 -> 13057419408922746
</code>```

Non-competing C++ reference implementation

void diff(int n) {
    long long total[2] = {0, 0}; //array holding the result for case insensivity ([0]) and case sensitivity ([1])

    for (int c = 1; c <= 2; c ++) //1 = insensitivity, 2 = sensitivity
        for (int l = 1; l <= n; l ++) //each character of the name
            if (l == 1)
                total[c - 1] = 26 * c + 1; //first character can't be a number
            else
                total[c - 1] *= 26 * c + 1 + 10; //starting from the second character, characters can include numbers

    std::cout << total[1] - total[0] << std::endl;
}
```

Scoring

Tom likes golf, so the shortest program in bytes wins.

Note

It's okay if maybe the last two testcases aren't right because of numerical precision. After all, I am not even sure my code handled number 9 correctly.

Body:
Python 3, 36 bytes

lambda n:n and 53*63**~-n-27*37**~-n

An anonymous function that takes input via argument and returns the output.

Hooray for operator precedence!

How it works

lambda n:   Function with input string length n
n and ...   Base case: return 0 if n=0

(Case sensitive)

53*...      The first character can be any of [a-z], [A-Z] and _ , giving 53 possibilities
...63**~-n  63^(n-1): the remaining n-1 characters can be any of above and [0-9], giving
            63 possibilities

(Case insensitive)

27*...      The first character can be any of [A-Z] and _ , giving 27 possibilities
...37**~-n  37^(n-1): the remaining n-1 characters can be any of above and [0-9], giving
            37 possibilities
...-...     Subtract the case insensitive value from the case sensitive value
:...        Return the above

Try it on Ideone


问:
Finding "sub-palindromes".
The shortest code that finds all unique "sub-palindromes" of a string, that is: any substring with length > 1 that is a palindrome.

eg.1

```<code>input: "12131331"
output: "33", "121", "131", "313", "1331"
</code>```

eg.2

```<code>input: "3333"
output: "33", "333", "3333"
</code>```

答:
Golfscript, 48 characters

subpalindrome.gs

```<code>{,}{(;}/{{,}{);}/}%{+}*{.,1>\.-1%=*},.&{`}%", "*
</code>```

Usage:

```<code>echo "12131331" | ruby golfscript.rb subpalindrome.gs
</code>```

The first operation {,}{(;}/ turns a string into a list of trailing-substrings. A similar leading-substrings transform is then mapped over the result. Then flatten with {+}*, filter for palindromes using the predicate .,1>\.-1%=*, grab unique values with .&, then pretty print.

It would be neater to extract the trailing-substrings transform as a block and reuse it as a replacement for leading-substrings after reversing each trailing substring, but I can't figure out a succinct way of doing that.

ContentLicense: CC BY-SA 2.5

Title: Finding "sub-palindromes".

Body:
Golfscript, 48 characters

subpalindrome.gs

{,}{(;}/{{,}{);}/}%{+}*{.,1>\.-1%=*},.&{`}%", "*

Usage:

echo "12131331" | ruby golfscript.rb subpalindrome.gs

The first operation {,}{(;}/ turns a string into a list of trailing-substrings. A similar leading-substrings transform is then mapped over the result. Then flatten with {+}*, filter for palindromes using the predicate .,1>\.-1%=*, grab unique values with .&, then pretty print.

It would be neater to extract the trailing-substrings transform as a block and reuse it as a replacement for leading-substrings after reversing each trailing substring, but I can't figure out a succinct way of doing that.


答:
ZX Spectrum BASIC, <s>210</s> <s>141</s> 92 bytes

```<code>1 LET n=-VAL "8.5": FOR y=n TO -n: FOR x=n TO VAL "16": LET p=VAL "271"(PI-(ABS x<SQR PI OR ABS y>SQR PI)-NOT INT ABS x*INT ABS y): PRINT PAPER p; BRIGHT p>PI;" ";: NEXT x: PRINT : NEXT y
</code>```

Size determined as the size of the BASIC program on tape via SAVE. A lot of the golfing credit to some members of the ZX Spectrum group on Facebook, in particular @impomatic and Johan Koelman.

Title: Draw the national flag of Iceland

Body:
ZX Spectrum BASIC, <s>210</s> <s>141</s> 92 bytes

1 LET n=-VAL "8.5": FOR y=n TO -n: FOR x=n TO VAL "16": LET p=VAL "271"(PI-(ABS x<SQR PI OR ABS y>SQR PI)-NOT INT ABS x*INT ABS y): PRINT PAPER p; BRIGHT p>PI;" ";: NEXT x: PRINT : NEXT y

Size determined as the size of the BASIC program on tape via SAVE. A lot of the golfing credit to some members of the ZX Spectrum group on Facebook, in particular @impomatic and Johan Koelman.


答:
Python, <s>119</s> <s>118</s> <s>114</s> 112 bytes

Nothing special, straightforward:

b,w,r="\0H\xe0"*28,"\xff"*12,"\xd7(("*8
A,B=28*(b+w+r+w+2*b),4*(8*w+r+15*w)
print"P6 100 72 255 "+A+B+100*r+B+A
```

<p>Output as binary PPM, usage</p>

<pre class="lang-python prettyprint-override"><code>python golf_iceland.py > iceland.ppm
</code>```

Edit1: shoved a byte between print and the quotation mark

Edit2: slighty shorter as binary PPM

Edit3: Figured that \0 can be used instead of \x00

If someone knows how to use the non-printable ASCII-character directly, please let know.

Title: Draw the national flag of Iceland

Body:
Python, <s>119</s> <s>118</s> <s>114</s> 112 bytes

Nothing special, straightforward:

b,w,r="\0H\xe0"*28,"\xff"*12,"\xd7(("*8
A,B=28*(b+w+r+w+2*b),4*(8*w+r+15*w)
print"P6 100 72 255 "+A+B+100*r+B+A

Output as binary PPM, usage

python golf_iceland.py > iceland.ppm

Edit1: shoved a byte between print and the quotation mark

Edit2: slighty shorter as binary PPM

Edit3: Figured that \0 can be used instead of \x00

If someone knows how to use the non-printable ASCII-character directly, please let know.


答:
GLSL, <s>266</s> 265 bytes (non-competing)

Just for fun!

Only input it takes is the uniform which is the resolution of the texture it draws to. Needs an existing OpenGL context.
The function r masks a rectangular area. The colors and the proportions are a bit off but looks believable.

```<code>#define r(p,w,h)step(abs(p.x),w)*step(abs(p.y),h)
uniform vec2 R;void main(){vec2 p=-1.+2.*gl_FragCoord.xy/R;p.y*=R.y/R.x*1.39;vec2 q=p;p.x+=.3;p=mod(p,2.)-1.;gl_FragColor.rgb=mix(mix(vec3(.83,.15,.15),vec3(1.),r(p,.9,.85)),vec3(0.,.28,.95),r(p,.8,.7))*r(q,1.,1.);}
</code>```

Title: Draw the national flag of Iceland

Body:
GLSL, <s>266</s> 265 bytes (non-competing)

Just for fun!

Only input it takes is the uniform which is the resolution of the texture it draws to. Needs an existing OpenGL context.
The function r masks a rectangular area. The colors and the proportions are a bit off but looks believable.

#define r(p,w,h)step(abs(p.x),w)*step(abs(p.y),h)
uniform vec2 R;void main(){vec2 p=-1.+2.*gl_FragCoord.xy/R;p.y*=R.y/R.x*1.39;vec2 q=p;p.x+=.3;p=mod(p,2.)-1.;gl_FragColor.rgb=mix(mix(vec3(.83,.15,.15),vec3(1.),r(p,.9,.85)),vec3(0.,.28,.95),r(p,.8,.7))*r(q,1.,1.);}


问:
Write a program that reverses the name of its source file
In a single file, write a program that requires no input and produces no output. When run it should reverse the name of the file it is contained in, regardless of what the name is, without altering the code or producing other lasting side effects.

Any way of achieving this is fine. It only matters that once the program is run the only lasting change is that its file name has been reversed. e.g. no new files should be in the directory.

Running the program again should reverse the name back. Indeed, the program should be able to be run arbitrarily many times.

For the purposes of this challenge:

You may assume filenames are always strings of lowercase letters (a-z) between 1 and 127 characters long. (If your language requires files to have extensions to run then just reverse the part before the extension, e.g. mycode.bat → edocym.bat.)

You may assume the code file is in a directory by itself so it will not have naming conflicts (except with itself).

You may not assume the filename is not a palindrome, i.e. the same when reversed. Filenames that are palindromes should work just as well as those that aren't.

You may read your file's contents or metadata. There are no quine restrictions here.

You may assume your program will be run on a particular, modern, commonplace operating system (e.g. Windows/Linux), since not all shells have the same command set.

As a concrete example, say you have a Python program in a file called
  mycode in its own directory. Running

```<code>python mycode
</code>```

in the terminal should result in the filename being reversed to
  edocym. The file edocym should be alone in its directory - no file
  named mycode should exist anymore. Running

```<code>python edocym
</code>```

will reverse the name back to mycode, at which point the process can
  be repeated indefinitely.

If the same Python file was renamed racecar (without changing the code) and then run

```<code>python racecar
</code>```

nothing should visibly change since "racecar" is a palindrome.
  That same goes if the filename were, say, a or xx.

The shortest code in bytes wins. Tiebreaker is higher voted answer.

答:
PowerShell, 50 bytes

```<code>mv *(-join($f=(ls).BaseName)[$f.Length..0]+'.ps1')
</code>```

There is only one file, so mv * shell wildcard will only have one result. The destination name is (ls).basename which lists all the files (alias for 'dir'), calls for the BaseName property - and since there's only one file, PowerShell will unpack the 1-item array into a string. Store that filename in $f, then index it with a countdown and -join the reversed characters back up into a string. Add the mandatory .ps1 suffix.

Body:
PowerShell, 50 bytes

mv *(-join($f=(ls).BaseName)[$f.Length..0]+'.ps1')

There is only one file, so mv * shell wildcard will only have one result. The destination name is (ls).basename which lists all the files (alias for 'dir'), calls for the BaseName property - and since there's only one file, PowerShell will unpack the 1-item array into a string. Store that filename in $f, then index it with a countdown and -join the reversed characters back up into a string. Add the mandatory .ps1 suffix.


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

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

The Rules

Each submission must be a full program.

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

The program must not write anything to STDERR.

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

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

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

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

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

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

For inspiration, check the Hello World Collection.

The Catalogue

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

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

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

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

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

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

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

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

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

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

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

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

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

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

```<code>print Hello, World!
</code>```

Seems legit!

ContentLicense: CC BY-SA 4.0

Title: "Hello, World!"

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

print Hello, World!

Seems legit!


问:
Run Stackylogic
Stackylogic is a logic-based programming language I made up that take in 0's and 1's for input and outputs a single 0 or 1 upon completion.

A Stackylogic program consists of lines that can only contain the three characters 01? as well as exactly one < at the end of one of the lines. Lines may not be empty and the line with the < must have at least one 0, 1, or ? before it.

Here's a sample program that (as I'll explain) computes the NAND of two bits:

```<code>1
?<
11
?
0
</code>```

Every line in a Stackylogic program is considered a stack, with the bottom on the left and the top on the right. Implicitly, there is an empty stack (empty line) before the first line in a program and after the last line.

The <, which we'll call the cursor, marks the stack to start on when a Stackylogic program is run. Execution of a Stackylogic program proceeds as follows:

Pop the top character off the stack the cursor is currently pointing to.

If the character is ?, prompt the user for a 0 or a 1 and act as if that was the character.

If the character is 0, move the cursor one stack up (to the line above the current line).

If the character is 1, move the cursor one stack down (to the line below the current line).

If the stack the cursor moves to is empty, output the last value that was popped off a stack (always a 0 or 1), and end the program.

Else, if the stack the cursor moves to is not empty, go back to step 1 and repeat the process.

Notice that Stackylogic programs always end because they must eventually deplete their stacks.

NAND Example

In the NAND program the cursor starts on a ?:

```<code>1
?<
11
?
0
</code>```

We'll assume the user inputs a 1 once the ? is popped, which means the cursor will move down, making the program look like this:

```<code>1

11<
?
0
</code>```

Now a plain 1 is at the top of the cursor stack. It is duly popped and the cursor moves again:

```<code>1

1
?<
0
</code>```

Now assume the user inputs 0 for the ?, which means the cursor will move up:

```<code>1

1<

0
</code>```

Again, a 1 is on the cursor stack so the cursor pops and moves down:

```<code>1

<
0
</code>```

Finally the cursor stack is empty, so the last value popped, the 1, is output and the program ends.

This is accurate for a NAND gate because 1 NAND 0 is 1. This of course works for the other three two-bit inputs if you care to check.

OR Example

This Stackylogic program simulates an OR gate:

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

It's easy to see that an initial input of 1 will push the cursor to the implicit empty stack below the last line, ending the program and outputting the 1 that was just input.

For an input of 00 on the other hand, the cursor will make its way to the implicit empty stack at the top, ending the program and outputting the last 0 to be input.

Challenge

Write a program or function that takes in a Stackylogic program as a string and runs it, printing or returning the resulting 0 or 1.

Upon ?'s, you may prompt the user for a 0 or 1 input, or read the value from a preset string of 0's and 1's that you also take as input. (This could be another string input to your program/function or you could just assume the first or last line of the program string will be the input stream).

You may assume the program and the input are always well formed. You may optionally assume input programs come with a single trailing newline (though remember there is always an implicit empty stack at the end).

The shortest code in bytes wins.

More Sample Programs

```<code>ZERO
0<

ONE
1<

BUFFER
?<

NOT
1
?<
0

AND
?<
?

NAND
1
?<
11
?
0

OR
?
?<

NOR
1
?
00
?<
0

XOR(v1)
?
0
1?<
?
0

XOR(v2)
?
?<
11
?
0

XNOR(v1)
1
?
0?<
1
?

XNOR(v2)
1
?
00
?<
?

MEDIAN(v1)
1
???<
0

MEDIAN(v2)
?
1?<
??
</code>```

Thanks Martin for the median programs.

答:
32-bit x86 machine code, 70 bytes

In hex:

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

Input is a NULL-terminated multi-line string (linefeed-separated) passed via ESI. User input is assumed to be the first line. Returns '0'/'1' in AL.

Disassembly:

```<code>fc           cld
89 e1        mov    ecx,esp
56           push   esi
5f           pop    edi                  ;EDI=ESI
31 d2        xor    edx,edx              ;EDX=0
_loop0:
8a 07        mov    al,BYTE PTR [edi]    ;AL=*EDI
a8 df        test   al,0xf5              ;AL&~0x0a==0 => separator ('\n' or '\0')
74 0b        je     _stck
3c 3c        cmp    al,'<'
75 11        jne    _loop0end
42           inc    edx                  ;For "cursor" symbol adjust stack pointer offset
8d 5c 24 fc  lea    ebx,[esp-0x4]        ;and load EBX with the address where this pointer
eb 0a        jmp    _loop0end            ;is going to be stored in the next iteration
_stck:
57           push   edi                  ;Pointer to the separator
29 14 24     sub    DWORD PTR [esp],edx  ;adjusted to point to the top of the stack
84 c0        test   al,al                ;AL==0?
74 05        je     _loop0break          ;break
b2 01        mov    dl,0x1               ;EDX can be [0..2], resets to 1
_loop0end:
47           inc    edi                  ;++EDI
eb e2        jmp    _loop0
_loop0break:
57           push   edi                  ;*EDI==0, add lower implicit empty stack
_loop1:                                  ;The actual state machine code
8b 3b        mov    edi,DWORD PTR [ebx]  ;EDI=*EBX
8a 17        mov    dl,BYTE PTR [edi]    ;DL=*EDI
f6 c2 df     test   dl,0xf5              ;DL&~0x0a
74 14        je     _loop1break          ;ZF==1 => current stack is empty
ff 0b        dec    DWORD PTR [ebx]      ;--(*EBX): pop the stack
92           xchg   edx,eax              ;AL=DL
3c 3f        cmp    al,'?'
75 01        jne    _skplods             ;AL=='?' => substitute char from the input string
ac           lodsb
_skplods:
3c 30        cmp    al,'0'
75 03        jne    _0x31                ;EBX+=AL==0?4:-4
83 c3 08     add    ebx,0x8              ;But to avoid wasting 2 bytes for the jump after the 'add'
_0x31:                                   ;add 8 and fall through to subtract 4 back
83 eb 04     sub    ebx,0x4
eb e3        jmp    _loop1
_loop1break:
89 cc        mov    esp,ecx              ;Clear the stack
c3           ret                         ;Returns '0'/'1' in AL
</code>```

Title: Run Stackylogic

Body:
32-bit x86 machine code, 70 bytes

In hex:

FC89E1565F31D28A07A8DF740B3C3C7511428D5C24FCEB0A5729142484C07405B20147EBE2578B3B8A17F6C2DF7414FF0B923C3F7501AC3C30750383C30883EB04EBE389CCC3

Input is a NULL-terminated multi-line string (linefeed-separated) passed via ESI. User input is assumed to be the first line. Returns '0'/'1' in AL.

Disassembly:

fc           cld
89 e1        mov    ecx,esp
56           push   esi
5f           pop    edi                  ;EDI=ESI
31 d2        xor    edx,edx              ;EDX=0
_loop0:
8a 07        mov    al,BYTE PTR [edi]    ;AL=*EDI
a8 df        test   al,0xf5              ;AL&~0x0a==0 => separator ('\n' or '\0')
74 0b        je     _stck
3c 3c        cmp    al,'<'
75 11        jne    _loop0end
42           inc    edx                  ;For "cursor" symbol adjust stack pointer offset
8d 5c 24 fc  lea    ebx,[esp-0x4]        ;and load EBX with the address where this pointer
eb 0a        jmp    _loop0end            ;is going to be stored in the next iteration
_stck:
57           push   edi                  ;Pointer to the separator
29 14 24     sub    DWORD PTR [esp],edx  ;adjusted to point to the top of the stack
84 c0        test   al,al                ;AL==0?
74 05        je     _loop0break          ;break
b2 01        mov    dl,0x1               ;EDX can be [0..2], resets to 1
_loop0end:
47           inc    edi                  ;++EDI
eb e2        jmp    _loop0
_loop0break:
57           push   edi                  ;*EDI==0, add lower implicit empty stack
_loop1:                                  ;The actual state machine code
8b 3b        mov    edi,DWORD PTR [ebx]  ;EDI=*EBX
8a 17        mov    dl,BYTE PTR [edi]    ;DL=*EDI
f6 c2 df     test   dl,0xf5              ;DL&~0x0a
74 14        je     _loop1break          ;ZF==1 => current stack is empty
ff 0b        dec    DWORD PTR [ebx]      ;--(*EBX): pop the stack
92           xchg   edx,eax              ;AL=DL
3c 3f        cmp    al,'?'
75 01        jne    _skplods             ;AL=='?' => substitute char from the input string
ac           lodsb
_skplods:
3c 30        cmp    al,'0'
75 03        jne    _0x31                ;EBX+=AL==0?4:-4
83 c3 08     add    ebx,0x8              ;But to avoid wasting 2 bytes for the jump after the 'add'
_0x31:                                   ;add 8 and fall through to subtract 4 back
83 eb 04     sub    ebx,0x4
eb e3        jmp    _loop1
_loop1break:
89 cc        mov    esp,ecx              ;Clear the stack
c3           ret                         ;Returns '0'/'1' in AL


答:
JavaScript, 211 bytes

I'm thinking about making a version that shows each step played after each other, displayed on a webpage.

```<code>(x,y)=>{t=0;l=0;n=1;while(t<x.length){c=(l?x:y);if(c[t]=='x'){l=!l;if(l){x=x.slice(0,t-2)+'*'+x.slice(t-1);}else{y=y.slice(0,t-2)+'*'+y.slice(t-1);}}if(c[t]=='X'){l=!l;t++;}if(c[t]=='1'){return n}
</code>```

Used more bytes than I'd hoped to when replacing x with * because of JS immutable Strings. Suggestions to improve are appreciated, especially with the replacement part.

Title: Walk the labyrinth

Body:
Or maybe it's not really a labyrinth, but still.

Rules:

Input is a two-line string, consisting of *, 1, x and X. That string is a labyrinth to walk through. The lines have the equal length.

You could take the input as a string with , (comma) or any convenient separator between these two lines. Or you could take both lines as separate arguments to your function.

Output is the number of steps you have to take to exit the string (last step is the step which moves you out of the string).

You start in the top left corner (the higher line), before the first symbol.

For each step, you move forward by one symbol (from nth to (n+1)th position). Then, depending on the character you step on, the outcome is different. Here's what each char does:

* - nothing. You just step on it normally.

x - once you stepped on it, switch the line, but remain on the same horizontal distance from the beginning. For example, you stepped on the third position of the higher line, and met a lowercase x here. Then you immediately move to the lower line, but again at the third position.

X - switch the line and go to the next position. The example is the same there, but you also move from the third to the forth position (thus you're on the second line at the forth position).

1 - just move forward by yet another position.

Once each character does its job, it's replaced with a space and no longer "works".

Examples follow.

Input:

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

As said before, you start before the first symbol of the first line. The first step moves you on letter x and this letter switches you to the second line. The letter x no longer functions as x, but replaced with *. This will be more relevant in the latter examples. You're now on an asterisk on the lower line, and it did nothing to you.

The second step is moving you forward and you exit the string, so the labyrinth is completed, and it took 2 steps.

Output 2.

Input:

```<code>xX*
x1*
</code>```

1st step: you move on x, which moves you on the x of the lower line. Here comes the rule which says that the used character is replaced with asterisk. Then you move back on the first line, but it's no longer x there, since it has been used and became an asterisk. So you move safely on this asterisk and the step is completed (you are now on the first position of the first line).

2nd step: you move on X, it pushes you to the lower line and then pushes you forward. You now reside on the third position of the second line (asterisk), having never visited the second position (which contains 1).

3rd step: you move forward, exiting the string.

Output: 3.

Test cases:

Input:

```<code>*1*
xxx
</code>```

Output: 3. (because 1 makes you jump on the third position). There you never visit the second line, but it's required part of the input.

Input:

```<code>*X*1*x
x*1xx*
</code>```

Output: 4.

Input:

```<code>1x1x
***X
</code>```

Output: 3.

Input:

```<code>1*x1xxx1*x
x*x1*11X1x
</code>```

Output: 6.

Input:

```<code>xXXXxxx111*
**xxx11*xxx
</code>```

Output: 6.

Body:
JavaScript, 211 bytes

I'm thinking about making a version that shows each step played after each other, displayed on a webpage.

(x,y)=>{t=0;l=0;n=1;while(t<x.length){c=(l?x:y);if(c[t]=='x'){l=!l;if(l){x=x.slice(0,t-2)+'*'+x.slice(t-1);}else{y=y.slice(0,t-2)+'*'+y.slice(t-1);}}if(c[t]=='X'){l=!l;t++;}if(c[t]=='1'){return n}

Used more bytes than I'd hoped to when replacing x with * because of JS immutable Strings. Suggestions to improve are appreciated, especially with the replacement part.


答:
Java 8, <s>449</s> 447 bytes:

```<code>import java.awt.*;import javax.swing.*;class A extends JPanel{public void paintComponent(Graphics G){super.paintComponent(G);G.setColor(new Color(0,72,224));G.fillRect(0,0,175,126);G.setColor(Color.WHITE);G.fillRect(49,0,28,126);G.fillRect(0,49,175,28);G.setColor(new Color(215,40,40));G.fillRect(56,0,14,126);G.fillRect(0,56,175,14);}public static void main(String[]a){JFrame J=new JFrame();J.add(new A());J.setSize(175,147);J.setVisible(true);}}
</code>```

A very late answer, and also the longest one here, apparently. Uses the java.awt.Graphics class to create and open a window with the flag in it, which is created by 5 total rectangles consisting of 1 for the blue blocks, 2 for the white stripes, and 2 for the red stripes. Uses 7 pixels:1 unit ratio. In other words, for each unit, 7 pixels are used. Here is an image of the output on a Macintosh with OS X 10.11:

Now to find a way to golf this down a bit more...

Title: Draw the national flag of Iceland

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

Body:
Java 8, <s>449</s> 447 bytes:

import java.awt.*;import javax.swing.*;class A extends JPanel{public void paintComponent(Graphics G){super.paintComponent(G);G.setColor(new Color(0,72,224));G.fillRect(0,0,175,126);G.setColor(Color.WHITE);G.fillRect(49,0,28,126);G.fillRect(0,49,175,28);G.setColor(new Color(215,40,40));G.fillRect(56,0,14,126);G.fillRect(0,56,175,14);}public static void main(String[]a){JFrame J=new JFrame();J.add(new A());J.setSize(175,147);J.setVisible(true);}}

A very late answer, and also the longest one here, apparently. Uses the java.awt.Graphics class to create and open a window with the flag in it, which is created by 5 total rectangles consisting of 1 for the blue blocks, 2 for the white stripes, and 2 for the red stripes. Uses 7 pixels:1 unit ratio. In other words, for each unit, 7 pixels are used. Here is an image of the output on a Macintosh with OS X 10.11:

Now to find a way to golf this down a bit more...