问:
Build an aesthetically pleasing divisor tree
An aesthetically pleasing divisor tree is a tree of divisors of input n that, for any composite number m, has two children nodes that are the pair of divisors that are closest to the square root of m. The left node should be the smaller divisor of m and the right node should be the larger divisor of m. A prime number in the tree should have no children nodes. Your tree may be in the form of text art or an image. The rules for text art output are as follows.

Spacing rules

To space out the nodes on the tree, we have the following rules:

The nodes at a given depth from the root should all be on the same line of text in the output.

```
  /  \    NOT    /  \
 /    \         /    3
2      3       2
```

For left nodes, the incoming branch should be on the upper right if the node is a single-digit number, else, just above the last digit. Example:

```
 /    AND    /
3          720
```

For right nodes, the incoming branch should be on the upper left if the node is a single-digit number, else, just above the first digit. Example:

```
\    AND    \
 7          243
```

For outgoing left branches, the branch should begin one space to the left of the number. Example:

```
  275
 /
11
```

For outgoing right branches, the branch should begin one space to the right of the number. Example:

```
275
   \
   25
```

Any two nodes on the same level of the tree should have a minimum of two spaces between them. At the same time, any two subtrees on the same level of the tree should have as few spaces between them as possible.

```

This tree doesn't work because the **subtrees** are too close.

        504
       /   \
      /     \
     /       \
    /         \
   21   .     24
  /  \  .    /  \
 /    \ .   /    \
3      7.  4      6
        . / \    / \
        .2   2  2   3

While this tree does have enough space between its branches.

         504
        /   \
       /     \
      /       \
     /         \
    /           \
   21   ...     24
  /  \  ...    /  \
 /    \ ...   /    \
3      7...  4      6
        ... / \    / \
        ...2   2  2   3
```

If any two subtrees are too close together on a tree, they can be separated by adding another row of branches /\ to the tree above the parents.

```
   441
  /   \    Last row is not filled in yet and we have already run out of space.
 21   21
/  \ /  \

Add another row of branches

     441
    /   \     Almost, but the 7 and the 3 are too close together.
   /     \    One more row should do it.
  21     21
 /  \   /  \
3    7 3    7

Add another row of branches

      441
     /   \      And we're done.
    /     \
   /       \
  21       21
 /  \     /  \
3    7   3    7
```

Examples

As a full example, the divisor tree of 24 will look like this:

```<code>     24
    /  \
   /    \
  4      6
 / \    / \
2   2  2   3
</code>```

4 and 6 are the pair of divisors closest to the square root of 24. 4 is on the left, because it's smaller. On the next line, the number 2 to the left of 3, because it's smaller.

The divisor tree for 63 should look like:

```<code>  63        and NOT like this        63
 /  \                               /  \
7    9                             3   21
    / \                               /  \
   3   3                             7    3
</code>```

In the incorrect tree, 3 and 21 are not the pair of divisors closest to the square root of 63, and 3 and 7 are not sorted properly. The branch placement on the 21 is correct, though.

For 42, you should have:

```<code>    42      and NOT        42
   /  \                   /  \
  6    7                 21   2
 / \                    /  \
2   3                  3    7
</code>```

Let's have a look at 720. Note that we need five levels of branches from 720 so that the 24 and 30 subtrees are correctly spaced. Also, note that 24 and 30 have two levels of branches because 4 and 6 have children nodes that need correct spacing and the children nodes of 30 need to be on the same level as the children nodes of 24.

```<code>           720
          /   \
         /     \
        /       \
       /         \
      /           \
     24           30
    /  \         /  \
   /    \       /    \
  4      6     5      6
 / \    / \          / \
2   2  2   3        2   3
</code>```

The challenge

Your task is to build a correctly-spaced aesthetically pleasing divisor tree for input n, where n is a positive integer greater than 1.

Your output may contain leading and trailing spaces and leading and trailing newlines, but must otherwise conform to the spacing rules given above.

Your output is allowed to be: text art, an image (other formats to be added, if needed).

For images, make sure your tree's nodes are well-spaced, and that nodes at the same height in the tree are at the same height in the image.

This is code golf. Least number of bytes (or equivalent) wins.

Credit to Stewie Griffin for thinking of this idea, and many thanks to Peter Taylor, Martin Ender, Mego, and Eᴀsᴛᴇʀʟʏ Iʀᴋ for their help in rewriting the specification. As usual, any suggestions or corrections are much appreciated. Good luck and good golfing!

More test cases:

```<code>2

  4
 / \
2   2

    20
   /  \
  4    5
 / \
2   2

  323
 /   \
17   19

                        362880
                       /      \
                      /        \
                     /          \
                    /            \
                   /              \
                  /                \
                 /                  \
                /                    \
               /                      \
              /                        \
            576                        630
           /   \                      /   \
          /     \                    /     \
         /       \                  /       \
        /         \                /         \
       /           \              /           \
      /             \            /             \
     24             24          21             30
    /  \           /  \        /  \           /  \
   /    \         /    \      /    \         /    \
  4      6       4      6    3      7       5      6
 / \    / \     / \    / \                        / \
2   2  2   3   2   2  2   3                      2   3

              1286250
             /       \
            /         \
           /           \
          /             \
         /               \
      1050               1225
     /    \             /    \
    /      \           /      \
   /        \         /        \
  30        35       35        35
 /  \      /  \     /  \      /  \
5    6    5    7   5    7    5    7
    / \
   2   3
</code>```

答:
Mathematica, <s>96</s> <s>86</s> <s>81</s> <s>79</s> 78 bytes

Thanks @MartinEnder for 2 bytes.

```<code>TreeForm[If[PrimeQ@#,#,#0/@(#2[#,#2/#]&[Max@Nearest[Divisors@#,#^.5],#])]&@#]&
</code>```

The output looks like this:

Explanation

```<code>Max@Nearest[Divisors@#,#^.5]
</code>```

Generate the list of divisors of the input. Find the element nearest to the square root of the input. (Max is for flattening the output)

```<code>#2[#,#2/#]&
</code>```

Find the other divisor by dividing the input by the divisor found above, apply the input as the head of the result.

```<code>#0/@
</code>```

Repeat the process.

```<code>If[PrimeQ@#,#, ... ]
</code>```

If the input is prime, don't do anything.

```<code>TreeForm
</code>```

Format the output.

Edit: A more aesthetically pleasing version (258 bytes)

```<code>TreeForm[#/.{a_,_,_}:>a,VertexRenderingFunction->(#2~Text~#&),VertexCoordinateRules->Cases[#,{_,_},Infinity,Heads->True]]&@(If[PrimeQ@#,{##},{##}@@#0@@@({{#,#3-#4{1,√3}/2,#4/2},{#2/#,#3-#4{-1,√3}/2,#4/2}}&[Max@Nearest[Divisors@#,√#],##])]&[#,{0,0},1])&
</code>```

The output looks like this:

Body:
Mathematica, <s>96</s> <s>86</s> <s>81</s> <s>79</s> 78 bytes

Thanks @MartinEnder for 2 bytes.

