问:
Create an unlimited counterstring
A counterstring is some sort of self-describing test data that is used in software testing. Not sure it was actually invented by James Bach, but I know it from there.

The idea is as follows: the test data contains many asterisk (*). The number in front of the asterisk tells you how long the test data is at that point. If you need to know a position in the test data that is not an asterisk, find the last asterisk, look at the number before and add the number of digits that follow.

The sequence starts like this:

```<code>2*4*6*8*11*14*17*20*23*
             ^
</code>```

As you can see, the marked asterisk is at position 14.

If a file happens to be truncated as follows

```<code>[...]2045*20
</code>```

then you can derive that there is a limit of 2047 characters somewhere (2045 where the asterisk is plus 2 for 2 and 0).

It's your task to create the shortest (this is code-golf) program that outputs (std::out or file or whatever) an arbitrary long test string of that format. The length in characters is given as argument. The program shall support up to 2 GB test data (input value 2147483647 characters).

"Dangerous" positions in the 2 GB file:

```<code>8*11*
98*102*
998*1003*
9998*10004*
99998*100005*
999995*1000003*
9999995*10000004*
99999995*100000005*
999999995*1000000006*
</code>```

This should answer @Leaky Nun's question if there is a decision to make between 995*999* and 995*1000* or similar: no.

The end of the 2 GB file with input value 2147483647 is:

```<code>2147483640*2147483
</code>```

答:
Haskell, <s>60</s> 58 bytes

As a function we get:

```<code>f=length.show
iterate(\n->1+n+(f$n+1+f n))2>>=(++"*").show
</code>```

Full program, <s>72</s> 70 bytes

This outputs an infinite counterstring to STDOUT:

```<code>f=length.show
main=putStr$iterate(\n->1+n+(f$n+1+f n))2>>=(++"*").show
</code>```

Inputting the length requires 20 additional bytes:

```<code>main=interact(\j->take(read j)$iterate(\n->1+n+(f$n+1+f n))2>>=(++"*").show)
</code>```

This works up to your approximately your RAM size, since Haskell defaults numeric integral types to Integer.

Title: Create an unlimited counterstring

Body:
Haskell, <s>60</s> 58 bytes

As a function we get:

f=length.show
iterate(\n->1+n+(f$n+1+f n))2>>=(++"*").show

Full program, <s>72</s> 70 bytes

This outputs an infinite counterstring to STDOUT:

f=length.show
main=putStr$iterate(\n->1+n+(f$n+1+f n))2>>=(++"*").show

Inputting the length requires 20 additional bytes:

main=interact(\j->take(read j)$iterate(\n->1+n+(f$n+1+f n))2>>=(++"*").show)

This works up to your approximately your RAM size, since Haskell defaults numeric integral types to Integer.


答:
c -- 372

Just for interest this is an implementation of Peter's Monte Carlo suggestion from the comments

```<code>#include "stdio.h"
#include "stdlib.h"
#include "math.h"
#define P printf
#define F(c,n) for(c=0;c<n;++c)
long c=9e9,i,j,k;double a[400],b=.01,t;
double B(){return sqrt(-2*log(drand48()))*cos(2*M_PI*drand48());}main()
{srand48(time(0));F(i,c){t=B();F(k,400)a[k] += t<b*k;}P("%4c",' ');F(j,10)
P("%4.2f    ",b*j);F(i,40){P("\n%3.1f ",10*i*b);F(j,10)
P("%6.4f  ",a[10*i+j]/c);}}
</code>```

Lots of repetitive code. A very straight forward implementation, ungolfed it looks like

```<code>#include "stdio.h"
#include "stdlib.h"
#include "math.h"

long c=9e9, i, j, k;  /* demands longs longer than 32 bits */

double a[400], bw=.01, t;

double B/*oxMuller*/(){
 /* normal distribution, centered on 0, std dev 1 */
  return sqrt(-2*log(drand48())) * cos(2*M_PI*drand48());
}

main(){
  srand48(time(0));
  for(i=0; i<c; ++i) { /* compute the probabilities by MC integration */
    t=B/*oxMuller*/();
    for(k=0; k<400; ++k) a[k] += t<bw*k;
  }
  /* Print the table */
  printf("%4c",' ');
  for(j=0; j<10; ++j) printf("%4.2f    ",bw*j);
  for(i=0; i<40; ++i) {
    printf("\n%3.1f ",10*i*bw);
    for(j=0; j<10; ++j) printf("%6.4f  ",a[10*i+j]/c);
  }
  printf("\n"); /* make the end pretty */
}
</code>```

It is slow, about 60 seconds to do 100,000,000 throws with absolutely all the optimization bells and whistles turned on (-m64 -Ofast) on my 2.2 GHz Core 2 Duo laptop. Worse, it needs circa 50 times that many to provide real confidence that you have the right value in each and every bin. As written I'm asking for even more.

That seems too long to me, but I suspect that I underestimate how much work drand48 is doing (and I have sacrificed about a factor of 2 in the random number generation at the alter of small code).

It also demands that long is a bit bigger than 32 bits (thus the -m64 above).

ContentLicense: CC BY-SA 3.0

Title: Normal distribution values

Body:
Write the shortest program possible which outputs a table of Normal distribution values

```<code>phi(z) = Integral[t from -infty to z of e^(-t^2/2) /sqrt(2 pi) dt]
</code>```

for z from 0.00 to 3.99, giving values accurate to 4 decimal places.

The canonical format for such a table appears to be:

```<code>    0.00    0.01    0.02    0.03    0.04    0.05    0.06    0.07    0.08    0.09
0.0 0.5000  0.5040  0.5080  0.5120  0.5160  0.5199  0.5239  0.5279  0.5319  0.5359
0.1 0.5398  0.5438  0.5478  0.5517  0.5557  0.5596  0.5636  0.5675  0.5714  0.5753
0.2 0.5793  0.5832  0.5871  0.5910  0.5948  0.5987  0.6026  0.6064  0.6103  0.6141
0.3 0.6179  0.6217  0.6255  0.6293  0.6331  0.6368  0.6406  0.6443  0.6480  0.6517
0.4 0.6554  0.6591  0.6628  0.6664  0.6700  0.6736  0.6772  0.6808  0.6844  0.6879
0.5 0.6915  0.6950  0.6985  0.7019  0.7054  0.7088  0.7123  0.7157  0.7190  0.7224
0.6 0.7257  0.7291  0.7324  0.7357  0.7389  0.7422  0.7454  0.7486  0.7517  0.7549
0.7 0.7580  0.7611  0.7642  0.7673  0.7704  0.7734  0.7764  0.7794  0.7823  0.7852
0.8 0.7881  0.7910  0.7939  0.7967  0.7995  0.8023  0.8051  0.8078  0.8106  0.8133
0.9 0.8159  0.8186  0.8212  0.8238  0.8264  0.8289  0.8315  0.8340  0.8365  0.8389
1.0 0.8413  0.8438  0.8461  0.8485  0.8508  0.8531  0.8554  0.8577  0.8599  0.8621
1.1 0.8643  0.8665  0.8686  0.8708  0.8729  0.8749  0.8770  0.8790  0.8810  0.8830
1.2 0.8849  0.8869  0.8888  0.8907  0.8925  0.8944  0.8962  0.8980  0.8997  0.9015
1.3 0.9032  0.9049  0.9066  0.9082  0.9099  0.9115  0.9131  0.9147  0.9162  0.9177
1.4 0.9192  0.9207  0.9222  0.9236  0.9251  0.9265  0.9279  0.9292  0.9306  0.9319
1.5 0.9332  0.9345  0.9357  0.9370  0.9382  0.9394  0.9406  0.9418  0.9429  0.9441
1.6 0.9452  0.9463  0.9474  0.9484  0.9495  0.9505  0.9515  0.9525  0.9535  0.9545
1.7 0.9554  0.9564  0.9573  0.9582  0.9591  0.9599  0.9608  0.9616  0.9625  0.9633
1.8 0.9641  0.9649  0.9656  0.9664  0.9671  0.9678  0.9686  0.9693  0.9699  0.9706
1.9 0.9713  0.9719  0.9726  0.9732  0.9738  0.9744  0.9750  0.9756  0.9761  0.9767
2.0 0.9772  0.9778  0.9783  0.9788  0.9793  0.9798  0.9803  0.9808  0.9812  0.9817
2.1 0.9821  0.9826  0.9830  0.9834  0.9838  0.9842  0.9846  0.9850  0.9854  0.9857
2.2 0.9861  0.9864  0.9868  0.9871  0.9875  0.9878  0.9881  0.9884  0.9887  0.9890
2.3 0.9893  0.9896  0.9898  0.9901  0.9904  0.9906  0.9909  0.9911  0.9913  0.9916
2.4 0.9918  0.9920  0.9922  0.9925  0.9927  0.9929  0.9931  0.9932  0.9934  0.9936
2.5 0.9938  0.9940  0.9941  0.9943  0.9945  0.9946  0.9948  0.9949  0.9951  0.9952
2.6 0.9953  0.9955  0.9956  0.9957  0.9959  0.9960  0.9961  0.9962  0.9963  0.9964
2.7 0.9965  0.9966  0.9967  0.9968  0.9969  0.9970  0.9971  0.9972  0.9973  0.9974
2.8 0.9974  0.9975  0.9976  0.9977  0.9977  0.9978  0.9979  0.9979  0.9980  0.9981
2.9 0.9981  0.9982  0.9982  0.9983  0.9984  0.9984  0.9985  0.9985  0.9986  0.9986
3.0 0.9987  0.9987  0.9987  0.9988  0.9988  0.9989  0.9989  0.9989  0.9990  0.9990
3.1 0.9990  0.9991  0.9991  0.9991  0.9992  0.9992  0.9992  0.9992  0.9993  0.9993
3.2 0.9993  0.9993  0.9994  0.9994  0.9994  0.9994  0.9994  0.9995  0.9995  0.9995
3.3 0.9995  0.9995  0.9995  0.9996  0.9996  0.9996  0.9996  0.9996  0.9996  0.9997
3.4 0.9997  0.9997  0.9997  0.9997  0.9997  0.9997  0.9997  0.9997  0.9997  0.9998
3.5 0.9998  0.9998  0.9998  0.9998  0.9998  0.9998  0.9998  0.9998  0.9998  0.9998
3.6 0.9998  0.9998  0.9999  0.9999  0.9999  0.9999  0.9999  0.9999  0.9999  0.9999
3.7 0.9999  0.9999  0.9999  0.9999  0.9999  0.9999  0.9999  0.9999  0.9999  0.9999
3.8 0.9999  0.9999  0.9999  0.9999  0.9999  0.9999  0.9999  0.9999  0.9999  0.9999
3.9 1.0000  1.0000  1.0000  1.0000  1.0000  1.0000  1.0000  1.0000  1.0000  1.0000
</code>```

Body:
c -- 372

Just for interest this is an implementation of Peter's Monte Carlo suggestion from the comments

#include "stdio.h"
#include "stdlib.h"
#include "math.h"
#define P printf
#define F(c,n) for(c=0;c<n;++c)
long c=9e9,i,j,k;double a[400],b=.01,t;
double B(){return sqrt(-2*log(drand48()))*cos(2*M_PI*drand48());}main()
{srand48(time(0));F(i,c){t=B();F(k,400)a[k] += t<b*k;}P("%4c",' ');F(j,10)
P("%4.2f    ",b*j);F(i,40){P("\n%3.1f ",10*i*b);F(j,10)
P("%6.4f  ",a[10*i+j]/c);}}

Lots of repetitive code. A very straight forward implementation, ungolfed it looks like

#include "stdio.h"
#include "stdlib.h"
#include "math.h"

long c=9e9, i, j, k;  /* demands longs longer than 32 bits */

double a[400], bw=.01, t;

double B/*oxMuller*/(){
 /* normal distribution, centered on 0, std dev 1 */
  return sqrt(-2*log(drand48())) * cos(2*M_PI*drand48());
}

main(){
  srand48(time(0));
  for(i=0; i<c; ++i) { /* compute the probabilities by MC integration */
    t=B/*oxMuller*/();
    for(k=0; k<400; ++k) a[k] += t<bw*k;
  }
  /* Print the table */
  printf("%4c",' ');
  for(j=0; j<10; ++j) printf("%4.2f    ",bw*j);
  for(i=0; i<40; ++i) {
    printf("\n%3.1f ",10*i*bw);
    for(j=0; j<10; ++j) printf("%6.4f  ",a[10*i+j]/c);
  }
  printf("\n"); /* make the end pretty */
}

