问:
Four is the magic number
I didn't check the sandbox before posting this challenge - it looks like this challenge was proposed by Cᴏɴᴏʀ O'Bʀɪᴇɴ.

Given an integer input, write a program that prints the "four is a magic number" riddle

Four is the magic number

Five is four and four is the magic number

Six is three and three is five and five is four and four is the magic number

Eleven is six and six is three and three is five and five is four and four is the magic number

Five Hundred is eleven and eleven is six and six is three and three is five and five is four and four is the magic number

If you already know the riddle, or are too <s>lazy to solve it</s> anxious to find out what the riddle is, here's an explanation

 The next number is the number of letters in the previous number. So, for example, five has four letters, so the next number is four.

 six has three letters, so the next number is 3, and three has five letters, so the next number is 5, and five has four letters, so the next number is 4

 The reason the riddle ends at four is because four has four letters, and four is four and four is four and four is four... (four is the magic number)

Test Cases

```<code>0 =>
  Zero is four and four is the magic number
1 =>
  One is three and three is five and five is four and four is the magic number
2 =>
  Two is three and three is five and five is four and four is the magic number
3 =>
  Three is five and five is four and four is the magic number
4 =>
  Four is the magic number
5 =>
  Five is four and four is the magic number
6 =>
  Six is three and three is five and five is four and four is the magic number
7 =>
  Seven is five and five is four and four is the magic number
8 =>
  Eight is five and five is four and four is the magic number
9 =>
  Nine is four and four is the magic number
10 =>
  Ten is three and three is five and five is four and four is the magic number
17 =>
  Seventeen is nine and nine is four and four is the magic number
100 =>
  One Hundred is ten and ten is three and three is five and five is four and four is the magic number
142 =>
  One Hundred Forty Two is eighteen and eighteen is eight and eight is five and five is four and four is the magic number
1,000 =>
  One Thousand is eleven and eleven is six and six is three and three is five and five is four and four is the magic number
1,642 =>
  One Thousand Six Hundred Forty Two is twenty nine and twenty nine is ten and ten is three and three is five and five is four and four is the magic number
70,000 =>
  Seventy Thousand is fifteen and fifteen is seven and seven is five and five is four and four is the magic number
131,072 =>
  One Hundred Thirty One Thousand Seventy Two is thirty seven and thirty seven is eleven and eleven is six and six is three and three is five and five is four and four is the magic number
999,999 =>
  Nine Hundred Ninety Nine Thousand Nine Hundred Ninety Nine is fifty and fifty is five and five is four and four is the magic number
</code>```

Rules

The input may either be taken from STDIN or as an argument to a function

The input will be a positive number between 0 and 999,999

The input will only contain numbers (it will follow the regex ^[0-9]+$)

The input can either be taken as an integer or a string

When converted to a word string, spaces and hyphens should not be included in the count (100 [One Hundred] is 10 characters, not 11. 1,742 [One thousand Seven hundred Forty-Two] is 31 characters, not 36)

When converted to a string, 100 should be One Hundred, not A Hundred or Hundred, 1000 should be One Thousand, not A Thousand or Thousand.

When converted to a string 142 should be One Hundred Forty Two, not One Hundred and Forty Two

The output is case-insensitive, and should follow the format "N is K and K is M and M is ... and four is the magic number" (unless the input is 4, in which case the output should simply be "four is the magic number")

The output can use numbers instead of letters ("5 is 4 and 4 is the magic number" instead of "five is four and four is the magic number") as long as your program is always consistent

The output can either be the return value of a function, or printed to STDOUT

Standard loopholes apply

This is code-golf, so the shortest program in bytes wins. Good luck!

Bonus

-30 bytes if the program works when the input is between -999,999 and 999,999.

Negative numbers, when converted to words, just have "negative" in front of them. For example -4 is "Negative Four", Negative Four is twelve and twelve is six and six is three and three is five and five is four and four is the magic number

-150 bytes if the program does not use any built-in functions for generating the string representation of the number

Leaderboard

This is a Stack Snippet that generates both a leaderboard and an overview of winners by language.

To ensure 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, in bytes, of your submission

If you want to include multiple numbers in your header (for example, striking through old scores, or including flags in the byte count), just make sure that the actual score is the last number in your header

```<code>## Language Name, <s>K</s> X + 2 = N bytes
</code>```

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
JavaScript, 382 - 150 - 30 = 202 bytes

```<code>var o=[0,3,3,5,4,4,3,5,5,4],f=s=>(s[1]==1?[3,6,6,8,8,7,7,9,8,8][s[0]]:o[s[0]]+(s.length>1?[0,3,6,6,5,5,5,7,6,6][s[1]]:0))+(s.length==3?(7+o[s[2]]-(o[s[2]]==0?7:0)):0),l=n=>{var s=(""+n).split("").reverse();return f(s.slice(0,3))+(s.length>3?(f(s.slice(3,6))+8):0)};(n=>{var s="";while(n!=4){s+=n+" is ";n=n>=0?l(n):(l(-n)+8);s+=n+" and ";}console.log(s+"4 is the magic number");})()
</code>```

The input is given as the parameter to the Immediately-Invoked Function Expression.

Test input:

```<code>999999 ->
    999999 is 50 and 50 is 5 and 5 is 4 and 4 is the magic number
17 ->
    17  is 9 and 9 is 4 and 4 is the magic number
-404 ->
    -404 is 23 and 23 is 11 and 11 is 6 and 6 is 3 and 3 is 5 and 5 is 4 and 4 is the magic number
</code>```

De-golfed:

```<code>// array of the lengths of digits in ones place:
// one is 3, two is 3, three is 5, etc... zero is a special case
// and is assigned zero length because zero is never written out in a number name
var o=[0,3,3,5,4,4,3,5,5,4],

// function that computes the length of a substring of the input
// because the input is 6 digits, it can be broken into two 3 digit subsections
// each of which can have it's length calculated separately
f=s=>
  (
  s[1]==1? // check for if the tens digit is a one
    // when the tens is a one, pull the string length from an array that represents
    // ten, eleven, twelve, thirteen, etc...
    [3,6,6,8,8,7,7,9,8,8][s[0]]
  :
    // when the tens digit is not a one, add the ones digit normally and...
    o[s[0]]
    +
    // add the tens digit length from the array that represents
    // zero, ten, twenty, thirty, forty, fifty, sixty, seventy, eighty, ninety
    (s.length>1?[0,3,6,6,5,5,5,7,6,6][s[1]]:0)
  )
  +
  (
  s.length==3? // check if the length is 3 and weren't not accidentally trying to do something wierd with a minus sign
    // if so, then we have to add a hundred (7 characters) to the length and the
    // length of the ones digit that is in the hundreds place like
    // 'one' hundred or 'two' hundred
    (7+o[s[2]]-
      (
        // also, if the hundreds place was a zero, subtract out those 7 characters
        // that were added because 'hundred' isn't added if there's a zero in its
        // place
        o[s[2]]==0?
          7
        :
          0
      )
    )
  :
    // if the length wasn't 3, then don't add anything for the hundred
    0
  ),

// function that computes the length of the whole six digit number
l=n=>{
  // coerce the number into a string and then reverse the string so that the
  // ones digit is the zeroth element instead of last element
  var s=(""+n).split("").reverse();
  return
    // calculate the character length of the first 3 characters
    // like in the number 999888, this does the '888'
    f(s.slice(0,3))
    +
    // then if there actually are any characters after the first 3
    (s.length>3?
        // parse the character length of the second 3 characters
        (f(s.slice(3,6))+8)
      :
        0
    )
};
// lastly is the Immediately-Invoked Function Expression
(n=>{
  var s="";
  // as long as we haven't reached four, just keep going through the loop
  while(n!=4){
    s+=n+" is ";
    n=n>=0?l(n):(l(-n)+8) // this handles negatives by only passing positive values to l and then just adding 8 onto the length for negatives
    s+=n+" and ";
  }
  // finally just say that '4 is the magic number'
  console.log(s+"4 is the magic number");
})(999999)
</code>```

Title: Four is the magic number

Body:
JavaScript, 382 - 150 - 30 = 202 bytes

var o=[0,3,3,5,4,4,3,5,5,4],f=s=>(s[1]==1?[3,6,6,8,8,7,7,9,8,8][s[0]]:o[s[0]]+(s.length>1?[0,3,6,6,5,5,5,7,6,6][s[1]]:0))+(s.length==3?(7+o[s[2]]-(o[s[2]]==0?7:0)):0),l=n=>{var s=(""+n).split("").reverse();return f(s.slice(0,3))+(s.length>3?(f(s.slice(3,6))+8):0)};(n=>{var s="";while(n!=4){s+=n+" is ";n=n>=0?l(n):(l(-n)+8);s+=n+" and ";}console.log(s+"4 is the magic number");})()

The input is given as the parameter to the Immediately-Invoked Function Expression.

Test input:

999999 ->
    999999 is 50 and 50 is 5 and 5 is 4 and 4 is the magic number
17 ->
    17  is 9 and 9 is 4 and 4 is the magic number
-404 ->
    -404 is 23 and 23 is 11 and 11 is 6 and 6 is 3 and 3 is 5 and 5 is 4 and 4 is the magic number

De-golfed:

// array of the lengths of digits in ones place:
// one is 3, two is 3, three is 5, etc... zero is a special case
// and is assigned zero length because zero is never written out in a number name
var o=[0,3,3,5,4,4,3,5,5,4],

// function that computes the length of a substring of the input
// because the input is 6 digits, it can be broken into two 3 digit subsections
// each of which can have it's length calculated separately
f=s=>
  (
  s[1]==1? // check for if the tens digit is a one
    // when the tens is a one, pull the string length from an array that represents
    // ten, eleven, twelve, thirteen, etc...
    [3,6,6,8,8,7,7,9,8,8][s[0]]
  :
    // when the tens digit is not a one, add the ones digit normally and...
    o[s[0]]
    +
    // add the tens digit length from the array that represents
    // zero, ten, twenty, thirty, forty, fifty, sixty, seventy, eighty, ninety
    (s.length>1?[0,3,6,6,5,5,5,7,6,6][s[1]]:0)
  )
  +
  (
  s.length==3? // check if the length is 3 and weren't not accidentally trying to do something wierd with a minus sign
    // if so, then we have to add a hundred (7 characters) to the length and the
    // length of the ones digit that is in the hundreds place like
    // 'one' hundred or 'two' hundred
    (7+o[s[2]]-
      (
        // also, if the hundreds place was a zero, subtract out those 7 characters
        // that were added because 'hundred' isn't added if there's a zero in its
        // place
        o[s[2]]==0?
          7
        :
          0
      )
    )
  :
    // if the length wasn't 3, then don't add anything for the hundred
    0
  ),