TreeForm[If[PrimeQ@#,#,#0/@(#2[#,#2/#]&[Max@Nearest[Divisors@#,#^.5],#])]&@#]&

The output looks like this:

Explanation

Max@Nearest[Divisors@#,#^.5]

Generate the list of divisors of the input. Find the element nearest to the square root of the input. (Max is for flattening the output)

#2[#,#2/#]&

Find the other divisor by dividing the input by the divisor found above, apply the input as the head of the result.

#0/@

Repeat the process.

If[PrimeQ@#,#, ... ]

If the input is prime, don't do anything.

TreeForm

Format the output.

Edit: A more aesthetically pleasing version (258 bytes)

TreeForm[#/.{a_,_,_}:>a,VertexRenderingFunction->(#2~Text~#&),VertexCoordinateRules->Cases[#,{_,_},Infinity,Heads->True]]&@(If[PrimeQ@#,{##},{##}@@#0@@@({{#,#3-#4{1,√3}/2,#4/2},{#2/#,#3-#4{-1,√3}/2,#4/2}}&[Max@Nearest[Divisors@#,√#],##])]&[#,{0,0},1])&

The output looks like this:


问:
Least Common Multiple
The least common multiple of a set of positive integers A is the smallest postive integer B such that, for each k in A, there exists a positive integer n such that k*n = B.

Given at least two positive integers as input, output their least common multiple.

Rules

Builtins are allowed, but if your solution uses one, you are encouraged to include an alternate solution that does not use GCD/LCM builtins. However, the alternate solution will not count towards your score at all, so it is entirely optional.

All inputs and outputs will be within the natively-representable range for your language. If your language is natively capable of arbitrarily-large integers, then your solution must work with arbitrarily large inputs and outputs.

Test cases

```<code>[7, 2] -> 14
[8, 1] -> 8
[6, 4, 8] -> 24
[8, 2, 1, 10] -> 40
[9, 6, 2, 1, 5] -> 90
[5, 5, 7, 1, 1] -> 35
[4, 13, 8, 8, 11, 1] -> 1144
[7, 2, 2, 11, 11, 8, 5] -> 3080
[1, 6, 10, 3, 4, 10, 7] -> 420
[5, 2, 9, 10, 3, 4, 4, 4, 7] -> 1260
[9, 7, 10, 9, 7, 8, 5, 10, 1] -> 2520
</code>```

答:
J, 11 bytes

```<code>>./&.(_&q:)
</code>```

There is a solution for 3 bytes using the LCM builtin.

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

Explanation

```<code>>./&.(_&q:)  Input: array of integers A
      _&q:   Get the prime exponents of each integer in A
>./&         Reduce by maximum on the lists
   &. _&q:   Convert the list of exponents back to an integer

*./  Input: array of integers A
  /  Reduce using
*.     LCM
</code>```

ContentLicense: CC BY-SA 3.0

Title: Least Common Multiple

Body:
J, 11 bytes

>./&.(_&q:)

There is a solution for 3 bytes using the LCM builtin.

*./

Explanation

>./&.(_&q:)  Input: array of integers A
      _&q:   Get the prime exponents of each integer in A
>./&         Reduce by maximum on the lists
   &. _&q:   Convert the list of exponents back to an integer

*./  Input: array of integers A
  /  Reduce using
*.     LCM


问:
So sayeth the Shepherd
I'm tired, but I can't seem to fall asleep. Help me count sheep.

Given an input N (positive integer), make N sheep jump over an ascii fence, like the sample below. Only one frame should be displayed at once:

```<code>o |-|
──|-|──  0
</code>```

```<code> o|-|
──|-|──  0
</code>```

```<code>   o
  |-|
──|-|──  0
</code>```

```<code>  |-|o
──|-|──  0
</code>```

```<code>  |-| o
──|-|──  0
</code>```

```<code>o |-|
──|-|──  1
</code>```

```<code> o|-|
──|-|──  1
</code>```

```<code>   o
  |-|
──|-|──  1
</code>```

Count should be kept at the lower right side of the 'ground'. Trailing and leading whitespace and newlines are allowed. If your language of choice has difficulty clearing the screen for each frame you can add sufficient newlines to clear the screen - please state how many lines you add for this in your answer. The program should terminate when the N'th sheep is on the fifth floortile.

I need to get up early tomorrow, so shortest code in bytes wins. Please submit a function or complete program. Standard loopholes apply.

答:
C#, 234 Bytes

```<code>using C=System.Console;class P{static void Main(string[]a){for(int n=0;n-1+""!=a[0];++n){foreach(int p in new[]{5,6,3,10,11}){C.Clear();C.Write("    \n  |-|  \n──|-|── ".Remove(p,1).Insert(p,"o")+n);for(var w=3e7;w>0;--w);}}}}
</code>```

Title: So sayeth the Shepherd

Body:
C#, 234 Bytes

using C=System.Console;class P{static void Main(string[]a){for(int n=0;n-1+""!=a[0];++n){foreach(int p in new[]{5,6,3,10,11}){C.Clear();C.Write("    \n  |-|  \n──|-|── ".Remove(p,1).Insert(p,"o")+n);for(var w=3e7;w>0;--w);}}}}


Title: Least Common Multiple

Body:
The least common multiple of a set of positive integers A is the smallest postive integer B such that, for each k in A, there exists a positive integer n such that k*n = B.

Given at least two positive integers as input, output their least common multiple.

Rules

Builtins are allowed, but if your solution uses one, you are encouraged to include an alternate solution that does not use GCD/LCM builtins. However, the alternate solution will not count towards your score at all, so it is entirely optional.

All inputs and outputs will be within the natively-representable range for your language. If your language is natively capable of arbitrarily-large integers, then your solution must work with arbitrarily large inputs and outputs.

Test cases

```<code>[7, 2] -> 14
[8, 1] -> 8
[6, 4, 8] -> 24
[8, 2, 1, 10] -> 40
[9, 6, 2, 1, 5] -> 90
[5, 5, 7, 1, 1] -> 35
[4, 13, 8, 8, 11, 1] -> 1144
[7, 2, 2, 11, 11, 8, 5] -> 3080
[1, 6, 10, 3, 4, 10, 7] -> 420
[5, 2, 9, 10, 3, 4, 4, 4, 7] -> 1260
[9, 7, 10, 9, 7, 8, 5, 10, 1] -> 2520
</code>```

Body:
Racket 13 bytes

lcm is a built-in function in Racket:

(apply lcm l)

Testing:

(define (f l)
   (apply lcm l))

(f (list 7 2))
(f (list 8 1))
(f (list 6 4 8))
(f (list 8 2 1 10))
(f (list 9 6 2 1 5))
(f (list 5 5 7 1 1))
(f (list 4 13 8 8 11 1))
(f (list 7 2 2 11 11 8 5))
(f (list 1 6 10 3 4 10 7))
(f (list 5 2 9 10 3 4 4 4 7))
(f (list 9 7 10 9 7 8 5 10 1))

Output:

14
8
24
40
90
35
1144
3080
420
1260
2520


问:
Greatest Common Divisor
Your task is to compute the greatest common divisor (GCD) of two given integers in as few bytes of code as possible.

You may write a program or function, taking input and returning output via any of our accepted standard methods (including STDIN/STDOUT, function parameters/return values, command-line arguments, etc.).

Input will be two non-negative integers. You should be able to handle either the full range supported by your language's default integer type, or the range [0,255], whichever is greater. You are guaranteed that at least one of the inputs will be non-zero.

You are not allowed to use built-ins that compute either the GCD or the LCM (least common multiple).

Standard code-golf rules apply.

Test Cases

```<code>0 2     => 2
6 0     => 6
30 42   => 6
15 14   => 1
7 7     => 7
69 25   => 1
21 12   => 3
169 123 => 1
20 142  => 2
101 202 => 101
</code>```

Title: Greatest Common Divisor

Body:
Racket 38 bytes

  (λ(a b)(if(> b 0)(f b(modulo a b))a))

Ungolfed:

(define f
  (λ (a b)
    (if (<= b 0)
        a
        (f b (modulo a b))
        )))

Testing:

(f 0 2)
(f 6 0)
(f 30 42)
(f 15 14)
(f 7 7)
(f 69 25)
(f 21 12)
(f 169 123)
(f 20 142)
(f 101 202)

Output:

2
6
6
1
7
1
3
1
2
101


问:
The Woz Monitor

 Challenge

I've recently gotten into 8-bit computers and are fascinated with the workings of them and others alike; thus the objective of this code golf, is to replicate a portion of the Woz Monitor, designed by Steve Wozniak for the Apple I.

You are to store an array of 22 hexadecimal values with a width of two bytes, (min value $10, max value $FF), and then take in n-amount of inputs. (Normally two; languages like Brainfuck might have a hard time).

The inputs will refer to where in the array to start printing from, and where to stop; an input with defined behaviour will have their starting value less or equal to the ending value. Your program must then be capable of printing every hexadecimal value between, and including, the hexadecimals inputted.

An example of this:

```<code>Array
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15

Values
FF F4 B6 D7 40 00 00 A4 F0 00 FF 0D 9C 21 65 C4 02 28 90 E7 D6 A5
</code>```

```<code>input first num:
04
input second num:
14
40 00 00 A4 F0 00 FF 0D 9C 21 65 C4 02 28 90 E7 D6
</code>```

Now the interesting part of this exercise, is that you can use whatever you want to check the bounds of the users input. Person inputs hello and your program has undefined behaviour? It quits without notice? They are both valid.

The only rules are:

1. You must include the values of the 22 hexadecimal values as part of your program before it starts, (can't ask the user for inputs).

2. The output of the hexadecimal values must follow the exact format:
    00 FF 00 FF 00 Trailing spaces, tabs or lines are OK. Characters are not.

3. The program doesn't have to ask for the inputs with a message. Leave the "message" blank if you wish. The user must input the hex-bounds however.

4. As with the values of the 22 hexadecimals are up to you to decide, you must make a program that actually fetches the values from storage, opposed to mimicking a program by simply printing values. (such as a list of $00's).

5. n-amount of inputs, refers to the amount of inputs required for your language of choice to recognise a hexadecimal of two byte-width. eg. (Brainfuck will require two inputs per hex, making it four for the two).

Feel free to comment if you need clarification.

This is code golf, so the shortest answer in the number of bytes is the winner.

 Leaderboard

Here is a leaderboard generating snippet courtesy of Martin Ender.

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>```

function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/95080/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function getAnswers(){$.ajax({url:answersUrl(page++),method:"get",dataType:"jsonp",crossDomain:true,success:function(e){answers.push.apply(answers,e.items);if(e.has_more)getAnswers();else process()}})}function shouldHaveHeading(e){var t=false;var n=e.body_markdown.split("\n");try{t|=/^#/.test(e.body_markdown);t|=["-","="].indexOf(n[1][0])>-1;t&=LANGUAGE_REG.test(e.body_markdown)}catch(r){}return t}function shouldHaveScore(e){var t=false;try{t|=SIZE_REG.test(e.body_markdown.split("\n")[0])}catch(n){}return t}function getAuthorName(e){return e.owner.display_name}function process(){answers=answers.filter(shouldHaveScore).filter(shouldHaveHeading);answers.sort(function(e,t){var n=+(e.body_markdown.split("\n")[0].match(SIZE_REG)||[Infinity])[0],r=+(t.body_markdown.split("\n")[0].match(SIZE_REG)||[Infinity])[0];return n-r});var e={};var t=0,c=0,p=-1;answers.forEach(function(n){var r=n.body_markdown.split("\n")[0];var i=$("#answer-template").html();var s=r.match(NUMBER_REG)[0];var o=(r.match(SIZE_REG)||[0])[0];var u=r.match(LANGUAGE_REG)[1];var a=getAuthorName(n);t++;c=p==o?c:t;i=i.replace("{{PLACE}}",c+".").replace("{{NAME}}",a).replace("{{LANGUAGE}}",u).replace("{{SIZE}}",o).replace("{{LINK}}",n.share_link);i=$(i);p=o;$("#answers").append(i);e[u]=e[u]||{lang:u,user:a,size:o,link:n.share_link}});var n=[];for(var r in e)if(e.hasOwnProperty(r))n.push(e[r]);n.sort(function(e,t){if(e.lang>t.lang)return 1;if(e.lang<t.lang)return-1;return 0});for(var i=0;i<n.length;++i){var s=$("#language-template").html();var r=n[i];s=s.replace("{{LANGUAGE}}",r.lang).replace("{{NAME}}",r.user).replace("{{SIZE}}",r.size).replace("{{LINK}}",r.link);s=$(s);$("#languages").append(s)}}var QUESTION_ID=49042;var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var answers=[],page=1;getAnswers();var SIZE_REG=/\d+(?=[^\d&]*(?:<(?:s>[^&]*<\/s>|[^&]+>)[^\d&]*)*$)/;var NUMBER_REG=/\d+/;var LANGUAGE_REG=/^#*\s*([^,]+)/```
<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

	AuthorLanguageSize

Winners by Language

LanguageUserScore

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

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

Title: The Woz Monitor

Body:
CJam, 22 bytes

{r:~Gb}2*37m!s2/\)<>S*

Chosen values:

00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15
-----------------------------------------------------------------
13 76 37 53 09 12 26 34 50 46 31 59 79 58 15 80 90 24 00 00 00 00

Try it online


问:
Holy Hole In A Donut, Batman!
Some characters are more holy than others. Using as few unholy letters as possible, display the statement above.

Challenge

Write a full program to print Holy Hole In A Donut, Batman! to STDOUT or closest alternative. If you can compress the input to reduce your score, go wild :)

Input

None

Output

```<code>Holy Hole In A Donut, Batman!
</code>```

Rules

This is a code-challenge, and lowest score wins

The desired output can be read from a file, but that should then be counted towards your total.

Trailing newlines are fine in the output

Standard loopholes and T&C's apply

Scoring

Your score is your byte count, plus some modifiers:

Using holy characters 0469abdegopqrADOPQR@# count as 2 points each

Using extra holy characters 8B%$& are 1 point (no penalty)

Using unholy characters 12357cfhijklmnstuvwxyzCEFGHIJKLMNSTUVWXYZ!"^*()[]{}-=_+|\/?,.<>:;'~ carries a heavier penalty and count as 10 points per character.

Space, tab and newlines are 1 point (no penalty).

Any other characters not listed are 10 points.

*On my keyboard the key '$' and '&' are extra holy. Where font variations cause a character to become unholy, defer to the list above

The unmodified string Holy Hole In A Donut, Batman! scores 172

Ruby: puts "Holy Hole In A Donut, Batman!" scores 225

Score checker

@DeadChex has kindly put together a scoring script

Please do let me know if I need to clarify anything. I will update the list of characters if necessary - I've only included the obvious keys at this point. The idea is simple enough though - holes in characters are good.

答:
ferNANDo, 467 points

```<code>8 B
B 8 B B 8 B B B
B 8 8 B 8 8 8 8
B 8 8 B 8 8 B B
B 8 8 8 8 B B 8
B B 8 B B B B B
B 8 B B 8 B B B
B 8 8 B 8 8 8 8
B 8 8 B 8 8 B B
B 8 8 B B 8 B 8
B B 8 B B B B B
B 8 B B 8 B B 8
B 8 8 B 8 8 8 B
B B 8 B B B B B
B 8 B B B B B 8
B B 8 B B B B B
B 8 B B B 8 B B
B 8 8 B 8 8 8 8
B 8 8 B 8 8 8 B
B 8 8 8 B 8 B 8
B 8 8 8 B 8 B B
B B 8 B 8 8 B B
B B 8 B B B B B
B 8 B B B B 8 B
B 8 8 B B B B 8
B 8 8 8 B 8 B B
B 8 8 B 8 8 B 8
B 8 8 B B B B 8
B 8 8 B 8 8 8 B
B B 8 B B B B 8
</code>```

Try it online!

Title: Holy Hole In A Donut, Batman!

Body:
ferNANDo, 467 points

8 B
B 8 B B 8 B B B
B 8 8 B 8 8 8 8
B 8 8 B 8 8 B B
B 8 8 8 8 B B 8
B B 8 B B B B B
B 8 B B 8 B B B
B 8 8 B 8 8 8 8
B 8 8 B 8 8 B B
B 8 8 B B 8 B 8
B B 8 B B B B B
B 8 B B 8 B B 8
B 8 8 B 8 8 8 B
B B 8 B B B B B
B 8 B B B B B 8
B B 8 B B B B B
B 8 B B B 8 B B
B 8 8 B 8 8 8 8
B 8 8 B 8 8 8 B
B 8 8 8 B 8 B 8
B 8 8 8 B 8 B B
B B 8 B 8 8 B B
B B 8 B B B B B
B 8 B B B B 8 B
B 8 8 B B B B 8
B 8 8 8 B 8 B B
B 8 8 B 8 8 B 8
B 8 8 B B B B 8
B 8 8 B 8 8 8 B
B B 8 B B B B 8

<a href="http://fernando.tryitonline.net/#code=OCBCCkIgOCBCIEIgOCBCIEIgQgpCIDggOCBCIDggOCA4IDgKQiA4IDggQiA4IDggQiBCCkIgOCA4IDggOCBCIEIgOApCIEIgOCBCIEIgQiBCIEIKQiA4IEIgQiA4IEIgQiBCCkIgOCA4IEIgOCA4IDggOApCIDggOCBCIDggOCBCIEIKQiA4IDggQiBCIDggQiA4CkIgQiA4IEIgQiBCIEIgQgpCIDggQiBCIDggQiBCIDgKQiA4IDggQiA4IDggOCBCCkIgQiA4IEIgQiBCIEIgQgpCIDggQiBCIEIgQiBCIDgKQiBCIDggQiBCIEIgQiBCCkIgOCBCIEIgQiA4IEIgQgpCIDggOCBCIDggOCA4IDgKQiA4IDggQiA4IDggOCBCCkIgOCA4IDggQiA4IEIgOApCIDggOCA4IEIgOCBCIEIKQiBCIDggQiA4IDggQiBCCkIgQiA4IEIgQiBCIEIgQgpCIDggQiBCIEIgQiA4IEIKQiA4IDggQiBCIEIgQiA4CkIgOCA4IDggQiA4IEIgQgpCIDggOCBCIDggOCBCIDgKQiA4IDggQiBCIEIgQiA4CkIgOCA4IEIgOCA4IDggQgpCIEIgOCBCIEIgQiBCIDg&input=" rel="nofollow">Try it online!


问:
Modulo code golf
Write a function f(a,b) that returns a mod b given the constraints:

you can't use division in any way

f(a,b) is always positive, eg: f(-1,5) = 4

it performs reasonably well for values of ~10e50 for a and b

答:
Python 2, 35 bytes

```<code>f=lambda a,b:a if a<b else f(a-b,b)
</code>```

Sadly, I can't use and/or short-circuiting here, so I have to do with one more byte.

Title: Modulo code golf

Body:
Python 2, 35 bytes

f=lambda a,b:a if a<b else f(a-b,b)

Sadly, I can't use and/or short-circuiting here, so I have to do with one more byte.


答:
PHP+JavaScript, 168 bytes

```<code><?extract($_GET);$s="     ";$s[$f=++$f%5]=o;echo strtr("```   C
AB|─|DE
──|─|── $c",EABCD,$s),($c+=!$f)<$n?"":"";
```

Save to file s.php, call in browser with s.php?n=<n>.

Calls itself with new parameters for every frame, no delay.

I could save 5 more with index.php; but I don´t want to go that far.

Title: So sayeth the Shepherd

Body:
I'm tired, but I can't seem to fall asleep. Help me count sheep.

Given an input N (positive integer), make N sheep jump over an ascii fence, like the sample below. Only one frame should be displayed at once:

```<code>o |-|
──|-|──  0
</code>```

```<code> o|-|
──|-|──  0
</code>```

```<code>   o
  |-|
──|-|──  0
</code>```

```<code>  |-|o
──|-|──  0
</code>```

```<code>  |-| o
──|-|──  0
</code>```

```<code>o |-|
──|-|──  1
</code>```

```<code> o|-|
──|-|──  1
</code>```

```<code>   o
  |-|
──|-|──  1
</code>```

Count should be kept at the lower right side of the 'ground'. Trailing and leading whitespace and newlines are allowed. If your language of choice has difficulty clearing the screen for each frame you can add sufficient newlines to clear the screen - please state how many lines you add for this in your answer. The program should terminate when the N'th sheep is on the fifth floortile.

I need to get up early tomorrow, so shortest code in bytes wins. Please submit a function or complete program. Standard loopholes apply.

Body:
PHP+JavaScript, 168 bytes

<?extract($_GET);$s="     ";$s[$f=++$f%5]=o;echo strtr("<pre>   C
AB|─|DE
──|─|── $c",EABCD,$s),($c+=!$f)<$n?"<script>location.href='s.php?n=$n&c=$c&f=$f'</script>":"";

Save to file s.php, call in browser with s.php?n=<n>.

Calls itself with new parameters for every frame, no delay.

I could save 5 more with index.php; but I don´t want to go that far.


答:
Jelly, <S>55 54</s> 53 bytes

```<code>ị30214D¤“o    ”ṙ“   “
““|-|““
__|-|__  ”ż
×5Ḷµ:5ż@Ç€Y
</code>```

TryItOnline

Prints frames separated by line feeds.

How?

```<code>ị30214D¤“o    ”ṙ“   “
““|-|““
__|-|__  ”ż           - Link 1, build a frame without counts: frameNumber
       ¤              - nilad and link(s) as a nilad:
 30214                -     literal 30214 (a nilad)
      D               -     to decimal: [3,0,2,1,4]
ị                     - index into (1-based and modular, so frames go 4,3,0,2,1,4,...)
        “o    ”       - string "o    "
               ṙ      - rotated to the left by that number
                “   “ - the rest, except the last character, is:
““|-|““               -     an array of strings ["   ","\n","","|-|","","\n__|-|__  "]
__|-|__  ”            -     i.e. split where a sheep might go

          ż           - zip the sheep (the rotated "o    ") into that

×5Ḷµ:5ż@Ç€Y - Main link: nSheep
×5          - multiply by 5 -> nFrames
  Ḷ         - lowered range: [0,1,2,...nFrames-1]
   µ        - monadic chain separation
    :5      - integer division by 5 (vectorises): [5 zeros, 5 ones, ..., 5 (nSheep-1)s]
      ż@    - zip with reversed arguments
        Ç€  - call last link (1) as a monad for each (zip sheep numbers with frames)
          Y - join with line feeds (TODO: replace with future animate frames atom :p)
</code>```

Title: So sayeth the Shepherd

Body:
Jelly, <S>55 54</s> 53 bytes

ị30214D¤“o    ”ṙ“   “
““|-|““
__|-|__  ”ż
×5Ḷµ:5ż@Ç€Y

TryItOnline

Prints frames separated by line feeds.

How?

ị30214D¤“o    ”ṙ“   “
““|-|““
__|-|__  ”ż           - Link 1, build a frame without counts: frameNumber
       ¤              - nilad and link(s) as a nilad:
 30214                -     literal 30214 (a nilad)
      D               -     to decimal: [3,0,2,1,4]
ị                     - index into (1-based and modular, so frames go 4,3,0,2,1,4,...)
        “o    ”       - string "o    "
               ṙ      - rotated to the left by that number
                “   “ - the rest, except the last character, is:
““|-|““               -     an array of strings ["   ","\n","","|-|","","\n__|-|__  "]
__|-|__  ”            -     i.e. split where a sheep might go

          ż           - zip the sheep (the rotated "o    ") into that

×5Ḷµ:5ż@Ç€Y - Main link: nSheep
×5          - multiply by 5 -> nFrames
  Ḷ         - lowered range: [0,1,2,...nFrames-1]
   µ        - monadic chain separation
    :5      - integer division by 5 (vectorises): [5 zeros, 5 ones, ..., 5 (nSheep-1)s]
      ż@    - zip with reversed arguments
        Ç€  - call last link (1) as a monad for each (zip sheep numbers with frames)
          Y - join with line feeds (TODO: replace with future animate frames atom :p)


答:
Ruby, 83 bytes

```<code>->n{(n*5).times{|i|$><<"   c
  |-|
ab|-|de  #{i/5}
".tr('abcde',' '*(i%5)+'o ')}}
</code>```

Prints to stdout. Output separated by newlines. Reducing screen height to 3 makes only one image visible at a time.

Title: So sayeth the Shepherd

Body:
Ruby, 83 bytes

->n{(n*5).times{|i|$><<"   c
  |-|
ab|-|de  #{i/5}
".tr('abcde',' '*(i%5)+'o ')}}

Prints to stdout. Output separated by newlines. Reducing screen height to 3 makes only one image visible at a time.


问:
De-Snakify a String
A regular string looks like this:

```<code>Hello,IAmAStringSnake!
</code>```

And a string snake looks something like this:

```<code>Hel
  l      rin
  o,IAmASt g
           S
       !ekan
</code>```

Your Task

String snakes are dangerous, so you must make a program that takes a string snake as input and outputs it as a regular string.

Specifications

Input can be a multiline string or an array of strings.

Each line of the input will be padded with spaces to form a rectangular grid.

Characters in the snake can only connect to adjacent characters above, below, left or right of them (just like in the game Snake). They cannot go diagonal.

The snake characters will never be adjacent to another part of the snake, only the connected characters.

The first character of the string is the end character with the shortest Manhattan distance from the top-left corner of the input grid (i.e. the minimum number of moves it would take for a snake to go directly from the end character to the top-left corner). Both ends will never have the same distance.

The string can contain any ASCII character between code points 33 and 126 inclusive (no spaces or newlines).

The string will be between 2 and 100 characters long.

Shortest code in bytes wins.

Test Cases

(Input grid, followed by the output string)

```<code>Hel
  l      rin
  o,IAmASt g
           S
       !ekan

Hello,IAmAStringSnake!

----------

Python

Python

----------

P  ngPu  Code
r  i  z  d  G
o  m  z  n  o
gram  lesA  lf

ProgrammingPuzzlesAndCodeGolf

----------

   ~ zyx tsr XWVUTSR
   }|{ wvu q Y     Q
!          p Z `ab P
"#$ 6789:; o [ _ c O
  % 5    < n \]^ d N
('& 432  = m     e M
)     1  > lkjihgf L
*+,-./0  ?         K
         @ABCDEFGHIJ

!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

----------

  tSyrep
  r    p
  in Sli
   g    Sile
   Snakes  n
Ser      ylt
a eh   ilS
fe w   t
   emo h
     Sre

SlipperyStringSnakesSilentlySlitherSomewhereSafe
</code>```

答:
Python 3, 245 243 241 236 bytes

s is the input string, n is the output printed to stdout:

```<code>f=s.find
w,l=f('\n')+1,len(s)
t=1,w,-1,-w
y=z=f(s.strip()[0]);n=s[y];v={y}
for i in range(l*l):
 i%=l;c=s[i]
 if c>' 'and i not in v:
  if i-y in t:y=i;n=c+n;v|={i}
  elif i-z in t:z=i;n+=c;v|={i}
if y%w+y//w>z%w+z//w:n=n[::-1]
print(n)
</code>```

Edit: Thanks to @Cees Timmerman for saving 5 bytes!

Title: De-Snakify a String

Body:
Python 3, 245 243 241 236 bytes

s is the input string, n is the output printed to stdout:

f=s.find
w,l=f('\n')+1,len(s)
t=1,w,-1,-w
y=z=f(s.strip()[0]);n=s[y];v={y}
for i in range(l*l):
 i%=l;c=s[i]
 if c>' 'and i not in v:
  if i-y in t:y=i;n=c+n;v|={i}
  elif i-z in t:z=i;n+=c;v|={i}
if y%w+y//w>z%w+z//w:n=n[::-1]
print(n)

Edit: Thanks to @Cees Timmerman for saving 5 bytes!


问:
Pointers, pointers, pointers!

Introduction

In the error outputs of some languages such as Java, a pointer is shown to give the programmer an idea of exactly where the error went wrong.

Take this example on Ideone:

```<code>Main.java:12: error: ';' expected
    Invalid Java!
                ^
</code>```

Notice the caret shows where the invalid code is?

Challenge

Your challenge is: given number N and string S, place a pointer on the Nth character in S.

Examples

Input: 2, "Lorem ipsum, dollar sit amet."

Output:

```<code>Lorem ipsum, dollar sit amet.
 ^
</code>```

Rules

Input is received via STDIN or function parameters

Output is printed out to the console or returned

Trailing new lines, spaces etc are allowed in the output

The pointer character must be a ^ caret and must be on a new line.

This is code golf, so the shortest answer wins. Good luck!

答:
Vim, 7 keystrokes (buffer input/output, excluding input keystrokes)

o<Esc> + input number + i <Esc>r^

Explanation

o<Esc> creates a new line

#i <Esc> creates # spaces

r^ replaces the last space by ^

Note: This answers does not write the output to stdout (:w !tee, + 6 keystrokes) - so maybe it will be considered invalid.

Title: Pointers, pointers, pointers!


答:
Scala, 45 bytes

```<code>(_:Int)to(_:Int)map(x=>f"$x%02X")mkString " "
</code>```

Ungolfed:

```<code>(a:Int,b:Int)=>a.to(b).map(x=>f"$x%02X").mkString(" ")
</code>```

Uses 00 to FF as values, but works up to 2147483647.

Title: The Woz Monitor

Body:
 Challenge

I've recently gotten into 8-bit computers and are fascinated with the workings of them and others alike; thus the objective of this code golf, is to replicate a portion of the Woz Monitor, designed by Steve Wozniak for the Apple I.

You are to store an array of 22 hexadecimal values with a width of two bytes, (min value $10, max value $FF), and then take in n-amount of inputs. (Normally two; languages like Brainfuck might have a hard time).

The inputs will refer to where in the array to start printing from, and where to stop; an input with defined behaviour will have their starting value less or equal to the ending value. Your program must then be capable of printing every hexadecimal value between, and including, the hexadecimals inputted.

An example of this:

```<code>Array
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15

Values
FF F4 B6 D7 40 00 00 A4 F0 00 FF 0D 9C 21 65 C4 02 28 90 E7 D6 A5
</code>```

```<code>input first num:
04
input second num:
14
40 00 00 A4 F0 00 FF 0D 9C 21 65 C4 02 28 90 E7 D6
</code>```

Now the interesting part of this exercise, is that you can use whatever you want to check the bounds of the users input. Person inputs hello and your program has undefined behaviour? It quits without notice? They are both valid.

The only rules are:

1. You must include the values of the 22 hexadecimal values as part of your program before it starts, (can't ask the user for inputs).

2. The output of the hexadecimal values must follow the exact format:
    00 FF 00 FF 00 Trailing spaces, tabs or lines are OK. Characters are not.

3. The program doesn't have to ask for the inputs with a message. Leave the "message" blank if you wish. The user must input the hex-bounds however.

4. As with the values of the 22 hexadecimals are up to you to decide, you must make a program that actually fetches the values from storage, opposed to mimicking a program by simply printing values. (such as a list of $00's).

5. n-amount of inputs, refers to the amount of inputs required for your language of choice to recognise a hexadecimal of two byte-width. eg. (Brainfuck will require two inputs per hex, making it four for the two).

Feel free to comment if you need clarification.

This is code golf, so the shortest answer in the number of bytes is the winner.

 Leaderboard

Here is a leaderboard generating snippet courtesy of Martin Ender.

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>```

function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/95080/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function getAnswers(){$.ajax({url:answersUrl(page++),method:"get",dataType:"jsonp",crossDomain:true,success:function(e){answers.push.apply(answers,e.items);if(e.has_more)getAnswers();else process()}})}function shouldHaveHeading(e){var t=false;var n=e.body_markdown.split("\n");try{t|=/^#/.test(e.body_markdown);t|=["-","="].indexOf(n[1][0])>-1;t&=LANGUAGE_REG.test(e.body_markdown)}catch(r){}return t}function shouldHaveScore(e){var t=false;try{t|=SIZE_REG.test(e.body_markdown.split("\n")[0])}catch(n){}return t}function getAuthorName(e){return e.owner.display_name}function process(){answers=answers.filter(shouldHaveScore).filter(shouldHaveHeading);answers.sort(function(e,t){var n=+(e.body_markdown.split("\n")[0].match(SIZE_REG)||[Infinity])[0],r=+(t.body_markdown.split("\n")[0].match(SIZE_REG)||[Infinity])[0];return n-r});var e={};var t=0,c=0,p=-1;answers.forEach(function(n){var r=n.body_markdown.split("\n")[0];var i=$("#answer-template").html();var s=r.match(NUMBER_REG)[0];var o=(r.match(SIZE_REG)||[0])[0];var u=r.match(LANGUAGE_REG)[1];var a=getAuthorName(n);t++;c=p==o?c:t;i=i.replace("{{PLACE}}",c+".").replace("{{NAME}}",a).replace("{{LANGUAGE}}",u).replace("{{SIZE}}",o).replace("{{LINK}}",n.share_link);i=$(i);p=o;$("#answers").append(i);e[u]=e[u]||{lang:u,user:a,size:o,link:n.share_link}});var n=[];for(var r in e)if(e.hasOwnProperty(r))n.push(e[r]);n.sort(function(e,t){if(e.lang>t.lang)return 1;if(e.lang<t.lang)return-1;return 0});for(var i=0;i<n.length;++i){var s=$("#language-template").html();var r=n[i];s=s.replace("{{LANGUAGE}}",r.lang).replace("{{NAME}}",r.user).replace("{{SIZE}}",r.size).replace("{{LINK}}",r.link);s=$(s);$("#languages").append(s)}}var QUESTION_ID=49042;var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var answers=[],page=1;getAnswers();var SIZE_REG=/\d+(?=[^\d&]*(?:<(?:s>[^&]*<\/s>|[^&]+>)[^\d&]*)*$)/;var NUMBER_REG=/\d+/;var LANGUAGE_REG=/^#*\s*([^,]+)/```
<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

	AuthorLanguageSize

Winners by Language

LanguageUserScore

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

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

Body:
Scala, 45 bytes

(_:Int)to(_:Int)map(x=>f"$x%02X")mkString " "

Ungolfed:

(a:Int,b:Int)=>a.to(b).map(x=>f"$x%02X").mkString(" ")

Uses 00 to FF as values, but works up to 2147483647.


问:
Make your language unusable
Try to write some code in your language and make it not satisfying our criteria of being a programming language any more.

A language satisfies our criteria (simplified version for this challenge) of being a programming language if:

It can read user input representing tuples of positive integers in some way.

It can output at least two different possible results depending on the input.

It can take two positive integers and add them (and the result can affect the output).

It can take a positive integer and decide whether it is a prime (and the result can affect the output).

For the purpose of this challenge, any kind of output that isn't an allowed output method for a normal challenge is ignored. So it doesn't matter whether the program can also play a piece of music, or posting via HTTP, etc.

Update: You can also choose one or some of the allowed output methods, and ignore all the others. But you must use the same definition everywhere in the following criteria. And if your program can disable more than one output methods — that worths more upvotes.

Examples like making it not able to output, or disabling all the loop constructs so it won't be able to do primality test and making sure the user cannot re-enable them.

You should leave a place for inserting new code. By default, it is at the end of your code. If we consider putting the source code in that place in your answer and running the full code as a complete program the interpreter of a new language, that language should not satisfy the criteria.

But the inserted code must be executed in such a way like a language satisfying the criteria:

The inserted code must be grammatically the same as something (say it's a code block in the following criteria) that generally do satisfy the criteria, from the perspective of whoever wants to write a syntax highlighter. So it cannot be in a string, comment, etc.

The inserted code must be actually executed, in a way it is supposed to satisfy the criteria. So it cannot be in an unused function or sizeof in C, you cannot just execute only a non-functional part in the code, and you cannot put it after an infinite loop, etc.

You can't limit the number of possible grammatically correct programs generated this way. If there is already something like a length limit in the language you are using, it shouldn't satisfy the criteria even if this limit is removed.

You can't modify or "use up" the content of input / output, but you can prevent them from being accessed.

These criteria usually only applies to languages without explicit I/O:

Your code should redirect the user input (that contains informations of arbitrary length) to the inserted code, if a code block isn't usually able to get the user input directly / explicitly in the language you are using.

Your code should print the returned value of the inserted code, if a code block isn't usually able to output things directly / explicitly in the language you are using.

In case you print the returned value, and it is typed in the language you are using, the returned type should be able to have 2 different practically possible values. For example, you cannot use the type struct {} or struct {private:int x;} in C++.

This is popularity-contest. The highest voted valid answer (so nobody spotted an error or all errors are fixed) wins.

Clarifications

You shouldn't modify the code in the text form, but can change the syntax before the code is interpreted or compiled.

You can do other things while the code is running. But the reason that it doesn't satisfy the criteria should be within the inserted code itself. It can error because of the interference of another thread, but not just be killed by another thread.

All the specs basically means it should be grammatically likely satisfying the criteria if all the built-ins were not changed but not actually do. It's fine if you find any non-grammatical workarounds, such as passing the parameters to the code block correctly, but make them not able to be used in some way.

Again, the inserted code must be actually executed. Code after an infinite loop or crashing is considered "not actually executed", thus not valid. Those answers might be interesting, but there are already some other infinite loop or crashing questions on this site, and you may find a more appropriate one to answer. If not, consider asking a new question. Examples of those questions are:

Shortest infinite loop producing no output

Why isn't it ending?

Loop without 'looping'

Challenge: Write a piece of code that quits itself

Ridiculous Runtime Errors

Crash your favorite compiler

Leaderboard

var QUESTION_ID=61115/*,OVERRIDE_USER=8478*/;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,/*getComments()*/(more_answers?getAnswers():process())}})}/*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),score:s.score,language:a[1],lang:jQuery('
').html(a[1]).text(),link:s.share_link})}),e.sort(function(e,s){var r=e.score,a=s.score;return a-r});var s={},r=1,a=null,n=1;e.forEach(function(e){e.score!=a&&(n=r),a=e.score,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",e.n=n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.score).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang.toUpperCase())-(e.lang.toUpperCase()<s.lang.toUpperCase())||(e.lang>s.lang)-(e.lang<s.lang)});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{PLACE}}",o.n).replace("{{LANGUAGE}}",o.language).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.score).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|(?!.*<h\d>)p)>\s*((?:[^,;(\s]| +[^-,;(\s])+)(?=(?: *(?:[,;(]| -).*?)?\s*<\/(h\d|p)>)/,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;float:left}table{width:250px}table thead{font-weight:700}table td{padding:5px}</code>```

 <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/all.css?v=7509797c03ea">

Leaderboard

	Author	Language	Score

Sorted by Language

	Language	User	Score

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

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

```

答:
///

```<code>/\///
</code>```

The only operation in /// is repeated string substitution, like this: /pattern/replacement/.

This code removes every /, that way you can't use repeated string substitution, so basically everything you write after that will get printed (except for /s).

You can still use \s, but that won't help you much.

Title: Make your language unusable

Body:
///

/\///

The only operation in /// is repeated string substitution, like this: /pattern/replacement/.

This code removes every /, that way you can't use repeated string substitution, so basically everything you write after that will get printed (except for /s).

You can still use \s, but that won't help you much.


答:
C++, <s>98</s> <s>95</s> 93 bytes

```<code>#include <iostream>
int _[22],a,b;int main(){for(std::cin>>a>>b;b/a++;)printf("%02x ",_[a]);}
</code>```

My chosen values are all 0's

Title: The Woz Monitor

Body:
C++, <s>98</s> <s>95</s> 93 bytes

#include <iostream>
int _[22],a,b;int main(){for(std::cin>>a>>b;b/a++;)printf("%02x ",_[a]);}

My chosen values are all 0's


问:
Pen Pineapple Apple Pen!
Your task is to print the following:

```<code>I have a pen
I have an apple
Uh! Apple pen!

I have a pen
I have pineapple
Uh! Pineapple pen!

Apple pen...
Pineapple pen...
Uh! Pen Pineapple Apple Pen!
</code>```

Remember, this is code-golf, so the code with the smallest number of bytes wins.

Leaderboards

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

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

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

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

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

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

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

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

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

var QUESTION_ID=95124,OVERRIDE_USER=12537;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

```

Title: Pen Pineapple Apple Pen!

Body:
///, 117 bytes

/@/I have //#/apple//$/Apple //&/Uh! //%/pen//*/Pine/@a %
@an #
&$%!

@a %
@pine#
&*# %!

$%...
*# %...
&Pen *# $Pen!

Try it online!


问:
Priority to the right
Your task is to regulate traffic on a crossroads. There are 4 roads coming from north, east, south and west.

The input is a string representing the upcoming traffic on each road. For example, NNNWS indicates there is a total of 5 cars: three at the north, one at the west and one at the south. The order of characters has no importance here, NNNWS is equivalent to WNNSN.

You must output the order in which the cars should go, using the priority to the right rule: cars coming from the south must let cars coming from east go first, east gives way to north, north gives way to west and west gives way to south.

For example, with the input NNNWS, the south car should go first, then the west car, then the 3 north cars. The output should thus be SWNNN.

There are some indecidable cases, for example NS or NNWSE : you should then output the string stuck.

Test cases

```<code>N => N
NW => WN
NWS => SWN
SNW => SWN
SSSSS => SSSSS
ENNNNES => NNNNEES
NS => stuck
NNWSE => stuck
</code>```

答:
PHP, 267 Bytes

use the new spaceship operator and usort
-5 Bytes by @IsmaelMiguel

```<code><?foreach($f=[E,S,W,N]as$l)$s.=+!($r=strstr)($i=$argv[1],$l);if(in_array($s,[0101,1010,0000]))die(stuck);$x=($p=strpos)($s,"1");$t=$r($j=join($f),$f[$x]).$r($j,$f[$x],1);$a=str_split($i);usort($a,function($x,$y)use($t,$p){return$p($t,$x)<=>$p($t,$y);});echo join($a);
</code>```

Breakdown

```<code># Extended Version without notices
$s="";
foreach($f=["E","S","W","N"] as $l){$s.=+!strstr($i=$argv[1],$l);} #bool concat swap the false true values in string
if(in_array($s,["0101","1010","0000"])){die("stuck");} # NS WE NESW -> stuck = end program
$x=strpos($s,"1"); # find the first false value for an begin for the sort algorithm
$t=strstr($j=join($f),$f[$x]).strstr($j,$f[$x],1); # create the sort pattern
#sort algorithm example sort string = NESW-> N is not in the string
function c($x,$y){
    global $t;
    return strpos($t,$x)<=>strpos($t,$y); # e.g. comparison E<=>W =-1 , W<=>S=1, W<=>W =0
}
$a=str_split($i); # Input in an array
usort($a,"c"); #sort array
echo join($a);# output array as string
</code>```

Title: Priority to the right

Body:
PHP, 267 Bytes

use the new spaceship operator and usort
-5 Bytes by @IsmaelMiguel

<?foreach($f=[E,S,W,N]as$l)$s.=+!($r=strstr)($i=$argv[1],$l);if(in_array($s,[0101,1010,0000]))die(stuck);$x=($p=strpos)($s,"1");$t=$r($j=join($f),$f[$x]).$r($j,$f[$x],1);$a=str_split($i);usort($a,function($x,$y)use($t,$p){return$p($t,$x)<=>$p($t,$y);});echo join($a);

Breakdown

# Extended Version without notices
$s="";
foreach($f=["E","S","W","N"] as $l){$s.=+!strstr($i=$argv[1],$l);} #bool concat swap the false true values in string
if(in_array($s,["0101","1010","0000"])){die("stuck");} # NS WE NESW -> stuck = end program
$x=strpos($s,"1"); # find the first false value for an begin for the sort algorithm
$t=strstr($j=join($f),$f[$x]).strstr($j,$f[$x],1); # create the sort pattern
#sort algorithm example sort string = NESW-> N is not in the string
function c($x,$y){
    global $t;
    return strpos($t,$x)<=>strpos($t,$y); # e.g. comparison E<=>W =-1 , W<=>S=1, W<=>W =0
}
$a=str_split($i); # Input in an array
usort($a,"c"); #sort array
echo join($a);# output array as string


答:
Batch, 203 bytes

```<code>@echo off
set e=echo(
call:l "an a" A
call:l pinea Pinea
%e%Apple pen...
%e%Pineapple pen...
%e%Uh! Pen Pineapple Apple Pen!
exit/b
:l
%e%I have a pen
%e%I have %~1pple
%e%Uh! %2pple pen!
%e%
</code>```

Batch is so verbose that the set e=echo( saves a whole byte. (Worth it of course for code golf purposes.)

Title: Pen Pineapple Apple Pen!

Body:
Your task is to print the following:

```<code>I have a pen
I have an apple
Uh! Apple pen!

I have a pen
I have pineapple
Uh! Pineapple pen!

Apple pen...
Pineapple pen...
Uh! Pen Pineapple Apple Pen!
</code>```

Remember, this is code-golf, so the code with the smallest number of bytes wins.

Leaderboards

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

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

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

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

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

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

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

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

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

var QUESTION_ID=95124,OVERRIDE_USER=12537;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:
Batch, 203 bytes

@echo off
set e=echo(
call:l "an a" A
call:l pinea Pinea
%e%Apple pen...
%e%Pineapple pen...
%e%Uh! Pen Pineapple Apple Pen!
exit/b
:l
%e%I have a pen
%e%I have %~1pple
%e%Uh! %2pple pen!
%e%

Batch is so verbose that the set e=echo( saves a whole byte. (Worth it of course for code golf purposes.)


问:
How much will this cost?
Given N items (0 < N <= 50) with prices (which are always integers) P0 ... PN-1 and given amounts of each item A0 ... AN-1, determine how much the total cost will be.

Examples

N: 2

P0: 2

P1: 3

A0: 1

A1: 4

Result: 14

N: 5

P0: 2

P1: 7

P2: 5

P3: 1

P4: 9

A0: 1

A1: 2

A2: 3

A3: 2

A4: 3

Result: 60

Remember, this is code-golf, so the code with the smallest number of bytes wins.

Leaderboards

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

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

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

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

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

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

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

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

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

var QUESTION_ID=95128,OVERRIDE_USER=12537;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

```

答:
PHP, 46 Bytes

```<code><?foreach($_GET[a]as$n)$s+=$n[0]*$n[1];echo$s;
</code>```

48 Bytes

```<code><?=array_sum(array_map(array_product,$_GET[a]));
</code>```

Title: How much will this cost?

Body:
PHP, 46 Bytes

<?foreach($_GET[a]as$n)$s+=$n[0]*$n[1];echo$s;

48 Bytes

<?=array_sum(array_map(array_product,$_GET[a]));


答:
Ruby, <s>34</s> 23 + 9 = 32 bytes

+9 bytes for -rmatrix flag.

```<code>->p,a{Vector[*p].dot a}
</code>```

See it on eval.in: https://eval.in/653676

Title: How much will this cost?

Body:
Given N items (0 < N <= 50) with prices (which are always integers) P0 ... PN-1 and given amounts of each item A0 ... AN-1, determine how much the total cost will be.

Examples

N: 2

P0: 2

P1: 3

A0: 1

A1: 4

Result: 14

N: 5

P0: 2

P1: 7

P2: 5

P3: 1

P4: 9

A0: 1

A1: 2

A2: 3

A3: 2

A4: 3

Result: 60

Remember, this is code-golf, so the code with the smallest number of bytes wins.

Leaderboards

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

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

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

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

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

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

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

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

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

var QUESTION_ID=95128,OVERRIDE_USER=12537;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:
Ruby, <s>34</s> 23 + 9 = 32 bytes

+9 bytes for -rmatrix flag.

->p,a{Vector[*p].dot a}

See it on eval.in: https://eval.in/653676


答:
Jelly, 2 bytes

```<code>æ.
</code>```

Try it online!

A built-in computing the dot product between two input vectors: if, for each 1 ≤ i ≤ n, we buy ai items worth pi each, the formula for the total cost is a1p1 + a2p2 + … +anpn, which is precisely the definition of the dot product.

Title: How much will this cost?

Body:
Jelly, 2 bytes

æ.

Try it online!

A built-in computing the dot product between two input vectors: if, for each 1 ≤ i ≤ n, we buy ai items worth pi each, the formula for the total cost is a1p1 + a2p2 + … +anpn, which is precisely the definition of the dot product.


Title: Pen Pineapple Apple Pen!

Body:
Bubblegum, 72 bytes

00000000: f354 c848 2c4b 5548 5428 48cd e3f2 8472  .T.H,KUHT(H....r
00000010: f214 120b 0a72 52b9 4233 1415 1c41 2c90  .....rR.B3...A,.
00000020: ac22 175c 1e59 7141 665e 2a42 7500 8c07  .".\.YqAf^*Bu...
00000030: d501 d7ad a7a7 c785 2209 1200 eb48 cd43  ........"....H.C
00000040: d205 510f 1453 0400                      ..Q..S..

<a href="http://bubblegum.tryitonline.net/#code=MDAwMDAwMDA6IGYzNTQgYzg0OCAyYzRiIDU1NDggNTQyOCA0OGNkIGUzZjIgODQ3MiAgLlQuSCxLVUhUKEguLi4ucgowMDAwMDAxMDogZjIxNCAxMjBiIDBhNzIgNTJiOSA0MjMzIDE0MTUgMWM0MSAyYzkwICAuLi4uLnJSLkIzLi4uQSwuCjAwMDAwMDIwOiBhYzIyIDE3NWMgMWU1OSA3MTQxIDY2NWUgMmE0MiA3NTAwIDhjMDcgIC4iLlwuWXFBZl4qQnUuLi4KMDAwMDAwMzA6IGQ1MDEgZDdhZCBhN2E3IGM3ODUgMjIwOSAxMjAwIGViNDggY2Q0MyAgLi4uLi4uLi4iLi4uLkguQwowMDAwMDA0MDogZDIwNSA1MTBmIDE0NTMgMDQwMCAgICAgICAgICAgICAgICAgICAgICAuLlEuLlMuLg&input=" rel="nofollow noreferrer">Try it online!

The above is the xxd hexdump of the actual code.


问:
Now I know my ABCs, won't you come and golf with me?
Write a program or function that outputs this exact text, case-insensitive:

```<code>A, B, C, D, E, F, G,
H, I, J, K, L, M, N, O, P,
Q, R, S,
T, U, V,
W, X, Y, Z.
</code>```

(Based on the alphabet song that many American kids learn to help memorize the alphabet, though edited for more compressibility.)

The output must look exactly the same as the above (again, case-insensitive), but may contain trailing spaces on each line and/or trailing newlines. Notice the period at the end.

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

答:
CJam, 26 bytes

```<code>'A79333Ab{{',S2$)}*N\}/'.@
</code>```

Online interpreter

```<code>'A                             Push 'A'
  79333Ab                      Push [7 9 3 3 3]
         {           }/        For each number n in the previous array...
          {      }*              Execute n times...
           ',S                     Push a comma and a space
              2$)                  Copy last letter and increment
                   N\            Place a newline under the letter on top
                       '.@     Push '.' and rotate
</code>```

Body:
CJam, 26 bytes

'A79333Ab{{',S2$)}*N\}/'.@

Online interpreter

'A                             Push 'A'
  79333Ab                      Push [7 9 3 3 3]
         {           }/        For each number n in the previous array...
          {      }*              Execute n times...
           ',S                     Push a comma and a space
              2$)                  Copy last letter and increment
                   N\            Place a newline under the letter on top
                       '.@     Push '.' and rotate


答:
Actually, 1 byte

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

Try it online!

Okay, this is the shortest dot product built-in I could find. >_>

Title: How much will this cost?

Body:
Actually, 1 byte

*

Try it online!

Okay, this is the shortest dot product built-in I could find. >_>


答:
Haskell, 17 bytes

(sum.).zipWith(*)
```

<p>Multiply the lists entrywise, then sum. Shorter than importing (23 bytes)</p>

<pre class="lang-haskell prettyprint-override"><code>import Data.Vector
vdot
</code>```

Title: How much will this cost?

Body:
Haskell, 17 bytes

(sum.).zipWith(*)

Multiply the lists entrywise, then sum. Shorter than importing (23 bytes)

import Data.Vector
vdot


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

lambda*x:sum(map(int.__mul__,*x))
```

Thanks to @xnor for golfing off 3 bytes!

Test it on Ideone.

Title: How much will this cost?

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

lambda*x:sum(map(int.__mul__,*x))

Thanks to @xnor for golfing off 3 bytes!

Test it on Ideone.


答:
Pyth, 3 bytes

```<code>s*V
</code>```

(s)ums the (V)ectorized (*)product of the two input arrays.

Title: How much will this cost?

Body:
Pyth, 3 bytes

s*V

(s)ums the (V)ectorized (*)product of the two input arrays.


答:
Jelly, 94 bytes

```<code>“/¢ȷKcḞvßÇwİµɼUṡ]nk]¹¤%Ƭ*|ẊƓẸḢÇ2ẋbịʋ]dṀ⁸)ṇẎ⁶ėDṭD’b⁴ị“I“have“a“p“en“¶“n“A“pple“Uh“!“ine“P“...“
</code>```

TryItOnline

How?

Manual compression:

I looked for strings that repeated and made a list, there were 15.

I ordered these like so:

“I“have“a“p“en“¶“n“A“pple“Uh“!“ine“P“...“

so as to make the smallest base-16 number from the text (with no leading 0)

here: “ separates; ¶ represents a line feed; and the last entry (index 0) is a space.

I then converted the number to base-250 and wrote it out in the first 250 of the 256 characters in the Jelly code-page:

/¢ȷKcḞvßÇwİµɼUṡ]nk]¹¤%Ƭ*|ẊƓẸḢÇ2ẋbịʋ]dṀ⁸)ṇẎ⁶ėDṭD

The code the inverses the same process:
“(base-250-encoded-number)’

b⁴ị - base 16, index into

“I“have“a“p“en“¶“n“A“pple“Uh“!“ine“P“...“

Note: base-15 would have the same byte-count, one less in the encoded number but one more to decode as literal 15 is 15 whereas literal 16 is ⁴. Maybe a substring list of 16 items could cost less in total.

Title: Pen Pineapple Apple Pen!

Body:
Jelly, 94 bytes

“/¢ȷKcḞvßÇwİµɼUṡ]nk]¹¤%Ƭ*|ẊƓẸḢÇ2ẋbịʋ]dṀ⁸)ṇẎ⁶ėDṭD’b⁴ị“I“have“a“p“en“¶“n“A“pple“Uh“!“ine“P“...“

