答:
PHP (CLI-Only), 277 chars

```<code><?f();r(7,25);r(1,25);r(1,25);r(7,25);f();function f(){for($c=0;$c<7;$c++){r(4);b(7);b(1);b(1);b(7);r(4,14);echo"\n";}}function r($c,$w=7){for($i=0;$i<$w;$i++)if($c==7&&$w==25)if($i==8||$i==9)b(1);else b($c);else b($c);if($w==25)echo"\n";}function b($c){echo"\033[01;3{$c}m█";}
</code>```

I'm using console colors and these blocky things to make it look like this:

It looks odd because the height is like 2.5x the width.

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:
PHP (CLI-Only), 277 chars

<?f();r(7,25);r(1,25);r(1,25);r(7,25);f();function f(){for($c=0;$c<7;$c++){r(4);b(7);b(1);b(1);b(7);r(4,14);echo"\n";}}function r($c,$w=7){for($i=0;$i<$w;$i++)if($c==7&&$w==25)if($i==8||$i==9)b(1);else b($c);else b($c);if($w==25)echo"\n";}function b($c){echo"\033[01;3{$c}m█";}

I'm using console colors and these blocky things to make it look like this:

It looks odd because the height is like 2.5x the width.


问:
Unzip some numbers
Your task is to create a program or function that generates a zipper with a length of 10 lines. Each line of the zipper is represented by two dashes --:

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

The program/function will take a percentage (divisible by 10) as input, and the output will be the zipper "unzipped" (dashes separated) from the top by the percentage, revealing the 1-indexed, lowest level repeated 2 times, with all prior levels repeated 4, 6, 8, ...etc. times, while keeping the bottom of the zipper centered.

Examples

```<code>>>10%
-11-
 --
 --
 --
 --
 --
 --
 --
 --
 --

>>50%
-1111111111-
 -22222222-
  -333333-
   -4444-
    -55-
     --
     --
     --
     --
     --

>>100%
-11111111111111111111-
 -222222222222222222-
  -3333333333333333-
   -44444444444444-
    -555555555555-
     -6666666666-
      -77777777-
       -888888-
        -9999-
         -10-
</code>```

The input (percentage) can be formatted however you like (50%, .5, 50, 5 [zero implied], etc), and it will always be in the range of 0 to 100 and divisible by 10. The spacing in the examples must be preserved in your output.

答:
Python 3, <s>98, 90, 87</s>, 85 bytes.

Takes the number already divided by 10. I can probably remove some of the parens, but this is pretty closed to fully golfed.

```<code>lambda n:'\n'.join(' '*min(i,n)+'-%s-'%(str(i+1)*(n>i>8or(n-i)*2))for i in range(10))
</code>```

ContentLicense: CC BY-SA 3.0

Title: Unzip some numbers

Body:
Python 3, <s>98, 90, 87</s>, 85 bytes.

Takes the number already divided by 10. I can probably remove some of the parens, but this is pretty closed to fully golfed.

lambda n:'\n'.join(' '*min(i,n)+'-%s-'%(str(i+1)*(n>i>8or(n-i)*2))for i in range(10))


问:
Shortest infinite loop producing no output
Your task is to create the shortest infinite loop!

The point of this challenge is to create an infinite loop producing no output, unlike its possible duplicate. The reason to this is because the code might be shorter if no output is given.

Rules

Each submission must be a full program.

You must create the shortest infinite loop.

Even if your program runs out of memory eventually, it is still accepted as long as it is running the whole time from the start to when it runs out of memory. Also when it runs out of memory, it should still not print anything to STDERR.

The program must take no input (however, reading from a file is allowed), and should not print anything to STDOUT. Output to a file is also forbidden.

The program must not write anything to STDERR.

Feel free to use a language (or language version) even if it's newer than this challenge.
-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. :D

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 infinite loop program. This is about finding the shortest infinite loop program in every language. Therefore, I will not accept an answer.

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 Brainf**k-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.

There should be a website such as Wikipedia, Esolangs, or GitHub for the language. For example, if the language is CJam, then one could link to the site in the header like #[CJam](http://sourceforge.net/p/cjam/wiki/Home/), X bytes.

Standard loopholes are not allowed.

