问:
Print a 10 by 10 grid of asterisks

Background

This is a standard textbook example to demonstrate for loops.

This is one of the first programs I learnt when I started learning programming ~10 years ago.

Task

You are to print this exact text:

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

Specs

You may have extra trailing newlines.

You may have extra trailing spaces (U+0020) at the end of each line, including the extra trailing newlines.

Scoring

This is code-golf. Shortest answer in bytes wins.

答:
Deadfish ~, 24 bytes

```<code>{{iiii}ii{c}{ddd}ddc{d}}
</code>```

how it works:

{foo} does foo exactly ten times.
first, it starts a ten loop, in this loop, it sets the counter to 42, prints it ten times (as char (asterisk)), decrements it to 10, prints it (newline), subtracts 10, then loops again, doing this 10 times.

Title: Print a 10 by 10 grid of asterisks

Body:
Deadfish ~, 24 bytes

{{iiii}ii{c}{ddd}ddc{d}}

how it works:

{foo} does foo exactly ten times.
first, it starts a ten loop, in this loop, it sets the counter to 42, prints it ten times (as char (asterisk)), decrements it to 10, prints it (newline), subtracts 10, then loops again, doing this 10 times.


答:
Pyke, <s>24</s> 22 bytes

```<code>\*\}:\/\e:\+\h:\-\t:0E
</code>```

Try it here!

Or 12 bytes (noncompetitive)

```<code>~:"ht}e".:0E
</code>```

Try it here!

Add translate node - basically multiple find and replace.

```<code>~:           -   "+-*/"
        .:   -  input.translate(^, V)
  "ht}e"     -   "ht}e"
          0E - eval(^, stack=0)
</code>```

ContentLicense: CC BY-SA 3.0

Title: Simple integer operation calculator

Body:
Implement a simple integer operation scriptable calculator.

Concept

The accumulator starts at 0 and has operations performed on it. At the end of the program output the value of the accumulator.

Operations:

+ adds 1 to the accumulator

- subtracts 1 from the accumulator

* multiplies the accumulator by 2

/ divides the accumulator by 2

Sample script

The input ++**--/ should give the output 3.

Example implementation

```<code>def calc(s)
    i = 0
    s.chars.each do |o|
        case o
            when '+'
                i += 1
            when '-'
                i -= 1
            when '*'
                i *= 2
            when '/'
                i /= 2
        end
    end
    return i
end
</code>```

Rules

This is code-golf, so lowest answer in bytes wins, but is not selected.

Creative implementations are encouraged.

Standard loopholes are prohibited.

You get the program via stdin or arguments, and you can output the answer via return value or stdout.

Have fun.

Division truncates down because it is integer division.

The program -/ returns -1.

Test cases

```<code>*///*-*+-+
-1
/*+/*+++/*///*/+-+//*+-+-/----*-*-+++*+**+/*--///+*-/+//*//-+++--++/-**--/+--/*-/+*//*+-*-*/*+*+/+*-
-17
+++-+--/-*/---++/-+*-//+/++-*--+*+/*/*/++--++-+//++--*/***-*+++--+-*//-*/+*/+-*++**+--*/*//-*--**-/-*+**-/*-**/*+*-*/--+/+/+//-+*/---///+**////-*//+-+-/+--/**///*+//+++/+*++**++//**+**+-*/+/*/*++-/+**+--+*++++/-*-/*+--/++*/-++/-**++++/-/+/--*/-/+---**//*///-//*+-*----+//--/-/+*/-+++-+*-*+*+-/-//*-//+/*-+//+/+/*-/-/+//+**/-****/-**-//+/+-+/*-+*++*/-/++*/-//*--+*--/-+-+/+/**/-***+/-/++-++*+*-+*+*-+-//+/-++*+/*//*-+/+*/-+/-/*/-/-+*+**/*//*+/+---+*+++*+/+-**/-+-/+*---/-*+/-++*//*/-+-*+--**/-////*/--/*--//-**/*++*+/*+/-+/--**/*-+*+/+-*+*+--*///+-++/+//+*/-+/**--//*/+++/*+*////+-*-//--*+/*/-+**/*//+*+-//+--+*-+/-**-*/+//*+---*+//*/+**/*--/--+/*-*+*++--*+//+*+-++--+-*-*-+--**+/+*-/+*+-/---+-*+-+-/++/+*///*/*-+-*//-+-++/++/*/-++/**--+-////-//+/*//+**/*+-+/+/+///*+*///*-/+/*/-//-*-**//-/-+--+/-*--+-++**++//*--/*++--*-/-///-+/+//--+*//-**-/*-*/+*/-*-*//--++*//-*/++//+/-++-+-*/*-+++**-/-*++++**+-+++-+-***-+//+-/**-+/*+****-*+++*/-*-/***/-/*+/*****++*+/-/-**-+-*-*-++**/*+-/*-+*++-/+/-++*-/*-****-*
18773342
</code>```

Body:
Pyke, <s>24</s> 22 bytes

\*\}:\/\e:\+\h:\-\t:0E

Try it here!

Or 12 bytes (noncompetitive)

~:"ht}e".:0E

Try it here!

Add translate node - basically multiple find and replace.

~:           -   "+-*/"
        .:   -  input.translate(^, V)
  "ht}e"     -   "ht}e"
          0E - eval(^, stack=0)


答:
Batch, 61 bytes

```<code>@set n=
@for %%a in (%*)do @set/an=n%%a2^&-2
@cmd/cset/an/2
</code>```

Translation of @xnor's xcellent Python answer.

Title: Simple integer operation calculator

Body:
Batch, 61 bytes

@set n=
@for %%a in (%*)do @set/an=n%%a2^&-2
@cmd/cset/an/2

Translation of @xnor's xcellent Python answer.


答:
Lex + C, <s>78</s>, <s>74</s>, 73 bytes

The first character is a space.

```<code> c;F(){yylex(c=0);return c;}
%%
\+ c++;
- c--;
\* c*=2;
\/ c=floor(c/2.);
</code>```

Reads from stdin, returns result.

Compile with lex golfed.l && cc lex.yy.c main.c -lm -lfl, test main:

```<code>int main() { printf("%d\n", F()); }
</code>```

Title: Simple integer operation calculator

Body:
Lex + C, <s>78</s>, <s>74</s>, 73 bytes

The first character is a space.

 c;F(){yylex(c=0);return c;}
%%
\+ c++;
- c--;
\* c*=2;
\/ c=floor(c/2.);

Reads from stdin, returns result.

Compile with lex golfed.l && cc lex.yy.c main.c -lm -lfl, test main:

int main() { printf("%d\n", F()); }


答:
GNU sed, <s>65</s> <s>59</s> 57 bytes

Edit: 2 bytes shorter thanks to Toby Speight's comments

```<code>s/[+-]/1&/g
s/*/2&/g
s:/:d0>@2&:g
s/.*/dc -e"0[1-]s@&p"/e
</code>```

Run:

sed -f simple_calculator.sed <<< "*///*-*+-+"
```

<p><strong>Output:</strong></p>

<pre class="lang-sh prettyprint-override"><code>-1
</code>```

The sed script prepares the input for the dc shell call at the end, the latter accepting the input in Reverse Polish notation. On division, if the number is negative (d0>), the [1-] decrement command stored in register @ is called. Conversion example: + - * / --> 1+ 1- 2* d0>@2/.

Title: Simple integer operation calculator

Body:
GNU sed, <s>65</s> <s>59</s> 57 bytes

Edit: 2 bytes shorter thanks to Toby Speight's comments

s/[+-]/1&/g
s/*/2&/g
s:/:d0>@2&:g
s/.*/dc -e"0[1-]s@&p"/e

Run:

sed -f simple_calculator.sed <<< "*///*-*+-+"

Output:

-1

The sed script prepares the input for the dc shell call at the end, the latter accepting the input in Reverse Polish notation. On division, if the number is negative (d0>), the [1-] decrement command stored in register @ is called. Conversion example: + - * / --> 1+ 1- 2* d0>@2/.