TryItOnline

How?

Manual compression:

I looked for strings that repeated and made a list, there were 15.

I ordered these like so:

“I“have“a“p“en“¶“n“A“pple“Uh“!“ine“P“...“

so as to make the smallest base-16 number from the text (with no leading 0)

here: “ separates; ¶ represents a line feed; and the last entry (index 0) is a space.

I then converted the number to base-250 and wrote it out in the first 250 of the 256 characters in the Jelly code-page:

/¢ȷKcḞvßÇwİµɼUṡ]nk]¹¤%Ƭ*|ẊƓẸḢÇ2ẋbịʋ]dṀ⁸)ṇẎ⁶ėDṭD

The code the inverses the same process:
“(base-250-encoded-number)’

b⁴ị - base 16, index into

“I“have“a“p“en“¶“n“A“pple“Uh“!“ine“P“...“

Note: base-15 would have the same byte-count, one less in the encoded number but one more to decode as literal 15 is 15 whereas literal 16 is ⁴. Maybe a substring list of 16 items could cost less in total.


Title: Pen Pineapple Apple Pen!

Body:
JavaScript (ES6), <s>145</s> 143 bytes

_=>`P325|I have |pple|inea|
Uh! | pen`.split`|`.reduce((s,r,i)=>s.split(i).join(r),`1a5
1an a24A25!

1a5
1p3240!

A25...
0...4Pen P32 A2 Pen!`)

