问:
Count from 1 to 100... in Roman Numerals
Write a program that count from 1 to 100 in Roman Numerals and print these numbers by standard output. Each one of the numbers must be separated by spaces.

You cannot use any built in function to transform to roman numerals nor external application or library to do so.

The desired result is

```<code>I II III IV V VI VII VIII IX X XI XII XIII XIV XV XVI XVII XVIII XIX XX XXI XXII XXIII XXIV XXV XXVI XXVII XXVIII XXIX XXX XXXI XXXII XXXIII XXXIV XXXV XXXVI XXXVII XXXVIII XXXIX XL XLI XLII XLIII XLIV XLV XLVI XLVII XLVIII XLIX L LI LII LIII LIV LV LVI LVII LVIII LIX LX LXI LXII LXIII LXIV LXV LXVI LXVII LXVIII LXIX LXX LXXI LXXII LXXIII LXXIV LXXV LXXVI LXXVII LXXVIII LXXIX LXXX LXXXI LXXXII LXXXIII LXXXIV LXXXV LXXXVI LXXXVII LXXXVIII LXXXIX XC XCI XCII XCIII XCIV XCV XCVI XCVII XCVIII XCIX C
</code>```

As it is a code golf challenge, shortest code wins.

答:
Perl 69 bytes

```<code>s;.;y/XVI60-9/CLXVIX/dfor$a[$_].="32e$&"%72726;gefor 1..100;print"@a"
</code>```

Works by way of magic formula. The expression "32e$&"%72726 transforms each digit in the following manner:

0⇒32, 1⇒320, 2⇒3200, 3⇒32000, 4⇒29096, 5⇒56, 6⇒560, 7⇒5600, 8⇒56000, 9⇒50918

After applying the translation y/016/IXV/, we have this instead:

0⇒32, 1⇒32I, 2⇒32II, 3⇒32III, 4⇒29I9V, 5⇒5V, 6⇒5VI, 7⇒5VII, 8⇒5VIII, 9⇒5I9X8

The rest of the digits (2-57-9) are removed. Note that this could be improved by one byte by using a formula which translates 012 instead of 016, simplifying /XVI60-9/ to /XVI0-9/. I wasn't able to find one, but maybe you'll have better luck.

Once one digit has been transformed in this manner, the process repeats for the next digit, appending the result, and translating the previous XVIs to CLX at the same time the translation for the new digit occurs.

Update

Exhaustive search didn't reveal anything shorter. I did, however, find an alternative 69 byte solution:

```<code>s;.;y/XVI0-9/CLXIXV/dfor$a[$_].="57e$&"%474976;gefor 1..100;print"@a"
</code>```

This one uses a 0-2 substitution for IXV, but has a modulo that's one digit longer.

Update: <s>66</s> 65 bytes

This version is notably different, so I should probably say a few words about it. The formula it uses is actually one byte longer!

Unable to shorten the formula any more than it is, I decided to golf down what I had. It wasn't long until I remembered my old friend $\. When a print statment is issued, $\ is automatically appended to the end of the output. I was able to get rid of the awkward $a[$_] construction for a two byte improvement:

```<code>s;.;y/XVI60-9/CLXVIX/dfor$\.="32e$&"%72726;ge,$\=!print$"for 1..100
</code>```

Much better, but that $\=!print$" still looked a bit verbose. I then remembered an alternative, equal length formula I had found which didn't contain the number 3 in any of its digit transforms. So, it should be possible to use $\=2+print instead, and substitute the resulting 3 with a space:

```<code>s;.;y/XVI0-9/CLXIIX V/dfor$\.="8e$&"%61535;ge,$\=2+print for 1..100
</code>```

Also 67 bytes, due to the necessary whitespace between print and for.

Edit: This can be improved by one byte, by moving the print to the front:

```<code>$\=2+print!s;.;y/XVI0-9/CLXIIX V/dfor$\.="8e$&"%61535;gefor 1..100
</code>```

Because the substitution needs to evaluate completely before the print, the assignment to $\ will still occur last. Removing the whitespace between ge and for will issue a deprecation warning, but is otherwise valid.

But, if there were a formula which didn't use a 1 anywhere, $\=2+print becomes $\=print for another two bytes worth of savings. Even if it were one byte longer, it'd still be an improvement.

As it turns out, such a formula does exist, but it is one byte longer than the original, resulting in a final score of 65 bytes:

```<code>$\=print!s;.;y/XVI60-9/CLXXI V/dfor$\.="37e$&"%97366;gefor 1..100
</code>```

Methodology

The question was asked how one might go about finding such a formula. In general, finding a magic formula to generalize any set of data is matter of probability. That is, you want to choose a form which is as likely as possible to produce something similar to the desired result.

Examing the first few roman numerals:

```<code>0:
1: I
2: II
3: III
4: IV
5: V
6: VI
7: VII
8: VIII
9: IX
</code>```

there is some regularity to be seen. Specifically, from 0-3 and then again from 5-8, each successive term increases in length by one numeral. If we wanted to create a mapping from digits to numerals, we would want to have an expression that also increases in length by one digit for each successive term. A logical choice is k • 10d where d is the corresponding digit, and k is any integer constant.

This works for 0-3, but 4 needs to break the pattern. What we can do here is tack on a modulo:

k • 10d % m, where m is somewhere between k • 103 and k • 104. This will leave the range 0-3 untouched, and modify 4 such that it won't contain four Is. If we additionally constrain our search algorithm such that the modular residue of 5, let's call it j, is less than m / 1000, this will ensure that we also have regularity from 5-8 as well. The result is something like this:

```<code>0: k
1: k0
2: k00
3: k000
4: ????
5: j
6: j0
7: j00
8: j000
9: ????
</code>```

As you can see, if we replace 0 with I, 0-3 and 5-8 are all guaranteed to be mapped correctly! The values for 4 and 9 need to be brute forced though. Specifically, 4 needs to contain one 0 and one j (in that order), and 9 needs to contain one 0, followed by one other digit that doesn't appear anywhere else. Certainly, there are a number of other formulae, which by some fluke of a coincidence might produce the desired result. Some of them may even be shorter. But I don't think there are any which are as likely to succeed as this one.

I also experimented with multiple replacements for I and/or V with some success. But alas, nothing shorter than what I already had. Here is a list of the shortest solutions I found (the number of solutions 1-2 bytes heavier are too many to list):

```<code>y/XVI60-9/CLXVIX/dfor$\.="32e$&"%72726
y/XVI0-9/CLXIXV/dfor$\.="57e$&"%474976
y/XVI0-9/CLXIVXI/dfor$\.="49e$&"%87971

y/XVI0-9/CLXIIXIV/dfor$\.="7e$&"%10606  #
y/XVI0-9/CLXIIXIV/dfor$\.="7e$&"%15909  # These are all essentially the same
y/XVI0-9/CLXIIXIV/dfor$\.="7e$&"%31818  #

y/XVI0-9/CLXIIX V/dfor$\.="8e$&"%61535  # Doesn't contain 3 anywhere

y/XVI60-9/CLXXI V/dfor$\.="37e$&"%97366 # Doesn't contain 1 anywhere
</code>```

Body:
Perl 69 bytes

s;.;y/XVI60-9/CLXVIX/dfor$a[$_].="32e$&"%72726;gefor 1..100;print"@a"

Works by way of magic formula. The expression "32e$&"%72726 transforms each digit in the following manner:

0⇒32, 1⇒320, 2⇒3200, 3⇒32000, 4⇒29096, 5⇒56, 6⇒560, 7⇒5600, 8⇒56000, 9⇒50918

After applying the translation y/016/IXV/, we have this instead:

0⇒32, 1⇒32I, 2⇒32II, 3⇒32III, 4⇒29I9V, 5⇒5V, 6⇒5VI, 7⇒5VII, 8⇒5VIII, 9⇒5I9X8

The rest of the digits (2-57-9) are removed. Note that this could be improved by one byte by using a formula which translates 012 instead of 016, simplifying /XVI60-9/ to /XVI0-9/. I wasn't able to find one, but maybe you'll have better luck.

Once one digit has been transformed in this manner, the process repeats for the next digit, appending the result, and translating the previous XVIs to CLX at the same time the translation for the new digit occurs.

Update

Exhaustive search didn't reveal anything shorter. I did, however, find an alternative 69 byte solution:

s;.;y/XVI0-9/CLXIXV/dfor$a[$_].="57e$&"%474976;gefor 1..100;print"@a"

This one uses a 0-2 substitution for IXV, but has a modulo that's one digit longer.

Update: <s>66</s> 65 bytes

This version is notably different, so I should probably say a few words about it. The formula it uses is actually one byte longer!

Unable to shorten the formula any more than it is, I decided to golf down what I had. It wasn't long until I remembered my old friend $\. When a print statment is issued, $\ is automatically appended to the end of the output. I was able to get rid of the awkward $a[$_] construction for a two byte improvement:

s;.;y/XVI60-9/CLXVIX/dfor$\.="32e$&"%72726;ge,$\=!print$"for 1..100

Much better, but that $\=!print$" still looked a bit verbose. I then remembered an alternative, equal length formula I had found which didn't contain the number 3 in any of its digit transforms. So, it should be possible to use $\=2+print instead, and substitute the resulting 3 with a space:

s;.;y/XVI0-9/CLXIIX V/dfor$\.="8e$&"%61535;ge,$\=2+print for 1..100

Also 67 bytes, due to the necessary whitespace between print and for.

Edit: This can be improved by one byte, by moving the print to the front:

$\=2+print!s;.;y/XVI0-9/CLXIIX V/dfor$\.="8e$&"%61535;gefor 1..100

Because the substitution needs to evaluate completely before the print, the assignment to $\ will still occur last. Removing the whitespace between ge and for will issue a deprecation warning, but is otherwise valid.

But, if there were a formula which didn't use a 1 anywhere, $\=2+print becomes $\=print for another two bytes worth of savings. Even if it were one byte longer, it'd still be an improvement.

As it turns out, such a formula does exist, but it is one byte longer than the original, resulting in a final score of 65 bytes:

$\=print!s;.;y/XVI60-9/CLXXI V/dfor$\.="37e$&"%97366;gefor 1..100

Methodology

The question was asked how one might go about finding such a formula. In general, finding a magic formula to generalize any set of data is matter of probability. That is, you want to choose a form which is as likely as possible to produce something similar to the desired result.

Examing the first few roman numerals:

0:
1: I
2: II
3: III
4: IV
5: V
6: VI
7: VII
8: VIII
9: IX

there is some regularity to be seen. Specifically, from 0-3 and then again from 5-8, each successive term increases in length by one numeral. If we wanted to create a mapping from digits to numerals, we would want to have an expression that also increases in length by one digit for each successive term. A logical choice is k • 10d where d is the corresponding digit, and k is any integer constant.

This works for 0-3, but 4 needs to break the pattern. What we can do here is tack on a modulo:

k • 10d % m, where m is somewhere between k • 103 and k • 104. This will leave the range 0-3 untouched, and modify 4 such that it won't contain four Is. If we additionally constrain our search algorithm such that the modular residue of 5, let's call it j, is less than m / 1000, this will ensure that we also have regularity from 5-8 as well. The result is something like this:

0: k
1: k0
2: k00
3: k000
4: ????
5: j
6: j0
7: j00
8: j000
9: ????

As you can see, if we replace 0 with I, 0-3 and 5-8 are all guaranteed to be mapped correctly! The values for 4 and 9 need to be brute forced though. Specifically, 4 needs to contain one 0 and one j (in that order), and 9 needs to contain one 0, followed by one other digit that doesn't appear anywhere else. Certainly, there are a number of other formulae, which by some fluke of a coincidence might produce the desired result. Some of them may even be shorter. But I don't think there are any which are as likely to succeed as this one.

I also experimented with multiple replacements for I and/or V with some success. But alas, nothing shorter than what I already had. Here is a list of the shortest solutions I found (the number of solutions 1-2 bytes heavier are too many to list):

y/XVI60-9/CLXVIX/dfor$\.="32e$&"%72726
y/XVI0-9/CLXIXV/dfor$\.="57e$&"%474976
y/XVI0-9/CLXIVXI/dfor$\.="49e$&"%87971

y/XVI0-9/CLXIIXIV/dfor$\.="7e$&"%10606  #
y/XVI0-9/CLXIIXIV/dfor$\.="7e$&"%15909  # These are all essentially the same
y/XVI0-9/CLXIIXIV/dfor$\.="7e$&"%31818  #

y/XVI0-9/CLXIIX V/dfor$\.="8e$&"%61535  # Doesn't contain 3 anywhere

y/XVI60-9/CLXXI V/dfor$\.="37e$&"%97366 # Doesn't contain 1 anywhere


问:
Help: Aliens Programmers only speak ASCII

Setting the Scene:

It is an average afternoon, as you unwind after a long day by engaging in your favorite pastime: answering the plethora of captivating questions on PPCG. It hasn't been a good day for you; those damned Pyth programmers keep getting best answer and it's killing your vibe. Suddenly, you notice a new question has been posted! You make up your mind; not this time CJammers. Furiously, you begin to type, birthing a stream of characters; a fetus of the glorious BrainFuck loop that your end product will be. You type and type. Faster! Faster still! You're so focused you don't even notice the lights on your screen start to flicker on and off. Suddenly, the monitor glows green, an alien like symbol branded upon the desktop. Using your impeccable skills you cat ~/Desktop/aliensymbol and get presented with a bunch of numbers, a message! Being the shrewd PPCG programmer that you are, you notice that it looks like ASCII. No matter for you, you print(chr(i) for i in file) and decipher the message. Your first thought: "I need to share this with the community!".

...

Who would've thought it? That the first people to make contact with aliens would be the humble programmers of PPCG. Why us? Maybe it is because we are the epitome of human intelligence. Or maybe because BrainFuck is about as close as we have to an alien language. Nevertheless, the aliens - being the ultra-intelligent life forms that they are - want to test whether they should classify the human race as  intelligent or not. As a test of our mental prowess, the aliens have asked us to send them a few computer programs to demonstrate that we are technologically cultured. The issue is, the only human language they understand is numerical ASCII!

Help humankind show those creatures who the real intellectual alpha is. We need to send them a script that will convert our text based source codes into their numerical ASCII versions. Unfortunately, due to our underdeveloped technology (thanks Obama), we must send as small a translating program as possible. Good thing they chose to contact PPCG!

The Challenge:

The premise of this challenge is simple: you are to write a program that will take any program's source code (or any general text file for that matter), and output a space separated version of it with an ASCII translation below each line. That is, given an input of a text file, you need to output each line of that file followed by a line containing the ASCII representation of each character in the line above it (with each number lining up with the character it represents).

An example will greatly clarify this. Taking the source code of the infamous hello world as the input:

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

int main() {
    printf("hello, world\n");
    return 0;
}
</code>```

your program should output:

```<code>#   i   n   c   l   u   d   e       <   s   t   d   i   o   .   h   >
35  105 110 99  108 117 100 101 32  60  115 116 100 105 111 46  104 62  10