It is slow, about 60 seconds to do 100,000,000 throws with absolutely all the optimization bells and whistles turned on (-m64 -Ofast) on my 2.2 GHz Core 2 Duo laptop. Worse, it needs circa 50 times that many to provide real confidence that you have the right value in each and every bin. As written I'm asking for even more.

That seems too long to me, but I suspect that I underestimate how much work drand48 is doing (and I have sacrificed about a factor of 2 in the random number generation at the alter of small code).

It also demands that long is a bit bigger than 32 bits (thus the -m64 above).


问:
Pokemon GO Evolution Cost Calculator
Tired of always wondering how many more Pokémon you need to catch to get those high-tier evolutions? Wonder no more! Now you will write a complete program or function to calculate it for you!

The Challenge:

As input, your program will receive a list of the costs in candy to evolve a Pokémon to the next tier. (This list may be separated by any delimiter of your choosing, or as function arguments). Your program will then return or print the number of Pokémon that must be caught, including the one that will be evolved, to evolve through all the tiers given.

How do you calculate this? Like so:

1. Add up all the candy costs: 12 + 50 = 62

2. Subtract 3 candies from the total, this being from the one Pokémon you keep for evolving: 62 - 3 = 59

3. Divide this number by 4 (3 for catching, 1 for giving it to the Professor), always taking the ceil() of the result: ceil(59/4) = 15

4. Finally, add 1 to this total to get the total number of Pokémon you must catch, 16!

Example Input -> Output:

```<code>[4] -> 2
[50] -> 13
[12, 50] -> 16
[25, 100] -> 32
[19, 35, 5, 200] -> 65
</code>```

Winning:

The app has already taken up most of the space on your phone, so your program needs to be as short as possible. The complete program or function with the smallest byte count will be accepted in two weeks! (with any ties being settled by the earliest submitted entry!)

答:
S.I.L.O.S <s>100 99</s> 103 characters + 22 for sample input

Code with testing harness.

```<code>set 512 52
set 513 10
GOSUB e
GOTO f
funce
a = 0
i = 511
lblE
i + 1
b = get i
a + b
if b E
a / 4
a + 1
return
lblf
printInt a
</code>```

input as a series of set commands to modify the spots of the heap starting at spot 512.

Try it Online!

Title: Pokemon GO Evolution Cost Calculator

Body:
S.I.L.O.S <s>100 99</s> 103 characters + 22 for sample input

Code with testing harness.

set 512 52
set 513 10
GOSUB e
GOTO f
funce
a = 0
i = 511
lblE
i + 1
b = get i
a + b
if b E
a / 4
a + 1
return
lblf
printInt a

input as a series of set commands to modify the spots of the heap starting at spot 512.

Try it Online!


答:
Jelly, <s>5</s> 4 bytes

```<code>S:4‘
</code>```

Try it online!

Sum, integer divide : by 4 and increment ‘.

Title: Pokemon GO Evolution Cost Calculator

Body:
Tired of always wondering how many more Pokémon you need to catch to get those high-tier evolutions? Wonder no more! Now you will write a complete program or function to calculate it for you!

The Challenge:

As input, your program will receive a list of the costs in candy to evolve a Pokémon to the next tier. (This list may be separated by any delimiter of your choosing, or as function arguments). Your program will then return or print the number of Pokémon that must be caught, including the one that will be evolved, to evolve through all the tiers given.

How do you calculate this? Like so:

1. Add up all the candy costs: 12 + 50 = 62

2. Subtract 3 candies from the total, this being from the one Pokémon you keep for evolving: 62 - 3 = 59

3. Divide this number by 4 (3 for catching, 1 for giving it to the Professor), always taking the ceil() of the result: ceil(59/4) = 15

4. Finally, add 1 to this total to get the total number of Pokémon you must catch, 16!

Example Input -> Output:

```<code>[4] -> 2
[50] -> 13
[12, 50] -> 16
[25, 100] -> 32
[19, 35, 5, 200] -> 65
</code>```

Winning:

The app has already taken up most of the space on your phone, so your program needs to be as short as possible. The complete program or function with the smallest byte count will be accepted in two weeks! (with any ties being settled by the earliest submitted entry!)

Body:
Jelly, <s>5</s> 4 bytes

S:4‘

Try it online!

Sum, integer divide : by 4 and increment ‘.


问:
How secure are my locks?
You have been assigned the task of installing new locks to the company's building. However, the locks you use are quite unusual: they require some combination of keys to open. Now, you want to figure out which locks are the most secure, so you can prioritize the most important locations.

The keys you use are numbered by security: key 1 is the weakest and could be given to the cat, key 2 is a bit better, and so on.

The locks are defined by AND and OR expressions between the keys. For example, a lock might open with just key 1, so it's defined by the string 1; another one might require key 3 and either key 1 or 2, so it's defined by 3 & (1 | 2). A lock opens if the expression is truthy when all key numbers are substituted for true/false depending on if the user possessed the respective keys. XOR and NOT are not needed, since possessing extra keys doesn't matter.

The security of a lock is defined by the weakest key combination required to open the lock. One way to compute this is the following algorithm:

Find all the subsets of the keys that open the lock.

Sort each combination descending (from the strongest key to the weakest).

Sort the combinations lexicographically ascending.

The security value of the lock is now the first item in the list.

In order to compare two locks, one just has to compare their security values lexicographically: the larger one is more secure.

Challenge

You are given a list of expressions that define locks. Your task is to sort the locks based on security in descending order.

Standard code-golf rules apply.

Input

You will receive a list of locks as input.

The list may be taken as lines or in the list representation of your choice.

Each lock can be given either as a string like 1 & ((2 | 3) & 4) or a nested list like [1, "&", [[2, "|", 3], "&", 4]].

Any whitespace in the string is optional, and all operations except for the outermost one will be wrapped in parentheses.

You are free to choose the list format that suits your needs.

Each operator will have two operands.

Key numbers will range from 1 to 99 and there will not be unused keys between 1 and the maximum used key.

Output

You will output the same list you got as input, sorted by security in descending order. All formats listed above are valid. If two locks are equally secure, their order does not matter.

Test cases

The test cases are in the "list" format. The outputs include the security values of each lock for reference; you should not output them.

Input:

[1]
[2]
[3]
[1, "&", 2]
[1, "&", 3]
[3, "&", 2]
[1, "|", 2]
[2, "|", 3]
[[1, "&", 2], "|", 3]
[[2, "|", 3], "&", 3]
```

<p><strong>Result:</strong></p>

<pre class="lang-python prettyprint-override"><code>[3, "&", 2]            # (3, 2)
[1, "&", 3]            # (3, 1)
[[2, "|", 3], "&", 3]  # (3)
[3]                    # (3)
[1, "&", 2]            # (2, 1)
[[1, "&", 2], "|", 3]  # (2, 1)
[2]                    # (2)
[2, "|", 3]            # (2)
[1]                    # (1)
[1, "|", 2]            # (1)
</code>```

Input:

[[[6, '|', [[10, '|', 1], '&', [3, '&', 3]]], '|', 10], '&', [[12, '&', [9, '|', 7]], '|', [[3, '|', 8], '&', [[10, '|', [[1, '&', 3], '&', 9]], '|', [[2, '|', 1], '&', 1]]]]]
[[7, '|', 9], '&', [[5, '|', 10], '&', [[12, '|', 3], '&', 4]]]
[7, '|', 7]
[[[5, '|', [1, '|', 9]], '&', [[7, '&', [[6, '&', [1, '|', 7]], '|', 2]], '|', 5]], '&', [[[[8, '&', 6], '&', 1], '&', 5], '&', [10, '|', [11, '&', [3, '&', 6]]]]]
[[[[2, '&', [6, '&', 8]], '|', [[4, '|', 4], '|', [[5, '&', 4], '|', [[[1, '|', 5], '|', 1], '&', 7]]]], '&', [[[9, '|', [3, '&', 7]], '|', [9, '|', 5]], '&', [[[[8, '|', 11], '|', 8], '|', 2], '|', 2]]], '&', [[3, '|', 6], '&', 9]]
[[12, '|', [5, '&', [[12, '&', 3], '|', [9, '&', 1]]]], '|', [10, '&', [[8, '|', 9], '&', [[[8, '|', 3], '|', 8], '|', 11]]]]
[[9, '|', 11], '&', [[[11, '&', 12], '|', 10], '&', [3, '&', 12]]]
[[[5, '&', 9], '&', [10, '&', 2]], '|', [10, '|', 10]]
[[6, '&', 4], '&', [4, '|', 11]]
[[[[11, '&', [[[[5, '|', 11], '&', [10, '|', 7]], '&', 2], '|', 2]], '|', 12], '|', 5], '&', [[[2, '&', [5, '|', 9]], '&', 4], '&', [6, '|', [3, '&', 2]]]]
```

<p><strong>Result:</strong></p>

<pre class="lang-python prettyprint-override"><code>[[9, '|', 11], '&', [[[11, '&', 12], '|', 10], '&', [3, '&', 12]]] # (12, 10, 9, 3)
[[[5, '|', [1, '|', 9]], '&', [[7, '&', [[6, '&', [1, '|', 7]], '|', 2]], '|', 5]], '&', [[[[8, '&', 6], '&', 1], '&', 5], '&', [10, '|', [11, '&', [3, '&', 6]]]]] # (10, 8, 6, 5, 1)
[[[5, '&', 9], '&', [10, '&', 2]], '|', [10, '|', 10]] # (10)
[[12, '|', [5, '&', [[12, '&', 3], '|', [9, '&', 1]]]], '|', [10, '&', [[8, '|', 9], '&', [[[8, '|', 3], '|', 8], '|', 11]]]] # (9, 5, 1)
[[[[2, '&', [6, '&', 8]], '|', [[4, '|', 4], '|', [[5, '&', 4], '|', [[[1, '|', 5], '|', 1], '&', 7]]]], '&', [[[9, '|', [3, '&', 7]], '|', [9, '|', 5]], '&', [[[[8, '|', 11], '|', 8], '|', 2], '|', 2]]], '&', [[3, '|', 6], '&', 9]] # (9, 4, 3, 2)
[[7, '|', 9], '&', [[5, '|', 10], '&', [[12, '|', 3], '&', 4]]] # (7, 5, 4, 3)
[7, '|', 7] # (7)
[[6, '&', 4], '&', [4, '|', 11]] # (6, 4)
[[[[11, '&', [[[[5, '|', 11], '&', [10, '|', 7]], '&', 2], '|', 2]], '|', 12], '|', 5], '&', [[[2, '&', [5, '|', 9]], '&', 4], '&', [6, '|', [3, '&', 2]]]] # (5, 4, 3, 2)
[[[6, '|', [[10, '|', 1], '&', [3, '&', 3]]], '|', 10], '&', [[12, '&', [9, '|', 7]], '|', [[3, '|', 8], '&', [[10, '|', [[1, '&', 3], '&', 9]], '|', [[2, '|', 1], '&', 1]]]]] # (3, 1)
</code>```

This program can be used to generate additional test cases. It also outputs the security values of each lock generated.

答:
Perl 6: <s>132</s> 124 bytes

```<code>{reverse .sort: {use MONKEY-SEE-NO-EVAL;my &infix:<|>={|$^a,|$^b}
min map *.flat.sort.squish.reverse,EVAL .trans('&'=>'X')}}
</code>```

A lambda that takes a list of lines as input.

It generates the sort key for each line as follows:

Declare | as a list concatenation operator within the lexical scope.

Replace & in the string with X, the Perl 6 cartesian product operator.

Eval the string (which unfortunately requires the ghastly MONKEY-SEE-NO-EVAL pragma), yielding all possible combinations of keys that open the door.

Post-process the lists and pick the "least secure" combination.

Title: How secure are my locks?

Body:
Perl 6: <s>132</s> 124 bytes

{reverse .sort: {use MONKEY-SEE-NO-EVAL;my &infix:<|>={|$^a,|$^b}
min map *.flat.sort.squish.reverse,EVAL .trans('&'=>'X')}}

A lambda that takes a list of lines as input.

It generates the sort key for each line as follows:

Declare | as a list concatenation operator within the lexical scope.

Replace & in the string with X, the Perl 6 cartesian product operator.

Eval the string (which unfortunately requires the ghastly MONKEY-SEE-NO-EVAL pragma), yielding all possible combinations of keys that open the door.

Post-process the lists and pick the "least secure" combination.


问:
Produce the number 2014 without any numbers in your source code

Note to challenge writers as per meta consensus:
This question was well-received when it was posted, but challenges
like this, asking answerers to Do X without using
Y
are likely to be poorly received. Try using the
sandbox
to get feedback on if you want to post a similar challenge.