let f =

_=>`P325|I have |pple|inea|
Uh! | pen`.split`|`.reduce((s,r,i)=>s.split(i).join(r),`1a5
1an a24A25!

1a5
1p3240!

A25...
0...4Pen P32 A2 Pen!`)

console.log(f());


问:
Am I old enough?
It is currently December 31, 2015, 11:59:00pm, and you must be at least 1324900 seconds old to be able to go to the New Year Celebration. Given the year, month, day, hour, minute, and second of your birth, determine if you are old enough to go.

Notes:

Assume that you are in the same timezone.

Leap years are every 4 years, but if the year is a multiple of 100, it is not a leap year, unless it is a multiple of 400.

Remember, this is code-golf, so the code with the smallest number of bytes wins.

Leaderboards

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

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

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

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

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

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

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

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

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

var QUESTION_ID=95129,OVERRIDE_USER=12537;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

```

答:
Mathematica, 66 bytes

```<code>DateObject@{2015,12,31,23,59,0}-DateObject@#>1324899~Quantity~"s"&
</code>```

Anonymous function. Takes a list of integers as input, and returns True or False as output.

Title: Am I old enough?

Body:
Mathematica, 66 bytes

DateObject@{2015,12,31,23,59,0}-DateObject@#>1324899~Quantity~"s"&

Anonymous function. Takes a list of integers as input, and returns True or False as output.


答:
Perl, 139 bytes

With UNIX line terminators (LF = one byte) :

```<code>s//0an a1
5A12!