// function that computes the length of the whole six digit number
l=n=>{
  // coerce the number into a string and then reverse the string so that the
  // ones digit is the zeroth element instead of last element
  var s=(""+n).split("").reverse();
  return
    // calculate the character length of the first 3 characters
    // like in the number 999888, this does the '888'
    f(s.slice(0,3))
    +
    // then if there actually are any characters after the first 3
    (s.length>3?
        // parse the character length of the second 3 characters
        (f(s.slice(3,6))+8)
      :
        0
    )
};
// lastly is the Immediately-Invoked Function Expression
(n=>{
  var s="";
  // as long as we haven't reached four, just keep going through the loop
  while(n!=4){
    s+=n+" is ";
    n=n>=0?l(n):(l(-n)+8) // this handles negatives by only passing positive values to l and then just adding 8 onto the length for negatives
    s+=n+" and ";
  }
  // finally just say that '4 is the magic number'
  console.log(s+"4 is the magic number");
})(999999)


问:
Gear Train, Rotating
Gears transfer different amount of speeds, depending on the size of the meshed gear.

Jack has a machine, that rotates a Gear Train. but you don't know the speed of the last gear.

Luckily, You are a great code golfer, so you can help him!

So, What should I do?

Each gear is represented by 2 numbers, the radius of the inner gear and the radius of the outer gears.

If gear A is [a,b] and gear B is [c,d], then the ratio between the speed of A and the speed of B would be c:b.

Given a list of gears (list of 2-tuples), output the speed of the last gear.

You can assume the speed of the first gear is 1.

Worked out example

Let's say our input is [[6,12],[3,10],[5,8]].

The first gear, [6,12], would have a speed of 1.

Then, the second gear, [3,10], would have a speed of 1*12/3 = 4.

Then, the last gear, [5,8], would have a speed of 4*10/5 = 8.

Testcases

```<code>input                    output
[[1,1],[2,2]]            0.5     (1/2)
[[1,2],[1,2],[1,2]]      4       (2/1*2/1)
[[6,12],[3,10],[5,8]]    8       (12/3*10/5)
</code>```

Rules

Basic code-golf rules apply.

答:
Pyth, 8 bytes

```<code>.UcZb_Pt
</code>```

Test suite.

ContentLicense: CC BY-SA 3.0

Title: Gear Train, Rotating

Body:
Pyth, 8 bytes

.UcZb_Pt

Test suite.


问:
Divisibility test

Task

Given two strictly positive integers n and d as input, determine whether n is evenly divisible by d, i.e., if there exists an integer q such that n = qd.

You may write a program or a function and use any of the our standard methods of receiving input and providing output.

The output should be a truthy or a falsy value; truthy if n is divisible by d, and falsy otherwise.

Your code only has to handle integers it can represent natively, as long as it works for all signed 8-bit integers. However, your algorithm has to work for arbitrarily large integers.

You may use any programming language, but note that these loopholes are forbidden by default.

This is code-golf, so the shortest valid answer – measured in bytes – wins.

Test cases

```<code> n,  d    output

 1,  1    truthy
 2,  1    truthy
 6,  3    truthy
17, 17    truthy
22,  2    truthy
 1,  2    falsy
 2,  3    falsy
 2,  4    falsy
 3,  9    falsy
15, 16    falsy
</code>```

Leaderboard

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

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

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

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

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

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

```<code>## Perl, 43 + 3 (-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

```

答:
Batch, 27 bytes

for /l %a IN (1,1,10)DO @%a

Does
' is not recognized as an internal or external command, operable program or batch file.'
count as a separator?

Title: Divisibility test


答:
Jelly, 7 bytes

```<code>U÷Ḣµ2\P
</code>```

Try it online! or verify all test cases.

Title: Gear Train, Rotating

Body:
Gears transfer different amount of speeds, depending on the size of the meshed gear.

Jack has a machine, that rotates a Gear Train. but you don't know the speed of the last gear.

Luckily, You are a great code golfer, so you can help him!

So, What should I do?

Each gear is represented by 2 numbers, the radius of the inner gear and the radius of the outer gears.

If gear A is [a,b] and gear B is [c,d], then the ratio between the speed of A and the speed of B would be c:b.

Given a list of gears (list of 2-tuples), output the speed of the last gear.

You can assume the speed of the first gear is 1.

Worked out example

Let's say our input is [[6,12],[3,10],[5,8]].

The first gear, [6,12], would have a speed of 1.

Then, the second gear, [3,10], would have a speed of 1*12/3 = 4.

Then, the last gear, [5,8], would have a speed of 4*10/5 = 8.

Testcases

```<code>input                    output
[[1,1],[2,2]]            0.5     (1/2)
[[1,2],[1,2],[1,2]]      4       (2/1*2/1)
[[6,12],[3,10],[5,8]]    8       (12/3*10/5)
</code>```

Rules

Basic code-golf rules apply.

Body:
Jelly, 7 bytes

U÷Ḣµ2\P

Try it online! or verify all test cases.


问:
Score a game of Bowling
Your task is to sum up and output one player's score in a game of 10-pin bowling after up to 21 rolls.

The rolls are represented as a sequence of integers in your preferred method of input.
Each integer corresponds to the number of pins that were knocked down in that roll.

Scoring

After each round the number of pins knocked down in that round is counted into the final score.
If a player knocks down all ten pins in the first roll of a round, this is a strike, and the round is over.
Otherwise, the round lasts for one more roll. If the second roll of a round knocks down all the remaining pins, this is a spare.

For each strike there is a bonus equal to the sum of pins knocked down in the two next rolls.
For each spare there is a bonus equal to the number of pins knocked down in the next roll.

The 10th and final round, the player may be granted extra rolls:
In case of a strike, the player gets two more rolls to make up his strike bonus.
In case of a spare, the player gets one more roll.

Examples

```<code>Input: 4 3 8 2 7 1 10 7 3 0 10 2 2 10 10 5 4
Output: 131

Input: 10 10 9 1 7 3 2 7 10 1 9 10 7 1 10 10 10
Output: 183
</code>```

Rules

You may assumed that the input is valid.

As per Mego's comment I have loosened the requirements for the input/output methods to meet our current standard.

Answers in languages that are newer than the challenge are allowed

Shortest code wins!

答:
CoffeeScript (234 215 170)

```<code>z=(a)->b=(Number i for i in a.split(' ').reverse());t=0;(r=b.pop();l=b.length;if(9<r)then(t+=r;t+=b[l-1]+b[l-2];)else(f=r+b.pop();t+=f;(t+=b[l-2])if 9<f))for i in[0..9];t
</code>```

EDIT: A hefty re-write, shamelessly plagiarising Howard's great stack-based approach. I'm confident more can be stripped out for accessing the last element of an array without destroying it...

ContentLicense: CC BY-SA 4.0

Title: Score a game of Bowling

Body:
CoffeeScript (234 215 170)

z=(a)->b=(Number i for i in a.split(' ').reverse());t=0;(r=b.pop();l=b.length;if(9<r)then(t+=r;t+=b[l-1]+b[l-2];)else(f=r+b.pop();t+=f;(t+=b[l-2])if 9<f))for i in[0..9];t

EDIT: A hefty re-write, shamelessly plagiarising Howard's great stack-based approach. I'm confident more can be stripped out for accessing the last element of an array without destroying it...


答:
Jelly, 6 bytes

```<code>ḊṖU÷@/
</code>```

Test suite.

```<code>ḊṖU÷@/   Main monadic chain. temp <- third argument (first input)
Ḋ        temp <- temp with first element removed
 Ṗ       temp <- temp with last element removed
  U      temp <- temp reversed
   ÷@/   temp <- temp reduced by reversed floating-point division.
         implicitly output temp.
</code>```

Title: Gear Train, Rotating

Body:
Jelly, 6 bytes

ḊṖU÷@/

Test suite.

ḊṖU÷@/   Main monadic chain. temp <- third argument (first input)
Ḋ        temp <- temp with first element removed
 Ṗ       temp <- temp with last element removed
  U      temp <- temp reversed
   ÷@/   temp <- temp reduced by reversed floating-point division.
         implicitly output temp.


问:
Showcase of Languages

Notes

This thread is open and unlocked only because the community decided to make an exception. Please do not use this question as evidence that you can ask similar questions here. Please do not create additional showcase questions.

This is no longer a popularity-contest, nor are snippet lengths limited by the vote tally. If you know this thread from before, please make sure you familiarize yourself with the changes.

This thread is dedicated to showing off interesting, useful, obscure, and/or unique features your favorite programming languages have to offer. This is neither a challenge nor a competition, but a collaboration effort to showcase as many programming languages as possible as well as possible.

How this works

All answers should include the name of the programming language at the top of the post, prefixed by a #.

Answers may contain one (and only one) factoid, i.e., a couple of sentences without code that describe the language.