10
i   n   t       m   a   i   n   (   )       {
105 110 116 32  109 97  105 110 40  41  32  123 10
                p   r   i   n   t   f   (   "   h   e   l   l   o   ,       w   o   r   l   d   \   n   "   )   ;
32  32  32  32  112 114 105 110 116 102 40  34  104 101 108 108 111 44  32  119 111 114 108 100 92  110 34  41  59  10
                r   e   t   u   r   n       0   ;
32  32  32  32  114 101 116 117 114 110 32  48  59  10
}
125 10
</code>```

Implementation Details:

You may choose to take the input in whatever form you wish (opening file, command line pipe, function parameter etc.) and you should output to stdout or return the output from a function.

Things to note

Each character in the output is separated by a '\t' to allow for the space of 3 digits in the line below to line up (we are going to assume your tab is set to 4 spaces or more).

The newlines are displayed on the line that the return key was pressed (notice the 10's in the example)

The '\t' and '\n' printing requirements are lax. Your output must, in the general sense, look pleasing to the eye (need to show those aliens we have aesthetic sense as well), and if you can bend the previous two points while maintaining visual integrity, you will be forgiven.

You can choose to assume whether or not there is a newline at the end of the last line.

Scoring

This is code-golf so shortest program wins. Note, even if your program isn't the shortest, but uses really neat tricks relative to the language you are using, many +1's to you!

Good luck. The intergalactic intelligence ranking of humanity rests on your shoulders.

Note: Please forgive the plot holes. I'm not a writer :D

答:
C, <s>136</s> <s>117</s> 114 Bytes

```<code>#define p(s)while(l[i])printf(s,l[i++]);i=0;puts("")
char l[99];i;f(f){while(fgets(l,99,f)){p("%c\t");p("%d\t");}}
</code>```

<s>char l[99];i;f(f){while(fgets(l,256,f)){i=0;while(l[i])printf("%c\t",l[i++]);i=0;puts("");while(l[i])printf("%d\t",l[i++]);puts("");}}
</s>

Can be tested like this

```<code>infile;
main(c,v)char**v;
{
    infile=fopen(v[1],"r");
    f(infile);
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
C, <s>136</s> <s>117</s> 114 Bytes

#define p(s)while(l[i])printf(s,l[i++]);i=0;puts("")
char l[99];i;f(f){while(fgets(l,99,f)){p("%c\t");p("%d\t");}}

<s>char l[99];i;f(f){while(fgets(l,256,f)){i=0;while(l[i])printf("%c\t",l[i++]);i=0;puts("");while(l[i])printf("%d\t",l[i++]);puts("");}}
</s>

Can be tested like this

infile;
main(c,v)char**v;
{
    infile=fopen(v[1],"r");
    f(infile);
}


答:
Perl, <s>>33</s> 31 bytes

Includes +3 for -F (cannot be combined with -e and the code has ' too, so space and - are counted too).

Run with the input on STDIN or give one or more filenames as argument

```<code>perl -M5.010 asciidump.pl <<< "Hoi"
</code>```

asciidump.pl

```<code>#!/usr/bin/perl -F
$"=v9;say"@F@{[unpack'W*']}"
</code>```

Output is not aesthetic if the text contains a tab or there is no final newline

Title: Help: Aliens Programmers only speak ASCII

Body:
Setting the Scene:

It is an average afternoon, as you unwind after a long day by engaging in your favorite pastime: answering the plethora of captivating questions on PPCG. It hasn't been a good day for you; those damned Pyth programmers keep getting best answer and it's killing your vibe. Suddenly, you notice a new question has been posted! You make up your mind; not this time CJammers. Furiously, you begin to type, birthing a stream of characters; a fetus of the glorious BrainFuck loop that your end product will be. You type and type. Faster! Faster still! You're so focused you don't even notice the lights on your screen start to flicker on and off. Suddenly, the monitor glows green, an alien like symbol branded upon the desktop. Using your impeccable skills you cat ~/Desktop/aliensymbol and get presented with a bunch of numbers, a message! Being the shrewd PPCG programmer that you are, you notice that it looks like ASCII. No matter for you, you print(chr(i) for i in file) and decipher the message. Your first thought: "I need to share this with the community!".

...

Who would've thought it? That the first people to make contact with aliens would be the humble programmers of PPCG. Why us? Maybe it is because we are the epitome of human intelligence. Or maybe because BrainFuck is about as close as we have to an alien language. Nevertheless, the aliens - being the ultra-intelligent life forms that they are - want to test whether they should classify the human race as  intelligent or not. As a test of our mental prowess, the aliens have asked us to send them a few computer programs to demonstrate that we are technologically cultured. The issue is, the only human language they understand is numerical ASCII!

Help humankind show those creatures who the real intellectual alpha is. We need to send them a script that will convert our text based source codes into their numerical ASCII versions. Unfortunately, due to our underdeveloped technology (thanks Obama), we must send as small a translating program as possible. Good thing they chose to contact PPCG!

The Challenge:

The premise of this challenge is simple: you are to write a program that will take any program's source code (or any general text file for that matter), and output a space separated version of it with an ASCII translation below each line. That is, given an input of a text file, you need to output each line of that file followed by a line containing the ASCII representation of each character in the line above it (with each number lining up with the character it represents).

An example will greatly clarify this. Taking the source code of the infamous hello world as the input:

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

int main() {
    printf("hello, world\n");
    return 0;
}
</code>```

your program should output:

```<code>#   i   n   c   l   u   d   e       <   s   t   d   i   o   .   h   >
35  105 110 99  108 117 100 101 32  60  115 116 100 105 111 46  104 62  10

10
i   n   t       m   a   i   n   (   )       {
105 110 116 32  109 97  105 110 40  41  32  123 10
                p   r   i   n   t   f   (   "   h   e   l   l   o   ,       w   o   r   l   d   \   n   "   )   ;
32  32  32  32  112 114 105 110 116 102 40  34  104 101 108 108 111 44  32  119 111 114 108 100 92  110 34  41  59  10
                r   e   t   u   r   n       0   ;
32  32  32  32  114 101 116 117 114 110 32  48  59  10
}
125 10
</code>```

Implementation Details:

You may choose to take the input in whatever form you wish (opening file, command line pipe, function parameter etc.) and you should output to stdout or return the output from a function.

Things to note

Each character in the output is separated by a '\t' to allow for the space of 3 digits in the line below to line up (we are going to assume your tab is set to 4 spaces or more).

The newlines are displayed on the line that the return key was pressed (notice the 10's in the example)

The '\t' and '\n' printing requirements are lax. Your output must, in the general sense, look pleasing to the eye (need to show those aliens we have aesthetic sense as well), and if you can bend the previous two points while maintaining visual integrity, you will be forgiven.

You can choose to assume whether or not there is a newline at the end of the last line.

Scoring

This is code-golf so shortest program wins. Note, even if your program isn't the shortest, but uses really neat tricks relative to the language you are using, many +1's to you!

Good luck. The intergalactic intelligence ranking of humanity rests on your shoulders.

Note: Please forgive the plot holes. I'm not a writer :D

Body:
Perl, <s>>33</s> 31 bytes

Includes +3 for -F (cannot be combined with -e and the code has ' too, so space and - are counted too).

Run with the input on STDIN or give one or more filenames as argument

perl -M5.010 asciidump.pl <<< "Hoi"

asciidump.pl

#!/usr/bin/perl -F
$"=v9;say"@F@{[unpack'W*']}"

Output is not aesthetic if the text contains a tab or there is no final newline


问:
Minesweeper At Work
Everyone knows the old minesweeper game that shipped with Windows XP. It's a simple grid with a 9x9 matrix of cells containing either a number (indicating how many mines are adjacent to it) or a mine.

The challenge is to generate a random 9x9 grid with 10 bombs given any integer seed (up to whatever your machine/language's largest int is) with brownie points if you implement the PRNG yourself

example output: cells contain either numerals 0-8 or * for mines

```<code>*101*1000
110111000
123210000
1***10000
123210011
00000002*
00000114*
000112*3*
0001*2121
</code>```

Shortest code in bytes wins.. standard rules etc, etc..

答:
MATLAB, <s>94</s> 93 bytes

```<code>rng(input(''));x(9,9)=~1;x(randperm(81,10))=1;y=[conv2(+x,ones(3),'s')+48 ''];y(x)=42;disp(y)
</code>```

Example run (the first line after the code is the input typed by the user):

```<code>>> rng(input(''));x(9,9)=~1;x(randperm(81,10))=1;y=[conv2(+x,ones(3),'s')+48 ''];y(x)=42;disp(y)
99
*10001*2*
220001232
*201111*1
*312*1111
12*211000
011211000
0001*1000
000112110
000001*10
</code>```

Explanation

```<code>rng(input(''));
</code>```

takes an integer and uses it as seed. (This works in modern MATLAB versions. Old versions may need a different syntax.)

```<code>x(9,9)=~1;
</code>```

assigns logical 0, or false (obtained by logically negating 1) to the entry (9,9) of a matrix x. The rest of the entries are automatically initiallized to logical 0 too.

```<code>x(randperm(81,10))=1;
</code>```

assigns 1 (autoomatically cast to logical 1, or true) to 10 of the
81 entries of x, chosen randomly without replacement. These entries are the ones that contain bombs.

```<code>conv2(+x,ones(3),'s')
</code>```

is an abbreviation of conv2(+x,ones(3),'same'). It convolves the matrix x (which needs to be cast to double, using +) with a 3×3 neighbourhood containing 1. This counts how many bombs are adjacent to each entry. For entries that contain a bomb it includes that bomb, but the value there will be overwritten later.

```<code>y=[...+48 ''];
</code>```

adds 48 to the value, to convert from number to ASCII code. Concatenating with the empty matrix casts these ASCII codes to chars.

```<code>y(x)=42;
</code>```

assigns 42 (ASCII code for '*') to the positions of the bombs. These positions are given by x, which is here used as a logical index.

```<code>disp(y)
</code>```

displays the result.

Title: Minesweeper At Work

Body:
MATLAB, <s>94</s> 93 bytes

rng(input(''));x(9,9)=~1;x(randperm(81,10))=1;y=[conv2(+x,ones(3),'s')+48 ''];y(x)=42;disp(y)

Example run (the first line after the code is the input typed by the user):

>> rng(input(''));x(9,9)=~1;x(randperm(81,10))=1;y=[conv2(+x,ones(3),'s')+48 ''];y(x)=42;disp(y)
99
*10001*2*
220001232
*201111*1
*312*1111
12*211000
011211000
0001*1000
000112110
000001*10

Explanation

rng(input(''));

takes an integer and uses it as seed. (This works in modern MATLAB versions. Old versions may need a different syntax.)

x(9,9)=~1;

assigns logical 0, or false (obtained by logically negating 1) to the entry (9,9) of a matrix x. The rest of the entries are automatically initiallized to logical 0 too.

x(randperm(81,10))=1;

assigns 1 (autoomatically cast to logical 1, or true) to 10 of the
81 entries of x, chosen randomly without replacement. These entries are the ones that contain bombs.

conv2(+x,ones(3),'s')

is an abbreviation of conv2(+x,ones(3),'same'). It convolves the matrix x (which needs to be cast to double, using +) with a 3×3 neighbourhood containing 1. This counts how many bombs are adjacent to each entry. For entries that contain a bomb it includes that bomb, but the value there will be overwritten later.

y=[...+48 ''];

adds 48 to the value, to convert from number to ASCII code. Concatenating with the empty matrix casts these ASCII codes to chars.

y(x)=42;

assigns 42 (ASCII code for '*') to the positions of the bombs. These positions are given by x, which is here used as a logical index.

disp(y)

displays the result.


问:
The Squiggly Sequence

All credits to Adnan for coming up with this challenge.

My last challenge, before I go on break.

Task

Given positive integer n, if n is odd, repeat / that many times; if n is even, repeat \ that many times.

(Seriously, the testcases would be much clearer than this description, so just look at the testcases.)

Specs

Any reasonable input/output format.

Standard loopholes apply.

Testcases

```<code>n output
1 /
2 \\
3 ///
4 \\\\
5 /////
6 \\\\\\
</code>```

答:
PL-SQL (Oracle), 530 characters

DECLARE
-- Enter your input here, here example is taken as 3 ---
  n number := 3 ;
  k varchar2(20);
BEGIN
     -- Checking the input number for odd --
     if mod(n,2)=1 then
     for j in 1..n loop
      k := k||'/';
      end loop;
      DBMS_OUTPUT.PUT_line (n||' '||k);
     end if;

     -- Checking the input number for even --
         if mod(n,2)=0 then
         for j in 1..n loop
         k := k||'\';
          end loop;
          DBMS_OUTPUT.PUT_line (n||' '||k);
         end if;
END;
```

Title: The Squiggly Sequence


问:
ETAOIN SHRDLU golf
Short and sweet description of the challenge:

Based off ETAOIN SHRDLU, your challenge is to write the shortest program or function in any language that outputs the 26 letters of the English alphabet based on their frequency in the input.

Really long, dry and thorough specification:

Your program/function will receive as input a string of text, which will contain one or more uppercase and/or lowercase letters and may also contain punctuation, numerals, symbols, and other non-alphabetic characters.

The program/function must output only the 26 UPPERCASE letters of the English alphabet, including those that do not appear in the input, ordered from most to least frequent based on how many times they appear in the input.

The frequency is calculated case-insensitively, but the output must be in uppercase.

If two or more letters have the same frequency, they may be in any order.

The only other output that is allowed is optional leading or trailing whitespace, such as a trailing newline. No other output inclusing whitespace is allowed.

Undefined behavior is allowed for input that does not contain any letters.

Example input:

```<code>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae erat velit. Mauris gravida euismod libero ut tincidunt. Phasellus elit dui, consectetur et egestas in, aliquam vitae diam. Donec eget varius ante. Vestibulum cursus diam aliquet, egestas orci quis, placerat dolor. Proin vel nisi lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam erat volutpat. Etiam libero tortor, ornare id dui eget, posuere dignissim libero. Pellentesque commodo consequat volutpat. Integer hendrerit sapien libero, vel viverra augue facilisis sit amet. Quisque consectetur eget nisl quis dignissim. Ut lacinia pretium quam a placerat.
Morbi sed interdum risus, nec pretium lectus. Morbi imperdiet est id accumsan molestie. Duis sed fermentum nisl. Nunc vitae augue mattis, dictum lectus vel, accumsan nisl. Sed ultricies adipiscing rhoncus. Vivamus eu lacus a enim venenatis eleifend. Praesent consectetur tortor non eleifend ultricies. Mauris et odio posuere, auctor erat at, fringilla est. Proin in vestibulum erat. Maecenas congue commodo ante vel varius. Sed tempus mi ut metus gravida, nec dictum libero dapibus. Morbi quis viverra elit. Ut pharetra neque eget lacus tincidunt dictum. Fusce scelerisque viverra tellus et pretium.
Fusce varius adipiscing odio. Nulla imperdiet faucibus sem, at rhoncus ipsum adipiscing vitae. Phasellus imperdiet congue lacus et mollis. Nullam egestas mauris magna, et mollis lectus varius ut. Sed sollicitudin adipiscing dolor, vel elementum elit laoreet molestie. Aliquam nec nulla vel sem ultrices ullamcorper. Nullam nec felis magna. Duis sodales orci non justo aliquam tempus. Integer mi diam, tempor sed vulputate et, varius et nunc. Vestibulum sodales ipsum id mi pharetra, ut convallis mi accumsan. Sed dictum volutpat vestibulum.
Quisque ac dolor sagittis, aliquam libero at, euismod enim. Nulla ullamcorper posuere nulla vitae varius. Nam at dolor non libero elementum pellentesque in in lorem. Fusce porttitor turpis in quam placerat varius. Donec lorem orci, condimentum eu sapien sit amet, aliquet commodo magna. Quisque sed lectus sit amet arcu euismod accumsan et non nunc. Phasellus placerat congue metus, feugiat posuere leo dictum quis. Sed ultricies feugiat eros dignissim bibendum.
Mauris scelerisque consectetur libero eget varius. Aenean neque nunc, ullamcorper vitae orci in, auctor ornare sapien. Nam lacinia molestie imperdiet. Nam vitae mattis nibh. Vestibulum consequat tellus ac nisi sagittis pulvinar. Nullam mollis ornare quam, et venenatis leo porttitor sit amet. Nulla urna neque, dignissim non orci ut, volutpat ultrices erat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque vestibulum tellus nec eros faucibus porta.
</code>```

Example output:

```<code>EITUSALNROMCDPVGQBFHJKWXYZ
</code>```

Note: there is a 5 way tie between KWXYZ for that input.

Edit:

The competition is over! Thanks to everyone who participated. And now for the winner(s!): Both Dennis' CJam and isaacg's Pyth answers came in at a whopping 19 characters. Taking Dennis' advice, I'm going to mark his answer as accepted because his was the first to reach 19 characters. Honorable mentions go to Ilmari Karonen's third-place Golfscript answer at 22 chars as well as undergroundmonorail's 75-char Python answer that got the most upvotes. Once again, thanks to everyone who participated!

答:
Floroid - 37 bytes

```<code>Ba:''.y(t(R(P,w(65,91)),fi=a.fk.fm))D
</code>```

A little late to the party, but here it is. An Floroid port of @undergroundmonorails answer.

This language was made some time after this challenge, therefore this isn't competing.

ContentLicense: CC BY-SA 4.0

Title: ETAOIN SHRDLU golf

Body:
Floroid - 37 bytes

Ba:''.y(t(R(P,w(65,91)),fi=a.fk.fm))D

A little late to the party, but here it is. An Floroid port of @undergroundmonorails answer.

This language was made some time after this challenge, therefore this isn't competing.


问:
Draw an Empty Scrabble Board
A standard Scrabble board is a 15×15 grid of spaces to place letter tiles. Most of the spaces are blank but some are double word scores (pink), triple word scores (red), double letter scores (light blue), and triple letter scores (blue). There is usually a star in the very center (which counts as a double word score).

Write a program or function that outputs a standard, empty Scrabble board in ASCII form where:

. represents an empty space

D represents a double word score

T represents a triple word score

d represents a double letter score

t represents a triple letter score

X represents the center star

That is, your exact output must be

```<code>T..d...T...d..T
.D...t...t...D.
..D...d.d...D..
d..D...d...D..d
....D.....D....
.t...t...t...t.
..d...d.d...d..
T..d...X...d..T
..d...d.d...d..
.t...t...t...t.
....D.....D....
d..D...d...D..d
..D...d.d...D..
.D...t...t...D.
T..d...T...d..T
</code>```

optionally followed by a trailing newline.

The shortest code in bytes wins.

答:
Ruby, <s>103</s> 97 bytes

Thanks to Mitch Schwartz for a 6 byte improvement on the iterations.

```<code>a=(-7..7).map &:abs
a.map{|i|puts a.map{|j|(d=i%7-j%7)%4<1?'X d t DTDdDdDtT d'[i+j+d*d/3]:?.}*''}
</code>```

A similar but significantly different approach to my original answer below. As before, we use the fact that a letter must be printed if i%7-j%7 is equal to 0 or 4. But here we store that difference in d and use the formula i+j+d*d/3 to give an integer which is unique (up to symmetry) to that particular coloured square. Then we just look it up in the magic string.

Just for fun: C version of this approach, 120 bytes

```<code>z,i,j,d;f(){for(z=240;z--;)i=abs(z%16-8),j=abs(z/16-7),putchar(i-8?(d=i%7-j%7)%4?46:"X d t DTDdDdDtT d"[i+j+d*d/3]:10);}
</code>```

Ruby, <s>115</s> 113  bytes

2 bytes saved thanks to Value Ink.

```<code>(k=-7..7).map{|y|k.map{|x|i=x.abs;j=y.abs
$><<=(i%7-j%7)%4<1?"#{'XdTdT'[(i+j)/3]}dtDDDD"[[i%7,j%7].min]:?.}
puts}
</code>```

Explanation

The origin is considered to be the centre of the board.

A letter must be printed if the x and y coordinates of the square have magnitudes that are identical or differ by 4. The only exceptions are on the outer edge of the board, but these follow the same pattern as the central row/column of the board, so we can use the same condition if we take the x and y coordinates modulo 7.

The choice of letter displayed is based on the coordinate of minimum magnitude. In this way the doubles and triples at (1,5) and (2,6) follow the same rule as at (1,1) and (2,2) and are obtained from the 7 character string "#{formula}dtDDDD" This does not cover all variations for the edge and centreline squares, so the first character of the string is calculated from the formula 'XdTdT'[(i+j)/3].

```<code>(k=-7..7).map{|y|
  k.map{|x|
    i=x.abs;j=y.abs
    print (i%7-j%7)%4<1?      #IF this expression is true print a letter
    "#{'XdTdT'[(i+j)/3]       #select 1st character of magic string where [i%7,j%7].min==0
     }dtDDDD"[[i%7,j%7].min]: #remaining 6 characters of magic string for diagonal
    ?.                        #ELSE print .
  }
  puts                        #at the end of the row print a newline
}
</code>```

Title: Draw an Empty Scrabble Board

Body:
Ruby, <s>103</s> 97 bytes

Thanks to Mitch Schwartz for a 6 byte improvement on the iterations.

a=(-7..7).map &:abs
a.map{|i|puts a.map{|j|(d=i%7-j%7)%4<1?'X d t DTDdDdDtT d'[i+j+d*d/3]:?.}*''}

A similar but significantly different approach to my original answer below. As before, we use the fact that a letter must be printed if i%7-j%7 is equal to 0 or 4. But here we store that difference in d and use the formula i+j+d*d/3 to give an integer which is unique (up to symmetry) to that particular coloured square. Then we just look it up in the magic string.

Just for fun: C version of this approach, 120 bytes

z,i,j,d;f(){for(z=240;z--;)i=abs(z%16-8),j=abs(z/16-7),putchar(i-8?(d=i%7-j%7)%4?46:"X d t DTDdDdDtT d"[i+j+d*d/3]:10);}

Ruby, <s>115</s> 113  bytes

2 bytes saved thanks to Value Ink.

(k=-7..7).map{|y|k.map{|x|i=x.abs;j=y.abs
$><<=(i%7-j%7)%4<1?"#{'XdTdT'[(i+j)/3]}dtDDDD"[[i%7,j%7].min]:?.}
puts}

Explanation

The origin is considered to be the centre of the board.

A letter must be printed if the x and y coordinates of the square have magnitudes that are identical or differ by 4. The only exceptions are on the outer edge of the board, but these follow the same pattern as the central row/column of the board, so we can use the same condition if we take the x and y coordinates modulo 7.

The choice of letter displayed is based on the coordinate of minimum magnitude. In this way the doubles and triples at (1,5) and (2,6) follow the same rule as at (1,1) and (2,2) and are obtained from the 7 character string "#{formula}dtDDDD" This does not cover all variations for the edge and centreline squares, so the first character of the string is calculated from the formula 'XdTdT'[(i+j)/3].

(k=-7..7).map{|y|
  k.map{|x|
    i=x.abs;j=y.abs
    print (i%7-j%7)%4<1?      #IF this expression is true print a letter
    "#{'XdTdT'[(i+j)/3]       #select 1st character of magic string where [i%7,j%7].min==0
     }dtDDDD"[[i%7,j%7].min]: #remaining 6 characters of magic string for diagonal
    ?.                        #ELSE print .
  }
  puts                        #at the end of the row print a newline
}


答:
Pyth, 21 bytes

```<code>j.imjC9d.zmjC9+CMdT.z
</code>```

Here's an entry from one of "those damned Pyth programmers" ;)

A program that takes input of an unquoted multiline string on STDIN and prints the result. This assumes that all input has a trailing newline. If you want it to deal with no trailing newline, add < at the beginning of the program and )_3 at the end.