0p4
5P42!

A123P4235Pen P4A1Pen!/;s/4/inea1/g;s/0/I have a pen
I have /g;s/1/pple /g;s/2/pen/g;s/3/...
/g;s/5/Uh! /g;print
</code>```

Title: Pen Pineapple Apple Pen!

Body:
Perl, 139 bytes

With UNIX line terminators (LF = one byte) :

s//0an a1
5A12!

0p4
5P42!

A123P4235Pen P4A1Pen!/;s/4/inea1/g;s/0/I have a pen
I have /g;s/1/pple /g;s/2/pen/g;s/3/...
/g;s/5/Uh! /g;print


答:
Python, 28 bytes

[2015,12,16,15,57,20].__le__
```

Going back 1324900 seconds from December 31, 2015, 11:59:00pm gives December 16, 2015 at 3:57:20 pm. We convert this date to a list and take it's less-than-or-equals method to compare to the input list. This compares it lexicographically, so first by year, then by month, and so on.

Title: Am I old enough?

Body:
It is currently December 31, 2015, 11:59:00pm, and you must be at least 1324900 seconds old to be able to go to the New Year Celebration. Given the year, month, day, hour, minute, and second of your birth, determine if you are old enough to go.

Notes:

Assume that you are in the same timezone.

Leap years are every 4 years, but if the year is a multiple of 100, it is not a leap year, unless it is a multiple of 400.

