问:
The Letter A without A
Your task is to display the letter "A" alone, without anything else, except any form of trailing newlines if you cannot avoid them, doing so in a program and/or snippet. Code that returns (instead of printing) is allowed.

Both the lowercase and uppercase versions of the letter "A" are acceptable (that is, unicode U+0061 or unicode U+0041. Other character encodings that aren't Unicode are allowed, but either way, the resulting output of your code must be the latin letter "A", and not any lookalikes or homoglyphs)

You must not use any of the below characters in your code, regardless of the character encoding that you pick:

"A", whether uppercase or lowercase.

"U", whether lowercase or uppercase.

X, whether uppercase or lowercase.

+

&

#

0

1

4

5

6

7

9

Cheating, loopholes, etc, are not allowed.

Since this is code-golf, the shortest solution, in bytes, that follows all the rules, is the winner.

Validity Checker

This Stack Snippet checks to make sure your code doesn't use the restricted characters. It might not work properly for some character encodings.

var t = prompt("Input your code.");

if (/[AaUuXx+&#0145679]/.test(t)) {
  alert("Contains a disallowed character!");
} else {
  alert("No disallowed characters");
}```
</div>
</div>
</p>

<p><em>This Stack Snippet that makes sure you don't have a disallowed character is also available on JSFiddle.</em></p>

<h3>Leaderboard</h3>

<p><div class="snippet" data-lang="js" data-hide="true" data-console="false" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var QUESTION_ID=90349,OVERRIDE_USER=58717;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="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});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;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>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;</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}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td>Link</td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td>Link</td></tr></tbody> </table></code>```

Title: The Letter A without A

Body:
MSX-BASIC, 25 bytes

?CHR$(3*3*3*2-(-3-3-3-2))


问:
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!)

答:
JavaScript, 29 Bytes

```<code>x=>x.reduce((a,b)=>a+b)/4+1|0
</code>```

ContentLicense: CC BY-SA 3.0

Title: Pokemon GO Evolution Cost Calculator

Body:
JavaScript, 29 Bytes

x=>x.reduce((a,b)=>a+b)/4+1|0


问:
Alphabet triangle strikes again

Task

Your task is to print this exact text:

```<code>A
BCD
EFGHI
JKLMNOP
QRSTUVWXY
ZABCDEFGHIJ
KLMNOPQRSTUVW
XYZABCDEFGHIJKL
MNOPQRSTUVWXYZABC
DEFGHIJKLMNOPQRSTUV
WXYZABCDEFGHIJKLMNOPQ
RSTUVWXYZABCDEFGHIJKLMN
OPQRSTUVWXYZABCDEFGHIJKLM
NOPQRSTUVWXYZABCDEFGHIJKLMN
OPQRSTUVWXYZABCDEFGHIJKLMNOPQ
RSTUVWXYZABCDEFGHIJKLMNOPQRSTUV
WXYZABCDEFGHIJKLMNOPQRSTUVWXYZABC
DEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL
MNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW
XYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ
KLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXY
ZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOP
QRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI
JKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCD
EFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZA
BCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ
</code>```

Specs

You may do it in all-lowercase instead of all-uppercase.

Trailing newlines at the end of the triangle is allowed.

Trailing spaces after each line is allowed.

You must print to STDOUT instead of outputting an array of strings.

Scoring

This is code-golf. Program with lowest byte-count wins.

Title: Alphabet triangle strikes again

Body:
Matlab, 81 bytes

b=char('A'+(1:26)-1)';b=repmat(b,1,26);
for j=1:26
disp(b((j-1)*(j-1)+1:j*j))
end


问:
Score Tarzan's Olympic Vine-Swinging Routine
Olympic vine-swingers perform their routines in standard trees.  In particular, Standard Tree n has vertices for 0 up through n-1 and edges linking each nonzero vertex a to the vertex n % a below it.  So, for example, Standard Tree 5 looks like this:

```<code>3
|
2   4
 \ /
  1
  |
  0
</code>```

because the remainder when 5 is divided by 3 is 2, the remainder when 5 is divided by 2 or by 4 is 1, and the remainder when 5 is divided by 1 is 0.

This year, Tarzan will be defending his gold with new routines, each of which begins at vertex n - 1, swings to vertex n - 2, continues to vertex n - 3, etc., until finally he dismounts to vertex 0.

The score for a routine is the sum of the scores for each swing (including the dismount), and the score for a swing is the distance within the tree between its start and end points.  Thus, Tarzan's routine on Standard Tree 5 has a score of 6:

a swing from 4 to 3 scores three points (down, up, up),

a swing from 3 to 2 scores one point (down),

a swing from 2 to 1 scores one point (down), and

a dismount from 1 to 0 scores one point (down).

Write a program or function that, given a positive integer n, computes the score of Tarzan's routine on Standard Tree n.  Sample inputs and outputs:

```<code> 1 ->  0
 2 ->  1
 3 ->  2
 4 ->  6
 5 ->  6
 6 -> 12
 7 -> 12
 8 -> 18
 9 -> 22
10 -> 32
11 -> 24
12 -> 34
13 -> 34
14 -> 36
15 -> 44
16 -> 58
17 -> 50
18 -> 64
19 -> 60
20 -> 66
21 -> 78
22 -> 88
23 -> 68
24 -> 82
</code>```

Rules and code scoring are as usual for code-golf.

答:
Perl, <s>65</s> <s>59</s> <s>55</s> 54 bytes

Includes +2 for -ap

Run with the tree size on STDIN:

```<code>for i in `seq 24`; do echo -n "$i: "; vines.pl <<< $i; echo; done
</code>```

vines.pl:

```<code>#!/usr/bin/perl -ap
$_=map{${"-@F"%$_}|=$_=$$_|$"x$p++.1;/.\b/g}1-$_..-1
</code>```

Explanation

If you rewrite the tree

```<code>3
|
2   4
 \ /
  1
  |
  0
</code>```

to one where each node contains the set of all its ancestors and itself:

```<code> {3}
  |
{2,3}   {4}
   \    /
    \  /
  {1,2,3,4}
      |
 {0,1,2,3,4}
</code>```

Then we can describe e.g. all the nodes the path from 4 to 3 as:

All nodes that contain 3 but not 4 (going down from 3)

All nodes that contain 4 but not 3 (going down from 4)

The highest node that contains both 3 and 4 (the join)

The number of edges is one less than the number of nodes so we can use that to
ignore the join point, so the number of edges on the path from 4 to 3 is 3 because:

The number of nodes that contain 3 but not 4: 2 nodes

The number of nodes that contain 4 but not 3: 1 node

Notice that this also works for a path that directly goes down to its target, e.g. for the path from 3 to 2 the number of edges is 1 because:

The number of nodes that contain 2 but not 3: 0 nodes

The number of nodes that contain 3 but not 2: 1 node

We can then sum over all these combinations.

If you instead look at just a node, e.g. node 2 with ancestor set {2,3}. This node is going to contribute once when processing the path 2 to 1 because it contains a 2 but not a 1. It will contribute nothing for the path 3 to 2 since it has both 2 and 3, but it will contribute once when processing the path 4 to 3 since it has 3 but no 4. In general a number in the ancestor set of a node will contribute one for each neighbour (one lower of higher) that is not in the set. Except for the maximum element (4 in this case) which only contributes for the low neighbour 3 since there is no path 5 to 4. Simular 0 is one sided, but since 0 is always at the root of the tree and contains all numbers (it is the ultimate join and we don't count joins) there is never any contribution from 0 so it's easiest to just leave node 0 out altogether.

So we can also solve the problem by looking at the ancestor set for each node, count the contributions and sum over all nodes.

To easily process neighbours I'm going to represent the ancestor sets as a string of spaces and 1's where each 1 at position p represents that n-1-p is an ancestor. So e.g. in our case of n=5 a 1 at position 0 indicates 4 is an ancestor. I will leave off trailing spaces. So the actual representation of the tree I will build is:

```<code>" 1"
  |
" 11"   "1"
   \    /
    \  /
   "1111"
</code>```

Notice that I left out node 0 which would be represented by "11111" because I'm going to ignore node 0 (it never contributes).

Ancestors with no lower neighbour are now represented by the end of a sequence of 1's. Ancestors with no higher neighbour are now represented by the start of a sequence of 1's, but we should ignore any start of a sequence at the start of a string since this would represent the path 5 to 4 which doesn't exist. This combination is exactly matched by the regex /.\b/.

Building the ancestor strings is done by processing all nodes in the order n-1 .. 1 and there set a 1 in the position for the node itself and doing an "or" into the descendant.

With all that the program is easy enough to understand:

```<code>-ap                                                  read STDIN into $_ and @F

   map{                                    }1-$_..-1 Process from n-1 to 1,
                                                     but use the negative
                                                     values so we can use a
                                                     perl sequence.
                                                     I will keep the current
                                                     ancestor for node $i in
                                                     global ${-$i} (another
                                                     reason to use negative
                                                     values since $1, $2 etc.
                                                     are read-only
                       $$_|$"x$p++.1                 "Or" the current node
                                                     position into its ancestor
                                                     accumulator
                    $_=                              Assign the ancestor string
                                                     to $_. This will overwrite
                                                     the current counter value
                                                     but that has no influence
                                                     on the following counter
                                                     values
       ${"-@F"%$_}|=                                 Merge the current node
                                                     ancestor string into the
                                                     successor
                                                     Notice that because this
                                                     is an |= the index
                                                     calculation was done
                                                     before the assignment
                                                     to $_ so $_ is still -i.
                                                     -n % -i = - (n % i), so
                                                     this is indeed the proper
                                                     index
                                     /.\b/g          As explained above this
                                                     gives the list of missing
                                                     higher and lower neighbours
                                                     but skips the start
$_=                                                  A map in scalar context
                                                     counts the number of
                                                     elements, so this assigns
                                                     the grand total to $_.
                                                     The -p implicitly prints
</code>```

Notice that replacing /.\b/ by /\b/ solves the roundtrip version of this problem where tarzan also takes the path 0 to n-1

Some examples of how the ancestor strings look (given in order n-1 .. 1):

```<code>n=23:
1
 1
  1
   1
    1
     1
      1
       1
        1
         1
          1
          11
         1  1
        1    1
       1      1
      11      11
     1          1
    11  1    1  11
   1              1
  1111  11  11  1111
 111111111  111111111
1111111111111111111111
edges=68

n=24:
1
 1
  1
   1
    1
     1
      1
       1
        1
         1
          1
           1
          1 1
         1   1
        1     1
       1       1
      1         1
     1  1     1  1
    1             1
   11    1   1    11
  1   1         1   1
 1        1 1        1
1                     1
edges=82
</code>```

Body:
Perl, <s>65</s> <s>59</s> <s>55</s> 54 bytes

Includes +2 for -ap

Run with the tree size on STDIN:

for i in `seq 24`; do echo -n "$i: "; vines.pl <<< $i; echo; done

vines.pl:

#!/usr/bin/perl -ap
$_=map{${"-@F"%$_}|=$_=$$_|$"x$p++.1;/.\b/g}1-$_..-1

Explanation

If you rewrite the tree

3
|
2   4
 \ /
  1
  |
  0

to one where each node contains the set of all its ancestors and itself:

 {3}
  |
{2,3}   {4}
   \    /
    \  /
  {1,2,3,4}
      |
 {0,1,2,3,4}

Then we can describe e.g. all the nodes the path from 4 to 3 as:

All nodes that contain 3 but not 4 (going down from 3)

All nodes that contain 4 but not 3 (going down from 4)

The highest node that contains both 3 and 4 (the join)

The number of edges is one less than the number of nodes so we can use that to
ignore the join point, so the number of edges on the path from 4 to 3 is 3 because:

The number of nodes that contain 3 but not 4: 2 nodes

The number of nodes that contain 4 but not 3: 1 node

Notice that this also works for a path that directly goes down to its target, e.g. for the path from 3 to 2 the number of edges is 1 because:

The number of nodes that contain 2 but not 3: 0 nodes

The number of nodes that contain 3 but not 2: 1 node

We can then sum over all these combinations.

If you instead look at just a node, e.g. node 2 with ancestor set {2,3}. This node is going to contribute once when processing the path 2 to 1 because it contains a 2 but not a 1. It will contribute nothing for the path 3 to 2 since it has both 2 and 3, but it will contribute once when processing the path 4 to 3 since it has 3 but no 4. In general a number in the ancestor set of a node will contribute one for each neighbour (one lower of higher) that is not in the set. Except for the maximum element (4 in this case) which only contributes for the low neighbour 3 since there is no path 5 to 4. Simular 0 is one sided, but since 0 is always at the root of the tree and contains all numbers (it is the ultimate join and we don't count joins) there is never any contribution from 0 so it's easiest to just leave node 0 out altogether.

So we can also solve the problem by looking at the ancestor set for each node, count the contributions and sum over all nodes.

To easily process neighbours I'm going to represent the ancestor sets as a string of spaces and 1's where each 1 at position p represents that n-1-p is an ancestor. So e.g. in our case of n=5 a 1 at position 0 indicates 4 is an ancestor. I will leave off trailing spaces. So the actual representation of the tree I will build is:

" 1"
  |
" 11"   "1"
   \    /
    \  /
   "1111"

Notice that I left out node 0 which would be represented by "11111" because I'm going to ignore node 0 (it never contributes).

Ancestors with no lower neighbour are now represented by the end of a sequence of 1's. Ancestors with no higher neighbour are now represented by the start of a sequence of 1's, but we should ignore any start of a sequence at the start of a string since this would represent the path 5 to 4 which doesn't exist. This combination is exactly matched by the regex /.\b/.

Building the ancestor strings is done by processing all nodes in the order n-1 .. 1 and there set a 1 in the position for the node itself and doing an "or" into the descendant.

With all that the program is easy enough to understand:

-ap                                                  read STDIN into $_ and @F

   map{                                    }1-$_..-1 Process from n-1 to 1,
                                                     but use the negative
                                                     values so we can use a
                                                     perl sequence.
                                                     I will keep the current
                                                     ancestor for node $i in
                                                     global ${-$i} (another
                                                     reason to use negative
                                                     values since $1, $2 etc.
                                                     are read-only
                       $$_|$"x$p++.1                 "Or" the current node
                                                     position into its ancestor
                                                     accumulator
                    $_=                              Assign the ancestor string
                                                     to $_. This will overwrite
                                                     the current counter value
                                                     but that has no influence
                                                     on the following counter
                                                     values
       ${"-@F"%$_}|=                                 Merge the current node
                                                     ancestor string into the
                                                     successor
                                                     Notice that because this
                                                     is an |= the index
                                                     calculation was done
                                                     before the assignment
                                                     to $_ so $_ is still -i.
                                                     -n % -i = - (n % i), so
                                                     this is indeed the proper
                                                     index
                                     /.\b/g          As explained above this
                                                     gives the list of missing
                                                     higher and lower neighbours
                                                     but skips the start
$_=                                                  A map in scalar context
                                                     counts the number of
                                                     elements, so this assigns
                                                     the grand total to $_.
                                                     The -p implicitly prints

Notice that replacing /.\b/ by /\b/ solves the roundtrip version of this problem where tarzan also takes the path 0 to n-1

Some examples of how the ancestor strings look (given in order n-1 .. 1):

n=23:
1
 1
  1
   1
    1
     1
      1
       1
        1
         1
          1
          11
         1  1
        1    1
       1      1
      11      11
     1          1
    11  1    1  11
   1              1
  1111  11  11  1111
 111111111  111111111
1111111111111111111111
edges=68

n=24:
1
 1
  1
   1
    1
     1
      1
       1
        1
         1
          1
           1
          1 1
         1   1
        1     1
       1       1
      1         1
     1  1     1  1
    1             1
   11    1   1    11
  1   1         1   1
 1        1 1        1
1                     1
edges=82


问:
Output a Magical 8 Trapezium
Your task is to output a Magical 8 Trapezium:

```<code>        1 × 8 + 1 = 9
       12 × 8 + 2 = 98
      123 × 8 + 3 = 987
     1234 × 8 + 4 = 9876
    12345 × 8 + 5 = 98765
   123456 × 8 + 6 = 987654
  1234567 × 8 + 7 = 9876543
 12345678 × 8 + 8 = 98765432
123456789 × 8 + 9 = 987654321
</code>```

Output in your chosen language in the fewest bytes possible.

Note the number of spaces at the start of each line to maintain the trapezium shape.

Trailing spaces are allowed.

You can use × or the letter x - whichever you prefer.

Title: Output a Magical 8 Trapezium

Body:
R, <s>107</s> 103 bytes

a=1;for(i in 2:10){cat(rep("",11-i),paste(a,"x",8,"+",(i-1),"=",strtoi(a)*8+(i-1)),"\n");a=paste0(a,i)}

Ungolfed :

a=1

for(i in 2:10)
    cat(rep("",11-i),paste(a,"x",8,"+",(i-1),"=",strtoi(a)*8+(i-1)),"\n")
    a=paste0(a,i)

Result :

        1 x 8 + 1 = 9
       12 x 8 + 2 = 98
      123 x 8 + 3 = 987
     1234 x 8 + 4 = 9876
    12345 x 8 + 5 = 98765
   123456 x 8 + 6 = 987654
  1234567 x 8 + 7 = 9876543
 12345678 x 8 + 8 = 98765432
123456789 x 8 + 9 = 987654321


问:
How can I get a repdigit?
In honor of how much rep I had several hours ago, when I first thought of this challenge:

Numbers like this that are made up of a single digit repeating are called repdigits. Repdigits are fun! Every body would be more happy if the amount of rep they had was a repdigit¹, but I am impatient, so you need to help me find out the fastest way to get to a repdigit.

Here is your challenge:

Given a positive integers representing reputation, output the minimum amount of rep they need to gain to get to a repdigit. For example, at the time of writing this challenge, user Martin Ender had 102,856 rep. The nearest rep-digit is 111,111, so he would need to gain: 8255 rep to be at a repdigit.

Since people dislike losing rep, we will only consider non-negative changes. This means that, for example, if someone is at 12 rep, rather than losing 1 rep, the solution is to gain 10 rep. This allows '0' to be a valid output, since anyone who has 111 rep is already at a repdigit.

Input and output can be in any reasonable format, and since it is impossible to have less than 1 rep on any Stack Exchange site, you can assume no inputs will be less than 1.

One cornercase to note:

If a user has less than 10 rep, they are already at a repdigit, and so they also need '0'.

Test IO:

```<code>#Input      #Ouput
8           0
100         11
113         109
87654321    1234567
42          2
20000       2222
11132       11090
</code>```

Standard loopholes apply, and the shortest solution in bytes wins!

答:
PowerShell v2+, 66 bytes

```<code>param($n)for($x=+"$($n[0])";($y="$x"*$n.length)-lt$n;$x++){}+$y-$n
</code>```

The usually-good-for-golf very loose casting of PowerShell is a major downfall here.

Takes input $n as a string, and enters a for loop. For the setup step, we extract out the first character $n[0], but have to convert it back to a string "$(...)" before casting as an int + and saving into $x. Otherwise, the later arithmetic will be using the ASCII value of the char-code.

The conditional checks whether a string constructed from $n.length "$x"s, temporarily stored in $y, is less-than $n. So long as it's not, we increment $x++, setting up the conditional for the next loop.

For example, for input 123, the value of $y when the conditional is first checked will be 111, which is less-than $n, so the loop continues. There's nothing in the loop body, so the step increment happens $x++, then the conditional is checked again. This time $y equals 222, which is greater than $n, so the loop terminates. If the input is already a repdigit, the conditional is not satisfied, because at that point $y is equal to $n.

Once out of the loop, we cast $y to an integer +, then subtract $n. That result is left on the pipeline and output is implicit.

Title: How can I get a repdigit?

Body:
PowerShell v2+, 66 bytes

param($n)for($x=+"$($n[0])";($y="$x"*$n.length)-lt$n;$x++){}+$y-$n

The usually-good-for-golf very loose casting of PowerShell is a major downfall here.

Takes input $n as a string, and enters a for loop. For the setup step, we extract out the first character $n[0], but have to convert it back to a string "$(...)" before casting as an int + and saving into $x. Otherwise, the later arithmetic will be using the ASCII value of the char-code.

The conditional checks whether a string constructed from $n.length "$x"s, temporarily stored in $y, is less-than $n. So long as it's not, we increment $x++, setting up the conditional for the next loop.

For example, for input 123, the value of $y when the conditional is first checked will be 111, which is less-than $n, so the loop continues. There's nothing in the loop body, so the step increment happens $x++, then the conditional is checked again. This time $y equals 222, which is greater than $n, so the loop terminates. If the input is already a repdigit, the conditional is not satisfied, because at that point $y is equal to $n.

Once out of the loop, we cast $y to an integer +, then subtract $n. That result is left on the pipeline and output is implicit.


问:
How does math work in Anastasiya's world?

Background:

Standard operation math like basic addition and multiplication in the real world work like these:

```<code>12 + 123 = 135
</code>```

and

```<code>12 * 123 = 1476
</code>```

That's not interesting and boring! Many schools are already interpreting this as practice, practice, practice of formal algorithms. That implies a pretty rigid and boring mathematical diet and is not what is intended in this challenge. Get ready to play some fun on our beloved site.

Consider the process of adding two positive integer numbers, then adding again all the digits of its result. Repeating with the addition until only a single digit is obtained. For example:

The result of 12 + 123 is 135.

Adding all the digits of 135 we obtain 1 + 3 + 5 = 9.

The number of steps required to obtain a single digit value 9 in this repeated addition is 2.

As with the previous process of the addition, the multiplication of two positive integer numbers follows the same process. Multiply all the digits of its result and then repeating this process until only a single digit remains. Take the above example:

The result of 12 * 123 is 1476.

Multiply all the digits of 1476 we obtain 1 * 4 * 7 * 6 = 168.

Multiply again all the digits of 168 we obtain 1 * 6 * 8 = 48.

Multiply again all the digits of 48 we obtain 4 * 8 = 32.

Multiply once again all the digits of 32 we obtain 3 * 2 = 6.

The number of steps required to obtain a single digit value 6 this repeated multiplication is 5.

For this challenge's sake and avoiding any misuse of math notations, I introduce these two dummy notations: (+) and (*), but you may use any notation you like, which work like the followings:

The operation of repeated addition process to obtain a single value is 12 (+) 123 = 9.

The operation of repeated multiplication process to obtain a single value is 12 (*) 123  = 6.

Challenge:

The challenge is to write either a program or a function which can perform both of operations as explained in the background section: (+) and (*).

Input:

The inputs of the program or the function are two positive integers and one operation either (+) and (*). The format of the input is an arbitrary choice of the programmer. You may format the input, for example, a (+) b or F(a, (+), b) or any format you wish.

Output:

The output of the program or the function must contain the result of operation and the number of steps required with freestyle format as you wish.

Test Cases (ignore the input and output format):

```<code>    81 (+) 31       -->   (4 ; 2)
    351 (+) 14568   -->   (6 ; 3)
    21 (*) 111      -->   (8 ; 3)
    136 (*) 2356    -->   (0 ; 2)
</code>```

General rules:

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

Don't let esolangs discourage you from posting an answer with regular languages. Enjoy this challenge by providing an answer as short as possible with your programming language. If you post a clever answer and a clear explanation, your answer will be appreciated (hence the upvotes) regardless of the programming language you use.

Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/ method with the proper parameters, full programs, etc. The choice is yours.

If possible, your program can properly handle large numbers. If not, that will just be fine.

Let the game begin!!

答:
Pyth, 16

```<code>eJ.uvjhQ`N.vQ)lJ
</code>```

Takes input like "+ 123 12" for addition, and "* 123 12" for multiplication. Outputs like result<linefeed>steps.

Try it here, or run a Test Suite, but note that this relies on eval, so only the addition variant will work in the online interpreter. Multiplication works correctly with the offline interpreter.

This uses the cumulative reduction function to create a list of intermediate results, so for "+ 351 14568" we get [14919, 24, 6]. This works because single digit numbers are a fixed point of the Anastasiya addition and multiplication. Then we just get the last element of the array as well as the length of the array.

This will work for arbitrarily large numbers, at least until you run out of memory.

Body:
Pyth, 16

eJ.uvjhQ`N.vQ)lJ

Takes input like "+ 123 12" for addition, and "* 123 12" for multiplication. Outputs like result<linefeed>steps.

Try it here, or run a Test Suite, but note that this relies on eval, so only the addition variant will work in the online interpreter. Multiplication works correctly with the offline interpreter.

This uses the cumulative reduction function to create a list of intermediate results, so for "+ 351 14568" we get [14919, 24, 6]. This works because single digit numbers are a fixed point of the Anastasiya addition and multiplication. Then we just get the last element of the array as well as the length of the array.

This will work for arbitrarily large numbers, at least until you run out of memory.


答:
Haskell, <s>76</s> 70 bytes

```<code> (x#y)f=until(<[10])(\[s,i]->[foldr(f.read.pure)0$show s,i+1])[f x y,1]
</code>```

Returns a two element list with the result and number of steps. Works for arbitrary large numbers. Usage example: (351#14568)(+) -> [6,3].

Edit: Thanks to @BlackCap for 6 bytes.

Title: How does math work in Anastasiya's world?

Body:
Background:

Standard operation math like basic addition and multiplication in the real world work like these:

```<code>12 + 123 = 135
</code>```

and

```<code>12 * 123 = 1476
</code>```

That's not interesting and boring! Many schools are already interpreting this as practice, practice, practice of formal algorithms. That implies a pretty rigid and boring mathematical diet and is not what is intended in this challenge. Get ready to play some fun on our beloved site.

Consider the process of adding two positive integer numbers, then adding again all the digits of its result. Repeating with the addition until only a single digit is obtained. For example:

The result of 12 + 123 is 135.

Adding all the digits of 135 we obtain 1 + 3 + 5 = 9.

The number of steps required to obtain a single digit value 9 in this repeated addition is 2.

As with the previous process of the addition, the multiplication of two positive integer numbers follows the same process. Multiply all the digits of its result and then repeating this process until only a single digit remains. Take the above example:

The result of 12 * 123 is 1476.

Multiply all the digits of 1476 we obtain 1 * 4 * 7 * 6 = 168.

Multiply again all the digits of 168 we obtain 1 * 6 * 8 = 48.

Multiply again all the digits of 48 we obtain 4 * 8 = 32.

Multiply once again all the digits of 32 we obtain 3 * 2 = 6.

The number of steps required to obtain a single digit value 6 this repeated multiplication is 5.

For this challenge's sake and avoiding any misuse of math notations, I introduce these two dummy notations: (+) and (*), but you may use any notation you like, which work like the followings:

The operation of repeated addition process to obtain a single value is 12 (+) 123 = 9.

The operation of repeated multiplication process to obtain a single value is 12 (*) 123  = 6.

Challenge:

The challenge is to write either a program or a function which can perform both of operations as explained in the background section: (+) and (*).

Input:

The inputs of the program or the function are two positive integers and one operation either (+) and (*). The format of the input is an arbitrary choice of the programmer. You may format the input, for example, a (+) b or F(a, (+), b) or any format you wish.

Output:

The output of the program or the function must contain the result of operation and the number of steps required with freestyle format as you wish.

Test Cases (ignore the input and output format):

```<code>    81 (+) 31       -->   (4 ; 2)
    351 (+) 14568   -->   (6 ; 3)
    21 (*) 111      -->   (8 ; 3)
    136 (*) 2356    -->   (0 ; 2)
</code>```

General rules:

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

Don't let esolangs discourage you from posting an answer with regular languages. Enjoy this challenge by providing an answer as short as possible with your programming language. If you post a clever answer and a clear explanation, your answer will be appreciated (hence the upvotes) regardless of the programming language you use.

Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/ method with the proper parameters, full programs, etc. The choice is yours.

If possible, your program can properly handle large numbers. If not, that will just be fine.

Let the game begin!!

Body:
Haskell, <s>76</s> 70 bytes

 (x#y)f=until(<[10])(\[s,i]->[foldr(f.read.pure)0$show s,i+1])[f x y,1]

Returns a two element list with the result and number of steps. Works for arbitrary large numbers. Usage example: (351#14568)(+) -> [6,3].

Edit: Thanks to @BlackCap for 6 bytes.


答:
R, <s>130</s> 124 chars

A somewhat different approach from @Frédéric's:

```<code>f=function(a,f,b){b=c(a,b);n=1;while((m<-nchar(d<-switch(f,'(+)'=sum,prod)(b)))>1){b=d%%10^(1:m)%/%10^(1:m-1);n=n+1};c(d,n)}
</code>```

Indented, with newlines:

f=function(a,f,b){
    b=c(a,b) # Take both numbers
    n=1 #Counter
    while((m<-nchar(d<-switch(f,'(+)'=sum,prod)(b)))>1){
#My own special digit splitter! (d is the result and m is the nb of char of d)
        b=d%%10^(1:m)%/%10^(1:m-1)
        n=n+1
    }
    c(d,n) #Print results
    }
```
<p>Line 4 probably needs more explanations:</p>
<pre class="lang-r prettyprint-override"><code>switch(f,'(+)'=sum,prod) #pick which operator to use
switch(f,'(+)'=sum,prod)(b) # apply it to b
d<-switch(f,'(+)'=sum,prod)(b) #Saves the result in d
nchar(d<-switch(f,'(+)'=sum,prod)(b))#Measures the number of character of d
m<-nchar(d<-switch(f,'(+)'=sum,prod)(b)) #Saves it in m
(m<-nchar(d<-switch(f,'(+)'=sum,prod)(b)))>1 #Checks if it is more than 1
</code>```

Test cases:

```<code>> f(12,"(+)",123)
[1] 9 2
> f(12,"(*)",123)
[1] 6 5
> f(351,"(+)",14568)
[1] 6 3
</code>```

Body:
R, <s>130</s> 124 chars

A somewhat different approach from @Frédéric's:

f=function(a,f,b){b=c(a,b);n=1;while((m<-nchar(d<-switch(f,'(+)'=sum,prod)(b)))>1){b=d%%10^(1:m)%/%10^(1:m-1);n=n+1};c(d,n)}

Indented, with newlines:

f=function(a,f,b){
    b=c(a,b) # Take both numbers
    n=1 #Counter
    while((m<-nchar(d<-switch(f,'(+)'=sum,prod)(b)))>1){
#My own special digit splitter! (d is the result and m is the nb of char of d)
        b=d%%10^(1:m)%/%10^(1:m-1)
        n=n+1
    }
    c(d,n) #Print results
    }

Line 4 probably needs more explanations:

switch(f,'(+)'=sum,prod) #pick which operator to use
switch(f,'(+)'=sum,prod)(b) # apply it to b
d<-switch(f,'(+)'=sum,prod)(b) #Saves the result in d
nchar(d<-switch(f,'(+)'=sum,prod)(b))#Measures the number of character of d
m<-nchar(d<-switch(f,'(+)'=sum,prod)(b)) #Saves it in m
(m<-nchar(d<-switch(f,'(+)'=sum,prod)(b)))>1 #Checks if it is more than 1

Test cases:

> f(12,"(+)",123)
[1] 9 2
> f(12,"(*)",123)
[1] 6 5
> f(351,"(+)",14568)
[1] 6 3


答:
PHP 5.6, <s>59</s> <s>53</s> <s>51</s> 50 bytes

Saved <s>6</s> 8 bytes thanks to @manatwork.

while(count_chars($argv[1]+$b,3)[1])$b++;echo$b?:0
```

<p>Test with:</p>

<pre class="lang-php prettyprint-override"><code>php test.php 11132
</code>```

The count_chars() function with 3 as the second parameter returns a string with the distinct characters in a string. When this string is 1 character long ([1] will return false when it's length 1) then echo $b, otherwise increment $b and loop again.

Title: How can I get a repdigit?

Body:
In honor of how much rep I had several hours ago, when I first thought of this challenge:

Numbers like this that are made up of a single digit repeating are called repdigits. Repdigits are fun! Every body would be more happy if the amount of rep they had was a repdigit¹, but I am impatient, so you need to help me find out the fastest way to get to a repdigit.

Here is your challenge:

Given a positive integers representing reputation, output the minimum amount of rep they need to gain to get to a repdigit. For example, at the time of writing this challenge, user Martin Ender had 102,856 rep. The nearest rep-digit is 111,111, so he would need to gain: 8255 rep to be at a repdigit.

Since people dislike losing rep, we will only consider non-negative changes. This means that, for example, if someone is at 12 rep, rather than losing 1 rep, the solution is to gain 10 rep. This allows '0' to be a valid output, since anyone who has 111 rep is already at a repdigit.

Input and output can be in any reasonable format, and since it is impossible to have less than 1 rep on any Stack Exchange site, you can assume no inputs will be less than 1.

One cornercase to note:

If a user has less than 10 rep, they are already at a repdigit, and so they also need '0'.

Test IO:

```<code>#Input      #Ouput
8           0
100         11
113         109
87654321    1234567
42          2
20000       2222
11132       11090
</code>```

Standard loopholes apply, and the shortest solution in bytes wins!

Body:
PHP 5.6, <s>59</s> <s>53</s> <s>51</s> 50 bytes

Saved <s>6</s> 8 bytes thanks to @manatwork.

while(count_chars($argv[1]+$b,3)[1])$b++;echo$b?:0

Test with:

php test.php 11132

The count_chars() function with 3 as the second parameter returns a string with the distinct characters in a string. When this string is 1 character long ([1] will return false when it's length 1) then echo $b, otherwise increment $b and loop again.


答:
Brain-Flak <s>690</s> 358 bytes

Here's my go at it

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

Try It Online

Explanation

Start by making a second copy of the input that is one less than the original.  We will use the copy to search for the next repdigit.  We subtract one in case the number itself was a repdigit

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

Push one to satisfy the coming loop. (doesn't have to be one just not zero)

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

This loop will run until there is a repdigit on top of the stack

```<code>{
</code>```

Pop the crap.  Their is a "boolean" on top that drives the loop, since it is no longer needed we pop it.

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

Add one and duplicate the top.  The copy will be decomposed into its digits.

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

While the copy is not zero...

```<code>{
</code>```

Copy again

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

Mod 10 and move to the other stack

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

Divide by 10 (Integer division)

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

}
</code>```

Pop the zero that was our copy

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

We have now decomposed the number into its base 10 digits, So we swap over to the stack with all the digits.

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

While the leading digit is not zero

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

We pick up a copy of the stack height (i.e. the number of digits)...

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

Silently subtract one from every number on the stack

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

Put the stack height we picked up down. (and swap to the other stack)

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

We use the stack height to pull all the digits we placed on the other stack back onto the proper stack.

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

Pop the zero that was our stack height

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

Swap back onto the stack with the digits (or what were the digits)

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

End loop

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

Now we have subtracted the top digit from all the other digits.  If all the digits are zero the orginal number (not the input but the number we are checking) was a repdigit.[citation needed].  So we need to check for non-zeroes.

While the stack height is not zero

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

If the digit is not zero move it to the other stack and replace it with a zero.

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

Pop it (now it is a zero)

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

End loop

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

Swap over onto the other stack (duh..)

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

Grab our selves a copy of the stack height minus two

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

While the stack height is not two (the original and the accumulator)

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

Pop the top

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

End the while

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

Put down our copy of the stack height minus two.  This ends up being the number of digits that are not the same as the first digit.  In other words if it is zero it is a repdigit.

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

If this loop ends we have found a repdigit

```<code>{
</code>```0

Pop the "boolean"

```<code>{
</code>```1

Subtract the original from the repdigit

```<code>{
</code>```2

Title: How can I get a repdigit?

Body:
Brain-Flak <s>690</s> 358 bytes

Here's my go at it

(({})[()])(()){{}(({}())){(({}))(<((()()()()()){}<>)>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<{}>)<>(<((()()()()()){}(<>))>)<>{({}[()])<>(({}()[({}<({}())>)])){{}(<({}({}<({}[()])>))>)}{}<>}{}<>{}{}({}<>)}{}<>{(([])<{{}({}[()]<>)<>([])}{}><>){({}[()]<({}<>)<>>)}{}<>}([]){{}{(<({}<>)<>>)}{}([])}{}<>(([][()()])<{{}{}([][()()])}{}>)}{}({}[{}])

<a href="http://brain-flak.tryitonline.net/#code=KCh7fSlbKCldKSgoKSl7e30oKHt9KCkpKXsoKHt9KSkoPCgoKCkoKSgpKCkoKSl7fTw-KT4pPD57KHt9WygpXSk8Pigoe30oKVsoe30pXSkpe3t9KDwoe30oe30pKT4pfXt9PD59e308Pih7fTx7fT4pPD4oPCgoKCkoKSgpKCkoKSl7fSg8PikpPik8Pnsoe31bKCldKTw-KCh7fSgpWyh7fTwoe30oKSk-KV0pKXt7fSg8KHt9KHt9PCh7fVsoKV0pPikpPil9e308Pn17fTw-e317fSh7fTw-KX17fTw-eygoW10pPHt7fSh7fVsoKV08Pik8PihbXSl9e30-PD4peyh7fVsoKV08KHt9PD4pPD4-KX17fTw-fShbXSl7e317KDwoe308Pik8Pj4pfXt9KFtdKX17fTw-KChbXVsoKSgpXSk8e3t9e30oW11bKCkoKV0pfXt9Pil9e30oe31be31dKQ&input=MTEy" rel="nofollow noreferrer">Try It Online

Explanation

Start by making a second copy of the input that is one less than the original.  We will use the copy to search for the next repdigit.  We subtract one in case the number itself was a repdigit

(({})[()])

Push one to satisfy the coming loop. (doesn't have to be one just not zero)

(())

This loop will run until there is a repdigit on top of the stack

{

Pop the crap.  Their is a "boolean" on top that drives the loop, since it is no longer needed we pop it.

{}

Add one and duplicate the top.  The copy will be decomposed into its digits.

(({}()))

While the copy is not zero...

{

Copy again

(({}))

Mod 10 and move to the other stack

(<((()()()()()){}<>)>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<{}>)<>

Divide by 10 (Integer division)

(<((()()()()()){}(<>))>)<>{({}[()])<>(({}()[({}<({}())>)])){{}(<({}({}<({}[()])>))>)}{}<>}{}<>{}{}({}<>)

}

Pop the zero that was our copy

{}

We have now decomposed the number into its base 10 digits, So we swap over to the stack with all the digits.

<>

While the leading digit is not zero

{

We pick up a copy of the stack height (i.e. the number of digits)...

(([])<

Silently subtract one from every number on the stack

{
{}
({}[()]<>)<>
([])
}
{}

Put the stack height we picked up down. (and swap to the other stack)

><>)

We use the stack height to pull all the digits we placed on the other stack back onto the proper stack.

{
({}[()]<({}<>)<>>)
}

Pop the zero that was our stack height

{}

Swap back onto the stack with the digits (or what were the digits)

<>

End loop

}

Now we have subtracted the top digit from all the other digits.  If all the digits are zero the orginal number (not the input but the number we are checking) was a repdigit.[citation needed].  So we need to check for non-zeroes.

While the stack height is not zero

([])
{
{}

If the digit is not zero move it to the other stack and replace it with a zero.

{
(<({}<>)<>>)
}

Pop it (now it is a zero)

{}

End loop

([])
}
{}

Swap over onto the other stack (duh..)

<>

Grab our selves a copy of the stack height minus two

(([][()()])<

While the stack height is not two (the original and the accumulator)

{
{}

Pop the top

{}

End the while

([][()()])
}
{}

Put down our copy of the stack height minus two.  This ends up being the number of digits that are not the same as the first digit.  In other words if it is zero it is a repdigit.

>)

If this loop ends we have found a repdigit

}

Pop the "boolean"

{}

Subtract the original from the repdigit

({}[{}])


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

答:
PowerShell v5, 97 bytes

```<code>param($n)$l=1;for($i=0;$i-lt$n){$i+="$i*".length;if("$i".Length-gt$l){$i++;$l++};ac .\o "$i*" -n}
</code>```

Takes input as a command-line argument $n, sets helper $l which we use to keep track of our integer length. Then, we loop from 0 up to $n. Each iteration, we increment $i by the .length of the string formed from $i and an asterisk. Then, if the .length of $i changed (e.g., we moved from 2 digits to 3 digits), we increment both the helper $length variable and $i (to account for the additional digit). We then use the add-content command to append "$i*" to file .\o in the current directory, with -noNewLine.

NB

Requires v5, since the -noNewLine parameter was finally added in that version.

PowerShell will automatically up-convert from [int] to [double] (no, I don't know why it doesn't go to [long]), so this will properly handle input up to and greater than 2147483648, without problem. Theoretically, it will handle input somewhere up to around 1.79769313486232E+308 (max value of [double]) before complaining, but I expect the disk to fill up before that happens. ;-)

Due to the loop conditional checking, this will output to the file a minimum of the input length. For example, for input 10 this will output 2*4*6*8*11*, since 11 is the first $i value greater than the input.

PowerShell v2+, also 97 bytes (non-competing)

```<code>param($n)$l=1;-join(&{for($i=0;$i-lt$n){$i+="$i*".length;if("$i".Length-gt$l){$i++;$l++};"$i*"}})
</code>```

Instead of sending to a file, this encapsulates the loop iterations and then -joins them together into a string. This allows it to work for versions earlier than v5. However, since .NET defines a [string] with a constructor like String(char c,Int32 length), this version does not satisfy the max input requirement, since the output string will overflow and barf.

Also, you may not want to have a ~2GB string floating around in your pipeline. Just sayin'.

Title: Create an unlimited counterstring

Body:
PowerShell v5, 97 bytes

param($n)$l=1;for($i=0;$i-lt$n){$i+="$i*".length;if("$i".Length-gt$l){$i++;$l++};ac .\o "$i*" -n}

Takes input as a command-line argument $n, sets helper $l which we use to keep track of our integer length. Then, we loop from 0 up to $n. Each iteration, we increment $i by the .length of the string formed from $i and an asterisk. Then, if the .length of $i changed (e.g., we moved from 2 digits to 3 digits), we increment both the helper $length variable and $i (to account for the additional digit). We then use the add-content command to append "$i*" to file .\o in the current directory, with -noNewLine.

NB

Requires v5, since the -noNewLine parameter was finally added in that version.

PowerShell will automatically up-convert from [int] to [double] (no, I don't know why it doesn't go to [long]), so this will properly handle input up to and greater than 2147483648, without problem. Theoretically, it will handle input somewhere up to around 1.79769313486232E+308 (max value of [double]) before complaining, but I expect the disk to fill up before that happens. ;-)

Due to the loop conditional checking, this will output to the file a minimum of the input length. For example, for input 10 this will output 2*4*6*8*11*, since 11 is the first $i value greater than the input.

PowerShell v2+, also 97 bytes (non-competing)

param($n)$l=1;-join(&{for($i=0;$i-lt$n){$i+="$i*".length;if("$i".Length-gt$l){$i++;$l++};"$i*"}})

Instead of sending to a file, this encapsulates the loop iterations and then -joins them together into a string. This allows it to work for versions earlier than v5. However, since .NET defines a [string] with a constructor like String(char c,Int32 length), this version does not satisfy the max input requirement, since the output string will overflow and barf.

Also, you may not want to have a ~2GB string floating around in your pipeline. Just sayin'.


答:
Perl, 40 + 1 (-n) = 41 bytes

/^(.)\1*$/&&say($v|0) or$_++&&++$v&&redo
```

<p>If printing nothing instead of <code>0</code> when the number is already a repdigit is acceptable, then 37 bytes are enough :</p>

<pre class="lang-pl prettyprint-override"><code>/^(.)\1*$/&&say$v or$_++&&++$v&&redo
</code>```

Run with -n (1 byte) and -E or -M5.010 (free) :

```<code>perl -nE '/^(.)\1*$/&&say($v|0) or$_++&&++$v&&redo'
</code>```

Explanations : there are two major parts in the code : /^(.)\1*$/&&say$v and $_++&&++$v&&redo. The first one test if $_ is a repdigit; if yes it prints the number we added to the original number to make it a repdigit ($v), and if no, we had 1 to both $_ and $v, and start over.

Title: How can I get a repdigit?

Body:
Perl, 40 + 1 (-n) = 41 bytes

/^(.)\1*$/&&say($v|0) or$_++&&++$v&&redo

If printing nothing instead of 0 when the number is already a repdigit is acceptable, then 37 bytes are enough :

/^(.)\1*$/&&say$v or$_++&&++$v&&redo

Run with -n (1 byte) and -E or -M5.010 (free) :

perl -nE '/^(.)\1*$/&&say($v|0) or$_++&&++$v&&redo'

Explanations : there are two major parts in the code : /^(.)\1*$/&&say$v and $_++&&++$v&&redo. The first one test if $_ is a repdigit; if yes it prints the number we added to the original number to make it a repdigit ($v), and if no, we had 1 to both $_ and $v, and start over.


答:
Mathematica, <s>105</s> 94 bytes

Code.

```<code>{x,y}=(c=0;f//.a_:>(c++;t=o@@IntegerDigits@a);{t,c})&/.{{f->#1+#2,o->Plus},{f->#1#2,o->Times}}
</code>```

Usage.

```<code>x[81, 31]
(* {4, 2} *)

x[351, 14568]
(* {6, 3} *)

y[21, 111]
(* {8, 3} *)

y[136, 2356]
(* {0, 2} *)
</code>```

Explanation.

The two functions x (for (+)) and y (for (*)) are created at the same time by replacing the parameters f and o in

```<code>(c = 0;
 f //. a_ :> (c++; t = o@@ IntegerDigits@a);
 {t, c}
)&
</code>```

with their appropriate values. For x, f becomes #1 + #2 and o becomes Plus; for y, they respectively become #1 #2 and Times. Rewriting the function x for the last part of the explanation:

```<code>x = (
  c = 0;
  #1 + #2 //. a_ :> (c++; t = Plus@@IntegerDigits@a);
  {t, c}
) &;

(* The symbol //. stands for ReplaceRepeated.
   The rule a_ :> (c++; t = Plus@@IntegerDigits@a) is applied until the result no longer
changed. Specifically, the rule increments the counter of 1 at each step (this is c++),
then takes the sum of the digits of the previous result (this is Plus@@IntegerDigits@a).
The rule stops to apply when the variable t is less than 10. We return the final result and
the number of steps with {t, c}. *)
</code>```

Body:
Mathematica, <s>105</s> 94 bytes

Code.

{x,y}=(c=0;f//.a_:>(c++;t=o@@IntegerDigits@a);{t,c})&/.{{f->#1+#2,o->Plus},{f->#1#2,o->Times}}

Usage.

x[81, 31]
(* {4, 2} *)

x[351, 14568]
(* {6, 3} *)

y[21, 111]
(* {8, 3} *)

y[136, 2356]
(* {0, 2} *)

Explanation.

The two functions x (for (+)) and y (for (*)) are created at the same time by replacing the parameters f and o in

(c = 0;
 f //. a_ :> (c++; t = o@@ IntegerDigits@a);
 {t, c}
)&

with their appropriate values. For x, f becomes #1 + #2 and o becomes Plus; for y, they respectively become #1 #2 and Times. Rewriting the function x for the last part of the explanation:

x = (
  c = 0;
  #1 + #2 //. a_ :> (c++; t = Plus@@IntegerDigits@a);
  {t, c}
) &;

(* The symbol //. stands for ReplaceRepeated.
   The rule a_ :> (c++; t = Plus@@IntegerDigits@a) is applied until the result no longer
changed. Specifically, the rule increments the counter of 1 at each step (this is c++),
then takes the sum of the digits of the previous result (this is Plus@@IntegerDigits@a).
The rule stops to apply when the variable t is less than 10. We return the final result and
the number of steps with {t, c}. *)


答:
Java, 74 72 bytes

int c(int i){int n=0;while(!(i+++"").matches("^(.)\\1*$"))n++;return n;}
```

<p><em>(If the other Java entry is 76 bytes, this one is <del>74</del> 72, since it's <del>two</del> four bytes shorter).</em></p>

<p>Anyway, just increment the input until it's a repdigit while incrementing a counter. Return the counter.</p>

<p>Yes, those are three pluses in a row, two to increment the input, one to concatenate an empty string to make it a string.<br>
No, I didn't think it would be legal without a space in between either, but there you go. That's what a typo will do for you: one byte shorter.</p>

<p>Using a for-loop instead of a while takes exactly as many bytes:</p>

<pre class="lang-java prettyprint-override"><code>int c(int i){int n=0;for(;!(i+++"").matches("^(.)\\1*$");n++);return n;}
</code>```

Edit:

An earlier version had matches("^(\\d)\\1*$") to check for a repdigit, but since we've just converted an int to a string, using a . to match is enough.

Ungolfed & test cases:

Try it here.

class Main{
  static int c(int i){
    int n=0;
    while(!(i++ + "").matches("^(.)\\1*$")) {
      n++;
    }
    return n;
  }

  public static void main(String[] a){
    System.out.println(c(8));
    System.out.println(c(100));
    System.out.println(c(113));
    System.out.println(c(87654321));
    System.out.println(c(42));
    System.out.println(c(20000));
    System.out.println(c(11132));
  }
```

<p>}</p>

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

<pre class="lang-java prettyprint-override"><code>0
11
109
1234567
2
2222
11090
</code>```

Title: How can I get a repdigit?

Body:
Java, 74 72 bytes

int c(int i){int n=0;while(!(i+++"").matches("^(.)\\1*$"))n++;return n;}

(If the other Java entry is 76 bytes, this one is 74 72, since it's two four bytes shorter).

Anyway, just increment the input until it's a repdigit while incrementing a counter. Return the counter.

Yes, those are three pluses in a row, two to increment the input, one to concatenate an empty string to make it a string.

No, I didn't think it would be legal without a space in between either, but there you go. That's what a typo will do for you: one byte shorter.

Using a for-loop instead of a while takes exactly as many bytes:

int c(int i){int n=0;for(;!(i+++"").matches("^(.)\\1*$");n++);return n;}

Edit:

An earlier version had matches("^(\\d)\\1*$") to check for a repdigit, but since we've just converted an int to a string, using a . to match is enough.

Ungolfed & test cases:

Try it here.

class Main{
  static int c(int i){
    int n=0;
    while(!(i++ + "").matches("^(.)\\1*$")) {
      n++;
    }
    return n;
  }

  public static void main(String[] a){
    System.out.println(c(8));
    System.out.println(c(100));
    System.out.println(c(113));
    System.out.println(c(87654321));
    System.out.println(c(42));
    System.out.println(c(20000));
    System.out.println(c(11132));
  }

}

Output:

0
11
109
1234567
2
2222
11090


问:
Print every character your program doesn't have
Your task is to build a program (using only printable ASCII characters and/or tabs and newlines) that prints out exactly the characters in the printable ASCII space (0x20 to 0x7e) that don't appear in your program's source code (in any order, however many times you want).

The shortest code to do this in any language wins.

Body:
Perl6, 66

(63..96)>>.chr.join.print #!"$%&/+-*:;<=0124578abdefghklmqsuvwxyz'


问:
Given a list of Tetris moves, return the number of completed lines

Description

We consider a slightly simplified version of Tetris where each move consists of:

rotating the piece clockwise, 0 to 3 times

positioning the piece at a given column

fast drop

The goal is to determine the number of completed lines, given a list of such Tetris moves.

Completed rows are removed as pieces are dropped, following standard Tetris rules.

Playfield

The playfield is 10-column wide. There's no Game Over and it is assumed that there's always enough space and time to perform the above actions, no matter the configuration of the playfield. The height of the playfield doesn't really matter here, but you can use the standard 22 rows as an upper limit.

Shapes of Tetrominoes

Input / Output

Input

A comma separated list of Tetris moves encoded with 3 characters. The first two character describe the Tetromino shape to use and the last one describes the position where it's dropped.

Tetromino: I, O, T, L, J, Z or S, in the same order as above.

Number of clockwise rotations: 0 to 3

Column: 0 to 9. This is the column in which the top-left corner of the piece (marked with an x on the above picture) is located after the rotation 1

It is assumed that all moves in the provided list are valid. There's no need to check for invalid entries such as I07 (horizontal I shape put too far on the right).

1 You are free to either implement a real rotation algorithm or to hardcode all the different shapes, as long as the x is located in the column given by the third character of the move.

Output

Number of completed lines.

Example

O00,T24 will generate the first position and O00,T24,S02,T01,L00,Z03,O07,L06,I05 will generate the second position.

Therefore, the following sequence will generate a Tetris and should return 4:

```<code>O00,T24,S02,T01,L00,Z03,O07,L06,I05,I19
</code>```

Test cases

```<code>1) "O00,T24,S02,T01,L00,Z03,O07,L06,I05,I19" -> 4
2) "S00,J03,L27,Z16,Z18,I10,T22,I01,I05,O01,L27,O05,S13" -> 5
3) "I01,T30,J18,L15,J37,I01,S15,L07,O03,O03,L00,Z00,T38,T01,S06,L18,L14" -> 4
4) "S14,T00,I13,I06,I05,I19,L20,J26,O07,Z14,Z10,Z12,O01,L27,L04,I03,S07,I01,T25,J23,J27,O01,
    I10,I10" -> 8
5) "O00,T24,L32,T16,L04,Z11,O06,L03,I18,J30,L23,Z07,I19,T05,T18,L30,I01,I01,I05,T02" -> 8
</code>```

Test page

You can use this JSFiddle to test a move list.

答:
PHP, <s>405</s> <s>399</s> <s>378</s> <s>372</s> <s>368</s> <s>360</s> <s>354</s> <s>347</s> <s>331</s> <s>330</s> <s>328</s> <s>319</s> <s>309</s> 300 bytes

(with Dave´s block mapping)

```<code><?$f=[~0];L:for($y=0;$f[++$d+$y]|$s;$s>>=4)$y-=1022<$f[$d+$y]=$f[$d]|$s%16<<$x;$c-=$y;if(list($p,$r,$x)=$argv[++$z])for($s=I==$p?$r&1?4369:15:hexdec(decoct(O==$p?27:ord(base64_decode('M1ozWjqaF1kemR6ZPJMPyTnSJ0s')[ord($p)/4%5*4+$r])));;$d--)for($y=4;$y--;)if ($f[$d+$y]>>$x&$s>>$y*4&15)goto L;echo$c;
</code>```

program, takes moves as separate arguments, prints result

breakdown to function:

takes moves as array, returns result

```<code>function t($a)
{
    $f=[~$z=0];             // init field $f (no need to init $z in golfed version)
    L:                      // jump label
                            // A: paint previous piece at line $d+1:
#   if($s)paint($f,$s,$d+1,$x);
    for($y=0;               // $y = working line offset and temporary score
        $f[++$d-$y]|$s;$s>>=4)// next field line; while field or piece have pixels ...
        $s>>=4)                 // next piece line
        $y+=1022<               // 3: decrease temp counter if updated line is full
            $f[$d-$y]=$f[$d]    // 2: use $y to copy over dropped lines
                |$s%16<<$x;     // 1: set pixels in working line
    $c+=$y;                         // add temp score to global score
#   paint($f);var_dump($c);
    if(list($p,$r,$x)=$a[$z++])// B: next piece: $p=name; $r=rotation, $x=column
#   {echo"<b>$z:$p$r-$x</b><br>";
        for(                // C: create base 16 value:
            $s=I==$p
                ? $r&1?4369:15  // I shape (rotated:0x1111, not rotated:0xf)
                : hexdec(decoct(    // 5: convert from base 8 to base 16
                    O==$p ? 27  // O shape (rotation irrelevant: 033)
                    : ord(          // 4: cast char to byte
                                    // 0: 4 bytes for each remaining tetromino
                        base64_decode('M1ozWjqaF1kemR6ZPJMPyTnSJ0s')[
                            ord($p)/4%5 // 1: map STZJL to 01234
                            *4      // 2: tetromino offset
                            +$r]    // 3: rotation offset
            )));;$d--
        )
            for($y=4;$y--;) // D: loop $y through piece lines
                if ($f[$d+$y]>>$x & $s>>$y*4 & 15) // if collision ...
                    goto L;         // goto Label: paint piece, tetris, next piece
#   }
    return$c;               // return score
}
</code>```

for reference: the old mapping

```<code>            hexdec(decoct(          // 3. map from base 8 to base 16
                                    // 0. dword values - from high to low: rotation 3,2,1,0
                [0x991e991e,0xc90f933c,0x4b27d239,0x1b1b1b1b,0,0x5a335a33,0x59179a3a]
                [ord($m[0])/2%9]    // 1. map ZJLO.ST to 0123.56 -> fetch wanted tetromino
                >>8*$m[1]&255       // 2. the $m[1]th byte -> rotated piece
            ))
</code>```

testing

see my other PHP answer

want to watch?

remove the # from the function source and add this:

```<code>function paint($f,$s=0,$d=0,$x=0){echo'```';for($y=count($f)+5;$y--;$g=0)if(($t=(($z=$y-$d)==$z&3)*($s>>4*$z&15)<<$x)|$r=$f[$y]|0){$z=$t?" $r|$t=<b".(1022<($z=$t|$r)?' style=color:green':'').">$z":" $r";for($b=1;$b<513;$b*=2)$z=($t&$b?''.($r&$b?2:1).'':($r&$b?1:'.')).$z;printf("%02d $z\n",$y);}echo'```';}
</code>```

some golfing steps

Rev. 5: A big leap (399-21=378) came by simply moving the column shift

from a separate loop to the two existing loops.

Rev. 8: Switching from array to base 16 for the piece ($s) did not give much,

but made way for some more golfing.

Rev. 17: crunched the values with base64_encode(pack('V*',<values>))

and used byte indexing instead of unpack to save 16 bytes

Rev. 25 to 29: inspired by Dave´s code: new hashing (-2), new loop design (-9), goto (-10)

no pre-shift though; that would cost 17 bytes.

more potential

With /2%9, I could save 15 bytes (only 14 bytes with /4%5)

by putting binary data into a file b and then indexing file(b)[0].

Do I want that?

UTF-8 characters would cost a lot for the transformation.

on the hashing

I used ZJLO.ST /2%9 -> 0123.56;
but T.ZJLOS /3%7 -> 0.23456 is as good.

one byte longer: O.STJLZ %13/2 -> 0.23456

and three more: OSTZJ.L %17%12%9 -> 01234.6

I could not find a short hash (max. 5 bytes) that leaves no gap;

but Dave found STZJL /4%5 -> 01234, dropping the O from the list. wtg!

btw: TIJSL.ZO (%12%8) -> 01234.67 leaves room for the I shape

(and a fictional A, M or Y shape). %28%8 and %84%8, do the same (but with E instead of A).

Body:
PHP, <s>405</s> <s>399</s> <s>378</s> <s>372</s> <s>368</s> <s>360</s> <s>354</s> <s>347</s> <s>331</s> <s>330</s> <s>328</s> <s>319</s> <s>309</s> 300 bytes

(with Dave´s block mapping)

<?$f=[~0];L:for($y=0;$f[++$d+$y]|$s;$s>>=4)$y-=1022<$f[$d+$y]=$f[$d]|$s%16<<$x;$c-=$y;if(list($p,$r,$x)=$argv[++$z])for($s=I==$p?$r&1?4369:15:hexdec(decoct(O==$p?27:ord(base64_decode('M1ozWjqaF1kemR6ZPJMPyTnSJ0s')[ord($p)/4%5*4+$r])));;$d--)for($y=4;$y--;)if ($f[$d+$y]>>$x&$s>>$y*4&15)goto L;echo$c;

program, takes moves as separate arguments, prints result

breakdown to function:

takes moves as array, returns result

function t($a)
{
    $f=[~$z=0];             // init field $f (no need to init $z in golfed version)
    L:                      // jump label
                            // A: paint previous piece at line $d+1:
#   if($s)paint($f,$s,$d+1,$x);
    for($y=0;               // $y = working line offset and temporary score
        $f[++$d-$y]|$s;$s>>=4)// next field line; while field or piece have pixels ...
        $s>>=4)                 // next piece line
        $y+=1022<               // 3: decrease temp counter if updated line is full
            $f[$d-$y]=$f[$d]    // 2: use $y to copy over dropped lines
                |$s%16<<$x;     // 1: set pixels in working line
    $c+=$y;                         // add temp score to global score
#   paint($f);var_dump($c);
    if(list($p,$r,$x)=$a[$z++])// B: next piece: $p=name; $r=rotation, $x=column
#   {echo"<b>$z:$p$r-$x</b><br>";
        for(                // C: create base 16 value:
            $s=I==$p
                ? $r&1?4369:15  // I shape (rotated:0x1111, not rotated:0xf)
                : hexdec(decoct(    // 5: convert from base 8 to base 16
                    O==$p ? 27  // O shape (rotation irrelevant: 033)
                    : ord(          // 4: cast char to byte
                                    // 0: 4 bytes for each remaining tetromino
                        base64_decode('M1ozWjqaF1kemR6ZPJMPyTnSJ0s')[
                            ord($p)/4%5 // 1: map STZJL to 01234
                            *4      // 2: tetromino offset
                            +$r]    // 3: rotation offset
            )));;$d--
        )
            for($y=4;$y--;) // D: loop $y through piece lines
                if ($f[$d+$y]>>$x & $s>>$y*4 & 15) // if collision ...
                    goto L;         // goto Label: paint piece, tetris, next piece
#   }
    return$c;               // return score
}

for reference: the old mapping

            hexdec(decoct(          // 3. map from base 8 to base 16
                                    // 0. dword values - from high to low: rotation 3,2,1,0
                [0x991e991e,0xc90f933c,0x4b27d239,0x1b1b1b1b,0,0x5a335a33,0x59179a3a]
                [ord($m[0])/2%9]    // 1. map ZJLO.ST to 0123.56 -> fetch wanted tetromino
                >>8*$m[1]&255       // 2. the $m[1]th byte -> rotated piece
            ))

testing

see my other PHP answer

want to watch?

remove the # from the function source and add this:

function paint($f,$s=0,$d=0,$x=0){echo'<pre>';for($y=count($f)+5;$y--;$g=0)if(($t=(($z=$y-$d)==$z&3)*($s>>4*$z&15)<<$x)|$r=$f[$y]|0){$z=$t?" $r|$t=<b".(1022<($z=$t|$r)?' style=color:green':'').">$z":" <b>$r";for($b=1;$b<513;$b*=2)$z=($t&$b?'<b>'.($r&$b?2:1).'</b>':($r&$b?1:'.')).$z;printf("%02d $z</b>\n",$y);}echo'</pre>';}

some golfing steps

Rev. 5: A big leap (399-21=378) came by simply moving the column shift

from a separate loop to the two existing loops.

Rev. 8: Switching from array to base 16 for the piece ($s) did not give much,

but made way for some more golfing.

Rev. 17: crunched the values with base64_encode(pack('V*',<values>))

and used byte indexing instead of unpack to save 16 bytes

Rev. 25 to 29: inspired by Dave´s code: new hashing (-2), new loop design (-9), goto (-10)

no pre-shift though; that would cost 17 bytes.

more potential

With /2%9, I could save 15 bytes (only 14 bytes with /4%5)

by putting binary data into a file b and then indexing file(b)[0].

Do I want that?

UTF-8 characters would cost a lot for the transformation.

on the hashing

I used ZJLO.ST /2%9 -> 0123.56;
but T.ZJLOS /3%7 -> 0.23456 is as good.

one byte longer: O.STJLZ %13/2 -> 0.23456

and three more: OSTZJ.L %17%12%9 -> 01234.6

I could not find a short hash (max. 5 bytes) that leaves no gap;

but Dave found STZJL /4%5 -> 01234, dropping the O from the list. wtg!

btw: TIJSL.ZO (%12%8) -> 01234.67 leaves room for the I shape

(and a fictional A, M or Y shape). %28%8 and %84%8, do the same (but with E instead of A).


答:
Perl 6 53 bytes

{$/=(&^b($^a,$^c),{[[&b]] .comb}...10>*);$/[*-1],+$/}
```

<p>Since <code>( 12, &[+], 123 )</code> is acceptable for the input, I can get it down to 53 bytes.<br>
( <code>&[+]</code> is short for <code>&infix:<+></code> which is a "reverence" to the numeric infix addition operator )</p>

<p>If the second argument had to be a string <code>(+)</code> it would be 87 bytes</p>

<pre class="lang-perl6 prettyprint-override"><code>{my&b=::("&infix:<$^b.substr(1,1)>");$/=(b($^a,$^c),{[[&b]] .comb}...10>*);$/[*-1],+$/}
</code>```

Explanation:

# bare block lambda with 3 parameters declared using placeholder syntax
{
  # store list into ｢$/｣
  # ( used ｢$/｣ so that I don't have to declare a variable )
  $/ = (

    # declare second placeholder parameter, and call it
    &^b(
      # with the first and third placeholder parameters
      $^a, $^c
    ),

    # bare block lambda with implicit parameter ｢$_｣
    {
      # list reduce using the second parameter from outer block
      [[&b]]

      # a list of the digits of ｢$_｣ (implicit method call)
      .comb
    }

    # keep doing that until
    ...

    # it produces something smaller than 10
    # ( Whatever lambda )
    10 > *
  );

  # returns

  # final result ( last value from list )
  $/[ * - 1 ],
  # and count of values in list
  +$/
}
```

<h2>Test:</h2>

<pre class="lang-perl6 prettyprint-override"><code>#! /usr/bin/env perl6
use v6.c;
use Test;

my &anastasiya-math = {$/=(&^b($^a,$^c),{[[&b]] .comb}...10>*);$/[*-1],+$/}

my @test = (
  (  81, &[+], 31    ) => (4, 2),
  ( 351, &[+], 14568 ) => (6, 3),
  (  21, &[*], 111   ) => (8, 3),
  ( 136, &[*], 2356  ) => (0, 2),
);

plan +@test;

for @test -> $_ ( :key(@input), :value(@expected) ) {
  cmp-ok anastasiya-math(|@input), &[»==«], @expected;
}
</code>```

Normal Usage:

# override built-in Bag operator ｢(+)｣ in current lexical scope
my &infix:<(+)> = &anastasiya-math.assuming: *, &[+], *;

# add a new operator
my &infix:<(*)> = &anastasiya-math.assuming: *, &[*], *;

say 12 (+) 123; # (9 2)
say 12 (*) 123; # (6 5)
```

Body:
Perl 6 53 bytes

{$/=(&^b($^a,$^c),{[[&b]] .comb}...10>*);$/[*-1],+$/}

Since ( 12, &[+], 123 ) is acceptable for the input, I can get it down to 53 bytes.

( &[+] is short for &infix:<+> which is a "reverence" to the numeric infix addition operator )

If the second argument had to be a string (+) it would be 87 bytes

{my&b=::("&infix:<$^b.substr(1,1)>");$/=(b($^a,$^c),{[[&b]] .comb}...10>*);$/[*-1],+$/}

Explanation:

# bare block lambda with 3 parameters declared using placeholder syntax
{
  # store list into ｢$/｣
  # ( used ｢$/｣ so that I don't have to declare a variable )
  $/ = (

    # declare second placeholder parameter, and call it
    &^b(
      # with the first and third placeholder parameters
      $^a, $^c
    ),

    # bare block lambda with implicit parameter ｢$_｣
    {
      # list reduce using the second parameter from outer block
      [[&b]]

      # a list of the digits of ｢$_｣ (implicit method call)
      .comb
    }

    # keep doing that until
    ...

    # it produces something smaller than 10
    # ( Whatever lambda )
    10 > *
  );

  # returns

  # final result ( last value from list )
  $/[ * - 1 ],
  # and count of values in list
  +$/
}

Test:

#! /usr/bin/env perl6
use v6.c;
use Test;

my &anastasiya-math = {$/=(&^b($^a,$^c),{[[&b]] .comb}...10>*);$/[*-1],+$/}

my @test = (
  (  81, &[+], 31    ) => (4, 2),
  ( 351, &[+], 14568 ) => (6, 3),
  (  21, &[*], 111   ) => (8, 3),
  ( 136, &[*], 2356  ) => (0, 2),
);

plan +@test;

for @test -> $_ ( :key(@input), :value(@expected) ) {
  cmp-ok anastasiya-math(|@input), &[»==«], @expected;
}

Normal Usage:

# override built-in Bag operator ｢(+)｣ in current lexical scope
my &infix:<(+)> = &anastasiya-math.assuming: *, &[+], *;

# add a new operator
my &infix:<(*)> = &anastasiya-math.assuming: *, &[*], *;

say 12 (+) 123; # (9 2)
say 12 (*) 123; # (6 5)


问:
Fibonacci + Fizz Buzz = Fibo Nacci!
Fibonacci + FizzBuzz = Fibo Nacci!

Your challenge is to create a Fibo Nacci program!

A Fibo Nacci program outputs the first 100 Fibonacci numbers (starting from 1).

If the Fibonacci number is divisible by both 2 and 3 (i.e. it is divisible by 6), then output FiboNacci instead of the number.

Otherwise, if the Fibonacci number is divisible by 2, then output Fibo instead of the number.

Otherwise, if the Fibonacci number is divisible by 3, then output Nacci instead of the number.

Rules

The program should take no input.

The program should output a new line (\n) after every entry.

The program should not print anything to STDERR.

The program must output the first 100 Fibo Nacci entries (starting from 1).

Standard loopholes are not allowed (by default).

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

Here is the expected output:

```<code>1
1
Fibo
Nacci
5
Fibo
13
Nacci
Fibo
55
89
FiboNacci
233
377
Fibo
Nacci
1597
Fibo
4181
Nacci
Fibo
17711
28657
FiboNacci
75025
121393
Fibo
Nacci
514229
Fibo
1346269
Nacci
Fibo
5702887
9227465
FiboNacci
24157817
39088169
Fibo
Nacci
165580141
Fibo
433494437
Nacci
Fibo
1836311903
2971215073
FiboNacci
7778742049
12586269025
Fibo
Nacci
53316291173
Fibo
139583862445
Nacci
Fibo
591286729879
956722026041
FiboNacci
2504730781961
4052739537881
Fibo
Nacci
17167680177565
Fibo
44945570212853
Nacci
Fibo
190392490709135
308061521170129
FiboNacci
806515533049393
1304969544928657
Fibo
Nacci
5527939700884757
Fibo
14472334024676221
Nacci
Fibo
61305790721611591
99194853094755497
FiboNacci
259695496911122585
420196140727489673
Fibo
Nacci
1779979416004714189
Fibo
4660046610375530309
Nacci
Fibo
19740274219868223167
31940434634990099905
FiboNacci
83621143489848422977
135301852344706746049
Fibo
Nacci
</code>```

The Catalogue

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

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

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

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

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

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

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

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

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

/* Configuration */

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

/* App */

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

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

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

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

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

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

    var lang = a.language;
    lang = jQuery(''+lang+'').text();

    languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;
    if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) return -1;
    return 0;
  });

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

Title: Fibonacci + Fizz Buzz = Fibo Nacci!

Body:
Perl6, <s>59</s> 58

say "Fibo"x$_%%2~"Nacci"x$_%%3||$_ for (1,1,*+*...*)[^100]


答:
Jelly, <s>11</s> 10 bytes

```<code>Dj⁹VµÐĿḊĖṪ
</code>```

Input is a pair of numbers and either + or ×.

Try it online! or verify all test cases.

How it works

```<code>Dj⁹VµÐĿḊĖṪ  Main link. Left argument: [x, y] (integers). Right argument: + or ×

    µÐĿ     Repeatedly execute the chain to the left, initially with argument
            [x, y], then with the previous return value. Stop when the results are
            no longer unique, and return the array of all intermediate results.
D           Decimal; convert the integers [x, y] or the return value z to base 10.
 j⁹         Join, separating by the link's right argument, i.e., '+' or '×'.
   V        Evaluate the result. This casts the previous return value to string,
            so, e.g., [8, 1, '+', 3, 1] becomes "81+31" before evaluation.
       Ḋ    Dequeue; discard the first intermediate result, i.e., [x, y].
        Ė   Enumerate; prefix each integer in the array with its 1-based index.
         Ṫ  Tail; extract the last index-value pair.
</code>```

Body:
Jelly, <s>11</s> 10 bytes

Dj⁹VµÐĿḊĖṪ

Input is a pair of numbers and either + or ×.

Try it online! or verify all test cases.

How it works

Dj⁹VµÐĿḊĖṪ  Main link. Left argument: [x, y] (integers). Right argument: + or ×

    µÐĿ     Repeatedly execute the chain to the left, initially with argument
            [x, y], then with the previous return value. Stop when the results are
            no longer unique, and return the array of all intermediate results.
D           Decimal; convert the integers [x, y] or the return value z to base 10.
 j⁹         Join, separating by the link's right argument, i.e., '+' or '×'.
   V        Evaluate the result. This casts the previous return value to string,
            so, e.g., [8, 1, '+', 3, 1] becomes "81+31" before evaluation.
       Ḋ    Dequeue; discard the first intermediate result, i.e., [x, y].
        Ė   Enumerate; prefix each integer in the array with its 1-based index.
         Ṫ  Tail; extract the last index-value pair.


答:
MIXAL - 101 bytes including tabs

Run on your MIX machine. Or assemble and run using the GNU MIX Development Kit (http://www.gnu.org/software/mdk/).

```<code>S       ENT2    2/2
        ST2     8
        ENT3    22*2-3-2-2
        ST3     P(8-3:8-3)
        ENT2    22-3
        ST2     P(8-2-2:8-2-2)
P       IN      8
        HLT
        END     S
</code>```

The biggest challenge is not being able to use OUT, the only output command, or 19, the number of the teletype output device. I get around the source restrictions by creating forbidden numbers using MIX assembler arithmetic, and by using MIX's self-modifying code features.

Enter the number 1 into index register 2 (assembler turns 2/2 into 1)

Store the contents of index register 2 at memory address 8, later to be sent to the output device

Enter the number 37 into index register 3 using assembler arithmetic. 37 is the operation code OUT, which we need but can't use because it has a U.

Store the contents of index register 3 (=37) in the opcode field (5:5) of the instruction already stored at address 'P' as part of the program (in other words, change IN to OUT)

Enter the number 19 into index register 2. The teletype output device is no. 19.

Store the contents of index register 2 (=19) in the field-specification field (4:4) of the instruction at address 'P' (change 0 to 19 to specify the teletype device as output).

Instruction 'P': We have now rewritten this line as P     OUT    8(19). So, send the contents stored at address 8 (= 1 = character code for 'A') to the teletype device for output.

Stop the machine.

Title: The Letter A without A

Body:
Your task is to display the letter "A" alone, without anything else, except any form of trailing newlines if you cannot avoid them, doing so in a program and/or snippet. Code that returns (instead of printing) is allowed.

Both the lowercase and uppercase versions of the letter "A" are acceptable (that is, unicode U+0061 or unicode U+0041. Other character encodings that aren't Unicode are allowed, but either way, the resulting output of your code must be the latin letter "A", and not any lookalikes or homoglyphs)

You must not use any of the below characters in your code, regardless of the character encoding that you pick:

"A", whether uppercase or lowercase.

"U", whether lowercase or uppercase.

X, whether uppercase or lowercase.

+

&

#

0

1

4

5

6

7

9

Cheating, loopholes, etc, are not allowed.

Since this is code-golf, the shortest solution, in bytes, that follows all the rules, is the winner.

Validity Checker

This Stack Snippet checks to make sure your code doesn't use the restricted characters. It might not work properly for some character encodings.

var t = prompt("Input your code.");

if (/[AaUuXx+&#0145679]/.test(t)) {
  alert("Contains a disallowed character!");
} else {
  alert("No disallowed characters");
}```
</div>
</div>
</p>

<p><em>This Stack Snippet that makes sure you don't have a disallowed character is also available on JSFiddle.</em></p>

<h3>Leaderboard</h3>

<p><div class="snippet" data-lang="js" data-hide="true" data-console="false" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var QUESTION_ID=90349,OVERRIDE_USER=58717;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="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});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;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>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;</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}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td>Link</td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td>Link</td></tr></tbody> </table></code>```

Body:
MIXAL - 101 bytes including tabs

Run on your MIX machine. Or assemble and run using the GNU MIX Development Kit (http://www.gnu.org/software/mdk/).

S       ENT2    2/2
        ST2     8
        ENT3    22*2-3-2-2
        ST3     P(8-3:8-3)
        ENT2    22-3
        ST2     P(8-2-2:8-2-2)
P       IN      8
        HLT
        END     S

The biggest challenge is not being able to use OUT, the only output command, or 19, the number of the teletype output device. I get around the source restrictions by creating forbidden numbers using MIX assembler arithmetic, and by using MIX's self-modifying code features.

Enter the number 1 into index register 2 (assembler turns 2/2 into 1)

Store the contents of index register 2 at memory address 8, later to be sent to the output device

Enter the number 37 into index register 3 using assembler arithmetic. 37 is the operation code OUT, which we need but can't use because it has a U.

Store the contents of index register 3 (=37) in the opcode field (5:5) of the instruction already stored at address 'P' as part of the program (in other words, change IN to OUT)

Enter the number 19 into index register 2. The teletype output device is no. 19.

Store the contents of index register 2 (=19) in the field-specification field (4:4) of the instruction at address 'P' (change 0 to 19 to specify the teletype device as output).

Instruction 'P': We have now rewritten this line as P     OUT    8(19). So, send the contents stored at address 8 (= 1 = character code for 'A') to the teletype device for output.

Stop the machine.


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

答:
JavaScript, 103 101 99 97 93 90

This implementation is based on primo's comprehensive description of the algorithm he used.

```<code>for(e=l=x=prompt(g=1e5);--g;y=x-1,l=(x>1?y/=x:-y)*l+y/g)
    e=1+e/g*x;
alert([e,x>0?l:"ERROR"])
</code>```

Edit:

- Trying to catch Perl. Stole a byte back from primo by copying his branch. :)

- 2 more bytes courtesy of primo.

- Finally, caught primo's version! With primo's help, of course... :)

- Simplified the assignment to L. Shaved 3 more bytes.

Title: Calculate e^x and ln(x)

Body:
JavaScript, 103 101 99 97 93 90

This implementation is based on primo's comprehensive description of the algorithm he used.

for(e=l=x=prompt(g=1e5);--g;y=x-1,l=(x>1?y/=x:-y)*l+y/g)
    e=1+e/g*x;
alert([e,x>0?l:"ERROR"])

Edit:

- Trying to catch Perl. Stole a byte back from primo by copying his branch. :)

- 2 more bytes courtesy of primo.

- Finally, caught primo's version! With primo's help, of course... :)

- Simplified the assignment to L. Shaved 3 more bytes.