Aside from the factoid, answers should consist of snippets of code, which can (but don't have to be) programs or functions.

The snippets do not need to be related. In fact, snippets that are too related may be redundant.

Since this is not a contest, all programming languages are welcome, whenever they were created.

Answers that contain more than a handful of code snippets should use a Stack Snippet to collapse everything except the factoid and one of the snippets.

Whenever possible, there should be only one answer per programming language. This is a community wiki, so feel free to add snippets to any answer, even if you haven't created it yourself. There is a Stack Snippet for compressing posts, which should mitigate the effect of the 30,000 character limit.

Answers that predate these guidelines should be edited. Please help updating them as needed.

Current answers, sorted alphabetically by language name

$.ajax({type:"GET",url:"https://api.stackexchange.com/2.2/questions/44680/answers?site=codegolf&filter=withbody",success:function(data){for(var i=0;i<data.items.length;i++){var temp=document.createElement('p');temp.innerHTML = data.items[i].body.split("\n")[0];$('#list').append('
' + temp.innerText || temp.textContent + '');}}})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><base href="http://codegolf.stackexchange.com"><ul id="list"></ul></code>```

答:
StackyLogic

Factoid:

StackyLogic is originially from a codegolf challenge, as seen in the link. It consists of a series of "stacks", however there are no "push" operations.

Length 1 Snippet

<

This is not a full program at all. This is just the pointer symbol. This symbol denotes where the pointer starts

Length 2 Snippet

```<code>?<
</code>```

This program takes a bit of input, and outputs it. It would be a cat program, if it looped, however Stackylogic possesses no loops.

First, the program will substitute the ? for either a 1 or 0, depending on input. Then, it will execute this command. 1 will make the pointer move down one, 0 will make it move up one. Then, upon discovering the empty stack (which are always implicitly exist), it will halt, and output the last executed command, either a 1, or 0

Length 3 Snippet

```<code>?1<
</code>```

This program always outputs one, the ? is never used. This is because, as stated in the previous snippet, 1 will move the pointer down one, and the implicit empty stack will cause the last executed command to be printed. the  ? isn't used, because the pointer is never directed to it.

Length 4 Snippet

```<code>?
?<
</code>```

Our first program with multiple non-empty stacks.

This program outputs the result of an OR operation on two bits.

How it works:

It first substitutes the ? under the pointer with a bit from input, and executes it. If it is a 1, it will go forward, find the empty stack, halt and print 1.

```<code>?<
</code>```

If it is a zero, it will go up one, and act like the above code: it will substitute the ? for a bit, execute it, and then move onto an empty stack and output it.

Note how the code after the first ? is executed is the same as snippet 2

Length 5 snippet

```<code>1
??<
</code>```

This program, like the last program, outputs the OR of two bits. However, the ?s are on the same line. if the first bit is one, it will move forward on to an empty stack, output 1, if it is a 0, it will move back one, on to the one, and then move forward back on to the second ?, again being identical to the length 2 snippet. This illustrates how multiple programs can have the same effect. You might have noticed that no new language features have been introduced this time. This is because they have all been introduced.

Length 6 Snippet

```<code>1
?<
0
</code>```

This program outputs the not of one bit (the opposite of snippet 2). You might, by now, think that StackyLogic is really boring, and can't do anything interesting. This isn't (entirely) true. It can be used for more interesting things, it just takes A LOT of characters. However, even after these lots of characters, it is not capable of much computation, it cannot even store the input, most challenges are closed out to it (in fact, the linked example actually checks which year it is, if it divisible by 4, to see if it is a special case (not a leap year))

Length 7 Snippet

```<code>?<
?1
?
</code>```

This program "nests" an OR in a surrounding program. I say it nests it, because if the first bit is 1, it changes to be the exact same as the OR, and executes the same things. This program is (x AND (y OR z))

I don't really know anymore decent snippets, there isn't much more to show. I plan on making another answer with my derivative, Eseljik, after I actually make the interpreter, but before that decide on the final part of the spec. Anyway, there are a lot more commands in Eseljik, so I shouldn't easily run out of things to show, like I have here.

Title: Showcase of Languages

Body:
StackyLogic

Factoid:

StackyLogic is originially from a codegolf challenge, as seen in the link. It consists of a series of "stacks", however there are no "push" operations.

Length 1 Snippet

<

This is not a full program at all. This is just the pointer symbol. This symbol denotes where the pointer starts

Length 2 Snippet

?<

This program takes a bit of input, and outputs it. It would be a cat program, if it looped, however Stackylogic possesses no loops.

First, the program will substitute the ? for either a 1 or 0, depending on input. Then, it will execute this command. 1 will make the pointer move down one, 0 will make it move up one. Then, upon discovering the empty stack (which are always implicitly exist), it will halt, and output the last executed command, either a 1, or 0

Length 3 Snippet

?1<

This program always outputs one, the ? is never used. This is because, as stated in the previous snippet, 1 will move the pointer down one, and the implicit empty stack will cause the last executed command to be printed. the  ? isn't used, because the pointer is never directed to it.

Length 4 Snippet

?
?<

Our first program with multiple non-empty stacks.

This program outputs the result of an OR operation on two bits.

How it works:

It first substitutes the ? under the pointer with a bit from input, and executes it. If it is a 1, it will go forward, find the empty stack, halt and print 1.

?<

If it is a zero, it will go up one, and act like the above code: it will substitute the ? for a bit, execute it, and then move onto an empty stack and output it.

Note how the code after the first ? is executed is the same as snippet 2

Length 5 snippet

1
??<

This program, like the last program, outputs the OR of two bits. However, the ?s are on the same line. if the first bit is one, it will move forward on to an empty stack, output 1, if it is a 0, it will move back one, on to the one, and then move forward back on to the second ?, again being identical to the length 2 snippet. This illustrates how multiple programs can have the same effect. You might have noticed that no new language features have been introduced this time. This is because they have all been introduced.

Length 6 Snippet

1
?<
0

This program outputs the not of one bit (the opposite of snippet 2). You might, by now, think that StackyLogic is really boring, and can't do anything interesting. This isn't (entirely) true. It can be used for more interesting things, it just takes A LOT of characters. However, even after these lots of characters, it is not capable of much computation, it cannot even store the input, most challenges are closed out to it (in fact, the linked example actually checks which year it is, if it divisible by 4, to see if it is a special case (not a leap year))

Length 7 Snippet

?<
?1
?

This program "nests" an OR in a surrounding program. I say it nests it, because if the first bit is 1, it changes to be the exact same as the OR, and executes the same things. This program is (x AND (y OR z))

I don't really know anymore decent snippets, there isn't much more to show. I plan on making another answer with my derivative, Eseljik, after I actually make the interpreter, but before that decide on the final part of the spec. Anyway, there are a lot more commands in Eseljik, so I shouldn't easily run out of things to show, like I have here.


答:
J, 8 bytes

```<code>%/@}:@}.
</code>```

Try it online!

Usage

```<code>>> f =: %/@}:@}.

>> f 1 1 2 2
<< 0.5

>> f 1 2 1 2 1 2
<< 4

>> f 6 12 3 10 5 8
<< 8
</code>```

where >> is STDIN and << is STDOUT.

Explanation

"Reduce" in J defaults from right to left, which took off a few bytes :p

```<code>divide       =: %
reduce       =: /
atop         =: @
remove_first =: }.
remove_last  =: }:

f =: (divide reduce) atop (remove_last) atop (remove_first)
</code>```

Title: Gear Train, Rotating

Body:
J, 8 bytes

%/@}:@}.

Try it online!

Usage

>> f =: %/@}:@}.

>> f 1 1 2 2
<< 0.5

>> f 1 2 1 2 1 2
<< 4

>> f 6 12 3 10 5 8
<< 8

where >> is STDIN and << is STDOUT.

Explanation

"Reduce" in J defaults from right to left, which took off a few bytes :p

divide       =: %
reduce       =: /
atop         =: @
remove_first =: }.
remove_last  =: }:

f =: (divide reduce) atop (remove_last) atop (remove_first)


答:
Haskell, 19 bytes

foldr1(/).tail.init
```

Given a flat list like [a,b,c,d,e,f], tail.init removes the first and last elements, and then foldr1(/) creates a cascade of divisions b/(c/(d/e)))) that works out to alternating * and /: b/c*d/e.

Title: Gear Train, Rotating

Body:
Haskell, 19 bytes

foldr1(/).tail.init

Given a flat list like [a,b,c,d,e,f], tail.init removes the first and last elements, and then foldr1(/) creates a cascade of divisions b/(c/(d/e)))) that works out to alternating * and /: b/c*d/e.


答:
x86_32 machine code, 8 bytes

```<code>08048550 <div7>:
 8048550:   99                      cdq
 8048551:   f7 f9                   idiv   %ecx
 8048553:   85 d2                   test   %edx,%edx
 8048555:   0f 94 c0                sete   %al
</code>```

This is my first code golf answer, so hopefully I'm following all the rules.

This first calls cdq to clear out the edx register, then performs signed division on the ecx register, which stores the remainder in edx. The test edx, edx line will set the zero flag if edx is zero, and sete puts a 0 for false if edx was not zero, and puts a 1 for true if edx was 0.

This is just the code snippet that contributes to the byte count, but for testing, here is the C code I wrote with the inline assembly because it's easier this way to handle I/O.

Title: Divisibility test

Body:
Task

Given two strictly positive integers n and d as input, determine whether n is evenly divisible by d, i.e., if there exists an integer q such that n = qd.

You may write a program or a function and use any of the our standard methods of receiving input and providing output.

The output should be a truthy or a falsy value; truthy if n is divisible by d, and falsy otherwise.

Your code only has to handle integers it can represent natively, as long as it works for all signed 8-bit integers. However, your algorithm has to work for arbitrarily large integers.

You may use any programming language, but note that these loopholes are forbidden by default.

This is code-golf, so the shortest valid answer – measured in bytes – wins.

Test cases

```<code> n,  d    output

 1,  1    truthy
 2,  1    truthy
 6,  3    truthy
17, 17    truthy
22,  2    truthy
 1,  2    falsy
 2,  3    falsy
 2,  4    falsy
 3,  9    falsy
15, 16    falsy
</code>```

Leaderboard

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

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

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

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

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

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

```<code>## Perl, 43 + 3 (-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:
x86_32 machine code, 8 bytes

08048550 <div7>:
 8048550:   99                      cdq
 8048551:   f7 f9                   idiv   %ecx
 8048553:   85 d2                   test   %edx,%edx
 8048555:   0f 94 c0                sete   %al

This is my first code golf answer, so hopefully I'm following all the rules.

This first calls cdq to clear out the edx register, then performs signed division on the ecx register, which stores the remainder in edx. The test edx, edx line will set the zero flag if edx is zero, and sete puts a 0 for false if edx was not zero, and puts a 1 for true if edx was 0.