Remember, this is code-golf, so the code with the smallest number of bytes wins.

Leaderboards

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

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

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

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

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

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

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

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

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

var QUESTION_ID=95129,OVERRIDE_USER=12537;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:
Python, 28 bytes

[2015,12,16,15,57,20].__le__

Going back 1324900 seconds from December 31, 2015, 11:59:00pm gives December 16, 2015 at 3:57:20 pm. We convert this date to a list and take it's less-than-or-equals method to compare to the input list. This compares it lexicographically, so first by year, then by month, and so on.


答:
MATL, 2 bytes

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

Try it online!

```<code>*     % Element-wise product of two implicit inputs
s     % Sum of array, implicitly displayed
</code>```

Title: How much will this cost?

Body:
MATL, 2 bytes

*s

Try it online!

*     % Element-wise product of two implicit inputs
s     % Sum of array, implicitly displayed


答:
MATLAB / Octave, 4 bytes

```<code>@dot
</code>```

This defines an anonymous function.

Try it at Ideone.

Title: How much will this cost?

Body:
MATLAB / Octave, 4 bytes

@dot

This defines an anonymous function.

Try it at Ideone.


Title: How much will this cost?

Body:
Given N items (0 < N <= 50) with prices (which are always integers) P0 ... PN-1 and given amounts of each item A0 ... AN-1, determine how much the total cost will be.