Try it online

The output for the test case is difficult to see in the online interpreter, so I've included it here:

```<code>#   i   n   c   l   u   d   e       <   s   t   d   i   o   .   h   >
35  105 110 99  108 117 100 101 32  60  115 116 100 105 111 46  104 62  10

10
i   n   t       m   a   i   n   t   (   )       {
105 110 116 32  109 97  105 110 116 40  41  32  123 10
                p   r   i   n   t   f   (   "   h   e   l   l   o   ,       w   o   r   l   d   \   n   "   )   ;
32  32  32  32  112 114 105 110 116 102 40  34  104 101 108 108 111 44  32  119 111 114 108 100 92  110 34  41  59  10
                r   e   t   u   r   n       0   ;
32  32  32  32  114 101 116 117 114 110 32  48  59  10
}
125 10
</code>```

How it works

```<code>j.imjC9d.zmjC9+CMdT.z  Program. Input: .z (All of STDIN split on newlines)
     C9                 Yield tab character by taking chr(9)
    j                   Join on tab
   m   d.z             Map that over .z
               CM       Map ord()
              +   T     Append 10
           jC9          Join on tab
          m      d .z  Map that over .z
 .i                    Interleave the results of the two mappings
j                      Join on newlines
                       Implicitly print
</code>```

Body:
Pyth, 21 bytes

j.imjC9d.zmjC9+CMdT.z

Here's an entry from one of "those damned Pyth programmers" ;)

A program that takes input of an unquoted multiline string on STDIN and prints the result. This assumes that all input has a trailing newline. If you want it to deal with no trailing newline, add < at the beginning of the program and )_3 at the end.

Try it online

The output for the test case is difficult to see in the online interpreter, so I've included it here:

#   i   n   c   l   u   d   e       <   s   t   d   i   o   .   h   >
35  105 110 99  108 117 100 101 32  60  115 116 100 105 111 46  104 62  10

10
i   n   t       m   a   i   n   t   (   )       {
105 110 116 32  109 97  105 110 116 40  41  32  123 10
                p   r   i   n   t   f   (   "   h   e   l   l   o   ,       w   o   r   l   d   \   n   "   )   ;
32  32  32  32  112 114 105 110 116 102 40  34  104 101 108 108 111 44  32  119 111 114 108 100 92  110 34  41  59  10
                r   e   t   u   r   n       0   ;
32  32  32  32  114 101 116 117 114 110 32  48  59  10
}
125 10

How it works

j.imjC9d.zmjC9+CMdT.z  Program. Input: .z (All of STDIN split on newlines)
     C9                 Yield tab character by taking chr(9)
    j                   Join on tab
   m   d.z             Map that over .z
               CM       Map ord()
              +   T     Append 10
           jC9          Join on tab
          m      d .z  Map that over .z
 .i                    Interleave the results of the two mappings
j                      Join on newlines
                       Implicitly print


答:
JavaScript (ES6), 94 bytes

```<code>s=>s.replace(/(.*)\n?/g,(s,n)=>n&&[...s].join`␉`+`
${[...n].map(c=>c.charCodeAt()).join`␉`}
`)
</code>```

Where ␉ represents the literal tab character. Works as long as the input doesn't contain tab characters. 81-byte version that also requires the input to have a trailing newline:

```<code>s=>s.replace(/.*\n/g,s=>[...s].join`␉`+[...s].map(c=>c.charCodeAt()).join`␉`+`
`)
</code>```

Body:
JavaScript (ES6), 94 bytes

s=>s.replace(/(.*)\n?/g,(s,n)=>n&&[...s].join`␉`+`
${[...n].map(c=>c.charCodeAt()).join`␉`}
`)

Where ␉ represents the literal tab character. Works as long as the input doesn't contain tab characters. 81-byte version that also requires the input to have a trailing newline:

s=>s.replace(/.*\n/g,s=>[...s].join`␉`+[...s].map(c=>c.charCodeAt()).join`␉`+`
`)


答:
Mathematica 159 150 142

```<code>c = {100, 90, 50, 40, 10, 9, 5, 4, 1};
Table["" <> Flatten[ConstantArray @@@ Thread@{StringSplit@"C XC L XL X IX V IV I",
  FoldList[Mod, k, Most@c]~Quotient~c}], {k, 100}]
</code>```

Built-in solution: IntegerString, 38 chars

```<code>IntegerString[k, "Roman"]~Table~{k, 100}
</code>```

Title: Count from 1 to 100... in Roman Numerals

Body:
Write a program that count from 1 to 100 in Roman Numerals and print these numbers by standard output. Each one of the numbers must be separated by spaces.

You cannot use any built in function to transform to roman numerals nor external application or library to do so.

The desired result is

```<code>I II III IV V VI VII VIII IX X XI XII XIII XIV XV XVI XVII XVIII XIX XX XXI XXII XXIII XXIV XXV XXVI XXVII XXVIII XXIX XXX XXXI XXXII XXXIII XXXIV XXXV XXXVI XXXVII XXXVIII XXXIX XL XLI XLII XLIII XLIV XLV XLVI XLVII XLVIII XLIX L LI LII LIII LIV LV LVI LVII LVIII LIX LX LXI LXII LXIII LXIV LXV LXVI LXVII LXVIII LXIX LXX LXXI LXXII LXXIII LXXIV LXXV LXXVI LXXVII LXXVIII LXXIX LXXX LXXXI LXXXII LXXXIII LXXXIV LXXXV LXXXVI LXXXVII LXXXVIII LXXXIX XC XCI XCII XCIII XCIV XCV XCVI XCVII XCVIII XCIX C
</code>```

As it is a code golf challenge, shortest code wins.

Body:
Mathematica 159 150 142

c = {100, 90, 50, 40, 10, 9, 5, 4, 1};
Table["" <> Flatten[ConstantArray @@@ Thread@{StringSplit@"C XC L XL X IX V IV I",
  FoldList[Mod, k, Most@c]~Quotient~c}], {k, 100}]

Built-in solution: IntegerString, 38 chars

IntegerString[k, "Roman"]~Table~{k, 100}


答:
Haskell, 114 bytes

```<code>g=(++)<*>reverse.init
unlines$g$g<$>words"T..d...T .D...t.. ..D...d. d..D...d ....D... .t...t.. ..d...d. T..d...X"
</code>```

g in a non-pointfree version is g x = x ++ (reverse (init x)). It is applied once per (half-)line and again on the result.

Title: Draw an Empty Scrabble Board

Body:
A standard Scrabble board is a 15×15 grid of spaces to place letter tiles. Most of the spaces are blank but some are double word scores (pink), triple word scores (red), double letter scores (light blue), and triple letter scores (blue). There is usually a star in the very center (which counts as a double word score).

Write a program or function that outputs a standard, empty Scrabble board in ASCII form where:

. represents an empty space

D represents a double word score

T represents a triple word score

d represents a double letter score

t represents a triple letter score

X represents the center star

That is, your exact output must be

```<code>T..d...T...d..T
.D...t...t...D.
..D...d.d...D..
d..D...d...D..d
....D.....D....
.t...t...t...t.
..d...d.d...d..
T..d...X...d..T
..d...d.d...d..
.t...t...t...t.
....D.....D....
d..D...d...D..d
..D...d.d...D..
.D...t...t...D.
T..d...T...d..T
</code>```

optionally followed by a trailing newline.

The shortest code in bytes wins.

Body:
Haskell, 114 bytes

g=(++)<*>reverse.init
unlines$g$g<$>words"T..d...T .D...t.. ..D...d. d..D...d ....D... .t...t.. ..d...d. T..d...X"

g in a non-pointfree version is g x = x ++ (reverse (init x)). It is applied once per (half-)line and again on the result.


Title: Minesweeper At Work

Body:
Everyone knows the old minesweeper game that shipped with Windows XP. It's a simple grid with a 9x9 matrix of cells containing either a number (indicating how many mines are adjacent to it) or a mine.

