答:
Javascript (ES6), <s>71</s> 59 bytes

```<code>f=(t,m,b)=>b&&(t>2?m>4?13-m:18-m*2:9+~(~-m/3))+f(t,m-1,b-1)
</code>```

Takes type, market_amount and buy_amount as arguments. type is an integer between 0 and 3.

Demo

f=(t,m,b)=>b&&(t>2?m>4?13-m:18-m*2:9+~(~-m/3))+f(t,m-1,b-1)
function run() { var tests = document.getElementById("tests").value.split("\n"), test, C = 0, O = 1, G = 2, U = 3; console.clear(); for (var test of tests) { console.log(test); console.log("> " + eval(test)); } }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><textarea rows="10" id="tests">f(C, 24, 4)
f(C, 20, 4)
f(O, 3, 3)
f(U, 1, 1)
f(C, 1, 1)
f(G, 0, 0)
f(O, 10, 7)
f(U, 12, 4)
f(G, 11, 4)</textarea><br/><button onclick="run()">Run</button></code>```

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:
Javascript (ES6), <s>71</s> 59 bytes

f=(t,m,b)=>b&&(t>2?m>4?13-m:18-m*2:9+~(~-m/3))+f(t,m-1,b-1)

Takes type, market_amount and buy_amount as arguments. type is an integer between 0 and 3.

Demo

f=(t,m,b)=>b&&(t>2?m>4?13-m:18-m*2:9+~(~-m/3))+f(t,m-1,b-1)
function run() { var tests = document.getElementById("tests").value.split("\n"), test, C = 0, O = 1, G = 2, U = 3; console.clear(); for (var test of tests) { console.log(test); console.log("> " + eval(test)); } }

<textarea rows="10" id="tests">f(C, 24, 4)&#10;f(C, 20, 4)&#10;f(O, 3, 3)&#10;f(U, 1, 1)&#10;f(C, 1, 1)&#10;f(G, 0, 0)&#10;f(O, 10, 7)&#10;f(U, 12, 4)&#10;f(G, 11, 4)</textarea><br/><button onclick="run()">Run</button>


问:
The Major-Minor Dichotomy
Given a list of chords label them as either 'Major' or ' Minor'.

Input

Input will be a list of chords, one per line, made up of 3 notes separated by a space. Each note will consist of the note name in uppercase (A-G) and an optional accidental (# or b). Chords may be in any inversion (i.e. the notes may be in any order).

Output

If the chord is major, output 'Major'. If the chord is minor, output 'Minor'. If the chord is neither major nor minor, output a blank line.

Example

Input

```<code>C E G
F Ab C
C Eb Gb
E G B
Db F Ab
Bb G D
D A Gb
</code>```

Output

```<code>Major
Minor

Minor
Major
Minor
Major
</code>```

Test scripts

As in some of my past questions, I've once again butchered some test scripts originally created by Joey and Ventero to provide some test cases for this question:

bash

Powershell

Usage: ./test [your program and its arguments]

Rewards

Each entry which I can verify that meets the spec, passes the tests and has obviously had some attempt at golfing will receive an upvote from me (so please provide usage instructions with your answer). The shortest solution by the end of 13/10/2012 will be accepted as the winner.

A little theory

For those of you with no musical theory knowledge here's enough information for you to be able to compete.

A major or minor chord is made up of three notes which are separated by a specific pattern of semitones. If we consider the root (bottom note) of the chord to be 0, then a major chord is the pattern 0-4-7 and a minor chord is the pattern 0-3-7. Things are made more awkward by the fact that some notes are a semitone apart and some are a tone apart. The spread of semitones from Ab-G# is as follows:

```<code>G#/Ab A A#/Bb B/Cb B#/C C#/Db D D#/Eb E/Fb E#/F F#/Gb G G#/Ab
  0   1   2    3     4    5   6   7    8     9    10  11  12