Examples

N: 2

P0: 2

P1: 3

A0: 1

A1: 4

Result: 14

N: 5

P0: 2

P1: 7

P2: 5

P3: 1

P4: 9

A0: 1

A1: 2

A2: 3

A3: 2

A4: 3

Result: 60

Remember, this is code-golf, so the code with the smallest number of bytes wins.

Leaderboards

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

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

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

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

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

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

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

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

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

var QUESTION_ID=95128,OVERRIDE_USER=12537;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:
Mathematica, 1 byte

.

Usage:

{1, 2, 3}.{4, 5, 6}

(* 32 *)


问:
Tips for golfing in Python
What general tips do you have for golfing in Python? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Python (e.g. "remove comments" is not an answer).

Please post one tip per answer.

答:
Object method as answer

Your submission can be a method of an object

range(123,790,111).count
```
<p>This defines an anonymous function much shorter than</p>
<pre class="lang-python prettyprint-override"><code>lambda n:range(123,790,111).count(n)
</code>```

The object method is a valid function that meets our definition. For example, it could be bound and called

f=range(123,790,111).count
print f(99)
```
<p>Because it avoids a costly <code>lambda</code>, this saves characters even rewriting from</p>
<pre class="lang-python prettyprint-override"><code>lambda n:n in range(123,790,111)
</code>```