The challenge is to generate a random 9x9 grid with 10 bombs given any integer seed (up to whatever your machine/language's largest int is) with brownie points if you implement the PRNG yourself

example output: cells contain either numerals 0-8 or * for mines

```<code>*101*1000
110111000
123210000
1***10000
123210011
00000002*
00000114*
000112*3*
0001*2121
</code>```

Shortest code in bytes wins.. standard rules etc, etc..

Body:
JavaScript ES6, 244 bytes

f=(a=[...Array(11)].map(_=>Array(11).fill(0)),n=10,r=_=>Math.random()*9|0,x=r(),y=r())=>a[x+1][y+1]>8||[0,1,2].map(i=>[0,1,2].map(j=>a[x+i][y+j]++),a[x+1][y+1]=9)&&--n?f(a,n):a.slice(1,-1).map(a=>a.slice(1,-1).map(n=>n<9?n:`*`).join``).join`
`
;o.textContent=f()

<pre id=o>


答:
C#, <s>64</s> 63 bytes

```<code>s=>{foreach(int c in s+(s=""))s+=c+(10==c?"\n":"    ");return s;};
</code>```

-1 byte by using actual tab character instead of \t. Note: renders as 4 spaces above and 2 spaces in the ungolfed version below.

Ungolfed:

```<code>/*Func<string, string> Lambda =*/ s =>
{
    // Enumerate the ascii (int) values of the chars in s,
    // but at the same time set input s to "" to use at the output var.
    // +(s="")   is 2 bytes less than   var o="";
    foreach (int c in s + (s=""))
        // Append the string representation of the ascii value,
        // Append new line if c was new line, otherwise append tab.
        s += c + (10==c ? "\n" : "  ");
    return s;
};
</code>```

Results:

(Note: Visual Studio has used \r\n for the new lines when I pasted the input in, hence the 13  10 line endings in output)

```<code>Input:

#include <stdio.h>

int maint() {
    printf("hello, world\n");
    return 0;
}

Output:

35  105 110 99  108 117 100 101 32  60  115 116 100 105 111 46  104 62  13  10
13  10
105 110 116 32  109 97  105 110 116 40  41  32  123 13  10
32  32  32  32  112 114 105 110 116 102 40  34  104 101 108 108 111 44  32  119 111 114 108 100 92  110 34  41  59  13  10
32  32  32  32  114 101 116 117 114 110 32  48  59  13  10
125
</code>```

Body:
C#, <s>64</s> 63 bytes

s=>{foreach(int c in s+(s=""))s+=c+(10==c?"\n":"    ");return s;};

-1 byte by using actual tab character instead of \t. Note: renders as 4 spaces above and 2 spaces in the ungolfed version below.

Ungolfed:

/*Func<string, string> Lambda =*/ s =>
{
    // Enumerate the ascii (int) values of the chars in s,
    // but at the same time set input s to "" to use at the output var.
    // +(s="")   is 2 bytes less than   var o="";
    foreach (int c in s + (s=""))
        // Append the string representation of the ascii value,
        // Append new line if c was new line, otherwise append tab.
        s += c + (10==c ? "\n" : "  ");
    return s;
};

Results:

(Note: Visual Studio has used \r\n for the new lines when I pasted the input in, hence the 13  10 line endings in output)

Input:

#include <stdio.h>

int maint() {
    printf("hello, world\n");
    return 0;
}

Output:

35  105 110 99  108 117 100 101 32  60  115 116 100 105 111 46  104 62  13  10
13  10
105 110 116 32  109 97  105 110 116 40  41  32  123 13  10
32  32  32  32  112 114 105 110 116 102 40  34  104 101 108 108 111 44  32  119 111 114 108 100 92  110 34  41  59  13  10
32  32  32  32  114 101 116 117 114 110 32  48  59  13  10
125


答:
Javascript (ES6), 204 or 198 bytes

Custom PRNG (204 bytes)

```<code>s=>(p=-1,S=n=>(x=p%9-(n+=p)%9)*x-64&&b[n]=='*',T=n=>S(n)+S(-n),b=[...'*00000000'.repeat(9)]).sort(_=>(s=(22695477*s+1)>>>0)&1||-1).map(c=>(p++,c=='0'?T(1)+T(8)+T(9)+T(10):c)).join``.match(/.{9}/g).join`
`
</code>```

This code is using a linear congruential generator with multiplier 22695477 and increment 1 (this is the Borland C/C++ implementation).

Due to the poor efficiency of the PRNG during its warmup phase, I had to place one bomb per row (instead of 10 at the beginning or 10 at the end of the unshuffled array). So, there are only 9 bombs. I may try to fix that later.

Also, there must be a simpler/shorter way of processing the 'out of board' check (x=p%9-(n+=p)%9)*x-64 but I just can't figure it out right now.

Using Math.random() (198 bytes)

```<code>s=>(p=-1,S=n=>(x=p%9-(n+=p)%9)*x-64&&b[n]=='*',T=n=>S(n)+S(-n),b=[...'**********'+'0'.repeat(71)]).sort(_=>Math.random()-.5).map(c=>(p++,c=='0'?T(1)+T(8)+T(9)+T(10):c)).join``.match(/.{9}/g).join`
`
</code>```

This one includes 10 mines as requested.

Demo

let f =
_=>(p=-1,S=n=>(x=p%9-(n+=p)%9)*x-64&&b[n]=='*',T=n=>S(n)+S(-n),b=[...'**********'+'0'.repeat(71)]).sort(_=>Math.random()-.5).map(c=>(p++,c=='0'?T(1)+T(8)+T(9)+T(10):c)).join``.match(/.{9}/g).join`
`
console.log(f())```

Title: Minesweeper At Work

Body:
Javascript (ES6), 204 or 198 bytes

Custom PRNG (204 bytes)

s=>(p=-1,S=n=>(x=p%9-(n+=p)%9)*x-64&&b[n]=='*',T=n=>S(n)+S(-n),b=[...'*00000000'.repeat(9)]).sort(_=>(s=(22695477*s+1)>>>0)&1||-1).map(c=>(p++,c=='0'?T(1)+T(8)+T(9)+T(10):c)).join``.match(/.{9}/g).join`
`

This code is using a linear congruential generator with multiplier 22695477 and increment 1 (this is the Borland C/C++ implementation).

Due to the poor efficiency of the PRNG during its warmup phase, I had to place one bomb per row (instead of 10 at the beginning or 10 at the end of the unshuffled array). So, there are only 9 bombs. I may try to fix that later.

Also, there must be a simpler/shorter way of processing the 'out of board' check (x=p%9-(n+=p)%9)*x-64 but I just can't figure it out right now.

Using Math.random() (198 bytes)

s=>(p=-1,S=n=>(x=p%9-(n+=p)%9)*x-64&&b[n]=='*',T=n=>S(n)+S(-n),b=[...'**********'+'0'.repeat(71)]).sort(_=>Math.random()-.5).map(c=>(p++,c=='0'?T(1)+T(8)+T(9)+T(10):c)).join``.match(/.{9}/g).join`
`

This one includes 10 mines as requested.

Demo

let f =
_=>(p=-1,S=n=>(x=p%9-(n+=p)%9)*x-64&&b[n]=='*',T=n=>S(n)+S(-n),b=[...'**********'+'0'.repeat(71)]).sort(_=>Math.random()-.5).map(c=>(p++,c=='0'?T(1)+T(8)+T(9)+T(10):c)).join``.match(/.{9}/g).join`
`
console.log(f())


答:
><> (Fish), 48 Bytes

```<code>>i:0(?v::oa=?v9o
2';'oa<.20r  <~p3
o9nv?=0l
voa<
</code>```

A task the language shines at! I'm sure I could probably have golfed out a little bit more, but it's been a long week. Might take a look at it later though.

Try it online!

Alternate try it online that looks nicer in my opinion, but the text wrapping messes up a bit for input with long lines like the test case.

Body:
><> (Fish), 48 Bytes

>i:0(?v::oa=?v9o
2';'oa<.20r  <~p3
o9nv?=0l
voa<

A task the language shines at! I'm sure I could probably have golfed out a little bit more, but it's been a long week. Might take a look at it later though.

Try it online!

Alternate try it online that looks nicer in my opinion, but the text wrapping messes up a bit for input with long lines like the test case.


答:
JavaScript (ES6), 221 bytes

f=
_=>(a=[...Array(15)].map(_=>Array(15).fill`.`),r=([c,i,j])=>[a[i][j]=a[k=14-i][j]=a[i][j=14-j]=a[k][j]=c,j,i],[..."TDDDDtdX"].map((c,i)=>r([c,i,i])),"d30t51d62d73T70".replace(/.../g,s=>r(r(s))),a.map(a=>a.join``).join`
`)
;o.textContent=f()```
<pre class="snippet-code-html lang-html prettyprint-override"><code><pre id=o></code>```

Since I went to the trouble of creating this I thought I'd post it anyway even though there's a clearly superior solution available.

Title: Draw an Empty Scrabble Board

Body:
JavaScript (ES6), 221 bytes

f=
_=>(a=[...Array(15)].map(_=>Array(15).fill`.`),r=([c,i,j])=>[a[i][j]=a[k=14-i][j]=a[i][j=14-j]=a[k][j]=c,j,i],[..."TDDDDtdX"].map((c,i)=>r([c,i,i])),"d30t51d62d73T70".replace(/.../g,s=>r(r(s))),a.map(a=>a.join``).join`
`)
;o.textContent=f()

<pre id=o>

Since I went to the trouble of creating this I thought I'd post it anyway even though there's a clearly superior solution available.


问:
At least h with at least h

Input

A list of nonnegative integers.

Output

The largest nonnegative integer h such that at least h of the numbers in the list are greater than or equal to h.

Test Cases

```<code>[0,0,0,0] -> 0
[12,312,33,12] -> 4
[1,2,3,4,5,6,7] -> 4
[22,33,1,2,4] -> 3
[1000,2,2,2] -> 2
[23,42,12,92,39,46,23,56,31,12,43,23,54,23,56,73,35,73,42,12,10,15,35,23,12,42] -> 20
</code>```

Rules

You can write either a full program or a function, and anonymous functions are allowed too. This is code-golf, so the fewest byte count wins. Standard loopholes are disallowed.

Background

The h-index is a notion used in academia which aims to capture the impact and productivity of a researcher. According to Wikipedia, a researcher has index h, if he or she has published h scientific articles, each of which has been cited in other articles at least h times. Thus, this challenge is about computing the h-index from a list of citation counts.

Update

Wow, great answers all round! I have accepted the shortest one, but if someone else comes up with an even shorter one, I'll update my choice accordingly.

Winners by language

Here's a table of winners by language that I'll also try to keep up to date. I have included all posts with nonnegative score. Please correct me if I have made a mistake here.

APL: 7 bytes by @MorisZucca

Bash + coreutils: 29 bytes by @DigitalTrauma

C#: 103 bytes by @LegionMammal978

C++: 219 bytes by @user9587

CJam: 15 bytes by @nutki

GolfScript: 13 bytes by @IlmariKaronen

Haskell: 40 bytes by @proudhaskeller

J: 12 bytes by @ɐɔıʇǝɥʇuʎs

Java: 107 bytes by @Ypnypn

JavaScript: 48 bytes by @edc65

Mathematica: 38 bytes by @kukac67

Perl: 32 bytes by @nutki

Pyth: 10 bytes by @isaacg

Python: 49 bytes by @feersum

R: 29 bytes by @MickyT

Ruby: 41 bytes by @daniero

Scala: 62 bytes by @ChadRetz

SQL: 83 bytes by @MickyT

TI-BASIC: 22 bytes by @Timtech

答:
Octave, 41 bytes

```<code>@(x)sum(cumprod(-sort(-x)>=(1:numel(x))))
</code>```

This is an anonymous function.

Try it at Ideone.

Title: At least h with at least h

Body:
Octave, 41 bytes

@(x)sum(cumprod(-sort(-x)>=(1:numel(x))))

This is an anonymous function.

Try it at Ideone.


答:
Pyth, <s>17</s> 13 bytes

Another one of those Pyth programmers.  Sorry.

The new code requires each line to be wrapped in quotes and escaped (including newlines if you desire them to be printed), but puts an extra newline between the line and the ASCII.

```<code>jjLC9smCMBd.Q
</code>```

Try it online!

Explanation:

```<code>           .Q  Evaluate all input lines
      m        For each of those lines:
         Bd     Return the line and
       CM       the line mapped to ASCII characters
     s         Sum all these together to begin alternating between line and mapped line
 jLC9          Join all the characters and numbers in the lines and mapped lines on tabs
j              And join all of those on newlines
</code>```

I'm keeping the old code and its' explanation below.

```<code>#Jw
jKC9J
jK+CMJT
</code>```

Try it online! or use an easier-to-read test case.

Explanation:

```<code>#                  Until we run into an error:
 Jw                 Read in the next line of input and call it J.
                     (When there is no line of input, error is thrown that ends program.)

j                  Join:
    J               all characters in input line
 KC9                and insert tab characters (C9), which we can refer to later as K.
                        (Setting it to a variable doesn't save or lose bytes.)

                   Implicit print that join with trailing newline.

j                  Join:
   CMJ              the mapping of ASCII numbers to characters in the input,
 K                  inserting tab characters in between every number
  +   T             And with a trailing 10 for the newline at the end.
</code>```

Body:
Setting the Scene:

It is an average afternoon, as you unwind after a long day by engaging in your favorite pastime: answering the plethora of captivating questions on PPCG. It hasn't been a good day for you; those damned Pyth programmers keep getting best answer and it's killing your vibe. Suddenly, you notice a new question has been posted! You make up your mind; not this time CJammers. Furiously, you begin to type, birthing a stream of characters; a fetus of the glorious BrainFuck loop that your end product will be. You type and type. Faster! Faster still! You're so focused you don't even notice the lights on your screen start to flicker on and off. Suddenly, the monitor glows green, an alien like symbol branded upon the desktop. Using your impeccable skills you cat ~/Desktop/aliensymbol and get presented with a bunch of numbers, a message! Being the shrewd PPCG programmer that you are, you notice that it looks like ASCII. No matter for you, you print(chr(i) for i in file) and decipher the message. Your first thought: "I need to share this with the community!".

...

Who would've thought it? That the first people to make contact with aliens would be the humble programmers of PPCG. Why us? Maybe it is because we are the epitome of human intelligence. Or maybe because BrainFuck is about as close as we have to an alien language. Nevertheless, the aliens - being the ultra-intelligent life forms that they are - want to test whether they should classify the human race as  intelligent or not. As a test of our mental prowess, the aliens have asked us to send them a few computer programs to demonstrate that we are technologically cultured. The issue is, the only human language they understand is numerical ASCII!

Help humankind show those creatures who the real intellectual alpha is. We need to send them a script that will convert our text based source codes into their numerical ASCII versions. Unfortunately, due to our underdeveloped technology (thanks Obama), we must send as small a translating program as possible. Good thing they chose to contact PPCG!

The Challenge:

The premise of this challenge is simple: you are to write a program that will take any program's source code (or any general text file for that matter), and output a space separated version of it with an ASCII translation below each line. That is, given an input of a text file, you need to output each line of that file followed by a line containing the ASCII representation of each character in the line above it (with each number lining up with the character it represents).

An example will greatly clarify this. Taking the source code of the infamous hello world as the input:

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

int main() {
    printf("hello, world\n");
    return 0;
}
</code>```

your program should output:

```<code>#   i   n   c   l   u   d   e       <   s   t   d   i   o   .   h   >
35  105 110 99  108 117 100 101 32  60  115 116 100 105 111 46  104 62  10

10
i   n   t       m   a   i   n   (   )       {
105 110 116 32  109 97  105 110 40  41  32  123 10
                p   r   i   n   t   f   (   "   h   e   l   l   o   ,       w   o   r   l   d   \   n   "   )   ;
32  32  32  32  112 114 105 110 116 102 40  34  104 101 108 108 111 44  32  119 111 114 108 100 92  110 34  41  59  10
                r   e   t   u   r   n       0   ;
32  32  32  32  114 101 116 117 114 110 32  48  59  10
}
125 10
</code>```

Implementation Details:

You may choose to take the input in whatever form you wish (opening file, command line pipe, function parameter etc.) and you should output to stdout or return the output from a function.

Things to note

Each character in the output is separated by a '\t' to allow for the space of 3 digits in the line below to line up (we are going to assume your tab is set to 4 spaces or more).

The newlines are displayed on the line that the return key was pressed (notice the 10's in the example)

The '\t' and '\n' printing requirements are lax. Your output must, in the general sense, look pleasing to the eye (need to show those aliens we have aesthetic sense as well), and if you can bend the previous two points while maintaining visual integrity, you will be forgiven.

You can choose to assume whether or not there is a newline at the end of the last line.

Scoring

This is code-golf so shortest program wins. Note, even if your program isn't the shortest, but uses really neat tricks relative to the language you are using, many +1's to you!

Good luck. The intergalactic intelligence ranking of humanity rests on your shoulders.

Note: Please forgive the plot holes. I'm not a writer :D

Body:
Pyth, <s>17</s> 13 bytes

Another one of those Pyth programmers.  Sorry.

The new code requires each line to be wrapped in quotes and escaped (including newlines if you desire them to be printed), but puts an extra newline between the line and the ASCII.

jjLC9smCMBd.Q

Try it online!

Explanation:

           .Q  Evaluate all input lines
      m        For each of those lines:
         Bd     Return the line and
       CM       the line mapped to ASCII characters
     s         Sum all these together to begin alternating between line and mapped line
 jLC9          Join all the characters and numbers in the lines and mapped lines on tabs
j              And join all of those on newlines

I'm keeping the old code and its' explanation below.

#Jw
jKC9J
jK+CMJT

Try it online! or use an easier-to-read test case.

Explanation:

#                  Until we run into an error:
 Jw                 Read in the next line of input and call it J.
                     (When there is no line of input, error is thrown that ends program.)

j                  Join:
    J               all characters in input line
 KC9                and insert tab characters (C9), which we can refer to later as K.
                        (Setting it to a variable doesn't save or lose bytes.)

                   Implicit print that join with trailing newline.

j                  Join:
   CMJ              the mapping of ASCII numbers to characters in the input,
 K                  inserting tab characters in between every number
  +   T             And with a trailing 10 for the newline at the end.


问:
A Formula for Congruences
The Chinese Remainder Theorem can be quite useful in modular arithmetic.

For example, consider the following set of congruence relations:

For sets of congruence relations like this, where all the bases (3, 5, 7 in this example) are co-prime with each other, there will be one and only one integer n between 1 and the product of the bases (3*5*7 = 105 in this example) inclusive that satisfies the relations.

In this example, the number would be 14, generated by this formula:

where 2, 4, and 0 are given from the above example.

70, 21, 15 are the coefficients of the formula and they are dependent on the bases, 3, 5, 7.

To calculate the coefficients of the formula (70, 21, 15 in our example) for a set of bases, we use the following procedure.

For each number a in a set of bases:

Find the product of all of the other bases, denoted as P.

Find the first multiple of P that leaves a remainder of 1 when divided by a. This is the coefficient of a.

For example, to calculate the coefficient that corresponds to the base 3, we find the product of all the other bases (i.e. 5*7 = 35) and then find the first multiple of that product that leaves a remainder of 1 when divided by the base.

In this case, 35 leaves a remainder of 2 when divided by 3, but 35*2 = 70 leaves a remainder of 1 when divided by 3, so 70 is the corresponding coefficient for 3. Similarly, 3*7 = 21 leaves a remainder of 1 when divided by 5 and 3*5 = 15 leaves a remainder of 1 when divided by 7.

In a nutshell

For each number a in a set of numbers:

Find the product of all of the other numbers, denoted as P.

Find the first multiple of P that leaves a remainder of 1 when divided by a. This is the coefficient of a.

The challenge

The challenge is, for a set of two or more bases, to find the set of corresponding coefficients.

The set of bases are guaranteed to be pairwise co-prime and each base is guaranteed to be larger than 1.

Your input is a list of integers as input [3,4,5] or space-separated string "3 4 5" or however your inputs work.

Your output should either be a list of integers or space-separated string that denotes the set of coefficients.

Test cases

```<code>input             output
[3,5,7]           [70,21,15]
[2,3,5]           [15,10,6]
[3,4,5]           [40,45,36]
[3,4]             [4,9]
[2,3,5,7]         [105,70,126,120]
[40,27,11]        [9801,7480,6480]
[100,27,31]       [61101,49600,56700]
[16,27,25,49,11]  [363825,2371600,2794176,5583600,529200]
</code>```

Many thanks to Leaky Nun for his help in writing this challenge. As always, if the problem is unclear, please let me know. Good luck and good golfing!

答:
Actually, 14 bytes

This uses the algorithm in Dennis's Jelly answer. Another answer based on my Python answer is forthcoming. Golfing suggestions welcome. Try it online!

```<code>;π;)♀\;♂▒@♀ⁿ♀%
</code>```

How it works

```<code>                 Implicit input a.
;                Duplicate a.
 π;)             Take product() of a, duplicate and rotate to bottom.
    ♀\           Integer divide the product by each element of a. Call this list b.
      ;♂▒        Take that list, duplicate, and get the totient of each element.
         @♀ⁿ     Swap and take pow(<item in b>, <corresponding totient>)
            ♀%   Modulo each item by the remaining duplicate product on the stack.
                 Implicit return.
</code>```

Another answer based on my Python answer at 22 bytes. Golfing suggestions welcome. Try it online!

```<code>;π╖`╝╛╜\╛r*"╛@%1="£░`M
</code>```

How it works

```<code>            Implicit input a.
;π╖         Duplicate, take product of a, and save to register 0.
`...`M      Map over a.
  ╝           Save the item, b, in register 1.
  ╛╜\         product(a) // b. Call it P.
  ╛r          Take the range [0...b].
  *           Multiply even item in the range by P. Call this list x.
  "..."£░     Turn a string into a function f.
              Push values of [b] where f returns a truthy value.
    ╛@%         Push b, swap, and push <item in x> % b.
    1=          Does <item> % b == 1?
            Implicit return.
</code>```

Title: A Formula for Congruences

Body:
Actually, 14 bytes

This uses the algorithm in Dennis's Jelly answer. Another answer based on my Python answer is forthcoming. Golfing suggestions welcome. Try it online!

;π;)♀\;♂▒@♀ⁿ♀%

How it works

                 Implicit input a.
;                Duplicate a.
 π;)             Take product() of a, duplicate and rotate to bottom.
    ♀\           Integer divide the product by each element of a. Call this list b.
      ;♂▒        Take that list, duplicate, and get the totient of each element.
         @♀ⁿ     Swap and take pow(<item in b>, <corresponding totient>)
            ♀%   Modulo each item by the remaining duplicate product on the stack.
                 Implicit return.

Another answer based on my Python answer at 22 bytes. Golfing suggestions welcome. Try it online!

;π╖`╝╛╜\╛r*"╛@%1="£░`M

How it works

            Implicit input a.
;π╖         Duplicate, take product of a, and save to register 0.
`...`M      Map over a.
  ╝           Save the item, b, in register 1.
  ╛╜\         product(a) // b. Call it P.
  ╛r          Take the range [0...b].
  *           Multiply even item in the range by P. Call this list x.
  "..."£░     Turn a string into a function f.
              Push values of [b] where f returns a truthy value.
    ╛@%         Push b, swap, and push <item in x> % b.
    1=          Does <item> % b == 1?
            Implicit return.


Title: Draw an Empty Scrabble Board

Body:
Python 3, 138 bytes

d=lambda s:s+s[-2::-1]
print(*d(list(map(d,'T..d...T .D...t.. ..D...d. d..D...d ....D... .t...t.. ..d...d. T..d...X '.split()))),sep='\n')


答:
Windows PowerShell, 204

```<code>'$c=,0*3e4;'+@{62='$i++
';60='$i--
';43='$c[$i]++
';45='$c[$i]--
';44='$c[$i]=+[console]::ReadKey().keychar
';46='write-host -n([char]$c[$i])
';91='for(;$c[$i]){';93='}'}[[int[]][char[]]"$(gc $args)"]|iex
</code>```

Fairly straightforward conversion of the instructions and then Invoke-Expression.

History:

2011-02-13 22:24 (220) First attempt.

2011-02-13 22:25 (218) 3e4 is shorter than 30000.

2011-02-13 22:28 (216) Unnecessary line breaks. Matching on integers instead of characters is shorter.

2011-02-13 22:34 (207) Used indexes into a hash table instead of the switch.

2011-02-13 22:40 (205) Better cast to string removes two parentheses.

2011-02-13 22:42 (204) No need for a space after the argument to Write-Host.

Title: Interpret brainfuck

Body:
Write the shortest program in your favourite language to interpret a brainfuck program. The program is read from a file. Input and output are standard input and standard output.

Cell size: 8bit unsigned. Overflow is undefined.

Array size: 30000 bytes (not circled)

Bad commands are not part of the input

Comments begin with # and extend to the end of line Comments are everything not in +-.,[]<>

no EOF symbol

A very good test can be found here. It reads a number and then prints the prime numbers up to that number. To prevent link rot, here is a copy of the code:

```<code>compute prime numbers
to use type the max number then push Alt 1 0
===================================================================
======================== OUTPUT STRING ============================
===================================================================
>++++++++[<++++++++>-]<++++++++++++++++.[-]
>++++++++++[<++++++++++>-]<++++++++++++++.[-]
>++++++++++[<++++++++++>-]<+++++.[-]
>++++++++++[<++++++++++>-]<+++++++++.[-]
>++++++++++[<++++++++++>-]<+.[-]
>++++++++++[<++++++++++>-]<+++++++++++++++.[-]
>+++++[<+++++>-]<+++++++.[-]
>++++++++++[<++++++++++>-]<+++++++++++++++++.[-]
>++++++++++[<++++++++++>-]<++++++++++++.[-]
>+++++[<+++++>-]<+++++++.[-]
>++++++++++[<++++++++++>-]<++++++++++++++++.[-]
>++++++++++[<++++++++++>-]<+++++++++++.[-]
>+++++++[<+++++++>-]<+++++++++.[-]
>+++++[<+++++>-]<+++++++.[-]

===================================================================
======================== INPUT NUMBER  ============================
===================================================================
+                          cont=1
[
 -                         cont=0
 >,
 ======SUB10======
 ----------

 [                         not 10
  <+>                      cont=1
  =====SUB38======
  ----------
  ----------
  ----------
  --------

  >
  =====MUL10=======
  [>+>+<<-]>>[<<+>>-]<     dup

  >>>+++++++++
  [
   <<<
   [>+>+<<-]>>[<<+>>-]<    dup
   [<<+>>-]
   >>-
  ]
  <<<[-]<
  ======RMOVE1======
  <
  [>+<-]
 ]
 <
]
>>[<<+>>-]<<

===================================================================
======================= PROCESS NUMBER  ===========================
===================================================================

==== ==== ==== ====
numd numu teid teiu
==== ==== ==== ====

>+<-
[
 >+
 ======DUP======
 [>+>+<<-]>>[<<+>>-]<

 >+<--

 >>>>>>>>+<<<<<<<<   isprime=1

 [
  >+

  <-

  =====DUP3=====
  <[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<<<

  =====DUP2=====
  >[>>+>+<<<-]>>>[<<<+>>>-]<<< <

  >>>

  ====DIVIDES=======
  [>+>+<<-]>>[<<+>>-]<   DUP i=div

  <<
  [
    >>>>>+               bool=1
    <<<
    [>+>+<<-]>>[<<+>>-]< DUP
    [>>[-]<<-]           IF i THEN bool=0
    >>
    [                    IF i=0
      <<<<
      [>+>+<<-]>>[<<+>>-]< i=div
      >>>
      -                  bool=0
    ]
    <<<
    -                    DEC i
    <<
    -
  ]

  +>>[<<[-]>>-]<<
  >[-]<                  CLR div
  =====END DIVIDES====

  [>>>>>>[-]<<<<<<-]     if divides then isprime=0

  <<

  >>[-]>[-]<<<
 ]

 >>>>>>>>
 [
  -
  <<<<<<<[-]<<

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

  >>

  ===================================================================
  ======================== OUTPUT NUMBER  ===========================
  ===================================================================
  [>+<-]>

  [
   ======DUP======
   [>+>+<<-]>>[<<+>>-]<

   ======MOD10====
   >+++++++++<
   [
    >>>+<<              bool= 1
    [>+>[-]<<-]         bool= ten==0
    >[<+>-]             ten = tmp
    >[<<++++++++++>>-]  if ten=0 ten=10
    <<-                 dec ten
    <-                  dec num
   ]
   +++++++++            num=9
   >[<->-]<             dec num by ten

   =======RROT======
      [>+<-]
   <  [>+<-]
   <  [>+<-]
   >>>[<<<+>>>-]
   <

   =======DIV10========
   >+++++++++<
   [
    >>>+<<                bool= 1
    [>+>[-]<<-]           bool= ten==0
    >[<+>-]               ten = tmp
    >[<<++++++++++>>>+<-] if ten=0 ten=10  inc div
    <<-                   dec ten
    <-                    dec num
   ]
   >>>>[<<<<+>>>>-]<<<<   copy div to num
   >[-]<                  clear ten

   =======INC1=========
   <+>
  ]

  <
  [
   =======MOVER=========
   [>+<-]

   =======ADD48========
   +++++++[<+++++++>-]<->

   =======PUTC=======
   <.[-]>

   ======MOVEL2========
   >[<<+>>-]<

   <-
  ]

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

  ===================================================================
  =========================== END FOR ===============================
  ===================================================================

  >>>>>>>
 ]
 <<<<<<<<

 >[-]<
  [-]
 <<-
]

======LF========

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

Example run:

```<code>$ python2 bf.py PRIME.BF
Primes up to: 100
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
</code>```

Body:
Windows PowerShell, 204

'$c=,0*3e4;'+@{62='$i++
';60='$i--
';43='$c[$i]++
';45='$c[$i]--
';44='$c[$i]=+[console]::ReadKey().keychar
';46='write-host -n([char]$c[$i])
';91='for(;$c[$i]){';93='}'}[[int[]][char[]]"$(gc $args)"]|iex

Fairly straightforward conversion of the instructions and then Invoke-Expression.

History:

2011-02-13 22:24 (220) First attempt.

2011-02-13 22:25 (218) 3e4 is shorter than 30000.

2011-02-13 22:28 (216) Unnecessary line breaks. Matching on integers instead of characters is shorter.

2011-02-13 22:34 (207) Used indexes into a hash table instead of the switch.

2011-02-13 22:40 (205) Better cast to string removes two parentheses.

2011-02-13 22:42 (204) No need for a space after the argument to Write-Host.

ContentLicense: CC BY-SA 2.5


答:
Ruby 112 chars

```<code>101.times{|n|r=' ';[100,90,50,40,10,9,5,4,1].zip(%w(C XC L XL X IX V IV I)){|(k,v)|a,n=n.divmod k;r<<v*a};$><<r}
</code>```

Basically using the to_roman method explained here, but using a zipped array for brevity.

Body:
Write a program that count from 1 to 100 in Roman Numerals and print these numbers by standard output. Each one of the numbers must be separated by spaces.

You cannot use any built in function to transform to roman numerals nor external application or library to do so.

The desired result is

```<code>I II III IV V VI VII VIII IX X XI XII XIII XIV XV XVI XVII XVIII XIX XX XXI XXII XXIII XXIV XXV XXVI XXVII XXVIII XXIX XXX XXXI XXXII XXXIII XXXIV XXXV XXXVI XXXVII XXXVIII XXXIX XL XLI XLII XLIII XLIV XLV XLVI XLVII XLVIII XLIX L LI LII LIII LIV LV LVI LVII LVIII LIX LX LXI LXII LXIII LXIV LXV LXVI LXVII LXVIII LXIX LXX LXXI LXXII LXXIII LXXIV LXXV LXXVI LXXVII LXXVIII LXXIX LXXX LXXXI LXXXII LXXXIII LXXXIV LXXXV LXXXVI LXXXVII LXXXVIII LXXXIX XC XCI XCII XCIII XCIV XCV XCVI XCVII XCVIII XCIX C
</code>```

As it is a code golf challenge, shortest code wins.

Body:
Ruby 112 chars

101.times{|n|r=' ';[100,90,50,40,10,9,5,4,1].zip(%w(C XC L XL X IX V IV I)){|(k,v)|a,n=n.divmod k;r<<v*a};$><<r}

Basically using the to_roman method explained here, but using a zipped array for brevity.


答:
Python 3, <s>89</s> 77 bytes

more golfed version based on the same idea:

```<code>def f(s):
 for a in s:print(*map('{:>4}'.format,[*a,*a.encode()]),end='\n\n')
</code>```

If there are '\t's in the input, then change the 4 to a 9.

Prior version:

```<code>def f(s):
 for l in s:
  print(*l,sep='\t',end='');print(*l.encode(),sep='\t',end='\n\n')
</code>```

Takes a list of strings, each ending with a '\n'.

Body:
Python 3, <s>89</s> 77 bytes

more golfed version based on the same idea:

def f(s):
 for a in s:print(*map('{:>4}'.format,[*a,*a.encode()]),end='\n\n')

If there are '\t's in the input, then change the 4 to a 9.

Prior version:

def f(s):
 for l in s:
  print(*l,sep='\t',end='');print(*l.encode(),sep='\t',end='\n\n')

Takes a list of strings, each ending with a '\n'.


答:
CJam, 27 bytes

```<code>qN/{_1/9c*N+\{is9c}%+}%AN+*
</code>```

Try it online!

Explanation

```<code>q       e# Take the whole input
N/      e# Split on newlines
{       e# Map this block to every line:
_        e# Duplicate
1/       e# Split into characters
9c*      e# Join with tabs (ASCII code 9)
N+       e# Append a newline
\        e# Swap top elements
{is9c}%  e# Map each character to its ASCII code plus a tab character
+        e# Concatenate the two lines
}%      e# (end of block)
AN+*    e# Join with "10" plus a newline
</code>```

Body:
CJam, 27 bytes

qN/{_1/9c*N+\{is9c}%+}%AN+*

Try it online!

Explanation

q       e# Take the whole input
N/      e# Split on newlines
{       e# Map this block to every line:
_        e# Duplicate
1/       e# Split into characters
9c*      e# Join with tabs (ASCII code 9)
N+       e# Append a newline
\        e# Swap top elements
{is9c}%  e# Map each character to its ASCII code plus a tab character
+        e# Concatenate the two lines
}%      e# (end of block)
AN+*    e# Join with "10" plus a newline


问:
Find every digit from the largest column
Here's a relatively simple challenge for you:

Given a list of positive integers:

Line them up in a grid, and sum each column. For example, if the input was [123, 7, 49, 681], the grid would look like this:

```<code> 1  2  3
 7
 4  9
 6  8  1
</code>```

And the sum of each column would be [18, 19, 4]:

```<code> 1  2  3
 7
 4  9
 6  8  1
 --------
 18 19 4
</code>```

Find the maximum of these sums, which in this case would be 19, and then

Output every digit that is at the same index as this maximum column. In this case, that would be

```<code>2
9
8
</code>```

You do not have to output these numbers in any particular order.
Note that there are only three outputs, even though we had 4 inputs. In the case of a tie, pick the earliest index. For example, if the input was [25, 223, 302], your grid is:

```<code>2  5
2  2  3
3  0  2
-------
7  7  5
</code>```

You should output

```<code>2
2
3
</code>```

You can print these numbers in any format you like. List format, newline separated, space separated, etc. You may not take the input as a 2D array of digits, e.g.

```<code>[[1, 2, 3],
[7],
[4, 9],
[6, 8, 1]
</code>```

But other than that, you can take input as a list of strings, a list of digits, or any other reasonable format.

You may also assume that all inputs will be valid and contain at least two numbers.

As usual, the shortest answer in bytes wins!

Test IO:

```<code>#Input                      #Output
[1, 11, 111, 1111]      --> [1, 1, 1, 1]
[1, 12, 123]            --> [2, 2]
[987654321, 111]        --> [9, 1]
[111, 123456789]        --> [9]
[4, 8, 15, 16, 23, 42]  --> [4, 8, 1, 1, 2, 4]
[4, 8, 12, 26, 27, 38]  --> [2, 6, 7, 8]
[24, 53]                --> [2, 5]
[12, 304, 506]          --> [4, 6]
[30, 285, 121]          --> [0, 8, 2]
</code>```

答:
Jelly, 6 bytes

```<code>DZṚSÞṪ
</code>```

Try it online!. This is a relatively straightforward implementation of the question.

```<code>D              Convert each number in the input to a list of digits, e.g.
               [353, 2247] -> [[3, 5, 3], [2, 2, 4, 7]]
 Z             Zip the lists together, e.g. [[3, 2], [5, 2], [3, 4], [7]]
  Ṛ            Reverse the list of lists so that first occurrences are now
               at the end, e.g. [[7], [3, 4], [5, 2], [3, 2]]
   SÞ          Sort by sum - this uses Python's sorted function, which is stable
               so equal elements end up in order of appearance, e.g.
               [[3, 2], [7], [3, 4], [5, 2]]
     Ṫ         Tail - get the last element, e.g. [5, 2]
</code>```

Body:
Jelly, 6 bytes

DZṚSÞṪ

Try it online!. This is a relatively straightforward implementation of the question.

D              Convert each number in the input to a list of digits, e.g.
               [353, 2247] -> [[3, 5, 3], [2, 2, 4, 7]]
 Z             Zip the lists together, e.g. [[3, 2], [5, 2], [3, 4], [7]]
  Ṛ            Reverse the list of lists so that first occurrences are now
               at the end, e.g. [[7], [3, 4], [5, 2], [3, 2]]
   SÞ          Sort by sum - this uses Python's sorted function, which is stable
               so equal elements end up in order of appearance, e.g.
               [[3, 2], [7], [3, 4], [5, 2]]
     Ṫ         Tail - get the last element, e.g. [5, 2]


答:
GNU sed, <s>219</s> 205 bytes

```<code>s/$/T..d...T...d..T/p;h
s/.*/.D...t...t...D./p;G;h
s/.*/..D...d.d...D../p;G;h
s/.*/d..D...d...D..d/p;G;h
s/.*/....D.....D..../p;G;h
s/.*/.t...t...t...t./p;G;h
s/.*/..d...d.d...d../p;G;h
s/.*\n//;s/T/X/2p;g
</code>```

Taking advantage of the mirror symmetry of the board, the second half is the first one that was stored in reverse order in the hold space.

Title: Draw an Empty Scrabble Board

Body:
A standard Scrabble board is a 15×15 grid of spaces to place letter tiles. Most of the spaces are blank but some are double word scores (pink), triple word scores (red), double letter scores (light blue), and triple letter scores (blue). There is usually a star in the very center (which counts as a double word score).

Write a program or function that outputs a standard, empty Scrabble board in ASCII form where:

. represents an empty space

D represents a double word score

T represents a triple word score

d represents a double letter score

t represents a triple letter score

X represents the center star

That is, your exact output must be

```<code>T..d...T...d..T
.D...t...t...D.
..D...d.d...D..
d..D...d...D..d
....D.....D....
.t...t...t...t.
..d...d.d...d..
T..d...X...d..T
..d...d.d...d..
.t...t...t...t.
....D.....D....
d..D...d...D..d
..D...d.d...D..
.D...t...t...D.
T..d...T...d..T
</code>```

optionally followed by a trailing newline.

The shortest code in bytes wins.

Body:
GNU sed, <s>219</s> 205 bytes

s/$/T..d...T...d..T/p;h
s/.*/.D...t...t...D./p;G;h
s/.*/..D...d.d...D../p;G;h
s/.*/d..D...d...D..d/p;G;h
s/.*/....D.....D..../p;G;h
s/.*/.t...t...t...t./p;G;h
s/.*/..d...d.d...d../p;G;h
s/.*\n//;s/T/X/2p;g

Taking advantage of the mirror symmetry of the board, the second half is the first one that was stored in reverse order in the hold space.


答:
Ruby, <s>100</s> 97 bytes

```<code>a=$<.map &:chomp
puts a.map(&:size).max.times.map{|i|a.map{|e|e[i]}.compact}.max_by{|e|eval e*?+}
</code>```

Title: Find every digit from the largest column

Body:
Here's a relatively simple challenge for you:

Given a list of positive integers:

Line them up in a grid, and sum each column. For example, if the input was [123, 7, 49, 681], the grid would look like this:

```<code> 1  2  3
 7
 4  9
 6  8  1
</code>```

And the sum of each column would be [18, 19, 4]:

```<code> 1  2  3
 7
 4  9
 6  8  1
 --------
 18 19 4
</code>```

Find the maximum of these sums, which in this case would be 19, and then

Output every digit that is at the same index as this maximum column. In this case, that would be

```<code>2
9
8
</code>```

You do not have to output these numbers in any particular order.
Note that there are only three outputs, even though we had 4 inputs. In the case of a tie, pick the earliest index. For example, if the input was [25, 223, 302], your grid is:

```<code>2  5
2  2  3
3  0  2
-------
7  7  5
</code>```

You should output

```<code>2
2
3
</code>```

You can print these numbers in any format you like. List format, newline separated, space separated, etc. You may not take the input as a 2D array of digits, e.g.

```<code>[[1, 2, 3],
[7],
[4, 9],
[6, 8, 1]
</code>```

But other than that, you can take input as a list of strings, a list of digits, or any other reasonable format.

You may also assume that all inputs will be valid and contain at least two numbers.

As usual, the shortest answer in bytes wins!

Test IO:

```<code>#Input                      #Output
[1, 11, 111, 1111]      --> [1, 1, 1, 1]
[1, 12, 123]            --> [2, 2]
[987654321, 111]        --> [9, 1]
[111, 123456789]        --> [9]
[4, 8, 15, 16, 23, 42]  --> [4, 8, 1, 1, 2, 4]
[4, 8, 12, 26, 27, 38]  --> [2, 6, 7, 8]
[24, 53]                --> [2, 5]
[12, 304, 506]          --> [4, 6]
[30, 285, 121]          --> [0, 8, 2]
</code>```

Body:
Ruby, <s>100</s> 97 bytes

a=$<.map &:chomp
puts a.map(&:size).max.times.map{|i|a.map{|e|e[i]}.compact}.max_by{|e|eval e*?+}


答:
C, <s>146</s> <s>145</s> <s>142</s> 138 bytes

```<code>i,r,c;main(){for(;i<240;)r=abs(i/16-7),c="T..12..0..12..0"[r+7-abs(i%16-7)],putchar(++i%16?c&4?c:"Xd.dd.tt.D..D.dD.dD.tTd."[c%4+r*3]:10);}
</code>```

Try it online!

<s>1 byte</s>5 bytes saved thanks to Level River St

This exploits the diagonal pattern of the board for encoding.  In particular, if we take the top left quadrant of the board and align the diagonal, we get:

```<code>       T..d...T
      .D...t..
     ..D...d.
    d..D...d
   ....D...
  .t...t..
 ..d...d.
T..d...X
</code>```

...a lot of the columns now line up.  If we encode columns in a line this way:

```<code>       0..12..0 y/012/Td./
      .0..12..  y/012/D.t/
     ..0..12.   y/012/D.d/
    2..0..12    y/012/D.d/
   12..0..1     y/012/D../
  .12..0..      y/012/tt./
 ..12..0.       y/012/dd./
T..12..0        y/012/Xd./
</code>```

...then the board pattern can be collapsed into a 15 character string: T..12..0..12..0; and we simply need the right mappings for each row.

With that in mind, here's an expanded version with comments:

```<code>i,r,c;
main() {
   for(;i<240;)  // one char per output including new line
   r=abs(i/16-7) // row; goes from 7 to 0 and back to 7.
   , c="T..12..0..12..0"[r+7-abs(i%16-7)] // pattern char
   , putchar(++i%16 // if this is 0 we need a new line
   ? c&4 // hash to distinguish 'T' and '.' from '0', '1', '2'
     ? c // print 'T' and '.' literally
     : "Xd.dd.tt.D..D.dD.dD.tTd."[c%4+r*3] // otherwise look up replacement char
   : 10 // print the new line
   );
}
</code>```

Title: Draw an Empty Scrabble Board

Body:
C, <s>146</s> <s>145</s> <s>142</s> 138 bytes

i,r,c;main(){for(;i<240;)r=abs(i/16-7),c="T..12..0..12..0"[r+7-abs(i%16-7)],putchar(++i%16?c&4?c:"Xd.dd.tt.D..D.dD.dD.tTd."[c%4+r*3]:10);}

Try it online!

<s>1 byte</s>5 bytes saved thanks to Level River St

This exploits the diagonal pattern of the board for encoding.  In particular, if we take the top left quadrant of the board and align the diagonal, we get:

       T..d...T
      .D...t..
     ..D...d.
    d..D...d
   ....D...
  .t...t..
 ..d...d.
T..d...X

...a lot of the columns now line up.  If we encode columns in a line this way:

       0..12..0 y/012/Td./
      .0..12..  y/012/D.t/
     ..0..12.   y/012/D.d/
    2..0..12    y/012/D.d/
   12..0..1     y/012/D../
  .12..0..      y/012/tt./
 ..12..0.       y/012/dd./
T..12..0        y/012/Xd./

...then the board pattern can be collapsed into a 15 character string: T..12..0..12..0; and we simply need the right mappings for each row.

With that in mind, here's an expanded version with comments:

i,r,c;
main() {
   for(;i<240;)  // one char per output including new line
   r=abs(i/16-7) // row; goes from 7 to 0 and back to 7.
   , c="T..12..0..12..0"[r+7-abs(i%16-7)] // pattern char
   , putchar(++i%16 // if this is 0 we need a new line
   ? c&4 // hash to distinguish 'T' and '.' from '0', '1', '2'
     ? c // print 'T' and '.' literally
     : "Xd.dd.tt.D..D.dD.dD.tTd."[c%4+r*3] // otherwise look up replacement char
   : 10 // print the new line
   );
}


问:
Subtract the next numbers

Description

Subtract the next P numbers from a N number. The next number of N is N + 1.

Look at the examples to get what I mean.

Examples:

```<code>Input: N=2,P=3
Calculate: n - (n+1) - (n+2) - (n+3)     //Ending with 3, because P=3
Calculate: 2 -  2+1  -  2+2  - 2+3       //Replacing N with 2 from Input
Calculate: 2 -  3    -  4    - 5
Output: -10

Input: N=100,P=5
Calculate: n - (n+1) - (n+2) - (n+3) - (n+4) - (n+5)
Calculate: 100-  101 -  102  -  103  -  104  - 105
Output: -415

Input: N=42,P=0
Calculate: n
Calculate: 42
Output: 42

Input: N=0,P=3
Calculate: n - (n+1) - (n+2) - (n+3)
Calculate: 0 -  1    -  2    -  3
Output: -6

Input: N=0,P=0
Calulate: n
Calculate: 0
Output: 0
</code>```

Input:

N: Integer, positive, negative or 0

P: Integer, positive or 0, not negative

Output:

Integer or String, leading 0 allowed, trailing newline allowed

Rules:

No loopholes

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

Input and Output must be as described

答:
Julia: 17-18 bytes (13 as program with terminal inputs)

As per suggestion in comments that "function or program" form is needed:

as function: 17 characters, 18 bytes if you count ∘ as multibyte

```<code>n∘r=2n-sum(n:n+r)
</code>```

usage: 5∘3 outputs -16

as program, passed initial parameters from terminal: 13 bytes:

```<code>2n-sum(n:n+r)
</code>```

usage: julia -E 'n,r=5,3;include("codegolf.jl")'

Title: Subtract the next numbers

Body:
Julia: 17-18 bytes (13 as program with terminal inputs)

As per suggestion in comments that "function or program" form is needed:

as function: 17 characters, 18 bytes if you count ∘ as multibyte

n∘r=2n-sum(n:n+r)

usage: 5∘3 outputs -16

as program, passed initial parameters from terminal: 13 bytes:

2n-sum(n:n+r)

usage: julia -E 'n,r=5,3;include("codegolf.jl")'


答:
Haskell, 63 bytes

```<code>import Data.Lists
argmax sum.transpose.map(map(read.pure).show)
</code>```

Usage example: argmax sum.transpose.map(map(read.pure).show) $ [12,304,506] -> [4,6].

How it works:

```<code>                     map                       -- for each number
                         map(read.pure).show   -- turn into list of digits
           transpose                           -- transpose the list of list
argmax sum                                     -- find the element with the
                                               -- largest sum
</code>```

Body:
Haskell, 63 bytes

import Data.Lists
argmax sum.transpose.map(map(read.pure).show)

Usage example: argmax sum.transpose.map(map(read.pure).show) $ [12,304,506] -> [4,6].

How it works:

                     map                       -- for each number
                         map(read.pure).show   -- turn into list of digits
           transpose                           -- transpose the list of list
argmax sum                                     -- find the element with the
                                               -- largest sum


答:
Python, 139

```<code>print' '.join(' '.join(i+j for  j in ' _I_II_III_IV_V_VI_VII_VIII_IX'.split('_'))for i in ' _X_XX_XXX_XL_L_LX_LXX_LXXX_XC'.split('_'))+' C'
</code>```

Body:
Python, 139

print' '.join(' '.join(i+j for  j in ' _I_II_III_IV_V_VI_VII_VIII_IX'.split('_'))for i in ' _X_XX_XXX_XL_L_LX_LXX_LXXX_XC'.split('_'))+' C'


问:
Outputting x to y

Challenge

You must choose one number x (y = x + 9) and create ten unique programs which each print out one of the numbers in the range x to y inclusive. However, there are three twists:

Each program's score is the difference between length of your program in bytes and n (where n is the number that the program outputs). i.e. If a program is 12 bytes long and it outputs the number 15, its score is 3 (|15-12| = 3).

You must not use comments to achieve this byte count.

Your program must not contain any number which is contained within the number which the program outputs. i.e. If a program outputs 1659, the program cannot contain 1, 6, 5 or 9

Your program must not contain any of the characters which are the first letters of the number which the program outpts. i.e. If the program outputs 1659, the program cannot contain o, s, f or n (one, six, five and nine)

Rules

If any number is impossible, this is counted as a DNP. You should declare all DNPs in your range.

The following is a list of numbers and their spellings. The disallowed characters for each are highlighted in bold:

0: Zero

1: One

2: Two

3: Three

4: Four

5: Five

6: Six

7: Seven

8: Eight

9: Nine

Scoring

Your overall score is the sum of all your programs' scores.

Winning

The person with the lowest score with the fewest DNPs wins.

In the event of a tie, the person whose last edit was earliest wins.

答:
05AB1E, score = 0

Chosen x = 1

Programs

1: Variable initialized as 1

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

2: zeroth prime number

```<code>0Ø
</code>```

3: first digit of 2^15

```<code>žG¬
</code>```

4: integer root of 16

```<code>žvtï
</code>```

5: first digit of pi + 2

```<code>žqS¬Ì
</code>```

6: first digit of 2nd to last set from the powerset of 256

```<code>žzœ¨¤¬
</code>```

7: the (e // e)th primeth prime

```<code>žržr÷ØØ
</code>```

8: the first 2 digits of the sum of the 10 first multiples of 3, divided by 2

```<code>TLx+O¨Y÷
</code>```

9: ceil(sqrt(sum(range[1..10])))+2 XOR 1st prime

```<code>TLOtîÌXØ^
</code>```

10: int(prod([1..9])/2^15)-1

```<code>žmS¨PžG/ï<
</code>```

Title: Outputting x to y

Body:
05AB1E, score = 0

Chosen x = 1

Programs

1: Variable initialized as 1

X

2: zeroth prime number

0Ø

3: first digit of 2^15

žG¬

4: integer root of 16

žvtï

5: first digit of pi + 2

žqS¬Ì

6: first digit of 2nd to last set from the powerset of 256

žzœ¨¤¬

7: the (e // e)th primeth prime

žržr÷ØØ

8: the first 2 digits of the sum of the 10 first multiples of 3, divided by 2

TLx+O¨Y÷

9: ceil(sqrt(sum(range[1..10])))+2 XOR 1st prime

TLOtîÌXØ^

10: int(prod([1..9])/2^15)-1

žmS¨PžG/ï<


答:
Pyke, x=2, score 0

```<code>1h
1hh
1hhh
1hhhh
1hhhhh
1hhhhhh
1hhhhhhh
1hhhhhhhh
ZOhhhhhhhh
ZOhhhhhhhhh
</code>```

Title: Outputting x to y

Body:
Challenge

You must choose one number x (y = x + 9) and create ten unique programs which each print out one of the numbers in the range x to y inclusive. However, there are three twists:

Each program's score is the difference between length of your program in bytes and n (where n is the number that the program outputs). i.e. If a program is 12 bytes long and it outputs the number 15, its score is 3 (|15-12| = 3).

You must not use comments to achieve this byte count.

Your program must not contain any number which is contained within the number which the program outputs. i.e. If a program outputs 1659, the program cannot contain 1, 6, 5 or 9

Your program must not contain any of the characters which are the first letters of the number which the program outpts. i.e. If the program outputs 1659, the program cannot contain o, s, f or n (one, six, five and nine)

Rules

If any number is impossible, this is counted as a DNP. You should declare all DNPs in your range.

The following is a list of numbers and their spellings. The disallowed characters for each are highlighted in bold:

0: Zero

1: One

2: Two

3: Three

4: Four

5: Five

6: Six

7: Seven

8: Eight

9: Nine

Scoring

Your overall score is the sum of all your programs' scores.

Winning

The person with the lowest score with the fewest DNPs wins.

In the event of a tie, the person whose last edit was earliest wins.

Body:
Pyke, x=2, score 0

1h
1hh
1hhh
1hhhh
1hhhhh
1hhhhhh
1hhhhhhh
1hhhhhhhh
ZOhhhhhhhh
ZOhhhhhhhhh


答:
Pyth, x=2, score 0

```<code>h1
hh1
hhh1
hhhh1
hhhhh1
hhhhhh1
hhhhhhh1
hhhhhhhh1
hhhhhhyyld
hhhhhhhyyld
</code>```

Title: Outputting x to y

Body:
Pyth, x=2, score 0

h1
hh1
hhh1
hhhh1
hhhhh1
hhhhhh1
hhhhhhh1
hhhhhhhh1
hhhhhhyyld
hhhhhhhyyld


Title: Outputting x to y

Body:
Mathematica, x = 4, score 0

3+1&
4+01&
5+001&
6+0001&
7+00001&
8+000001&
8+2+22-22&
9+00000002&
9+000000003&
9+0000000004&

Anonymous functions. Take no input and return numbers as output.


Title: Outputting x to y

Body:
brainfuck, score = 0

Chosen x = 15

15

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

16

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

17

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

18

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

19

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

20

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

21

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

22

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

23

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

24

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

Output is in byte values.