</code>```

G#/Ab means that that G# is the same note as Ab. From this we can see that the chord Ab C Eb is a major chord, and that Ab Cb Eb is minor.

To complicate matters further, the chord Eb Cb Ab is considered to be the same as Ab Cb Eb, Cb Eb Ab and Cb Ab Eb and so on. Every one of these variations is still a minor chord.

答:
GolfScript, 83 chars

```<code>n%{' '%{1\{'A#BC D EF G'?+}/.}%$(+2/{~- 12%}%.(+.(+]$0=.$]10,7>?'MMaijnoorr

'>2%}%
</code>```

This is a quick first solution; I'm sure this can be golfed further.  Passes the bash test suite, after fixing the bug pointed out by flodel in the comments.

Edit 1: Saved 5 chars with a shorter way to recognize the canonicalized major and minor chord patterns.

Edit 2: Saved 2 more chars with more compact output encoding inspired by grc's solution.  (Thanks!)  As a side effect, the code now prints an extra blank line after the output, but the test harness seems to accept that, so I guess it's OK. :)

Here's how it works:

The outer loop n%{ }%n* just splits the input into lines, runs the code inside the braces for each line and joins the results with newlines.

' '% splits each line into an array of notes.  For each of those notes, 1\{'A#BC D EF G'?+}/ then converts that note into a semitone number by searching for each of its characters in the string 'A#BC D EF G' and adding up the positions (which will be -1 for any character not found in the string, notably including b).  (I'm sure I've seen this trick used before.)  Finally, the . duplicates each number, so that, at the end of the loop, e.g. the input F Ab C has been turned into [9 9 0 0 4 4].

We then sort the notes with $, move the first note to the end with (+, and split the array into pairs with 2/, so that it now looks e.g. like [[9 0] [0 4] [4 9]].  Then {~- 12%}% maps each pair of notes into its difference modulo 12, turning our example array into [9 8 7].

Next, .(+ makes a copy of the array and rotates its elements left by one position.  We do this twice and collect the copies into an array with ], so that our example now looks like [[9 8 7] [8 7 9] [7 9 8]].

We then sort this array of arrays with $ and take the first element — in this case [7 9 8] — with 0=.  We then make a copy of this array (.), sort it ($), collect both the unsorted and the unsorted array into another array of arrays (]), and search for the first occurrence of the array [7 8 9] (which is written as 10,7> to save two chars) in it.

This gives us either 0 (if the unsorted array was [7 8 9], and thus the chord is major), 1 (if the unsorted array was a permutation of [7 8 9], which, given that its first element must be smallest, can only be [7 9 8], making the chord minor) or -1 (if even the sorted array does not equal [7 8 9]).

This number is then used as a starting index into the string "MMaijnoorr\n\n" (where the \ns are given as actual linefeeds in the code), from which we take that character and every second subsequent one as the output.  If the index is -1, we start from the last character of the string, which is just a line feed.

ContentLicense: CC BY-SA 3.0

Title: The Major-Minor Dichotomy

Body:
GolfScript, 83 chars

n%{' '%{1\{'A#BC D EF G'?+}/.}%$(+2/{~- 12%}%.(+.(+]$0=.$]10,7>?'MMaijnoorr

'>2%}%

This is a quick first solution; I'm sure this can be golfed further.  Passes the bash test suite, after fixing the bug pointed out by flodel in the comments.

Edit 1: Saved 5 chars with a shorter way to recognize the canonicalized major and minor chord patterns.

Edit 2: Saved 2 more chars with more compact output encoding inspired by grc's solution.  (Thanks!)  As a side effect, the code now prints an extra blank line after the output, but the test harness seems to accept that, so I guess it's OK. :)

Here's how it works:

The outer loop n%{ }%n* just splits the input into lines, runs the code inside the braces for each line and joins the results with newlines.

' '% splits each line into an array of notes.  For each of those notes, 1\{'A#BC D EF G'?+}/ then converts that note into a semitone number by searching for each of its characters in the string 'A#BC D EF G' and adding up the positions (which will be -1 for any character not found in the string, notably including b).  (I'm sure I've seen this trick used before.)  Finally, the . duplicates each number, so that, at the end of the loop, e.g. the input F Ab C has been turned into [9 9 0 0 4 4].

We then sort the notes with $, move the first note to the end with (+, and split the array into pairs with 2/, so that it now looks e.g. like [[9 0] [0 4] [4 9]].  Then {~- 12%}% maps each pair of notes into its difference modulo 12, turning our example array into [9 8 7].

Next, .(+ makes a copy of the array and rotates its elements left by one position.  We do this twice and collect the copies into an array with ], so that our example now looks like [[9 8 7] [8 7 9] [7 9 8]].

We then sort this array of arrays with $ and take the first element — in this case [7 9 8] — with 0=.  We then make a copy of this array (.), sort it ($), collect both the unsorted and the unsorted array into another array of arrays (]), and search for the first occurrence of the array [7 8 9] (which is written as 10,7> to save two chars) in it.

This gives us either 0 (if the unsorted array was [7 8 9], and thus the chord is major), 1 (if the unsorted array was a permutation of [7 8 9], which, given that its first element must be smallest, can only be [7 9 8], making the chord minor) or -1 (if even the sorted array does not equal [7 8 9]).

This number is then used as a starting index into the string "MMaijnoorr\n\n" (where the \ns are given as actual linefeeds in the code), from which we take that character and every second subsequent one as the output.  If the index is -1, we start from the last character of the string, which is just a line feed.


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

答:
J, <s>86</s> <s>84</s> 83 bytes

```<code>   load'viewmat'
   (255,0 72 224,:215,2#40)viewmat _9 _9|.2(b=.[,~[,.~[,[,.])0 b 14 21$1
</code>```

The approach is the same as @Gábor Fekete's with Python.

Left argument colors for viewmat is an array of RGB values, in our case:

```<code>255 255 255
  0  72 224
215  40  40
</code>```

And the right argument is a matrix of indices of colors.

(_9 _9 |. matrix) instructs to shift matrix 9 items in each dimension.

Scary construction (border ([,~[,.~[,[,.]) matrix) wraps matrix with number border.

And (14 21 $ 1) makes 14×21 matrix of ones.

The output is displayed in separate resizable window, pretty large by default.

Thanks

miles - saved 2 bytes with reordering the colors, used the feature of , that duplicates the numbers (255) for the shape agreement.

Title: Draw the national flag of Iceland

Body:
J, <s>86</s> <s>84</s> 83 bytes

   load'viewmat'
   (255,0 72 224,:215,2#40)viewmat _9 _9|.2(b=.[,~[,.~[,[,.])0 b 14 21$1

The approach is the same as @Gábor Fekete's with Python.

Left argument colors for viewmat is an array of RGB values, in our case:

255 255 255
  0  72 224
215  40  40

And the right argument is a matrix of indices of colors.

(_9 _9 |. matrix) instructs to shift matrix 9 items in each dimension.

Scary construction (border ([,~[,.~[,[,.]) matrix) wraps matrix with number border.

And (14 21 $ 1) makes 14×21 matrix of ones.

The output is displayed in separate resizable window, pretty large by default.

Thanks

miles - saved 2 bytes with reordering the colors, used the feature of , that duplicates the numbers (255) for the shape agreement.


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

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

Test Cases:

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

f(9)=42

f(14)=1308

f(15)=2605

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

答:
JavaScript, 54 52

```<code>f=n=>Math.round(n<3?1:2*f(n-1)-n%2*f(parseInt(n/2)))
</code>```

Based on the C answer.

Saved 2 bytes by using parseInt instead of Math.floor

Title: Narayana-Zidek-Capell numbers

Body:
JavaScript, 54 52

f=n=>Math.round(n<3?1:2*f(n-1)-n%2*f(parseInt(n/2)))

Based on the C answer.

Saved 2 bytes by using parseInt instead of Math.floor


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

答:
MATLAB, <s>3'062.5</s> 2'888.125 bytes

This approach just ditches the last row and the last column of the square, and converts each entry into words of a certain bit depth. The bit depth is chosen minimal for the given size square. (Suggestion by @KarlNapf) These words are just appended to each other.  Decompression is just the reverse.

The sum for all the test cases is 23'105 bits or 2'888.125 bytes. (Still holds for the updated test cases, as the size of my outputs is only dependent of the size of the input.)

function bin=compress(a)
%get rid of last row and column:
s=a(1:end-1,1:end-1);
s = s(:)';
bin = [];
%choose bit depth:
bitDepth = ceil(log2(numel(a(:,1))));
for x=s;
    bin = [bin, dec2bin(x,bitDepth)];
end
end

function a=decompress(bin)
%determine bit depth
N=0;
f=@(n)ceil(log2(n)).*(n-1).^2;
while f(N)~= numel(bin)
    N=N+1;
end
bitDepth = ceil(log2(N));
%binary to decimal:
assert(mod(numel(bin),bitDepth)==0,'invalid input length')
a=[];
for k=1:numel(bin)/bitDepth;
    number = bin2dec([bin(bitDepth*(k-1) + (1:bitDepth)),' ']);
    a = [a,number];
end
n = sqrt(numel(a));
a = reshape(a,n,n);
disp(a)
%reconstruct last row/column:
n=size(a,1)+1;
a(n,n)=0;%resize
%complete rows:
v = 0:n-1;
for k=1:n
    a(k,n) = setdiff(v,a(k,1:n-1));
    a(n,k) = setdiff(v,a(1:n-1,k));
end
end
```

Title: Latin square compression


答:
Python, <s>6052</s> <s>4521</s> 3556 bytes

compress takes the square as a multiline string, just like the examples and returns a binary string, whereas decompress does the opposite.

import bz2
import math

def compress(L):
 if L=="0":
  C = []
 else:
  #split elements
  elems=[l.split(',') for l in L.split('\n')]
  n=len(elems)
  #remove last row and col
  cropd=[e[:-1] for e in elems][:-1]
  C = [int(c) for d in cropd for c in d]

 #turn to string
 B=map(chr,C)
 B=''.join(B)

 #compress if needed
 if len(B) > 36:
  BZ=bz2.BZ2Compressor(9)
  BZ.compress(B)
  B=BZ.flush()

 return B

def decompress(C):

 #decompress if needed
 if len(C) > 40:
  BZ=bz2.BZ2Decompressor()
  C=BZ.decompress(C)

 #return to int and determine length
 C = map(ord,C)
 n = int(math.sqrt(len(C)))
 if n==0: return "0"

 #reshape to list of lists
 elems = [C[i:i+n] for i in xrange(0, len(C), n)]

 #determine target length
 n = len(elems[0])+1
 L = []
 #restore last column
 for i in xrange(n-1):
  S = {j for j in range(n)}
  L.append([])
  for e in elems[i]:
   L[i].append(e)
   S.remove(e)
  L[i].append(S.pop())
 #restore last row
 L.append([])
 for col in xrange(n):
  S = {j for j in range(n)}
  for row in xrange(n-1):
   S.remove(L[row][col])
  L[-1].append(S.pop())
 #merge elements
 orig='\n'.join([','.join([str(e) for e in l]) for l in L])
 return orig
```

Remove the last row+column and zip the rest.

Edit1: well base64 does not seem necessary

Edit2: now converting the chopped table into a binary string and compress only if necessary

Title: Latin square compression

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

Body:
Python, <s>6052</s> <s>4521</s> 3556 bytes

compress takes the square as a multiline string, just like the examples and returns a binary string, whereas decompress does the opposite.

import bz2
import math

def compress(L):
 if L=="0":
  C = []
 else:
  #split elements
  elems=[l.split(',') for l in L.split('\n')]
  n=len(elems)
  #remove last row and col
  cropd=[e[:-1] for e in elems][:-1]
  C = [int(c) for d in cropd for c in d]

 #turn to string
 B=map(chr,C)
 B=''.join(B)

 #compress if needed
 if len(B) > 36:
  BZ=bz2.BZ2Compressor(9)
  BZ.compress(B)
  B=BZ.flush()

 return B

def decompress(C):

 #decompress if needed
 if len(C) > 40:
  BZ=bz2.BZ2Decompressor()
  C=BZ.decompress(C)

 #return to int and determine length
 C = map(ord,C)
 n = int(math.sqrt(len(C)))
 if n==0: return "0"

 #reshape to list of lists
 elems = [C[i:i+n] for i in xrange(0, len(C), n)]

 #determine target length
 n = len(elems[0])+1
 L = []
 #restore last column
 for i in xrange(n-1):
  S = {j for j in range(n)}
  L.append([])
  for e in elems[i]:
   L[i].append(e)
   S.remove(e)
  L[i].append(S.pop())
 #restore last row
 L.append([])
 for col in xrange(n):
  S = {j for j in range(n)}
  for row in xrange(n-1):
   S.remove(L[row][col])
  L[-1].append(S.pop())
 #merge elements
 orig='\n'.join([','.join([str(e) for e in l]) for l in L])
 return orig

Remove the last row+column and zip the rest.

Edit1: well base64 does not seem necessary

Edit2: now converting the chopped table into a binary string and compress only if necessary


问:
Return the nth digit of the sequence of aliquot series

0. DEFINITIONS

A sequence is a list of numbers.

A series is the sum of a list of numbers.

The set of natural numbers contains all "non-negative integers greater than zero".

A divisor (in this context) of a natural number j is a natural number i, such that j÷i is also a natural number.

1. PREAMBLE

A couple of other questions on this site mention the concept of the aliquot, or the sequence of divisors of a natural number a which are less than a. Determining amicable numbers involves computing the sum of these divisors, called an aliquot sum or aliquot series. Every natural number has its own aliquot sum, although the value of a number's aliquot sum is not necessarily unique to that number. (Exempli gratia, every prime number has an aliquot sum of 1.)

2. CHALLENGE

Given a natural number n, return the nth digit of the sequence of aliquot sums. The first several series in the sequence, starting with the series for 1, are:

```<code>{0, 1, 1, 3, 1, 6, 1, 7, 4, 8, 1, 16, 1, 10, 9, 15, 1, 21, 1, 22, 11, 14, 1, 36, 6, 16, 13}
</code>```

Concatenated, these look like:

```<code>0113161748116110915121122111413661613
</code>```

Input may be zero-indexed or one-indexed, according to your preference. Solutions must be programs or functions capable of returning the 10,000th digit (input up to 9999 or 10000). The shortest working solution wins.

3. TEST CASES

Correct input-output pairs should include, but are not limited to, the following:

```<code>   0 or     1    ->    0
   4 or     5    ->    1
  12 or    13    ->    6
9999 or 10000    ->    7
</code>```

The number preceding the "or" is 0-indexed; the number following is 1-indexed.

Additional test cases may be provided upon request.

4. REFERENCES

OEIS has a list of numbers and their aliquot sums.

答:
Haskell, 52 bytes

```<code>(([1..]>>= \n->show$sum[m|m<-[1..n-1],mod n m<1])!!)
</code>```

Usage example: (([1..]>>= \n->show$sum[m|m<-[1..n-1],mod n m<1])!!) 12-> 6.

It's a direct implementation of the definition: foreach n sum it's divisors and convert it into a string. Concatenate all such strings and pick the element at the requested index. Haskell's laziness takes only as much ns from the infinite list [1..] as needed.

Body:
Haskell, 52 bytes

(([1..]>>= \n->show$sum[m|m<-[1..n-1],mod n m<1])!!)

Usage example: (([1..]>>= \n->show$sum[m|m<-[1..n-1],mod n m<1])!!) 12-> 6.

It's a direct implementation of the definition: foreach n sum it's divisors and convert it into a string. Concatenate all such strings and pick the element at the requested index. Haskell's laziness takes only as much ns from the infinite list [1..] as needed.


答:
Logo, <s>216</s> 188 bytes

Using Calormen.com's implementation.  For you purists, the implementation uses some antialiasing which feathers the edges a little.  I did waste 3 bytes hiding the turtle, though, so that should make up for it.

This could be reduced greatly if your Logo implementation lets you set the size of the window.  Then you could wrap and make the turtle plow on through to make the cross in four strokes, and skip having to trim it up with a border.

```<code>TO X :C :S
setpc :C
setpensize :S
home
pd
setx 100
setx 36
bk 36
fd 72
pu
END
setpc "#48e0
fill
X 7 16
X "#d72828 8
fd 4
pe
pd
setx -4
bk 80
setx 104
fd 80
setx 0
ht
</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:
Logo, <s>216</s> 188 bytes

Using Calormen.com's implementation.  For you purists, the implementation uses some antialiasing which feathers the edges a little.  I did waste 3 bytes hiding the turtle, though, so that should make up for it.

This could be reduced greatly if your Logo implementation lets you set the size of the window.  Then you could wrap and make the turtle plow on through to make the cross in four strokes, and skip having to trim it up with a border.

TO X :C :S
setpc :C
setpensize :S
home
pd
setx 100
setx 36
bk 36
fd 72
pu
END
setpc "#48e0
fill
X 7 16
X "#d72828 8
fd 4
pe
pd
setx -4
bk 80
setx 104
fd 80
setx 0
ht


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

答:
PowerShell v2+, <s>130</s> <s>120</s> <s>116</s> 110 bytes

```<code>param($n)$i=0;10..1|%{" "*$i+(("-"+("$($i+1)"*([math]::Max($n-10+$_,0))*2)),"-10")[$n-$_-eq9]+"-";$i+=$i-ne$n}
</code>```

Edit 1 - Golfed 10 bytes by eliminating $x variable and slightly redoing how the string is formulated.

Edit 2 - Golfed another 4 bytes by redoing how input happens and by redoing how $i is calculated each loop.

Edit 3 - Saved 6 bytes by OP allowing input as 0..10, so no need to divide by 10.

Surprisingly difficult!

Takes input as 1,5, etc., stored in $n. Sets helper $i variable (one of the very rare times that a variable needs to be initialized to 0 in PowerShell), and then starts a loop from 10 to 1.

Each iteration, we set start our string with a number of spaces equal to $i, followed by a pseudo-ternary (... , ...)[]. Inside the pseudo-ternary, we select a string of either - with a number of digits (the higher of $n-10+$_ or 0, multiplied by 2), or the string -10 -- the selection is based on whether we're at the 10th iteration and our input was 100. We concatenate that with a final -. That resultant string is placed onto the pipeline.

Finally, we increment $i, and this was really tricky. We wound up using a binary-cast-to-int trick to only increment $i up until it reaches $n, and then keeping it at the same value thereafter. This ensures we've reached the "end" of the zipper indentation at the appropriate level.

Once the loop has finished, the resultant strings are all accumulated on the pipeline and output is implicit.

Examples

```<code>PS C:\Tools\Scripts\golfing> .\unzip-some-numbers.ps1 70
-11111111111111-
 -222222222222-
  -3333333333-
   -44444444-
    -555555-
     -6666-
      -77-
       --
       --
       --

PS C:\Tools\Scripts\golfing> .\unzip-some-numbers.ps1 100
-11111111111111111111-
 -222222222222222222-
  -3333333333333333-
   -44444444444444-
    -555555555555-
     -6666666666-
      -77777777-
       -888888-
        -9999-
         -10-
</code>```

Title: Unzip some numbers

Body:
PowerShell v2+, <s>130</s> <s>120</s> <s>116</s> 110 bytes

param($n)$i=0;10..1|%{" "*$i+(("-"+("$($i+1)"*([math]::Max($n-10+$_,0))*2)),"-10")[$n-$_-eq9]+"-";$i+=$i-ne$n}

Edit 1 - Golfed 10 bytes by eliminating $x variable and slightly redoing how the string is formulated.

Edit 2 - Golfed another 4 bytes by redoing how input happens and by redoing how $i is calculated each loop.

Edit 3 - Saved 6 bytes by OP allowing input as 0..10, so no need to divide by 10.

Surprisingly difficult!

Takes input as 1,5, etc., stored in $n. Sets helper $i variable (one of the very rare times that a variable needs to be initialized to 0 in PowerShell), and then starts a loop from 10 to 1.

Each iteration, we set start our string with a number of spaces equal to $i, followed by a pseudo-ternary (... , ...)[]. Inside the pseudo-ternary, we select a string of either - with a number of digits (the higher of $n-10+$_ or 0, multiplied by 2), or the string -10 -- the selection is based on whether we're at the 10th iteration and our input was 100. We concatenate that with a final -. That resultant string is placed onto the pipeline.

Finally, we increment $i, and this was really tricky. We wound up using a binary-cast-to-int trick to only increment $i up until it reaches $n, and then keeping it at the same value thereafter. This ensures we've reached the "end" of the zipper indentation at the appropriate level.

Once the loop has finished, the resultant strings are all accumulated on the pipeline and output is implicit.

Examples

PS C:\Tools\Scripts\golfing> .\unzip-some-numbers.ps1 70
-11111111111111-
 -222222222222-
  -3333333333-
   -44444444-
    -555555-
     -6666-
      -77-
       --
       --
       --

PS C:\Tools\Scripts\golfing> .\unzip-some-numbers.ps1 100
-11111111111111111111-
 -222222222222222222-
  -3333333333333333-
   -44444444444444-
    -555555555555-
     -6666666666-
      -77777777-
       -888888-
        -9999-
         -10-


答:
Python, 160

```<code>f='A#BC D EF G3453543'.find
try:
 while 1:x,y,z=sorted(map(lambda x:f(x[0])+f(x[1:])+1,raw_input().split()));print'MMianjoorrr'[f(`y-x`+`z-y`)/14:-1:2]
except:0
</code>```

Title: The Major-Minor Dichotomy

Body:
Given a list of chords label them as either 'Major' or ' Minor'.

Input

Input will be a list of chords, one per line, made up of 3 notes separated by a space. Each note will consist of the note name in uppercase (A-G) and an optional accidental (# or b). Chords may be in any inversion (i.e. the notes may be in any order).

Output

If the chord is major, output 'Major'. If the chord is minor, output 'Minor'. If the chord is neither major nor minor, output a blank line.

Example

Input

```<code>C E G
F Ab C
C Eb Gb
E G B
Db F Ab
Bb G D
D A Gb
</code>```

Output

```<code>Major
Minor

Minor
Major
Minor
Major
</code>```

Test scripts

As in some of my past questions, I've once again butchered some test scripts originally created by Joey and Ventero to provide some test cases for this question:

bash

Powershell

Usage: ./test [your program and its arguments]

Rewards

Each entry which I can verify that meets the spec, passes the tests and has obviously had some attempt at golfing will receive an upvote from me (so please provide usage instructions with your answer). The shortest solution by the end of 13/10/2012 will be accepted as the winner.

A little theory

For those of you with no musical theory knowledge here's enough information for you to be able to compete.

A major or minor chord is made up of three notes which are separated by a specific pattern of semitones. If we consider the root (bottom note) of the chord to be 0, then a major chord is the pattern 0-4-7 and a minor chord is the pattern 0-3-7. Things are made more awkward by the fact that some notes are a semitone apart and some are a tone apart. The spread of semitones from Ab-G# is as follows:

```<code>G#/Ab A A#/Bb B/Cb B#/C C#/Db D D#/Eb E/Fb E#/F F#/Gb G G#/Ab
  0   1   2    3     4    5   6   7    8     9    10  11  12
</code>```

G#/Ab means that that G# is the same note as Ab. From this we can see that the chord Ab C Eb is a major chord, and that Ab Cb Eb is minor.

To complicate matters further, the chord Eb Cb Ab is considered to be the same as Ab Cb Eb, Cb Eb Ab and Cb Ab Eb and so on. Every one of these variations is still a minor chord.

Body:
Python, 160

f='A#BC D EF G3453543'.find
try:
 while 1:x,y,z=sorted(map(lambda x:f(x[0])+f(x[1:])+1,raw_input().split()));print'MMianjoorrr'[f(`y-x`+`z-y`)/14:-1:2]
except:0


答:
Python3 - 3,572 3,581 bytes

```<code>from itertools import *
from math import *

def int2base(x,b,alphabet='0123456789abcdefghijklmnopqrstuvwxyz'):
    if isinstance(x,complex):
        return (int2base(x.real,b,alphabet) , int2base(x.imag,b,alphabet))
    if x<=0:
        if x==0:return alphabet[0]
        else:return  '-' + int2base(-x,b,alphabet)
    rets=''
    while x>0:
        x,idx = divmod(x,b)
        rets = alphabet[idx] + rets
    return rets

def lexicographic_index(p):
    result = 0
    for j in range(len(p)):
        k = sum(1 for i in p[j + 1:] if i < p[j])
        result += k * factorial(len(p) - j - 1)
    return result

def getPermutationByindex(sequence, index):
    S = list(sequence)
    permutation = []
    while S != []:
        f = factorial(len(S) - 1)
        i = int(floor(index / f))
        x = S[i]
        index %= f
        permutation.append(x)
        del S[i]
    return tuple(permutation)

alphabet = "abcdefghijklmnopqrstuvwxyz"

def dataCompress(lst):
    n = len(lst[0])

    output = alphabet[n-1]+"|"

    for line in lst:
        output += "%s|" % int2base(lexicographic_index(line), 36)

    return output[:len(output) - 1]

def dataDeCompress(data):
    indexes = data.split("|")
    n = alphabet.index(indexes[0]) + 1
    del indexes[0]

    lst = []

    for index in indexes:
        if index != '':
            lst.append(getPermutationByindex(range(n), int(index, 36)))

    return lst
</code>```

dataCompress takes a list of integer tuples and returns a string.

dateDeCompress takes a string and returns a list of integer tuples.

In short, for each line, this program takes that lines permutation index and saves it in base 36. Decompressing takes a long time with big inputs but compression is really fast even on big inputs.

Usage:

dataCompress([(2,0,1),(1,2,0),(0,1,2)])

result: c|4|3|0

dataDeCompress("c|4|3|0")

result: [(2, 0, 1), (1, 2, 0), (0, 1, 2)]

Title: Latin square compression

Body:
Python3 - 3,572 3,581 bytes

from itertools import *
from math import *

def int2base(x,b,alphabet='0123456789abcdefghijklmnopqrstuvwxyz'):
    if isinstance(x,complex):
        return (int2base(x.real,b,alphabet) , int2base(x.imag,b,alphabet))
    if x<=0:
        if x==0:return alphabet[0]
        else:return  '-' + int2base(-x,b,alphabet)
    rets=''
    while x>0:
        x,idx = divmod(x,b)
        rets = alphabet[idx] + rets
    return rets

def lexicographic_index(p):
    result = 0
    for j in range(len(p)):
        k = sum(1 for i in p[j + 1:] if i < p[j])
        result += k * factorial(len(p) - j - 1)
    return result

def getPermutationByindex(sequence, index):
    S = list(sequence)
    permutation = []
    while S != []:
        f = factorial(len(S) - 1)
        i = int(floor(index / f))
        x = S[i]
        index %= f
        permutation.append(x)
        del S[i]
    return tuple(permutation)

alphabet = "abcdefghijklmnopqrstuvwxyz"

def dataCompress(lst):
    n = len(lst[0])

    output = alphabet[n-1]+"|"

    for line in lst:
        output += "%s|" % int2base(lexicographic_index(line), 36)

    return output[:len(output) - 1]

def dataDeCompress(data):
    indexes = data.split("|")
    n = alphabet.index(indexes[0]) + 1
    del indexes[0]

    lst = []

    for index in indexes:
        if index != '':
            lst.append(getPermutationByindex(range(n), int(index, 36)))

    return lst

dataCompress takes a list of integer tuples and returns a string.

dateDeCompress takes a string and returns a list of integer tuples.

In short, for each line, this program takes that lines permutation index and saves it in base 36. Decompressing takes a long time with big inputs but compression is really fast even on big inputs.

Usage:

dataCompress([(2,0,1),(1,2,0),(0,1,2)])

result: c|4|3|0

dataDeCompress("c|4|3|0")

result: [(2, 0, 1), (1, 2, 0), (0, 1, 2)]


答:
Python 2 - 184 151 146 Bytes

```<code>def r(n):
  n/=10
  for i in range(1,11):
    if n<0:print"%s--"%p
    elif i>9:print" %s-10-"%p
    else:p=" "*~-i;print"%s-%s-"%(p,`i`*2*n);n-=1
</code>```

The last number kinda messed with me a little. I might be able to remove the second if statement if I look at it later.

EDIT: Thx to mbomb007 for removing 3 bytes. Thanks to charredgrass for the formatting tips to help remove lots and lots of bytes! :-D Thanks to TheBikingViking for helping with yet another two bytes!

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 - 184 151 146 Bytes

def r(n):
  n/=10
  for i in range(1,11):
    if n<0:print"%s--"%p
    elif i>9:print" %s-10-"%p
    else:p=" "*~-i;print"%s-%s-"%(p,`i`*2*n);n-=1

The last number kinda messed with me a little. I might be able to remove the second if statement if I look at it later.

EDIT: Thx to mbomb007 for removing 3 bytes. Thanks to charredgrass for the formatting tips to help remove lots and lots of bytes! :-D Thanks to TheBikingViking for helping with yet another two bytes!


问:
Distinct Sieves
Given a list of integers, create a boolean mask such that the true indices can be used to filter the distinct values from the list. Which index is selected as the true one does not matter as long as only one of them is selected for each set of indices corresponding to identical values.

The input will be a non-empty list of non-negative integers in a format suitable for your language and the output will be a list of boolean values following the specification above. You are allowed to use your own definitions of truthy and falsy values in the output list.

In my examples below, I define 1 to be truthy and 0 to be falsy.

```<code>[5, 4, 7, 1]  Input
[1, 1, 1, 1]  Output
              Select only the values with with true indicies in the sieve
[5  4  7  1]  Contains zero duplicate values

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

Test Cases

When there is an or, it means that there are multiple valid outputs. If there is a trailing ellipsis ... after the or, it means that not all of the possible outputs were listed.

```<code>[0] = [1]

[55] = [1]

[32, 44] = [1, 1]

[0, 0] = [1, 0] or [0, 1]

[9001, 9001, 9001] = [1, 0 , 0] or [0, 1, 0] or [0, 0, 1]

[5, 4, 7, 1] = [1, 1, 1, 1]

[1, 2, 3, 4, 3, 5] = [1, 1, 1, 1, 0, 1] or
                     [1, 1, 0, 1, 1, 1]

[5, 9, 7, 5, 6, 0, 5] = [1, 1, 1, 0, 1, 1, 0] or
                        [0, 1, 1, 1, 1, 1, 0] or
                        [0, 1, 1, 0, 1, 1, 1]

[0, 8, 6, 6, 3, 8, 7, 2] = [1, 1, 1, 0, 1, 0, 1, 1] or
                           [1, 0, 0, 1, 1, 1, 1, 1] or
                           [1, 0, 1, 0, 1, 1, 1, 1] or
                           [1, 1, 0, 1, 1, 0, 1, 1]

[45, 47, 47, 45, 24, 24, 24, 8, 47, 41, 47, 88]
= [1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1] or ...

[154, 993, 420, 154, 154, 689, 172, 417, 790, 175, 790, 790, 154, 172, 175, 175, 420, 417, 154, 175, 172, 175, 172, 993, 689, 993, 993, 790]
= [1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] or ...
</code>```

Rules

This is code-golf so the shortest solution wins.

Builtins are allowed!

You are allowed to use your own definitions of truthy and falsy values in the output list. If you choose to do so, please state your definitions.

The input will be a non-empty list of non-negative integers.

You are free to choose between outputting only one of the sieves or multiple or even all of them. As long as each sieve is valid, it will be accepted.

答:
Perl 5 + Perligata, 343 bytes

315 bytes, plus 28 for -MLingua::Romana::Perligata

Use as perl -MLingua::Romana::Perligata foo.pl; input (from stdin) and output (to stdout) are underscore-separated strings of decimal integers. Tested on Strawberry 5.20.2 with version 0.6 of Perligata; I don't know whether it works with Perligata version 0.50.

```<code>huic vestibulo perlegementum da.qis _ scindementa da.dum qis fac sic
ao qis decumulamentum da.ao aum tum nullum addementum da.meo io.meo ro.per ium in qis fac sic
si ium tum aum aequalitas fac sic ro I da cis cis
ro nullum tum non rum addementum da.capita bis rum cis
per in bis fac sic hoc tum _ egresso scribe cis
</code>```

Obviously this is clear as a bell. In case it's not, run it with -MLingua::Romana::Perligata=converte instead of -MLingua::Romana::Perligata, and perl will, instead of running the script, output a translation into regular Perl:

```<code> $_ = Lingua::Romana::Perligata::getline (*STDIN );
 @q = split ( '_');
while (@q) { $a = pop (@q );
 $a =  ($a + 0);
my $i ;
my $r ;
for $i (@q) {if ( ($i eq $a)) { $r = 1}
}
;
 $r =  (0 +  ! ($r));
unshift (@b, $r)}
;
for $_ (@b) {print (STDOUT $_, '_')}
</code>```

For a token-by-token analysis, use -MLingua::Romana::Perligata=discribe.

Golfing notes:

Undocumented (but unsurprising), you don't need a space after ..

(Also unsurprising,) scinde doesn't need a second argument, and uses hoc.

I had to use ao aum tum nullum addementum da because I couldn't get morde to work.

Similarly, I used per ium in qis... ro I da because I couldn't get vanne to work.

Instead of huic vestibulo perlegementum da, I tried -pMLingua::Romana::Perligata, but couldn't get it to work, either.

Just for kicks (although this whole answer was just for kicks):

After cleaning it up to Huic vestibulo perlegementum da. Qis lacunam scindementa da. Dum qis fac sic ao qis decumulamentum da. Ao aum tum nullum addementum da. Meo io. Meo ro. Per ium in qis fac sic si ium tum aum aequalitas fac sic ro I da cis cis. Ro nullum tum non rum addementum da. Capita bis rum cis. Per in bis fac sic hoc tum lacunam egresso scribe cis., Google Translate gives This court perlegementum grant. QIS gap scindementa grant. While QIS QIS decumulamentum do so ao da. Ao sum and no addementum grant. My io. My ro. Through ium in QIS do so if the sum ium equality do so ro 1 from cis. Ro was not any rum addementum grant. The heads of the bis side. Write, do so as soon as he at that time that in the gap by the Kish was taken..

Title: Distinct Sieves

Body:
Perl 5 + Perligata, 343 bytes

315 bytes, plus 28 for -MLingua::Romana::Perligata

Use as perl -MLingua::Romana::Perligata foo.pl; input (from stdin) and output (to stdout) are underscore-separated strings of decimal integers. Tested on Strawberry 5.20.2 with version 0.6 of Perligata; I don't know whether it works with Perligata version 0.50.

huic vestibulo perlegementum da.qis _ scindementa da.dum qis fac sic
ao qis decumulamentum da.ao aum tum nullum addementum da.meo io.meo ro.per ium in qis fac sic
si ium tum aum aequalitas fac sic ro I da cis cis
ro nullum tum non rum addementum da.capita bis rum cis
per in bis fac sic hoc tum _ egresso scribe cis

Obviously this is clear as a bell. In case it's not, run it with -MLingua::Romana::Perligata=converte instead of -MLingua::Romana::Perligata, and perl will, instead of running the script, output a translation into regular Perl:

 $_ = Lingua::Romana::Perligata::getline (*STDIN );
 @q = split ( '_');
while (@q) { $a = pop (@q );
 $a =  ($a + 0);
my $i ;
my $r ;
for $i (@q) {if ( ($i eq $a)) { $r = 1}
}
;
 $r =  (0 +  ! ($r));
unshift (@b, $r)}
;
for $_ (@b) {print (STDOUT $_, '_')}

For a token-by-token analysis, use -MLingua::Romana::Perligata=discribe.

Golfing notes:

Undocumented (but unsurprising), you don't need a space after ..

(Also unsurprising,) scinde doesn't need a second argument, and uses hoc.

I had to use ao aum tum nullum addementum da because I couldn't get morde to work.

Similarly, I used per ium in qis... ro I da because I couldn't get vanne to work.

Instead of huic vestibulo perlegementum da, I tried -pMLingua::Romana::Perligata, but couldn't get it to work, either.

Just for kicks (although this whole answer was just for kicks):

After cleaning it up to Huic vestibulo perlegementum da. Qis lacunam scindementa da. Dum qis fac sic ao qis decumulamentum da. Ao aum tum nullum addementum da. Meo io. Meo ro. Per ium in qis fac sic si ium tum aum aequalitas fac sic ro I da cis cis. Ro nullum tum non rum addementum da. Capita bis rum cis. Per in bis fac sic hoc tum lacunam egresso scribe cis., Google Translate gives This court perlegementum grant. QIS gap scindementa grant. While QIS QIS decumulamentum do so ao da. Ao sum and no addementum grant. My io. My ro. Through ium in QIS do so if the sum ium equality do so ro 1 from cis. Ro was not any rum addementum grant. The heads of the bis side. Write, do so as soon as he at that time that in the gap by the Kish was taken..


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

```

答:
Benul, 0 bytes

``````

In Benul, programs are placed in an implicit infinite loop and require special conditions to terminate.

Body:
Benul, 0 bytes

In Benul, programs are placed in an implicit infinite loop and require special conditions to terminate.


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

```

答:
Pyke, 1 byte

```<code>,
</code>```

Try it here!

Transpose.

Body:
Pyke, 1 byte

,

Try it here!

Transpose.


答:
Brachylog, 5 bytes

```<code>z:ca.
</code>```

Expects a list of strings as input, e.g. run_from_atom('z:ca.',["money":"taken":"trust"],Output).

Explanation

```<code>z       Zip the strings in the Input list
 :ca.   output is the application of concatenation to each element of the zip
</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:
Brachylog, 5 bytes

z:ca.

Expects a list of strings as input, e.g. run_from_atom('z:ca.',["money":"taken":"trust"],Output).

Explanation

z       Zip the strings in the Input list
 :ca.   output is the application of concatenation to each element of the zip


答:
Python, <s>36</s> 29 bytes

zip(*s) returns a list of tuples of each character, transposed.

lambda s:map(''.join,zip(*s))
```

Try it online

Body:
Python, <s>36</s> 29 bytes

zip(*s) returns a list of tuples of each character, transposed.

lambda s:map(''.join,zip(*s))

Try it online


问:
How to determine if a number is odd or even without mod -or- bitwise operations?
How to determine if a number is odd or even without mod -or- bitwise operations?

This challenge is grossly inefficient, but challenges your ability to think outside the box for a creative solution.

EDIT:

Please create a function. Also, while regex is a fun response, the function should accept any valid number.

BACKGROUND:
This question stems from my earliest programming days.  The homework for our first day of class was to write a simple program that printed 'odd' or 'even'.  Being the brat I was, I didn't read the book we had for the class where it simply showed us how to use % to determine that.  I spent about a half hour pacing back in forth in my room trying to think of a way to do this and had remembered from the lecture that numbers can lose and gain precision as they are cast from one primitive type to another.  Therefore, if you took the number, divided it by two and then multiplied it back didn't equal the original number, then you would know that the number was odd.

I was stunned the next day, while our instructor was evaluating our programs, that he thought that it was the most original, if inefficient, way of solving the problem.

答:
Coq, 103

```<code>Fixpoint even n:=match n with O=>true|S n=>odd n end with odd n:=match n with O=>false|S n=>even n end.
</code>```

As far as I can tell this is the first coq entry on codegolf.

Even shorter (59):

```<code>Fixpoint even n:=match n with O=>true|S n=>negb(even n)end.
</code>```

Body:
Coq, 103

Fixpoint even n:=match n with O=>true|S n=>odd n end with odd n:=match n with O=>false|S n=>even n end.

As far as I can tell this is the first coq entry on codegolf.

Even shorter (59):

Fixpoint even n:=match n with O=>true|S n=>negb(even n)end.


答:
Jelly, 1 byte

```<code>Z
</code>```

Try it online!

Body:
Jelly, 1 byte

Z

Try it online!


答:
JavaScript ES6, <s>48</s> 46 bytes

```<code>a=>[...a[0]].map((n,x)=>a.map(a=>a[x]).join``)
</code>```

I feel left out, we have no built in zip function. Thanks nicael for pointing out my type error.

Usage

```<code>(a=>[...a[0]].map((n,x)=>a.map(a=>a[x])))(["asd","dsa"]); //or whatever is above, might change due to edits
</code>```

returns

```<code>["ad","ss","da"]
</code>```

Body:
JavaScript ES6, <s>48</s> 46 bytes

a=>[...a[0]].map((n,x)=>a.map(a=>a[x]).join``)

I feel left out, we have no built in zip function. Thanks nicael for pointing out my type error.

Usage

(a=>[...a[0]].map((n,x)=>a.map(a=>a[x])))(["asd","dsa"]); //or whatever is above, might change due to edits

returns

["ad","ss","da"]


答:
Pyth, 1 byte

```<code>C
</code>```

Try it here

Another transpose builtin

Body:
Pyth, 1 byte

C

Try it here

Another transpose builtin


答:
MATL, 1 byte

```<code>!
</code>```

Try it online!

Takes input implicitly, transposes, displays output implicitly.

Body:
MATL, 1 byte

!

Try it online!

Takes input implicitly, transposes, displays output implicitly.


答:
MATLAB / Octave, 4 bytes

```<code>@(x)x'
</code>```

This defines an anonymous function. Input format is ['car'; 'dog'; 'man'; 'yay'].

Try it here.

Body:
MATLAB / Octave, 4 bytes

@(x)x'

This defines an anonymous function. Input format is ['car'; 'dog'; 'man'; 'yay'].

Try it here.


答:
CJam, <s>6</s> 5 bytes

Saved 1 byte thanks to Luis Mendo.

```<code>qS%zp
</code>```

Try it online!

```<code>q      e# Get all input
 S%    e# Split it on spaces
   z   e# Take the transpose
    p  e# Print it as an array
</code>```

Body:
CJam, <s>6</s> 5 bytes

Saved 1 byte thanks to Luis Mendo.

qS%zp

Try it online!

q      e# Get all input
 S%    e# Split it on spaces
   z   e# Take the transpose
    p  e# Print it as an array


答:
CJam, 3 bytes

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

This is a code block (equivalent to a function; allowed by default) that expects the input on the stack and leaves the output on the stack.

Try it online!

Body:
CJam, 3 bytes

{z}

This is a code block (equivalent to a function; allowed by default) that expects the input on the stack and leaves the output on the stack.

Try it online!


答:
PowerShell v2+, <s>66</s> 54 bytes

```<code>param($n)for($x=0;$n[0][$x];$x++){-join($n|%{$_[$x]})}
</code>```

Yo ... no map, no zip, no transpose, etc., so we get to roll our own. Big props to @DarthTwon for the 12-byte golf.

Takes input $n, sets up a for loop. Initialization sets $x to 0, the test is whether we still have letters in our word $n[0][$x], and we increment $x++ each iteration.

Inside the loop, we take our array of strings, pipe it to an inner loop that spits out the appropriate character from each word. That is encapsulated in a -join to form a string, and that string is left on the pipeline. At end of execution, the strings on the pipeline are implicitly printed.

```<code>PS C:\Tools\Scripts\golfing> .\convert-n-strings.ps1 "Darth","-Twon","Rocks"
D-R
aTo
rwc
tok
hns
</code>```

Body:
PowerShell v2+, <s>66</s> 54 bytes

param($n)for($x=0;$n[0][$x];$x++){-join($n|%{$_[$x]})}

Yo ... no map, no zip, no transpose, etc., so we get to roll our own. Big props to @DarthTwon for the 12-byte golf.

Takes input $n, sets up a for loop. Initialization sets $x to 0, the test is whether we still have letters in our word $n[0][$x], and we increment $x++ each iteration.

Inside the loop, we take our array of strings, pipe it to an inner loop that spits out the appropriate character from each word. That is encapsulated in a -join to form a string, and that string is left on the pipeline. At end of execution, the strings on the pipeline are implicitly printed.

PS C:\Tools\Scripts\golfing> .\convert-n-strings.ps1 "Darth","-Twon","Rocks"
D-R
aTo
rwc
tok
hns


Title: Unzip some numbers

Body:
MATL, <s>48</s> <s>41</s> 35 bytes

0:9"@GhX<Z"45h@QVG@-E@8>-OhX>Y"h45h

Try it online!


问:
Code Golf Bingo!
You are given a Bingo board and a list of calls.  You must print BINGO! as soon as your board wins the game.

Bingo boards look like this:

They will be specified like this:

```<code>14 29 38 52 74
4 18 33 46 62
7 16 * 60 71
9 27 44 51 67
12 23 35 47 73
</code>```

Immediately following the board will be calls, like this:

```<code>B7
I29
G60
G51
O71
I23
I16
N38
</code>```

You must echo the calls out to standard output until just after the call that makes you win (get a row, column, or 5-long diagonal all filled), then print BINGO!.

For the above example, print:

```<code>B7
I29
G60
G51
O71
I23
I16
BINGO!
</code>```

Rules

Standard code-golf rules, shortest code wins.

Details

There will always be enough calls to guarantee you a Bingo.  There will be no duplicate numbers on the board, and no duplicate calls.  Boards will always have correctly matched numbers and letters (the B column contains only 1-15, the I column contains only 16-30, and so on), as will calls.  The one and only free space will always be in the middle, marked with * instead of a number.  Consuming and discarding calls from standard input after the winning call is allowed, but not required.

Make your own test cases!

答:
Perl, 122 120 char

```<code>$b=join'. .
',map~~<>,0..4;while(<>){/(\d+)/;$b=~s/\b$1\b/*/;print;
$b=~/(\*\s(\S+\s){$_}){4}\*/&&die"BINGO!
"for 0..7}
</code>```

Build the card in $b with two additional junky columns.
Replace the numbers that are called on the card with * and print the called number.
Then the last regular expression will evaluate to true when there are 5 regularly spaced *s on the board.

Title: Code Golf Bingo!

Body:
Perl, 122 120 char

$b=join'. .
',map~~<>,0..4;while(<>){/(\d+)/;$b=~s/\b$1\b/*/;print;
$b=~/(\*\s(\S+\s){$_}){4}\*/&&die"BINGO!
"for 0..7}

Build the card in $b with two additional junky columns.
Replace the numbers that are called on the card with * and print the called number.
Then the last regular expression will evaluate to true when there are 5 regularly spaced *s on the board.


问:
Print a bunch of uninteresting numbers!
An uninteresting number (which I totally didn't make up only for this challenge) is created like this:

Take a positive integer N

Create a new number O by adding the digits of N at the end of N

The final uninteresting number is O*N

For example for N=12:

O = 1212

O*N = 1212 * 12

Final number is 14544

Input

A positive integer N (N > 0) or your language's equivalent. You don't have to catch incorrect input.

Output

The corresponding uninteresting number.

Test cases

```<code>  1 -> 11
  2 -> 44
  3 -> 99
 10 -> 10100
174 -> 30306276
</code>```

Scoring

Shortest Code in Bytes wins.

答:
Your mom, 6 bytes

```<code>ð::+*
</code>```

The name of this language is a idea from mbomb007...

Explanation:

```<code>ð     Read a string from stdin
 ::   : is the duplicate operator, so the input is duplicated 2 times
   +*
      Implicit output
</code>```

Title: Print a bunch of uninteresting numbers!

Body:
Your mom, 6 bytes

ð::+*

The name of this language is a idea from mbomb007...

Explanation:

ð     Read a string from stdin
 ::   : is the duplicate operator, so the input is duplicated 2 times
   +*
      Implicit output

ContentLicense: CC BY-SA 4.0


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

答:
Ruby, 102 99 84 83 bytes

```<code>s='
'*203;33.times{|j|a=(' '*rand(6)).ljust 6,'=';6.times{|i|s[i*34+j]=a[i]}};$><<s
</code>```

New and significantly shorter approach, where I start with string full of newlines.

Older version...

```<code>s='';204.times do|i|s+=->i{i%34==0?"\n":i>170?'=':s[i-34]=='='?'=':rand(2)==1?'=':' '}[i]end;puts s
</code>```

...gave output with leading new line. My first submission in Ruby, using similar approach to @Barbarossa's one, but in single loop.

What I liked in Ruby while working on this program:

.times loop

rand() which is pretty short

stacking ternary operators without parentheses

I didn't like (mainly in terms of golfing):

mandatory $ for global variables not so mandatory in .times loop

do and end keywords which can be replaced with single-line block

0 is not falsy

Title: Illustrate music beats

Body:
Ruby, 102 99 84 83 bytes

s='
'*203;33.times{|j|a=(' '*rand(6)).ljust 6,'=';6.times{|i|s[i*34+j]=a[i]}};$><<s

New and significantly shorter approach, where I start with string full of newlines.

Older version...

s='';204.times do|i|s+=->i{i%34==0?"\n":i>170?'=':s[i-34]=='='?'=':rand(2)==1?'=':' '}[i]end;puts s

...gave output with leading new line. My first submission in Ruby, using similar approach to @Barbarossa's one, but in single loop.

What I liked in Ruby while working on this program:

.times loop

rand() which is pretty short

stacking ternary operators without parentheses

I didn't like (mainly in terms of golfing):

mandatory $ for global variables not so mandatory in .times loop

do and end keywords which can be replaced with single-line block

0 is not falsy


答:
Ruby, 74 bytes

Uses the implied-zero format specified in the question, so 40% is f[4] if the anonymous function is assigned to f. If a full percentage is needed, +6 bytes for n/=10;

Try it online!

```<code>->n{10.times{|i|puts' '*[i,n].min+"-#{i>8?10:(i+1).to_s*2*(n-i)if i<n}-"}}
</code>```

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:
Ruby, 74 bytes

Uses the implied-zero format specified in the question, so 40% is f[4] if the anonymous function is assigned to f. If a full percentage is needed, +6 bytes for n/=10;

Try it online!

->n{10.times{|i|puts' '*[i,n].min+"-#{i>8?10:(i+1).to_s*2*(n-i)if i<n}-"}}


答:
05AB1E, 3 bytes

```<code>ø€J
</code>```

Explained

```<code>     # implicit input, eg: ['car', 'dog', 'man', 'yay']
ø    # zip, producing [['c', 'd', 'm', 'y'], ['a', 'o', 'a', 'a'], ['r', 'g', 'n', 'y']]
 €J  # map join, resulting in ['cdmy', 'aoaa', 'rgny']
</code>```

Try it online

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:
05AB1E, 3 bytes

ø€J

Explained

     # implicit input, eg: ['car', 'dog', 'man', 'yay']
ø    # zip, producing [['c', 'd', 'm', 'y'], ['a', 'o', 'a', 'a'], ['r', 'g', 'n', 'y']]
 €J  # map join, resulting in ['cdmy', 'aoaa', 'rgny']

Try it online


答:
Ruby, 46 bytes

Probably the first time that "Ruby strings aren't Enumerables" is actually biting me hard since I had to map the strings into arrays before processing. (Normally having to use String#chars isn't enough of a byte loss to matter, but since I need to map them, it stings a lot more)

```<code>->s{s.map!(&:chars).shift.zip(*s).map &:join}
</code>```

Body:
Ruby, 46 bytes

Probably the first time that "Ruby strings aren't Enumerables" is actually biting me hard since I had to map the strings into arrays before processing. (Normally having to use String#chars isn't enough of a byte loss to matter, but since I need to map them, it stings a lot more)

->s{s.map!(&:chars).shift.zip(*s).map &:join}


答:
Python 3, 10772 bits (1346.5 bytes)

def compress(rows):
    columns = list(zip(*rows))
    size = len(rows)
    symbols = range(size)
    output = size - 1
    weight = 25
    for i in symbols:
        for j in symbols:
            choices = set(rows[i][j:]) & set(columns[j][i:])
            output += weight * sorted(choices).index(rows[i][j])
            weight *= len(choices)
    return bin(output + 1)[3:]

def decompress(bitstring):
    number = int('1' + bitstring, 2) - 1
    number, size = divmod(number, 25)
    size += 1
    symbols = range(size)
    rows = [[None] * size for _ in symbols]
    columns = [list(column) for column in zip(*rows)]
    for i in symbols:
        for j in symbols:
            choices = set(symbols) - set(rows[i]) - set(columns[j])
            number, index = divmod(number, len(choices))
            rows[i][j] = columns[j][i] = sorted(choices)[index]
    return rows
```

Takes 0.1 seconds to compress and decompress the combined test cases.

Verify the score on Ideone.

Title: Latin square compression

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

Body:
Python 3, 10772 bits (1346.5 bytes)

def compress(rows):
    columns = list(zip(*rows))
    size = len(rows)
    symbols = range(size)
    output = size - 1
    weight = 25
    for i in symbols:
        for j in symbols:
            choices = set(rows[i][j:]) & set(columns[j][i:])
            output += weight * sorted(choices).index(rows[i][j])
            weight *= len(choices)
    return bin(output + 1)[3:]

def decompress(bitstring):
    number = int('1' + bitstring, 2) - 1
    number, size = divmod(number, 25)
    size += 1
    symbols = range(size)
    rows = [[None] * size for _ in symbols]
    columns = [list(column) for column in zip(*rows)]
    for i in symbols:
        for j in symbols:
            choices = set(symbols) - set(rows[i]) - set(columns[j])
            number, index = divmod(number, len(choices))
            rows[i][j] = columns[j][i] = sorted(choices)[index]
    return rows

Takes 0.1 seconds to compress and decompress the combined test cases.

Verify the score on Ideone.


答:
J, 2444 bytes

Relies on the builtin A. to convert to and from a permutation of integers [0, n) and a permutation index.

Compress, 36 bytes

```<code>({:a.)joinstring<@(a.{~255&#.inv)@A.
</code>```

The input is a 2d array representing the Latin square. Each row is converted to a permutation index, and that index is converted to a list of base 255 digits and replaced with an ASCII value. Each string is then joined using the ASCII character at 255.

Decompress, 45 bytes

```<code>[:(A.i.@#)[:(_&,(255&#.&x:);._1~1,255&=)u:inv
</code>```

Splits the input string at each ASCII value of 255, and parse each group as base 255 digits. Then using the number of groups, create a list of integers [0, length) and permute it according to each index and return it as a 2d array.

Title: Latin square compression

Body:
J, 2444 bytes

Relies on the builtin A. to convert to and from a permutation of integers [0, n) and a permutation index.

Compress, 36 bytes

({:a.)joinstring<@(a.{~255&#.inv)@A.

The input is a 2d array representing the Latin square. Each row is converted to a permutation index, and that index is converted to a list of base 255 digits and replaced with an ASCII value. Each string is then joined using the ASCII character at 255.

Decompress, 45 bytes

[:(A.i.@#)[:(_&,(255&#.&x:);._1~1,255&=)u:inv

Splits the input string at each ASCII value of 255, and parse each group as base 255 digits. Then using the number of groups, create a list of integers [0, length) and permute it according to each index and return it as a 2d array.