This is just the code snippet that contributes to the byte count, but for testing, here is the C code I wrote with the inline assembly because it's easier this way to handle I/O.


答:
QBIC

I'm trying to teach QuickBasic to do codegolf (and myself in the process), so I'm creating the language Quick Basic Interpreter for Codegolf, or QBIC for short.

0 byte factoid

Most of QBIC's strength lies in just making a shorthand for QBasic's expansive syntax, but I've also incorporated several features of my own. When generating the trans-compiled BAS file, a standard header is imported that implements some of these features. For instance, the numbers 1 through 10 get initialised as variables q through z. This occasionally saves me some bytes when initialising a FOR loop, and shaves a byte off of using 10.

1 byte

```<code>}
</code>```

The above statement will do ... exactly nothing. When found in the QBIC code, it wil automatically add END IF's, NEXTs and LOOPs for every opened IF/FOR/DO construct it finds (in the correct order, naturally). Note that ] does the same for one language construct, where } closes all opened constructs.

However, since we've not yet opened any of those constructs, this does nothing and results in an 'empty' Qbasic BAS file. Also, at the end of compiling QBIC, the compiler will run this statement automatically.

2 bytes

```<code>?z
</code>```

This will write 10 on the screen. In QBIC, the letters of the lower-case alphabet are references to numerical variables. This is retained from QBasic, where PRINT a would give me a 0 on the screen (even without ever defining a). In addition, QBIC initialises q-z to be 1 through 10 by default. The ? is obviously shorthand for the PRINT statement and writes to screen.

3 bytes

```<code>_Xb
</code>```

_X can be used to terminate a program, and when used with a suffix, it will print something on exit. Suffixes can be A-Z (which refers to string variables A$ - Z$) or lowercase a-z (for the numerical vars of this name). The example snippet ends the program, and prints variable b to screen before it turns off the lights.

4 bytes

```<code>?_r|
</code>```

_r is a random number generator. By itself, it will generate a random number between 0 and 10 and, in this case, print it. We can also add one or two parameters for a different lower and upper bound; If only one is specified, that's our new upper bound.

_r20| will generate a number between 0 and 20.

_r5,18| will generate a number between 5 and 18.
The statement _R is equivalent to _r with one exception: _R assigns to a variable, _r does not:

```<code>?_r|    PRINT getNextRandomNumber(0, 10)
_R|?a   a = getNextRandomNumber(0, 10) : PRINT a
</code>```

5 bytes

```<code>:_Ra|
</code>```

The above snippet introduces the :, which reads the first unread command line parameter and assigns it to the first available numeric var. The resulting QBasic code for this snippet is:

```<code>a = assignCMDToNum!
b = getRandomNumber(0, a)
</code>```

There's also ;, which does the same for string variables.

6 bytes

```<code>?!z$+A
</code>```

Here, we see a cast in action. QBasic is kinda picky when it comes to data types. Adding a string to an integer will result in errors. To work around this, I've added a casting function. The above snippet will print 10 (z is auto-initialised to 10) and append whatever is in the variable A$. For instance, a full program could be

```<code>#test`?!z$+A
</code>```

and the result then is 10test.

Casting is done using the ! symbol. It then casts everything between the ! and the delimiter. Usually | is the delimiter for variable-length arguments, but CAST uses either a $ to perform the cast from number to string, or another ! to cast a string to number.

7 bytes

```<code>Z=_f_tA
</code>```

Lot going on here. Let's work on the assumption that A$ already holds a value, say "  Hello  " (significant spaces). This snippet then sets Z$ to the reversed (_f), trimmed (_t) version of A$, olleH and prints it to the screen.

The behaviour between _f and _F is different: _F declares a variable and assigns its output to it, _f only gives the output and assigning is done by other parts of the script. The same goes for _r in my 5-byte snippet. This is called ULX, or Upper-Lowercase Extension. Whether or not output gets auto-assigned is one of the behavioural changes ULX can bring, but there are other examples. _D, for intance, yields the system date, _d yelds system time. Both don't auto-assign.

_t removes the whitespace on both sides of its argument. _u does a left-trim, _v does right-trim. All three support ULX, and for all three this switches between auto-assign (uppercase) or output only (lowercase).

Both _f and _t should be delimited with | to signify the end of the parameter list. However, since EOF is reached, the correct number of |'s get added to close all opened parameter lists. If this statement would have been followed by the closing commands for language constructs (]or }, see byte 1) those same |'s would get added.

QBIC allows for the result of one function to be the input for the next: _f takes as input the result of _t

Finally, if we would run this program, it would actually print olleH, despite we never use a ? or _X* statement. This is because QBIC implicitly prints the contents of Z$ on exit.

Summarizing, the above 7-byte snippet would roughly compile into this QBasic block:

```<code>?z
</code>```0

8 bytes

Let's look at literals. There are 2 types in QBIC: String literals (Verbal and Silent) and Code Literals. They are started with @, # and ' respectively, are terminated with ```. Using a <code>┘</code> respresents a line-break.</p>

```?z
```1

Title: Showcase of Languages

Body:
Notes

This thread is open and unlocked only because the community decided to make an exception. Please do not use this question as evidence that you can ask similar questions here. Please do not create additional showcase questions.

This is no longer a popularity-contest, nor are snippet lengths limited by the vote tally. If you know this thread from before, please make sure you familiarize yourself with the changes.

This thread is dedicated to showing off interesting, useful, obscure, and/or unique features your favorite programming languages have to offer. This is neither a challenge nor a competition, but a collaboration effort to showcase as many programming languages as possible as well as possible.

How this works

All answers should include the name of the programming language at the top of the post, prefixed by a #.

Answers may contain one (and only one) factoid, i.e., a couple of sentences without code that describe the language.