(I have taken some of these rules from Martin Büttner's "Hello World" challenge)

Please feel free to post in the comments to tell me how this challenge could be  improved.

Catalogue

This is a Stack Snippet which generates both an alphabetical catalogue of the used languages, and an overall leaderboard. To make sure your answer shows up, please start it with this Markdown header:

```<code># Language name, X bytes
</code>```

Obviously replacing Language name and X bytes with the proper items. If you want to link to the languages' website, use this template, as posted above:

```<code>#[Language name](http://link.to/the/language), X bytes
</code>```

Now, finally, here's the snippet: (Try pressing "Full page" for a better view.)

var QUESTION_ID=59347;var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk";var OVERRIDE_USER=41805;var answers=[],answers_hash,answer_ids,answer_page=1,more_answers=true,comment_page;function answersUrl(index){return"//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"//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}#answer-list{padding:10px;width:500px;float:left}#language-list{padding:10px;padding-right:40px;width:500px;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">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
AlphaBeta, 2 bytes

```<code> N
</code>```

 is a no-op, and N moves the IP to the value stored in the position register (initially 0) if the third register is 0 (which it is).

Body:
AlphaBeta, 2 bytes

 N

 is a no-op, and N moves the IP to the value stored in the position register (initially 0) if the third register is 0 (which it is).


问:
Construct the Identity Matrix
The challenge is very simple. Given an integer input n, output the n x n identity matrix. The identity matrix is one that has 1s spanning from the top left down to the bottom right. You will write a program or a function that will return or output the identity matrix you constructed. Your output may be a 2D array, or numbers separated by spaces/tabs and newlines.

Example input and output

```<code>1: [[1]]
2: [[1, 0], [0, 1]]
3: [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
4: [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
5: [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]

1
===
1

2
===
1 0
0 1

3
===
1 0 0
0 1 0
0 0 1

etc.
</code>```

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

答:
K6, 1 byte

```<code>=
</code>```

= is exactly this

Try it online!

Title: Construct the Identity Matrix

Body:
K6, 1 byte

=

= is exactly this

Try it online!


问:
Convert n strings of m length to m strings of n length
Write a program that, given any 'n' number of strings of 'm' length, returns 'm' number of 'n'-length strings, with this condition:

Every new string should contains the letters at the same index of the others strings

For example, the first output string must contain the first letter of all the input strings, the second output string must contain the second letter of all the input strings, and so on.

Examples (the numbers under the letters are the indexes of the strings):

```<code>input: "car", "dog", "man", "yay"
        012    012    012    012
output: "cdmy", "aoaa", "rgny"
         0000    1111    2222

input: "money", "taken", "trust"
        01234    01234    01234
output: "mtt", "oar", "nku", "ees", "ynt"
         000    111    222    333    444
</code>```

Assume that the input is correct everytime

Shortest bytes' code wins!

Edit:

Since there are many programming languages, and there could be many possible solutions for each of them, I will post the shortest solution for each programming language and the user who provided it. Keep coding!

Re-Edit:

Thanks to user Dennis I inserted a snippet for the leaderboards.

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Vim, <s>37</s> 36 keystrokes

All the other answers are boring, and using boring single-byte builtins. Here's a hacky answer that does the entire thing manually, in something that isn't even a programming language:

```<code>Gmaqqgg:s/./&<cr>d<C-v>`aGo<esc>pvGgJ@qq@q`adgg
</code>```

Explanation:

```<code>G                                   "move to the end of this line
     ma                             "And leave mark 'a' here
       qq                           "Start recording in register 'q'
         gg                         "Move to the beginning
           :s/./&<cr>               "Assert that there is atleast one character on this line
                      d             "Delete
                       <C-v>        "Blockwise
                            `a      "Until mark 'a'

    G                               "Move to the end of the buffer
     o<esc>                         "Open a newline below us
           p                        "And paste what we deleted
            vG                      "Visually select everything until the end
              gJ                    "And join these without spaces
                @q                  "Call macro 'q'. The first time, this will do nothing,
                                    "The second time, it will cause recursion.
                  q                 "Stop recording
                   @q               "Call macro 'q' to start it all
</code>```

Now, everything is good, but the buffer has some extra text left over. So we must:

```<code>`a                              "Move to mark 'a'
  dgg                           "And delete everything until the first line
</code>```

Body:
Vim, <s>37</s> 36 keystrokes

All the other answers are boring, and using boring single-byte builtins. Here's a hacky answer that does the entire thing manually, in something that isn't even a programming language:

Gmaqqgg:s/./&<cr>d<C-v>`aGo<esc>pvGgJ@qq@q`adgg

Explanation:

G                                   "move to the end of this line
     ma                             "And leave mark 'a' here
       qq                           "Start recording in register 'q'
         gg                         "Move to the beginning
           :s/./&<cr>               "Assert that there is atleast one character on this line
                      d             "Delete
                       <C-v>        "Blockwise
                            `a      "Until mark 'a'

    G                               "Move to the end of the buffer
     o<esc>                         "Open a newline below us
           p                        "And paste what we deleted
            vG                      "Visually select everything until the end
              gJ                    "And join these without spaces
                @q                  "Call macro 'q'. The first time, this will do nothing,
                                    "The second time, it will cause recursion.
                  q                 "Stop recording
                   @q               "Call macro 'q' to start it all

Now, everything is good, but the buffer has some extra text left over. So we must:

`a                              "Move to mark 'a'
  dgg                           "And delete everything until the first line


Title: Unzip some numbers

Body:
Your task is to create a program or function that generates a zipper with a length of 10 lines. Each line of the zipper is represented by two dashes --:

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

The program/function will take a percentage (divisible by 10) as input, and the output will be the zipper "unzipped" (dashes separated) from the top by the percentage, revealing the 1-indexed, lowest level repeated 2 times, with all prior levels repeated 4, 6, 8, ...etc. times, while keeping the bottom of the zipper centered.

Examples

```<code>>>10%
-11-
 --
 --
 --
 --
 --
 --
 --
 --
 --

>>50%
-1111111111-
 -22222222-
  -333333-
   -4444-
    -55-
     --
     --
     --
     --
     --

>>100%
-11111111111111111111-
 -222222222222222222-
  -3333333333333333-
   -44444444444444-
    -555555555555-
     -6666666666-
      -77777777-
       -888888-
        -9999-
         -10-
</code>```

The input (percentage) can be formatted however you like (50%, .5, 50, 5 [zero implied], etc), and it will always be in the range of 0 to 100 and divisible by 10. The spacing in the examples must be preserved in your output.

Body:
Javascript es7, 105 bytes

A=>[...Array(10)].map((a,i)=>' '.repeat((d=A<i)?A:i)+('-'+(i+1+'').repeat(d?0:i<9?2*(A-i):1)+'-')).join`
`

call with

f=A=>[...Array(10)].map((a,i)=>' '.repeat((d=A<i)?A:i)+('-'+(i+1+'').repeat(d?0:i<9?2*(A-i):1)+'-')).join`
`

f(10)
f(5)
f(0)


答:
Mathematica, 26 bytes

```<code>""<>#&/@(Characters@#)&
</code>```

Anonymous function. Takes a string list as input and returns a string list as output. The Unicode character is U+F3C7, representing \[Transpose]. Works by converting to a character matrix, transposing, and converting back to a string list. If the input/output format was stretched, then a simple 5-byte transpose would work:

```<code>#&
</code>```

Title: Convert n strings of m length to m strings of n length

Body:
Write a program that, given any 'n' number of strings of 'm' length, returns 'm' number of 'n'-length strings, with this condition:

Every new string should contains the letters at the same index of the others strings

For example, the first output string must contain the first letter of all the input strings, the second output string must contain the second letter of all the input strings, and so on.

Examples (the numbers under the letters are the indexes of the strings):

```<code>input: "car", "dog", "man", "yay"
        012    012    012    012
output: "cdmy", "aoaa", "rgny"
         0000    1111    2222

input: "money", "taken", "trust"
        01234    01234    01234
output: "mtt", "oar", "nku", "ees", "ynt"
         000    111    222    333    444
</code>```

Assume that the input is correct everytime

Shortest bytes' code wins!

Edit:

Since there are many programming languages, and there could be many possible solutions for each of them, I will post the shortest solution for each programming language and the user who provided it. Keep coding!

Re-Edit:

Thanks to user Dennis I inserted a snippet for the leaderboards.

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Mathematica, 26 bytes

""<>#&/@(Characters@#)&

Anonymous function. Takes a string list as input and returns a string list as output. The Unicode character is U+F3C7, representing \[Transpose]. Works by converting to a character matrix, transposing, and converting back to a string list. If the input/output format was stretched, then a simple 5-byte transpose would work:

#&


答:
Python 2, 74 bytes

```<code>n=input()
x=0
exec"print' '*x+'-'+`x+1`*(n-x<<1-x/9)+'-';x=min(x+1,n);"*10
</code>```

Saved two bytes by exec-ifying a loop, thanks to Dennis.

EDIT: I took a slightly different approach and saved two more bytes.

Title: Unzip some numbers

Body:
Python 2, 74 bytes

n=input()
x=0
exec"print' '*x+'-'+`x+1`*(n-x<<1-x/9)+'-';x=min(x+1,n);"*10

Saved two bytes by exec-ifying a loop, thanks to Dennis.

EDIT: I took a slightly different approach and saved two more bytes.


答:
Bash + BSD utilities, 27

sed s/./\&:/g|rs -c: -g0 -T
```

<p>I/O via STDIN/STDOUT newline-separated strings.</p>

<p>You may need to install <code>rs</code> with <code>sudo apt install rs</code> or similar.  Works out of the box on OS X.</p>

<p>The <code>-T</code> option to <code>rs</code> does the heavy lifting of the transposition.  The rest is just formatting:</p>

<ul>
<li>The <code>sed</code> command simply inserts <code>:</code> after every character</li>
<li><code>-c:</code> specifies input columns are <code>:</code> separated</li>
<li><code>-g0</code> specifies output columns have zero width separation</li>
</ul>

<p>If my reading of the <code>rs</code> manpage is correct, then the following <strong>ought</strong> to work for a score of 12, but unfortunately it doesn't work - see note below:</p>

<pre class="lang-bash prettyprint-override"><code>rs -E -g0 -T
</code>```

Example output:

$ printf "%s\n" car dog man yay |sed s/./\&:/g|rs -c: -g0 -T
cdmy
aoaa
rgny
$
```

If input is expected to be all printable ASCII, then the : may be replaced with some unprintable character, e.g. 0x7 BEL.

Note

I wanted to understand why I couldn't get the -E option to work and get rid of the sed preprocessing.  I found the rs source code here.  As you can see, giving this option sets the ONEPERCHAR flag.  However, there is nothing in the code that actually checks the state of this flag.  So I think we can say that despite the fact that is option is documented, it is not implemented.

In fact, this option is documented in the Linux rs manpage:

-E      Consider each character of input as an array entry.

but not the OS X version.

Body:
Bash + BSD utilities, 27

sed s/./\&:/g|rs -c: -g0 -T

I/O via STDIN/STDOUT newline-separated strings.

You may need to install rs with sudo apt install rs or similar.  Works out of the box on OS X.

The -T option to rs does the heavy lifting of the transposition.  The rest is just formatting:

The sed command simply inserts : after every character

-c: specifies input columns are : separated

-g0 specifies output columns have zero width separation

If my reading of the rs manpage is correct, then the following ought to work for a score of 12, but unfortunately it doesn't work - see note below:

rs -E -g0 -T

Example output:

$ printf "%s\n" car dog man yay |sed s/./\&:/g|rs -c: -g0 -T
cdmy
aoaa
rgny
$

If input is expected to be all printable ASCII, then the : may be replaced with some unprintable character, e.g. 0x7 BEL.

Note

I wanted to understand why I couldn't get the -E option to work and get rid of the sed preprocessing.  I found the rs source code here.  As you can see, giving this option sets the ONEPERCHAR flag.  However, there is nothing in the code that actually checks the state of this flag.  So I think we can say that despite the fact that is option is documented, it is not implemented.

In fact, this option is documented in the Linux rs manpage:

-E      Consider each character of input as an array entry.

but not the OS X version.


答:
Python, 95 84 bytes

I wasn't aware lambdas were legal, thanks @Dr Green Eggs and Iron Man

```<code>lambda p:'\n'.join(' '*min(p,l)+'-'+(2-(l==9))*(p-l)*str(l+1)+'-'for l in range(10))
</code>```

Title: Unzip some numbers

Body:
Python, 95 84 bytes

I wasn't aware lambdas were legal, thanks @Dr Green Eggs and Iron Man

lambda p:'\n'.join(' '*min(p,l)+'-'+(2-(l==9))*(p-l)*str(l+1)+'-'for l in range(10))


问:
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:
PICO-8/Lua, <s>108</s> <s>100</s> 92 bytes (non-competing)

rectfill(0,0,24,17,12)
rect(0,7,24,10,7)
rect(7,0,10,17,7)
rect(0,8,24,9,8)
rect(8,0,9,17,8)

ContentLicense: CC BY-SA 4.0


问:
Is it a max-heap?
A heap, also known as a priority-queue, is an abstract data type. Conceptually, it's a binary tree where the children of every node are smaller than or equal to the node itself. (Assuming it's a max-heap.) When an element is pushed or popped, the heap rearranges itself so the the biggest element is the next to be popped. It can easily be implemented as a tree or as an array.

Your challenge, should you choose to accept it, is to determine if an array is a valid heap. An array is in heap form if every element's children are smaller than or equal to the element itself. Take the following array as an example:

```<code>[90, 15, 10, 7, 12, 2]
</code>```

Really, this is a binary tree arranged in the form of an array. This is because every element has children. 90 has two children, 15 and 10.

```<code>       15, 10,
[(90),         7, 12, 2]
</code>```

15 also has children, 7 and 12:

```<code>               7, 12,
[90, (15), 10,        2]
</code>```

10 has children:

```<code>                      2
[90, 15, (10), 7, 12,  ]
</code>```

and the next element would also be a child of 10, except that there isn't room. 7, 12 and 2 would all also have children if the array was long enough. Here is another example of a heap:

```<code>[16, 14, 10, 8, 7, 9, 3, 2, 4, 1]
</code>```

And here is a visualization of the tree the previous array makes:

Just in case this isn't clear enough, here is the explicit formula to get the children of the i'th element

```<code>//0-indexing:
child1 = (i * 2) + 1
child2 = (i * 2) + 2

//1-indexing:
child1 = (i * 2)
child2 = (i * 2) + 1
</code>```

You must take an non-empty array as input and output a truthy value if the array is in heap order, and a falsy value otherwise. This can be a 0-indexed heap, or a 1-indexed heap as long as you specify which format your program/function expects. You may assume that all arrays will only contain positive integers. You may not use any heap-builtins. This includes, but is not limited to

Functions that determine if an array is in heap-form

Functions that convert an array into a heap or into heap-form

Functions that take an array as input and return a heap data-structure

You can use this python script to verify if an array is in heap-form or not (0 indexed):

```<code>def is_heap(l):
    for head in range(0, len(l)):
        c1, c2 = head * 2 + 1, head * 2 + 2
        if c1 < len(l) and l[head] < l[c1]:
            return False
        if c2 < len(l) and l[head] < l[c2]:
            return False

    return True
</code>```

Test IO:

All of these inputs should return True:

```<code>[90, 15, 10, 7, 12, 2]
[93, 15, 87, 7, 15, 5]
[16, 14, 10, 8, 7, 9, 3, 2, 4, 1]
[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
[100, 19, 36, 17, 3, 25, 1, 2, 7]
[5, 5, 5, 5, 5, 5, 5, 5]
</code>```

And all of these inputs should return False:

```<code>[4, 5, 5, 5, 5, 5, 5, 5]
[90, 15, 10, 7, 12, 11]
[1, 2, 3, 4, 5]
[4, 8, 15, 16, 23, 42]
[2, 1, 3]
</code>```

As usual, this is code-golf, so standard loopholes apply and the shortest answer in bytes wins!

答:
Python 2, 45 bytes

f=lambda l:l==[]or l[len(l)/2-1]/l.pop()*f(l)
```
<p>Outputs 0 for Falsy, nonzero for Truthy.</p>
<p>Checks that the last element is less than or equal to its parent at index <code>len(l)/2-1</code>. Then, recurses to check that the same is True with the last element of the list removed, and so on until the list is empty.</p>
<hr />
<p><strong>48 bytes:</strong></p>
<pre class="lang-python prettyprint-override"><code>f=lambda l,i=1:l==l[:i]or l[~-i/2]/l[i]*f(l,i+1)
</code>```

Checks that at each index i, the element is at most its parent at index (i-1)/2. The floor-division produces 0 if this is not the case.

Doing the base case as i/len(l)or gives the same length. I had tried zipping at first, but got longer code (57 bytes).

lambda l:all(map(lambda a,b,c:b<=a>=c,l,l[1::2],l[2::2]))
```

Title: Is it a max-heap?

Body:
Python 2, 45 bytes

f=lambda l:l==[]or l[len(l)/2-1]/l.pop()*f(l)

Outputs 0 for Falsy, nonzero for Truthy.

Checks that the last element is less than or equal to its parent at index len(l)/2-1. Then, recurses to check that the same is True with the last element of the list removed, and so on until the list is empty.

48 bytes:

f=lambda l,i=1:l==l[:i]or l[~-i/2]/l[i]*f(l,i+1)

Checks that at each index i, the element is at most its parent at index (i-1)/2. The floor-division produces 0 if this is not the case.

Doing the base case as i/len(l)or gives the same length. I had tried zipping at first, but got longer code (57 bytes).

lambda l:all(map(lambda a,b,c:b<=a>=c,l,l[1::2],l[2::2]))


答:
ImageScript, 145 bytes

```<code>hex("0048e0");rect(0,0,156,156);rect(0,244,156,156);rect(244,0,366,156);rect(244,244,366,156);hex("d72828");rect(0,178,600,44);rect(178,0,44,400)
</code>```

Fairly straightforward. Just changes colors and draws rectangles

NOTE: When this is loaded into the website, the website automatically adds new lines after semicolons. The program still works fine without them

(By default, image size is 600x400)

Try it online!

Title: Draw the national flag of Iceland

Body:
ImageScript, 145 bytes

hex("0048e0");rect(0,0,156,156);rect(0,244,156,156);rect(244,0,366,156);rect(244,244,366,156);hex("d72828");rect(0,178,600,44);rect(178,0,44,400)

Fairly straightforward. Just changes colors and draws rectangles

NOTE: When this is loaded into the website, the website automatically adds new lines after semicolons. The program still works fine without them

(By default, image size is 600x400)

Try it online!


答:
Pyth, <s>37</s> 34 bytes

```
<s>=h/QTjm+*;thS,dQj<*`d20eS,0y-Qd"--"ST</s>
=h/QTjm+*;thS,dQj*`d/y-Qdl`d"--"ST
```

Test suite.

Title: Unzip some numbers

Body:
Pyth, <s>37</s> 34 bytes

<s>=h/QTjm+*;thS,dQj<*`d20eS,0y-Qd"--"ST</s>
=h/QTjm+*;thS,dQj*`d/y-Qdl`d"--"ST

Test suite.


问:
Illustrate music beats
You know—they look like this:

source

The goal is to draw a music beats illustration like the following:

```<code>=     =      =
=  =  =      =          =
== = ==   =  ==     = ====
== ====  == ===   = = =======
======== == ====  = ========= =
=================================
</code>```

The rules are:

The width of the illustration is 33 symbols, but if you need—any trailing spaces exceeding this width are allowed.

Each column is made of equals signs (=).

Each column has a random height (the height of the next column shouldn’t depend in any way on the height of the previous column), varying from 1 to 6. It’s also fine if it’s at least possible to get some input with no strict math probability (i.e. some inputs could appear more rarely than others).

A column can’t float above the bottom and have gaps in it.

Since every column has the minimal height of 1, the last row can’t have any gaps either—it always consists of 33 equals signs.

Since it’s possible to have no columns with the height of 6 (it’s all random after all): in this case you don’t need to have a top line made of spaces. Applies to any edge cases of this nature: if suddenly your code provided no columns with the height greater than 1, you don’t need to have additional lines made of spaces above the bottom line.

You don’t take any input.

答:
Forth, 190 bytes

I had to create my own PRNG, an xor-shift taken from here. The word f is the word you would call multiple times to see the output.

```<code>variable S utime S !
: L lshift xor ;
: R S @ dup 13 L dup 17 rshift xor dup 5 L dup S ! 6 mod ;
: f
33 0 DO R LOOP
1 -5 DO
33 0 DO
I PICK J + 0< 1+ IF ." =" ELSE SPACE THEN
LOOP CR
LOOP
; f
</code>```

Try it online - Note that the system time is one of two values based on which server (or something) is running the code. Other than that, they don't change in the online IDE for some reason. So you'll only see two possible outputs. You can manually set the seed by changing utime to an integer.

Ungolfed

```<code>variable seed                   \ seed with time
utime seed !

: RNG                           \ xor-shift PRNG
seed @
dup 13 lshift xor
dup 17 rshift xor
dup 5 lshift xor
dup seed !
6 mod                           \ between 0 and 6, exclusive
;

: f 33 0 DO RNG LOOP            \ push 33 randoms
    1 -5 DO                     \ for (J = -6; J <  0; J++)
        33 0 DO                 \ for (I =  0; I < 33; I++)
            I PICK J + 0< 1+ IF \ if  (stack[I] < J)
                61 EMIT         \ print "="
            ELSE
                32 EMIT         \ print " "
            THEN
        LOOP
        CR                      \ print "\n"
    LOOP
; f
</code>```

Ungolfed online

Title: Illustrate music beats

Body:
Forth, 190 bytes

I had to create my own PRNG, an xor-shift taken from here. The word f is the word you would call multiple times to see the output.

variable S utime S !
: L lshift xor ;
: R S @ dup 13 L dup 17 rshift xor dup 5 L dup S ! 6 mod ;
: f
33 0 DO R LOOP
1 -5 DO
33 0 DO
I PICK J + 0< 1+ IF ." =" ELSE SPACE THEN
LOOP CR
LOOP
; f

Try it online - Note that the system time is one of two values based on which server (or something) is running the code. Other than that, they don't change in the online IDE for some reason. So you'll only see two possible outputs. You can manually set the seed by changing utime to an integer.

Ungolfed

variable seed                   \ seed with time
utime seed !

: RNG                           \ xor-shift PRNG
seed @
dup 13 lshift xor
dup 17 rshift xor
dup 5 lshift xor
dup seed !
6 mod                           \ between 0 and 6, exclusive
;

: f 33 0 DO RNG LOOP            \ push 33 randoms
    1 -5 DO                     \ for (J = -6; J <  0; J++)
        33 0 DO                 \ for (I =  0; I < 33; I++)
            I PICK J + 0< 1+ IF \ if  (stack[I] < J)
                61 EMIT         \ print "="
            ELSE
                32 EMIT         \ print " "
            THEN
        LOOP
        CR                      \ print "\n"
    LOOP
; f

Ungolfed online


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:
Javascript console, 242 bytes

c='background:#';r=c+'d72828;';b=c+'0048e0;';w=c+'fff;';console.log(('%c  '[E='repeat'](25)+'\n')[E](18),...((t=(v='b'[E](7))+'wrrw'+v+v)[E](7)+(o=(j='w'[E](7))+'wrrw'+j+j)+'r'[E](50)+o+t[E](7)).replace(/(.)/g,a=>eval(a)).slice(0,-1).split`;`)


Title: Unzip some numbers

Body:
Python 2, 81 bytes

n=input()/10
for i in range(10):print(' '*min(i,n)+'-'+2*(n-i)/-~(i>8)*`i+1`+'-')

Ideone it!


Title: Unzip some numbers

Body:
Haskell, 83 bytes

f n=unlines[[[1..y]>>" ",take(2*(n-y))$cycle$show$y+1]>>=(++"-")|y<-min n<$>[0..9]]


答:
Retina, <s>45</s> 43 bytes

Byte count assumes ISO 8859-1 encoding.

```<code>O$#`.(?<=(.+))|¶
$.1
!`(?<=(¶)+.*)(?<-1>.)+
</code>```

The leading linefeed is significant. Input and output are linefeed-terminated lists of printable ASCII strings (note that both have a single trailing linefeed).

Try it online!

I knew for a while that transposing rectangular blocks would be a pain in Retina (whereas transposing squares isn't too bad), but never actually tried. The first solution was indeed a whopping 110 bytes long, but after several substantial changes in the approach, the resulting 45 bytes are by far not as bad as I suspected (but still...). Explanation will follow tomorrow.

Explanation

Stage 1: Sort

```<code>O$#`.(?<=(.+))|¶
$.1
</code>```

This does the main work of reordering the characters in the input, but it ends up messing up the separation into lines. Interestingly, if we remove the |¶, we get the code required to transpose a square input.

Sort stages (denoted by the O) work like this: they find all matches of the given regex (the thing after the `), and then sort those matches and reinsert them into the places where the matches were found. As it happens, this regex matches every single character: non-linefeeds via the .(?<=(.*)) alternative and linefeeds via the ¶. Hence, it sorts all characters in the input. The more interesting part is what they are sorted by.

The $ option activates a "sort-by" mode, where each match is replaced with the substitution pattern on the second line, which is then used for comparing the matches. Furthermore, the # tells Retina to convert the result of the substitution to an integer, and compare those integers (instead of treating them as strings).

So finally, we need to look at the regex and the substitution. If the first alternative matches (i.e. we have matched any character within one of the lines), then the (?<=(.*)) captures everything up to that character on that line into group 1. The $.1 in the substitution pattern replaces this with the length of group 1. Hence, the first character in each string becomes 1, the second becomes 2, the third becomes 3 and so on. It should be clear now how this transposes a square input: all the first characters of the lines come first and all end up in the top-most line, then all the second characters end up in the second line and so on. But for these rectangular inputs, we're also matching the linefeeds. Since group 1 is unused in this case, the substitution is empty, but for the purposes of the # option, this is considered 0. That means, all the linefeeds are sorted to the front.

So now we do have the characters in the first order (first character of each string, second character of each string, etc.) and all the linefeeds at the start.

Stage 2: Match

```<code>!`(?<=(¶)+.*)(?<-1>.)+
</code>```

We now need to split up the characters into lines of the correct length. This length corresponds to the number of lines in the original input, which is corresponds to the number of linefeeds we have at the beginning of the string.

The splitting is done here with the help of a match stage, which simply finds all matches of the given regex and uses the ! option to print those matches (the default would be to count them instead). So the goal of the regex is to match one line at a time.

We start by "counting" the number with the lookbehind (?<=(¶)*.*). It generates one capture in group 1 for every linefeed at the front.

Then, for each of those captures, we match a single character with (?<-1>.)+.

Body:
Retina, <s>45</s> 43 bytes

Byte count assumes ISO 8859-1 encoding.

O$#`.(?<=(.+))|¶
$.1
!`(?<=(¶)+.*)(?<-1>.)+

The leading linefeed is significant. Input and output are linefeed-terminated lists of printable ASCII strings (note that both have a single trailing linefeed).

Try it online!

I knew for a while that transposing rectangular blocks would be a pain in Retina (whereas transposing squares isn't too bad), but never actually tried. The first solution was indeed a whopping 110 bytes long, but after several substantial changes in the approach, the resulting 45 bytes are by far not as bad as I suspected (but still...). Explanation will follow tomorrow.

Explanation

Stage 1: Sort

O$#`.(?<=(.+))|¶
$.1

This does the main work of reordering the characters in the input, but it ends up messing up the separation into lines. Interestingly, if we remove the |¶, we get the code required to transpose a square input.

Sort stages (denoted by the O) work like this: they find all matches of the given regex (the thing after the `), and then sort those matches and reinsert them into the places where the matches were found. As it happens, this regex matches every single character: non-linefeeds via the .(?<=(.*)) alternative and linefeeds via the ¶. Hence, it sorts all characters in the input. The more interesting part is what they are sorted by.

The $ option activates a "sort-by" mode, where each match is replaced with the substitution pattern on the second line, which is then used for comparing the matches. Furthermore, the # tells Retina to convert the result of the substitution to an integer, and compare those integers (instead of treating them as strings).

So finally, we need to look at the regex and the substitution. If the first alternative matches (i.e. we have matched any character within one of the lines), then the (?<=(.*)) captures everything up to that character on that line into group 1. The $.1 in the substitution pattern replaces this with the length of group 1. Hence, the first character in each string becomes 1, the second becomes 2, the third becomes 3 and so on. It should be clear now how this transposes a square input: all the first characters of the lines come first and all end up in the top-most line, then all the second characters end up in the second line and so on. But for these rectangular inputs, we're also matching the linefeeds. Since group 1 is unused in this case, the substitution is empty, but for the purposes of the # option, this is considered 0. That means, all the linefeeds are sorted to the front.

So now we do have the characters in the first order (first character of each string, second character of each string, etc.) and all the linefeeds at the start.

Stage 2: Match

!`(?<=(¶)+.*)(?<-1>.)+

We now need to split up the characters into lines of the correct length. This length corresponds to the number of lines in the original input, which is corresponds to the number of linefeeds we have at the beginning of the string.

The splitting is done here with the help of a match stage, which simply finds all matches of the given regex and uses the ! option to print those matches (the default would be to count them instead). So the goal of the regex is to match one line at a time.

We start by "counting" the number with the lookbehind (?<=(¶)*.*). It generates one capture in group 1 for every linefeed at the front.

Then, for each of those captures, we match a single character with (?<-1>.)+.


问:
Power Grid Resource Costs

Power Grid Resource Costs

Introduction

In the board game Power Grid, an integral part of the game is the act of buying resources to fuel your power stations. There are four types of resource used in the game (five, if you include renewable energy, but obviously you can't buy resources for that). These are Coal, Oil, Garbage, and Uranium. The resource market looks like this:

```<code>1---- | 2---- | 3---- | 4---- | 5---- | 6---- | 7---- | 8---- | 10  | 12
CCC   | CCC   | CCC   | CCC   | CCC   | CCC   | CCC   | CCC   |  U  |  U
OOO U | OOO U | OOO U | OOO U | OOO U | OOO U | OOO U | OOO U | 14  | 16
GGG   | GGG   | GGG   | GGG   | GGG   | GGG   | GGG   | GGG   |  U  |  U
</code>```

When resources are bought, they are taken from the left of the market, where they are cheapest. When new resources are added to the market, they are added from the right. As can be seen, this produces a supply and demand balance - if more resources of a particular type are being bought than are being replenished each round, the price of that resource will rise. Similarly, if it's less, the cost will reduce.

Coal, Oil, and Garbage all scale up in cost at the same rate, while Uranium scales much faster. A single unit of a non-Uranium resource costs 8 - floor((<units available> - 1) / 3). A single unit of Uranium costs 13 - <units available> if there are 5 or more units available, and 18 - (2 * <units available>) otherwise.

For example, at the start of the game there are all 24 units of Coal available to buy. If the first player would like to buy 4 units of Coal, the first three units would cost 1 each, and the 4th would cost 2, making the total cost 5. This leaves 20 units available. If the second player would also like to buy 4 units of Coal, the cost would be (2*2 + 2*3) = 10.

The Challenge

Your challenge is to write a program or function which calculates the cost of buying a given amount of a particular resource, assuming that there is a given amount of that resource present in the market.

Your submission should accept, in any reasonable input format and in any order, the following parameters:

The resource type - guaranteed to be one of [C, O, G, U].

The amount of that resource that is present in the market - guaranteed to be a non-negative integer. If the resource type is not U, it will not be greater than 24. If the resource type is U, it will not be greater than 12.

The amount of that resource that a player would like to buy - guaranteed to be a non-negative integer which is less than or equal to the amount already present in the market.

The output should be the cost of the requested resources.

Additional Rules

The formulae given are for illustrative purposes only, feel free to use any method of calculating the costs you like.

The letter codes for the different resource types (C, O, G, U) may be replaced by their lower case equivalents. You may also replace the letters for numbers, either in the form C=0, O=1, G=2, U=3 or C=1, O=2, G=3, U=4.

This is code-golf, so the smallest submission in bytes will be the winner.

If your submission requires the input in a different order or format than specified in the previous section, you should provide details.

Test cases

Test case format:

```<code>resource type, amount in market, amount to buy
> result
</code>```

Test cases:

```<code>C, 24, 4
> 5

C, 20, 4
> 10

O, 3, 3
> 24

U, 1, 1
> 16

C, 1, 1
> 8

G, 0, 0
> 0

O, 10, 7
> 44

U, 12, 4
> 10

G, 11, 4
> 22
</code>```

答:
Python 3, <s>71</s> 69 bytes

Thanks to @xnor for -2 bytes

```<code>f=lambda r,a,b:b and[8-int(~-a/3),max(18-2*a,13-a)][r>2]+f(r,a-1,b-1)
</code>```

A function that takes input via argument of the zero-indexed resource type r, the amount available a and the amount to buy b, and returns the cost.

This makes use of the fact that True and False equate to 1 and 0 in Python, allowing the use of Boolean expressions to index into lists.

How it works

```<code>f=lambda r,a,b           Function with input resource type r, amount available a and amount
                         to buy b
b and...                 Base case: return 0 if b=0
[8-int(~-a/3),...][r>2]  If not uranium, yield the unit cost 8-floor((a-1)/3)...
max(18-2*a,13-a)         ..else yield the current uranium unit cost
...f(r,a-1,b-1)          Decrement a and b, then pass to function
...+...                  Add the cost of each unit to give the total cost
:...                     Return the above
</code>```

Try it on Ideone

Title: Power Grid Resource Costs

Body:
Python 3, <s>71</s> 69 bytes

Thanks to @xnor for -2 bytes

f=lambda r,a,b:b and[8-int(~-a/3),max(18-2*a,13-a)][r>2]+f(r,a-1,b-1)

A function that takes input via argument of the zero-indexed resource type r, the amount available a and the amount to buy b, and returns the cost.

This makes use of the fact that True and False equate to 1 and 0 in Python, allowing the use of Boolean expressions to index into lists.

How it works

f=lambda r,a,b           Function with input resource type r, amount available a and amount
                         to buy b
b and...                 Base case: return 0 if b=0
[8-int(~-a/3),...][r>2]  If not uranium, yield the unit cost 8-floor((a-1)/3)...
max(18-2*a,13-a)         ..else yield the current uranium unit cost
...f(r,a-1,b-1)          Decrement a and b, then pass to function
...+...                  Add the cost of each unit to give the total cost
:...                     Return the above

Try it on Ideone


答:
Python 2.7, <s>110</s> <s>99</s> <s>95</s> 91 bytes:

```<code>G=input();i=1;exec"print' '*[~-i,G][i>G]+'-%s-'%[`i`*(2*-~G-i*2),'10'][(i>9)*G>9];i+=1;"*10
</code>```

A full program that takes input by an integer in the inclusive range [1,10], where 10 means 100% and 1 means 10%. Can probably be golfed down a bit more.

Try It Online! (Ideone)

Title: Unzip some numbers

Body:
Your task is to create a program or function that generates a zipper with a length of 10 lines. Each line of the zipper is represented by two dashes --:

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

The program/function will take a percentage (divisible by 10) as input, and the output will be the zipper "unzipped" (dashes separated) from the top by the percentage, revealing the 1-indexed, lowest level repeated 2 times, with all prior levels repeated 4, 6, 8, ...etc. times, while keeping the bottom of the zipper centered.

Examples

```<code>>>10%
-11-
 --
 --
 --
 --
 --
 --
 --
 --
 --

>>50%
-1111111111-
 -22222222-
  -333333-
   -4444-
    -55-
     --
     --
     --
     --
     --

>>100%
-11111111111111111111-
 -222222222222222222-
  -3333333333333333-
   -44444444444444-
    -555555555555-
     -6666666666-
      -77777777-
       -888888-
        -9999-
         -10-
</code>```

The input (percentage) can be formatted however you like (50%, .5, 50, 5 [zero implied], etc), and it will always be in the range of 0 to 100 and divisible by 10. The spacing in the examples must be preserved in your output.

Body:
Python 2.7, <s>110</s> <s>99</s> <s>95</s> 91 bytes:

G=input();i=1;exec"print' '*[~-i,G][i>G]+'-%s-'%[`i`*(2*-~G-i*2),'10'][(i>9)*G>9];i+=1;"*10

A full program that takes input by an integer in the inclusive range [1,10], where 10 means 100% and 1 means 10%. Can probably be golfed down a bit more.

Try It Online! (Ideone)


答:
FFmpeg, <s>339</s> 184 bytes

```<code>ffplay -f lavfi color=d72828:100x36[r];color=white:64x32[w];color=0048e0:56x28[b];[w][b]overlay=4,split[x][y];[r][x]overlay=-32[d];[d][y]overlay=40,split[t][m];[m]vflip[n];[t][n]vstack
</code>```

Will try to golf this down ..further.

Title: Draw the national flag of Iceland

Body:
FFmpeg, <s>339</s> 184 bytes

ffplay -f lavfi color=d72828:100x36[r];color=white:64x32[w];color=0048e0:56x28[b];[w][b]overlay=4,split[x][y];[r][x]overlay=-32[d];[d][y]overlay=40,split[t][m];[m]vflip[n];[t][n]vstack

Will try to golf this down ..further.


问:
Partition of a positive integer N
Find the number of partitions of a positive integer n. Hope someone uses the explicit finite formula for the partition function defined in Jan Hendrik Brunier and Ken Ono paper here.

```<code>Sample Input
8
Sample Output
22
</code>```

N is less than or equal to 1000.
Write the complete program. More than anything I would like to see the different approaches.

ContentLicense: CC BY-SA 2.5

Title: Partition of a positive integer N

Body:
J, 72

Modified from the manual:

f=:[:(0<@-."1~>@{:)](,([:<@;(-i.)@#([,.(>:{."1)#])&.>]))@]^:[(<i.1 0)"_

eg

#f 8
22


答:
PHP 5.3, <s>92</s> 91 bytes

```<code><?for(;$i<10;$i++)echo'
'.str_pad('-'.str_repeat($i+1,$n>9&&$i>8?:($n-$i)*2).'-',22,' ',2);
</code>```

for PHP 5.3 with register_globals=1 and short_open_tags=1 (and error_reporting=0)

call in cli with php-cgi -f <filename> n=<number>

number from 0 to 10

to call in web browser with

Title: Unzip some numbers

Body:
PHP 5.3, <s>92</s> 91 bytes

<?for(;$i<10;$i++)echo'
'.str_pad('-'.str_repeat($i+1,$n>9&&$i>8?:($n-$i)*2).'-',22,' ',2);

for PHP 5.3 with register_globals=1 and short_open_tags=1 (and error_reporting=0)

call in cli with php-cgi -f <filename> n=<number>

number from 0 to 10

to call in web browser with <scriptpath>?n=<number>: prepend <pre>

for 4.0.1 < PHP < 5.3: replace ?: with ?1: (+1)

for PHP>=5.4: replace the first $n with ($n=$_GET[n]) (+11)

ungolfed as a function (any PHP>=4.0.1)

function unzip($n) // $n from 0 to 10
{
    for($i=0;$i<10;$i++)                // $i = line number -1
        $s.='
'.str_pad(                              // pad the result of the following on both sides
            '-'.                            // prepend '-'
            str_repeat($i+1,                // print line number
                ($n>9&&$i>8 ? 1             // in tenth line, if $n is 10: once
                : ($n-$i)*2)                    // else  2*($n-$i) times
            ).'-'                           // append '-'
            , 22,' ', STR_PAD_BOTH);    // pad to 22 width with SPC on both sides
    return $s;
}

test suite

echo'<table border=1><tr>';
for($i=0;$i<11;$i++)echo'<th>',$i*10,'%</th>';
echo'</tr><tr>';
for($i=0;$i<11;$i++)echo'<td><pre>', unzip($i), '</pre></td>';
echo '</table>';

Now this is new to me: PHP beats JavaScript.

This approach is golfed to the min, I think.


答:
Python 2.7, 86 bytes:

```<code>F,G,H=input();B=0;exec"B+=[[18-(2*G),13-G][G>5],8-((G-1)//3)][F!='U'];G-=1;"*H;print B
</code>```

Takes input by an array in the format [resource type, units available, units to purchase]. Output is an integer. Will try to golf more over time.

Try It Online! (Ideone)

Title: Power Grid Resource Costs

Body:
Power Grid Resource Costs

Introduction

In the board game Power Grid, an integral part of the game is the act of buying resources to fuel your power stations. There are four types of resource used in the game (five, if you include renewable energy, but obviously you can't buy resources for that). These are Coal, Oil, Garbage, and Uranium. The resource market looks like this:

```<code>1---- | 2---- | 3---- | 4---- | 5---- | 6---- | 7---- | 8---- | 10  | 12
CCC   | CCC   | CCC   | CCC   | CCC   | CCC   | CCC   | CCC   |  U  |  U
OOO U | OOO U | OOO U | OOO U | OOO U | OOO U | OOO U | OOO U | 14  | 16
GGG   | GGG   | GGG   | GGG   | GGG   | GGG   | GGG   | GGG   |  U  |  U
</code>```

When resources are bought, they are taken from the left of the market, where they are cheapest. When new resources are added to the market, they are added from the right. As can be seen, this produces a supply and demand balance - if more resources of a particular type are being bought than are being replenished each round, the price of that resource will rise. Similarly, if it's less, the cost will reduce.

Coal, Oil, and Garbage all scale up in cost at the same rate, while Uranium scales much faster. A single unit of a non-Uranium resource costs 8 - floor((<units available> - 1) / 3). A single unit of Uranium costs 13 - <units available> if there are 5 or more units available, and 18 - (2 * <units available>) otherwise.

For example, at the start of the game there are all 24 units of Coal available to buy. If the first player would like to buy 4 units of Coal, the first three units would cost 1 each, and the 4th would cost 2, making the total cost 5. This leaves 20 units available. If the second player would also like to buy 4 units of Coal, the cost would be (2*2 + 2*3) = 10.

The Challenge

Your challenge is to write a program or function which calculates the cost of buying a given amount of a particular resource, assuming that there is a given amount of that resource present in the market.

Your submission should accept, in any reasonable input format and in any order, the following parameters:

The resource type - guaranteed to be one of [C, O, G, U].

The amount of that resource that is present in the market - guaranteed to be a non-negative integer. If the resource type is not U, it will not be greater than 24. If the resource type is U, it will not be greater than 12.

The amount of that resource that a player would like to buy - guaranteed to be a non-negative integer which is less than or equal to the amount already present in the market.

The output should be the cost of the requested resources.

Additional Rules

The formulae given are for illustrative purposes only, feel free to use any method of calculating the costs you like.

The letter codes for the different resource types (C, O, G, U) may be replaced by their lower case equivalents. You may also replace the letters for numbers, either in the form C=0, O=1, G=2, U=3 or C=1, O=2, G=3, U=4.

This is code-golf, so the smallest submission in bytes will be the winner.

If your submission requires the input in a different order or format than specified in the previous section, you should provide details.

Test cases

Test case format:

```<code>resource type, amount in market, amount to buy
> result
</code>```

Test cases:

```<code>C, 24, 4
> 5

C, 20, 4
> 10

O, 3, 3
> 24

U, 1, 1
> 16

C, 1, 1
> 8

G, 0, 0
> 0

O, 10, 7
> 44

U, 12, 4
> 10

G, 11, 4
> 22
</code>```

Body:
Python 2.7, 86 bytes:

F,G,H=input();B=0;exec"B+=[[18-(2*G),13-G][G>5],8-((G-1)//3)][F!='U'];G-=1;"*H;print B

Takes input by an array in the format [resource type, units available, units to purchase]. Output is an integer. Will try to golf more over time.

Try It Online! (Ideone)


答:
bash, <s>239</s> 161 bytes

took the closest colors I could find in ANSI

golfed by a third (an amazing 78 bytes) with manatwork´s tips

```<code>a="${u=${e=\e[48;5};20m}${s=       }${w=$e;231m} ${r=$e;124m}  $w $u$s$s${n=\e[0m
}"
printf "${t=$a$a$a$a$a$a$a}${b=$w$s $r  $w $s$s$n}${c=$r$s    $s$s$n}$c$b$t"
</code>```

ungolfed (184 bytes + comments)

```<code>u='\e[48;5;20m'             # color blUe
r='\e[48;5;124m'            # color Red
w='\e[48;5;231m'            # color White
#presets:
n="\e[0m\n"                 # No color + New line
s='       '                 # 7*chr(32)

# lines:
a="$u$s$w $r  $w $u$s$s$n"  # blue-white-red-white-blue
b="$w$s $r  $w $s$s$n"      # white-red-white
c="$r$s    $s$s$n"          # all red

# output:
t="$a$a$a$a$a$a$a"          # 7* line $a
printf "$t$b$c$c$b$t"
</code>```

output pretty distorted due to character aspect ratio:

Title: Draw the national flag of Iceland

Body:
bash, <s>239</s> 161 bytes

took the closest colors I could find in ANSI

golfed by a third (an amazing 78 bytes) with manatwork´s tips

a="${u=${e=\e[48;5};20m}${s=       }${w=$e;231m} ${r=$e;124m}  $w $u$s$s${n=\e[0m
}"
printf "${t=$a$a$a$a$a$a$a}${b=$w$s $r  $w $s$s$n}${c=$r$s    $s$s$n}$c$b$t"

ungolfed (184 bytes + comments)

u='\e[48;5;20m'             # color blUe
r='\e[48;5;124m'            # color Red
w='\e[48;5;231m'            # color White
#presets:
n="\e[0m\n"                 # No color + New line
s='       '                 # 7*chr(32)

# lines:
a="$u$s$w $r  $w $u$s$s$n"  # blue-white-red-white-blue
b="$w$s $r  $w $s$s$n"      # white-red-white
c="$r$s    $s$s$n"          # all red

# output:
t="$a$a$a$a$a$a$a"          # 7* line $a
printf "$t$b$c$c$b$t"

output pretty distorted due to character aspect ratio:


问:
Write a hello world GUI program that closes itself after three seconds
Please read the rules, and the bold areas as well.

Write a program in any language, so long as it has GUI support for a window system (cannot be text-consoles, etc., and must be a GUI/toolkit/window).

The program must say hello world in any manner (splash image, menu bar, status bar, title, video, message box, other widget stuff, etc.), so long as a GUI-compliant window appears and shows this text for three seconds. The person who can code this in the least amount of code used, counted in bytes, will take the cake.

答:
Factor, 128 bytes

```<code>[ f T{ world-attributes { title "" } } clone "Hello world" <label> >>gadgets open-window* 3 seconds sleep close-window ] with-ui
</code>```

Body:
Factor, 128 bytes

[ f T{ world-attributes { title "" } } clone "Hello world" <label> >>gadgets open-window* 3 seconds sleep close-window ] with-ui


答:
PHP with GD, <s>256</s> <s>253</s> <s>244</s> 238 bytes

saved 9 bytes thanks to insertusernamehere, manatwork reminded me of another 6.

```<code><?$a=imageColorAllocate;$f=imageFilledRectangle;$a($g=imagecreate(100,72),0,72,224);$f($g,28,0,43,71,$w=$a($g,-1,-1,-1));$f($g,0,28,99,43,$w);$f($g,32,0,39,71,$r=$a($g,215,40,40));$f($g,0,32,99,39,$r);header('Content-Type:');imagegif($g);
</code>```

call in web browser

for Android: insert image/gif behind Content-Type: (+9)

Title: Draw the national flag of Iceland

Body:
PHP with GD, <s>256</s> <s>253</s> <s>244</s> 238 bytes

saved 9 bytes thanks to insertusernamehere, manatwork reminded me of another 6.

<?$a=imageColorAllocate;$f=imageFilledRectangle;$a($g=imagecreate(100,72),0,72,224);$f($g,28,0,43,71,$w=$a($g,-1,-1,-1));$f($g,0,28,99,43,$w);$f($g,32,0,39,71,$r=$a($g,215,40,40));$f($g,0,32,99,39,$r);header('Content-Type:');imagegif($g);

call in web browser

for Android: insert image/gif behind Content-Type: (+9)


问:
Latin square compression
A Latin square is a square that has no repeated symbols in the rows or columns:.

```<code>13420
21304
32041
04213
40132
</code>```

And as many Sudoku players know, you don't need all of the numbers to deduce the remaining numbers.

Your challenge is to compress a Latin square into as few bytes as possible.  You need to provide one or two program(s) that compresses/decompresses.

Various info:

The numbers used will always be 0..N-1, where N is the length of the square's edge, and N<=25

On decompression, the latin square must be identical to the input.

Your program(s) should be able to (de)compress any latin square (within the maximum square size), not just the ones I've provided.  Compression ratios should be similar as well.

You must actually run the compression and decompressor to obtain your score (No end-of-universe runtimes)

The test cases can be found on github.  Your score is total size of compressed test cases.

EDIT: As of 20:07 on July 7th, I updated the test cases (in order to fix a generation issue).  Please rerun your program on the new test cases.  Thanks Anders Kaseorg.

答:
Python, <s>1281.375</s> 1268.625 bytes

We encode the Latin square one “decision” at a time, where each decision is of one of these three forms:

which number goes in row i, column j;

in row i, which column the number k goes in;

in column j, which row the number k goes in.

At each step, we make all the logical inferences we can based on previous decisions, then pick the decision with the smallest number of possible choices, which therefore take the smallest number of bits to represent.

The choices are provided by a simple arithmetic decoder (div/mod by the number of choices).  But that leaves some redundancy in the encoding: if k decodes to a square where the product of all the numbers of choices was m, then k + m, k + 2⋅m, k + 3⋅m, … decode to the same square with some leftover state at the end.

We take advantage of this redundancy to avoid explicitly encoding the size of the square.  The decompressor starts by trying to decode a square of size 1.  Whenever the decoder finishes with leftover state, it throws out that result, subtracts m from the original number, increases the size by 1, and tries again.

import numpy as np

class Latin(object):
    def __init__(self, size):
        self.size = size
        self.possible = np.full((size, size, size), True, dtype=bool)
        self.count = np.full((3, size, size), size, dtype=int)
        self.chosen = np.full((3, size, size), -1, dtype=int)

    def decision(self):
        axis, u, v = np.unravel_index(np.where(self.chosen == -1, self.count, self.size).argmin(), self.count.shape)
        if self.chosen[axis, u, v] == -1:
            ws, = np.rollaxis(self.possible, axis)[:, u, v].nonzero()
            return axis, u, v, list(ws)
        else:
            return None, None, None, None

    def choose(self, axis, u, v, w):
        t = [u, v]
        t[axis:axis] = [w]
        i, j, k = t
        assert self.possible[i, j, k]
        assert self.chosen[0, j, k] == self.chosen[1, i, k] == self.chosen[2, i, j] == -1

        self.count[1, :, k] -= self.possible[:, j, k]
        self.count[2, :, j] -= self.possible[:, j, k]
        self.count[0, :, k] -= self.possible[i, :, k]
        self.count[2, i, :] -= self.possible[i, :, k]
        self.count[0, j, :] -= self.possible[i, j, :]
        self.count[1, i, :] -= self.possible[i, j, :]
        self.count[0, j, k] = self.count[1, i, k] = self.count[2, i, j] = 1
        self.possible[i, j, :] = self.possible[i, :, k] = self.possible[:, j, k] = False
        self.possible[i, j, k] = True
        self.chosen[0, j, k] = i
        self.chosen[1, i, k] = j
        self.chosen[2, i, j] = k

def encode_sized(size, square):
    square = np.array(square, dtype=int)
    latin = Latin(size)
    chosen = np.array([np.argmax(square[:, :, np.newaxis] == np.arange(size)[np.newaxis, np.newaxis, :], axis=axis) for axis in range(3)])
    num, denom = 0, 1
    while True:
        axis, u, v, ws = latin.decision()
        if axis is None:
            break
        w = chosen[axis, u, v]
        num += ws.index(w)*denom
        denom *= len(ws)
        latin.choose(axis, u, v, w)
    return num

def decode_sized(size, num):
    latin = Latin(size)
    denom = 1
    while True:
        axis, u, v, ws = latin.decision()
        if axis is None:
            break
        if not ws:
            return None, 0
        latin.choose(axis, u, v, ws[num % len(ws)])
        num //= len(ws)
        denom *= len(ws)
    return latin.chosen[2].tolist(), denom

def compress(square):
    size = len(square)
    assert size > 0
    num = encode_sized(size, square)
    while size > 1:
        size -= 1
        square, denom = decode_sized(size, num)
        num += denom
    return '{:b}'.format(num + 1)[1:]

def decompress(bits):
    num = int('1' + bits, 2) - 1
    size = 1
    while True:
        square, denom = decode_sized(size, num)
        num -= denom
        if num < 0:
            return square
        size += 1

total = 0
with open('latin_squares.txt') as f:
    while True:
        square = [list(map(int, l.split(','))) for l in iter(lambda: next(f), '\n')]
        if not square:
            break

        bits = compress(square)
        assert set(bits) <= {'0', '1'}
        assert square == decompress(bits)
        print('Square {}: {} bits'.format(len(square), len(bits)))
        total += len(bits)

print('Total: {} bits = {} bytes'.format(total, total/8.0))
```

<p>Output:</p>

```Square 1: 0 bits
Square 2: 1 bits
Square 3: 3 bits
Square 4: 8 bits
Square 5: 12 bits
Square 6: 29 bits
Square 7: 43 bits
Square 8: 66 bits
Square 9: 94 bits
Square 10: 122 bits
Square 11: 153 bits
Square 12: 198 bits
Square 13: 250 bits
Square 14: 305 bits
Square 15: 363 bits
Square 16: 436 bits
Square 17: 506 bits
Square 18: 584 bits
Square 19: 674 bits
Square 20: 763 bits
Square 21: 877 bits
Square 22: 978 bits
Square 23: 1097 bits
Square 24: 1230 bits
Square 25: 1357 bits
Total: 10149 bits = 1268.625 bytes
```

Title: Latin square compression

Body:
Python, <s>1281.375</s> 1268.625 bytes

We encode the Latin square one “decision” at a time, where each decision is of one of these three forms:

which number goes in row i, column j;

in row i, which column the number k goes in;

in column j, which row the number k goes in.

At each step, we make all the logical inferences we can based on previous decisions, then pick the decision with the smallest number of possible choices, which therefore take the smallest number of bits to represent.

The choices are provided by a simple arithmetic decoder (div/mod by the number of choices).  But that leaves some redundancy in the encoding: if k decodes to a square where the product of all the numbers of choices was m, then k + m, k + 2⋅m, k + 3⋅m, … decode to the same square with some leftover state at the end.

We take advantage of this redundancy to avoid explicitly encoding the size of the square.  The decompressor starts by trying to decode a square of size 1.  Whenever the decoder finishes with leftover state, it throws out that result, subtracts m from the original number, increases the size by 1, and tries again.

import numpy as np

class Latin(object):
    def __init__(self, size):
        self.size = size
        self.possible = np.full((size, size, size), True, dtype=bool)
        self.count = np.full((3, size, size), size, dtype=int)
        self.chosen = np.full((3, size, size), -1, dtype=int)

    def decision(self):
        axis, u, v = np.unravel_index(np.where(self.chosen == -1, self.count, self.size).argmin(), self.count.shape)
        if self.chosen[axis, u, v] == -1:
            ws, = np.rollaxis(self.possible, axis)[:, u, v].nonzero()
            return axis, u, v, list(ws)
        else:
            return None, None, None, None

    def choose(self, axis, u, v, w):
        t = [u, v]
        t[axis:axis] = [w]
        i, j, k = t
        assert self.possible[i, j, k]
        assert self.chosen[0, j, k] == self.chosen[1, i, k] == self.chosen[2, i, j] == -1

        self.count[1, :, k] -= self.possible[:, j, k]
        self.count[2, :, j] -= self.possible[:, j, k]
        self.count[0, :, k] -= self.possible[i, :, k]
        self.count[2, i, :] -= self.possible[i, :, k]
        self.count[0, j, :] -= self.possible[i, j, :]
        self.count[1, i, :] -= self.possible[i, j, :]
        self.count[0, j, k] = self.count[1, i, k] = self.count[2, i, j] = 1
        self.possible[i, j, :] = self.possible[i, :, k] = self.possible[:, j, k] = False
        self.possible[i, j, k] = True
        self.chosen[0, j, k] = i
        self.chosen[1, i, k] = j
        self.chosen[2, i, j] = k

def encode_sized(size, square):
    square = np.array(square, dtype=int)
    latin = Latin(size)
    chosen = np.array([np.argmax(square[:, :, np.newaxis] == np.arange(size)[np.newaxis, np.newaxis, :], axis=axis) for axis in range(3)])
    num, denom = 0, 1
    while True:
        axis, u, v, ws = latin.decision()
        if axis is None:
            break
        w = chosen[axis, u, v]
        num += ws.index(w)*denom
        denom *= len(ws)
        latin.choose(axis, u, v, w)
    return num

def decode_sized(size, num):
    latin = Latin(size)
    denom = 1
    while True:
        axis, u, v, ws = latin.decision()
        if axis is None:
            break
        if not ws:
            return None, 0
        latin.choose(axis, u, v, ws[num % len(ws)])
        num //= len(ws)
        denom *= len(ws)
    return latin.chosen[2].tolist(), denom

def compress(square):
    size = len(square)
    assert size > 0
    num = encode_sized(size, square)
    while size > 1:
        size -= 1
        square, denom = decode_sized(size, num)
        num += denom
    return '{:b}'.format(num + 1)[1:]

def decompress(bits):
    num = int('1' + bits, 2) - 1
    size = 1
    while True:
        square, denom = decode_sized(size, num)
        num -= denom
        if num < 0:
            return square
        size += 1

total = 0
with open('latin_squares.txt') as f:
    while True:
        square = [list(map(int, l.split(','))) for l in iter(lambda: next(f), '\n')]
        if not square:
            break

        bits = compress(square)
        assert set(bits) <= {'0', '1'}
        assert square == decompress(bits)
        print('Square {}: {} bits'.format(len(square), len(bits)))
        total += len(bits)

print('Total: {} bits = {} bytes'.format(total, total/8.0))

Output:

Square 1: 0 bits
Square 2: 1 bits
Square 3: 3 bits
Square 4: 8 bits
Square 5: 12 bits
Square 6: 29 bits
Square 7: 43 bits
Square 8: 66 bits
Square 9: 94 bits
Square 10: 122 bits
Square 11: 153 bits
Square 12: 198 bits
Square 13: 250 bits
Square 14: 305 bits
Square 15: 363 bits
Square 16: 436 bits
Square 17: 506 bits
Square 18: 584 bits
Square 19: 674 bits
Square 20: 763 bits
Square 21: 877 bits
Square 22: 978 bits
Square 23: 1097 bits
Square 24: 1230 bits
Square 25: 1357 bits
Total: 10149 bits = 1268.625 bytes


答:
Java with ANSI escape codes, 278 bytes

```<code>interface R{static void main(String[]a){String x=o(0,0)+"\n",l=o(4,7)+o(7,1)+o(1,2)+o(7,1)+o(4,14)+x,t=l+l+l+l+l+l+l,r=o(1,12)+o(1,13)+x,q=o(7,8)+o(1,2)+o(7,15)+x;System.out.print(t+q+r+r+q+t);}static String o(int c,int l){return"\33[4"+c+"m"+"               ".substring(0,l);}}
</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:
Java with ANSI escape codes, 278 bytes

interface R{static void main(String[]a){String x=o(0,0)+"\n",l=o(4,7)+o(7,1)+o(1,2)+o(7,1)+o(4,14)+x,t=l+l+l+l+l+l+l,r=o(1,12)+o(1,13)+x,q=o(7,8)+o(1,2)+o(7,15)+x;System.out.print(t+q+r+r+q+t);}static String o(int c,int l){return"\33[4"+c+"m"+"               ".substring(0,l);}}


答:
Java, 153 bytes

```<code>interface a{static void main(String[]A){new Thread(()->javax.swing.JOptionPane.showMessageDialog("Hello world")).start();Thread.sleep(3000);throw null;}}
</code>```

Points to null three seconds after popping up a quite ugly window with the text "Hello world" on it.

Title: Write a hello world GUI program that closes itself after three seconds

Body:
Please read the rules, and the bold areas as well.

Write a program in any language, so long as it has GUI support for a window system (cannot be text-consoles, etc., and must be a GUI/toolkit/window).

The program must say hello world in any manner (splash image, menu bar, status bar, title, video, message box, other widget stuff, etc.), so long as a GUI-compliant window appears and shows this text for three seconds. The person who can code this in the least amount of code used, counted in bytes, will take the cake.

Body:
Java, 153 bytes

interface a{static void main(String[]A){new Thread(()->javax.swing.JOptionPane.showMessageDialog("Hello world")).start();Thread.sleep(3000);throw null;}}

Points to null three seconds after popping up a quite ugly window with the text "Hello world" on it.


答:
Befunge, 142 bytes

```<code>&2`#v_&&>:!#v_\:1-3/8\-v
v:&&<   ^-1\ -1p15+g15 <
v>#<v       <
! v5<
# 1:
>^g-
| 81
\ 4\
: *-
4 -1
` .p
# @^15+g15<
>:49+\-   ^
|
>:2*92*\- ^
</code>```

Try it here! Takes input as 3 integers, where the resource type is 0,1,2,3. Output is an integer.

No idea if this can be golfed any better. There's not that much whitespace, but the newlines probably hurt.

Title: Power Grid Resource Costs

Body:
Befunge, 142 bytes

&2`#v_&&>:!#v_\:1-3/8\-v
v:&&<   ^-1\ -1p15+g15 <
v>#<v       <
! v5<
# 1:
>^g-
| 81
\ 4\
: *-
4 -1
` .p
# @^15+g15<
>:49+\-   ^
|
>:2*92*\- ^

Try it here! Takes input as 3 integers, where the resource type is 0,1,2,3. Output is an integer.

No idea if this can be golfed any better. There's not that much whitespace, but the newlines probably hurt.