It's <s>2017</s> <s>2018</s> <s>2019</s> <s>2020</s> <s>2021</s> <s>2022</s> 2023 already, folks, go home.

So, now that it's 2014, it's time for a code question involving the number 2014.

Your task is to make a program that prints the number 2014, without using any of the characters 0123456789 in your code, and independently of any external variables such as the date or time or a random seed.

The shortest code (counting in bytes) to do so in any language in which numbers are valid tokens wins.

Leaderboard:

var QUESTION_ID=17005,OVERRIDE_USER=7110;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

```

答:
C (gcc 5.3.1), 49 bytes

Pure arithmetic! \o/

main(a){printf("%d",(++a<<(a<<a|a))-(a<<a+a)-a);}
```

<p>Undefined behaviours.</p>

<p>Specifically, use this compiler (languages are defined by implementation).</p>

<h3>Without undefined behaviour (which would work on all compilers), 51 bytes</h3>

<pre class="lang-c prettyprint-override"><code>main(a){a++;printf("%d",(a<<(a<<a|a))-(a<<a+a)-a);}
</code>```

Explanation

Basically 2048 - 32 - 2, constructed using powers of 2.

ContentLicense: CC BY-SA 4.0

Body:
C (gcc 5.3.1), 49 bytes

Pure arithmetic! \o/

main(a){printf("%d",(++a<<(a<<a|a))-(a<<a+a)-a);}

Undefined behaviours.

Specifically, use this compiler (languages are defined by implementation).

Without undefined behaviour (which would work on all compilers), 51 bytes

main(a){a++;printf("%d",(a<<(a<<a|a))-(a<<a+a)-a);}

Explanation

Basically 2048 - 32 - 2, constructed using powers of 2.


答:
05AB1E, 4 bytes

```<code>O4÷>
</code>```

Explanation

```<code>O    # sum
 4÷  # integer division by 4
   > # increment
</code>```

Try it online

Title: Pokemon GO Evolution Cost Calculator

Body:
05AB1E, 4 bytes

O4÷>

Explanation

O    # sum
 4÷  # integer division by 4
   > # increment

Try it online


问:
Find the minimum and maximum integers in an array, without using builtins

Challenge

Given an array of integers, received from stdin, function arguments, program arguments, or some other method:

Output only the minimum and maximum numbers in the array, through a return value, stdout, or other fitting methods.

Example session

```<code>> minmax( {0, 15, 2, 3, 7, 18, -2, 9, 6, -5, 3, 8, 9, -14} )
-14 18
</code>```

Reference implementation

```<code>// C++14

