答:
Ruby - 70 bytes

```<code>λ cat inf.rb
n,=$*[0].unpack 'B*';loop{p n.to_i(2);n.tr!('10','01').sub!(/^0*/,'')}
λ ruby inf.rb Hello
310939249775
788572378000
310939249775
238816564112
36061342831
32658133904
1701604463
445879184
90991727
43226000
23882863
9671568
7105647
1282960
814191
234384
27759
5008
3183
912
111
16
15
0
inf.rb:1:in `block in <main>': undefined method `sub!' for nil:NilClass (NoMethodError)
        from inf.rb:1:in `loop'
        from inf.rb:1:in `<main>'
</code>```

The program exits with an exception after completing, but my understanding is that that is fine as long as the error output goes to STDERR rather than STDOUT (which it does).

Title: Count down from "Infinity"

Body:
Seems like an impossible task right? Well, it's actually not that hard. If we write the word Infinity as 8-bit binary ASCII code, we'll get:

```<code>01001001 01101110 01100110 01101001 01101110 01101001 01110100 01111001
</code>```

This can be concatenated, and converted to the decimal value 5291279215216915577. Now that's a number we can work with...

The way you'll count down is:

Output the original string as a decimal number (as shown above)

Remove leading 0s in its binary representation (if any)

Toggle the bits in the binary representation (1->0, 0->1)

Output the number in decimal

Repeat steps 2-4 as until you reach 0.

Challenge:

Create a program or function that takes a string as input, and outputs (on any suitable format) the numbers you'll get when performing the procedure above.

Test case:

I think the challenge will be fairly easy to understand, even though it's only one test case. I'll use Inf instead of Infinity to keep this fairly short.

```<code>Inf
4812390  (10010010110111001100110)
3576217  ( 1101101001000110011001)
618086   (   10010110111001100110)
430489   (    1101001000110011001)
93798    (      10110111001100110)
37273    (       1001000110011001)
28262    (        110111001100110)
4505     (          1000110011001)
3686     (           111001100110)
409      (              110011001)
102      (                1100110)
25       (                  11001)
6        (                    110)
1        (                      1)
0        (                      0)
</code>```

```<code>Input: Inf
Output:
4812390, 3576217, 618086, 430489, 93798, 37273, 28262, 4505, 3686, 409, 102, 25, 6, 1, 0
</code>```

```<code>Input: Infinity
Output:
5291279215216915577, 3932092821637860230, 679593196789527673, 473328307817319302, 103132444486104185, 40982743589751686, 31074850448176249, 4953946570787718, 4053252683953273, 450346943417222, 112603010004089, 28134478351238, 7049893737593, 1746199284614, 452823970937, 96931842950, 40507110521, 28212366214, 6147372153, 2442562438, 1852404857, 295078790, 241792121, 26643334, 6911097, 1477510, 619641, 428934, 95353, 35718, 29817, 2950, 1145, 902, 121, 6, 1, 0
</code>```

Your code must support strings that can be represented as a binary number up to the limit of your language. All strings will only contain printable ASCII-characters from 32-126 (space to tilde).

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Ruby - 70 bytes

λ cat inf.rb
n,=$*[0].unpack 'B*';loop{p n.to_i(2);n.tr!('10','01').sub!(/^0*/,'')}
λ ruby inf.rb Hello
310939249775
788572378000
310939249775
238816564112
36061342831
32658133904
1701604463
445879184
90991727
43226000
23882863
9671568
7105647
1282960
814191
234384
27759
5008
3183
912
111
16
15
0
inf.rb:1:in `block in <main>': undefined method `sub!' for nil:NilClass (NoMethodError)
        from inf.rb:1:in `loop'
        from inf.rb:1:in `<main>'

The program exits with an exception after completing, but my understanding is that that is fine as long as the error output goes to STDERR rather than STDOUT (which it does).


问:
Print a letter Fibonacci
Given N (2 <= N), print N lines of the letter Fibonacci series like this (i.e. N = 5)
First, start with a and b:

```<code>a
b
</code>```

Next, add the two lines.

```<code>a
b
ab
</code>```

Keep adding the last two lines.

```<code>a
b
ab
bab
</code>```

Keep going...

```<code>a
b
ab
bab
abbab
</code>```

And we're done.

Remember, this is code-golf, so the code with the fewest bytes wins.

答:
Java 7, 69 bytes

String c(int n,String a,String b){return n--<1?"":a+"\n"+c(n,b,a+b);}
```
<h3>ungolfed</h3>
  <pre class="lang-java prettyprint-override"><code> class fibb {

public static void main(String[] args) {
    System.out.println( c( 7, "a" , "b" ) );

}
static String c(int n,String a,String b) {

    return n-- < 1  ? "" : a + "\n" + c(n,b,a + b);

}
}
</code>```

ContentLicense: CC BY-SA 4.0

Title: Print a letter Fibonacci

Body:
Java 7, 69 bytes

String c(int n,String a,String b){return n--<1?"":a+"\n"+c(n,b,a+b);}

ungolfed

 class fibb {

public static void main(String[] args) {
    System.out.println( c( 7, "a" , "b" ) );

}
static String c(int n,String a,String b) {

    return n-- < 1  ? "" : a + "\n" + c(n,b,a + b);

}
}

ContentLicense: CC BY-SA 3.0


答:
Mathematica, 49 bytes

```<code>f@1="a";f@2="b";f@n_:=f[n-2]<>f[n-1];g=f~Array~#&
</code>```

Defines a function g taking the single numerical input; returns a list of strings. Straightforward recursive implementation, using the string-joining operator <>.

Mathematica, 56 bytes

```<code>NestList[#~StringReplace~{"a"->"b","b"->"ab"}&,"a",#-1]&
</code>```

Unnamed function, same input/output format as above. This solution uses an alternate way to generate the strings: each string in the list is the result of simultaneously replacing, in the previous string, all occurrences of "a" with "b" and all occurrences of "b" with "ab".

Title: Print a letter Fibonacci

Body:
Given N (2 <= N), print N lines of the letter Fibonacci series like this (i.e. N = 5)
First, start with a and b:

```<code>a
b
</code>```

Next, add the two lines.

```<code>a
b
ab
</code>```

Keep adding the last two lines.

```<code>a
b
ab
bab
</code>```

Keep going...

```<code>a
b
ab
bab
abbab
</code>```

And we're done.

Remember, this is code-golf, so the code with the fewest bytes wins.

Body:
Mathematica, 49 bytes

f@1="a";f@2="b";f@n_:=f[n-2]<>f[n-1];g=f~Array~#&

Defines a function g taking the single numerical input; returns a list of strings. Straightforward recursive implementation, using the string-joining operator <>.

Mathematica, 56 bytes

NestList[#~StringReplace~{"a"->"b","b"->"ab"}&,"a",#-1]&

Unnamed function, same input/output format as above. This solution uses an alternate way to generate the strings: each string in the list is the result of simultaneously replacing, in the previous string, all occurrences of "a" with "b" and all occurrences of "b" with "ab".


答:
Perl, 48 bytes

47 bytes code + 1 for -n.

Simple approach. Try using an array slice originally $a[@a]="@a[-2,-1]" but that necessitates $"="" or similar :(. Save 1 byte thanks to @Dada!

@;=(a,b);$;[@;]=$;[-2].$;[-1]for 3..$_;say for@
```

<h3>Usage</h3>

<pre class="lang-sh prettyprint-override"><code>perl -nE '@;=(a,b);$;[@;]=$;[-2].$;[-1]for 3..$_;say for@' <<< 5
a
b
ab
bab
abbab
</code>```

Title: Print a letter Fibonacci

Body:
Perl, 48 bytes

47 bytes code + 1 for -n.

Simple approach. Try using an array slice originally $a[@a]="@a[-2,-1]" but that necessitates $"="" or similar :(. Save 1 byte thanks to @Dada!

@;=(a,b);$;[@;]=$;[-2].$;[-1]for 3..$_;say for@

Usage

perl -nE '@;=(a,b);$;[@;]=$;[-2].$;[-1]for 3..$_;say for@' <<< 5
a
b
ab
bab
abbab


答:
Retina, 33 bytes

```<code>.+
$*
^11
a¶b
+`¶(.+?)1
¶$1¶$%`$1
</code>```

Try it online!

Saved 10 (!) bytes thanks to @MartinEnder!

Explanation

Converts the input to unary, subtracts 2 and adds the a and the b, then recursively replaces the remaining 1s with the concatenation of the two previous strings.

Title: Print a letter Fibonacci

Body:
Retina, 33 bytes

.+
$*
^11
a¶b
+`¶(.+?)1
¶$1¶$%`$1

Try it online!

Saved 10 (!) bytes thanks to @MartinEnder!

Explanation

Converts the input to unary, subtracts 2 and adds the a and the b, then recursively replaces the remaining 1s with the concatenation of the two previous strings.


问:
How many integers contain a number in a specific range
The program should take input the number, the start of the range and the end of the range, and output how many integers the number appears between the start and end of the range, inclusive. Both programs and functions are allowed.

Example Inputs

For example:

```<code>//Input example 1
3,1,100
//Input example 2
3
1
100
//Input example 3
3 1 100
//Input example 4
a(3, 1, 100);
</code>```

All the above four input examples are valid and all of them mean that 3 is the number in question, 1 is the beginning of the range and 100 the the end of the range.

And then the program should output how many times 3 appears in the range from 1 to 100 inclusive. 3 appears in the integers 3, 13, 23, 30, 31, 32, 33, ..., 93 at a total of 19 times. So the program should output 19 as the output because that is how many times 3 appears in the range from 1 to 100.

Rules

Both programs and functions are allowed.

All numbers will be integers, meaning that there will not be any floats or doubles.

Note: the sought number will always be in the range 0≤x≤127. There will be no cases where it will be outside this 0≤x≤127 range.

As in the first example, with the case as 33, the number 3 will be counted as appearing only once, not twice.

The values of the start and end of the range will be between -65536 and 65535 inclusive.

The value of range's start will never exceed or equal to range's end. start < end

Also the range is inclusive. For example if the input was 8 8 10, the range would be 8≤x≤10 and hence the output will be 1.

Input can be taken in any of the ways shown in the examples. Input can be taken as a string or as a number, any way you wish.

Test Cases

```<code>3 1 100
19

3 3 93
19

12,-200,200
24          //This is because 12 appears in -129, -128, ..., -112, -12, 12, 112, 120, 121, 122, ...

123,1,3
0           //This is because all of 123's digits have to appear in the same order

3 33 34
2           //Because 3 appears in 2 numbers: 33 and 34

a(0,-1,1);
1

$ java NotVerbose 127 -12 27
0
</code>```

Snack Snippet

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

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

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

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

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

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

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

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

/* Configuration */

var QUESTION_ID = 98470; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 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 "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

  });

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
PHP, 62 bytes