Aside from the factoid, answers should consist of snippets of code, which can (but don't have to be) programs or functions.

The snippets do not need to be related. In fact, snippets that are too related may be redundant.

Since this is not a contest, all programming languages are welcome, whenever they were created.

Answers that contain more than a handful of code snippets should use a Stack Snippet to collapse everything except the factoid and one of the snippets.

Whenever possible, there should be only one answer per programming language. This is a community wiki, so feel free to add snippets to any answer, even if you haven't created it yourself. There is a Stack Snippet for compressing posts, which should mitigate the effect of the 30,000 character limit.

Answers that predate these guidelines should be edited. Please help updating them as needed.

Current answers, sorted alphabetically by language name

$.ajax({type:"GET",url:"https://api.stackexchange.com/2.2/questions/44680/answers?site=codegolf&filter=withbody",success:function(data){for(var i=0;i<data.items.length;i++){var temp=document.createElement('p');temp.innerHTML = data.items[i].body.split("\n")[0];$('#list').append('
' + temp.innerText || temp.textContent + '');}}})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><base href="http://codegolf.stackexchange.com"><ul id="list"></ul></code>```

Body:
QBIC

I'm trying to teach QuickBasic to do codegolf (and myself in the process), so I'm creating the language Quick Basic Interpreter for Codegolf, or QBIC for short.

0 byte factoid

Most of QBIC's strength lies in just making a shorthand for QBasic's expansive syntax, but I've also incorporated several features of my own. When generating the trans-compiled BAS file, a standard header is imported that implements some of these features. For instance, the numbers 1 through 10 get initialised as variables q through z. This occasionally saves me some bytes when initialising a FOR loop, and shaves a byte off of using 10.

1 byte

}

The above statement will do ... exactly nothing. When found in the QBIC code, it wil automatically add END IF's, NEXTs and LOOPs for every opened IF/FOR/DO construct it finds (in the correct order, naturally). Note that ] does the same for one language construct, where } closes all opened constructs.

However, since we've not yet opened any of those constructs, this does nothing and results in an 'empty' Qbasic BAS file. Also, at the end of compiling QBIC, the compiler will run this statement automatically.

2 bytes

?z

This will write 10 on the screen. In QBIC, the letters of the lower-case alphabet are references to numerical variables. This is retained from QBasic, where PRINT a would give me a 0 on the screen (even without ever defining a). In addition, QBIC initialises q-z to be 1 through 10 by default. The ? is obviously shorthand for the PRINT statement and writes to screen.

3 bytes

_Xb

_X can be used to terminate a program, and when used with a suffix, it will print something on exit. Suffixes can be A-Z (which refers to string variables A$ - Z$) or lowercase a-z (for the numerical vars of this name). The example snippet ends the program, and prints variable b to screen before it turns off the lights.

4 bytes

?_r|

_r is a random number generator. By itself, it will generate a random number between 0 and 10 and, in this case, print it. We can also add one or two parameters for a different lower and upper bound; If only one is specified, that's our new upper bound.

_r20| will generate a number between 0 and 20.

_r5,18| will generate a number between 5 and 18.
The statement _R is equivalent to _r with one exception: _R assigns to a variable, _r does not:

?_r|    PRINT getNextRandomNumber(0, 10)
_R|?a   a = getNextRandomNumber(0, 10) : PRINT a

5 bytes

:_Ra|

The above snippet introduces the :, which reads the first unread command line parameter and assigns it to the first available numeric var. The resulting QBasic code for this snippet is:

a = assignCMDToNum!
b = getRandomNumber(0, a)

There's also ;, which does the same for string variables.

6 bytes

?!z$+A

Here, we see a cast in action. QBasic is kinda picky when it comes to data types. Adding a string to an integer will result in errors. To work around this, I've added a casting function. The above snippet will print 10 (z is auto-initialised to 10) and append whatever is in the variable A$. For instance, a full program could be

#test`?!z$+A

and the result then is 10test.

Casting is done using the ! symbol. It then casts everything between the ! and the delimiter. Usually | is the delimiter for variable-length arguments, but CAST uses either a $ to perform the cast from number to string, or another ! to cast a string to number.

7 bytes

Z=_f_tA

Lot going on here. Let's work on the assumption that A$ already holds a value, say "  Hello  " (significant spaces). This snippet then sets Z$ to the reversed (_f), trimmed (_t) version of A$, olleH and prints it to the screen.

The behaviour between _f and _F is different: _F declares a variable and assigns its output to it, _f only gives the output and assigning is done by other parts of the script. The same goes for _r in my 5-byte snippet. This is called ULX, or Upper-Lowercase Extension. Whether or not output gets auto-assigned is one of the behavioural changes ULX can bring, but there are other examples. _D, for intance, yields the system date, _d yelds system time. Both don't auto-assign.

_t removes the whitespace on both sides of its argument. _u does a left-trim, _v does right-trim. All three support ULX, and for all three this switches between auto-assign (uppercase) or output only (lowercase).

Both _f and _t should be delimited with | to signify the end of the parameter list. However, since EOF is reached, the correct number of |'s get added to close all opened parameter lists. If this statement would have been followed by the closing commands for language constructs (]or }, see byte 1) those same |'s would get added.

QBIC allows for the result of one function to be the input for the next: _f takes as input the result of _t

Finally, if we would run this program, it would actually print olleH, despite we never use a ? or _X* statement. This is because QBIC implicitly prints the contents of Z$ on exit.

Summarizing, the above 7-byte snippet would roughly compile into this QBasic block:

FUNCTION revstring$(in$)
  ... function definition imported through QBIC.H
END FUNCTION

... we set A$ to be "  Hello  "

Z$ = revstring$(LTRIM$(RTRIM$(A$)))

PRINT Z$

8 bytes

Let's look at literals. There are 2 types in QBIC: String literals (Verbal and Silent) and Code Literals. They are started with @, # and ' respectively, are terminated with ```. Using a <code>&boxul;</code> respresents a line-break.</p>

<pre><code>?@check`  --> Verbal string literal: Defines A$ in the header, assign the value "check"
              to it, and insert A$ in the body of the resulting QBasic at this moment.
#10`?A+A  --> Silent literal: Defines the literal A$ as "10", but doesn't insert `A$`
              in the QBasic output at this time. This sample then prints "1010"; `+`in
              this context is string concatenation.
'SQR(9)`  --> Code literal: from the `'`(which would be seen as a comment by QBasic) to
              the ``` is not stored as a variable, but passed unaltered to the resulting
              QBasic. This particular statement calculates the root of 9.


答:
QBIC (Non-competing), 8 bytes

```<code>::?a%b=0
</code>```

For this challenge, I've improved QBIC's user input of numeric values. : now takes a command line argument and casts this to num.

Title: Divisibility test

Body:
QBIC (Non-competing), 8 bytes

::?a%b=0

For this challenge, I've improved QBIC's user input of numeric values. : now takes a command line argument and casts this to num.


问:
Bring ASCII art to the 3rd dimension
In this challenge, You have to bring ASCII art (which are usually 2D) to 3D!

How?

like this,

```<code>X X DD
 X  D D
X X DD
</code>```

to...

```<code>  X X DD
 X X DD D
X X DDDD
 X XDDD
X X DD
</code>```

Then How do we do that?

Given the ascii art and N, repeat this N times.

for every character (we will call this A):

let B be the character which is exactly 1 right and 1 up from A

if B is a space or is undefined:

set B to A.

Specs

The first input can be a string with newline characters or a list of strings representing the 2D ASCII art.

You are allowed to use %END% to tag the end of input, but this is not required.

The second input will be N. It will be a positive integer.

all the lines of the strings will be the same length.

Examples

Input: ("###\n###",1)

Output:

```<code> ###
####
###
</code>```

Rules

Basic code-golf rules apply.

also, If you have questions, be sure to ask in the comments!

答:
Convex, 23 bytes

Byte count assumes CP-1252 encoding.

```<code>{{' 1$f+La@+..{sS@Ë}}*}
</code>```

An unnamed block that expects a list of strings and the number of repetitions on the stack and leaves a new list of strings instead.

Try it online!

This is a direct port of my CJam answer to Convex (which is heavily based on CJam). The only difference is that Convex uses Ë instead of er for transliteration, saving one byte. Thanks to GamrCorps for letting me know about it.

Title: Bring ASCII art to the 3rd dimension

Body:
Convex, 23 bytes

Byte count assumes CP-1252 encoding.

{{' 1$f+La@+..{sS@Ë}}*}

An unnamed block that expects a list of strings and the number of repetitions on the stack and leaves a new list of strings instead.

Try it online!

This is a direct port of my CJam answer to Convex (which is heavily based on CJam). The only difference is that Convex uses Ë instead of er for transliteration, saving one byte. Thanks to GamrCorps for letting me know about it.


Title: Print this Multiplication Table

Body:
Write shortest code to print the following Multiplication Table:</p>

```<code>1×1=1
1×2=2  2×2=4
1×3=3  2×3=6  3×3=9
1×4=4  2×4=8  3×4=12 4×4=16
1×5=5  2×5=10 3×5=15 4×5=20 5×5=25
1×6=6  2×6=12 3×6=18 4×6=24 5×6=30 6×6=36
1×7=7  2×7=14 3×7=21 4×7=28 5×7=35 6×7=42 7×7=49
1×8=8  2×8=16 3×8=24 4×8=32 5×8=40 6×8=48 7×8=56 8×8=64
1×9=9  2×9=18 3×9=27 4×9=36 5×9=45 6×9=54 7×9=63 8×9=72 9×9=81
</code>```

Body:
C, <s>86</s> <s>85</s> 84 bytes

i;m(j){for(;i++^9;puts(""))for(j=0;j++^i;printf("%d×%d=%d %c",j,i,j*i,j*i>9?:32));}


答:
C, <s>115</s> <s>123</s> <s>121</s> <s>83</s> <s>80</s> <s>76</s> <s>71</s> 70 bytes

4 bytes saved thanks to @LeakyNun!

My first golf, probably not the best.

c;float r=1;float g(a,s)int*a;{for(;c<s-2;)r*=a[++c]/a[++c];return r;}
```

<p>Takes an array and size.</p>

<p>Ungolfed:</p>

<pre class="lang-c prettyprint-override"><code>int counter;
float ret=1;
float gear(int *arr, int size) {
    for(; counter < size-2; )
        ret = ret * arr[++counter] / arr[++counter];
    return ret;
}
</code>```

Title: Gear Train, Rotating

Body:
C, <s>115</s> <s>123</s> <s>121</s> <s>83</s> <s>80</s> <s>76</s> <s>71</s> 70 bytes

4 bytes saved thanks to @LeakyNun!

My first golf, probably not the best.

c;float r=1;float g(a,s)int*a;{for(;c<s-2;)r*=a[++c]/a[++c];return r;}

Takes an array and size.

Ungolfed:

int counter;
float ret=1;
float gear(int *arr, int size) {
    for(; counter < size-2; )
        ret = ret * arr[++counter] / arr[++counter];
    return ret;
}


答:
GolfScript, 50 41 characters

```<code>~0]-1%~0{\.9>{+1$3$}{@+.9>3$*}if++}10*p];
</code>```

Another attempt in GolfScript (run it online).

An explanation of the code follows. The solution utilises the stack nature of the problem (consume rolls one after another) but therefore the input has to be reversed.

```<code>~0          # Take the input and evaluate to single numbers on the stack. Add zero.
]-1%~       # Reverse the stack (make array, reverse array, dump array)

0           # Start with a sum of zero
{           # Perform this block 10 times (once for each round)
  \         #   Take the next roll
  .9>{      #   If it is a strike
    +       #     Add the value of the roll to the sum
    1$3$    #     and duplicate top two members of the stack (i.e. next two rolls).
  }{        #   ... else ...
    @+      #     Take the next roll and add with first roll in round.
    .9>     #     Does this sum show a spare?
    3$*     #     Get next roll (potential bonus) and multiply with yes/no.
            #     Since we pushed an additional 0 in the beginning
            #     there is a spare roll even for the last round.
  }if       #   endif
  ++        #   Add top three stack entries together
            #   (i.e. sum+2 bonus rolls for strike, sum+rolls+bonus else)
}10*        # Loop ten times

p];         # Sum is top of stack. Print sum and discard any leftover rolls.
</code>```

Previous version:

```<code>~].1>.1>]zip{((.10<{@(0=@+@1>1$9><}*@}10*;]{+}.@**
</code>```

Title: Score a game of Bowling

Body:
Your task is to sum up and output one player's score in a game of 10-pin bowling after up to 21 rolls.

The rolls are represented as a sequence of integers in your preferred method of input.
Each integer corresponds to the number of pins that were knocked down in that roll.

Scoring

After each round the number of pins knocked down in that round is counted into the final score.
If a player knocks down all ten pins in the first roll of a round, this is a strike, and the round is over.
Otherwise, the round lasts for one more roll. If the second roll of a round knocks down all the remaining pins, this is a spare.

For each strike there is a bonus equal to the sum of pins knocked down in the two next rolls.
For each spare there is a bonus equal to the number of pins knocked down in the next roll.

The 10th and final round, the player may be granted extra rolls:
In case of a strike, the player gets two more rolls to make up his strike bonus.
In case of a spare, the player gets one more roll.

Examples

```<code>Input: 4 3 8 2 7 1 10 7 3 0 10 2 2 10 10 5 4
Output: 131

Input: 10 10 9 1 7 3 2 7 10 1 9 10 7 1 10 10 10
Output: 183
</code>```

Rules

You may assumed that the input is valid.

As per Mego's comment I have loosened the requirements for the input/output methods to meet our current standard.

Answers in languages that are newer than the challenge are allowed

Shortest code wins!

Body:
GolfScript, 50 41 characters

~0]-1%~0{\.9>{+1$3$}{@+.9>3$*}if++}10*p];

Another attempt in GolfScript (run it online).

An explanation of the code follows. The solution utilises the stack nature of the problem (consume rolls one after another) but therefore the input has to be reversed.

~0          # Take the input and evaluate to single numbers on the stack. Add zero.
]-1%~       # Reverse the stack (make array, reverse array, dump array)

0           # Start with a sum of zero
{           # Perform this block 10 times (once for each round)
  \         #   Take the next roll
  .9>{      #   If it is a strike
    +       #     Add the value of the roll to the sum
    1$3$    #     and duplicate top two members of the stack (i.e. next two rolls).
  }{        #   ... else ...
    @+      #     Take the next roll and add with first roll in round.
    .9>     #     Does this sum show a spare?
    3$*     #     Get next roll (potential bonus) and multiply with yes/no.
            #     Since we pushed an additional 0 in the beginning
            #     there is a spare roll even for the last round.
  }if       #   endif
  ++        #   Add top three stack entries together
            #   (i.e. sum+2 bonus rolls for strike, sum+rolls+bonus else)
}10*        # Loop ten times

p];         # Sum is top of stack. Print sum and discard any leftover rolls.

Previous version:

~].1>.1>]zip{((.10<{@(0=@+@1>1$9><}*@}10*;]{+}.@**


答:
q - 9 bytes

An anonymous lambda, returns boolean true/false

```<code>not(mod).
</code>```

Example

```<code>q)not(mod). 18 4
0b
q)not(mod). 18 3
1b
</code>```

Title: Divisibility test

Body:
q - 9 bytes

An anonymous lambda, returns boolean true/false

not(mod).

Example

q)not(mod). 18 4
0b
q)not(mod). 18 3
1b


问:
Print numbers from 1 to 10
This might be a very simple challenge, but I am surprised it hasn't been done on code-golf yet:

Print all Integers from 1 to 10 inclusive in ascending order to standard output.

Your output format can be whatever your language supports. This includes arbitrary separators (commas, semicolons, newlines, combinations of those, etc., but no digits), and prefixes and postfixes (like [...]). However, you may not output any other numbers than 1 through 10. Your program may not take any input. Standard loopholes are disallowed.

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

Leaderboard

var QUESTION_ID=86075,OVERRIDE_USER=42570;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

```

答:
Elixir, 18 bytes

```<code>for n<-1..10,do: n
</code>```

Output:

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

Note: This is using iex, the Elixir REPL.

Title: Print numbers from 1 to 10

Body:
Elixir, 18 bytes

for n<-1..10,do: n

Output:

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Note: This is using iex, the Elixir REPL.


答:
GolfScript, 5 bytes

```<code>11,(;
</code>```

Try it online!

Title: Print numbers from 1 to 10

Body:
This might be a very simple challenge, but I am surprised it hasn't been done on code-golf yet:

Print all Integers from 1 to 10 inclusive in ascending order to standard output.

Your output format can be whatever your language supports. This includes arbitrary separators (commas, semicolons, newlines, combinations of those, etc., but no digits), and prefixes and postfixes (like [...]). However, you may not output any other numbers than 1 through 10. Your program may not take any input. Standard loopholes are disallowed.

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

Leaderboard

var QUESTION_ID=86075,OVERRIDE_USER=42570;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:
GolfScript, 5 bytes

11,(;

Try it online!


Title: Print this Multiplication Table

Body:
k (63 characters)

Prints the output to stdout.

-1@`/:" "/:'{7$x,"×",y,"=",z}.''$v,''(*).''v:(1+!:'t),''t:1+!9;

Example

k)-1@`/:" "/:'{7$x,"×",y,"=",z}.''$v,''(*).''v:(1+!:'t),''t:1+!9;
1×1=1
1×2=2  2×2=4
1×3=3  2×3=6  3×3=9
1×4=4  2×4=8  3×4=12 4×4=16
1×5=5  2×5=10 3×5=15 4×5=20 5×5=25
1×6=6  2×6=12 3×6=18 4×6=24 5×6=30 6×6=36
1×7=7  2×7=14 3×7=21 4×7=28 5×7=35 6×7=42 7×7=49
1×8=8  2×8=16 3×8=24 4×8=32 5×8=40 6×8=48 7×8=56 8×8=64
1×9=9  2×9=18 3×9=27 4×9=36 5×9=45 6×9=54 7×9=63 8×9=72 9×9=81


问:
Tips for golfing in PHP
What general tips do you have for golfing in PHP? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to PHP (e.g. "remove comments" is not an answer). Please post one tip per answer.</p>

答:
Use ${0}, ${1}, ${2}, ... instead of $a[0], $a[1], $a[2], ...

Unless you're performing an array manipulation, most references to an array index $a[$i] can be replaced with simply $$i. This is even true if the index is an integer, as integers are valid variable names in PHP (although literals will require brackets, e.g. ${0}).

Consider the following implementation of the Rabonowitz Wagon spigot:

3.<?for(;$g?$d=0|($a[$g]=$d*$g--/2+($a[$g]?:2)%$g*1e4)/$g--:238<<printf($e?'%04d':'',$e+$d/$g=1e4)^$e=$d%$g;);
```