void minmax(std::vector<int> v) {
    int min = v[0]; int max = v[0];
    for(auto it : v) {
        if (*it < min)
            min = *it;
        if (*it > max)
            max = *it;
    }
    std::cout << min << ' ' << max << std::endl;
}
</code>```

Rules

You may not use a built-in function to calculate the values.

Standard loopholes disallowed.

Creative implementations encouraged.

This is code-golf, shortest answer wins but will not be selected.

Clarifications

If the array contains 1 element you need to output it twice.

If the minimum and maximum values are the same, you need to output them both.

答:
CJam, <s>10</s> 9 bytes

```<code>q~$_(p;W>
</code>```

Try it online.

I'm really not good at CJam.

```<code>q~          e# eval input
  $         e# sort
   _        e# duplicate
    (       e# pop first
     p      e# print
      ;     e# remove array
       W>   e# get last element
</code>```

Body:
CJam, <s>10</s> 9 bytes

q~$_(p;W>

Try it online.

I'm really not good at CJam.

q~          e# eval input
  $         e# sort
   _        e# duplicate
    (       e# pop first
     p      e# print
      ;     e# remove array
       W>   e# get last element


答:
BASH (sed + bc) 19

```<code>sed 's~)~+4)/4~'|bc
</code>```

Input is a + separate list on stdin

E.g.:

echo '(19+35+5+200)'|  sed 's~)~+4)/4~'|bc

Title: Pokemon GO Evolution Cost Calculator

Body:
BASH (sed + bc) 19

sed 's~)~+4)/4~'|bc

Input is a + separate list on stdin

E.g.:

echo '(19+35+5+200)'|  sed 's~)~+4)/4~'|bc


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

Byte count assumes ISO 8859-1 encoding.

```<code>$
¶4
.+|¶
$*
1111
</code>```

Input is linefeed-separated.

Try it online!

Title: Pokemon GO Evolution Cost Calculator

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

Byte count assumes ISO 8859-1 encoding.

$
¶4
.+|¶
$*
1111

Input is linefeed-separated.

Try it online!


问:
Calculate e^x and ln(x)
Given a floating point x (x<100), return e^x and ln(x). The first 6 decimal places of the number have to be right, but any others after do not have to be correct.

You cannot have any "magic" constants explicitly stated (e.x. a=1.35914 since 1.35914*2 ~= e), but you can calculate them. Only use +, -, *, and / for arithmetic operators.

If x is less than or equal to 0, output ERROR instead of the intended value of ln(x).

Test Cases:

```<code>input: 2
output: 7.389056 0.693147
input: 0.25
output: 1.284025 -1.386294
input: 2.718281828
output: 15.154262 0.999999  (for this to output correctly, don't round to 6 places)
input: -0.1
output: 0.904837 ERROR
</code>```

Shortest code wins.

答:
PHP <s>109</s> 107 bytes

```<code><?for($g=1e4;--$g;$l=$y/$g+abs($y=$x>1?1-1/$x:$x-1)*$l)$e=1+$e/$g*$x.=fgets(STDIN);echo"$e ",$x>0?$l:ERROR;
</code>```

\$e^x\$ is a fairly straight-forward calculation. I use a nested form of the sum of inverse factorials, which not only increases the convergence rate, but also allows for exponentiation at the same time:

$$e^x = 1 + x \left( 1 + \frac x 2 \left( 1 + \frac x 3 \left( 1 + \frac x 4 \bigg( 1 + \dots \bigg)\right)\right)\right)$$

\$\ln x\$ is slightly more complicated. All convergent series seem to work for \$x \le 1\$ or \$x \ge 1 \$, but not both (Newton's iteration does not have this limitation, but requires the calculation of \$e^{x_n}\$ each step). This isn't really a problem, though, given the log identity:

$$\ln x = -\ln \frac 1 x$$

This means that if, for example, the iteration you're using only works on \$0 < x \le 1\$ and \$x > 1\$, you can use the multiplicative inverse of \$x\$ and negate the result. Because I was using a nested identity for \$e^x\$, I also chose to use a nested identity for \$\ln x\$:

$$\ln(1 + x) = x\left(1 - x\left(\frac 1 2 - x\left(\frac 1 3 - x\left(\frac 1 4 - \dots \right)\right)\right)\right)$$

where \$0 < x \le 1\$

Or equivalently, as demonstrated by Paul Walls' implementation:

$$\ln(1 + x) = x - x\left(\frac x 2 - x\left(\frac x 3 - x\left(\frac x 4 - \dots \right)\right)\right)$$

I define the \$0 < x \le 1\$ case as \$x-1\$ (which is necessarily negative), using the absolute value for the inner product, and then allowing a bare \$x\$ value in the fraction to correct the sign.

Sample I/O:

```<code>$ echo 2 | php exp_ln.php
7.3890560989307 0.69314718055995

$ echo 0.25 | php exp_ln.php
1.2840254166877 -1.3862943611199

$ echo 2.718281828 | php exp_ln.php
15.154262234523 0.99999999983113

$ echo -0.1 | php exp_ln.php
0.90483741803596 ERROR
</code>```

Perl <s>95</s> <s>93</s> 89 bytes

```<code>$e=1+$e/$?*($x.=<>),$l=$_/$?+$l*abs,$_=$x>1?1-1/$x:$x-1while--$?;print"$e ",$x>0?$l:ERROR
</code>```

Nearly identical to the PHP solution above, with a slightly larger iteration (65535 down to 0).

Edits:

Both 2 byte improvements due to Paul Walls.

Four more bytes saved in Perl by (ab)using $?, which is stored internally as an unsigned short, and by using $_ to save parentheses in abs.

Title: Calculate e^x and ln(x)

Body:
PHP <s>109</s> 107 bytes

<?for($g=1e4;--$g;$l=$y/$g+abs($y=$x>1?1-1/$x:$x-1)*$l)$e=1+$e/$g*$x.=fgets(STDIN);echo"$e ",$x>0?$l:ERROR;

\$e^x\$ is a fairly straight-forward calculation. I use a nested form of the sum of inverse factorials, which not only increases the convergence rate, but also allows for exponentiation at the same time:

$$e^x = 1 + x \left( 1 + \frac x 2 \left( 1 + \frac x 3 \left( 1 + \frac x 4 \bigg( 1 + \dots \bigg)\right)\right)\right)$$

\$\ln x\$ is slightly more complicated. All convergent series seem to work for \$x \le 1\$ or \$x \ge 1 \$, but not both (Newton's iteration does not have this limitation, but requires the calculation of \$e^{x_n}\$ each step). This isn't really a problem, though, given the log identity:

$$\ln x = -\ln \frac 1 x$$

This means that if, for example, the iteration you're using only works on \$0 < x \le 1\$ and \$x > 1\$, you can use the multiplicative inverse of \$x\$ and negate the result. Because I was using a nested identity for \$e^x\$, I also chose to use a nested identity for \$\ln x\$:

$$\ln(1 + x) = x\left(1 - x\left(\frac 1 2 - x\left(\frac 1 3 - x\left(\frac 1 4 - \dots \right)\right)\right)\right)$$

where \$0 < x \le 1\$

Or equivalently, as demonstrated by Paul Walls' implementation:

$$\ln(1 + x) = x - x\left(\frac x 2 - x\left(\frac x 3 - x\left(\frac x 4 - \dots \right)\right)\right)$$

I define the \$0 < x \le 1\$ case as \$x-1\$ (which is necessarily negative), using the absolute value for the inner product, and then allowing a bare \$x\$ value in the fraction to correct the sign.

Sample I/O:

$ echo 2 | php exp_ln.php
7.3890560989307 0.69314718055995

$ echo 0.25 | php exp_ln.php
1.2840254166877 -1.3862943611199

$ echo 2.718281828 | php exp_ln.php
15.154262234523 0.99999999983113

$ echo -0.1 | php exp_ln.php
0.90483741803596 ERROR

Perl <s>95</s> <s>93</s> 89 bytes

$e=1+$e/$?*($x.=<>),$l=$_/$?+$l*abs,$_=$x>1?1-1/$x:$x-1while--$?;print"$e ",$x>0?$l:ERROR

Nearly identical to the PHP solution above, with a slightly larger iteration (65535 down to 0).

Edits:

Both 2 byte improvements due to Paul Walls.

Four more bytes saved in Perl by (ab)using $?, which is stored internally as an unsigned short, and by using $_ to save parentheses in abs.


问:
Exploring 10-Rep Questions
Related

Introduction

As it happens, someone put forward the idea that, since PPCG has graduated, up votes on questions should be worth 10 rep. As a result, I started wondering how much rep I would have if it had always been 10 rep.

Challenge

Given a PPCG user's id as input, output how much total rep the user would have if question up votes were worth +10.

Example Calculation

I, Beta Decay (user id 30525), have 6744 rep. 3488 of that was earned by posting questions (calculated by subtracting the total rep lost from downvotes from the total rep gained from upvotes).

Firstly, we subtract 3488 from 6744, giving us 3256 rep, the amount earned from posting answers.

Next, we find out how much I would have earned from 10 rep questions by simply multiplying 3488 by 2, giving us 6976.

Finally, we add 3256 and 6976 together to get a final answer of 10232 rep.

A simplified method is to take the total, 6744 and add the rep from questions, 3488, giving is 10232 rep.

For continuity, you must use the method described above

Examples

Note that these examples are subject to change and are unlikely to stay current.

Helka Homba (UID 26997)

```<code>71398
</code>```

Martin Ender (UID 8478)

```<code>121077
</code>```

Downgoat (UID 40695)

```<code>21894
</code>```

Rules

Internet access is allowed. Similarly, access to the Stack Exchange API is allowed. However, URL shorteners are disallowed.

T-SQL entrants using the Stack Exchange Data Explorer are allowed.

You also do not have to take into account the daily rep cap of 200.

Winning

Shortest code in bytes wins.

答:
Python, 336 Bytes

Anonymous lambda function, takes a string.

Should work, but couldn't test it, because I drained my api quota.

(Warning! Will drain your api quota!)

```<code>import requests,re
lambda x,u="http://api.stackexchange.com/2.2/users/%s%s?site=codegolf&page=%d":int(re.search('n":\d+',requests.get(u%(x,"",1)).text).group()[3:])+sum([5*len(re.findall(':5,',requests.get(u%(x,"/reputation-history",i)).text))-2*len(re.findall('-2',requests.get(u%(x,"/reputation-history",i)).text))for i in range(99)])
</code>```

a bit quota-friendlier:

```<code>import requests,re
f=lambda x,u="https://api.stackexchange.com/2.2/users/%s%s?site=codegolf&pagesize=100&page=%d":int(re.search('n":\d+',requests.get(u%(x,"",1)).text).group()[3:])+sum([5*len(re.findall(':5,',requests.get(u%(x,"/reputation-history",i)).text))-2*len(re.findall('-2',requests.get(u%(x,"/reputation-history",i)).text))for i in range(30)])
</code>```

Title: Exploring 10-Rep Questions

Body:
Python, 336 Bytes

Anonymous lambda function, takes a string.

Should work, but couldn't test it, because I drained my api quota.

(Warning! Will drain your api quota!)

import requests,re
lambda x,u="http://api.stackexchange.com/2.2/users/%s%s?site=codegolf&page=%d":int(re.search('n":\d+',requests.get(u%(x,"",1)).text).group()[3:])+sum([5*len(re.findall(':5,',requests.get(u%(x,"/reputation-history",i)).text))-2*len(re.findall('-2',requests.get(u%(x,"/reputation-history",i)).text))for i in range(99)])

a bit quota-friendlier:

import requests,re
f=lambda x,u="https://api.stackexchange.com/2.2/users/%s%s?site=codegolf&pagesize=100&page=%d":int(re.search('n":\d+',requests.get(u%(x,"",1)).text).group()[3:])+sum([5*len(re.findall(':5,',requests.get(u%(x,"/reputation-history",i)).text))-2*len(re.findall('-2',requests.get(u%(x,"/reputation-history",i)).text))for i in range(30)])


答:
Python 3, <s>126</s> <s>114</s> 99 bytes

```<code>def f(x,s=''):
 i=t=2
 while len(s)<x:i+=len(str(t+i))-len(str(t));s+=str(t)+'*';t+=i
 print(s[:x])
</code>```

A function that takes input via argument of the character count at which to truncate the string, and prints to STDOUT.

How it works

The difference between the numbers in the string is initially 2. Every time an order of magnitude is passed, this difference is increased by 1; this can be achieved by taking the difference between the number of digits of the current number and the number of digits of the current number added to the difference, which is 1 only when required. The function simply loops while the length of the string is less than the input, appends to the string and updates the difference and number as required, and then truncates before printing.

Try it on Ideone

Infinite output version, 69 bytes

```<code>s=i=2
while 1:i+=len(str(s+i))-len(str(s));print(end=str(s)+'*');s+=i
</code>```

Title: Create an unlimited counterstring

Body:
A counterstring is some sort of self-describing test data that is used in software testing. Not sure it was actually invented by James Bach, but I know it from there.

The idea is as follows: the test data contains many asterisk (*). The number in front of the asterisk tells you how long the test data is at that point. If you need to know a position in the test data that is not an asterisk, find the last asterisk, look at the number before and add the number of digits that follow.

The sequence starts like this:

```<code>2*4*6*8*11*14*17*20*23*
             ^
</code>```

As you can see, the marked asterisk is at position 14.

If a file happens to be truncated as follows

```<code>[...]2045*20
</code>```

then you can derive that there is a limit of 2047 characters somewhere (2045 where the asterisk is plus 2 for 2 and 0).

It's your task to create the shortest (this is code-golf) program that outputs (std::out or file or whatever) an arbitrary long test string of that format. The length in characters is given as argument. The program shall support up to 2 GB test data (input value 2147483647 characters).

"Dangerous" positions in the 2 GB file:

```<code>8*11*
98*102*
998*1003*
9998*10004*
99998*100005*
999995*1000003*
9999995*10000004*
99999995*100000005*
999999995*1000000006*
</code>```

This should answer @Leaky Nun's question if there is a decision to make between 995*999* and 995*1000* or similar: no.

The end of the 2 GB file with input value 2147483647 is:

```<code>2147483640*2147483
</code>```

Body:
Python 3, <s>126</s> <s>114</s> 99 bytes

def f(x,s=''):
 i=t=2
 while len(s)<x:i+=len(str(t+i))-len(str(t));s+=str(t)+'*';t+=i
 print(s[:x])

A function that takes input via argument of the character count at which to truncate the string, and prints to STDOUT.

How it works

The difference between the numbers in the string is initially 2. Every time an order of magnitude is passed, this difference is increased by 1; this can be achieved by taking the difference between the number of digits of the current number and the number of digits of the current number added to the difference, which is 1 only when required. The function simply loops while the length of the string is less than the input, appends to the string and updates the difference and number as required, and then truncates before printing.

Try it on Ideone

Infinite output version, 69 bytes

s=i=2
while 1:i+=len(str(s+i))-len(str(s));print(end=str(s)+'*');s+=i


答:
Python 2, <s>74</s> <s>72</s> <s>66</s> <s>64</s> 61 Bytes

```<code>f=lambda n,i=2:"%d*"%i+f(n,len(`i+2`)-~i)[:n-2]if i<n*2else""
</code>```

Takes an integer n and outputs a counterstring of length n.

program version, 69 Bytes:

```<code>s,n,i="",input(),2
while i<2*n:s+="%d*"%i;i+=len(`i+2`)+1
print s[:n]
</code>```

Takes an integer n from stdin and prints a counterstring of length n.

Shorter, but only almost working, alternative version:

```<code>n,i=input(),2
while i<2*n:print("%d*"%i)[:n-i],;i+=len(str(i+2))+1
</code>```

Title: Create an unlimited counterstring

Body:
Python 2, <s>74</s> <s>72</s> <s>66</s> <s>64</s> 61 Bytes

f=lambda n,i=2:"%d*"%i+f(n,len(`i+2`)-~i)[:n-2]if i<n*2else""

Takes an integer n and outputs a counterstring of length n.

program version, 69 Bytes:

s,n,i="",input(),2
while i<2*n:s+="%d*"%i;i+=len(`i+2`)+1
print s[:n]

Takes an integer n from stdin and prints a counterstring of length n.

Shorter, but only almost working, alternative version:

n,i=input(),2
while i<2*n:print("%d*"%i)[:n-i],;i+=len(str(i+2))+1


答:
Haskell, 27 bytes

```<code>f x=(`foldl1`x)<$>[min,max]
</code>```

In Haskell, min and max give minimum and maximum of two arguments, not of a list. I couldn't tell whether this is disallowed (it seems that instead only minimum and maximum would be disallowed) so please let me know if they are and I'll promptly delete this answer.

Title: Find the minimum and maximum integers in an array, without using builtins

Body:
Challenge

Given an array of integers, received from stdin, function arguments, program arguments, or some other method:

Output only the minimum and maximum numbers in the array, through a return value, stdout, or other fitting methods.

Example session

```<code>> minmax( {0, 15, 2, 3, 7, 18, -2, 9, 6, -5, 3, 8, 9, -14} )
-14 18
</code>```

Reference implementation

```<code>// C++14

void minmax(std::vector<int> v) {
    int min = v[0]; int max = v[0];
    for(auto it : v) {
        if (*it < min)
            min = *it;
        if (*it > max)
            max = *it;
    }
    std::cout << min << ' ' << max << std::endl;
}
</code>```

Rules

You may not use a built-in function to calculate the values.

Standard loopholes disallowed.

Creative implementations encouraged.

This is code-golf, shortest answer wins but will not be selected.

Clarifications

If the array contains 1 element you need to output it twice.

If the minimum and maximum values are the same, you need to output them both.

Body:
Haskell, 27 bytes

f x=(`foldl1`x)<$>[min,max]

In Haskell, min and max give minimum and maximum of two arguments, not of a list. I couldn't tell whether this is disallowed (it seems that instead only minimum and maximum would be disallowed) so please let me know if they are and I'll promptly delete this answer.


Body:
Perl 6 13 bytes

*.sort[0,*-1]

Test:

my &min-max = *.sort[0,*-1];

say min-max 1;
# (1 1)
say min-max (0, 15, 2, 3, 7, 18, -2, 9, 6, -5, 3, 8, 9, -14)
# (-14 18)


答:
Factor, 38 bytes

```<code>[ natural-sort [ first ] [ last ] bi ]
</code>```

Sort the sequence and get its first and last elements.

Body:
Factor, 38 bytes

[ natural-sort [ first ] [ last ] bi ]

Sort the sequence and get its first and last elements.


答:
Lua, 32 bytes

```<code>print(#'XX'..#''..#'X'..#'XXXX')
</code>```

This makes use of the length operator # used on string literals to get numbers, and the lengths are concatenated (with ..) to print 2014

Title: Produce the number 2014 without any numbers in your source code

Body:
Note to challenge writers as per meta consensus:
This question was well-received when it was posted, but challenges
like this, asking answerers to Do X without using
Y
are likely to be poorly received. Try using the
sandbox
to get feedback on if you want to post a similar challenge.

It's <s>2017</s> <s>2018</s> <s>2019</s> <s>2020</s> <s>2021</s> <s>2022</s> 2023 already, folks, go home.

So, now that it's 2014, it's time for a code question involving the number 2014.

Your task is to make a program that prints the number 2014, without using any of the characters 0123456789 in your code, and independently of any external variables such as the date or time or a random seed.

The shortest code (counting in bytes) to do so in any language in which numbers are valid tokens wins.

Leaderboard:

var QUESTION_ID=17005,OVERRIDE_USER=7110;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:
Lua, 32 bytes

print(#'XX'..#''..#'X'..#'XXXX')

This makes use of the length operator # used on string literals to get numbers, and the lengths are concatenated (with ..) to print 2014


答:
C# REPL, 15 bytes

```<code>n=>n.Sum()/4+1;
</code>```

Casts to Func<IEnumerable<int>, int>.

Title: Pokemon GO Evolution Cost Calculator

Body:
Tired of always wondering how many more Pokémon you need to catch to get those high-tier evolutions? Wonder no more! Now you will write a complete program or function to calculate it for you!

The Challenge:

As input, your program will receive a list of the costs in candy to evolve a Pokémon to the next tier. (This list may be separated by any delimiter of your choosing, or as function arguments). Your program will then return or print the number of Pokémon that must be caught, including the one that will be evolved, to evolve through all the tiers given.

How do you calculate this? Like so:

1. Add up all the candy costs: 12 + 50 = 62

2. Subtract 3 candies from the total, this being from the one Pokémon you keep for evolving: 62 - 3 = 59

3. Divide this number by 4 (3 for catching, 1 for giving it to the Professor), always taking the ceil() of the result: ceil(59/4) = 15

4. Finally, add 1 to this total to get the total number of Pokémon you must catch, 16!

Example Input -> Output:

```<code>[4] -> 2
[50] -> 13
[12, 50] -> 16
[25, 100] -> 32
[19, 35, 5, 200] -> 65
</code>```

Winning:

The app has already taken up most of the space on your phone, so your program needs to be as short as possible. The complete program or function with the smallest byte count will be accepted in two weeks! (with any ties being settled by the earliest submitted entry!)

Body:
C# REPL, 15 bytes

n=>n.Sum()/4+1;

Casts to Func<IEnumerable<int>, int>.


答:
JavaScript (ES6), 34 bytes

```<code>a=>[a.sort((x,y)=>x-y)[0],a.pop()]
</code>```

sort sorts in-place, so I can just refer to the [0] index for the lowest value and pop the highest value from the array, however it does a string sort by default so I have to pass a comparator.

Body:
JavaScript (ES6), 34 bytes

a=>[a.sort((x,y)=>x-y)[0],a.pop()]

sort sorts in-place, so I can just refer to the [0] index for the lowest value and pop the highest value from the array, however it does a string sort by default so I have to pass a comparator.


答:
MATL, 4 bytes

```<code>S5L)
</code>```

Try it online!

Explanation

```<code>S    % Implicitly input the array. Sort
5L   % Push [1 0]. When used as a (modular, 1-based) index, this means "first and last"
)    % Apply as an indexing vector into the sorted array. Implicitly display
</code>```

Body:
MATL, 4 bytes

S5L)

Try it online!

Explanation

S    % Implicitly input the array. Sort
5L   % Push [1 0]. When used as a (modular, 1-based) index, this means "first and last"
)    % Apply as an indexing vector into the sorted array. Implicitly display