问:
Count sum of all digits
This challenge is to write a program or script which counts the sum of all digits within the integers from 1 up to and including a given number.

Input, one positive integer.
Output, the sum of digits in that number and all smaller numbers.

Examples:

```<code>Input: 5
Integer Sequence: 1, 2, 3, 4, 5
Sum of Digits: 1 + 2 + 3 + 4 + 5 = 15

Input: 12
Integer Sequence: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
Sum of Digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 1 + 0 + 1 + 1 + 1 + 2 = 51
</code>```

To be clear, this is to count a sum of the digits - not the integers. For single-digit inputs, this will be the same. However, inputs larger than 10 will have different responses. This would be an incorrect response:

```<code>Input: 12
Output: 78
</code>```

Another example, to show the difference:

```<code>Input: 10

Integer Sequence: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Sum of Integers (INCORRECT RESPONSE): 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55

Digit Sequence: 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0
Sum of Digits (CORRECT RESPONSE): 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 1 + 0 = 46
</code>```

A larger test case (CORRECT RESPONSE):

```<code>Input: 1000000
Output: 27000001
</code>```

Rules & Guidelines:

Submitted code must be a complete program or script - not just a function. If the code requires includes, imports, etc., they must be included in the posted code.

The number must be input by the user - not hard-coded. Input may be received as a command-line argument, file, stdin, or any other means by which your language can take user input.

The code must be able to properly handle inputs at least up to (2^64)-1.

The code should only output the sum.

Submitted programs & scripts should be user-friendly and not wasteful of computer resources (e.g.: they should not declare insanely-large arrays to hold every character). There is no strict bonus or penalty for this, but please be good programmers.

Scoring:

Primary scoring mechanism is by code length. Lower scores are better. The following bonuses and penalties also apply:

-25 Bonus if your code can handle all positive numbers, for example: 1234567891234567891234564789087414984894900000000

-50 Bonus if your code can handle simple expressions, for example 55*96-12. To qualify for this bonus, the code should handle + - / * (addition, subtraction, division, multiplication) operators and enforce order of operations. Division is regular integer division.

The given example (55*96-12) evaluates to 5268. Your code should return the same for either of those inputs - correct answer is 81393.

-10 Bonus if your code qualifies for the -50 bonus and can handle the ^ (exponent) operator.

-100 Bonus if your code qualifies for the -50 bonus and does not use eval or similar to handle expressions.

+300 Penalty if your code relies upon any web resources.

答:
Silicon, 9 bytes

```<code>0I\«S»îTM
</code>```

Ugh, this is overly complicated in my opinion.

Anyways, explanation:

```<code>0I\«S»îTM

  \          Push a list with integers in the range...
0            ...0 to...
 I           ...the input.
   «         Map
    S        Split
   »
      î      Flatten list
       T     Convert all list items to integers
        M    Sum of list items
             Implicit output
</code>```

Title: Count sum of all digits

Body:
Silicon, 9 bytes

0I\«S»îTM

Ugh, this is overly complicated in my opinion.

Anyways, explanation:

0I\«S»îTM

  \          Push a list with integers in the range...
0            ...0 to...
 I           ...the input.
   «         Map
    S        Split
   »
      î      Flatten list
       T     Convert all list items to integers
        M    Sum of list items
             Implicit output


问:
Can Pac-Man Eat This String?
In the arcade version of the game, Pac-Man eats pac-dots. However, in this challenge, he's hungry for alphanumeric characters and punctuation in a string.

Your task is to create a function that feeds Pac-Man a string, evaluates if he can eat it or not, and returns the string with Pac-Man's location in it.

Pac-Man (<) eats characters from left to right, leaving an underscore or space for each character as he goes, and his goal is to get from the first position-1 to the last position+1:

```<code>1. <Pac
2. _<ac
3. __<c
4. ___<
</code>```

However, Pac-Man's natural enemy, the ghost, will stop him if he encounters one of the letters in the word "GHOST" (not case sensitive). Your function should return the string with Pac-Man's location as he encounters the ghost character:

```<code>1. <No!
2. _<o!
</code>```

The only thing that can defeat a ghost is a power pellet. If Pac-Man reaches a letter in the word "PELLET" (also not case sensitive) before coming to a ghost, he will eat the ghost and keep moving, and that pellet will be used up. Power pellets can stack (ie, in ppgg both ghosts would be eaten). The T character exists as both as a ghost and a pellet, so it can be ignored (treated as any other letter, like a).

```<code>1. <Pop
2. _<op
3. __<p
4. ___<
</code>```

To further clarify, in the string "Pac-Man loses here", the following operations occur:

```<code>P <P, +1 Pellet (1 pellet)
a <a
c <c
- <-
M <M
a <a
n <n
  <[space]
l <l, +1 Pellet (2 pellets)
o <o, -1 Pellet (1 pellet)
s <s, -1 Pellet (0 pellets)
e <e, +1 Pellet (1 pellet)
s <s, -1 Pellet (0 pellets)
  <[space]
h <h, ghost wins, returns
e
r
e
</code>```

Examples

```<code>Input: Pacman wins!
Output: ____________<

Input: Pacman loses wah-wah :(
Output: _______________<h-wah :(

Input: PELLET PELLET GHOST
Output: ___________________<

Input: Hello World!
Output: <Hello World!

Input: <_!@12<_<_<
Output: ___________<
</code>```

This is code-golf--lowest score in bytes wins.

答:
C++, 315 373 327 Bytes

(Note: still golfing)

```<code>#include <iostream>
#include <string>
using namespace std;
int main(){string input;getline(cin, input);
if(input.find("Pac-Man loses")!=string::npos||input.find("Pacman loses")!=string::npos)
    cout<<"<"<<input.substr(15,input.length()-1);
else{for(unsigned i=0;i<=input.length();++i)
    cout << "_";
cout<<"<";
}return 0;
}
</code>```

ContentLicense: CC BY-SA 3.0

Title: Can Pac-Man Eat This String?

Body:
C++, 315 373 327 Bytes

(Note: still golfing)

#include <iostream>
#include <string>
using namespace std;
int main(){string input;getline(cin, input);
if(input.find("Pac-Man loses")!=string::npos||input.find("Pacman loses")!=string::npos)
    cout<<"<"<<input.substr(15,input.length()-1);
else{for(unsigned i=0;i<=input.length();++i)
    cout << "_";
cout<<"<";
}return 0;
}


问:
From Rgb to Cmyk
Given 3 bytes or RGB as input, calculate the nearest CMYK values, and output them.

create either a function with parameters and return value or a program that operates on stdin/stdout

use the color profile of your choice, but provide a reference

input may be either separate numeric values in range [0;255] or a 6 digit hex string

output should be separate numeric values ranging either [0;1] or [0;100]

standard code golf: no loopholes, shortest code wins

extravagant ideas are welcome

sample data:

```<code>input             output
108,174,106       [0.3793103448275862, 0.0, 0.3908045977011494, 0.3176470588235294]
0,0,0             0,0,0,1
170,255,238       33,0,7,0
0x0088ff          1,0.4667,0,0
[250,235,215]     [0,6,14,1.96]
#123456           .7907,.3953,0,.6627
</code>```

Uncalibrated mapping is fine and probably the easiest

No input validation required; floats are allowed (ranging from 0 to 255), but may also be rounded

Output format should be either clearly commented or obvious; i.e.:

CMYK in that order

does not matter if percentage [0;100] or pure numbers [0;1]

Testing should include the trivial example [0,0,0].

This site has the most digits of online tools that I could find. Does anyone know a tool that gives more than 4 digits?

Title: From Rgb to Cmyk

Body:
Bash + ImageMagick, 69 bytes

convert "xc:$1[1x1]" -colorspace cmyk txt:-|grep -o '([^)]*)'|head -1

Example:

$ ./rgb2cmyk.sh "#6CAE6A"
(38%,0%,39%,32%)

$ ./rgb2cmyk.sh "#000000"
(0%,0%,0%,100%)

$ ./rgb2cmyk.sh "#AAFFEE"
(33%,0%,7%,0%)

$ ./rgb2cmyk.sh "#0088ff"
(100%,47%,0%,0%)

$ ./rgb2cmyk.sh "#FAEBD7"
(0%,6%,14%,2%)

$ ./rgb2cmyk.sh "#123456"
(79%,40%,0%,66%)


问:
Print a Lego piece
This challenge is a simple ascii-art one. Given two inputs, describing the height and width of a Lego piece, you have print an ASCII art representation of it.

Here is how the Lego pieces are supposed to look:

```<code>(4, 2)

___________
| o o o o |
| o o o o |
-----------

(8, 2)

___________________
| o o o o o o o o |
| o o o o o o o o |
-------------------

(4, 4)

___________
| o o o o |
| o o o o |
| o o o o |
| o o o o |
-----------

(3, 2)

_________
| o o o |
| o o o |
---------

(1, 1)

o
</code>```

If you can't tell from the test-cases, the top and bottom are width*2+3 underscores and dashes, and each row has pipes for the sides, o's for the little things, and everything is separated by spaces.

The only exception for this is (1, 1), which is just a single o.

You will never get 0 for any of the dimensions.

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Title: Print a Lego piece

Body:
Perl 5 - 84 77 bytes

84 Bytes

sub l{($x,$y)=@_;$w=3+2*$x;warn$x*$y<2?"o":'_'x$w.$/.('| '.'o 'x$x."|\n")x$y.'-'x$w}

77 Bytes. With some help from Dom Hastings