<p>This can be improved by 6 bytes, simply by replacing both array references <code>$a[$g]</code> with <code>$$g</code> instead:</p>

<pre class="lang-php prettyprint-override"><code>3.<?for(;$g?$d=0|($$g=$d*$g--/2+($$g?:2)%$g*1e4)/$g--:238<<printf($e?'%04d':'',$e+$d/$g=1e4)^$e=$d%$g;);
</code>```

Title: Tips for golfing in PHP

Body:
Use ${0}, ${1}, ${2}, ... instead of $a[0], $a[1], $a[2], ...

Unless you're performing an array manipulation, most references to an array index $a[$i] can be replaced with simply $$i. This is even true if the index is an integer, as integers are valid variable names in PHP (although literals will require brackets, e.g. ${0}).

Consider the following implementation of the Rabonowitz Wagon spigot:

3.<?for(;$g?$d=0|($a[$g]=$d*$g--/2+($a[$g]?:2)%$g*1e4)/$g--:238<<printf($e?'%04d':'',$e+$d/$g=1e4)^$e=$d%$g;);

This can be improved by 6 bytes, simply by replacing both array references $a[$g] with $$g instead:

3.<?for(;$g?$d=0|($$g=$d*$g--/2+($$g?:2)%$g*1e4)/$g--:238<<printf($e?'%04d':'',$e+$d/$g=1e4)^$e=$d%$g;);


问:
Count of "a"s and "b"s must be equal. Did you get it computer?
In the popular (and essential) computer science book, An Introduction to Formal Languages and Automata by Peter Linz, the following formal language is frequently stated:

$$\large{L=\{a^n b^n:n\in\mathbb{Z}^+\}}$$

mainly because this language can not be processed with finite-state automata.
This expression mean "Language L consists all strings of 'a's followed by 'b's, in which the number of 'a's and 'b's are equal and non-zero".

Challenge

Write a working program/function which gets a string, containing "a"s and "b"s only, as input and returns/outputs a truth value, saying if this string is valid the formal language L.

Your program cannot use any external computation tools, including network, external programs, etc. Shells are an exception to this rule; Bash, e.g., can use command line utilities.

Your program must return/output the result in a "logical" way, for example: returning 10 instead of 0, "beep" sound, outputting to stdout etc. More info here.

Standard code golf rules apply.

This is a code-golf. Shortest code in bytes wins. Good luck!

Truthy test cases

```<code>"ab"
"aabb"
"aaabbb"
"aaaabbbb"
"aaaaabbbbb"
"aaaaaabbbbbb"
</code>```

Falsy test cases

```<code>""
"a"
"b"
"aa"
"ba"
"bb"
"aaa"
"aab"
"aba"
"abb"
"baa"
"bab"
"bba"
"bbb"
"aaaa"
"aaab"
"aaba"
"abaa"
"abab"
"abba"
"abbb"
"baaa"
"baab"
"baba"
"babb"
"bbaa"
"bbab"
"bbba"
"bbbb"
</code>```

Leaderboard

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

/* Configuration */

var QUESTION_ID = 85994; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 48934; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });

  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (/ b.lang) return 1;
    if (a.lang < b.lang) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}</code>```

<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/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:
k (21 bytes)

Can probably be shorter