Pretty straight forward approach:

```<code><?=count(preg_grep('/'.($a=$argv)[1].'/',range($a[2],$a[3])));
</code>```

Try it online

Body:
PHP, 62 bytes

Pretty straight forward approach:

<?=count(preg_grep('/'.($a=$argv)[1].'/',range($a[2],$a[3])));

Try it online


答:
PHP, <s>63</s> 62 bytes

Recursive version:

```<code>function f($n,$a=a,$b=b){return$n--?"$a
".f($n,$b,$a.$b):'';}
</code>```

Title: Print a letter Fibonacci

Body:
PHP, <s>63</s> 62 bytes

Recursive version:

function f($n,$a=a,$b=b){return$n--?"$a
".f($n,$b,$a.$b):'';}


答:
PHP, <s>61</s> 57 bytes

```<code><?=$c=a;for($b=b;--$argv[1];$b=$c.$b,$c=$a)echo"
",$a=$b;
</code>```

<s>come php 7.1 you can save 3 bytes by changing to:</s> an "old" version that I wish was short:

```<code><?=$a=a;for($b=b;--$argv[1];[$a,$b]=[$b,$a.$b])echo"
$b";
</code>```

If a trailing new line is acceptable then:

```<code>for($b=b;$argv[1]--;$a=$b,$b=$c.$b)echo$c=$a?:a,"
";
</code>```

is only 52 bytes.

edit: 4 bytes saved (on both usable versions) thanks to Titus.

Title: Print a letter Fibonacci

Body:
PHP, <s>61</s> 57 bytes

<?=$c=a;for($b=b;--$argv[1];$b=$c.$b,$c=$a)echo"
",$a=$b;

<s>come php 7.1 you can save 3 bytes by changing to:</s> an "old" version that I wish was short:

<?=$a=a;for($b=b;--$argv[1];[$a,$b]=[$b,$a.$b])echo"
$b";

If a trailing new line is acceptable then:

for($b=b;$argv[1]--;$a=$b,$b=$c.$b)echo$c=$a?:a,"
";

is only 52 bytes.

edit: 4 bytes saved (on both usable versions) thanks to Titus.


问:
Finding prime numbers without using "prime characters"
Your task, if you choose to accept it, is to write a program/function that accepts an integer \$N\$ as input. The program/function should output/return a list of the first \$N\$ prime numbers. But here's the catch: you are not allowed to use prime characters in your code. A prime character is a character whose Unicode code point is a prime number. In the printable ASCII range, these are:

```<code>%)+/5;=CGIOSYaegkmq
</code>```

But the rule also applies to non-ASCII characters if your code uses those.

A valid input is an integer \$N\$ where \$0 < N \le T\$, where you can choose \$T\$, but it has to be greater than or equal to \$10000\$. \$T\$ does not have to be finite.

For invalid inputs (non-integers, integers out of range), throw an exception or output/return nothing/null.

An integer with leading/trailing whitespace as input is considered invalid.

An integer with a + as sign character as input is considered invalid.

An integer with leading zeros as input is considered valid.

If your language allows you to pass an already-parsed integer as input, the above parsing rules (except the range one) don't apply, because the int is already parsed.

The input is always base-10.

Use of built-in prime generators and primality testers (this includes prime factorization functions) is not allowed.

The source restriction is imposed on Unicode characters, but the byte counting for the score can be in another encoding if you wish.

The output can contain a single trailing newline, but this is not required.

If you output/return the prime number list as a string, then every prime number must be delimited by one or multiple non-digit char(s). You can choose which delimiter you use.

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

Stack Snippet to verify your code

You can use the below Stack Snippet to verify that your code does not contain prime chars:

var primes=[],max=10000;for(var i=2;i<=max;i++){primes.push(i);}for(var N=2;N<Math.sqrt(max);N++){if(primes.indexOf(N)===-1){continue;}primes=primes.filter(function (x){return x===N||x%N!==0;});}function setText(elem,text){var z=('innerText' in elem)? 'innerText' : 'textContent';elem[z]=text;}function verify(inputCode,resultSpan){var invalidChars=[];var success=true;for(var i=0;i<inputCode.length;i++){var cc = inputCode.charCodeAt(i);if (cc>max){setText(resultSpan,"Uh oh! The char code was bigger than the max. prime number calculated by the snippet.");success = false;break;}if (primes.indexOf(cc)!==-1){invalidChars.push(inputCode[i]);}}if (invalidChars.length===0&&success){setText(resultSpan, "Valid code!");}else if(success) {  var uniqueInvalidChars = invalidChars.filter(function (x, i, self){return self.indexOf(x)===i;});setText(resultSpan, "Invalid code! Invalid chars: " + uniqueInvalidChars.join(""));    }}document.getElementById("verifyBtn").onclick=function(e){e=e||window.event;e.preventDefault();var code=document.getElementById("codeTxt").value;verify(code,document.getElementById("result"));};```
<pre class="snippet-code-html lang-html prettyprint-override"><code>Enter your code snippet here:<br /><textarea id="codeTxt" rows="5" cols="70"></textarea><br /><button id="verifyBtn">Verify</button><br /><span id="result"></span></code>```

答:
Rust, 64897 bytes

|n|println!{"{:?}",&[2,3,6-1,7,11,13,17,19,23,29,31,37,41,43,47,60-7,0x3b,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,0x97,0x9d,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,0xfb,0x101 ...}
```

(code snipped due to character limit, full solution here)

The following rust features become unavailable due to the prime restriction:

function calls, as they require ')'

regular bindings, since they require let (e)

macro definitions, they require macro-rules! (a,e,m)

match statements, they require match (a,m) and => (=)

mutability, since it's always introduced with the mut keyword (m).

return (e), break (a,e), continue (e)

else (e)

What you can technically use:

if. But without else, they're useless in expression contexts, so only good for side effects.

macros. Standard macros like print! are usually followed by (), but it's actually legal to use {} or [] instead. Without this, the task would be impossible.

closures, in the most narrow sense. You can't call them (requires ()) or bind them(requires let), but you can define a single non-recursive one. Without this, the task would obviously become impossible.

structs.

for loops. These are promising, since they actually allow variable binding, and they take an iterator, which can still be defined with the range syntax. The iterator can even be an expression.

Builtin operators, except +, % and /. The short-circuiting logical operators seem promising.

I simply couldn't make anything Turing-complete with these tools. I'm sorry. All that was left was to include the full first 10000 primes, cleaned of 5's. At least you can slice it and have a valid solution, in the most narrow sense possible.

I very much would like experts on Turing tarpit diving (or on Rust!) to tell me if I could have done anything better!

Body:
Rust, 64897 bytes

|n|println!{"{:?}",&[2,3,6-1,7,11,13,17,19,23,29,31,37,41,43,47,60-7,0x3b,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,0x97,0x9d,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,0xfb,0x101 ...}

(code snipped due to character limit, full solution here)

The following rust features become unavailable due to the prime restriction:

function calls, as they require ')'

regular bindings, since they require let (e)

macro definitions, they require macro-rules! (a,e,m)

match statements, they require match (a,m) and => (=)

mutability, since it's always introduced with the mut keyword (m).

return (e), break (a,e), continue (e)

else (e)

What you can technically use:

if. But without else, they're useless in expression contexts, so only good for side effects.

macros. Standard macros like print! are usually followed by (), but it's actually legal to use {} or [] instead. Without this, the task would be impossible.

closures, in the most narrow sense. You can't call them (requires ()) or bind them(requires let), but you can define a single non-recursive one. Without this, the task would obviously become impossible.

structs.

for loops. These are promising, since they actually allow variable binding, and they take an iterator, which can still be defined with the range syntax. The iterator can even be an expression.

Builtin operators, except +, % and /. The short-circuiting logical operators seem promising.

I simply couldn't make anything Turing-complete with these tools. I'm sorry. All that was left was to include the full first 10000 primes, cleaned of 5's. At least you can slice it and have a valid solution, in the most narrow sense possible.

I very much would like experts on Turing tarpit diving (or on Rust!) to tell me if I could have done anything better!


Title: Bailey–Borwein–Plouffe Iterations

Body:
Bailey–Borwein–Plouffe Iterations

We've seen a few pi challenges on PPCG, but none that specifically dictate the algorithm you should be using. I'd like to see implementations of the Bailey–Borwein–Plouffe algorithm in any language up to iteration n. The formula is as follows:

Your algorithm should output each iteration up to n, showing intermediate sums as well as the final result to form a "piangle". You may also use the reduced polynomial form of the algorithm shown on the wikipedia page. An example run for n=50 is shown below:

```<code>3
3.1
3.14
3.141
3.1415
3.14159
3.141592
3.1415926
3.14159265
3.141592653
3.1415926535
3.14159265358
3.141592653589
3.1415926535897
3.14159265358979
3.141592653589793
3.1415926535897932
3.14159265358979323
3.141592653589793238
3.1415926535897932384
3.14159265358979323846
3.141592653589793238462
3.1415926535897932384626
3.14159265358979323846264
3.141592653589793238462643
3.1415926535897932384626433
3.14159265358979323846264338
3.141592653589793238462643383
3.1415926535897932384626433832
3.14159265358979323846264338327
3.141592653589793238462643383279
3.1415926535897932384626433832795
3.14159265358979323846264338327950
3.141592653589793238462643383279502
3.1415926535897932384626433832795028
3.14159265358979323846264338327950288
3.141592653589793238462643383279502884
3.1415926535897932384626433832795028841
3.14159265358979323846264338327950288419
3.141592653589793238462643383279502884197
3.1415926535897932384626433832795028841971
3.14159265358979323846264338327950288419716
3.141592653589793238462643383279502884197169
3.1415926535897932384626433832795028841971693
3.14159265358979323846264338327950288419716939
3.141592653589793238462643383279502884197169399
3.1415926535897932384626433832795028841971693993
3.14159265358979323846264338327950288419716939937
3.141592653589793238462643383279502884197169399375
3.1415926535897932384626433832795028841971693993751
3.14159265358979323846264338327950288419716939937510
</code>```

The precision of each iteration should equal the n that is passed to the algorithm, that is to say that each iteration should calculate pi up to the passed n for all k.

Rules:

Built-ins are not allowed, nor is pi, you must use the formula.

You must support n up to a maximum that your language allows in terms of the calculation of 16^n. If the input is causing an arithmetic overflow during calculation after x<n executions because your language only supports decimals up to 2^32-1, this is fine. Any other assumptions on n are not fine.

You MUST provide an explanation of how you got the output if it is not obvious. For instance, if you're posting in a Golfing language a break-down is 100% required. This is to ensure you're using the algorithm that is specified.

Standard loop-holes are disallowed.

This is code-golf, lowest byte count wins here.

Reference Code (Code used to Generate Example):

```<code>public static void main(String[] args) {
    (0..50).each {
        n->
        def x=(0..n).collect {
            j->
            def k=new BigDecimal(j)
            def s={it.setScale(n)}
            def a=s(1.0g).divide(s(16.0g)**s(k))
            def b=s(4.0g)/(s(8.0g)*s(k)+s(1.0g))
            def c=s(2.0g)/(s(8.0g)*s(k)+s(4.0g))
            def d=s(1.0g)/(s(8.0g)*s(k)+s(5.0g))
            def e=s(1.0g)/(s(8.0g)*s(k)+s(6.0g))
            def f=a*(b-c-d-e)
        }.sum()
        println(n + "\t" + x.setScale(n, BigDecimal.ROUND_DOWN))
    }
}
</code>```

This implementation caps out at n=255, you may cap out at less or more.

This implementation was done in Groovy.

Body:
C#, 183 bytes

Golfed:

void F(int n){double s=0;for(int k=0;k<=n;k++){s+=1/Math.Pow(16,k)*(4.0/(8*k+1)-2.0/(8*k+4)-1.0/(8*k+5)-1.0/(8*k+6));double p=Math.Pow(10,k);Console.WriteLine(Math.Truncate(s*p)/p);}}

Ungolfed:

void F(int n)
{
    double s = 0;

    for (int k = 0; k <= n; k++)
    {
        s += 1/Math.Pow(16, k)*(4.0/(8*k + 1) - 2.0/(8*k + 4) - 1.0/(8*k + 5) - 1.0/(8*k + 6));
        double p = Math.Pow(10, k);

        Console.WriteLine(Math.Truncate(s*p)/p);
    }
}


问:
Count without 3

Background

When I was in elementary school, we used to play a game in math class that goes as follows.

All kids sit in a big circle and take turns counting, starting from 1.

However, the following numbers must be skipped while counting:

Numbers that are multiples of 3.

Numbers that have a 3 in its decimal representation.

The first 15 numbers the kids should say are

```<code>1 2 4 5 7 8 10 11 14 16 17 19 20 22 25
</code>```

Whenever somebody gets a number wrong – says a number that isn't in the sequence or skips a number that is – he's removed from the circle. This goes on until there's only one kid left.

Task

You're bad at this game, so you decide to cheat. Write a program or a function that, given a number of the sequence, calculates the next number of the sequence.

You don't have to handle numbers that cannot be represented using your language's native numeric type, provided that your program works correctly up to input 251 and that your algorithm works for arbitrarily large inputs.

Input and output can use any convenient base.

Since you have to conceal your code, it must be as short as possible. In fact, this is code-golf, so the shortest code in bytes wins.

Test cases

```<code>  1 ->   2
  2 ->   4
 11 ->  14
 22 ->  25
 29 ->  40
251 -> 254
</code>```

Title: Count without 3

Body:
Perl, 19 bytes

18 bytes code + 1 for -p.

++$_%3&&!/3/||redo

Usage

perl -pe '++$_%3&&!/3/||redo' <<< 8
10

perl -pe '++$_%3&&!/3/||redo' <<< 11
14


答:
Emacs, <s>26</s>, 25-ish keystrokes

Program

#n to be read as key with digit(s) n:

ARETBRETF3UPUPC-SPACEC-EM-WDOWNDOWNC-Y
UPC-AC-SPACEC-EM-WDOWNC-EC-YRETF4C-#(n-2)F4

Explanation

```<code>command(s)               explanation                      buffer reads (| = cursor aka point)
-----------------------------------------------------------------------------------------------
A<RET> B<RET>            input starting points            "a\nb\n|"
<F3>                     start new macro                  "a\nb\n|"
<UP><UP>                 move point two lines up          "|a\nb\n"
C-<SPACE> C-E M-W        copy line at point               "a|\nb\n"
<DOWN><DOWN>             move point two lines down        "a\nb\n|"
C-Y                      yank (paste)                     "a\nb\na|"
<UP>                     move point one line up           "a\nb|\na"
C-A C-<SPACE> C-E M-W    copy line at point               "a\nb|\na"
<DOWN>                   move point one line down         "a\nb|\na|"
C-E C-Y <RET>            yank (paste) and add new line    "a\nb|\nab\n|"
<F4>                     stop macro recording             "a\nb|\nab\n|"
C-#(n-3) <F4>            apply macro n-3 times            "a\nb|\nab\nbab\nabbab\n|"
</code>```

With n=10

```<code>a
b
ab
bab
abbab
bababbab
abbabbababbab
bababbababbabbababbab
abbabbababbabbababbababbabbababbab
bababbababbabbababbababbabbababbabbababbababbabbababbab
</code>```

Title: Print a letter Fibonacci

Body:
Emacs, <s>26</s>, 25-ish keystrokes

Program

#n to be read as key with digit(s) n:

ARETBRETF3UPUPC-SPACEC-EM-WDOWNDOWNC-Y
UPC-AC-SPACEC-EM-WDOWNC-EC-YRETF4C-#(n-2)F4

Explanation

command(s)               explanation                      buffer reads (| = cursor aka point)
-----------------------------------------------------------------------------------------------
A<RET> B<RET>            input starting points            "a\nb\n|"
<F3>                     start new macro                  "a\nb\n|"
<UP><UP>                 move point two lines up          "|a\nb\n"
C-<SPACE> C-E M-W        copy line at point               "a|\nb\n"
<DOWN><DOWN>             move point two lines down        "a\nb\n|"
C-Y                      yank (paste)                     "a\nb\na|"
<UP>                     move point one line up           "a\nb|\na"
C-A C-<SPACE> C-E M-W    copy line at point               "a\nb|\na"
<DOWN>                   move point one line down         "a\nb|\na|"
C-E C-Y <RET>            yank (paste) and add new line    "a\nb|\nab\n|"
<F4>                     stop macro recording             "a\nb|\nab\n|"
C-#(n-3) <F4>            apply macro n-3 times            "a\nb|\nab\nbab\nabbab\n|"

With n=10

a
b
ab
bab
abbab
bababbab
abbabbababbab
bababbababbabbababbab
abbabbababbabbababbababbabbababbab
bababbababbabbababbababbabbababbabbababbababbabbababbab


问:
Self-compiling compiler
This is based on a talk on compilers I listened to a while back, but I, unfortunately, can't remember when or where.

Create the shortest compiler in any language that can compile itself.  Target any reasonable ISA (68K, x86, MIPS, ARM, SPARC, IBM BAL, etc.) that doesn't have a "compile-program" instruction (this may exclude some versions of VAX).  Read source programs from stdin and print generated code to stdout.  You may use the standard C library for I/O and string processing (e.g., _printf).  You don't need to compile the whole language, just any subset that contains the compiler (i.e., just printing an assembly language quine, while impressive, does not count as a solution.)

答:
05AB1E, 2 bytes (possibly non-competing)

```<code>.V
</code>```

Try it online!

Code on the first line of input, inputs on subsequent lines.

Title: Self-compiling compiler

Body:
05AB1E, 2 bytes (possibly non-competing)

.V

Try it online!

Code on the first line of input, inputs on subsequent lines.


Title: Print a letter Fibonacci

Body:
Groovy, 79 Bytes

{println("a\nb");x=['a','b'];(it-2).times{println(y=x.sum());x[0]=x[1];x[1]=y}}


答:
CJam, 19 bytes

```<code>ri{)__3%!\`'3e=e|}g
</code>```

ONLINE

Explanation:

```<code>ri{)__3%!\`'3e=e|}g
r                   Get token
 i                  Convert to integer
  {              }  Block
   )                 Increment
    _                Duplicate
     _               Duplicate
      3              Push 3
       %             Modulo
        !            NOT gate
         \           Swap
          `          String representation
           '3        Push '3'
             e=      Count occurrences
               e|    OR gate
                  g While popped ToS is true
</code>```

If a less verbose explanation was asked, I would have done this:

```<code>ri{)__3%!\`'3e=e|}g
ri                  Get integer
  {              }  Block
   )                 Increment
    __               Triplicate
      3%!            Test non-divisibility with 3
         \           Swap
          `'3e=      Count occurrences of '3' in string repr
               e|    OR gate
                  g While popped ToS is true
</code>```

Title: Count without 3

Body:
Background

When I was in elementary school, we used to play a game in math class that goes as follows.

All kids sit in a big circle and take turns counting, starting from 1.

However, the following numbers must be skipped while counting:

Numbers that are multiples of 3.

Numbers that have a 3 in its decimal representation.

The first 15 numbers the kids should say are

```<code>1 2 4 5 7 8 10 11 14 16 17 19 20 22 25
</code>```

Whenever somebody gets a number wrong – says a number that isn't in the sequence or skips a number that is – he's removed from the circle. This goes on until there's only one kid left.

Task

You're bad at this game, so you decide to cheat. Write a program or a function that, given a number of the sequence, calculates the next number of the sequence.

You don't have to handle numbers that cannot be represented using your language's native numeric type, provided that your program works correctly up to input 251 and that your algorithm works for arbitrarily large inputs.

Input and output can use any convenient base.

Since you have to conceal your code, it must be as short as possible. In fact, this is code-golf, so the shortest code in bytes wins.

Test cases

```<code>  1 ->   2
  2 ->   4
 11 ->  14
 22 ->  25
 29 ->  40
251 -> 254
</code>```

Body:
CJam, 19 bytes

ri{)__3%!\`'3e=e|}g

ONLINE

Explanation:

ri{)__3%!\`'3e=e|}g
r                   Get token
 i                  Convert to integer
  {              }  Block
   )                 Increment
    _                Duplicate
     _               Duplicate
      3              Push 3
       %             Modulo
        !            NOT gate
         \           Swap
          `          String representation
           '3        Push '3'
             e=      Count occurrences
               e|    OR gate
                  g While popped ToS is true

If a less verbose explanation was asked, I would have done this:

ri{)__3%!\`'3e=e|}g
ri                  Get integer
  {              }  Block
   )                 Increment
    __               Triplicate
      3%!            Test non-divisibility with 3
         \           Swap
          `'3e=      Count occurrences of '3' in string repr
               e|    OR gate
                  g While popped ToS is true


答:
Perl, 45 +1 = 46 bytes

+1 byte for -n flag

```<code>$a=a,$b=b;say($a),($a,$b)=($b,$a.$b)for 1..$_
</code>```

Slight improvement over the existing 49-byte solution, but developed separately.  The parentheses for say($a) are necessary because otherwise, it interprets $a,($a,$b)=($b,$a.$b) as the argument of say which outputs more junk than we need.

Perl, 42 bytes

```<code>$b=<>;$_=a;say,y/ab/bc/,s/c/ab/g while$b--
</code>```

A separate approach from the above solution:

```<code>$b=<>;                                       #Read the input into $b
      $_=a;                                  #Create the initial string 'a' stored in $_
           say                               #Print $_ on a new line
               y/ab/bc/                      #Perform a transliteration on $_ as follows:
                                   #Replace 'a' with 'b' and 'b' with 'c' everywhere in $_
                        s/c/ab/g             #Perform a replacement on $_ as follows:
                                   #Replace 'c' with 'ab' everywhere in $_
              ,        ,         while$b--   #Perform the operations separated by commas
                                   #iteratively as long as $b-- remains truthy
</code>```

I'm not yet convinced I can't combine the transliteration and replacement into a single, shorter operation.  If I find one, I'll post it.

Title: Print a letter Fibonacci

Body:
Perl, 45 +1 = 46 bytes

+1 byte for -n flag

$a=a,$b=b;say($a),($a,$b)=($b,$a.$b)for 1..$_

Slight improvement over the existing 49-byte solution, but developed separately.  The parentheses for say($a) are necessary because otherwise, it interprets $a,($a,$b)=($b,$a.$b) as the argument of say which outputs more junk than we need.

Perl, 42 bytes

$b=<>;$_=a;say,y/ab/bc/,s/c/ab/g while$b--

A separate approach from the above solution:

$b=<>;                                       #Read the input into $b
      $_=a;                                  #Create the initial string 'a' stored in $_
           say                               #Print $_ on a new line
               y/ab/bc/                      #Perform a transliteration on $_ as follows:
                                   #Replace 'a' with 'b' and 'b' with 'c' everywhere in $_
                        s/c/ab/g             #Perform a replacement on $_ as follows:
                                   #Replace 'c' with 'ab' everywhere in $_
              ,        ,         while$b--   #Perform the operations separated by commas
                                   #iteratively as long as $b-- remains truthy

I'm not yet convinced I can't combine the transliteration and replacement into a single, shorter operation.  If I find one, I'll post it.


问:
Palindromic palindrome generator
Create a program, that converts input string to a palindrome starting with the input string. The program itself must be a palindrome.

For example input: neverod, print neveroddoreven. You should handle multi-word, multi-line inputs as well.

答:
C# (<s>33</s> 32 + 1) * 2 = <s>68</s> 66 bytes

saved 2 bytes to the use of .Aggregate()

s=>s+s.Aggregate("",(a,b)=>b+a);//;)a+b>=)b,a(,""(etagerggA.s+s>=s
```

<p>Oh the good old lambda, you can catch it with</p>

<pre class="lang-cs prettyprint-override"><code>Func<string, string> f=<lambda here>
</code>```

and then call it with

f("neverod")
```

Title: Palindromic palindrome generator

Body:
C# (<s>33</s> 32 + 1) * 2 = <s>68</s> 66 bytes

saved 2 bytes to the use of .Aggregate()

s=>s+s.Aggregate("",(a,b)=>b+a);//;)a+b>=)b,a(,""(etagerggA.s+s>=s

Oh the good old lambda, you can catch it with

Func<string, string> f=<lambda here>

and then call it with

f("neverod")


答:
C++11, <s>89</s> 98 bytes

+7 bytes for all lines, not only the last one. +2 bytes more for N being the number of lines printed, not some 0-based stuff.

#include<string>
using S=std::string;S f(int n,S a="a",S b="b"){return n-1?a+"\n"+f(n-1,b,a+b):a;}
```
<p>Usage:</p>
<pre class="lang-c++ prettyprint-override"><code>f(5)
</code>```

Title: Print a letter Fibonacci

Body:
Given N (2 <= N), print N lines of the letter Fibonacci series like this (i.e. N = 5)
First, start with a and b:

```<code>a
b
</code>```

Next, add the two lines.

```<code>a
b
ab
</code>```

Keep adding the last two lines.

```<code>a
b
ab
bab
</code>```

Keep going...

```<code>a
b
ab
bab
abbab
</code>```

And we're done.

Remember, this is code-golf, so the code with the fewest bytes wins.

Body:
C++11, <s>89</s> 98 bytes

+7 bytes for all lines, not only the last one. +2 bytes more for N being the number of lines printed, not some 0-based stuff.

#include<string>
using S=std::string;S f(int n,S a="a",S b="b"){return n-1?a+"\n"+f(n-1,b,a+b):a;}

Usage:

f(5)


答:
Pyth, 19 bytes

```<code>JhQW|!%J3/`J\3=hJ;J
</code>```

Test suite

I am sure I can golf this... it's the same as my CJam answer.

Explanation:

```<code>JhQW|!%J3/`J\3=hJ;J
  Q                 Evaluated input
 h                  Increment
J                   Assign J to value
       J            Variable J
        3           Value 3
      %             Modulo
     !              Logical NOT
           J        Variable J
          `         String representation
            \3      Value "3"
         /          Count occurrences
    |               Logical OR
               h    Increment
                J   Variable J
              =     Apply function then assign
                 ;  End statement block
                  J Variable J
</code>```

Title: Count without 3

Body:
Pyth, 19 bytes

JhQW|!%J3/`J\3=hJ;J

Test suite

I am sure I can golf this... it's the same as my CJam answer.

Explanation:

JhQW|!%J3/`J\3=hJ;J
  Q                 Evaluated input
 h                  Increment
J                   Assign J to value
       J            Variable J
        3           Value 3
      %             Modulo
     !              Logical NOT
           J        Variable J
          `         String representation
            \3      Value "3"
         /          Count occurrences
    |               Logical OR
               h    Increment
                J   Variable J
              =     Apply function then assign
                 ;  End statement block
                  J Variable J


答:
Groovy, 48 bytes

```<code>{a,b,c->(a..b).collect{"$it".count("$c")}.sum()}
</code>```

Title: How many integers contain a number in a specific range

Body:
The program should take input the number, the start of the range and the end of the range, and output how many integers the number appears between the start and end of the range, inclusive. Both programs and functions are allowed.

Example Inputs

For example:

```<code>//Input example 1
3,1,100
//Input example 2
3
1
100
//Input example 3
3 1 100
//Input example 4
a(3, 1, 100);
</code>```

All the above four input examples are valid and all of them mean that 3 is the number in question, 1 is the beginning of the range and 100 the the end of the range.

And then the program should output how many times 3 appears in the range from 1 to 100 inclusive. 3 appears in the integers 3, 13, 23, 30, 31, 32, 33, ..., 93 at a total of 19 times. So the program should output 19 as the output because that is how many times 3 appears in the range from 1 to 100.

Rules

Both programs and functions are allowed.

All numbers will be integers, meaning that there will not be any floats or doubles.

Note: the sought number will always be in the range 0≤x≤127. There will be no cases where it will be outside this 0≤x≤127 range.

As in the first example, with the case as 33, the number 3 will be counted as appearing only once, not twice.

The values of the start and end of the range will be between -65536 and 65535 inclusive.

The value of range's start will never exceed or equal to range's end. start < end

Also the range is inclusive. For example if the input was 8 8 10, the range would be 8≤x≤10 and hence the output will be 1.

Input can be taken in any of the ways shown in the examples. Input can be taken as a string or as a number, any way you wish.

Test Cases

```<code>3 1 100
19

3 3 93
19

12,-200,200
24          //This is because 12 appears in -129, -128, ..., -112, -12, 12, 112, 120, 121, 122, ...

123,1,3
0           //This is because all of 123's digits have to appear in the same order

3 33 34
2           //Because 3 appears in 2 numbers: 33 and 34

a(0,-1,1);
1

$ java NotVerbose 127 -12 27
0
</code>```

Snack Snippet

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

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

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

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

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

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

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

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

/* Configuration */

var QUESTION_ID = 98470; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 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 "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

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

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

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

getAnswers();

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

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

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

function process() {
  var valid = [];

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

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

  });

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

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

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

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

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

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

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

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

table thead {
  font-weight: bold;
}

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Groovy, 48 bytes

{a,b,c->(a..b).collect{"$it".count("$c")}.sum()}


问:
Goldbach partitions
The Goldbach conjecture states that every even number greater than two can be expressed as the sum of two primes. For example,

```<code>4 = 2 + 2
6 = 3 + 3
8 = 5 + 3
</code>```

However, once we get to 10 something interesting happens. Not only can 10 be written as

```<code>5 + 5
</code>```

but it can also be written as

```<code>7 + 3
</code>```

Since 10 can be expressed as the sum of two primes two ways, we say that the "Goldbach partition" of 10 is 2. Or more generally,

The Goldbach partition of a number is the total number of distinct ways of writing n = p + q where p and q are primes and p >= q

Your challenge is to write a program or function that finds the Goldbach partition of a number. Now, technically the term "Goldbach partition" is used only to refer to even numbers. However, since the odd integer p + 2 can also be expressed as the sum of two primes if p > 2 is prime, we will extend this to all positive integers (A061358).

You may safely assume that your input will always be a positive integer, and you may take input and output in any of our default allowed methods, for example function arguments and return value, STDIN and STDOUT, reading and writing to a file, etc.

The Goldbach partitions of the positive integers up to 100 are:

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

As usual, standard loopholes apply, and the shortest answer in bytes wins!

答:
Haskell, 73 bytes

```<code>f n|r<-[a|a<-[2..n],all((<2).gcd a)[2..a-1]]=sum[1|p<-r,q<-r,q<=p,p+q==n]
</code>```

Usage example: map f [1..25] -> [0,0,0,1,1,1,1,1,1,2,0,1,1,2,1,2,0,2,1,2,1,3,0,3,1].

Direct implementation of the definition: first bind r to all primes up to the input number n, then take a 1 for all p and q from r where q<=p and p+q==n and sum them.

Title: Goldbach partitions

Body:
Haskell, 73 bytes

f n|r<-[a|a<-[2..n],all((<2).gcd a)[2..a-1]]=sum[1|p<-r,q<-r,q<=p,p+q==n]

Usage example: map f [1..25] -> [0,0,0,1,1,1,1,1,1,2,0,1,1,2,1,2,0,2,1,2,1,3,0,3,1].

Direct implementation of the definition: first bind r to all primes up to the input number n, then take a 1 for all p and q from r where q<=p and p+q==n and sum them.


Title: Print a letter Fibonacci

Body:
PHP, 53 bytes

for($a=b,$b=a;$argv[1]--;$a=($_=$b).$b=$a)echo$b.'
';


Title: Print a letter Fibonacci

Body:
Javascript (ES6), 35 bytes

f=v=>v&&v-1?f(v-2)+f(v-1):v?'b':'a'


问:
Square-unspiral the string!
Given a string, first square it as follows:

First, write the string.

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

Next, write the string rotated one left.

```<code>abcde
bcdea
</code>```

Keep doing this until you have written len(string) lines.

```<code>abcde
bcdea
cdeab
deabc
eabcd
</code>```

Now, read from the string like this:

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

Which gives:

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

Print this string.

Test cases

```<code>abcdef -> abcdefabcdedcbafedcbcdefabcbafedefaf
cena! -> cena!cenanec!anena!cec!a!
ppcg -> ppcgppcppgcpcgpg
abc -> abcabacbc
ab -> abab
a -> a
 ->
</code>```

Please comment if a test case is incorrect.

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

答:
C, <s>95</s> 94 Bytes

```<code>i,j,k,l;f(char*s){for(k=-1,l=i=strlen(s);i--;)for(j=i*2;~j--;putchar(s[(k+=(l-i)%2*2-1)%l]));}
</code>```

Inspired by @ETHproductions answer.

Title: Square-unspiral the string!

Body:
C, <s>95</s> 94 Bytes

i,j,k,l;f(char*s){for(k=-1,l=i=strlen(s);i--;)for(j=i*2;~j--;putchar(s[(k+=(l-i)%2*2-1)%l]));}

Inspired by @ETHproductions answer.


问:
Depalindromize this string!
Given a palindrome generated according to this challenge, depalindromize it.

Test cases

```<code>abcdedcba -> abcde
johncenanecnhoj -> johncena
ppapapp -> ppap
codegolflogedoc -> codegolf
</code>```

As this is about depalindromizing, your code cannot be a palindrome.

Remember, this is code-golf, so the code with the fewest bytes wins.

答:
Common Lisp, 43

```<code>(lambda(s)(subseq s 0(ceiling(length s)2)))
</code>```

Truly hard to golf without accidentally writing a palindrome, will all those ( matching opposite ).

I know, this is not what "palindrome" means.

Title: Depalindromize this string!

Body:
Common Lisp, 43

(lambda(s)(subseq s 0(ceiling(length s)2)))

Truly hard to golf without accidentally writing a palindrome, will all those ( matching opposite ).

I know, this is not what "palindrome" means.


答:
C, 156 bytes (without indent)

```<code>void f(int n)
{
    char u[999]="a",v[999]="b",*a=u,*b=a+1,*c=v,*d=c+1,*e,i;
    for(i=0;i<n;++i)
    {
        printf("%s\n",a);
        for(e=c;*b++=*e++;);
        e=a;a=c;c=e;e=b+1;b=d;d=e;
    }
}
</code>```

Two buffers (u & v) store the last two lines. The newest line (tracked with two pointers: start=c, end=d) is appended to the oldest one (start=a, end=b). Swap (a,b) and (c,d), and loop. Pay attention to buffer size before requesting too much lines.
Not so short (as expected of a low-level language), but was fun to code.

Title: Print a letter Fibonacci

Body:
C, 156 bytes (without indent)

void f(int n)
{
    char u[999]="a",v[999]="b",*a=u,*b=a+1,*c=v,*d=c+1,*e,i;
    for(i=0;i<n;++i)
    {
        printf("%s\n",a);
        for(e=c;*b++=*e++;);
        e=a;a=c;c=e;e=b+1;b=d;d=e;
    }
}

Two buffers (u & v) store the last two lines. The newest line (tracked with two pointers: start=c, end=d) is appended to the oldest one (start=a, end=b). Swap (a,b) and (c,d), and loop. Pay attention to buffer size before requesting too much lines.
Not so short (as expected of a low-level language), but was fun to code.


答:
Element, 11 bytes

```<code>_2:$'[(`)#]
</code>```

Try it online!

```<code>_2:$'[(`)#]
_             take input
 2:           make a second copy
   $          length of string
    '[    ]   FOR loop
     [(`  ]   chop off then print the first character
     [  )#]   chop off then discard the last character
</code>```

The FOR loop is actually executed about twice as many times as it needs to be, but those extra iterations do not affect the output since it runs out of data to print.

Title: Depalindromize this string!

Body:
Given a palindrome generated according to this challenge, depalindromize it.

Test cases

```<code>abcdedcba -> abcde
johncenanecnhoj -> johncena
ppapapp -> ppap
codegolflogedoc -> codegolf
</code>```

As this is about depalindromizing, your code cannot be a palindrome.

Remember, this is code-golf, so the code with the fewest bytes wins.

Body:
Element, 11 bytes

_2:$'[(`)#]

Try it online!

_2:$'[(`)#]
_             take input
 2:           make a second copy
   $          length of string
    '[    ]   FOR loop
     [(`  ]   chop off then print the first character
     [  )#]   chop off then discard the last character

The FOR loop is actually executed about twice as many times as it needs to be, but those extra iterations do not affect the output since it runs out of data to print.


答:
Swift 3, <s>96</s> 93 bytes

```<code>import Cocoa
func c(n:Int,s:Int,e:Int){print((s...e).filter{"\($0)".contains("\(n)")}.count)}
</code>```

Edit 1:

Saved 3 bytes by using shorthand parameters

Body:
Swift 3, <s>96</s> 93 bytes

import Cocoa
func c(n:Int,s:Int,e:Int){print((s...e).filter{"\($0)".contains("\(n)")}.count)}

Edit 1:

Saved 3 bytes by using shorthand parameters


答:
C#, <s>360</s> 359 bytes

```<code>using w=System.Console;using q=System.Convert;s={System.Func<int,int,string>S=q.ToString;string t="",f="";for(int i=0;i<s.Length;i++)t+=i>0?S(s[i],2).PadLeft(8,'0'):S(s[i],2);w.WriteLine(q.ToInt64(t,2).ToString());while(t!="0"){f="";foreach(var n in t)f+=n=='0'?'1':'0';t=f.TrimStart(new char[]{'0'});t+=t==""?"0":"";w.WriteLine(q.ToInt64(t,2).ToString());}};
</code>```

Full program:

```<code>using w = System.Console;
using q = System.Convert;

class a
{
    static void Main()
    {
        System.Action<string> b = s =>
        {
            System.Func<int,int,string> S = q.ToString;
            string t = "", f = ""; // Var does not work here
            for(int i = 0; i < s.Length; i++)
                t += i > 0 ? S(s[i], 2).PadLeft(8, '0') : S(s[i], 2);
            w.WriteLine(q.ToInt64(t, 2).ToString());
            while(t != "0")
            {
                f = "";
                foreach (var n in t) f += n== '0' ? '1' : '0';
                t = f.TrimStart(new char[] { '0' });
                t += t == "" ? "0" : "";
                w.WriteLine(q.ToInt64(t, 2).ToString());
            }
        };

        b("Inf");
        b("Infinity");
        w.Read(); // prevent close in VS
    }
}
</code>```

Title: Count down from "Infinity"

Body:
Seems like an impossible task right? Well, it's actually not that hard. If we write the word Infinity as 8-bit binary ASCII code, we'll get:

```<code>01001001 01101110 01100110 01101001 01101110 01101001 01110100 01111001
</code>```

This can be concatenated, and converted to the decimal value 5291279215216915577. Now that's a number we can work with...

The way you'll count down is:

Output the original string as a decimal number (as shown above)

Remove leading 0s in its binary representation (if any)

Toggle the bits in the binary representation (1->0, 0->1)

Output the number in decimal

Repeat steps 2-4 as until you reach 0.

Challenge:

Create a program or function that takes a string as input, and outputs (on any suitable format) the numbers you'll get when performing the procedure above.

Test case:

I think the challenge will be fairly easy to understand, even though it's only one test case. I'll use Inf instead of Infinity to keep this fairly short.

```<code>Inf
4812390  (10010010110111001100110)
3576217  ( 1101101001000110011001)
618086   (   10010110111001100110)
430489   (    1101001000110011001)
93798    (      10110111001100110)
37273    (       1001000110011001)
28262    (        110111001100110)
4505     (          1000110011001)
3686     (           111001100110)
409      (              110011001)
102      (                1100110)
25       (                  11001)
6        (                    110)
1        (                      1)
0        (                      0)
</code>```

```<code>Input: Inf
Output:
4812390, 3576217, 618086, 430489, 93798, 37273, 28262, 4505, 3686, 409, 102, 25, 6, 1, 0
</code>```

```<code>Input: Infinity
Output:
5291279215216915577, 3932092821637860230, 679593196789527673, 473328307817319302, 103132444486104185, 40982743589751686, 31074850448176249, 4953946570787718, 4053252683953273, 450346943417222, 112603010004089, 28134478351238, 7049893737593, 1746199284614, 452823970937, 96931842950, 40507110521, 28212366214, 6147372153, 2442562438, 1852404857, 295078790, 241792121, 26643334, 6911097, 1477510, 619641, 428934, 95353, 35718, 29817, 2950, 1145, 902, 121, 6, 1, 0
</code>```

Your code must support strings that can be represented as a binary number up to the limit of your language. All strings will only contain printable ASCII-characters from 32-126 (space to tilde).

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
C#, <s>360</s> 359 bytes

using w=System.Console;using q=System.Convert;s={System.Func<int,int,string>S=q.ToString;string t="",f="";for(int i=0;i<s.Length;i++)t+=i>0?S(s[i],2).PadLeft(8,'0'):S(s[i],2);w.WriteLine(q.ToInt64(t,2).ToString());while(t!="0"){f="";foreach(var n in t)f+=n=='0'?'1':'0';t=f.TrimStart(new char[]{'0'});t+=t==""?"0":"";w.WriteLine(q.ToInt64(t,2).ToString());}};

Full program:

using w = System.Console;
using q = System.Convert;

class a
{
    static void Main()
    {
        System.Action<string> b = s =>
        {
            System.Func<int,int,string> S = q.ToString;
            string t = "", f = ""; // Var does not work here
            for(int i = 0; i < s.Length; i++)
                t += i > 0 ? S(s[i], 2).PadLeft(8, '0') : S(s[i], 2);
            w.WriteLine(q.ToInt64(t, 2).ToString());
            while(t != "0")
            {
                f = "";
                foreach (var n in t) f += n== '0' ? '1' : '0';
                t = f.TrimStart(new char[] { '0' });
                t += t == "" ? "0" : "";
                w.WriteLine(q.ToInt64(t, 2).ToString());
            }
        };

        b("Inf");
        b("Infinity");
        w.Read(); // prevent close in VS
    }
}


答:
Scala, 50 bytes

```<code>(c:String)=>(_:Int)to(_:Int)count(""+_ contains c)
</code>```

takes the first input curried; call it like this: f("12")(-200,200)

Explantion:

```<code>(c:String)=>  //define an anonymous function taking a string parameter
  (_:Int)     //create a range from an anonymous int parameter
  to          //to
  (_:Int)     //another anonymous int parameter
  count(      //and count how many...
   ""+_       //elements converted to a string
   contains c //contain c
  )
</code>```

Body:
Scala, 50 bytes

(c:String)=>(_:Int)to(_:Int)count(""+_ contains c)

takes the first input curried; call it like this: f("12")(-200,200)

Explantion:

(c:String)=>  //define an anonymous function taking a string parameter
  (_:Int)     //create a range from an anonymous int parameter
  to          //to
  (_:Int)     //another anonymous int parameter
  count(      //and count how many...
   ""+_       //elements converted to a string
   contains c //contain c
  )


问:
What degree is this palindrome?
Your task is to determine the palindromic degree of a given non-empty string.

To do this, loop until one of the following conditions are met:

The string is not a palindrome.

You encounter a string that has already been encountered.

And do the following:

If it is a palindrome, add one to the degree.

Depalindromize.

For example, if I had the string babababab, the calculation would go:

```<code>babababab     1
babab         2
bab           3
ba
</code>```

For the string zzzzz, it would go:

```<code>zzzzz         1
zzz           2
zz            3
z             4
z
</code>```

Test cases

```<code>abc 0
cenea 0
pappap 2
aa 2
aba 1
aaa 3
cccc 3
zzzzz 4
</code>```

Explanation:

```<code>abc : 0
cenea : 0
pappap -> pap -> pa : 2
aa -> a -> a : 2
aba -> ab : 1
aaa -> aa -> a -> a: 3
cccc -> cc -> c -> c: 3
zzzzz -> zzz -> zz -> z -> z : 4
</code>```

Remember, this is code-golf, so the code with the fewest bytes wins.

答:
Scala, 56 bytes

```<code>s=>if(s.reverse==s&&s.size>1)1+h(s.take(s.size/2))else 2
</code>```

requires an assignmentt to a variable with type declaration:

val f:(String=>Int)=...

Title: What degree is this palindrome?

Body:
Scala, 56 bytes

s=>if(s.reverse==s&&s.size>1)1+h(s.take(s.size/2))else 2

requires an assignmentt to a variable with type declaration:

val f:(String=>Int)=...


问:
Let's abbreviate those numbers! Now reverse?
Introduction:

Like Twitter and Instagram and others, I wanted to display numbers like 1.2K and 3.8 M instead of 1,222 or 3,823,456.

But that's not all! As we all know, there might be some human beings which undoubtely won't like these abbreviations and will try to reverse them. So, 1.2k will become 1,200 and 3.8 M will become 3,800,000.

The task:

your task is to write a program or a function that converts a list of numbers (which are given as strings) into their abbreviate pairs and vice-versa.

For example, if the input list (or any STDIN) was ['1.4k', '1,234,567', '7.99M'], then you should output:

```<code>['1,400', '1.2M', '7,990,000']
</code>```

You can follow the next schema for abbreviations:

103 -> one kilo -> K

106 -> one million -> M

109 -> one billion -> B

Your code may assume all lowercase, all uppercase, mixed case or undefined case for input and use any of these for output, but should be consistent.

Rules and restrictions:

you may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.

input may be in any convenient list or string format. You may assume that the ai are less than 231 each and that the list contains at least one element.

each abbreviated number will contain only one . while a normal number will contain as many , as necessary (you may assume that this numbers won't be altered).

you MAY NOT enter a number as '123456' but rather 123,456

standard code-golf rules apply.

Test cases:

```<code>Input: ['1.5M', '77.6k', '123,456,789']         Output: ['1,500,000', '77,600', '123.4M']
Input: ['3,000,000,000', '581k', '2b']          Output: ['3B', '581,000', '2,000,000,000']
Input: ['0.1k']                                 Output: ['100']
Input: ['888', '33']                            Output: ['0.888k', '0.033k']
</code>```

Clarifications:

for numbers < 1000 after the decimal point in abbreviation output you should have as many digits as required to get the correct result. (e.g: 2 -> will become 0.002k) - that means 3 decimals at most; for numbers > 1000 you can have a maximum of 1 decimal.

the abbreviation may be in both lower or upper case

I removed the built-ins restriction as suggested in the comments

The shortest code in bytes wins!

答:
JavaScript, <s>545</s> <s>524</s> <s>522</s> <s>518</s> <s>514</s> <s>508</s> <s>504</s> <s>498</s> <s>494</s> 214 bytes

Thanks to @ETHproductions for saving 180 bytes!

```<code>d=F=>F.map(f=>1/f.slice(-1)?f=(f=f.replace(/,/g,""))[9]?(f/1e8|0)/10+"B":f[6]?(f/1e5|0)/10+"M":f/1e3+"k":R(R(f.slice(0,-1)+"e"+' kMB'.indexOf(f.substr(-1))*3-0+"").match(/.{1,3}/g)+""),R=x=>[...x].reverse().join``)
</code>```

To call the function:

```<code>d(["1.5M","1,500,000"]) //["1,500,500","1.5M"]
</code>```

Outputs as alert, where each alert contains a different element of the input

Readable version:

d = F => F.map(f => 1 / f.slice(-1) ? f = (f = f.replace(/,/g, ""))[9] ? (f / 1e8 | 0) / 10 + "B" : f[6] ? (f / 1e5 | 0) / 10 + "M" : f / 1e3 + "k" : R(R(f.slice(0, -1) + "e" + ' kMB'.indexOf(f.substr(-1)) * 3 - 0 + "").match(/.{1,3}/g) + ""), R = x => [...x].reverse().join ``)
```

Summary of edits: converted function to an arrow function

removed semi-colons ';'

removed var

converted to an arrow function

used map to iterate through the individual elements of the array

used |0 instead of floor

used regex for testing

used ternary operators instead of if-else statements

included a separate function for .reverse().join''

Body:
JavaScript, <s>545</s> <s>524</s> <s>522</s> <s>518</s> <s>514</s> <s>508</s> <s>504</s> <s>498</s> <s>494</s> 214 bytes

Thanks to @ETHproductions for saving 180 bytes!

d=F=>F.map(f=>1/f.slice(-1)?f=(f=f.replace(/,/g,""))[9]?(f/1e8|0)/10+"B":f[6]?(f/1e5|0)/10+"M":f/1e3+"k":R(R(f.slice(0,-1)+"e"+' kMB'.indexOf(f.substr(-1))*3-0+"").match(/.{1,3}/g)+""),R=x=>[...x].reverse().join``)

To call the function:

d(["1.5M","1,500,000"]) //["1,500,500","1.5M"]

Outputs as alert, where each alert contains a different element of the input

Readable version:

d = F => F.map(f => 1 / f.slice(-1) ? f = (f = f.replace(/,/g, ""))[9] ? (f / 1e8 | 0) / 10 + "B" : f[6] ? (f / 1e5 | 0) / 10 + "M" : f / 1e3 + "k" : R(R(f.slice(0, -1) + "e" + ' kMB'.indexOf(f.substr(-1)) * 3 - 0 + "").match(/.{1,3}/g) + ""), R = x => [...x].reverse().join ``)

Summary of edits: converted function to an arrow function

removed semi-colons ';'

removed var

converted to an arrow function

used map to iterate through the individual elements of the array

used |0 instead of floor

used regex for testing

used ternary operators instead of if-else statements

included a separate function for .reverse().join''


答:
Scala, 21 bytes

```<code>a=>a.take(a.size/2+1)
</code>```

requires an assignment with a type annotation: val f:(Seq[_]=>Seq[_])...

Title: Depalindromize this string!

Body:
Scala, 21 bytes

a=>a.take(a.size/2+1)

requires an assignment with a type annotation: val f:(Seq[_]=>Seq[_])...


问:
Output a googol copies of a string
I am interested in seeing programs which don't ask for any input, print a googol copies of some nonempty string, no less, no more, and then stop. A googol is defined as \$10^{100}\$, i.e., 1 followed by a hundred 0's in decimal.

Example output:

```<code>111111111111111111111111111111111111111111111111111111111111111111111111...
</code>```

or

```<code>Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
...
</code>```

The string can also be entirely composed of white space or special symbols. The only exception to identical copies of a fixed string is if your language decorates the output in some way that can not be prevented, but could be trivially undone in a wrapper script, like prepending a line number to each line. The wrapper script in such cases need not be provided.

You can assume your computer will never run out of time, but other than that, your program must have a reasonable demand of resources. Also, you must respect any restrictions that the programming language of your choice poses, for example, you can not exceed a maximum value allowed for its integer types, and at no point more than 4 GB of memory must be needed.

In other words, the program should in principle be testable by running it on your computer. But because of the extent of this number you will be expected to prove that the number of copies of the string it outputs is exactly 10^100 and that the program stops afterwards. Stopping can be exiting or halting or even terminating due to an error, but if so, the error must not produce any output that could not easily be separated from the program's output.

This is code-golf,  so the solution with the fewest bytes wins.

Example solution (C, ungolfed, 3768 bytes)

```<code>#include <stdio.h>

int main() {
  int a00, a01, a02, a03, ..., a99;
  for(a00 = 0; a00 < 10; a00++)
  for(a01 = 0; a01 < 10; a01++)
  for(a02 = 0; a02 < 10; a02++)
  for(a03 = 0; a03 < 10; a03++)
  ...
  for(a99 = 0; a99 < 10; a99++)
    puts("1");
  return 0;
}
</code>```

答:
Turing machine simulator, 1082 bytes

```<code>0 * 6 r 1
1 * E r 2
2 * C r 3
3 * 1 r 4
4 * B r 5
5 * C r 6
6 * F r 7
7 * 4 r 8
8 * 6 r 9
9 * 8 r A
A * 8 r B
B * 3 r C
C * 0 r D
D * 9 r E
E * G r F
F * H r G
G * 8 r H
H * 0 r I
I * 6 r J
J * H r K
K * 9 r L
L * 3 r M
M * 2 r N
N * A r O
O * D r P
P * C r Q
Q * C r R
R * 4 r S
S * 4 r T
T * E r U
U * E r V
V * G r W
W * 6 r X
X * D r Y
Y * E r Z
Z * 0 r a
a * F r b
b * E r c
c * 9 r d
d * F r e
e * A r f
f * H r g
g * D r h
h * E r i
i * 6 r j
j * 6 r k
k * D r l
l * G r m
m * H r n
n * 1 r o
o * 0 r p
p * 8 r q
q * C r r
r * 9 r s
s * G r t
t * 3 r u
u * 6 r v
v * 2 r w
w * 3 r x
x * E r y
y * 0 r z
z * 4 r +
+ * 5 r /
/ * A r =
= * 0 r -
- * H r \
\ * 7 r !
! * A r @
@ * 9 r #
# * 5 r $
$ * A r %
% * B r ^
^ * 5 r &
& * 9 r ?
? * 4 r (
( * C r )
) * E r `
` * 9 r ~
~ * 9 r _
_ * A * .
. 0 I l *
. 1 0 r <
. 2 1 r <
. 3 2 r <
. 4 3 r <
. 5 4 r <
. 6 5 r <
. 7 6 r <
. 8 7 r <
. 9 8 r <
. A 9 r <
. B A r <
. C B r <
. D C r <
. E D r <
. F E r <
. G F r <
. H G r <
. I H r <
. _ * r ]
< _ * r >
< * * r *
> _ = l [
> * * r *
[ _ * l .
[ * * l *
] _ * * halt
] * _ r *
</code>```

Turing machine simulator

I do not know if this counts as the correct output, since it has 82 leading spaces.

I do not know if this respects the 4 GB limit, so, if it doesn't, then it's non-competitive and just for showcase. The output is 1e100 bytes, so that should be deducted from the memory byte count. The final byte count is 82 bytes.

Here is an explanation:

The first 80 lines of code are 80 different states that generate the base-191 loop count 6EC1BCF4688309GH806H932ADCC44EEG6DE0FE9FAHDE66DGH108C9G3623E045A0H7A95AB594CE99A.

The next 19 lines of code are the counter state, which decrements the count every time a character is printed.

The next 6 lines are the printer state, which appends an =.

Finally, the last 2 lines are the cleaner state, which are needed to make sure the only output is =====...=====. Leading/trailing spaces do not count as output, since they are unavoidable side-effects.

The program then halts.

1I did the math for that.

Title: Output a googol copies of a string

Body:
Turing machine simulator, 1082 bytes

0 * 6 r 1
1 * E r 2
2 * C r 3
3 * 1 r 4
4 * B r 5
5 * C r 6
6 * F r 7
7 * 4 r 8
8 * 6 r 9
9 * 8 r A
A * 8 r B
B * 3 r C
C * 0 r D
D * 9 r E
E * G r F
F * H r G
G * 8 r H
H * 0 r I
I * 6 r J
J * H r K
K * 9 r L
L * 3 r M
M * 2 r N
N * A r O
O * D r P
P * C r Q
Q * C r R
R * 4 r S
S * 4 r T
T * E r U
U * E r V
V * G r W
W * 6 r X
X * D r Y
Y * E r Z
Z * 0 r a
a * F r b
b * E r c
c * 9 r d
d * F r e
e * A r f
f * H r g
g * D r h
h * E r i
i * 6 r j
j * 6 r k
k * D r l
l * G r m
m * H r n
n * 1 r o
o * 0 r p
p * 8 r q
q * C r r
r * 9 r s
s * G r t
t * 3 r u
u * 6 r v
v * 2 r w
w * 3 r x
x * E r y
y * 0 r z
z * 4 r +
+ * 5 r /
/ * A r =
= * 0 r -
- * H r \
\ * 7 r !
! * A r @
@ * 9 r #
# * 5 r $
$ * A r %
% * B r ^
^ * 5 r &
& * 9 r ?
? * 4 r (
( * C r )
) * E r `
` * 9 r ~
~ * 9 r _
_ * A * .
. 0 I l *
. 1 0 r <
. 2 1 r <
. 3 2 r <
. 4 3 r <
. 5 4 r <
. 6 5 r <
. 7 6 r <
. 8 7 r <
. 9 8 r <
. A 9 r <
. B A r <
. C B r <
. D C r <
. E D r <
. F E r <
. G F r <
. H G r <
. I H r <
. _ * r ]
< _ * r >
< * * r *
> _ = l [
> * * r *
[ _ * l .
[ * * l *
] _ * * halt
] * _ r *

Turing machine simulator

I do not know if this counts as the correct output, since it has 82 leading spaces.

I do not know if this respects the 4 GB limit, so, if it doesn't, then it's non-competitive and just for showcase. The output is 1e100 bytes, so that should be deducted from the memory byte count. The final byte count is 82 bytes.

Here is an explanation:

The first 80 lines of code are 80 different states that generate the base-191 loop count 6EC1BCF4688309GH806H932ADCC44EEG6DE0FE9FAHDE66DGH108C9G3623E045A0H7A95AB594CE99A.

The next 19 lines of code are the counter state, which decrements the count every time a character is printed.

The next 6 lines are the printer state, which appends an =.

Finally, the last 2 lines are the cleaner state, which are needed to make sure the only output is =====...=====. Leading/trailing spaces do not count as output, since they are unavoidable side-effects.

The program then halts.

1I did the math for that.


答:
Perl, 99 bytes

```<code>$_=<>;
chop;
@a=split//;
print(@a[$%,(@f=1-($b=@a-$%)..$b-3),$b-1?$b-2:(),reverse@f]),$%+=2 until$%>@a
</code>```

Whitespace is not part of the program and is provided for readability.

Not extremely efficient code.  I should be able to shorten the first three lines somehow, but everything I tried to do failed.  That ternary operator also needs to be fixed somehow, but having it this way made it possible to shorten my code by like, 10 bytes because I could cut out so much.

The code works by compiling a list of palindromes, separated by even numbers, which represent the place values of the string to be pulled.

Title: Square-unspiral the string!

Body:
Given a string, first square it as follows:

First, write the string.

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

Next, write the string rotated one left.

```<code>abcde
bcdea
</code>```

Keep doing this until you have written len(string) lines.

```<code>abcde
bcdea
cdeab
deabc
eabcd
</code>```

Now, read from the string like this:

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

Which gives:

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

Print this string.

Test cases

```<code>abcdef -> abcdefabcdedcbafedcbcdefabcbafedefaf
cena! -> cena!cenanec!anena!cec!a!
ppcg -> ppcgppcppgcpcgpg
abc -> abcabacbc
ab -> abab
a -> a
 ->
</code>```

Please comment if a test case is incorrect.

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

Body:
Perl, 99 bytes

$_=<>;
chop;
@a=split//;
print(@a[$%,(@f=1-($b=@a-$%)..$b-3),$b-1?$b-2:(),reverse@f]),$%+=2 until$%>@a

Whitespace is not part of the program and is provided for readability.

Not extremely efficient code.  I should be able to shorten the first three lines somehow, but everything I tried to do failed.  That ternary operator also needs to be fixed somehow, but having it this way made it possible to shorten my code by like, 10 bytes because I could cut out so much.

The code works by compiling a list of palindromes, separated by even numbers, which represent the place values of the string to be pulled.


答:
Pyth, 15 bytes

```<code>.Wp.(H0_CZ.<LQU
</code>```

A program that takes input of a "quoted string" and prints the result.

Try it online! or verify all test cases (modified for multiple input).

How it works

```<code>.Wp.(H0_CZ.<LQU  Program. Input: Q
            L U  Map over [0, 1, 2, 3, ..., Q-1] (implicit input):
          .< Q     Q left-shifted by that many characters
                 Call this X
.W               While
   .(H0          popping the first element of X (mutates X in-place)
  p              and printing it with no trailing newline is truthy:
         Z           X =
        C            X transposed
       _             reversed
</code>```

Title: Square-unspiral the string!

Body:
Pyth, 15 bytes

.Wp.(H0_CZ.<LQU

A program that takes input of a "quoted string" and prints the result.

Try it online! or verify all test cases (modified for multiple input).

How it works

.Wp.(H0_CZ.<LQU  Program. Input: Q
            L U  Map over [0, 1, 2, 3, ..., Q-1] (implicit input):
          .< Q     Q left-shifted by that many characters
                 Call this X
.W               While
   .(H0          popping the first element of X (mutates X in-place)
  p              and printing it with no trailing newline is truthy:
         Z           X =
        C            X transposed
       _             reversed


答:
Python 3, 93 bytes

```<code>s=input();r,n,i=s[::-1],len(s)-1,0
while n-i:print(s[i:]+s[:n-i]+r[i+2:]+r[:n-i],end='');i+=2
</code>```

Try it online!

Title: Square-unspiral the string!

Body:
Python 3, 93 bytes

s=input();r,n,i=s[::-1],len(s)-1,0
while n-i:print(s[i:]+s[:n-i]+r[i+2:]+r[:n-i],end='');i+=2

Try it online!


问:
Draw some mountain peaks
Write a program or function that draws a mountain range, where each subsequent larger mountain peak is "behind" the ones in front, and alternates which side is visible.

This is a mountain range of size 1

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

This is a mountain range of size 2

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

This is a mountain range of size 3

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

This is a mountain range of size 4

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

This is a mountain range of size 5

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

And so on.

Input

A single positive integer in any convenient format, n > 0.

Output

An ASCII-art representation of the mountain range, following the above rules. Leading/trailing newlines or other whitespace are optional, provided that the peaks line up appropriately.

Rules

Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.

Standard loopholes are forbidden.

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

答:
Charcoal, 16 bytes

```<code>ＮλＦλ«Ｐ↘⁻λι←↙¹‖Ｔ→
</code>```

Try it online!

How?

Ｎλ inputs the size of the largest mountain into λ. Ｆλ« runs a loop over values of ι from 0 through λ-1. (The closing » is implied at the end of the program.)

Inside the loop, Ｐ↘⁻λι calculates λ-ι and draws, without moving the cursor afterward, a line of that length going southeast. Based on its direction, this line will consist of \ characters. ← moves one step to the west, and ↙¹ draws a line of length 1 going southwest (made of /). Finally, ‖Ｔ→ horizontally reflects the drawing, transforming characters as appropriate: \ becomes / and / becomes \.

Adding the dump instruction Ｄ at the beginning of the loop (try it) allows us to see the progression:

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

Title: Draw some mountain peaks

Body:
Charcoal, 16 bytes

ＮλＦλ«Ｐ↘⁻λι←↙¹‖Ｔ→

Try it online!

How?

Ｎλ inputs the size of the largest mountain into λ. Ｆλ« runs a loop over values of ι from 0 through λ-1. (The closing » is implied at the end of the program.)

Inside the loop, Ｐ↘⁻λι calculates λ-ι and draws, without moving the cursor afterward, a line of that length going southeast. Based on its direction, this line will consist of \ characters. ← moves one step to the west, and ↙¹ draws a line of length 1 going southwest (made of /). Finally, ‖Ｔ→ horizontally reflects the drawing, transforming characters as appropriate: \ becomes / and / becomes \.

Adding the dump instruction Ｄ at the beginning of the loop (try it) allows us to see the progression:

    /\
   /
  /
 /
/
    /\
   /\ \
  /    \
 /      \
/        \
    /\
   / /\
  / /\ \
 / /    \
/ /      \
    /\
   /\ \
  / /\ \
 / /\ \ \
/ /    \ \
    /\
   / /\
  / /\ \
 / / /\ \
/ / /\ \ \


问:
How many significant figures?
Given a number as input, determine how many significant figures it has. This number will should be taken as a string because you have to do some special formatting. You'll see what I mean soon (I think).

A digit is a sig-fig if at least one of the following apply:

Non-zero digits are always significant.

Any zeros between two significant digits are significant.

final zero or trailing zeros in the decimal portion only are significant.

all digits are significant if nothing follows the decimal place.

when there are only zeroes, all but the last zero are considered leading zeroes

Input

A string or string array of the number. It might have a decimal point at the end without a digit after it. It might not have a decimal point at all.

Output

How many sig-figs there are.

Examples

```<code>1.240 -> 4
0. -> 1
83900 -> 3
83900.0 -> 6
0.025 -> 2
0.0250 -> 3
2.5 -> 2
970. -> 3
0.00 -> 1
</code>```

答:
Scala, 90 bytes

```<code>& =>(if(&contains 46)&filter(46!=)else&.reverse dropWhile(48==)reverse)dropWhile(48==)size
</code>```

Explanation:

```<code>& =>               //define an anonymous function with a parameter called &
  (
  if(&contains 46) //if & contains a '.'
    &filter(46!=)    //remove all periods
  else             //else
    &.reverse        //reverse the string
    dropWhile(48==)  //remove leading zeros
    reverse          //and reverse again
  )
  dropWhile(48==) //remove leading zeros
  size            //return the length
</code>```

Title: How many significant figures?

Body:
Scala, 90 bytes

& =>(if(&contains 46)&filter(46!=)else&.reverse dropWhile(48==)reverse)dropWhile(48==)size

Explanation:

& =>               //define an anonymous function with a parameter called &
  (
  if(&contains 46) //if & contains a '.'
    &filter(46!=)    //remove all periods
  else             //else
    &.reverse        //reverse the string
    dropWhile(48==)  //remove leading zeros
    reverse          //and reverse again
  )
  dropWhile(48==) //remove leading zeros
  size            //return the length


答:
JavaScript (ES6), 75 bytes

```<code>for(n=prompt(s="/\\");n--;s=n%2?s+' \\':'/ '+s)console.log(" ".repeat(n)+s)
</code>```

The full program is currently slightly shorter than the recursive function:

```<code>f=n=>n?" ".repeat(--n)+`/\\
`+f(n).replace(/\S.+/g,x=>n%2?x+" \\":"/ "+x):""
</code>```

Title: Draw some mountain peaks

Body:
Write a program or function that draws a mountain range, where each subsequent larger mountain peak is "behind" the ones in front, and alternates which side is visible.

This is a mountain range of size 1

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

This is a mountain range of size 2

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

This is a mountain range of size 3

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

This is a mountain range of size 4

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

This is a mountain range of size 5

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

And so on.

Input

A single positive integer in any convenient format, n > 0.

Output

An ASCII-art representation of the mountain range, following the above rules. Leading/trailing newlines or other whitespace are optional, provided that the peaks line up appropriately.

Rules

Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.

Standard loopholes are forbidden.

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

Body:
JavaScript (ES6), 75 bytes

for(n=prompt(s="/\\");n--;s=n%2?s+' \\':'/ '+s)console.log(" ".repeat(n)+s)

The full program is currently slightly shorter than the recursive function:

f=n=>n?" ".repeat(--n)+`/\\
`+f(n).replace(/\S.+/g,x=>n%2?x+" \\":"/ "+x):""


答:
Haskell, <s>117 107 105 97</s> 90 bytes

b!1=["/\\"]
b!n|m<-(1-b)!(n-1)=map(' ':)m++[[("/ "++),(++" \\")]!!b$last m]
(unlines.(1!))
```
<p>Try it on Ideone.
Edit: Saved 8 bytes with an idea from Neil.</p>
<p>Ungolfed version:</p>
<pre class="lang-haskell prettyprint-override"><code>p b 1 = ["/\\"]
p b n = let m = p (1-b) (n-1)
            k = last m
            r = map (' ':) m
        in if b == 1
           then r ++ [k ++ " \\"]
           else r ++ ["/ " ++ k]
f n = unlines(p 1 n)
</code>```

Recursive approach. The shape for n is generated by adding a space in front of each line of the n-1 shape and taking the last line of n-1 and add "/ " before if n is odd or " \" after if n is even ... or so I thought before noticing that this last step is reversed for all recursive steps when the final n is odd. Therefore a flag b is passed which alternates each recursive call and determines if the next mountain part is added left or right.

Title: Draw some mountain peaks

Body:
Haskell, <s>117 107 105 97</s> 90 bytes

b!1=["/\\"]
b!n|m<-(1-b)!(n-1)=map(' ':)m++[[("/ "++),(++" \\")]!!b$last m]
(unlines.(1!))

Try it on Ideone.
Edit: Saved 8 bytes with an idea from Neil.

Ungolfed version:

p b 1 = ["/\\"]
p b n = let m = p (1-b) (n-1)
            k = last m
            r = map (' ':) m
        in if b == 1
           then r ++ [k ++ " \\"]
           else r ++ ["/ " ++ k]
f n = unlines(p 1 n)

Recursive approach. The shape for n is generated by adding a space in front of each line of the n-1 shape and taking the last line of n-1 and add "/ " before if n is odd or " \" after if n is even ... or so I thought before noticing that this last step is reversed for all recursive steps when the final n is odd. Therefore a flag b is passed which alternates each recursive call and determines if the next mountain part is added left or right.


答:
Batch, 202 bytes

```<code>@echo off
set/af=%1^&1
set m=/\
set s=
for /l %%i in (2,1,%1)do call set s= %%s%%
for /l %%i in (2,1,%1)do call:l
:l
echo %s%%m%
set s=%s:~1%
set/af^^=1
if %f%==1 (set m=%m% \)else set m=/ %m%
</code>```

Takes input as a command-line parameter. Falls through to execute the last loop.

Title: Draw some mountain peaks

Body:
Batch, 202 bytes

@echo off
set/af=%1^&1
set m=/\
set s=
for /l %%i in (2,1,%1)do call set s= %%s%%
for /l %%i in (2,1,%1)do call:l
:l
echo %s%%m%
set s=%s:~1%
set/af^^=1
if %f%==1 (set m=%m% \)else set m=/ %m%

Takes input as a command-line parameter. Falls through to execute the last loop.


问:
Can you outgolf me? (Cops section)

Cops section

The robbers section can be found here.

Thanks to FryAmTheEggman, Peter Taylor, Nathan Merrill, xnor, Dennis, Laikoni and Mego for their contributions.

Challenge

Your task is to write 2 different programs (full programs/functions/etc.) in the same language and the same version (e.g. Python 3.5 ≠ Python 3.4, so that is not allowed), and when given n (using STDIN/function arguments/etc.), compute a(n) where a is an OEIS sequence of your choice. One of those programs is shorter than the other. You only need to submit the longer program of the two. The other one needs to be saved in case of not being cracked after 7 days. Your submission is cracked when your program has been outgolfed (whether it is by 1 byte or more).

For example, if the task you chose was to perform 2 × n, this could be a valid submission (in Python 2):

Python 2, 16 bytes, score = 15 / 16 = 0.9375

```<code>print(2*input())
</code>```

Computes A005843, (offset = 0).

If your submission has been cracked, then you need to state that in your header like so:

Python 2, 16 bytes, score = 15 / 16 = 0.9375, [cracked] + link

```<code>print(2*input())
</code>```

Computes A005843, (offset = 0).

Offset

This can be found on every OEIS page. For example, for A005843, the offset is 0,2. We only need to use the first one, which is 0. This means that the function is defined for all numbers ≥ 0.

In other words, the function OEIS(n) starts with n = 0. Your program needs to work for all cases given by OEIS.

More information can be found here.

Scoring

The score you get for your submission is equal to the following formula:

Score = Length (in bytes) of secret code ÷ Length (in bytes) of public code

The example above has the score 15 ÷ 16 = 0.9375.

The submission with the lowest score wins. Only submissions that have posted their solution will be eligible for winning.

Rules

The task you need to do is an OEIS sequence of your choice.

Given n, output OEIS(n). Deviation is not allowed, so you need to produce the exact same sequence (when given n, you need to output OEIS(n)).

Submissions that are not cracked within a period of 7 days are considered safe after the solution has been posted (submissions older than 7 days that do not have their solution posted are still vulnerable in being cracked).

In your submission, you need to post the following things: language name, byte count, full code, so no pastebin links etc. (to prevent answers like Unary), OEIS sequence, score with lengths of both programs and additionally, the encoding that is used.

Note: the same sequence cannot be posted twice in the same language. (For example, if the sequence A005843 has been done in Pyth, you cannot use Pyth again for that same sequence.)

Input and output are both in decimal (base 10)

Leaderboard

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

Uncracked submissions

 Language	 Score	 User

Sort by: score creation

Safe submissions

 Language	 Score	 User

```

Note

This challenge is finished. The final winner is feersum with his Seed answer. Congratulations! :).

You can still submit new cops, but be aware that they are no longer competing.

答:
Seed, 5861 bytes, score = 5012 / 5861 = 0.85

The sequence is primes (A000040) with offset 1. a(1) = 2, a(2) = 3, a(3) = 5 etc.

```<code>106 [encoded data, 5857 characters]
</code>```

The Befunge-98 programs were tested with this interpreter.

Solution:

```<code>62 [encoded data, 5009 characters]
</code>```

Title: Can you outgolf me? (Cops section)

Body:
Seed, 5861 bytes, score = 5012 / 5861 = 0.85

The sequence is primes (A000040) with offset 1. a(1) = 2, a(2) = 3, a(3) = 5 etc.

106 [encoded data, 5857 characters]

The Befunge-98 programs were tested with this interpreter.

Solution:

62 [encoded data, 5009 characters]