Consider using an object method when your solution is a simple two-input function of your input and some concrete object. You can use dir() to get a list of methods of an object. Note in particular methods like .__add__ that are called for an operator like +. Most infix operators correspond to a method.

Other examples:

"prefix{}suffix".format
lambda s:"prefix"+s+"suffix"

2 .__rpow__    #Space for lexer
lambda n:n*n

[0,0].__le__
lambda l:[0,0]<=l
```
<p>You can even sometimes save bytes with two input by currying. For example, compare</p>
<pre class="lang-python prettyprint-override"><code>lambda l:expression_in_l.count
lambda n,l:n in expression_in_l
</code>```

where expression_in_l produces a list with no duplicates and has favorable spacing and precedence.

Title: Tips for golfing in Python

Body:
Object method as answer

Your submission can be a method of an object

range(123,790,111).count

This defines an anonymous function much shorter than

lambda n:range(123,790,111).count(n)

The object method is a valid function that meets our definition. For example, it could be bound and called

f=range(123,790,111).count
print f(99)

Because it avoids a costly lambda, this saves characters even rewriting from

lambda n:n in range(123,790,111)

Consider using an object method when your solution is a simple two-input function of your input and some concrete object. You can use dir() to get a list of methods of an object. Note in particular methods like .__add__ that are called for an operator like +. Most infix operators correspond to a method.

Other examples:

"prefix{}suffix".format
lambda s:"prefix"+s+"suffix"

2 .__rpow__    #Space for lexer
lambda n:n*n

[0,0].__le__
lambda l:[0,0]<=l

You can even sometimes save bytes with two input by currying. For example, compare

lambda l:expression_in_l.count
lambda n,l:n in expression_in_l

where expression_in_l produces a list with no duplicates and has favorable spacing and precedence.

ContentLicense: CC BY-SA 4.0


问:
Draw an ASCII Rectangle
Given two integers as input in an array, draw a rectangle, using the first integer as width and second as height.

Or, if your language supports it, the two integers can be given as separate inputs.

Assume the width and height will never be less than 3, and they will always be given.

Example Outputs:

[3, 3]

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

[5, 8]

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

[10, 3]

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

This is code-golf, so the answer with the lowest amount of bytes wins.

Title: Draw an ASCII Rectangle

Body:
Racket 108 bytes

(λ(w h)(for((j h))(display #\|)(for((i(- w 2)))(display(if(or(= j 0)(= j(- h 1)))#\-" ")))(displayln #\|)))

Ungolfed:

(define f
  (λ (w h)
    (for ((j h))
      (display #\|)
      (for ((i (- w 2)))
        (display (if (or
                      (= j 0)
                      (= j (- h 1)))
                     #\-
                     " ")))
      (displayln #\|))))

Testing:

(f 5 3)

Output:

|---|
|   |
|---|


答:
Tcl, 168 bytes

Version using 10-row-high screen. (Replace the 7 below with your screen height in columns minus four.)

```<code>set s {0 1 2 3 4 }
for {set n 0} {$n<$argv} {incr n} {foreach x $s {
puts [string repe \n 6][string map [split $s {}] [string map "$x o" {   2
01|-|34
--|-|--  }]]$n}}
</code>```

That runs really fast, so you can add a pause on line two:

Tcl, 177 bytes

```<code>set s {0 1 2 3 4 }
for {set n 0} {$n<$argv} {incr n} {foreach x $s {after 250
puts [string repe \n 6][string map [split $s {}] [string map "$x o" {   2
01|-|34
--|-|--  }]]$n}}
</code>```

It works by reusing the string at the top for two different things:

as a list for the inner loop (to display each version of the sheep+fence)

as a mapping of digit→space to remove digits from the sheep+fence image template

The template itself is the string image to display. First we map (string replace) the sheep's current position digit (inner loop) to an 'o'. Then we map the remaining digits to spaces. Then we print the resulting string.

(The string itself starts after the last { on the third line and ends with the leftmost } on the last line.)

Title: So sayeth the Shepherd

Body:
I'm tired, but I can't seem to fall asleep. Help me count sheep.

Given an input N (positive integer), make N sheep jump over an ascii fence, like the sample below. Only one frame should be displayed at once:

```<code>o |-|
──|-|──  0
</code>```

```<code> o|-|
──|-|──  0
</code>```

```<code>   o
  |-|
──|-|──  0
</code>```

```<code>  |-|o
──|-|──  0
</code>```

```<code>  |-| o
──|-|──  0
</code>```

```<code>o |-|
──|-|──  1
</code>```

```<code> o|-|
──|-|──  1
</code>```

```<code>   o
  |-|
──|-|──  1
</code>```

Count should be kept at the lower right side of the 'ground'. Trailing and leading whitespace and newlines are allowed. If your language of choice has difficulty clearing the screen for each frame you can add sufficient newlines to clear the screen - please state how many lines you add for this in your answer. The program should terminate when the N'th sheep is on the fifth floortile.

I need to get up early tomorrow, so shortest code in bytes wins. Please submit a function or complete program. Standard loopholes apply.

Body:
Tcl, 168 bytes

Version using 10-row-high screen. (Replace the 7 below with your screen height in columns minus four.)

set s {0 1 2 3 4 }
for {set n 0} {$n<$argv} {incr n} {foreach x $s {
puts [string repe \n 6][string map [split $s {}] [string map "$x o" {   2
01|-|34
--|-|--  }]]$n}}

That runs really fast, so you can add a pause on line two:

Tcl, 177 bytes

set s {0 1 2 3 4 }
for {set n 0} {$n<$argv} {incr n} {foreach x $s {after 250
puts [string repe \n 6][string map [split $s {}] [string map "$x o" {   2
01|-|34
--|-|--  }]]$n}}

It works by reusing the string at the top for two different things:

as a list for the inner loop (to display each version of the sheep+fence)

as a mapping of digit→space to remove digits from the sheep+fence image template

The template itself is the string image to display. First we map (string replace) the sheep's current position digit (inner loop) to an 'o'. Then we map the remaining digits to spaces. Then we print the resulting string.

(The string itself starts after the last { on the third line and ends with the leftmost } on the last line.)