{|/0,(=).(#:'=x)"ab"}

Example

k){|/0,(=).(#:'=x)"ab"}""
0b
k){|/0,(=).(#:'=x)"ab"}"ab"
1b
k){|/0,(=).(#:'=x)"ab"}"aab"
0b


问:
ASCII art reflection
In this challenge, you will be given a text block, and you need to perform reflection on the text.

Input:

A string to be reflected. The text may not be supplied as an array whose elements are the lines of text. For example, "ab\ncd" and ['a','b','\n','c','d'] are allowed, but ['ab','cd'] or [['a','b'],['c','d']] are not. You can assume that all of the lines have the same number of characters (padded with whitespace where needed).

A boolean where True indicates Y reflection and False indicates X reflection

The two inputs can be passed in any order.

Output:

The reflected string. The characters do not change, only their position. The resulting image block should be aligned to the top left (the first row and column must each contain a non-whitespace character). Trailing whitespace (on any of the lines) is allowed.

Test cases:

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

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

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

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

```<code>True
text

text
</code>```

```<code>False
text

txet
</code>```

```<code>True
P
P
C
G

G
C
P
P
</code>```

```<code>False
P
P
C
G

P
P
C
G
</code>```

```<code>True
abcde
fghij
kl mn
opqrs
tuvwx

tuvwx
opqrs
kl mn
fghij
abcde
</code>```

This is a code-golf, so answer with the shortest answer in your favorite language!

答:
Perl, 35 bytes

34 bytes code + 1 for -n.

Requires the input lines be padded with spaces. 13 (!) bytes saved thanks to @Dada.

print/T/?reverse<>:map~~reverse,<>
```

<h3>Usage</h3>

<pre class="lang-sh prettyprint-override"><code>perl -ne 'print/T/?reverse<>:map~~reverse,<>' <<< 'False
  o /
--|/
  |
 / \ '

/ o
 /|--
  |
 \ /

 perl -ne 'print/T/?reverse<>:map~~reverse,<>' <<< 'True
  o /
--|/
  |
 / \ '
 / \
  |
--|/
  o /
</code>```

Title: ASCII art reflection

Body:
Perl, 35 bytes

34 bytes code + 1 for -n.

Requires the input lines be padded with spaces. 13 (!) bytes saved thanks to @Dada.

print/T/?reverse<>:map~~reverse,<>

Usage

perl -ne 'print/T/?reverse<>:map~~reverse,<>' <<< 'False
  o /
--|/
  |
 / \ '

/ o
 /|--
  |
 \ /

 perl -ne 'print/T/?reverse<>:map~~reverse,<>' <<< 'True
  o /
--|/
  |
 / \ '
 / \
  |
--|/
  o /


答:
Mathematica, 26 bytes

```<code>#2/#&~Fold~#[[-2;;2;;-1]]&
</code>```

An unnamed function that takes a flat even-length list of values and returns the exact result (as a fraction if necessary).

This uses the same approach as some other answers of folding division over the reversed list (after removing the first and last element).

Title: Gear Train, Rotating

Body:
Gears transfer different amount of speeds, depending on the size of the meshed gear.

Jack has a machine, that rotates a Gear Train. but you don't know the speed of the last gear.

Luckily, You are a great code golfer, so you can help him!

So, What should I do?

Each gear is represented by 2 numbers, the radius of the inner gear and the radius of the outer gears.

If gear A is [a,b] and gear B is [c,d], then the ratio between the speed of A and the speed of B would be c:b.

Given a list of gears (list of 2-tuples), output the speed of the last gear.

You can assume the speed of the first gear is 1.

Worked out example

Let's say our input is [[6,12],[3,10],[5,8]].

The first gear, [6,12], would have a speed of 1.

Then, the second gear, [3,10], would have a speed of 1*12/3 = 4.

Then, the last gear, [5,8], would have a speed of 4*10/5 = 8.

Testcases

```<code>input                    output
[[1,1],[2,2]]            0.5     (1/2)
[[1,2],[1,2],[1,2]]      4       (2/1*2/1)
[[6,12],[3,10],[5,8]]    8       (12/3*10/5)
</code>```

Rules

Basic code-golf rules apply.

Body:
Mathematica, 26 bytes

#2/#&~Fold~#[[-2;;2;;-1]]&

An unnamed function that takes a flat even-length list of values and returns the exact result (as a fraction if necessary).

This uses the same approach as some other answers of folding division over the reversed list (after removing the first and last element).


答:
CoffeeScript, 19 characters

console.log [1..10]
```

<p>Sample run:</p>

```bash-4.3$ coffee -e 'console.log [1..10]'
[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
```

On-line test

Title: Print numbers from 1 to 10

Body:
CoffeeScript, 19 characters

console.log [1..10]

Sample run:

bash-4.3$ coffee -e 'console.log [1..10]'
[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]

On-line test


问:
How much snow did you get?
My apologies for the wordiness. We had fun with it at work in our internal golfing, but it required a few emails for clarification, so I hope I captured most of that the first time.

PROBLEM

Given a “simulated” snowfall snapshot (as a string, stdin or parameter to your function/method), report on 4 values: minimum depth, maximum depth, average depth, and duration.

Here’s a formatted example to illustrate the input:

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

The ‘*’ is a snowflake and the ‘-‘ is the ground. Imagine all of those “snowflakes” falling toward the ground. This is the final “snapshot”:

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

You need to report on:

Minimum depth - count the shortest “pile” (1, in example above)

Maximum depth - count the tallest “pile” (4, in example above)

Average depth - average count of all “piles” (1.9, in example above - rounding to tenths)

Duration - (each “fall” = 1 second) - time from the first snapshot to the last snapshot (3 seconds, in example above)

Another example for reference:

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

Final snapshot:

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

INPUT

The starting “snapshot” will have 8 “rows”, 8 “columns”, and be pipe-delimited (the pipes separate the rows). For example (excluding quotes):

```<code>“        |        |        |        |     *  |   *   *|      * |*       |--------”
</code>```

OUTPUT

The 4 values pipe-delimited on a single line: 0|1|.6|3 or 0|5|1|1

答:
PHP, 139 bytes

```<code><?for(;$y<8;$y++)for($x=0;++$n[$x],$x<8;$x++)'!'>$argv[1][$y*9+$x]&&--$n[$x]?$b[$x]++:0;print_r([min($n),max($n),array_sum($n)/8,max($b)]);
</code>```

for each column, count no. of snowflakes and no. of spaces below the first snowflake, then calculate

takes string as argument from command line

breakdown and golfing steps

```<code>$i=$argv[1];
for(;$y<8;$y++)         # $y=row
{
    for($x=0;$x<8;$x++) # $x=column
    {
        // loop body: 32+26=58 bytes
        if('*'==$i[$p=$y*9+$x])$n[$x]++;# if snowflake: increase snowflakes count
        elseif($n[$x]+=0)$b[$x]++;      # elseif has snowflakes: increase blanks count
                                        # +=0: min needs a value in every column

        // -> golf if/elseif to ternaries, 16+9+25+1 = 51 (-7)
#       '*'==$i[$y*9+$x]
#           ? $n[$x]++
#           : (($n[$x]+=0)?$b[$x]++:0)
#       ;

        // golfing on the ternary, 15+23+9+1 = 48 (-3)
#       '!'>$i[$y*9+$x]                 # -1: char<'!' <=> char==' '
#           ? ($n[$x]+=0)?$b[$x]++:0    # -2: inverted condition -> eliminated parens
#           : $n[$x]++
#       ; # 15+23+9+1-2=46

        // increase snowflakes count in any case (initialization)
        // (needs curlies; elminate them by moving increase to the for condition)
        // decrease snowflakes count for blank
#       ++$n[$x];if('!'>$i[$y*9+$x]&&--$n[$x])$b[$x]++; # if: 47
#       ++$n[$x];'!'>$i[$y*9+$x]&&--$n[$x]?$b[$x]++:0;  # ternary: 46
    }
}
print_r([min($n),max($n),array_sum($n)/8,max($b)]); # calculate and print results
</code>```

add round(...,1) around array_sum($n)/8 for rounding (+9)

ContentLicense: CC BY-SA 2.5

Title: How much snow did you get?

Body:
PHP, 139 bytes

<?for(;$y<8;$y++)for($x=0;++$n[$x],$x<8;$x++)'!'>$argv[1][$y*9+$x]&&--$n[$x]?$b[$x]++:0;print_r([min($n),max($n),array_sum($n)/8,max($b)]);

for each column, count no. of snowflakes and no. of spaces below the first snowflake, then calculate

takes string as argument from command line

breakdown and golfing steps

$i=$argv[1];
for(;$y<8;$y++)         # $y=row
{
    for($x=0;$x<8;$x++) # $x=column
    {
        // loop body: 32+26=58 bytes
        if('*'==$i[$p=$y*9+$x])$n[$x]++;# if snowflake: increase snowflakes count
        elseif($n[$x]+=0)$b[$x]++;      # elseif has snowflakes: increase blanks count
                                        # +=0: min needs a value in every column

        // -> golf if/elseif to ternaries, 16+9+25+1 = 51 (-7)
#       '*'==$i[$y*9+$x]
#           ? $n[$x]++
#           : (($n[$x]+=0)?$b[$x]++:0)
#       ;

        // golfing on the ternary, 15+23+9+1 = 48 (-3)
#       '!'>$i[$y*9+$x]                 # -1: char<'!' <=> char==' '
#           ? ($n[$x]+=0)?$b[$x]++:0    # -2: inverted condition -> eliminated parens
#           : $n[$x]++
#       ; # 15+23+9+1-2=46

        // increase snowflakes count in any case (initialization)
        // (needs curlies; elminate them by moving increase to the for condition)
        // decrease snowflakes count for blank
#       ++$n[$x];if('!'>$i[$y*9+$x]&&--$n[$x])$b[$x]++; # if: 47
#       ++$n[$x];'!'>$i[$y*9+$x]&&--$n[$x]?$b[$x]++:0;  # ternary: 46
    }
}
print_r([min($n),max($n),array_sum($n)/8,max($b)]); # calculate and print results

add round(...,1) around array_sum($n)/8 for rounding (+9)


问:
Forecast the weather
Write the shortest program to forecast the weather for the next 7 days

The input (from stdin) is the weekday and the season

The output (to stdout) is seven lines weekday and the temperature in centigrade

The weekdays begin on the input weekday

The temperatures are random numbers with the range depending on the season

```
Spring 10 - 30 degrees
Summer 20 - 40 degrees
Autumn  5 - 25 degrees  (Fall is a synonym for autumn)
Winter -5 - 15 degrees
```

Sample Input

Thursday Winter

Sample Output

```
Thursday -1
Friday 3
Saturday 8
Sunday 7
Monday 10
Tuesday 10
Wednesday -1
```

Your program must not have identical output every time it is run with the same input

答:
Golfscript - 110 chars

```<code>' ':^/){*}*43845%7&5*:|;){*}*333121%7&:$;7,{($+'Sun Mon Tues Wednes Thurs Fri Satur'^/.+='day '+20rand|+5-+n}/
</code>```

Fully support all the temperature ranges, seasons and also support "Fall" as synonym for "Autumn" too.

I think there is some rooms for improvement, but my current golfscript knowledge is limited so far.

Here is the tests, 2 passes each to confirm randomness

```<code>$ echo -n Thursday Spring | gs codegolf-404.gs
Thursday 23
Friday 28
Saturday 25
Sunday 22
Monday 19
Tuesday 14
Wednesday 25

$ echo -n Thursday Spring | gs codegolf-404.gs
Thursday 27
Friday 12
Saturday 26
Sunday 12
Monday 27
Tuesday 17
Wednesday 21

$ echo -n Friday Autumn | gs codegolf-404.gs
Friday 10
Saturday 5
Sunday 17
Monday 24
Tuesday 24
Wednesday 12
Thursday 18

$ echo -n Friday Autumn | gs codegolf-404.gs
Friday 13
Saturday 7
Sunday 14
Monday 6
Tuesday 14
Wednesday 21
Thursday 5

$ echo -n Sunday Summer | gs codegolf-404.gs
Sunday 39
Monday 31
Tuesday 35
Wednesday 34
Thursday 21
Friday 36
Saturday 28

$ echo -n Sunday Summer | gs codegolf-404.gs
Sunday 34
Monday 20
Tuesday 30
Wednesday 39
Thursday 30
Friday 31
Saturday 37

$ echo -n Monday Fall | gs codegolf-404.gs
Monday 6
Tuesday 7
Wednesday 18
Thursday 13
Friday 7
Saturday 5
Sunday 14

$ echo -n Monday Fall | gs codegolf-404.gs
Monday 16
Tuesday 22
Wednesday 19
Thursday 23
Friday 21
Saturday 9
Sunday 17

$ echo -n Saturday Winter | gs codegolf-404.gs
Saturday 0
Sunday -5
Monday 10
Tuesday -3
Wednesday -5
Thursday 13
Friday -1

$ echo -n Saturday Winter | gs codegolf-404.gs
Saturday -4
Sunday 13
Monday 11
Tuesday 0
Wednesday 0
Thursday -5
Friday 9

$ echo -n Tuesday Summer | gs codegolf-404.gs
Tuesday 38
Wednesday 29
Thursday 25
Friday 29
Saturday 34
Sunday 20
Monday 39

$ echo -n Tuesday Summer | gs codegolf-404.gs
Tuesday 33
Wednesday 26
Thursday 31
Friday 37
Saturday 39
Sunday 24
Monday 28

$ echo -n Wednesday Winter | gs codegolf-404.gs
W    ednesday 7
Thursday 12
Friday 0
Saturday -3
Sunday 11
Monday 14
Tuesday 8

$ echo -n Wednesday Winter | gs codegolf-404.gs
Wednesday 0
Thursday -1
Friday 7
Saturday 12
Sunday -5
Monday -3
Tuesday 2
</code>```

Title: Forecast the weather

Body:
Golfscript - 110 chars

' ':^/){*}*43845%7&5*:|;){*}*333121%7&:$;7,{($+'Sun Mon Tues Wednes Thurs Fri Satur'^/.+='day '+20rand|+5-+n}/

Fully support all the temperature ranges, seasons and also support "Fall" as synonym for "Autumn" too.

I think there is some rooms for improvement, but my current golfscript knowledge is limited so far.

Here is the tests, 2 passes each to confirm randomness

$ echo -n Thursday Spring | gs codegolf-404.gs
Thursday 23
Friday 28
Saturday 25
Sunday 22
Monday 19
Tuesday 14
Wednesday 25

$ echo -n Thursday Spring | gs codegolf-404.gs
Thursday 27
Friday 12
Saturday 26
Sunday 12
Monday 27
Tuesday 17
Wednesday 21

$ echo -n Friday Autumn | gs codegolf-404.gs
Friday 10
Saturday 5
Sunday 17
Monday 24
Tuesday 24
Wednesday 12
Thursday 18

$ echo -n Friday Autumn | gs codegolf-404.gs
Friday 13
Saturday 7
Sunday 14
Monday 6
Tuesday 14
Wednesday 21
Thursday 5

$ echo -n Sunday Summer | gs codegolf-404.gs
Sunday 39
Monday 31
Tuesday 35
Wednesday 34
Thursday 21
Friday 36
Saturday 28

$ echo -n Sunday Summer | gs codegolf-404.gs
Sunday 34
Monday 20
Tuesday 30
Wednesday 39
Thursday 30
Friday 31
Saturday 37

$ echo -n Monday Fall | gs codegolf-404.gs
Monday 6
Tuesday 7
Wednesday 18
Thursday 13
Friday 7
Saturday 5
Sunday 14

$ echo -n Monday Fall | gs codegolf-404.gs
Monday 16
Tuesday 22
Wednesday 19
Thursday 23
Friday 21
Saturday 9
Sunday 17

$ echo -n Saturday Winter | gs codegolf-404.gs
Saturday 0
Sunday -5
Monday 10
Tuesday -3
Wednesday -5
Thursday 13
Friday -1

$ echo -n Saturday Winter | gs codegolf-404.gs
Saturday -4
Sunday 13
Monday 11
Tuesday 0
Wednesday 0
Thursday -5
Friday 9

$ echo -n Tuesday Summer | gs codegolf-404.gs
Tuesday 38
Wednesday 29
Thursday 25
Friday 29
Saturday 34
Sunday 20
Monday 39

$ echo -n Tuesday Summer | gs codegolf-404.gs
Tuesday 33
Wednesday 26
Thursday 31
Friday 37
Saturday 39
Sunday 24
Monday 28

$ echo -n Wednesday Winter | gs codegolf-404.gs
W    ednesday 7
Thursday 12
Friday 0
Saturday -3
Sunday 11
Monday 14
Tuesday 8

$ echo -n Wednesday Winter | gs codegolf-404.gs
Wednesday 0
Thursday -1
Friday 7
Saturday 12
Sunday -5
Monday -3
Tuesday 2


答:
Python, 116 110 105 103 100 99 characters

```<code>z=map(int,raw_input().split())
s=0
exec('s+=sum(z[:2+(z[0]+z[1]>9)]);z=z[2-(z[0]>9):];'*10)
</code>```

Spending 30 characters on input is irksome.  Suggestions welcome.

Much thanks to Howard for improvements.

Title: Score a game of Bowling

Body:
Python, 116 110 105 103 100 99 characters

z=map(int,raw_input().split())
s=0
exec('s+=sum(z[:2+(z[0]+z[1]>9)]);z=z[2-(z[0]>9):];'*10)

Spending 30 characters on input is irksome.  Suggestions welcome.

Much thanks to Howard for improvements.


答:
JavaScript, 54 bytes

```<code>(a,s=1)=>a.map((v,i)=>s*=(x=a[i+1])?v[1]/x[0]:1).pop()
</code>```

Usage

f=(a,s=1)=>a.map((v,i)=>s*=(x=a[i+1])?v[1]/x[0]:1).pop()

document.write([
  f([[1,1],[2,2]]),
  f([[1,2],[1,2],[1,2]]),
  f([[6,12],[3,10],[5,8]])
].join('
'))```
</div>
</div>
</p>

<h2>Ungolfed</h2>

```function ( array ) {
  var s = 1;                                  // Set initial speed

  for ( var i = 0; i < array.length ; i++ ) { // Loop through array
    if ( array[i + 1] === undefined ) {       // If last element
      return s;                               // Return speed
    } else {                                  // Else
      s = s * ( array[i][0] / array[i+1][0])  // Calculate speed
    }
  }
}
```

Of course, the golfed variant is a bit different. With .map(), it replaces the first value of the array with the speed after the second wheel, the second value with the speed of the third wheel, and the last value and the second last value with the speed of the last wheel. So, we just take the last element with .pop().

Title: Gear Train, Rotating

Body:
JavaScript, 54 bytes

(a,s=1)=>a.map((v,i)=>s*=(x=a[i+1])?v[1]/x[0]:1).pop()

Usage

f=(a,s=1)=>a.map((v,i)=>s*=(x=a[i+1])?v[1]/x[0]:1).pop()

document.write([
  f([[1,1],[2,2]]),
  f([[1,2],[1,2],[1,2]]),
  f([[6,12],[3,10],[5,8]])
].join('<br>'))

Ungolfed

function ( array ) {
  var s = 1;                                  // Set initial speed

  for ( var i = 0; i < array.length ; i++ ) { // Loop through array
    if ( array[i + 1] === undefined ) {       // If last element
      return s;                               // Return speed
    } else {                                  // Else
      s = s * ( array[i][0] / array[i+1][0])  // Calculate speed
    }
  }
}

Of course, the golfed variant is a bit different. With .map(), it replaces the first value of the array with the speed after the second wheel, the second value with the speed of the third wheel, and the last value and the second last value with the speed of the last wheel. So, we just take the last element with .pop().


答:
Mathematica, ~115

```<code>"        \n        \n* * **  \n        \n** * ***\n** *  * \n*       \n--------"

Most/@ToCharacterCode@%~Partition~9/10-16/5
Min@#|Max@#|Mean@#~Round~.1|Position[#,1][[{-1,1},1]].{1,-1}-1&@Total@%
</code>```

```<code>1 | 4 | 1.9 | 4
</code>```

In this post I had to resort to the escaped string form \n as paste and copy loses spaces.  In the Front End I can enter it like this:

Title: How much snow did you get?

Body:
My apologies for the wordiness. We had fun with it at work in our internal golfing, but it required a few emails for clarification, so I hope I captured most of that the first time.

PROBLEM

Given a “simulated” snowfall snapshot (as a string, stdin or parameter to your function/method), report on 4 values: minimum depth, maximum depth, average depth, and duration.

Here’s a formatted example to illustrate the input:

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

The ‘*’ is a snowflake and the ‘-‘ is the ground. Imagine all of those “snowflakes” falling toward the ground. This is the final “snapshot”:

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

You need to report on:

Minimum depth - count the shortest “pile” (1, in example above)

Maximum depth - count the tallest “pile” (4, in example above)

Average depth - average count of all “piles” (1.9, in example above - rounding to tenths)

Duration - (each “fall” = 1 second) - time from the first snapshot to the last snapshot (3 seconds, in example above)

Another example for reference:

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

Final snapshot:

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

INPUT

The starting “snapshot” will have 8 “rows”, 8 “columns”, and be pipe-delimited (the pipes separate the rows). For example (excluding quotes):

```<code>“        |        |        |        |     *  |   *   *|      * |*       |--------”
</code>```

OUTPUT

The 4 values pipe-delimited on a single line: 0|1|.6|3 or 0|5|1|1

Body:
Mathematica, ~115

"        \n        \n* * **  \n        \n** * ***\n** *  * \n*       \n--------"

Most/@ToCharacterCode@%~Partition~9/10-16/5
Min@#|Max@#|Mean@#~Round~.1|Position[#,1][[{-1,1},1]].{1,-1}-1&@Total@%

1 | 4 | 1.9 | 4

In this post I had to resort to the escaped string form \n as paste and copy loses spaces.  In the Front End I can enter it like this:


答:
MoonScript, 17 characters

(Rewrite of Katenkyo's Lua answer. Appreciations should be expressed by upvoting the original answer.)

```<code>for i=1,10print i
</code>```

Sample run:

```<code>bash-4.3$ moon <(echo 'for i=1,10print i')
1
2
3
4
5
6
7
8
9
10
</code>```

Title: Print numbers from 1 to 10

Body:
MoonScript, 17 characters

(Rewrite of Katenkyo's Lua answer. Appreciations should be expressed by upvoting the original answer.)

for i=1,10print i

Sample run:

bash-4.3$ moon <(echo 'for i=1,10print i')
1
2
3
4
5
6
7
8
9
10