问:
Where are Champernowne's zeroes?
Consider the infinite string of all nonnegative decimal integers concatenated together in order (akin to Champernowne's constant):

```<code>0123456789101112131415161718192021222324252627282930...979899100101102103...
</code>```

Write a program or function that takes in a nonnegative integer that indexes (0-based) into this infinite string. Output a truthy value if the digit indexed is 0, otherwise output a falsy value if the digit is 1-9.

The shortest code in bytes wins.

The first 25 truthy-producing inputs are:

```<code>0
11
31
51
71
91
111
131
151
171
191
192
194
197
200
203
206
209
212
215
218
222
252
282
312
</code>```

Kudos if your program is memory effecient, but this is not a requirement.

答:
Pyke, 7 bytes

```<code>m`sQ@b!
</code>```

Try it here!

Title: Where are Champernowne's zeroes?

Body:
Pyke, 7 bytes

m`sQ@b!

Try it here!


答:
Javascript (ES6), 57 bytes (array) / 60 bytes (integer)

Returning an array of all intermediate results:

```<code>o=>[...o].map(c=>x=[x>>1,x+1,x*2,x-1][eval(2+c+3)&3],x=0)
</code>```

For instance, the output for "++**--/" will be [1, 2, 4, 8, 7, 6, 3].

Returning only the final result:

```<code>o=>[...o].reduce((x,c)=>[x>>1,x+1,x*2,x-1][eval(2+c+3)&3],0)
</code>```

How it works

Both solutions are based on the same idea: using the perfect hash function eval(2+c+3)&3 to map the different operator characters c in [0, 3].

```<code> operator | eval(2+c+3)  | eval(2+c+3)&3
----------+--------------+---------------
    +     |  2+3 = 5     |    5 & 3 = 1
    -     |  2-3 = -1    |   -1 & 3 = 3
    *     |  2*3 = 6     |    6 & 3 = 2
    /     |  2/3 ~= 0.67 | 0.67 & 3 = 0
</code>```

Title: Simple integer operation calculator

Body:
Javascript (ES6), 57 bytes (array) / 60 bytes (integer)

Returning an array of all intermediate results:

o=>[...o].map(c=>x=[x>>1,x+1,x*2,x-1][eval(2+c+3)&3],x=0)

For instance, the output for "++**--/" will be [1, 2, 4, 8, 7, 6, 3].

Returning only the final result:

o=>[...o].reduce((x,c)=>[x>>1,x+1,x*2,x-1][eval(2+c+3)&3],0)

How it works

Both solutions are based on the same idea: using the perfect hash function eval(2+c+3)&3 to map the different operator characters c in [0, 3].

 operator | eval(2+c+3)  | eval(2+c+3)&3
----------+--------------+---------------
    +     |  2+3 = 5     |    5 & 3 = 1
    -     |  2-3 = -1    |   -1 & 3 = 3
    *     |  2*3 = 6     |    6 & 3 = 2
    /     |  2/3 ~= 0.67 | 0.67 & 3 = 0


问:
The Burnt Pancake Problem
This challenge is related to Flipping Pancakes.

You may have heard of pancake sorting, where a stack of pancakes is sorted by size by inserting spatula into the stack and flipping all of the pancakes above the spatula, until the pancakes are sorted smallest to largest on the plate. The burnt pancake problem is slightly different. All pancakes now have one side that is burnt, and the burnt side of each pancake must face the plate once the sorting is completed.

For example, given the following stack (size of pancake on the left. 0 meaning burnt-side down and 1 meaning burnt-side up on the right):

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

You may flip the whole stack to get 20 30 11, flip the top two to get 31 21 11 and flip the whole stack again to get 10 20 30, a sorted stack of burnt pancakes. This sequence of moves, flip 3, flip 2, flip 3, could be represented as 3 2 3.

The Challenge

Given an array of pancakes sizes (not necessarily unique) and their orientations, output any valid burnt pancake sorting sequence, that is, a sequence of flips that leads to the stack of pancakes being sorted from smallest to largest with burnt sides down.

Input and output may be any sane format with separators, but please specify which formats you use and state which end of your input format is the top of the stack (TOS).

Flipping zero pancakes is allowed.

Mixing separators in the input/output is allowed.

Test cases

For all of the following test cases, input is a list and output is a space-separated string, and TOS is on the left.

```<code>[[1, 0], [3, 1], [2, 1]]
"3 2 3"

[[5, 1], [3, 0], [4, 1], [2, 1], [1, 0]]
"5 3 4 1 3 2 1"

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

As always, if anything is unclear or incorrect, please let me know in the comments. Good luck and good golfing!

答:
CJam (37 bytes)

```<code>q~{__$W>#)_p/(W%\M*2,f.^+(1=p_,)pW%}h
</code>```

Input is an array in CJam format on stdin; output is a newline-separated list of flip lengths on stdout. The top of stack is at index 0; 0 indicates burnt side up, and 1 indicates burnt side down.

Online demo

Dissection

The output is always 3n flips long, where n is the number of pancakes. First we flip the largest remaining pancake to the top; then if it's burnt side down we flip that one pancake; and then we flip it to the bottom and repeat as though the stack of pancakes were one shorter.

```<code>q~         e# Parse input into array
{          e# Loop...
  __$W>#)  e#   Find 1-based index of largest element in array
  _p       e#   Dup and print
  /(       e#   Split into chunks that long, and pull off the first
  W%       e#   Reverse the first chunk. Note that we don't flip the burnt/unburnt bit
  \M*      e#   Merge the remaining chunks into a single array
  2,f.^    e#   Flip *their* burnt/unburnt bits
  +        e#   Concatenate, prepending the first chunk
  (1=p     e#   Pull off the first (largest) element and print its burnt/unburnt bit
  _,)p     e#   Print the number of remaining elements plus 1 (to account for the largest)
  W%       e#   Reverse. Note that the first chunk has now been flipped twice, which is
           e#   why we have left its burnt/unburnt bit alone
}h         e# ... until we get down to an empty array
</code>```

Title: The Burnt Pancake Problem

Body:
CJam (37 bytes)

q~{__$W>#)_p/(W%\M*2,f.^+(1=p_,)pW%}h

Input is an array in CJam format on stdin; output is a newline-separated list of flip lengths on stdout. The top of stack is at index 0; 0 indicates burnt side up, and 1 indicates burnt side down.

Online demo

Dissection

The output is always 3n flips long, where n is the number of pancakes. First we flip the largest remaining pancake to the top; then if it's burnt side down we flip that one pancake; and then we flip it to the bottom and repeat as though the stack of pancakes were one shorter.

q~         e# Parse input into array
{          e# Loop...
  __$W>#)  e#   Find 1-based index of largest element in array
  _p       e#   Dup and print
  /(       e#   Split into chunks that long, and pull off the first
  W%       e#   Reverse the first chunk. Note that we don't flip the burnt/unburnt bit
  \M*      e#   Merge the remaining chunks into a single array
  2,f.^    e#   Flip *their* burnt/unburnt bits
  +        e#   Concatenate, prepending the first chunk
  (1=p     e#   Pull off the first (largest) element and print its burnt/unburnt bit
  _,)p     e#   Print the number of remaining elements plus 1 (to account for the largest)
  W%       e#   Reverse. Note that the first chunk has now been flipped twice, which is
           e#   why we have left its burnt/unburnt bit alone
}h         e# ... until we get down to an empty array


答:
Ruby, <s>35</s> 23 bytes

This is an anonymous function that concatenates [0..n], takes the nth index and checks if that char is "0" (less than "1"). Golfing suggestions welcome.

->n{([*0..n]*'')[n]<?1}
```

<p><strong>Ungolfing</strong></p>

<pre class="lang-ruby prettyprint-override"><code>->n{...}   # Create an anonymous function with parameter n.
[*0..n]    # Create an array of the range [0..n].
[...]*''   # Join the array using the empty string.
(...)[n]   # Take the char at the n-th index of the string.
<?1        # Check if the char is < "1" (that is, "0").
</code>```

Title: Where are Champernowne's zeroes?

Body:
Consider the infinite string of all nonnegative decimal integers concatenated together in order (akin to Champernowne's constant):

```<code>0123456789101112131415161718192021222324252627282930...979899100101102103...
</code>```

Write a program or function that takes in a nonnegative integer that indexes (0-based) into this infinite string. Output a truthy value if the digit indexed is 0, otherwise output a falsy value if the digit is 1-9.

The shortest code in bytes wins.

The first 25 truthy-producing inputs are:

```<code>0
11
31
51
71
91
111
131
151
171
191
192
194
197
200
203
206
209
212
215
218
222
252
282
312
</code>```

Kudos if your program is memory effecient, but this is not a requirement.

Body:
Ruby, <s>35</s> 23 bytes

This is an anonymous function that concatenates [0..n], takes the nth index and checks if that char is "0" (less than "1"). Golfing suggestions welcome.

->n{([*0..n]*'')[n]<?1}

Ungolfing

->n{...}   # Create an anonymous function with parameter n.
[*0..n]    # Create an array of the range [0..n].
[...]*''   # Join the array using the empty string.
(...)[n]   # Take the char at the n-th index of the string.
<?1        # Check if the char is < "1" (that is, "0").


答:
Bash + coreutils + X11 term - 7 keystrokes

Exact keys to hit:

<Alt>+1

0

0

* (<Shift>+8)

<Return>

Requirements:

Your terminal window must be exactly 10 characters wide.

Your terminal prompt (PS1) should be empty.

Your working dir must be empty.

Title: Print a 10 by 10 grid of asterisks

Body:
Background

This is a standard textbook example to demonstrate for loops.

This is one of the first programs I learnt when I started learning programming ~10 years ago.

Task

You are to print this exact text:

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

Specs

You may have extra trailing newlines.

You may have extra trailing spaces (U+0020) at the end of each line, including the extra trailing newlines.

Scoring

This is code-golf. Shortest answer in bytes wins.


答:
Actually, <s>9</s> 8 bytes

This answer concatenates the range [0..n], takes the nth index and checks if that char is "0". Golfing suggestions welcome. Try it online!

```<code>;urεjE≈Y
</code>```

Ungolfing

```<code>;          Duplicate n
 ur        Increment the duplicate and create range [0..n].
   εj      Join the range with an empty string. Stack: <string> n
     E     Take the char at the n-th index.
      ≈    int(a)
       Y   Logical NOT. If the digit is 0, then return 1, else return 0.
</code>```

Title: Where are Champernowne's zeroes?

Body:
Actually, <s>9</s> 8 bytes

This answer concatenates the range [0..n], takes the nth index and checks if that char is "0". Golfing suggestions welcome. Try it online!

;urεjE≈Y

Ungolfing

;          Duplicate n
 ur        Increment the duplicate and create range [0..n].
   εj      Join the range with an empty string. Stack: <string> n
     E     Take the char at the n-th index.
      ≈    int(a)
       Y   Logical NOT. If the digit is 0, then return 1, else return 0.


问:
Golf all the 16 logic gates with 2 inputs and 1 output!
For example, the gate A and B is a logic gate with 2 inputs and 1 output.

There are exactly 16 of them, because:

each logic gate takes two inputs, which can be truthy or falsey, giving us 4 possible inputs

of the 4 possible inputs, each can have an output of truthy and falsey

therefore, there are 2^4 possible logic gates, which is 16.

Your task is to write 16 programs/functions which implement all of them separately.

Your functions/programs must be independent.

They are valid as long as they output truthy/falsey values, meaning that you can implement A or B in Python as lambda a,b:a+b, even if 2 is produced for A=True and B=True.

Score is total bytes used for each function/program.

List of logic gates

0,0,0,0 (false)

0,0,0,1 (and)

0,0,1,0 (A and not B)

0,0,1,1 (A)

0,1,0,0 (not A and B)

0,1,0,1 (B)

0,1,1,0 (xor)

0,1,1,1 (or)

1,0,0,0 (nor)

1,0,0,1 (xnor)

1,0,1,0 (not B)

1,0,1,1 (B implies A)

1,1,0,0 (not A)

1,1,0,1 (A implies B)

1,1,1,0 (nand)

1,1,1,1 (true)

Where the first number is the output for A=false, B=false,
the second number is the output for A=false, B=true,
the third number is the output for A=true, B=false,
the fourth number is the output for A=true, B=true.

Leaderboard

var QUESTION_ID=82938,OVERRIDE_USER=48934;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+(?:\.\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

```

答:
Fourier, 94 bytes

Fourier uses 0 for falsey and 1 truthy. Many thanks to @LeakyNun for golfing help.

False, 1 bytes

```<code>o
</code>```

Outputs the value of the accumulator (0), then takes input.

Try it online!

AND, 4 bytes

```<code>I*Io
</code>```

Multiplies the two numbers together.

Try it online!

a AND NOT b, 6 bytes

```<code>I*1-Io
</code>```

Similar to above, except the second input is subtracted from one, simulating a NOT.

Try it online!

a, 2 bytes

```<code>Io
</code>```

Only outputs the first input.

Try it online!

NOT a AND b, 6 bytes

```<code>1-I+Io
</code>```

Pretty mich the same as a AND NOT b.

Try it online!

b, 3 bytes

```<code>IIo
</code>```

Outputs the second input.

Try it online!

XOR, 6 bytes

```<code>I+I=1o
</code>```

Checks if the sum of the inputs is equal to one.

Try it online!

OR, 6 bytes

```<code>I+I>0o
</code>```

Similar to AND, this checks to see if the sum of the inputs is greater than zero.

Try it online!

NOR, 6 bytes

```<code>I+I<1o
</code>```

Just a reverse of the OR.

Try it online!

XNOR, 8 bytes

```<code>1-I+I=1o
</code>```

Adds a NOT in front of the XOR gate.

Try it online!

NOT b, 5 bytes

```<code>I*Io
</code>```0

Puts a NOT in front of the second input.

Try it online!

b implies a, 13 bytes

```<code>I*Io
</code>```1

Outputs NOT a then, if b equals 1, clears the screen and outputs 1.

Try it online!

NOT a, 4 bytes

```<code>I*Io
</code>```2

Pretty much NOT b, just slightly different.

Try it online!

a implies b, 16 bytes

```<code>I~A1-IoA{0}{@1o}
</code>```

Stores the first input in the variable A, then outputs the value of NOT b. If a is 0, the program clears the screen and outputs 1.

Try it online!

NAND, 6 bytes

```<code>I+I<2o
</code>```

Again, just the inverse of the AND program.

Try it online!

True, 2 bytes

```<code>1o
</code>```

Outputs 1 and ignores the inputs.

Try it online!

Body:
Fourier, 94 bytes

Fourier uses 0 for falsey and 1 truthy. Many thanks to @LeakyNun for golfing help.

False, 1 bytes

o

Outputs the value of the accumulator (0), then takes input.

Try it online!

AND, 4 bytes

I*Io

Multiplies the two numbers together.

Try it online!

a AND NOT b, 6 bytes

I*1-Io

Similar to above, except the second input is subtracted from one, simulating a NOT.

Try it online!

a, 2 bytes

Io

Only outputs the first input.

Try it online!

NOT a AND b, 6 bytes

1-I+Io

Pretty mich the same as a AND NOT b.

Try it online!

b, 3 bytes

IIo

Outputs the second input.

Try it online!

XOR, 6 bytes

I+I=1o

Checks if the sum of the inputs is equal to one.

Try it online!

OR, 6 bytes

I+I>0o

Similar to AND, this checks to see if the sum of the inputs is greater than zero.

Try it online!

NOR, 6 bytes

I+I<1o

Just a reverse of the OR.

Try it online!

XNOR, 8 bytes

1-I+I=1o

Adds a NOT in front of the XOR gate.

Try it online!

NOT b, 5 bytes

I1-Io

Puts a NOT in front of the second input.

Try it online!

b implies a, 13 bytes

1-IoI{1}{@1o}

Outputs NOT a then, if b equals 1, clears the screen and outputs 1.

Try it online!

NOT a, 4 bytes

1-Io

Pretty much NOT b, just slightly different.

Try it online!

a implies b, 16 bytes

I~A1-IoA{0}{@1o}

Stores the first input in the variable A, then outputs the value of NOT b. If a is 0, the program clears the screen and outputs 1.

Try it online!

NAND, 6 bytes

I+I<2o

Again, just the inverse of the AND program.

Try it online!

True, 2 bytes

1o

Outputs 1 and ignores the inputs.

Try it online!


答:
GNU sed, 27 bytes

s/^/**********/;h;H;G;H;g;G
```

<p>To add to the diversity of languages used, I present a sed solution. The code works as follows, indicating the number of sets of 10 asterisks in pattern space and then in hold space:</p>

<pre class="lang-sed prettyprint-override"><code>s/^/**********/        # 10 asterisks are added to pattern space      (1 0)
h                      # overwrites hold space with pattern space     (1 1)
H                      # appends pattern space to hold space          (1 2)
G                      # appends hold space to pattern space          (3 2)
H                      #                                              (3 5)
g                      # overwrites pattern space with hold space     (5 5)
G                      # after G, pattern space is printed on exit   (10 5)
</code>```

Title: Print a 10 by 10 grid of asterisks

Body:
GNU sed, 27 bytes

s/^/**********/;h;H;G;H;g;G

To add to the diversity of languages used, I present a sed solution. The code works as follows, indicating the number of sets of 10 asterisks in pattern space and then in hold space:

s/^/**********/        # 10 asterisks are added to pattern space      (1 0)
h                      # overwrites hold space with pattern space     (1 1)
H                      # appends pattern space to hold space          (1 2)
G                      # appends hold space to pattern space          (3 2)
H                      #                                              (3 5)
g                      # overwrites pattern space with hold space     (5 5)
G                      # after G, pattern space is printed on exit   (10 5)


答:
PHP, 36 bytes

```<code><?=!join(range(0,$a=$argv[1]))[$a];
</code>```

Print 1 if Champernowne argument-th decimal is 0, else print '' (empty string).

Title: Where are Champernowne's zeroes?

Body:
PHP, 36 bytes

<?=!join(range(0,$a=$argv[1]))[$a];

Print 1 if Champernowne argument-th decimal is 0, else print '' (empty string).


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

```

ContentLicense: CC BY-SA 4.0

Title: "99 Bottles of Beer"

Body:
Brainfuck, 4028 bytes

This is quite hideous.
Lots of duplication, and very inefficient, so it won't win any prizes. However, I started it, and was determined to finish it.

I may try and improve this, but probably wont, because frankly, my brain is fucked.

Golfed

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

Ungolfed

# SETUP COUNTERS
>>+++[-<+++<+++>>]
>>++++++[-<++++++++++<++++++++++>>]<---<--->>

# SETUP CONSTANTS
>+++++[-<++++++>]<++>
>++++++++++[-<++++++++++>]<-->        # B
>++++++++++[-<+++++++++++>]<+>        # O
>++++++++++[-<++++++++++>]<+>         # E
>++++++++++[-<++++++++++>]<++>        # F
>++++++++++[-<+++++++++++>]<++++++>   # T
>++++++++++[-<++++++++++>]<++++>      # H
>++++++++++[-<+++++++++++>]<-->       # L
>++++++++++[-<+++++++++++>]<++++>     # R
>++++++++++[-<+++++++++++>]<+++++>    # S
>++++++++++[-<+++++++++++>]           # N
>++++++++++[-<+++++++++++>]<+++++++++># W
>++++++++++[-<++++++++++>]<--->       # A
>+++++[-<++++++>]<++>                 # SPACE
>++++[-<++++++++++++>]<---->          # Comma
>++++[-<++++++++++++>]<-->            # Stop
++++++++++>                           # Newline
>++++++++++[-<+++++++++++>]<--->      # K
>++++++++++[-<++++++++++>]            # D
>++++++++++[-<+++++++++++>]<++>       # P
>++++++++++[-<++++++++++>]<+++++>     # I
>++++++++++[-<+++++++++++>]<+++++++   # U

# BACK TO START
<<<<<<<<<<<<<<<<<<<<<<<<<
[>
    [
        -> # Dec x0 counter
        .> # Print 0x char
        .> # Print x0 char
        .>
        .>.>>>..>>.<<<<.>>>>>>. # Bottles
        <<<<<<<<<.
        >>.>>.       # Of
        <<<<.
        >.>>..>>>>>. # Beer
        <<<<<<<<.
        >>.>>>>>>>>. # On
        >>>.
        <<<<<<<<.>.<<<. # The
        <<<.
        >>>>>>>>>>>.>.<<<<<.. # Wall
        >>>>>>>.     # Comma
        <.
        <<<<<<<<<<<<<<<.>.- # Counter with decrement
        >.
        >.>.>>>..>>.<<<<.>>>>>>. # Bottles
        <<<<<<<<<.
        >>.>>.       # Of
        <<<<.
        >.>>..>>>>>. # Beer
        >>>>>>>.     # Stop
        >.           # Newline
        <<<<<<<<<<<.>>>>>>>.>>>>>.<<<<<<<<<<<<<<. # Take
        <<<.
        >>.>>>>>>>>.<<<<<<<. # One
        <<<.
        >>>>>>>>>>>>>>>>>>.<<<<<<<<<<<<<<<<.>>>>>>>>>.<. # Down
        >>>.
        <.<<.>>>>>>>>.  # And
        <<<<<.
        >>>>>>.<<<<<<<.<<<..    # Pass
        >>>>.
        >>>>>>>.<<<<<<<<<<<<<<<. # It
        >>>>>>>>.
        <.<<<<.<<<<<<.>>>>>>>>>>>>>>>>>>>.<<<<<<<<<<<.>>>>>>>>. # Around
        <<<<. # Comma
        <.
        <<<<<<<<<<<<<<<.>. # 0x and x0
        >.
        >.>.>>>..>>.<<<<.>>>>>>. # Bottles
        <<<<<<<<<.
        >>.>>.  # Of
        <<<<.
        >.>>..>>>>>. # Beer
        <<<<<<<<.
        >>.>>>>>>>>. # On
        >>>.
        <<<<<<<<.>.<<<. # The
        <<<.
        >>>>>>>>>>>.>.<<<<<.. # Wall
        >>>>>>>>.    # Stop
        >..   # Newline x2
        <<<<<<<<<<<<<<<<<<<      # Reset loop
    ]
    <-
    >+++++++++
    >.>.
    >.
    >.>.>>>..>>.<<<<.>>>>>>. # Bottles
    <<<<<<<<<.
    >>.>>.       # Of
    <<<<.
    >.>>..>>>>>. # Beer
    <<<<<<<<.
    >>.>>>>>>>>. # On
    >>>.
    <<<<<<<<.>.<<<. # The
    <<<.
    >>>>>>>>>>>.>.<<<<<.. # Wall
    >>>>>>>.     # Comma
    <.
    <<<<<<<<<<<<<<<.- # 0x with decrement
    >.+++++++++ # x0 with increment
    >.
    >.>.>>>..>>.<<<<.>>>>>>. # Bottles
    <<<<<<<<<.
    >>.>>.       # Of
    <<<<.
    >.>>..>>>>>. # Beer
    >>>>>>>.     # Stop
    >.           # Newline
    <<<<<<<<<<<.>>>>>>>.>>>>>.<<<<<<<<<<<<<<. # Take
    <<<.
    >>.>>>>>>>>.<<<<<<<. # One
    <<<.
    >>>>>>>>>>>>>>>>>>.<<<<<<<<<<<<<<<<.>>>>>>>>>.<. # Down
    >>>.
    <.<<.>>>>>>>>.  # And
    <<<<<.
    >>>>>>.<<<<<<<.<<<..    # Pass
    >>>>.
    >>>>>>>.<<<<<<<<<<<<<<<. # It
    >>>>>>>>.
    <.<<<<.<<<<<<.>>>>>>>>>>>>>>>>>>>.<<<<<<<<<<<.>>>>>>>>. # Around
    <<<<. # Comma
    <.
    <<<<<<<<<<<<<<<.>. # Counter
    >.
    >.>.>>>..>>.<<<<.>>>>>>. # Bottles
    <<<<<<<<<.
    >>.>>.  # Of
    <<<<.
    >.>>..>>>>>. # Beer
    <<<<<<<<.
    >>.>>>>>>>>. # On
    >>>.
    <<<<<<<<.>.<<<. # The
    <<<.
    >>>>>>>>>>>.>.<<<<<.. # Wall
    >>>>>>>>.    # Stop
    >..   # Newline x2
    <<<<<<<<<<<<<<<<<<<<      # Reset outer loop
]
>-- # Decrement counter to only count from 7
# Last 8 loop
[
    -> # Dec counter
    >. # Print x0 char
    >.
    >.>.>>>..>>.<<<<.>>>>>>. # Bottles
    <<<<<<<<<.
    >>.>>.       # Of
    <<<<.
    >.>>..>>>>>. # Beer
    <<<<<<<<.
    >>.>>>>>>>>. # On
    >>>.
    <<<<<<<<.>.<<<. # The
    <<<.
    >>>>>>>>>>>.>.<<<<<.. # Wall
    >>>>>>>.     # Comma
    <.
    <<<<<<<<<<<<<<.- # x with decrement
    >.
    >.>.>>>..>>.<<<<.>>>>>>. # Bottles
    <<<<<<<<<.
    >>.>>.       # Of
    <<<<.
    >.>>..>>>>>. # Beer
    >>>>>>>.     # Stop
    >.           # Newline
    <<<<<<<<<<<.>>>>>>>.>>>>>.<<<<<<<<<<<<<<. # Take
    <<<.
    >>.>>>>>>>>.<<<<<<<. # One
    <<<.
    >>>>>>>>>>>>>>>>>>.<<<<<<<<<<<<<<<<.>>>>>>>>>.<. # Down
    >>>.
    <.<<.>>>>>>>>.  # And
    <<<<<.
    >>>>>>.<<<<<<<.<<<..    # Pass
    >>>>.
    >>>>>>>.<<<<<<<<<<<<<<<. # It
    >>>>>>>>.
    <.<<<<.<<<<<<.>>>>>>>>>>>>>>>>>>>.<<<<<<<<<<<.>>>>>>>>. # Around
    <<<<. # Comma
    <.
    <<<<<<<<<<<<<<. # Count
    >.
    >.>.>>>..>>.<<<<.>>>>>>. # Bottles
    <<<<<<<<<.
    >>.>>.  # Of
    <<<<.
    >.>>..>>>>>. # Beer
    <<<<<<<<.
    >>.>>>>>>>>. # On
    >>>.
    <<<<<<<<.>.<<<. # The
    <<<.
    >>>>>>>>>>>.>.<<<<<.. # Wall
    >>>>>>>>.    # Stop
    >..   # Newline x2
    <<<<<<<<<<<<<<<<<<<     # Reset loop
]
# Last but 1 exception
>>. # Counter
>.
>.>.>>>..>>.<<<<.>>>>>>. # Bottles
<<<<<<<<<.
>>.>>.       # Of
<<<<.
>.>>..>>>>>. # Beer
<<<<<<<<.
>>.>>>>>>>>. # On
>>>.
<<<<<<<<.>.<<<. # The
<<<.
>>>>>>>>>>>.>.<<<<<.. # Wall
>>>>>>>.     # Comma
<.
<<<<<<<<<<<<<<.- # x with decrement
>.
>.>.>>>..>>.<<<<.>>>>>>. # Bottles
<<<<<<<<<.
>>.>>.       # Of
<<<<.
>.>>..>>>>>. # Beer
>>>>>>>.     # Stop
>.           # Newline
<<<<<<<<<<<.>>>>>>>.>>>>>.<<<<<<<<<<<<<<. # Take
<<<.
>>.>>>>>>>>.<<<<<<<. # One
<<<.
>>>>>>>>>>>>>>>>>>.<<<<<<<<<<<<<<<<.>>>>>>>>>.<. # Down
>>>.
<.<<.>>>>>>>>.  # And
<<<<<.
>>>>>>.<<<<<<<.<<<..    # Pass
>>>>.
>>>>>>>.<<<<<<<<<<<<<<<. # It
>>>>>>>>.
<.<<<<.<<<<<<.>>>>>>>>>>>>>>>>>>>.<<<<<<<<<<<.>>>>>>>>. # Around
<<<<. # Comma
<.
<<<<<<<<<<<<<<. # Count
>.
>.>.>>>..>>.<<<<. # Bottle
<<<.
>>.>>.  # Of
<<<<.
>.>>..>>>>>. # Beer
<<<<<<<<.
>>.>>>>>>>>. # On
>>>.
<<<<<<<<.>.<<<. # The
<<<.
>>>>>>>>>>>.>.<<<<<.. # Wall
>>>>>>>>.    # Stop
>..   # Newline x2
# Last 1 exception
<<<<<<<<<<<<<<<<<. # Counter
>.
>.>.>>>..>>.<<<<. # Bottle
<<<.
>>.>>.       # Of
<<<<.
>.>>..>>>>>. # Beer
<<<<<<<<.
>>.>>>>>>>>. # On
>>>.
<<<<<<<<.>.<<<. # The
<<<.
>>>>>>>>>>>.>.<<<<<.. # Wall
>>>>>>>.     # Comma
<.
<<<<<<<<<<<<<<.++++++++ # x with reset to 99
>.
>.>.>>>..>>.<<<<. # Bottle
<<<.
>>.>>.       # Of
<<<<.
>.>>..>>>>>. # Beer
>>>>>>>.     # Stop
>.           # Newline
>----        # Change K to G
>>+++++++++  # Change P to Y
>++++        # Change I to M
<<<.<<<<<<<<<<<<<<<. # Go
<<.
>>>>>.<<<.           # To
<<.
>>>>>.>.<<<.         # The
<<<.
>>>>>>>>>.<<<<.<<<.>>>>>>.<<<<<. # Store
<<<.
>>>>>>>>>>>>.<<.>>>>>>>>.       # And
<<<<<.
<<<<<<<<<<<<.>>>>>>>>>>>>>>>>>>>>.<<. # Buy
<<<<<<.
<<<<.<<<<<<<.>>>>>>>>>>>>>>>>>>.<<<<<<<<<<<<<<<<<. # Some
>>>>>>>>>>.
>>>>>>>.<<<<<<<<<<<<<<<<<<.>>>>>>.<<<<<. # More
>>>>>>>>>>>.
<.
<<<<<<<<<<<<<<..  # 99
>.
>.>.>>>..>>.<<<<.>>>>>>. # Bottles
<<<<<<<<<.
>>.>>.  # Of
<<<<.
>.>>..>>>>>. # Beer
<<<<<<<<.
>>.>>>>>>>>. # On
>>>.
<<<<<<<<.>.<<<. # The
<<<.
>>>>>>>>>>>.>.<<<<<.. # Wall
>>>>>>>>.    # Stop
>.   # Newline x2

Output:

Try it yourself here!

OK, so it seems the URL is too long to include here, so you will need to copy/paste to try it yourself.

I tested it using this interpreter.


问:
This isn't rocket science
Write a program or function that takes in a single-line string. You can assume it only contains printable ASCII. Print or return a string of an ASCII art rocket such as

```<code>  |
 /_\
 |E|
 |a|
 |r|
 |t|
 |h|
 |_|
/___\
 VvV
</code>```

with the input string written from top to bottom on the fuselage. In this case the input was Earth. The height of the rocket (including flames) is always the length of the string plus five.

Each line in the output may have up to two trailing spaces and there may be a single optional trailing newline. The shortest code in bytes wins.

More Examples:

```<code>[empty string]

  |
 /_\
 |_|
/___\
 VvV

a

  |
 /_\
 |a|
 |_|
/___\
 VvV

|0

  |
 /_\
 |||
 |0|
 |_|
/___\
 VvV

\/\

  |
 /_\
 |\|
 |/|
 |\|
 |_|
/___\
 VvV

 _ _ [note trailing space]

  |
 /_\
 | |
 |_|
 | |
 |_|
 | |
 |_|
/___\
 VvV

    [4 spaces]

  |
 /_\
 | |
 | |
 | |
 | |
 |_|
/___\
 VvV

SPACEY

  |
 /_\
 |S|
 |P|
 |A|
 |C|
 |E|
 |Y|
 |_|
/___\
 VvV
</code>```

Leaderboard

var QUESTION_ID=91182,OVERRIDE_USER=26997;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

```

答:
R, 148 bytes

```<code>f=function(b){cat("  |\n /_\\\n |",paste(as.character(unlist(strsplit(c(b,"_"),''))),collapse='|\n |'),"|\n/___\\\n VvV",sep="")}
f(commandArgs(T))
</code>```

If above code is in sample.R file then run from command line

```<code>Rscript sample.R "GOKUL"
</code>```

Output:

```<code>  |
 /_\
 |G|
 |O|
 |K|
 |U|
 |L|
 |_|
/___\
 VvV
</code>```

Title: This isn't rocket science

Body:
R, 148 bytes

f=function(b){cat("  |\n /_\\\n |",paste(as.character(unlist(strsplit(c(b,"_"),''))),collapse='|\n |'),"|\n/___\\\n VvV",sep="")}
f(commandArgs(T))

If above code is in sample.R file then run from command line

Rscript sample.R "GOKUL"

Output:

  |
 /_\
 |G|
 |O|
 |K|
 |U|
 |L|
 |_|
/___\
 VvV


问:
Build a small and balanced mobile
You are given a bunch of weights, and your task is to build a small balanced mobile using those weights.

The input is a list of integer weights in the range 1 through 9, inclusive.  There may be duplicates.

The output is an ascii picture of a mobile that, when hung, would balance.  Perhaps best shown by example:

input

```<code>3 8 9 7 5
</code>```

possible output

```<code>         |
   +-----+---------+
   |               |
+--+-+        +----+------+
|    |        |           |
8   ++--+     7           5
    |   |
    9   3
</code>```

You must use the ascii characters as shown.  The horizontal and vertical segments may be of any length.  No part of the mobile may touch (horizontally or vertically) another unconnected part of the mobile.  All weights must be hung from a vertical segment of length at least 1, and there must be a vertical segment from which the whole mobile is hung.

The size of a mobile is the total number of +,-,and | characters required to build it.  Lower sizes are better.

You may put as many connections on a segment as you would like.  For example:

input

```<code>2 3 3 5 3 9
</code>```

possible output

```<code>           |
   +---+---+-----------+
   |   |               |
+--+-+ 5               9
|  | |
2  | 3
   |
  +++
  | |
  3 3
</code>```

The winning program is the one that can generate the lowest average of mobile sizes for a test set of inputs.  The real test is super-secret to prevent hard-coding, but it will be something like this:

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

答:
Here is a solution that brute forces the smallest single row solution.
The code iterates over all permutations and compute the center of mass for each. If the center of mass has integer coordinates, we've found a solution.

After all permutations have been tried, we add a segment to the mix (equivalent to a weight of mass 0) in our current set of weights and retry.

To run the program, do python balance.py 1 2 2 4.

#!/usr/bin/env python3
import itertools, sys

# taken from http://stackoverflow.com/a/30558049/436792
def unique_permutations(elements):
    if len(elements) == 1:
        yield (elements[0],)
    else:
        unique_elements = set(elements)
        for first_element in unique_elements:
            remaining_elements = list(elements)
            remaining_elements.remove(first_element)
            for sub_permutation in unique_permutations(remaining_elements):
                yield (first_element,) + sub_permutation

def print_solution(cm, values):
    print(('  ' * cm) + '|')
    print('-'.join(['-' if v == 0 else '+'  for v in values]))
    print(' '.join([' ' if v == 0 else '|'  for v in values]))
    print(' '.join([' ' if v == 0 else str(v) for v in values]))

input = list(map(int, sys.argv[1:]))
mass = sum(input)
while True:
    n = len(input)
    permutations = filter(lambda p: p[0] != 0 and p[n-1] != 0, unique_permutations(input))
    for p in permutations:
        cm = 0
        for i in range(n):
            cm += p[i] * i;
        if (cm % mass == 0):
            print_solution(cm//mass, p)
            sys.exit(0)
    input.append(0)
```

<p>which produces these best solutions :</p>

```    |
+-+-+-+-+
| | | | |
8 3 9 5 7

    |
+-+-+-+-+-+
| | | | | |
9 2 3 5 3 3

                |
+-+-+-+-+-+-+---+-+-+-+-+-+-+-+-+
| | | | | | |   | | | | | | | | |
8 8 8 8 8 8 8   8 8 8 8 8 8 8 8 7

                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| | | | | | | | | | | | | | | | | | | |
1 1 2 2 3 3 4 4 8 8 5 5 6 6 7 7 7 7 9 9

                  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| | | | | | | | | | | | | | | | |
3 4 4 4 4 5 5 5 5 6 7 6 7 7 7 6 6
```

Title: Build a small and balanced mobile

Body:
Here is a solution that brute forces the smallest single row solution.
The code iterates over all permutations and compute the center of mass for each. If the center of mass has integer coordinates, we've found a solution.

After all permutations have been tried, we add a segment to the mix (equivalent to a weight of mass 0) in our current set of weights and retry.

To run the program, do python balance.py 1 2 2 4.

#!/usr/bin/env python3
import itertools, sys

# taken from http://stackoverflow.com/a/30558049/436792
def unique_permutations(elements):
    if len(elements) == 1:
        yield (elements[0],)
    else:
        unique_elements = set(elements)
        for first_element in unique_elements:
            remaining_elements = list(elements)
            remaining_elements.remove(first_element)
            for sub_permutation in unique_permutations(remaining_elements):
                yield (first_element,) + sub_permutation

def print_solution(cm, values):
    print(('  ' * cm) + '|')
    print('-'.join(['-' if v == 0 else '+'  for v in values]))
    print(' '.join([' ' if v == 0 else '|'  for v in values]))
    print(' '.join([' ' if v == 0 else str(v) for v in values]))

input = list(map(int, sys.argv[1:]))
mass = sum(input)
while True:
    n = len(input)
    permutations = filter(lambda p: p[0] != 0 and p[n-1] != 0, unique_permutations(input))
    for p in permutations:
        cm = 0
        for i in range(n):
            cm += p[i] * i;
        if (cm % mass == 0):
            print_solution(cm//mass, p)
            sys.exit(0)
    input.append(0)

which produces these best solutions :

    |
+-+-+-+-+
| | | | |
8 3 9 5 7

    |
+-+-+-+-+-+
| | | | | |
9 2 3 5 3 3

                |
+-+-+-+-+-+-+---+-+-+-+-+-+-+-+-+
| | | | | | |   | | | | | | | | |
8 8 8 8 8 8 8   8 8 8 8 8 8 8 8 7

                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| | | | | | | | | | | | | | | | | | | |
1 1 2 2 3 3 4 4 8 8 5 5 6 6 7 7 7 7 9 9

                  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| | | | | | | | | | | | | | | | |
3 4 4 4 4 5 5 5 5 6 7 6 7 7 7 6 6


答:
GNU sed, 53 bytes

```<code>1i\  |\n /_\\
s:.: |&|\n:g;s:$: |_|:g;$a\/___\\\n VvV
</code>```

With GNU sed, you can omit the initial \ for the a command, so it is one byte less:

```<code>1i\  |\n /_\\
s:.: |&|\n:g;s:$: |_|:g;$a/___\\\n VvV
</code>```

Title: This isn't rocket science

Body:
Write a program or function that takes in a single-line string. You can assume it only contains printable ASCII. Print or return a string of an ASCII art rocket such as

```<code>  |
 /_\
 |E|
 |a|
 |r|
 |t|
 |h|
 |_|
/___\
 VvV
</code>```

with the input string written from top to bottom on the fuselage. In this case the input was Earth. The height of the rocket (including flames) is always the length of the string plus five.

Each line in the output may have up to two trailing spaces and there may be a single optional trailing newline. The shortest code in bytes wins.

More Examples:

```<code>[empty string]

  |
 /_\
 |_|
/___\
 VvV

a

  |
 /_\
 |a|
 |_|
/___\
 VvV

|0

  |
 /_\
 |||
 |0|
 |_|
/___\
 VvV

\/\

  |
 /_\
 |\|
 |/|
 |\|
 |_|
/___\
 VvV

 _ _ [note trailing space]

  |
 /_\
 | |
 |_|
 | |
 |_|
 | |
 |_|
/___\
 VvV

    [4 spaces]

  |
 /_\
 | |
 | |
 | |
 | |
 |_|
/___\
 VvV

SPACEY

  |
 /_\
 |S|
 |P|
 |A|
 |C|
 |E|
 |Y|
 |_|
/___\
 VvV
</code>```

Leaderboard

var QUESTION_ID=91182,OVERRIDE_USER=26997;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:
GNU sed, 53 bytes

1i\  |\n /_\\
s:.: |&|\n:g;s:$: |_|:g;$a\/___\\\n VvV

With GNU sed, you can omit the initial \ for the a command, so it is one byte less:

1i\  |\n /_\\
s:.: |&|\n:g;s:$: |_|:g;$a/___\\\n VvV


问:
Excessive Integers
For a positive integer n with the prime factorization n = p1^e1 * p2^e2 * ... pk^ek where p1,...,pk are primes and e1,...,ek are positive integers, we can define two functions:

Ω(n) = e1+e2+...+ek the number of prime divisors (counted with multiplicity) (A001222)

ω(n) = k the number of distinct prime divisors. (A001221)

With those two functions we define the excess e(n) = Ω(n) - ω(n) (A046660). This can be considered as a measure of how close a number is to being squarefree.

Challenge

For a given positive integer n return e(n).

Examples

For n = 12 = 2^2 * 3 we have Ω(12) = 2+1 and ω(12) = 2 and therefore e(12) = Ω(12) - ω(12) = 1. For any squarefree number n we obivously have e(n) = 0. The first few terms are

```<code>1       0
2       0
3       0
4       1
5       0
6       0
7       0
8       2
9       1
10      0
11      0
12      1
13      0
14      0
15      0
</code>```

Some more details in the OEIS wiki.

答:
Haskell, 65 bytes

```<code>(c%x)n|x>n=c|mod n x>0=c%(x+1)$n|y<-div n x=(c+0^mod y x)%x$y
0%2
</code>```

Title: Excessive Integers

Body:
Haskell, 65 bytes

(c%x)n|x>n=c|mod n x>0=c%(x+1)$n|y<-div n x=(c+0^mod y x)%x$y
0%2


问:
Musical Score Interpreter
Given an ascii musical score, you must be able to output the note and its corresponding length.  The score will contain between 5 and 15 notes inclusive, and is transcribed on a stave.  A stave is made up of five horizontal lines comprising of - (minus) characters separated by lines of spaces.  The bottom line in the stave is equivalent to the note 'E'. The line of spaces immediately above the bottom line indicates an 'F', and is of a higher pitch that the 'E' below it. This continues as below. Note that notes only go up to 'G' before starting again at 'A'.  See below:

```<code>F ----------
E
D ----------
C
B ----------
A
G ----------
F
E ----------
</code>```

Note that the letters aren't included in the input.  The notes are superimposed on top of the stave using a o (lowercase ooh) character to indicate the 'note head'. This note head indicates the frequency of the note, and therefore the alphabetic representation of it as above. For example, a note placed on the score as below indicates an 'A' :

```<code>----

----

----
o
----

----
</code>```

A note, like the 'A' above, is called a 'whole note' and would be played for one whole beat. Other durations can be indicated by including a 'stem' rising from the note, and between zero and three 'flags'. A stem is made up of three | (pipe, or vertical bar) characters stacked immediately above the note head .  A stem with no flags is considered a 'quarter-note', and plays for quarter of a beat.  Flags are \ (backslash) characters, and hand on the right hand side of the stem. Each stem halves the time the note is played for. The length of each note will be one of the following: a whole note, a quarter note, an eighth note, a sixteenth note or a thirty-second note.  This how each type of note would look for A :

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

----|---|\--|\--|\--
    |   |   |\  |\
----|---|---|---|\--
o   o   o   o   o
--------------------

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

Putting more than one note together gives you a score. Each note can be considered to be four characters wide, with a note being in the first column of each four-character block. For example :

```<code>    |\
----|\--|\----------
    |\  |       |\
----o---|---o---|\--
|       o       |
|---------------o---
|
o-------------------

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

The example above contains the following notes, in order: a quarter note 'G', a thirty-second note 'D', an eighth note 'C', a whole note 'D' and a sixteenth note 'B'.  Each note in your output should be in the format letter/length, where letter is A-G and length is the fraction of the note's length when compared to a whole note. As an exception, the length and / character should not be printed if the note is a whole note. Each note in your output should be separated by a single space. Therefore, for the score above, your code should output the following:

```<code>G/4 D/32 C/8 D B/16
</code>```

The notes will be in the following range: E F G A B C D E F. Note that only the letter needs to be printed, the octave is ignored.

Note that the number of lines of input varies from 9 to 12, since notes with quarter time or less on line D or higher will require more lines to show completely.

There is no half-note in this case.

Shortest code wins (whitespace doesn't count).

Edit: Fixed error in spacing in one input.

Some sample inputs:

```<code>        |\
----|\--|-------------------
|\  |   |
|---|---o---------------o---
|   o               |\
o---------------|\--|\------
            |\  |\  |\
------------|\--|\--o-------
            |\  o
------------o---------------
</code>```

Output: B/8 C/8 D/8 E/32 F/32 G/32 D

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

Output: E G B D F F A C E

```<code>            |\
            |\
            |\
------------o-------|-----------
|               o   |   |\
|---|\--------------|---|\------
|   |               o   |\
o---|---|\--------------o---|\--
    o   |\                  |\
--------|\------------------|---
        o                   o
--------------------------------
</code>```

Output: B/4 A/8 F/32 F/32 E C/4 B/32 F/16

答:
Python golf, 207 chars.

```<code>import sys
a=[x[:-1]+' '*99 for x in sys.stdin]
for x in range(0,99,4):
 b=''.join((y[x:x+4] for y in a))+'o'
 c=2**(b.count('\\')+('|'in b)*2)
 print'FEDCBAGFE '[b.index('o')/4-len(a)+9]+('','/'+`c`)[c>1],
</code>```

I've start code golfing with Python for 2 days and I found that things like import sys, sys.stdin.read, sys.stdout.write are expansive.

Title: Musical Score Interpreter

Body:
Python golf, 207 chars.

import sys
a=[x[:-1]+' '*99 for x in sys.stdin]
for x in range(0,99,4):
 b=''.join((y[x:x+4] for y in a))+'o'
 c=2**(b.count('\\')+('|'in b)*2)
 print'FEDCBAGFE '[b.index('o')/4-len(a)+9]+('','/'+`c`)[c>1],

I've start code golfing with Python for 2 days and I found that things like import sys, sys.stdin.read, sys.stdout.write are expansive.


问:
Together Everyone Achieves More
(related: one, two, three)

An acrostic is a style of poem/writing where the beginning character of each line, when read vertically, also produces a word or message. For example,

```<code>Together
Everyone
Achieves
More
</code>```

also spells out the word TEAM when the first column is read vertically.

Acrostics are a subset of mesostics, where the vertical word can be anywhere in the horizontal words. For example, the TEAM one above could also be written as a mesostic as follows

```<code>   togeTher
everyonE
       Achieves
       More
</code>```

along with several other variations.

The challenge here will be to produce an acrostic or mesostic from a given list of input words.

Input

A list of words in any any suitable format.

The list will only contain words made from lowercase [a-z].

The list is guaranteed to form an acrostic or a mesostic (no need to handle bogus input).

One of the words in the input will form the vertical word, while the rest make the horizontal words - part of the challenge here is to find the appropriate vertical word, so it cannot be taken separately.

Output

The ASCII-art acrostic or mesostic formed from the input words, written to STDOUT or returned, in any reasonable format.

The corresponding vertical word must be capitalized (as in the examples).

Leading spaces to get the vertical word to line up appropriately are required. Trailing spaces, and leading/trailing newlines are optional. Extra leading spaces are fine as well, so long as the words align correctly.

If both an acrostic and mesostic are possible, output only the acrostic.

If more than one acrostic/mesostic is possible, your code can output any or all of them.

Rules

Either a full program or a function are acceptable.

Standard loopholes are forbidden.

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

Examples

```<code>['together', 'team', 'everyone', 'achieves', 'more']
Together
Everyone
Achieves
More

['aaa', 'aaa', 'aaa', 'aaa']
Aaa
Aaa
Aaa
# One output, or multiple (of the same) output is allowed

['aaa', 'aaa', 'aab', 'baa']
Aaa
Aaa
Baa
# This is the only allowed output, since others would be mesostic, which are lower priority

['live', 'every', 'love', 'very', 'ohio']
Live
Ohio
Very
Every
# Note that 'live' couldn't be the vertical word since then it would be a mesostic, which is lower priority output

['cow', 'of', 'fox']
cOw
 Fox
# A shorter mesostic test case

['late', 'ballroom', 'anvil', 'to', 'head']
anviL
   bAllroom
    To
   hEad
</code>```

答:
Python, 249 bytes

Probably still very golfable

from itertools import*;e=enumerate;lambda l:[[[' ']*(max(j for k,(j,c)in o[1:])-i)+l[k][:i]+[c.upper()]+l[k][i+1:]for k,(i,c)in o[1:]]for p in product(*[list(e(w))for w in l])for o in permutations(list(e(p)))if[c for k,(i,c)in o[1:]]==l[o[0][0]]][0]
```

<p>Takes and returns a list of list of characters.<br>
- e.g. <code>"   bAllroom"</code> is <code>[' ',' ',' ','b','A','l','l','r','o','o','m']</code></p>

<p>Only ever returns the first result and checks in an order such that all the acrostics are checked first.</p>

<p>See all test cases printed in the display format on <strong>ideone</strong></p>

<hr>

<p>Here is a more readable functional form that does the same (except it returns the first result immediately rather than evaluating and then returning the first result):</p>

<pre class="lang-python prettyprint-override"><code>from itertools import*
def f(l):
    for p in product(*[list(enumerate(w)) for w in l]):
        for o in permutations(list(enumerate(p))):
            if [c for k,(i,c) in o[1:]] == l[o[0][0]]:
                return [ [' '] * (max(j for k,(j,c) in o[1:]) - i)
                       + l[k][:i]
                       + [c.upper()]
                       + l[k][i+1:]
                       for k, (i, c) in o[1:]
                       ]
</code>```

Title: Together Everyone Achieves More

Body:
Python, 249 bytes

Probably still very golfable

from itertools import*;e=enumerate;lambda l:[[[' ']*(max(j for k,(j,c)in o[1:])-i)+l[k][:i]+[c.upper()]+l[k][i+1:]for k,(i,c)in o[1:]]for p in product(*[list(e(w))for w in l])for o in permutations(list(e(p)))if[c for k,(i,c)in o[1:]]==l[o[0][0]]][0]

Takes and returns a list of list of characters.

- e.g. "   bAllroom" is [' ',' ',' ','b','A','l','l','r','o','o','m']

Only ever returns the first result and checks in an order such that all the acrostics are checked first.

See all test cases printed in the display format on ideone

Here is a more readable functional form that does the same (except it returns the first result immediately rather than evaluating and then returning the first result):

from itertools import*
def f(l):
    for p in product(*[list(enumerate(w)) for w in l]):
        for o in permutations(list(enumerate(p))):
            if [c for k,(i,c) in o[1:]] == l[o[0][0]]:
                return [ [' '] * (max(j for k,(j,c) in o[1:]) - i)
                       + l[k][:i]
                       + [c.upper()]
                       + l[k][i+1:]
                       for k, (i, c) in o[1:]
                       ]


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

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

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

If that number is 1, print out 1 forever.

Challenge

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

take input from STDIN or an acceptable alternative

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

must output to STDOUT or an acceptable alternative

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

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

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

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

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

Catalog

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
Churro, <s>100</s> 95 bytes

```<code>{========={o}{*}======}{*}======}{={*}{={o}{={o}{={*}{={o}{======={*}{==={*}{======={*}{===={*}
</code>```

Explanation

Churro is a stack-based esolang where the only syntax element is, well, churros! Or rather, ASCII-art representations of churros. An example of such a churro is {o}====}.

In Churro, each churro has three characteristics:

Its orientation; whether it's facing left ({o}====}) or right ({===={o}).

Its filling; whether it's filled ({*}==}) or not ({o}==}).

Its tail length; the number of =s in the churro is the length of its tail.

Left-facing churros are integer literals; their tail length is their value, while their filling status is their sign. Filled churros are negative, while unfilled churros are positive.

Right-facing churros are operators; their tail length is which operator they represent, according to this table:

```<code>{{o}           pop A; discard A
{={o}          pop A, B; push B + A
{=={o}         pop A, B; push B - A
{==={o}        pop A; if A == 0, jump to churro after matching occurrence of {==={o}
{===={o}       pop A; if A != 0, jump to churro after matching occurrence of {==={o}
{====={o}      pop A, B; store B in memory location A
{======{o}     pop A; push the value in memory location A to stack
{======={o}    pop A; print A as an integer
{========{o}   pop A; print A as an ASCII character
{========={o}  read a single character from STDIN and push it to the stack
{=========={o} exit the program
</code>```

Filled operator churros have the same behaviour, but peek at the stack instead of popping from it.

With that, here's the ungolfed, explained version of the Churro truth-machine:

```<code>{========={o}    read char from stdin
{*}======}       push -6
{*}======}       push -6
{={*}            push -6 + -6 = -12
{={o}            pop -6, -12; push -6 + -12 = -18
{={o}            pop -6, -18; push -6 + -18 = -24
{={*}            push input + -24
{={o}            pop -24, input + -24; push input + -48 (convert char to int)
{======={*}      print input as integer
{==={*}          if input == 0 jump to matching churro
{======={*}      print input as integer
{===={*}         if input != 0 jump back to matching churro
</code>```

I'm using TheLastBanana's Haskell interpreter to interpret this. Installation instructions can be found there.

Finally, here's the "pure" version (no comments, line length 80, spaces between churros), as output by purify truth.ch:

```<code>{========={o} {*}======} {*}======} {={*} {={o} {={o} {={*} {={o} {======={*}
{==={*} {======={*} {===={*}
</code>```

Saved 5 bytes thanks to Martin Ender!

Title: Implement a Truth-Machine

Body:
Churro, <s>100</s> 95 bytes

{========={o}{*}======}{*}======}{={*}{={o}{={o}{={*}{={o}{======={*}{==={*}{======={*}{===={*}

Explanation

Churro is a stack-based esolang where the only syntax element is, well, churros! Or rather, ASCII-art representations of churros. An example of such a churro is {o}====}.

In Churro, each churro has three characteristics:

Its orientation; whether it's facing left ({o}====}) or right ({===={o}).

Its filling; whether it's filled ({*}==}) or not ({o}==}).

Its tail length; the number of =s in the churro is the length of its tail.

Left-facing churros are integer literals; their tail length is their value, while their filling status is their sign. Filled churros are negative, while unfilled churros are positive.

Right-facing churros are operators; their tail length is which operator they represent, according to this table:

{{o}           pop A; discard A
{={o}          pop A, B; push B + A
{=={o}         pop A, B; push B - A
{==={o}        pop A; if A == 0, jump to churro after matching occurrence of {==={o}
{===={o}       pop A; if A != 0, jump to churro after matching occurrence of {==={o}
{====={o}      pop A, B; store B in memory location A
{======{o}     pop A; push the value in memory location A to stack
{======={o}    pop A; print A as an integer
{========{o}   pop A; print A as an ASCII character
{========={o}  read a single character from STDIN and push it to the stack
{=========={o} exit the program

Filled operator churros have the same behaviour, but peek at the stack instead of popping from it.

With that, here's the ungolfed, explained version of the Churro truth-machine:

{========={o}    read char from stdin
{*}======}       push -6
{*}======}       push -6
{={*}            push -6 + -6 = -12
{={o}            pop -6, -12; push -6 + -12 = -18
{={o}            pop -6, -18; push -6 + -18 = -24
{={*}            push input + -24
{={o}            pop -24, input + -24; push input + -48 (convert char to int)
{======={*}      print input as integer
{==={*}          if input == 0 jump to matching churro
{======={*}      print input as integer
{===={*}         if input != 0 jump back to matching churro

I'm using TheLastBanana's Haskell interpreter to interpret this. Installation instructions can be found there.

Finally, here's the "pure" version (no comments, line length 80, spaces between churros), as output by purify truth.ch:

{========={o} {*}======} {*}======} {={*} {={o} {={o} {={*} {={o} {======={*}
{==={*} {======={*} {===={*}

Saved 5 bytes thanks to Martin Ender!


答:
PHP, 146 138, 133, 131 bytes

```<code>$a=$_POST['s'];$i=0;while($a){$c=substr($a,0,1);$i=$c=='+'?$i+=1:($c=='-'?$i-1:($c=='*'?$i*2:round($i/2)));$a=substr($a,1);}echo$i;
</code>```

Takes argument from $_POST['s'].

Uses ternary operator as "if's".

Takes one character at a time, parse that char in operation, then continue reading next char

EDIT 1: Shortened "while(strlen($a))" to "while($a)"

EDIT 2: Removed some useless paranthesis

EDIT 3. Removed extra space after last "echo"

Title: Simple integer operation calculator

Body:
Implement a simple integer operation scriptable calculator.

Concept

The accumulator starts at 0 and has operations performed on it. At the end of the program output the value of the accumulator.

Operations:

+ adds 1 to the accumulator

- subtracts 1 from the accumulator

* multiplies the accumulator by 2

/ divides the accumulator by 2

Sample script

The input ++**--/ should give the output 3.

Example implementation

```<code>def calc(s)
    i = 0
    s.chars.each do |o|
        case o
            when '+'
                i += 1
            when '-'
                i -= 1
            when '*'
                i *= 2
            when '/'
                i /= 2
        end
    end
    return i
end
</code>```

Rules

This is code-golf, so lowest answer in bytes wins, but is not selected.

Creative implementations are encouraged.

Standard loopholes are prohibited.

You get the program via stdin or arguments, and you can output the answer via return value or stdout.

Have fun.

Division truncates down because it is integer division.

The program -/ returns -1.

Test cases

```<code>*///*-*+-+
-1
/*+/*+++/*///*/+-+//*+-+-/----*-*-+++*+**+/*--///+*-/+//*//-+++--++/-**--/+--/*-/+*//*+-*-*/*+*+/+*-
-17
+++-+--/-*/---++/-+*-//+/++-*--+*+/*/*/++--++-+//++--*/***-*+++--+-*//-*/+*/+-*++**+--*/*//-*--**-/-*+**-/*-**/*+*-*/--+/+/+//-+*/---///+**////-*//+-+-/+--/**///*+//+++/+*++**++//**+**+-*/+/*/*++-/+**+--+*++++/-*-/*+--/++*/-++/-**++++/-/+/--*/-/+---**//*///-//*+-*----+//--/-/+*/-+++-+*-*+*+-/-//*-//+/*-+//+/+/*-/-/+//+**/-****/-**-//+/+-+/*-+*++*/-/++*/-//*--+*--/-+-+/+/**/-***+/-/++-++*+*-+*+*-+-//+/-++*+/*//*-+/+*/-+/-/*/-/-+*+**/*//*+/+---+*+++*+/+-**/-+-/+*---/-*+/-++*//*/-+-*+--**/-////*/--/*--//-**/*++*+/*+/-+/--**/*-+*+/+-*+*+--*///+-++/+//+*/-+/**--//*/+++/*+*////+-*-//--*+/*/-+**/*//+*+-//+--+*-+/-**-*/+//*+---*+//*/+**/*--/--+/*-*+*++--*+//+*+-++--+-*-*-+--**+/+*-/+*+-/---+-*+-+-/++/+*///*/*-+-*//-+-++/++/*/-++/**--+-////-//+/*//+**/*+-+/+/+///*+*///*-/+/*/-//-*-**//-/-+--+/-*--+-++**++//*--/*++--*-/-///-+/+//--+*//-**-/*-*/+*/-*-*//--++*//-*/++//+/-++-+-*/*-+++**-/-*++++**+-+++-+-***-+//+-/**-+/*+****-*+++*/-*-/***/-/*+/*****++*+/-/-**-+-*-*-++**/*+-/*-+*++-/+/-++*-/*-****-*
18773342
</code>```

Body:
PHP, 146 138, 133, 131 bytes

$a=$_POST['s'];$i=0;while($a){$c=substr($a,0,1);$i=$c=='+'?$i+=1:($c=='-'?$i-1:($c=='*'?$i*2:round($i/2)));$a=substr($a,1);}echo$i;

Takes argument from $_POST['s'].

Uses ternary operator as "if's".

Takes one character at a time, parse that char in operation, then continue reading next char

EDIT 1: Shortened "while(strlen($a))" to "while($a)"

EDIT 2: Removed some useless paranthesis

EDIT 3. Removed extra space after last "echo"


答:
PHP, <s>104</s> <s>102</s> 82 bytes

First version with eval:

```<code>$i=0;while($c<9999)eval('$i'.['+'=>'++','-'=>'--','*'=>'*=2','/'=>'>>=1'][$argv[1]{$c++}].';');echo$i;
</code>```

Second version with ternary operators:

```<code>while($o=ord($argv[1]{$c++}))$i=$o<43?$i*2:($o<44?$i+1:($o<46?$i-1:$i>>1));echo$i;
</code>```

Takes the input string as first argument from the command line.

<s>This "only" works for input strings shorter than 10,000 characters - which should be plenty. Tested with all the test cases, unfortunately can't save on the initialization in the beginning.</s> Second version works with strings of any length and without initialization. :-)

The main element is the eval function which manipulates $i based on a map of arithmetic operations, which are pretty straightforward except for the division. PHP returns a float when using / and intdiv is too many bytes, so we do a right-shift.

Updates

Saved 2 bytes by shortening $i=$i>>1 to $i>>=1 for integer division.

Threw out eval in favor of ternary operators.

Title: Simple integer operation calculator

Body:
PHP, <s>104</s> <s>102</s> 82 bytes

First version with eval:

$i=0;while($c<9999)eval('$i'.['+'=>'++','-'=>'--','*'=>'*=2','/'=>'>>=1'][$argv[1]{$c++}].';');echo$i;

Second version with ternary operators:

while($o=ord($argv[1]{$c++}))$i=$o<43?$i*2:($o<44?$i+1:($o<46?$i-1:$i>>1));echo$i;

Takes the input string as first argument from the command line.

<s>This "only" works for input strings shorter than 10,000 characters - which should be plenty. Tested with all the test cases, unfortunately can't save on the initialization in the beginning.</s> Second version works with strings of any length and without initialization. :-)

The main element is the eval function which manipulates $i based on a map of arithmetic operations, which are pretty straightforward except for the division. PHP returns a float when using / and intdiv is too many bytes, so we do a right-shift.

Updates

Saved 2 bytes by shortening $i=$i>>1 to $i>>=1 for integer division.

Threw out eval in favor of ternary operators.


答:
Javascript (ES5), 127 bytes

```<code>function(b){for(a=c=0;a<b.length;++a)switch(b[a]){case"+":++c;break;case"-":--c;break;case"*":c*=2;break;case"/":c/=2}return c}
</code>```

Ungolfed:

```<code>function c(a){
  c=0;
  for(var i=0;i<a.length;++i){
    switch(a[i]){
      case "+":++c;break;
      case "-":--c;break;
      case "*":c*=2;break;
      case "/":c/=2;break;
    }
  }
  return c;
}
</code>```

Title: Simple integer operation calculator

Body:
Javascript (ES5), 127 bytes

function(b){for(a=c=0;a<b.length;++a)switch(b[a]){case"+":++c;break;case"-":--c;break;case"*":c*=2;break;case"/":c/=2}return c}

Ungolfed:

function c(a){
  c=0;
  for(var i=0;i<a.length;++i){
    switch(a[i]){
      case "+":++c;break;
      case "-":--c;break;
      case "*":c*=2;break;
      case "/":c/=2;break;
    }
  }
  return c;
}


答:
PowerShell v2+, 32 bytes

```<code>param($n)(-join(0..$n))[$n]-eq48
</code>```

Does the same as other answers -- takes the range from 0 to input $n, -joins together into a string, takes the [$n] index, checks if it's -equal to 48 (i.e., ASCII for 0).

Note this will only work up to input 49999, as the PowerShell range operator .. only supports ranges of 50,000 elements or fewer. For larger inputs, you'll need to use the following, based on my previous Champernowne answer, at 58 bytes:

```<code>param($n)$j=$n;for($c='';$j-ge0;$j--){$c+=$i++}$c[$n]-eq48
</code>```

Title: Where are Champernowne's zeroes?

Body:
Consider the infinite string of all nonnegative decimal integers concatenated together in order (akin to Champernowne's constant):

```<code>0123456789101112131415161718192021222324252627282930...979899100101102103...
</code>```

Write a program or function that takes in a nonnegative integer that indexes (0-based) into this infinite string. Output a truthy value if the digit indexed is 0, otherwise output a falsy value if the digit is 1-9.

The shortest code in bytes wins.

The first 25 truthy-producing inputs are:

```<code>0
11
31
51
71
91
111
131
151
171
191
192
194
197
200
203
206
209
212
215
218
222
252
282
312
</code>```

Kudos if your program is memory effecient, but this is not a requirement.

Body:
PowerShell v2+, 32 bytes

param($n)(-join(0..$n))[$n]-eq48

Does the same as other answers -- takes the range from 0 to input $n, -joins together into a string, takes the [$n] index, checks if it's -equal to 48 (i.e., ASCII for 0).

Note this will only work up to input 49999, as the PowerShell range operator .. only supports ranges of 50,000 elements or fewer. For larger inputs, you'll need to use the following, based on my previous Champernowne answer, at 58 bytes:

param($n)$j=$n;for($c='';$j-ge0;$j--){$c+=$i++}$c[$n]-eq48


答:
C#, <s>87</s> 81 bytes

```<code>int f(string s){int i=0;foreach(var c in s)i=c<43?i*2:c<46?i+44-c:i>>1;return i;}
</code>```

Ungolfed:

```<code>int f(string s)
{
    int i = 0;

    foreach (var c in s)
        i = c < 43 ? i * 2
          : c < 46 ? i + 44 - c
          : i >> 1;

    return i;
}
</code>```

Input is assumed to be valid. Division by two is done by shifting right one bit, because regular division always rounds towards zero, and bit shifting always rounds down. Increment and decrement make handy use of the 1 distance between the ASCII codes for + and -.

Title: Simple integer operation calculator

Body:
C#, <s>87</s> 81 bytes

int f(string s){int i=0;foreach(var c in s)i=c<43?i*2:c<46?i+44-c:i>>1;return i;}

Ungolfed:

int f(string s)
{
    int i = 0;

    foreach (var c in s)
        i = c < 43 ? i * 2
          : c < 46 ? i + 44 - c
          : i >> 1;

    return i;
}

Input is assumed to be valid. Division by two is done by shifting right one bit, because regular division always rounds towards zero, and bit shifting always rounds down. Increment and decrement make handy use of the 1 distance between the ASCII codes for + and -.


答:
Pyth, 23 bytes

```<code>FNQ=Z.v%".&%sZ2_2"N;/Z2
</code>```

A full program that takes input as a string and prints the result.

This is a port of @xnor's Python answer.

Try it online

How it works

```<code>FNQ=Z.v%".&%sZ2_2"N;/Z2   Program. Input: Q. Z initialised as 0
FNQ                       For. For N in Q:
        ".&%sZ2_2"         String. Literal string ".&%sZ2_2"
       %          N        String format. Replace %s with the current operator N
           %sZ2            Operator. Yield Z*2, Z//2, Z+2, Z-2 as appropriate
         .&    _2          Bitwise and. Result of above & -2
     .v                    Evaluate. Yield the result of the expression
   =Z                      Assignment. Assign result of above to Z
                   ;      End. End for loop
                    /Z2   Integer division. Yield Z//2
                          Print. Print the above implicitly
</code>```

Title: Simple integer operation calculator

Body:
Pyth, 23 bytes

FNQ=Z.v%".&%sZ2_2"N;/Z2

A full program that takes input as a string and prints the result.

This is a port of @xnor's Python answer.

Try it online

How it works

FNQ=Z.v%".&%sZ2_2"N;/Z2   Program. Input: Q. Z initialised as 0
FNQ                       For. For N in Q:
        ".&%sZ2_2"         String. Literal string ".&%sZ2_2"
       %          N        String format. Replace %s with the current operator N
           %sZ2            Operator. Yield Z*2, Z//2, Z+2, Z-2 as appropriate
         .&    _2          Bitwise and. Result of above & -2
     .v                    Evaluate. Yield the result of the expression
   =Z                      Assignment. Assign result of above to Z
                   ;      End. End for loop
                    /Z2   Integer division. Yield Z//2
                          Print. Print the above implicitly


答:
C, <s>41</s>, 40 bytes

```<code>main(c){for(c=getchar();putchar(c)&1;);}
</code>```

Reads a single character from stdin, writes to stdout.

This version is 1 byte longer than feersum's solution, but removes his/her assumptions onstdin.

Title: Implement a Truth-Machine

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

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

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

If that number is 1, print out 1 forever.

Challenge

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

take input from STDIN or an acceptable alternative

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

must output to STDOUT or an acceptable alternative

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

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

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

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

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

Catalog

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

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

Body:
C, <s>41</s>, 40 bytes

main(c){for(c=getchar();putchar(c)&1;);}

Reads a single character from stdin, writes to stdout.

This version is 1 byte longer than feersum's solution, but removes his/her assumptions onstdin.


问:
Mathematical Combination
Write a program that takes an input such as:

```<code>n,k
</code>```

which then computes:

$$\binom n k = \frac {n!} {k!(n-k)!}$$

and then prints the result.

A numerical example:

Input:

```<code>5,2
</code>```

Internal computation:

$$\frac {5!} {3!\times2!}$$

Printed Output:

```<code>10
</code>```

I'd like to see an answer that beats my python solution of 65 characters, but all languages are obviously welcome.

Here's my solution:

```<code>n,k=input();f=lambda x:+(x<2)or x*f(x-1);print f(n)/(f(k)*f(n-k))
</code>```

Edit:

I admit that this question is from the codegolf website mathematical combination puzzle.  I know that my answer may look like not much progress can be made on it, but the leaders of this puzzle have solved it in nearly half as many characters.

答:
(The OP only loosely specified the input & output method/format, so the following seems acceptable.)

Sage Notebook (<s>39 41</s> 40)

In the current cell,

```<code>f=lambda n,k:k<1or f(n-1,k-1)*n/k;+f(*_)
</code>```

where the input in the form n,k is entered & evaluated in the preceding cell. This simulates "command-line input" by assigning it to _ (similar to command-line arguments).

Sage Notebook (<s>42 44</s> 43)

Alternatively, using "in-source input" (with only the x= and newline characters adding to the score), e.g.,

```<code>x=5,2
f=lambda n,k:k<1or f(n-1,k-1)*n/k;+f(*x)
</code>```

Both of these approaches are obviously spin-offs from earlier answers by others.

Title: Mathematical Combination

Body:
(The OP only loosely specified the input & output method/format, so the following seems acceptable.)

Sage Notebook (<s>39 41</s> 40)

In the current cell,

f=lambda n,k:k<1or f(n-1,k-1)*n/k;+f(*_)

where the input in the form n,k is entered & evaluated in the preceding cell. This simulates "command-line input" by assigning it to _ (similar to command-line arguments).

Sage Notebook (<s>42 44</s> 43)

Alternatively, using "in-source input" (with only the x= and newline characters adding to the score), e.g.,

x=5,2
f=lambda n,k:k<1or f(n-1,k-1)*n/k;+f(*x)

Both of these approaches are obviously spin-offs from earlier answers by others.


答:
R, 61 57 bytes

Thanks to @plannapus for 4 bytes.

```<code>n=scan();strsplit(paste(0:n,collapse=""),"")[[1]][n+1]==0
</code>```

Creates a vector of numbers 0:n (for 0 indexing), creates a string of them, pulls the nth value from string (adjusting for 0 indexing). Converts to numeric and tests if it is 0.

Title: Where are Champernowne's zeroes?

Body:
R, 61 57 bytes

Thanks to @plannapus for 4 bytes.

n=scan();strsplit(paste(0:n,collapse=""),"")[[1]][n+1]==0

Creates a vector of numbers 0:n (for 0 indexing), creates a string of them, pulls the nth value from string (adjusting for 0 indexing). Converts to numeric and tests if it is 0.