sub l{($x,$y)=@_;$x*$y<2?o:'_'x($w=3+2*$x).('
| '.'o 'x$x."|")x$y.$/.'-'x$w}


问:
IPv4 Integer Conversion Function
Write the shortest function to convert an IP address into it's integer representation and output it as an integer.

To change an IPv4 address to it's integer representation, the following calculation is required:

Break the IP address into it's four octets.

(Octet1 * 16777216) + (Octet2 * 65536) + (Octet3 * 256) + (Octet4)

Sample Input

```<code>192.168.1.1           10.10.104.36           8.8.8.8
</code>```

Sample Output

```<code>3232235777            168454180              134744072
</code>```

答:
Haskell - 14 chars

```<code>(.) a=(256*a+)
</code>```

usage in GHCi:

```<code>Prelude> let (.) a=(256*a+)
Prelude> 192. 168. 0. 1
3232235521
</code>```

The only problem is that you have to put spaces left or right of the dot, otherwise the numbers will be interpreted as floating point.

ContentLicense: CC BY-SA 2.5

Title: IPv4 Integer Conversion Function

Body:
Haskell - 14 chars

(.) a=(256*a+)

usage in GHCi:

Prelude> let (.) a=(256*a+)
Prelude> 192. 168. 0. 1
3232235521

The only problem is that you have to put spaces left or right of the dot, otherwise the numbers will be interpreted as floating point.


问:
Calculate the sum of ILD

Input:

An integer

Output:

Sum of the input itself + the length of the input + each individual digit of the input.

```<code>nr + nr-length + {sum of digits} = output
</code>```

Examples:

Input: 99

Output: 99 (nr) + 2 (nr-length) + (9 + 9) (digits) → 119

Input: 123

Output: 123 + 3 + (1 + 2 + 3) → 132

Challenge rules:

The input can also contain negative input, which are resolved special. The -/minus-sign is also +1 for the length, and is part of the first digit.

For example:

Input: -123

Output: -123 + 4 + (-1 + 2 + 3) → -115

You can assume that the input nor output will ever be outside the range of an (32-bit) integer.

General rules:

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

Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.

Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.

Default Loopholes are forbidden.

If possible, please add a link with a test for your code.

Also, please add an explanation if necessary.

Test cases:

```<code>87901 → 87931
123 → 132
99 → 119
5 → 11
1 → 3
0 → 1
-3 → -4
-123 → -115
-900 → -905
-87901 → -87886
</code>```

Semi-related: Count Sum of all Digits

答:
C++, 255 Bytes

```<code>#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int main(){
    string input;
    cin >> input;
    int sum = atoi(input.c_str()) + input.length();
    for(unsigned i = 0; i < input.length(); ++i)
        sum += input.at(i) - 48;
    return 0;
}
</code>```

Title: Calculate the sum of ILD

Body:
C++, 255 Bytes

#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int main(){
    string input;
    cin >> input;
    int sum = atoi(input.c_str()) + input.length();
    for(unsigned i = 0; i < input.length(); ++i)
        sum += input.at(i) - 48;
    return 0;
}


问:
What's the second non-repeating character?
Based on this question from Code Review

Given a non-empty string of printable ASCII characters, output the second non-repeating character. For example, for input DEFD, output F.

Input

A single string, in any suitable format.

Output

The second character that doesn't repeat, when reading left-to-right, again in a suitable format.

The output character is case-insensitive.

If no such character exists (e.g., all characters repeat), output an empty string.

Rules

The algorithm should ignore case. That is, D and d count as the same character.

Either a full program or a function are acceptable.

The input string will be guaranteed non-empty (i.e., at least one character in length).

The input string is ASCII. Any valid character could repeat, not just alphanumeric (this includes spaces).

Standard loopholes are forbidden.

This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Examples

Input is on first line, output is on second line.

```<code>DEFD
F

FEED
D

This is an example input sentence.
x

...,,,..,,!@
@

ABCDefgHijklMNOPqrsTuVWxyz
B

AAAAAABBBBB

Thisxthis

This this.
.
</code>```

答:
C#, 141 bytes

```<code>void p(){var x=Console.ReadLine().ToLower();var c=0;foreach(char i in x){if(x.Split(i).Length-1<2){if(++c==2){Console.WriteLine(i);break;}}}}
</code>```

Without break(smallest), 135 bytes

```<code>void p(){var x=Console.ReadLine().ToLower();var c=0;foreach(char i in x){if(x.Split(i).Length-1<2){if(++c==2){Console.WriteLine(i);}}}}
</code>```

With for(;;), 150 bytes

```<code>void p(){for(;;){var x=Console.ReadLine().ToLower();var c=0;foreach(char i in x){if(x.Split(i).Length-1<2){if(++c==2){Console.WriteLine(i);break;}}}}}
</code>```

Ungolfed with comments

```<code>void p()
{
    var x=Console.ReadLine().ToLower();//Get lowercase version of input from STDIN
    var c=0; //Create "count" integer
    foreach(char i in x){//For each char in input from STDIN
        if(x.Split(i).Length-1<2)//If current char occurs once in input from STDIN
        {
            if(++c==2){ //Add 1 to count and if count is 2
                Console.WriteLine(i); //Print result to STDOUT
                break; //Exit foreach
            } //End of IF
         } //End of IF
     } //End of FOREACH
} //End of VOID
</code>```

12 bytes saved by TuukkaX(change count to c).

3 bytes saved by TuukkaX(change string to var).

4 bytes saved by TuukkaX in "With for(;;)"(changed while(true) to for(;;)).

2 bytes saved by TuukkaX(changed c++;if(c==2) to if(++c==2)).

14 bytes saved by Bryce Wagner(changed x.ToCharArray() to x).

Body:
C#, 141 bytes

void p(){var x=Console.ReadLine().ToLower();var c=0;foreach(char i in x){if(x.Split(i).Length-1<2){if(++c==2){Console.WriteLine(i);break;}}}}

Without break(smallest), 135 bytes

void p(){var x=Console.ReadLine().ToLower();var c=0;foreach(char i in x){if(x.Split(i).Length-1<2){if(++c==2){Console.WriteLine(i);}}}}

With for(;;), 150 bytes

void p(){for(;;){var x=Console.ReadLine().ToLower();var c=0;foreach(char i in x){if(x.Split(i).Length-1<2){if(++c==2){Console.WriteLine(i);break;}}}}}

Ungolfed with comments

void p()
{
    var x=Console.ReadLine().ToLower();//Get lowercase version of input from STDIN
    var c=0; //Create "count" integer
    foreach(char i in x){//For each char in input from STDIN
        if(x.Split(i).Length-1<2)//If current char occurs once in input from STDIN
        {
            if(++c==2){ //Add 1 to count and if count is 2
                Console.WriteLine(i); //Print result to STDOUT
                break; //Exit foreach
            } //End of IF
         } //End of IF
     } //End of FOREACH
} //End of VOID

12 bytes saved by TuukkaX(change count to c).

3 bytes saved by TuukkaX(change string to var).

4 bytes saved by TuukkaX in "With for(;;)"(changed while(true) to for(;;)).

2 bytes saved by TuukkaX(changed c++;if(c==2) to if(++c==2)).

14 bytes saved by Bryce Wagner(changed x.ToCharArray() to x).


问:
Product over a range
Your task is simple: given two integers \$a\$ and \$b\$, output \$\Pi[a,b]\$; that is, the product of the range between \$a\$ and \$b\$. You may take \$a\$ and \$b\$ in any reasonable format, whether that be arguments to a function, a list input, STDIN, et cetera. You may output in any reasonable format, such as a return value (for functions) or STDOUT. \$a\$ will always be less than \$b\$.

Note that the end may be exclusive or inclusive of \$b\$. I'm not picky. ^_^

Test cases

```<code>[a,b) => result
[2,5) => 24
[5,10) => 15120
[-4,3) => 0
[0,3) => 0
[-4,0) => 24

[a,b] => result
[2,5] => 120
[5,10] => 151200
[-4,3] => 0
[0,3] => 0
[-4,-1] => 24
</code>```

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

Leaderboard

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

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

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

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

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

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

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

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

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
dc, <s>41</s> <s>38</s> 37 bytes

This is my first code golf, so bear with me

```<code>[lad1+sa*dstlalb>d]sd?sbdst1+saltldxf
</code>```

It must be saved as a file, and invoked (with bash, so UNIX only) as

```<code>dc -f [filename]
</code>```

It will proceed to wait for input, in the form of a b integers. Note that negative numbers must come as _number.

Alternatively,

```<code>echo "X Y [lad1+sa*dstlalb>d]sd?sbdst1+saltdxf" | dc
</code>```

with X and Y replaced with the two numbers you'd like to product-over-range. This one won't wait unless you don't pipe two numbers.

Explanation:

```<code>The recursive macro:
[lad    # load the contents of register a onto the stack, and duplicate it
 1+sa   # Add 1 to the top of the stack (a) and store it in register a
 *dst   # Multiply two off the stack, duplicate and store in register t (stack contains t)
 lalb>d # load a and b, as long as b>a execute d (which is this macro)
 ]sd    # Store that macro in register d
 ?      # Wait for input, hope it is [a b] without braces
 sbd    # store b, duplicate a (stack == a a) (old: sbddsa)
 st     # store a => t (stack == a)
 1+sa   # add 1 to a and store it in a
 lt     # load t since d expects the total to be on the stack
 ldx    # load d and execute it as a macro
 f      # after d is done recursively calling, t will still be on the stack.
        # Print the stack and close (close is implicit)
</code>```

There was a removal of a spare duplication and store (dsa)

ContentLicense: CC BY-SA 4.0

Title: Product over a range

Body:
dc, <s>41</s> <s>38</s> 37 bytes

This is my first code golf, so bear with me

[lad1+sa*dstlalb>d]sd?sbdst1+saltldxf

It must be saved as a file, and invoked (with bash, so UNIX only) as

dc -f [filename]

It will proceed to wait for input, in the form of a b integers. Note that negative numbers must come as _number.

Alternatively,

echo "X Y [lad1+sa*dstlalb>d]sd?sbdst1+saltdxf" | dc

with X and Y replaced with the two numbers you'd like to product-over-range. This one won't wait unless you don't pipe two numbers.

Explanation:

The recursive macro:
[lad    # load the contents of register a onto the stack, and duplicate it
 1+sa   # Add 1 to the top of the stack (a) and store it in register a
 *dst   # Multiply two off the stack, duplicate and store in register t (stack contains t)
 lalb>d # load a and b, as long as b>a execute d (which is this macro)
 ]sd    # Store that macro in register d
 ?      # Wait for input, hope it is [a b] without braces
 sbd    # store b, duplicate a (stack == a a) (old: sbddsa)
 st     # store a => t (stack == a)
 1+sa   # add 1 to a and store it in a
 lt     # load t since d expects the total to be on the stack
 ldx    # load d and execute it as a macro
 f      # after d is done recursively calling, t will still be on the stack.
        # Print the stack and close (close is implicit)

There was a removal of a spare duplication and store (dsa)


问:
"99 Bottles of Beer"
Write a program that outputs the lyrics to 99 Bottles of Beer, in as few bytes as possible.

Lyrics:

```<code>99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.

98 bottles of beer on the wall, 98 bottles of beer.
Take one down and pass it around, 97 bottles of beer on the wall.

97 bottles of beer on the wall, 97 bottles of beer.
Take one down and pass it around, 96 bottles of beer on the wall.

96 bottles of beer on the wall, 96 bottles of beer.
Take one down and pass it around, 95 bottles of beer on the wall.

95 bottles of beer on the wall, 95 bottles of beer.
Take one down and pass it around, 94 bottles of beer on the wall.

....

3 bottles of beer on the wall, 3 bottles of beer.
Take one down and pass it around, 2 bottles of beer on the wall.

2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.

1 bottle of beer on the wall, 1 bottle of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
</code>```

Rules:

Your program must log to STDOUT or an acceptable alternative, or be returned from a function (with or without a trailing newline).

Your program must be a full, runnable program or function.

Languages specifically written to submit a 0-byte answer to this challenge are allowed, just not particularly interesting.

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

This is different from the output by HQ9+ or 99. Any answers written in these languages will be deleted.

As this is a catalog challenge, this is not about finding the language with the shortest solution for this (there are some where the empty program does the trick) - this is about finding the shortest solution in every language. Therefore, no answer will be marked as accepted.

Catalogue

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
XSLT 1.0 (no EXSLT), 845 bytes

```<code><transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0"><output method="text"/><template match="/"><call-template name="b"/></template><template name="b"><param name="n" select="99"/><if test="$n>0"><variable name="o"><if test="$n>1"><value-of select="$n -1"/></if><if test="$n=1">99</if></variable><variable name="p"><if test="$n>1">s</if></variable><variable name="q"><if test="$n!=2">s</if></variable><variable name="z"><if test="$n=1">Go to the store and buy some more</if><if test="$n>1">Take one down and pass it around</if></variable><variable name="w" select="concat($n,' bottle',$p,' of beer')"/><value-of select="concat($w,' on the wall, ',$w,'.
',$z,', ',number($o),' bottle',$q,' of beer on the wall.
')"/><call-template name="b"><with-param name="n" select="$n -1"/></call-template></if></template></transform>
</code>```

With a bit less golf in it:

```<code><transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <output method="text"/>
    <template match="/">
        <call-template name="b"/>
    </template>
    <template name="b">
        <param name="n" select="99"/>
        <if test="$n>0">
            <variable name="o">
                <if test="$n>1">
                    <value-of select="$n -1"/>
                </if>
                <if test="$n=1">99</if>
            </variable>
            <variable name="p">
                <if test="$n>1">s</if>
            </variable>
            <variable name="q">
                <if test="$n!=2">s</if>
            </variable>
            <variable name="z">
                <if test="$n=1">Go to the store and buy some more</if>
                <if test="$n>1">Take one down and pass it around</if>
            </variable>
            <variable name="w" select="concat($n,' bottle',$p,' of beer')"/>
            <value-of select="concat($w,' on the wall, ',$w,'.
',$z,', ',number($o),' bottle',$q,' of beer on the wall.
')"/>
            <call-template name="b">
                <with-param name="n" select="$n -1"/>
            </call-template>
        </if>
    </template>
</transform>
</code>```

Notes

Text compression

The use of variables as abbreviations isn't as extensive as in other languages; for example, note the repetition of ' bottle' as a constant. In XSLT, the binding of an XPath expression or some arbitrary text to a variable name requires at least 29 characters of overhead, excluding the name and content itself:

```<code><variable name="name" select="expr"/>
<variable name="name">text</variable>
</code>```

Say, for example, that one would like to replace all instances of the XPath string literal ' bottle' (8 chars) with $b (2 chars). Each substitution saves 6 characters. However, given the definition <variable name="b"> bottle</variable> (38 chars), there is no net profit unless there are 7 or more such sequences to replace.

The use of the <variable/> element is limited to evaluating conditions. The version of XPath used with XSLT 1.0 does not have its own if/else constructs, but XSLT itself does, and <variable/> is necessary to retrieve the results in a useful form.

$n -1

The expression $n -1 appears twice. The space after the $n is required since - is a valid name character in XPath.

Inequalities

Wherever practical, any instance where != originally appeared was changed to use > instead. If the program counted down to 0 instead of resetting to 99 after 1, the plural check for $n would be incorrect at 0.

Tail recursion

The template named b recurses, counting the variable n down by one each time. XSLT provides looping constructs, but they are for traversing structures found in the input document. A task like this one would be substantially easier if we had an input doc containing the countdown (<doc><value>99</value><value>98</value><value>97</value>...</doc>) but at that point we're cheating (or we at least have to count the input doc in our byte count).

Run

Run using xsltproc:

```<code>xsltproc 99.xsl 99.xsl
</code>```

Yes, 99.xsl is passed twice: Once as the XSLT document and then as the XML document to be transformed. An input document must be present because an XSLT processor generally requires one to begin running. (XSLT is designed to define a transformation from an input document to an output document; running a transform solely with command-line parameters as I've done here is atypical.) For this program, any well-formed XML document will suffice as input, and, XSLT being an application of XML, any well-formed XSLT transform is by definition a well-formed XML document.

Title: "99 Bottles of Beer"

Body:
XSLT 1.0 (no EXSLT), 845 bytes

<transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0"><output method="text"/><template match="/"><call-template name="b"/></template><template name="b"><param name="n" select="99"/><if test="$n>0"><variable name="o"><if test="$n>1"><value-of select="$n -1"/></if><if test="$n=1">99</if></variable><variable name="p"><if test="$n>1">s</if></variable><variable name="q"><if test="$n!=2">s</if></variable><variable name="z"><if test="$n=1">Go to the store and buy some more</if><if test="$n>1">Take one down and pass it around</if></variable><variable name="w" select="concat($n,' bottle',$p,' of beer')"/><value-of select="concat($w,' on the wall, ',$w,'.&#10;',$z,', ',number($o),' bottle',$q,' of beer on the wall.&#10;')"/><call-template name="b"><with-param name="n" select="$n -1"/></call-template></if></template></transform>

With a bit less golf in it:

<transform xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <output method="text"/>
    <template match="/">
        <call-template name="b"/>
    </template>
    <template name="b">
        <param name="n" select="99"/>
        <if test="$n>0">
            <variable name="o">
                <if test="$n>1">
                    <value-of select="$n -1"/>
                </if>
                <if test="$n=1">99</if>
            </variable>
            <variable name="p">
                <if test="$n>1">s</if>
            </variable>
            <variable name="q">
                <if test="$n!=2">s</if>
            </variable>
            <variable name="z">
                <if test="$n=1">Go to the store and buy some more</if>
                <if test="$n>1">Take one down and pass it around</if>
            </variable>
            <variable name="w" select="concat($n,' bottle',$p,' of beer')"/>
            <value-of select="concat($w,' on the wall, ',$w,'.&#10;',$z,', ',number($o),' bottle',$q,' of beer on the wall.&#10;')"/>
            <call-template name="b">
                <with-param name="n" select="$n -1"/>
            </call-template>
        </if>
    </template>
</transform>

Notes

Text compression

The use of variables as abbreviations isn't as extensive as in other languages; for example, note the repetition of ' bottle' as a constant. In XSLT, the binding of an XPath expression or some arbitrary text to a variable name requires at least 29 characters of overhead, excluding the name and content itself:

<variable name="name" select="expr"/>
<variable name="name">text</variable>

Say, for example, that one would like to replace all instances of the XPath string literal ' bottle' (8 chars) with $b (2 chars). Each substitution saves 6 characters. However, given the definition <variable name="b"> bottle</variable> (38 chars), there is no net profit unless there are 7 or more such sequences to replace.

The use of the <variable/> element is limited to evaluating conditions. The version of XPath used with XSLT 1.0 does not have its own if/else constructs, but XSLT itself does, and <variable/> is necessary to retrieve the results in a useful form.

$n -1

The expression $n -1 appears twice. The space after the $n is required since - is a valid name character in XPath.

Inequalities

Wherever practical, any instance where != originally appeared was changed to use > instead. If the program counted down to 0 instead of resetting to 99 after 1, the plural check for $n would be incorrect at 0.

Tail recursion

The template named b recurses, counting the variable n down by one each time. XSLT provides looping constructs, but they are for traversing structures found in the input document. A task like this one would be substantially easier if we had an input doc containing the countdown (<doc><value>99</value><value>98</value><value>97</value>...</doc>) but at that point we're cheating (or we at least have to count the input doc in our byte count).

Run

Run using xsltproc:

xsltproc 99.xsl 99.xsl

Yes, 99.xsl is passed twice: Once as the XSLT document and then as the XML document to be transformed. An input document must be present because an XSLT processor generally requires one to begin running. (XSLT is designed to define a transformation from an input document to an output document; running a transform solely with command-line parameters as I've done here is atypical.) For this program, any well-formed XML document will suffice as input, and, XSLT being an application of XML, any well-formed XSLT transform is by definition a well-formed XML document.


答:
JavaScript (Firefox 48 or earlier), 60 bytes

```<code>f=s=>(m=s.match(/(.).*\1/i))?f(s.replace(m[1],"","gi")):s[1]
</code>```

Returns undefined if there are only zero or one non-repeating characters. Works by case-insensitively deleting all occurrences of characters that appear more than once in the string. Relies on a non-standard Firefox extension that was removed in Firefox 49. <s>119</s> 91 byte ES6 version:

```<code>f=s=>(m=s.match(/(.).*?(\1)(.*\1)?/i))?f((m[3]?s:s.replace(m[2],"")).replace(m[1],"")):s[1]
</code>```

Recursively searches for all characters that appear at least twice in the string. If the character appears exactly twice then both occurrences are deleted otherwise only the first occurrence is deleted (the other occurrences will be deleted later). This allows the occurrences to have a difference case.

Title: What's the second non-repeating character?

Body:
Based on this question from Code Review

Given a non-empty string of printable ASCII characters, output the second non-repeating character. For example, for input DEFD, output F.

Input

A single string, in any suitable format.

Output

The second character that doesn't repeat, when reading left-to-right, again in a suitable format.

The output character is case-insensitive.

If no such character exists (e.g., all characters repeat), output an empty string.

Rules

The algorithm should ignore case. That is, D and d count as the same character.

Either a full program or a function are acceptable.

The input string will be guaranteed non-empty (i.e., at least one character in length).

The input string is ASCII. Any valid character could repeat, not just alphanumeric (this includes spaces).

Standard loopholes are forbidden.

This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Examples

Input is on first line, output is on second line.

```<code>DEFD
F

FEED
D

This is an example input sentence.
x

...,,,..,,!@
@

ABCDefgHijklMNOPqrsTuVWxyz
B

AAAAAABBBBB

Thisxthis

This this.
.
</code>```

Body:
JavaScript (Firefox 48 or earlier), 60 bytes

f=s=>(m=s.match(/(.).*\1/i))?f(s.replace(m[1],"","gi")):s[1]

Returns undefined if there are only zero or one non-repeating characters. Works by case-insensitively deleting all occurrences of characters that appear more than once in the string. Relies on a non-standard Firefox extension that was removed in Firefox 49. <s>119</s> 91 byte ES6 version:

f=s=>(m=s.match(/(.).*?(\1)(.*\1)?/i))?f((m[3]?s:s.replace(m[2],"")).replace(m[1],"")):s[1]

Recursively searches for all characters that appear at least twice in the string. If the character appears exactly twice then both occurrences are deleted otherwise only the first occurrence is deleted (the other occurrences will be deleted later). This allows the occurrences to have a difference case.


问:
Sum of integers in string, separated by non-numericals such as 'a' and 'Y'
Create a program which sums all integers found in a string which is set as a variable in the program (thus, the program doesn't have to handle any input). The integer numbers are separated by non-numericals (anything but 0, 1, 2, 3, ..., 9).

Examples:

e7rde f  ,fe 43 jfj 54f4sD = 7+43+54+4=108

5 = 5

64 545,5445-32JIFk0ddk = 64+545+5445+32+0=6086

0ab0 = 0+0 = 0

Extra notes:

Unicode support is not necessary, but allowed

-n (where n is an integer) is not counted as a negative n, but as a hyphen followed by n.

The answer may be printed on the screen (but not required).

Shortest answer (in characters) win.

答:
Perl - 24 chars

```<code>warn eval join'+',/\d+/g
</code>```

Input is in $_

Body:
Perl - 24 chars

warn eval join'+',/\d+/g

Input is in $_


Title: Print a Lego piece

Body:
This challenge is a simple ascii-art one. Given two inputs, describing the height and width of a Lego piece, you have print an ASCII art representation of it.

Here is how the Lego pieces are supposed to look:

```<code>(4, 2)

___________
| o o o o |
| o o o o |
-----------

(8, 2)

___________________
| o o o o o o o o |
| o o o o o o o o |
-------------------

(4, 4)

___________
| o o o o |
| o o o o |
| o o o o |
| o o o o |
-----------

(3, 2)

_________
| o o o |
| o o o |
---------

(1, 1)

o
</code>```

If you can't tell from the test-cases, the top and bottom are width*2+3 underscores and dashes, and each row has pipes for the sides, o's for the little things, and everything is separated by spaces.

The only exception for this is (1, 1), which is just a single o.

You will never get 0 for any of the dimensions.

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Groovy, 107, 98, 70, 64

{x,y->t=x*2+3;x<2&&y<2?"o":'_'*t+"\n"+"|${' o'*x} |\n"*y+'-'*t}

Testing:

(2,2)
(1,1)
(8,2)
(1,4)
_______
| o o |
| o o |
-------
o
___________________
| o o o o o o o o |
| o o o o o o o o |
-------------------
_____
| o |
| o |
| o |
| o |
-----


答:
Forth, 33 bytes

Pretty simple looping program.

: f DUP ROT DO DUP I * LOOP ; f .
```

Try it online

Title: Product over a range

Body:
Your task is simple: given two integers \$a\$ and \$b\$, output \$\Pi[a,b]\$; that is, the product of the range between \$a\$ and \$b\$. You may take \$a\$ and \$b\$ in any reasonable format, whether that be arguments to a function, a list input, STDIN, et cetera. You may output in any reasonable format, such as a return value (for functions) or STDOUT. \$a\$ will always be less than \$b\$.

Note that the end may be exclusive or inclusive of \$b\$. I'm not picky. ^_^

Test cases

```<code>[a,b) => result
[2,5) => 24
[5,10) => 15120
[-4,3) => 0
[0,3) => 0
[-4,0) => 24

[a,b] => result
[2,5] => 120
[5,10] => 151200
[-4,3] => 0
[0,3] => 0
[-4,-1] => 24
</code>```

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

Leaderboard

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

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

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

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

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

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

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

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

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

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Forth, 33 bytes

Pretty simple looping program.

: f DUP ROT DO DUP I * LOOP ; f .

Try it online


问:
I hate Mondays!
You should a program in language X, which will only output its source code (i.e function as a quine) when it is not a monday. On monday it should output some string with a levehnstein distance of 4 from the source code. i.e if the code is aaaa on sunday it should output aaaa and on monday it could output ....aaaa or bbbb or cccc or ..aaaa.. etc

Read about Levehnstein difference here https://en.wikipedia.org/wiki/Levenshtein_distance

Rules

Your solution must be testable

No cheating quines, and any other standard loopholes allowed

Should your language "X" lack access to the date it may assume its a random date at the cost of 35 bytes

This is code golf and I will accept the shortest solution (in bytes) as winner

答:
Javascript - <s>47</s> <s>45</s> <s>43</s> <s>42</s> <s>34</s> <s>32</s> 29 bytes

8 bytes saved thanks to @Downgoat.

5 bytes saved thanks to @Dendrobium.

```<code>f=_=>(Date()[0]!="M"&&"f=")+f
</code>```

Title: I hate Mondays!

Body:
Javascript - <s>47</s> <s>45</s> <s>43</s> <s>42</s> <s>34</s> <s>32</s> 29 bytes

8 bytes saved thanks to @Downgoat.

5 bytes saved thanks to @Dendrobium.

f=_=>(Date()[0]!="M"&&"f=")+f


问:
matrix determinant

Calculate the determinant of an n x n matrix.

Rules

read matrix from standard input

write to standard output

do not use ready solutions from library or language

input: columns separated by any space char

input: lines separated by cr and/or lf

Winner

The shortest code :)

答:
Python, 369

This is ridiculously long, but I thought I'd provide a solution that implements the Leibniz formula.

```<code>def f(l):
    if len(l)==1:return [l]
    a=[]
    for s in l:
        for p in f(list(set(l)-set([s]))):a+=[[s]+p]
    return a
def s(a):
    n=1
    for i in range(len(a)):n*=(-1)**(a[i]>i);a[a.index(i)]=a[i];a[i]=i
    return n
m=[map(int,w.split(','))for w in raw_input().split(' ')]
r=range(len(m))
print sum([reduce(lambda x,y:x*y,[m[p[i]][i] for i in r],1)*s(p) for p in f(r)])
</code>```

Values are read from stdin in a format like 1,2,-3 7,0,4 -1,-3,0 with a single space between columns. I wouldn't have posted this, but it was fun to write and contains a couple interesting sub-problems. The function f generates all permutations of n elements, and the function s determines the parity of those permutations.

Title: matrix determinant

Body:
Python, 369

This is ridiculously long, but I thought I'd provide a solution that implements the Leibniz formula.

def f(l):
    if len(l)==1:return [l]
    a=[]
    for s in l:
        for p in f(list(set(l)-set([s]))):a+=[[s]+p]
    return a
def s(a):
    n=1
    for i in range(len(a)):n*=(-1)**(a[i]>i);a[a.index(i)]=a[i];a[i]=i
    return n
m=[map(int,w.split(','))for w in raw_input().split(' ')]
r=range(len(m))
print sum([reduce(lambda x,y:x*y,[m[p[i]][i] for i in r],1)*s(p) for p in f(r)])

Values are read from stdin in a format like 1,2,-3 7,0,4 -1,-3,0 with a single space between columns. I wouldn't have posted this, but it was fun to write and contains a couple interesting sub-problems. The function f generates all permutations of n elements, and the function s determines the parity of those permutations.


答:
Mathematica, 75 bytes

```<code>StringJoin[If[DayName[] == Monday, "0001", ""], ToString[#0, InputForm]] &
</code>```

Anonymous function, takes no inputs and returns the output. Replace Monday with Friday (or whatever the current day is) to test.

Title: I hate Mondays!

Body:
You should a program in language X, which will only output its source code (i.e function as a quine) when it is not a monday. On monday it should output some string with a levehnstein distance of 4 from the source code. i.e if the code is aaaa on sunday it should output aaaa and on monday it could output ....aaaa or bbbb or cccc or ..aaaa.. etc

Read about Levehnstein difference here https://en.wikipedia.org/wiki/Levenshtein_distance

Rules

Your solution must be testable

No cheating quines, and any other standard loopholes allowed

Should your language "X" lack access to the date it may assume its a random date at the cost of 35 bytes

This is code golf and I will accept the shortest solution (in bytes) as winner

Body:
Mathematica, 75 bytes

StringJoin[If[DayName[] == Monday, "0001", ""], ToString[#0, InputForm]] &

Anonymous function, takes no inputs and returns the output. Replace Monday with Friday (or whatever the current day is) to test.


答:
Jolf, <s>19</s> <s>13</s> 9 bytes

```<code>?wfb+q~2q
</code>```

Try it online.

Saved quite a few bytes thanks to Conor.

```<code>?wfb+q~2q

?wfb+q~2q
?          if
 wfb       the current weekday - 1 (which is 0 on Monday) is truthy
    +q~2   print the program's source code with 1000 appended to it
           else
        q  print the program's source code
</code>```

Title: I hate Mondays!

Body:
Jolf, <s>19</s> <s>13</s> 9 bytes

?wfb+q~2q

Try it online.

Saved quite a few bytes thanks to Conor.

?wfb+q~2q

?wfb+q~2q
?          if
 wfb       the current weekday - 1 (which is 0 on Monday) is truthy
    +q~2   print the program's source code with 1000 appended to it
           else
        q  print the program's source code


答:
CJam, <s>18</s> 17 bytes

```<code>{"_~"et7=({\}|}_~
</code>```

Test it here.

On Mondays, it prints:

```<code>_~{"_~"et7=({\}|}
</code>```

Dennis found a 16-byte solution which will break in the year 10,000 though:

```<code>{"_~"et_7=1=<}_~
</code>```

On Mondays, this prints

```<code>{"_~"et_7=1=<}_~2016
</code>```

... or whatever the current year is.

Title: I hate Mondays!

Body:
CJam, <s>18</s> 17 bytes

{"_~"et7=({\}|}_~

Test it here.

On Mondays, it prints:

_~{"_~"et7=({\}|}

Dennis found a 16-byte solution which will break in the year 10,000 though:

{"_~"et_7=1=<}_~

On Mondays, this prints

{"_~"et_7=1=<}_~2016

... or whatever the current year is.


答:
Vitsy + bash, <s>29</s> 26 bytes

```<code>'&"etad","M"-)[Y4\a]?rd3*Z

'                            Take a string of everything until hitting another '.
                             This will wrap around as it finds none.
 &                           Create a new stack and push the current stack over.
  "etad"                     Push the string "date" to the stack.
        ,                    Execute the current stack through shell.
         "M"-                Subtract the character "M" from the first item of the
                             current stack.
             )[    ]         If it is equal to zero, do the stuff in brackets.
               Y             Remove the current stack.
                4\a          Push the return character to the stack four times.
                    ?        Rotate over a stack (if there is none, stay put).
                     r       Reverse the stack.
                      d3*    Push the character ' to the stack.
                         Z   Print everything in the current stack.
</code>```

This cannot be tried online as it accesses shell, however, feel free to test this with the downloadable interpreter found here.

Note that this is a variant of the standard quine, 'rd3*Z.

Title: I hate Mondays!

Body:
Vitsy + bash, <s>29</s> 26 bytes

'&"etad","M"-)[Y4\a]?rd3*Z

'                            Take a string of everything until hitting another '.
                             This will wrap around as it finds none.
 &                           Create a new stack and push the current stack over.
  "etad"                     Push the string "date" to the stack.
        ,                    Execute the current stack through shell.
         "M"-                Subtract the character "M" from the first item of the
                             current stack.
             )[    ]         If it is equal to zero, do the stuff in brackets.
               Y             Remove the current stack.
                4\a          Push the return character to the stack four times.
                    ?        Rotate over a stack (if there is none, stay put).
                     r       Reverse the stack.
                      d3*    Push the character ' to the stack.
                         Z   Print everything in the current stack.

This cannot be tried online as it accesses shell, however, feel free to test this with the downloadable interpreter found here.

Note that this is a variant of the standard quine, 'rd3*Z.


Title: Can Pac-Man Eat This String?

Body:
In the arcade version of the game, Pac-Man eats pac-dots. However, in this challenge, he's hungry for alphanumeric characters and punctuation in a string.

Your task is to create a function that feeds Pac-Man a string, evaluates if he can eat it or not, and returns the string with Pac-Man's location in it.

Pac-Man (<) eats characters from left to right, leaving an underscore or space for each character as he goes, and his goal is to get from the first position-1 to the last position+1:

```<code>1. <Pac
2. _<ac
3. __<c
4. ___<
</code>```

However, Pac-Man's natural enemy, the ghost, will stop him if he encounters one of the letters in the word "GHOST" (not case sensitive). Your function should return the string with Pac-Man's location as he encounters the ghost character:

```<code>1. <No!
2. _<o!
</code>```

The only thing that can defeat a ghost is a power pellet. If Pac-Man reaches a letter in the word "PELLET" (also not case sensitive) before coming to a ghost, he will eat the ghost and keep moving, and that pellet will be used up. Power pellets can stack (ie, in ppgg both ghosts would be eaten). The T character exists as both as a ghost and a pellet, so it can be ignored (treated as any other letter, like a).

```<code>1. <Pop
2. _<op
3. __<p
4. ___<
</code>```

To further clarify, in the string "Pac-Man loses here", the following operations occur:

```<code>P <P, +1 Pellet (1 pellet)
a <a
c <c
- <-
M <M
a <a
n <n
  <[space]
l <l, +1 Pellet (2 pellets)
o <o, -1 Pellet (1 pellet)
s <s, -1 Pellet (0 pellets)
e <e, +1 Pellet (1 pellet)
s <s, -1 Pellet (0 pellets)
  <[space]
h <h, ghost wins, returns
e
r
e
</code>```

Examples

```<code>Input: Pacman wins!
Output: ____________<

Input: Pacman loses wah-wah :(
Output: _______________<h-wah :(

Input: PELLET PELLET GHOST
Output: ___________________<

Input: Hello World!
Output: <Hello World!

Input: <_!@12<_<_<
Output: ___________<
</code>```

This is code-golf--lowest score in bytes wins.

Body:
Powershell, 185

{$l=1;$o="";for($i=0;($i -lt $_.Length) -or (($o+="<") -and 0); $i++){if ($_[$i] -match '[pel]'){$l++}if($_[$i] -match '[ghos]'){$l--}if(!$l){$o+="<"+$_.substring($i);break}$o+="_"}$o}

Ungolfed:

("Pacman wins!",
"Pacman loses wah-wah :(",
"PELLET PELLET GHOST",
"Hello World!"
) |
% {
    $l=1;$o="";
    for($i = 0; ($i -lt $_.Length) -or (($o+="<") -and 0); $i++) {
        if ($_[$i] -match '[pel]') { $l++ }
        if ($_[$i] -match '[ghos]') { $l--}
        if (!$l) { $o+="<"+$_.substring($i); break }
        $o += "_"
    }
    $o
}


答:
Scala, 90 bytes

```<code>(w:Int,h:Int)=>{val A=2*w+3;if(w*h==1)"o"else s"${"_"*A}\n${s"| ${"o "*w}|\n"*h}${"-"*A}"}
</code>```

paste the above function into your Scala REPL, and then invoke the function with the width and height arguments.

Title: Print a Lego piece

Body:
Scala, 90 bytes

(w:Int,h:Int)=>{val A=2*w+3;if(w*h==1)"o"else s"${"_"*A}\n${s"| ${"o "*w}|\n"*h}${"-"*A}"}

paste the above function into your Scala REPL, and then invoke the function with the width and height arguments.


答:
J, 25 bytes

```<code>(1{2{.]-.]#~1-~:)@tolower
</code>```

Usage

```<code>   f =: (1{2{.]-.]#~1-~:)@tolower
   f 'DEFD'
f
   f 'FEED'
d
   f 'This is an example input sentence.'
x
   f '...,,,..,,!@'
@
   f 'ABCDefgHijklMNOPqrsTuVWxyz'
b
   f 'AAAAAABBBBB'

   f 'Thisxthis'

   f 'This this.'
.
</code>```

Explanation

```<code>(1{2{.]-.]#~1-~:)@tolower  Input: s
                  tolower  Converts the string s to lowercase
              ~:           Mark the indices where the first time a char appears
            1-             Complement it
         ]                 Identity function to get s
          #~               Copy only the chars appearing more than once
      ]                    Identity function to get s
       -.                  Remove all the chars from s appearing more than once
   2{.                     Take the first 2 chars from the result (pad with empty string)
 1{                        Take the second char at index 1 and return it
</code>```

Body:
Based on this question from Code Review

Given a non-empty string of printable ASCII characters, output the second non-repeating character. For example, for input DEFD, output F.

Input

A single string, in any suitable format.

Output

The second character that doesn't repeat, when reading left-to-right, again in a suitable format.

The output character is case-insensitive.

If no such character exists (e.g., all characters repeat), output an empty string.

Rules

The algorithm should ignore case. That is, D and d count as the same character.

Either a full program or a function are acceptable.

The input string will be guaranteed non-empty (i.e., at least one character in length).

The input string is ASCII. Any valid character could repeat, not just alphanumeric (this includes spaces).

Standard loopholes are forbidden.

This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Examples

Input is on first line, output is on second line.

```<code>DEFD
F

FEED
D

This is an example input sentence.
x

...,,,..,,!@
@

ABCDefgHijklMNOPqrsTuVWxyz
B

AAAAAABBBBB

Thisxthis

This this.
.
</code>```

Body:
J, 25 bytes

(1{2{.]-.]#~1-~:)@tolower

Usage

   f =: (1{2{.]-.]#~1-~:)@tolower
   f 'DEFD'
f
   f 'FEED'
d
   f 'This is an example input sentence.'
x
   f '...,,,..,,!@'
@
   f 'ABCDefgHijklMNOPqrsTuVWxyz'
b
   f 'AAAAAABBBBB'

   f 'Thisxthis'

   f 'This this.'
.

Explanation

(1{2{.]-.]#~1-~:)@tolower  Input: s
                  tolower  Converts the string s to lowercase
              ~:           Mark the indices where the first time a char appears
            1-             Complement it
         ]                 Identity function to get s
          #~               Copy only the chars appearing more than once
      ]                    Identity function to get s
       -.                  Remove all the chars from s appearing more than once
   2{.                     Take the first 2 chars from the result (pad with empty string)
 1{                        Take the second char at index 1 and return it


答:
Actually, 19 bytes

```<code>;╗`ù╜ùc1=`░ε;(qq1@E
</code>```

Try it online!

Explanation:

```<code>;╗`ù╜ùc1=`░ε;(qq1@E
;╗                   push a copy of input to reg0
  `ù╜ùc1=`░          [v for v in s if
   ù╜ùc1=              s.lower().count(v.lower()) == 1]
           ε;(qq     append two empty strings to the list
                1@E  element at index 1 (second element)
</code>```

Body:
Actually, 19 bytes

;╗`ù╜ùc1=`░ε;(qq1@E

Try it online!

Explanation:

;╗`ù╜ùc1=`░ε;(qq1@E
;╗                   push a copy of input to reg0
  `ù╜ùc1=`░          [v for v in s if
   ù╜ùc1=              s.lower().count(v.lower()) == 1]
           ε;(qq     append two empty strings to the list
                1@E  element at index 1 (second element)


答:
Actually, 14 bytes

```<code>9u▀8╙r♂┌-@s♂≈Σ
</code>```

Try it online!

This program supports the CP437 code page for input.

Explanation:

```<code>9u▀8╙r♂┌-@s♂≈Σ
9u▀             base 10 digits (0-9)
   8╙r♂┌        all characters in CP437 (map(ord_cp437, range(2**8)))
        -       set difference
         @s     split input on any value in the resulting list
           ♂≈Σ  convert to ints and sum
</code>```

Title: Sum of integers in string, separated by non-numericals such as 'a' and 'Y'

Body:
Create a program which sums all integers found in a string which is set as a variable in the program (thus, the program doesn't have to handle any input). The integer numbers are separated by non-numericals (anything but 0, 1, 2, 3, ..., 9).

Examples:

e7rde f  ,fe 43 jfj 54f4sD = 7+43+54+4=108

5 = 5

64 545,5445-32JIFk0ddk = 64+545+5445+32+0=6086

0ab0 = 0+0 = 0

Extra notes:

Unicode support is not necessary, but allowed

-n (where n is an integer) is not counted as a negative n, but as a hyphen followed by n.

The answer may be printed on the screen (but not required).

Shortest answer (in characters) win.

Body:
Actually, 14 bytes

9u▀8╙r♂┌-@s♂≈Σ

Try it online!

This program supports the CP437 code page for input.

Explanation:

9u▀8╙r♂┌-@s♂≈Σ
9u▀             base 10 digits (0-9)
   8╙r♂┌        all characters in CP437 (map(ord_cp437, range(2**8)))
        -       set difference
         @s     split input on any value in the resulting list
           ♂≈Σ  convert to ints and sum


问:
Starbucks to English
In the classic days of Starbucks before these newfangled sticker-printers and wireless drivethrough headset palmtop scanner dealies, in the heady days of 2000-ish, Starbucks had a concise system for describing beverages with a strict syntax and accompanying encoded form.

Vertically on the cup there are a series of labelled boxes which may contain certain values.:

```<code>Decaf
[   ]     -blank-  X  1/2  1/3  2/3
Shots
[   ]     -blank-  0 1 2 3 ... 20    followed by    S T G V
Syrup
[   ]     -blank-  V M C H
Milk
[   ]     -blank-  Wh % N B
Custom
[    ]    -blank- ((-|x)?(F|WC|M|CR) )+
Drink
[   ]     E EM ECP A L C CM
</code>```

But we will use a horizontal form for easier manipulation. These are the names of the 6 fields of the input which may be any convenient form. Examples here are simple CSV. The Custom field and Syrup fields each may be a concatenation of several values. You may use any convenient subdelimiter. Examples here use space. The Shots field is also a concatenation of a (possible) number and a designation of the cup size (which is implicit in the physical cup but naturally fits in this place in the encoding).

The Decaf field values are translated into words like this

```<code>-blank-   -nothing-
X         "decaf"
1/2       "half-caf"
1/3       "one-third-caf"
2/3       "two-thirds-caf"
</code>```

Logically, the fractional values are only permissible when the number of shots is divisible by the denominator; but for this challenge it is not necessary to detect or diagnose this error.

The Shots field should be broken into its numerical component (if present) and the size identifier. The number should be displayed in latin tuple form: single, double, triple, quadruple, quintuple, beyond 5 just print the number and the suffix "-tuple" ie. 7-tuple, 16-tuple. The size designations are:

```<code>S  short
T  tall
G  grande
V  venti
</code>```

Eg.

```<code>2T  double tall
3G  triple grande
</code>```

The Syrup field may contain one or more of several optional-number/lettercode tokens. The maximum number of a syrup is 20. Even that is too much. LOL.

```<code>V  vanilla
C  caramel
M  mocha
H  hazelnut
</code>```

Eg.

```<code>2V 2C     two vanilla two caramel
H         hazelnut
M H 1V    mocha hazelnut one vanilla
</code>```

The Milk field may contain one of the following.

```<code>Wh  whole-milk
%   two-percent
N   skim
B   breve
</code>```

The Custom field may contain one or more of several modifiers with optional x or - sign.

```<code>x  extra     F   foam
-  no        WC  whip
             M   mocha drizzle
             CR  caramel drizzle
</code>```

The Drink field contains one drink id.

```<code>E    espresso
EM   espresso macchiato
ECP  espresso con panna
A    americano
L    latte
C    cappuccino
CM   caramel macchiato
</code>```

Any field may be blank except for the size designation and the drink id.

Examples.

```<code>,3G,V,Wh,,L    =>   triple grande vanilla whole-milk latte
X,2T,,N,,L     =>   decaf double tall skim latte
1/2,V,,,,CM    =>   half-caf venti caramel macchiato
2/3,3V,3V,B,WC,L  => two-thirds-caf triple venti three vanilla breve whip latte
,G,,,xCR,CM    =>   grande extra caramel drizzle caramel macchiato
X,4T,2M 2C,B,xWC -F xM,C  =>
  decaf quadruple tall two mocha two caramel breve extra whip no foam extra mocha drizzle cappuccino
</code>```

There is no need to diagnose erroneous or illogical concoctions such as a "no foam ... cappuccino*.

Additional Complication

For only the drinks with the word espresso, the number single should be replaced by solo and double should be replaced by doppio. And the size may be unspecified and omitted. Also, just for the bare espresso drink itself, if the only other specification is one of these two specially-replaced numbers-of-shots, then the word espresso itself should be omitted.

```<code>-blank-   -nothing-
X         "decaf"
1/2       "half-caf"
1/3       "one-third-caf"
2/3       "two-thirds-caf"
</code>```0

Additional observations on 'reading a cup'

This part is not a requirement for this challenge but may be a useful refinement in applying this sort of verbalized system in other domains.

I mentioned syntax at the very beginning, and by applying the schema to incoming streams of words, orders could be transmitted verbally by several order takers to the barista making beverages. The rough framework SIZE .... DRINK provides demarcation between several orders spoken at once. There is thus a tendency to make all the interior attributes as adjectival phrases so the order also has a valid English noun-phrase structure. So whip is often spoken with whip or whipped and foam is often spoken foamy or with foam.

Thus, for some old-time baristas, they're not "correcting you" when they repeat the order in the proper format (well,... sometimes). They're simply organizing the information for the purpose of remembering all the details exactly. By schematizing the information, an entire beverage order becomes a single unit for the purpose of applying the magic number 7 plus or minus 2. So a barista with this skill can hold 5-9 orders in their head provided other distractions do not consume too much head room. :)

答:
Python, <s>824</s> <s>815</s> <s>807</s> 805 bytes

```<code>f=lambda s,a=0:a==0and" ".join(" ".join(f(" "+s.split(",")[i],(["X,deC,1/2,half-C,1/3,oneT-C,2/3,twoTs-C,C,caf,T,-third","".join(" %i"%i+f(",%i-tupL,"%i,["1","x","2","y"])for i in range(6,21))+"1,solo,2,doppio,"*('E'in s)+"1,singL,2,doubL, 3,tripL, 4,quadrupL, 5,quintupL,x,1,y,2,S,short,T,tall,G,grande,V,Vnti","V, vanilla,H, hazelnut,10,ten,11,eleVn,12,twelV,13,thirT,14,4T,15,fifT,16,6T,17,7T,18,8een,19,9T,20,twenty,1,one,2,two,3,three,4,four,5,fiV,6,six,7,seVn,8,eight,9,nine,T,teen","Wh,whole-milk,%,two-percent,N,skim,B,breV","x,extra ,-,no ,F,foam,WC,whip,M,MR,R, drizzL","CM,xM,E,espresso,M, macchiato,CP, con panna,A,americano,L,latte,C,cappuccino,x,C"][i]+",C, caramel,M, mocha,L,le ,V,ve").split(","))for i in range(6-(s in",1,,,,E,2,,,,E"))).split())or a and f(s.replace(a[0],a[1]),a[2:])or s
</code>```

Slightly more readable:

```<code>def f(s,a=0):
 if a==0:
  a=["X,deC,1/2,half-C,1/3,oneT-C,2/3,twoTs-C,C,caf,T,-third"]
  a+=["".join(" %i"%i+f(",%i-tupL,"%i,["1","x","2","y"])for i in range(6,21))+"1,solo,2,doppio,"*('E'in s)+"1,singL,2,doubL, 3,tripL, 4,quadrupL, 5,quintupL,x,1,y,2,S,short,T,tall,G,grande,V,Vnti"]
  a+=["V, vanilla,H, hazelnut,10,ten,11,eleVn,12,twelV,13,thirT,14,4T,15,fifT,16,6T,17,7T,18,8een,19,9T,20,twenty,1,one,2,two,3,three,4,four,5,fiV,6,six,7,seVn,8,eight,9,nine,T,teen"]
  a+=["Wh,whole-milk,%,two-percent,N,skim,B,breV"]
  a+=["x,extra ,-,no ,F,foam,WC,whip,M,MR,R, drizzL"]
  a+=["CM,xM,E,espresso,M, macchiato,CP, con panna,A,americano,L,latte,C,cappuccino,x,C"]
  return" ".join(" ".join(f(" "+s.split(",")[i],(a[i]+",C, caramel,M, mocha,L,le ,V,ve").split(","))for i in range(6-(s in",1,,,,E,2,,,,E"))).split())
 elif a:
  return f(s.replace(a[0],a[1]),a[2:])
 else:
  return s
</code>```

Demo at https://repl.it/C8Hz/3

Title: Starbucks to English

Body:
Python, <s>824</s> <s>815</s> <s>807</s> 805 bytes

f=lambda s,a=0:a==0and" ".join(" ".join(f(" "+s.split(",")[i],(["X,deC,1/2,half-C,1/3,oneT-C,2/3,twoTs-C,C,caf,T,-third","".join(" %i"%i+f(",%i-tupL,"%i,["1","x","2","y"])for i in range(6,21))+"1,solo,2,doppio,"*('E'in s)+"1,singL,2,doubL, 3,tripL, 4,quadrupL, 5,quintupL,x,1,y,2,S,short,T,tall,G,grande,V,Vnti","V, vanilla,H, hazelnut,10,ten,11,eleVn,12,twelV,13,thirT,14,4T,15,fifT,16,6T,17,7T,18,8een,19,9T,20,twenty,1,one,2,two,3,three,4,four,5,fiV,6,six,7,seVn,8,eight,9,nine,T,teen","Wh,whole-milk,%,two-percent,N,skim,B,breV","x,extra ,-,no ,F,foam,WC,whip,M,MR,R, drizzL","CM,xM,E,espresso,M, macchiato,CP, con panna,A,americano,L,latte,C,cappuccino,x,C"][i]+",C, caramel,M, mocha,L,le ,V,ve").split(","))for i in range(6-(s in",1,,,,E,2,,,,E"))).split())or a and f(s.replace(a[0],a[1]),a[2:])or s

Slightly more readable:

def f(s,a=0):
 if a==0:
  a=["X,deC,1/2,half-C,1/3,oneT-C,2/3,twoTs-C,C,caf,T,-third"]
  a+=["".join(" %i"%i+f(",%i-tupL,"%i,["1","x","2","y"])for i in range(6,21))+"1,solo,2,doppio,"*('E'in s)+"1,singL,2,doubL, 3,tripL, 4,quadrupL, 5,quintupL,x,1,y,2,S,short,T,tall,G,grande,V,Vnti"]
  a+=["V, vanilla,H, hazelnut,10,ten,11,eleVn,12,twelV,13,thirT,14,4T,15,fifT,16,6T,17,7T,18,8een,19,9T,20,twenty,1,one,2,two,3,three,4,four,5,fiV,6,six,7,seVn,8,eight,9,nine,T,teen"]
  a+=["Wh,whole-milk,%,two-percent,N,skim,B,breV"]
  a+=["x,extra ,-,no ,F,foam,WC,whip,M,MR,R, drizzL"]
  a+=["CM,xM,E,espresso,M, macchiato,CP, con panna,A,americano,L,latte,C,cappuccino,x,C"]
  return" ".join(" ".join(f(" "+s.split(",")[i],(a[i]+",C, caramel,M, mocha,L,le ,V,ve").split(","))for i in range(6-(s in",1,,,,E,2,,,,E"))).split())
 elif a:
  return f(s.replace(a[0],a[1]),a[2:])
 else:
  return s

Demo at https://repl.it/C8Hz/3


答:
GolfScript, 58 chars

```<code>n%{~]}%{[.!{(.,,0\{:^2$=-1^?*3${.^<\^)>+}%d*+}/}or])\;}:d~
</code>```

A straightforward recursive algorithm using Laplace expansion.

Example input (random 5 × 5 matrix):

```<code>-562   40   43 -586  347
-229  177  305 -367   50
-434  343  241 -365  -86
-3   -384 -351   61 -214
-400   96 -339   25 -116
</code>```

Output: 282416596900 (Online demo; Verify with Wolfram Alpha)

The code consists of three parts:

n%{~]}% parses the input,

{[.!{(.,,0\{:^2$=-1^?*3${.^<\^)>+}%d*+}/}or])\;}:d defines a recursive subroutine to calculate the determinant, and

the final ~ applies the subroutine to the input.

I'm sure there's room for improvement in this code, but at least I beat Gareth by three chars.  Also, {:^2$= is a pretty nice GS smiley. :)

Title: matrix determinant

Body:
Calculate the determinant of an n x n matrix.

Rules

read matrix from standard input

write to standard output

do not use ready solutions from library or language

input: columns separated by any space char

input: lines separated by cr and/or lf

Winner

The shortest code :)

Body:
GolfScript, 58 chars

n%{~]}%{[.!{(.,,0\{:^2$=-1^?*3${.^<\^)>+}%d*+}/}or])\;}:d~

A straightforward recursive algorithm using Laplace expansion.

Example input (random 5 × 5 matrix):

-562   40   43 -586  347
-229  177  305 -367   50
-434  343  241 -365  -86
-3   -384 -351   61 -214
-400   96 -339   25 -116

Output: 282416596900 (Online demo; Verify with Wolfram Alpha)

The code consists of three parts:

n%{~]}% parses the input,

{[.!{(.,,0\{:^2$=-1^?*3${.^<\^)>+}%d*+}/}or])\;}:d defines a recursive subroutine to calculate the determinant, and

the final ~ applies the subroutine to the input.

I'm sure there's room for improvement in this code, but at least I beat Gareth by three chars.  Also, {:^2$= is a pretty nice GS smiley. :)


问:
Add two numbers
Input: Two integers. Preferably decimal integers, but other forms of numbers can be used. These can be given to the code in standard input, as arguments to the program or function, or as a list.

Output: Their sum. Use the same format for output integers as input integers. For example, the input 5 16 would lead to the output 21.

Restrictions: No standard loopholes please. This is code-golf, answer in lowest amount of bytes wins.

Notes: This should be fairly trivial, however I'm interested to see how it can be implemented. The answer can be a complete program or a function, but please identify which one it is.

Test cases:

```<code>1 2 -> 3
14 15 -> 29
7 9 -> 16
-1 8 -> 7
8 -9 -> -1
-8 -9 -> -17
</code>```

Or as CSV:

```<code>a,b,c
1,2,3
14,15,29
7,9,16
-1,8,7
8,-9,-1
-8,-9,-17
</code>```

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Jelly, 1 byte

```<code>+
</code>```

Try it online!

Also works in 05AB1E, Actually, APL, BQN, Brachylog, Braingolf, Chocolate, ,,, (Commata), dc, Deorst, Factor, Fig**, Forth, Halfwit*, HBL*, Implicit, J, Julia, K, kdb+, Keg, Ly, MathGolf, MATL, Pyke, Q, Racket, Scheme, Swift, Thunno**, Thunno 2, and Vyxal.

* Language uses a half-byte code page, and therefore + counts as 0.5 bytes.

** In Fig and Thunno, this is \$\log_{256}(96)\approx\$ 0.823 bytes.

Title: Add two numbers

Body:
Jelly, 1 byte

+

Try it online!

Also works in 05AB1E, Actually, APL, BQN, Brachylog, Braingolf, Chocolate, ,,, (Commata), dc, Deorst, Factor, Fig**, Forth, Halfwit*, HBL*, Implicit, J, Julia, K, kdb+, Keg, Ly, MathGolf, MATL, Pyke, Q, Racket, Scheme, Swift, Thunno**, Thunno 2, and Vyxal.

* Language uses a half-byte code page, and therefore + counts as 0.5 bytes.

** In Fig and Thunno, this is \$\log_{256}(96)\approx\$ 0.823 bytes.


答:
Brain-flak, 6 bytes

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

Try it online!

Brain-flak is a really interesting language with two major restrictions on it.

The only valid characters are brackets, i.e. any of these characters:

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

Every single set of brackets must be entirely matched, otherwise the program is invalid.

A set of brackets with nothing between them is called a "nilad". A nilad creates a certain numerical value, and all of these nilads next to each other are added up. A set of brackets with something between them is called a "monad". A monad is a function that takes an numerical argument. So the brackets inside a monad are evaluated, and that is the argument to the monad. Here is a more concrete example.

The () nilad equals 1. So the following brain-flak code:

```<code>()()()
</code>```

Is evaluated to 3. The () monad pushes the value inside of it on the global stack. So the following

```<code>(()()())
</code>```

pushes a 3. The {} nilad pops the value on top of the stack. Since consecutive nilads are always added, a string of {} sums all of the top elements on the stack. So my code is essentially:

```<code>push(pop() + pop())
</code>```

Title: Add two numbers

Body:
Input: Two integers. Preferably decimal integers, but other forms of numbers can be used. These can be given to the code in standard input, as arguments to the program or function, or as a list.

Output: Their sum. Use the same format for output integers as input integers. For example, the input 5 16 would lead to the output 21.

Restrictions: No standard loopholes please. This is code-golf, answer in lowest amount of bytes wins.

Notes: This should be fairly trivial, however I'm interested to see how it can be implemented. The answer can be a complete program or a function, but please identify which one it is.

Test cases:

```<code>1 2 -> 3
14 15 -> 29
7 9 -> 16
-1 8 -> 7
8 -9 -> -1
-8 -9 -> -17
</code>```

Or as CSV:

```<code>a,b,c
1,2,3
14,15,29
7,9,16
-1,8,7
8,-9,-1
-8,-9,-17
</code>```

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Brain-flak, 6 bytes

({}{})

Try it online!

Brain-flak is a really interesting language with two major restrictions on it.

The only valid characters are brackets, i.e. any of these characters:

 (){}[]<>

Every single set of brackets must be entirely matched, otherwise the program is invalid.

A set of brackets with nothing between them is called a "nilad". A nilad creates a certain numerical value, and all of these nilads next to each other are added up. A set of brackets with something between them is called a "monad". A monad is a function that takes an numerical argument. So the brackets inside a monad are evaluated, and that is the argument to the monad. Here is a more concrete example.

The () nilad equals 1. So the following brain-flak code:

()()()

Is evaluated to 3. The () monad pushes the value inside of it on the global stack. So the following

(()()())

pushes a 3. The {} nilad pops the value on top of the stack. Since consecutive nilads are always added, a string of {} sums all of the top elements on the stack. So my code is essentially:

push(pop() + pop())


答:
05AB1E, 1 byte

Code:

```<code>+
</code>```

Try it online!.

Title: Add two numbers

Body:
05AB1E, 1 byte

Code:

+

Try it online!.


答:
Minkolang 0.15, 5 bytes

```<code>nn+N.
</code>```

Try it here.

Explanation

```<code>nn       Take two numbers from input
  +      Add
   N.    Output as number and stop.
</code>```

Title: Add two numbers

Body:
Minkolang 0.15, 5 bytes

nn+N.

Try it here.

Explanation

nn       Take two numbers from input
  +      Add
   N.    Output as number and stop.


答:
Bash, 58 bytes

tr A-Z a-z>t
tr -dc "`fold -1<t|sort|uniq -u`"<t|cut -c2
```

Caution: This creates a temporary file named t. If it already exists, it will be overwritten.

Body:
Bash, 58 bytes

tr A-Z a-z>t
tr -dc "`fold -1<t|sort|uniq -u`"<t|cut -c2

Caution: This creates a temporary file named t. If it already exists, it will be overwritten.


答:
Binary lambda calculus, 4.125 bytes

Input and output as Church numerals.

```<code>00000000 01011111 01100101 11101101 0
</code>```

In lambda calculus, it is λm. λn. λf. λx. m f (n f x).

De Bruijn index: λ λ λ λ 4 2 (3 2 1)

Lambda calculus is a concise way of describing a mapping (function).

For example, this task can be written as λx. λy. x + y

The thing to note is, that this is not a lambda (function) which takes two arguments. This is actually a nested lambda. However, it behaves like a lambda which takes two arguments, so it can be informally described as such. Every lambda formally only takes one argument.

For example, if we apply this lambda to 3 and 4:

(λx. λy. x + y) 3 4 ≡ (λy. 3 + y) 4 ≡ 3 + 4 = 7

So, the first lambda actually returns another lambda.

Church numerals is a way of doing away with the extra signs, leaving with only lambda symbols and variables.

Each number in the Church system is actually a lambda that specifies how many times the function is applied to an item.

Let the function be f and the item be x.

So, the number 1 would correspond to λf. λx. f x, which means apply f to x exactly once.

The number 3, for example, would be λf. λx. f (f (f x)), which means apply f to x exactly three times.

Therefore, to add two Church numerals (say, m and n) together, it is the same as applying f to x, m + n times.

We can observe that this is the same as first applying f to x, n times, and then applying f to the resulting item m times.

For example, 2 would mean f(f(x)) and 3 would mean f(f(f(x))), so 2 + 3 would be f(f(f(f(f(x))))).

To apply f to x, n times, we have n f x.

You can view m and n as functions taking two arguments, informally.

Then, we apply f again to this resulting item, m times: m f (n f x).

Then, we add back the boilerplate to obtain λm. λn. λf. λx. m f (n f x).

Now, we have to convert it to De Bruijn index.

Firstly, we count the "relative distance" between each variable to the lambda declaration. For example, the m would have a distance of 4, because it is declared 4 lambdas "ago". Similarly, the n would have a distance of 3, the f would have a distance of 2, and the x would have a distance of 1.

So, we write it as this intermediate form: λm. λn. λf. λx. 4 2 (3 2 1)

Then, we remove the variable declarations, leaving us with: λ λ λ λ 4 2 (3 2 1)

Now, we convert it to binary lambda calculus.

The rules are:

λ becomes 00.

m n (grouping) becomes 01 m n.

numbers i becomes 1 i times + 0, for example 4 becomes 11110.

λ λ λ λ 4 2 (3 2 1)

≡ λ λ λ λ 11110 110 (1110 110 10)

≡ λ λ λ λ 11110 110 0101 111011010

≡ λ λ λ λ 0101 111101100101111011010

≡ 00 00 00 00 0101 111101100101 111011010

≡ 000000000101111101100101111011010

Title: Add two numbers

Body:
Binary lambda calculus, 4.125 bytes

Input and output as Church numerals.

00000000 01011111 01100101 11101101 0

In lambda calculus, it is λm. λn. λf. λx. m f (n f x).

De Bruijn index: λ λ λ λ 4 2 (3 2 1)

Lambda calculus is a concise way of describing a mapping (function).

For example, this task can be written as λx. λy. x + y

The thing to note is, that this is not a lambda (function) which takes two arguments. This is actually a nested lambda. However, it behaves like a lambda which takes two arguments, so it can be informally described as such. Every lambda formally only takes one argument.

For example, if we apply this lambda to 3 and 4:

(λx. λy. x + y) 3 4 ≡ (λy. 3 + y) 4 ≡ 3 + 4 = 7

So, the first lambda actually returns another lambda.

Church numerals is a way of doing away with the extra signs, leaving with only lambda symbols and variables.

Each number in the Church system is actually a lambda that specifies how many times the function is applied to an item.

Let the function be f and the item be x.

So, the number 1 would correspond to λf. λx. f x, which means apply f to x exactly once.

The number 3, for example, would be λf. λx. f (f (f x)), which means apply f to x exactly three times.

Therefore, to add two Church numerals (say, m and n) together, it is the same as applying f to x, m + n times.

We can observe that this is the same as first applying f to x, n times, and then applying f to the resulting item m times.

For example, 2 would mean f(f(x)) and 3 would mean f(f(f(x))), so 2 + 3 would be f(f(f(f(f(x))))).

To apply f to x, n times, we have n f x.

You can view m and n as functions taking two arguments, informally.

Then, we apply f again to this resulting item, m times: m f (n f x).

Then, we add back the boilerplate to obtain λm. λn. λf. λx. m f (n f x).

Now, we have to convert it to De Bruijn index.

Firstly, we count the "relative distance" between each variable to the lambda declaration. For example, the m would have a distance of 4, because it is declared 4 lambdas "ago". Similarly, the n would have a distance of 3, the f would have a distance of 2, and the x would have a distance of 1.

So, we write it as this intermediate form: λm. λn. λf. λx. 4 2 (3 2 1)

Then, we remove the variable declarations, leaving us with: λ λ λ λ 4 2 (3 2 1)

Now, we convert it to binary lambda calculus.

The rules are:

λ becomes 00.

m n (grouping) becomes 01 m n.

numbers i becomes 1 i times + 0, for example 4 becomes 11110.

λ λ λ λ 4 2 (3 2 1)

≡ λ λ λ λ 11110 110 (1110 110 10)

≡ λ λ λ λ 11110 110 0101 111011010

≡ λ λ λ λ 0101 111101100101111011010

≡ 00 00 00 00 0101 111101100101 111011010

≡ 000000000101111101100101111011010


问:
Remove all occurrences of the first letter of a string from the entire string
Given an input string only containing the characters A-Z, a-z, and spaces, remove all occurrences of the uppercase and lowercase versions of the first character of the string (if the first character is A remove all As and as, if the first character is (space) remove all spaces), and print the output.

Example cases:

Testing Testing One Two Three -> esing esing One wo hree

Programming Puzzles and Code Golf -> rogramming uzzles and Code Golf

How much wood would a woodchuck chuck if a woodchuck could chuck wood -> ow muc wood would a woodcuck cuck if a woodcuck could cuck wood

{space}hello world -> helloworld

welcome to WATER WORLD -> elcome to ATER ORLD

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

Notes:

Input will always be 2 or more valid characters.

Output will never be an empty string.

答:
J, 17 bytes

```<code>#~1-(={.)@tolower
</code>```

Usage

```<code>   f =: #~1-(={.)@tolower
   f 'Testing Testing One Two Three'
esing esing One wo hree
   f 'Programming Puzzles and Code Golf'
rogramming uzzles and Code Golf
   f ' hello world'
helloworld
</code>```

Body:
J, 17 bytes

#~1-(={.)@tolower

Usage

   f =: #~1-(={.)@tolower
   f 'Testing Testing One Two Three'
esing esing One wo hree
   f 'Programming Puzzles and Code Golf'
rogramming uzzles and Code Golf
   f ' hello world'
helloworld


答:
Python, <s>11</s> 3 bytes

sum
```

<s>int.__add__</s>

A simple special operator.

Title: Add two numbers

Body:
Python, <s>11</s> 3 bytes

sum

<s>int.__add__</s>

A simple special operator.


问:
Array Sandwiches
(Adapted from Problem C of the first qualifier of the ACM Programming Contest of 2012/2013)

You have several arrays, named \$A_1, A_2, ... , A_n\$, each sorted in ascending order. Every item in the array will be a 32-bit integer.

A sandwich is a set of indices \$j_1, j_2, ... , j_n\$ such that \$A_1[j_1] ≤ A_2[j_2] ≤ ... ≤ A_n[j_n]\$. \$A_i[0]\$ is the first element of \$A_i\$.

Given some arrays, output every possible sandwich that you can have from those arrays, separated by a newline.

If there is somehow a built-in function which does this in your language, don't use it.

Input can be given in any way, output must be separated with whitespace, but can given in any order.

Test Case:

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

Output:

```<code>0 0 0
0 0 1
0 0 2
0 1 2
0 2 2
0 3 2
1 1 2
1 2 2
1 3 2
2 3 2
</code>```

Test Case:

```<code>[[10, 20, 30], [1, 2, 3]]
</code>```

Output:

Shortest code wins.

Title: Array Sandwiches

Body:
R - 89 chars

i=do.call(expand.grid,lapply(x,seq_along))
i[apply(diff(t(mapply(`[`,x,i)))>=0,2,all),]-1

where

x = list(c(1, 5, 7, 10), c(2, 6, 6, 8, 12), c(4, 5, 9))

or

x = list(c(10, 20, 30), c(1, 2, 3))