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

答:
Pyth - 21  bytes

The case of palindromes never running out really cost me, will look for a better way.

```<code>.xxK.uhc2NQ)hf!_ITKlK
</code>```

Test Suite.

Title: What degree is this palindrome?

Body:
Pyth - 21  bytes

The case of palindromes never running out really cost me, will look for a better way.

.xxK.uhc2NQ)hf!_ITKlK

Test Suite.


ContentLicense: CC BY-SA 3.0

Title: What degree is this palindrome?

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

Body:
JavaScript (ES6), 85 bytes

f=s=>s[1]?(t=s.slice(0,l=-~s.length/2))==[...s.slice(-l)].reverse().join``?1+f(t):0:1


答:
Haskell, 58 bytes

```<code>p[a]=1
p a|reverse a==a=1+p(take(div(1+length a)2)a)
p _=0
</code>```

Title: What degree is this palindrome?

Body:
Haskell, 58 bytes

p[a]=1
p a|reverse a==a=1+p(take(div(1+length a)2)a)
p _=0


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

答:
reticular, 30 bytes

```<code>in v
?v$>1+d3,qds:3@cQm*
;\$o
</code>```

Try it online!

Explanation

1: initialization

```<code>in v
</code>```

This converts the input to a number, then goes down (v)

2: loop

```<code>?v$>1+d3,qds:3@cQm*
   >                 go right!              [n]
    1+               add 1                  [n+1]
      d3,            duplicate and mod 3    [n+1, (n+1)%3]
         qd          reverse and duplicate  [(n+1)%3, n+1, n+1]
           s         cast to string         [(n+1)%3, n+1, `n+1`]
            :3@c     count numbers of "3"   [(n+1)%3, n+1, `n+1`.count(3)]
                Qm*  negate and rotate      [n+1, continue?]
?v                   terminate if continue
  $                  drop continue
</code>```

3: final

```<code>;\$o
 \$o  drop and output
;     terminate
</code>```

Title: Count without 3

Body:
reticular, 30 bytes

in v
?v$>1+d3,qds:3@cQm*
;\$o

Try it online!

Explanation

1: initialization

in v

This converts the input to a number, then goes down (v)

2: loop

?v$>1+d3,qds:3@cQm*
   >                 go right!              [n]
    1+               add 1                  [n+1]
      d3,            duplicate and mod 3    [n+1, (n+1)%3]
         qd          reverse and duplicate  [(n+1)%3, n+1, n+1]
           s         cast to string         [(n+1)%3, n+1, `n+1`]
            :3@c     count numbers of "3"   [(n+1)%3, n+1, `n+1`.count(3)]
                Qm*  negate and rotate      [n+1, continue?]
?v                   terminate if continue
  $                  drop continue

3: final

;\$o
 \$o  drop and output
;     terminate


答:
Python 2, <s>94</s> <s>87</s> 77 bytes

The recursive approach... this currently assumes that empty & single letter strings get a score of 1.

```<code>def P(x,c=0):a=len(x);return c+(a<2)if(x[::-1]!=x)+(a<2)else P(x[:-~a/2],-~c)
</code>```

Try it online!

Title: What degree is this palindrome?

Body:
Python 2, <s>94</s> <s>87</s> 77 bytes

The recursive approach... this currently assumes that empty & single letter strings get a score of 1.

def P(x,c=0):a=len(x);return c+(a<2)if(x[::-1]!=x)+(a<2)else P(x[:-~a/2],-~c)

Try it online!


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

```

Body:
Ruby 44 bytes

m=->(n,s,f){(s..f).count{|x|x.to_s[/#{n}/]}}

Test Cases:

m.(3,1,100)     #=> 19
m.(3,3,93)      #=> 19
m.(12,-200,200) #=> 24
m.(123,1,3)     #=>  0
m.(3,33,34)     #=>  2
m.(0,-1,1)      #=>  1
m.(127,-12,27)  #=>  0


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:
GolfSharp, 41 bytes

(w,q,e)=>r(q,1+e-q).w(n=>n.T().I(w)).L();

A 45 byte version:

(w,q,e)=>r(q,1+e-q).w(n=>n.T().I(w.T())).L();

ContentLicense: CC BY-SA 4.0


问:
Trick or Treat polyglot
Since Halloween is coming up I thought I might start a fun little code golf challenge!

The challenge is quite simple. You have to write a program that outputs either trick or treat.

"The twist?" you may ask. Well let me explain:

Your program has to do the following:

Be compilable/runnable in two different languages. Different versions of the same language don't count.

When you run the program in one language it should output trick and the other should output treat. The case is irrelevant and padding the string with whitespace characters are allowed (see examples).

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

A few explanations:

Valid outputs (Just for the words not for running the code in the two languages. Also adding quotes to signalize the beginning or end of the output. Do not include them in your solution!):

```<code>"trick"

"Treat"

"    TReAt"

"
     tRICk          "
</code>```

Invalid outputs:

```<code>"tri ck"

"tr
eat"

"trck"
</code>```

I'm interested to see what you can come up with! Happy Golfing!

I'd like to note that this is my first challenge so if you have suggestions on this question please leave them in the form of a comment.

Leaderboards

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

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

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

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

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

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

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

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

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

var QUESTION_ID=97472,OVERRIDE_USER=23417;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,TAGS_REG = /(<([^>]+)>)/ig;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:400px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
JavaScript/Ruby - 32 bytes

(Assuming Spidermonkey-like output function print)

```<code>a=1
print(["trick","treat"][--a])
</code>```

Ruby -- is double negative, while in JavaScript it is decrement;

Title: Trick or Treat polyglot

Body:
JavaScript/Ruby - 32 bytes

(Assuming Spidermonkey-like output function print)

a=1
print(["trick","treat"][--a])

Ruby -- is double negative, while in JavaScript it is decrement;


答:
05AB1E, 14 bytes

```<code>[ÐÂÊ#¼g#2ä¬])\
</code>```

Uses the CP-1252 encoding. Try it online!

Title: What degree is this palindrome?

Body:
05AB1E, 14 bytes

[ÐÂÊ#¼g#2ä¬])\

Uses the CP-1252 encoding. Try it online!


答:
JavaScript (with SpiderMonkey print)/Python - 32 bytes

```<code>a=1
print(["trick","treat"][--a])
</code>```

Title: Trick or Treat polyglot

Body:
Since Halloween is coming up I thought I might start a fun little code golf challenge!

The challenge is quite simple. You have to write a program that outputs either trick or treat.

"The twist?" you may ask. Well let me explain:

Your program has to do the following:

Be compilable/runnable in two different languages. Different versions of the same language don't count.

When you run the program in one language it should output trick and the other should output treat. The case is irrelevant and padding the string with whitespace characters are allowed (see examples).

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

A few explanations:

Valid outputs (Just for the words not for running the code in the two languages. Also adding quotes to signalize the beginning or end of the output. Do not include them in your solution!):

```<code>"trick"

"Treat"

"    TReAt"

"
     tRICk          "
</code>```

Invalid outputs:

```<code>"tri ck"

"tr
eat"

"trck"
</code>```

I'm interested to see what you can come up with! Happy Golfing!

I'd like to note that this is my first challenge so if you have suggestions on this question please leave them in the form of a comment.

Leaderboards

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

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

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

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

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

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

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

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

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

var QUESTION_ID=97472,OVERRIDE_USER=23417;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,TAGS_REG = /(<([^>]+)>)/ig;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:400px;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:
JavaScript (with SpiderMonkey print)/Python - 32 bytes

a=1
print(["trick","treat"][--a])


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

答:
Pyth, <s>8</s> 7 bytes

```<code><zh/lz2
</code>```

Saved 1 with thanks to @Steven H

Not the shortest Pyth answer (by half) but I'm making an effort to learn the language and this is my first post using it. Posted as much for comments and feedback as anything. It's also the first Pyth program that I have actually got to work :)

Now I just need to work out how the 4 byte answer from @Maltysen works :-)

Title: Depalindromize this string!

Body:
Pyth, <s>8</s> 7 bytes

<zh/lz2

Saved 1 with thanks to @Steven H

Not the shortest Pyth answer (by half) but I'm making an effort to learn the language and this is my first post using it. Posted as much for comments and feedback as anything. It's also the first Pyth program that I have actually got to work :)

Now I just need to work out how the 4 byte answer from @Maltysen works :-)


答:
Java 7,147 bytes

int c(String s,int t){int l=s.length();return l<2?t+1:s.equals(new StringBuilder(s).reverse().toString())?c(s.substring(0,l%2>0?l/2+1:l/2),++t):t;}
```

Title: What degree is this palindrome?


答:
JavaScript, 35 bytes

f=n=>++n%3&&!(n+"").match(3)?n:f(n)
```

Try it online!

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:
JavaScript, 35 bytes

f=n=>++n%3&&!(n+"").match(3)?n:f(n)

Try it online!


问:
Interlace strings
Your challenge is to write a program or function that, when given two strings of equal length, swaps every other character and outputs/returns the resulting strings in either order.

Examples

```<code>"Hello," "world!" --> "Hollo!" "werld,"
"code" "golf" --> "codf" "gole"
"happy" "angry" --> "hnpry" "aagpy"
"qwerty" "dvorak" --> "qvertk" "dworay"
"1, 2, 3" "a, b, c" --> "1, b, 3" "a, 2, c"
"3.141592653589" "2.718281828459" --> "3.111291623489" "2.748582858559"
"DJMcMayhem" "trichoplax" --> "DrMcMoylex" "tJichapham"
"Doorknob" "Downgoat" --> "Doonkoot" "Dowrgnab"
"Halloween" "Challenge" --> "Hhlloeegn" "Caallwnee"
</code>```

Rules

The strings will only contain ASCII chars (32-126).

The strings will always be the same length, and will never be empty.

You may accept input in any suitable format: separate parameters, items in an array, separated by one or more newlines, even concatenated. The only restriction is that one string must come fully before the other (e.g. a1\nb2\nc3 for "abc", "123" is invalid).

The output may be in either order (i.e. you can start swapping from the first or the second char), and in any valid format mentioned above. (2-item array, separated by newline(s), concatenated, etc.)

Scoring

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

答:
Scala, 85 bytes

```<code>(_:String)zip(_:String)zip(Stream from 0)map{case(t,z)=>if(z%2==0)t else t.swap}unzip
</code>```

take an anonymous string parameter, zip it with another string parameter, zip it with an stream of natural numbers, swap every second tuple of chars and unzip to get a tuple of sequences of chars

Title: Interlace strings

Body:
Scala, 85 bytes

(_:String)zip(_:String)zip(Stream from 0)map{case(t,z)=>if(z%2==0)t else t.swap}unzip

take an anonymous string parameter, zip it with another string parameter, zip it with an stream of natural numbers, swap every second tuple of chars and unzip to get a tuple of sequences of chars


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:
Lua, 28 bytes

x=...print(x:sub(1,#x//2+1))


答:
JavaScript (Spidermonkey print) (treat), Python (trick) - 34 bytes

```<code>a=1//2
print(["trick","treat"][a])
</code>```

// is a comment in JavaScript, and truncating integer division in Python.

Title: Trick or Treat polyglot

Body:
JavaScript (Spidermonkey print) (treat), Python (trick) - 34 bytes

a=1//2
print(["trick","treat"][a])

// is a comment in JavaScript, and truncating integer division in Python.


答:
CJam, 7 bytes

```<code>r_,-2/<
</code>```

Try it online!

Title: Depalindromize this string!

Body:
CJam, 7 bytes

r_,-2/<

Try it online!


答:
Perl, 14 + 3 (-lF flag) = <s>19</s> 17 bytes

For 5.20.0+:

```<code>perl -lF -E 'say@F[0..@F/2]'
</code>```

For 5.10.0+ (19 bytes):

```<code>perl -nlaF -E 'say@F[0..@F/2]'
</code>```

Ungolfed:

while (<>) {             # -n flag (implicitly sets by -F in 5.20.0+)
    chomp($_)            # -l flag
    @F = split('', $_);  # -aF flag (implicitly sets by -F in 5.20.0+)
    say(@F[0 .. (scalar(@F) / 2)]);
}
```

Thanx to @simbabque.

Title: Depalindromize this string!

Body:
Perl, 14 + 3 (-lF flag) = <s>19</s> 17 bytes

For 5.20.0+:

perl -lF -E 'say@F[0..@F/2]'

For 5.10.0+ (19 bytes):

perl -nlaF -E 'say@F[0..@F/2]'

Ungolfed:

while (<>) {             # -n flag (implicitly sets by -F in 5.20.0+)
    chomp($_)            # -l flag
    @F = split('', $_);  # -aF flag (implicitly sets by -F in 5.20.0+)
    say(@F[0 .. (scalar(@F) / 2)]);
}

Thanx to @simbabque.


Title: What degree is this palindrome?

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

Body:
Perl, 53 bytes

52 bytes of code + 1 byte for -p.

$\++while s/^((.+).?)(??{reverse$2})$/$1/||s/^.$//}{

To run it :

perl -pE '$\++while s/^((.+).?)(??{reverse$2})$/$1/||s/^.$//}{' <<< "zzzzz"


答:
Python / Japt, 22 bytes

```<code>1
print"trick";"treat"
</code>```

Python

This should be fairly obvious: print"trick" prints trick; 1 and "treat" don't do anything.

Japt

This code transpiles to

```<code>1
.p("r".i("n".t(("trick"))));("treat")
</code>```

The result of last expression is automatically sent to STDOUT, so this prints treat.

Title: Trick or Treat polyglot

Body:
Python / Japt, 22 bytes

1
print"trick";"treat"

Python

This should be fairly obvious: print"trick" prints trick; 1 and "treat" don't do anything.

Japt

This code transpiles to

1
.p("r".i("n".t(("trick"))));("treat")

The result of last expression is automatically sent to STDOUT, so this prints treat.


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

答:
Haskell, <s>29</s> <s>35</s> 32 bytes

```<code>a%b=a:b%(a++b)
(`take`("a"%"b"))
</code>```

Simple recursion.

For reference: the old version (an adaption of this answer),
concatenated the strings in the wrong order, so I had to add a flip(...) which made it too long (35 bytes).

```<code>f="a":scanl(flip(++))"b"f
(`take`f)
</code>```

Title: Print a letter Fibonacci

Body:
Haskell, <s>29</s> <s>35</s> 32 bytes

a%b=a:b%(a++b)
(`take`("a"%"b"))

Simple recursion.

For reference: the old version (an adaption of this answer),
concatenated the strings in the wrong order, so I had to add a flip(...) which made it too long (35 bytes).

f="a":scanl(flip(++))"b"f
(`take`f)


答:
V, 18 bytes

```<code>ia
bkÀñyjGpgJkñdj
</code>```

Try it online!

Or, the more readable version:

```<code>ia
b<esc>kÀñyjGpgJkñdj
</code>```

Explanation:

```<code>ia
b<esc>          " Insert the starting text and escape back to normal mode
k               " Move up a line
 Àñ       ñ     " Arg1 times:
   yj           "   Yank the current line and the line below
     G          "   Move to the end of the buffer
      p         "   Paste what we just yanked
       gJ       "   Join these two lines
         k      "   Move up one line
           dj   " Delete the last two lines
</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:
V, 18 bytes

ia
bkÀñyjGpgJkñdj

Try it online!

Or, the more readable version:

ia
b<esc>kÀñyjGpgJkñdj

Explanation:

ia
b<esc>          " Insert the starting text and escape back to normal mode
k               " Move up a line
 Àñ       ñ     " Arg1 times:
   yj           "   Yank the current line and the line below
     G          "   Move to the end of the buffer
      p         "   Paste what we just yanked
       gJ       "   Join these two lines
         k      "   Move up one line
           dj   " Delete the last two lines


答:
Python 2, <s>49</s> <s>44</s> 42 bytes

```<code>f=lambda x:'3'[:~x%3]in`~x`and f(x+1)or-~x
</code>```

The other Python entry beats this (edit: not any more :-D), but I posted it because I rather like its recursive approach.
Thanks to Mitch Schwarz and Erik the Golfer for helping me make this shorter.

Title: Count without 3

Body:
Python 2, <s>49</s> <s>44</s> 42 bytes

f=lambda x:'3'[:~x%3]in`~x`and f(x+1)or-~x

The other Python entry beats this (edit: not any more :-D), but I posted it because I rather like its recursive approach.
Thanks to Mitch Schwarz and Erik the Golfer for helping me make this shorter.


答:
Befunge, <s>24</s> 22 bytes

```<code>~:0`!#v_\1+
0:-2,\_@#`
</code>```

Try it online!

Befunge has no string or array type so the everything is done on the stack one character at a time. The first loop (on the top line) counts the number of characters read (swapping with less than 2 elements in the stack produces an initial 0). The second (on the middle line) prints characters while counting down twice as fast. As a result only the last half of the input is printed, but LIFO so it's in the correct order.

Thanks to Brian Gradin for a better version of the first loop.

Title: Depalindromize this string!

Body:
Befunge, <s>24</s> 22 bytes

~:0`!#v_\1+
0:-2,\_@#`

Try it online!

Befunge has no string or array type so the everything is done on the stack one character at a time. The first loop (on the top line) counts the number of characters read (swapping with less than 2 elements in the stack produces an initial 0). The second (on the middle line) prints characters while counting down twice as fast. As a result only the last half of the input is printed, but LIFO so it's in the correct order.

Thanks to Brian Gradin for a better version of the first loop.


问:
shortest progam to scan a line and print it using befunge!
well, I'm newly introduced to befunge.
it seems to be an amazing language but a bit hard to start with! anyway after about 2 hours of hard work I've created a code which could read a line from stdin and write same line into stdout(I'm using line -1 as buffer in this code):

```<code>0> :~:a-#v_$$v vg-10:-1< >$>:#,_@
 ^+1p-10\<   >0>\:    #^_^
</code>```

since I'm new to this language I wanted to know if there is a shorter code to do such a thing.
I'm currently using Rc/funge-98 v2 interpreter. note that none-trailing whitespaces are counted in your code.

答:
Befunge-98, 4

~,#@

Try it online!

It works because ~ acts like r when there is no more input (credit to David Holderness for finding this in the funge-98 spec)


答:
05AB1E, <s>12</s> 11 bytes

Thanks to Emigna for saving a byte!

```<code>'a='b¹GD=Š«
</code>```

Uses the CP-1252 encoding. Try it online!

Title: Print a letter Fibonacci

Body:
05AB1E, <s>12</s> 11 bytes

Thanks to Emigna for saving a byte!

'a='b¹GD=Š«

Uses the CP-1252 encoding. Try it online!


Title: Print a letter Fibonacci

Body:
Python 2, 55 bytes

def f(n):m='a','b';exec'print m[-2];m+=m[-2]+m[-1],;'*n


答:
Pyth, 17 bytes

```<code>J,\a\bjP.U=+Js>2J
</code>```

A program that takes input of an integer and prints the result.

Try it online!

How it works

```<code>J,\a\bjP.U=+Js>2J  Program. Input: Q
 ,\a\b             Yield the two element list ['a', 'b']
J                  Assign to J
        .U         Reduce over [0, 1, 2, 3, ..., Q] (implicit input):
          =J+        J = J +
              >2J     the last two elements of J
             s        concatenated
       P           All of that except the last element
      j            Join on newlines
                   Implicitly print
</code>```

Title: Print a letter Fibonacci

Body:
Pyth, 17 bytes

J,\a\bjP.U=+Js>2J

A program that takes input of an integer and prints the result.

Try it online!

How it works

J,\a\bjP.U=+Js>2J  Program. Input: Q
 ,\a\b             Yield the two element list ['a', 'b']
J                  Assign to J
        .U         Reduce over [0, 1, 2, 3, ..., Q] (implicit input):
          =J+        J = J +
              >2J     the last two elements of J
             s        concatenated
       P           All of that except the last element
      j            Join on newlines
                   Implicitly print


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

答:
Befunge, 37 bytes

```<code>~:0`!#v_:,
  >:#,_@_,#:>
,:_v#!`0:~
</code>```

Try it online!

The top line pushes and prints every character of input. The second line (before the @) prints the stack in reverse, but we enter at the contional _ to consume the -1 generated when finish reading input. The other half of the code (including those ugly trailing newlines) makes the source a palindrome, but nevers runs.

Title: Palindromic palindrome generator

Body:
Befunge, 37 bytes

~:0`!#v_:,
  >:#,_@_,#:>
,:_v#!`0:~

Try it online!

The top line pushes and prints every character of input. The second line (before the @) prints the stack in reverse, but we enter at the contional _ to consume the -1 generated when finish reading input. The other half of the code (including those ugly trailing newlines) makes the source a palindrome, but nevers runs.


问:
1, 2, 3, 4, 5, Shaggy
This is my first code golf exercise for you:
Your input is two integers n and k. You can assume n >= 1 and k >= 1
You have to output all numbers from 1 to n (inclusively) and replace every element that is a multiple of k or that contains k with "Shaggy".

you can take the input in any convenient form and output it in a human readable form (seperators can be whitespaces, commas or whatever)

Standard loop holes are forbidden. Functions or programs are acceptable. Shortest code in byte wins!

This is different from the "Bzzt"-game, as this takes a variable "Bzzt" parameter, which, for values>=10, may increase the difficulty in some languages.

Examples:

```<code>Input: 20 6
Output: 1 2 3 4 5 Shaggy 7 8 9 10 11 Shaggy 13 14 15 Shaggy 17 Shaggy 19 20

Input: 21 4
Output: 1 2 3 Shaggy 5 6 7 Shaggy 9 10 11 Shaggy 13 Shaggy 15 Shaggy 17 18 19 Shaggy 21

Input: 212 11
Output: 1 2 3 4 5 6 7 8 9 10 Shaggy 12 13 14 15 16 17 18 19 20 21 Shaggy 23 24 25 26 27 28 29 30 31 32 Shaggy 34 35 36 37 38 39 40 41 42 43 Shaggy 45 46 47 48 49 50 51 52 53 54 Shaggy 56 57 58 59 60 61 62 63 64 65 Shaggy 67 68 69 70 71 72 73 74 75 76 Shaggy 78 79 80 81 82 83 84 85 86 87 Shaggy 89 90 91 92 93 94 95 96 97 98 Shaggy 100 101 102 103 104 105 106 107 108 109 Shaggy Shaggy Shaggy Shaggy Shaggy Shaggy Shaggy Shaggy Shaggy Shaggy 120 Shaggy 122 123 124 125 126 127 128 129 130 131 Shaggy 133 134 135 136 137 138 139 140 141 142 Shaggy 144 145 146 147 148 149 150 151 152 153 Shaggy 155 156 157 158 159 160 161 162 163 164 Shaggy 166 167 168 169 170 171 172 173 174 175 Shaggy 177 178 179 180 181 182 183 184 185 186 Shaggy 188 189 190 191 192 193 194 195 196 197 Shaggy 199 200 201 202 203 204 205 206 207 208 Shaggy 210 Shaggy 212
</code>```

答:
Python 2, <s>64</s> 63 bytes

Anonymous function with arguments n and k, returns the list to output.

lambda n,k:[[i,'Shaggy'][i%k<1or`k`in`i`]for i in range(1,n+1)]
```
<p>Alternatively, a function which prints to <code>STDOUT</code> for the same bytecount:</p>
<pre class="lang-py prettyprint-override"><code>def f(n,k,i=1):exec"print[i,'Shaggy'][i%k<1or`k`in`i`];i+=1;"*n
</code>```

Title: 1, 2, 3, 4, 5, Shaggy

Body:
Python 2, <s>64</s> 63 bytes

Anonymous function with arguments n and k, returns the list to output.

lambda n,k:[[i,'Shaggy'][i%k<1or`k`in`i`]for i in range(1,n+1)]

Alternatively, a function which prints to STDOUT for the same bytecount:

def f(n,k,i=1):exec"print[i,'Shaggy'][i%k<1or`k`in`i`];i+=1;"*n


答:
MATL, 14 bytes

```<code>97c98ci2-:"yyh
</code>```

Try it online!

```<code>97c     % Push 'a'
98c     % Push 'b'
i2-     % Input number. Subtract 2
:"      % Repeat that many times
  yy    %   Duplicate the top two elements
  h     %   Concatenate them
</code>```

Title: Print a letter Fibonacci

Body:
MATL, 14 bytes

97c98ci2-:"yyh

Try it online!

97c     % Push 'a'
98c     % Push 'b'
i2-     % Input number. Subtract 2
:"      % Repeat that many times
  yy    %   Duplicate the top two elements
  h     %   Concatenate them


答:
Cubix / Japt, 24 bytes

```<code>WHAT"kcirt"u@!C;Co} `É.t
</code>```

Test Cubix | Test Japt

The . represents the unprintable char U+0084.

Japt

Before running Japt code, it is first transpiled to JavaScript. The various features transpile roughly to:

```<code>WHAT    "kcirt"u  @               !C;       Co      `É.t
W,H,A,T,"kcirt".u(function(X,Y,Z){!C;return C.o()}),"treat"
</code>```

The the code is evaluated, and the result of the last expression is sent to STDOUT. W,H,A,T are variables, but they're effectively no-ops since we don't do anything with them. "kcirt".u() makes the string uppercase, ignoring the function, but again, this is discarded. The only thing that matters is the "treat" at the end; this is printed, end then the program ends.

Cubix

Before the code is run, all whitespace is removed, and the code is transformed into the smallest cube net possible, padded with . no-ops. This particular program becomes:

```<code>    W H
    A T
" k c i r t " u
@ ! C ; C o } `
    É .
    t .
</code>```

Then the code is run like a regular 2D language, with the IP (instruction pointer) starting at the top-left corner of the leftmost face. Here's what happens:

"kcirt" - Push the char codes of these letters to the stack.

u - Make a U-turn to the right, going down a row in the process.

` - Not implemented, so a no-op.

} - Another no-op.

o - Output the char-code on top of the stack (t).

C - Another no-op.

; - Remove the top item.

C - Another no-op.

! - If the top item is non-zero, skip the next instruction (@).

Since the top item is non-zero, the IP jumps the @ and wraps back around to the `. This repeats until the last character has been outputted, at which point ! fails and the IP hits @, ending the program.

Old solution, 25 bytes

```<code>"treat"//"kcirt"under@!;o
</code>```

Test Cubix | Test Japt

Japt

This is very simple: // and everything after is a comment, so the only thing evaluated is "treat". This is implicitly printed to STDOUT.

Cubix

The code is expanded to the following cube net:

```<code>      " t r
      e a t
      " / /
" k c i r t " u n d e r
@ ! ; o . . . . . . . .
. . . . . . . . . . . .
      . . .
      . . .
      . . .
</code>```

Then the code is run like a regular 2D language, with the IP (instruction pointer) starting at the top-left corner of the leftmost face. Here's what happens:

"kcirt" - Push the char codes of these letters to the stack.

u - Make a U-turn to the right, going down a row in the process.

.... - A bunch of no-ops.

o - Output the char-code on top of the stack (t).

; - Remove the top item.

! - If the top item is non-zero, skip the next instruction.

The IP then wraps around to the right, so these last 3 instructions repeat until the stack is empty. Then ! fails, so the IP lands on @, which ends the program. The Japt code is conveniently contained on the top face and never gets run.

Title: Trick or Treat polyglot

Body:
Since Halloween is coming up I thought I might start a fun little code golf challenge!

The challenge is quite simple. You have to write a program that outputs either trick or treat.

"The twist?" you may ask. Well let me explain:

Your program has to do the following:

Be compilable/runnable in two different languages. Different versions of the same language don't count.

When you run the program in one language it should output trick and the other should output treat. The case is irrelevant and padding the string with whitespace characters are allowed (see examples).

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

A few explanations:

Valid outputs (Just for the words not for running the code in the two languages. Also adding quotes to signalize the beginning or end of the output. Do not include them in your solution!):

```<code>"trick"

"Treat"

"    TReAt"

"
     tRICk          "
</code>```

Invalid outputs:

```<code>"tri ck"

"tr
eat"

"trck"
</code>```

I'm interested to see what you can come up with! Happy Golfing!

I'd like to note that this is my first challenge so if you have suggestions on this question please leave them in the form of a comment.

Leaderboards

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

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

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

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

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

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

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

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

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

var QUESTION_ID=97472,OVERRIDE_USER=23417;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,TAGS_REG = /(<([^>]+)>)/ig;```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body{text-align:left!important}#answer-list,#language-list{padding:10px;width:400px;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:
Cubix / Japt, 24 bytes

WHAT"kcirt"u@!C;Co} `É.t

Test Cubix | Test Japt

The . represents the unprintable char U+0084.

Japt

Before running Japt code, it is first transpiled to JavaScript. The various features transpile roughly to:

WHAT    "kcirt"u  @               !C;       Co      `É.t
W,H,A,T,"kcirt".u(function(X,Y,Z){!C;return C.o()}),"treat"

The the code is evaluated, and the result of the last expression is sent to STDOUT. W,H,A,T are variables, but they're effectively no-ops since we don't do anything with them. "kcirt".u() makes the string uppercase, ignoring the function, but again, this is discarded. The only thing that matters is the "treat" at the end; this is printed, end then the program ends.

Cubix

Before the code is run, all whitespace is removed, and the code is transformed into the smallest cube net possible, padded with . no-ops. This particular program becomes:

    W H
    A T
" k c i r t " u
@ ! C ; C o } `
    É .
    t .

Then the code is run like a regular 2D language, with the IP (instruction pointer) starting at the top-left corner of the leftmost face. Here's what happens:

"kcirt" - Push the char codes of these letters to the stack.

u - Make a U-turn to the right, going down a row in the process.

` - Not implemented, so a no-op.

} - Another no-op.

o - Output the char-code on top of the stack (t).

C - Another no-op.

; - Remove the top item.

C - Another no-op.

! - If the top item is non-zero, skip the next instruction (@).

Since the top item is non-zero, the IP jumps the @ and wraps back around to the `. This repeats until the last character has been outputted, at which point ! fails and the IP hits @, ending the program.

Old solution, 25 bytes

"treat"//"kcirt"under@!;o

Test Cubix | Test Japt

Japt

This is very simple: // and everything after is a comment, so the only thing evaluated is "treat". This is implicitly printed to STDOUT.

Cubix

The code is expanded to the following cube net:

      " t r
      e a t
      " / /
" k c i r t " u n d e r
@ ! ; o . . . . . . . .
. . . . . . . . . . . .
      . . .
      . . .
      . . .

Then the code is run like a regular 2D language, with the IP (instruction pointer) starting at the top-left corner of the leftmost face. Here's what happens:

"kcirt" - Push the char codes of these letters to the stack.

u - Make a U-turn to the right, going down a row in the process.

.... - A bunch of no-ops.

o - Output the char-code on top of the stack (t).

; - Remove the top item.

! - If the top item is non-zero, skip the next instruction.

The IP then wraps around to the right, so these last 3 instructions repeat until the stack is empty. Then ! fails, so the IP lands on @, which ends the program. The Japt code is conveniently contained on the top face and never gets run.


答:
Lua, <s>71</s> 70 Bytes

Saved a byte thanks to Flp.Tkc

Getting in before Jelly or Pyth or similar can swoop in and destroy my byte count.

```<code>a,b=...for i=1,a do print(((i..""):find(b)or i%b<1)and"Shaggy"or i)end
</code>```

Ungolfed with comments

```<code>local a,b = ...                         -- Command Line Input
for i=1, a do                           -- For all numbers between 1 and a
    print(                              -- Print with newlines...
            ((i..""):find(b) or i%b<1)  -- if the String version of i contains b, or if the remainder when i is divided by b == 0
            and "Shaggy"                -- then Shaggy
            or i                        -- Else i
        )
end
</code>```

Title: 1, 2, 3, 4, 5, Shaggy

Body:
This is my first code golf exercise for you:
Your input is two integers n and k. You can assume n >= 1 and k >= 1
You have to output all numbers from 1 to n (inclusively) and replace every element that is a multiple of k or that contains k with "Shaggy".

you can take the input in any convenient form and output it in a human readable form (seperators can be whitespaces, commas or whatever)

Standard loop holes are forbidden. Functions or programs are acceptable. Shortest code in byte wins!

This is different from the "Bzzt"-game, as this takes a variable "Bzzt" parameter, which, for values>=10, may increase the difficulty in some languages.

Examples:

```<code>Input: 20 6
Output: 1 2 3 4 5 Shaggy 7 8 9 10 11 Shaggy 13 14 15 Shaggy 17 Shaggy 19 20

Input: 21 4
Output: 1 2 3 Shaggy 5 6 7 Shaggy 9 10 11 Shaggy 13 Shaggy 15 Shaggy 17 18 19 Shaggy 21

Input: 212 11
Output: 1 2 3 4 5 6 7 8 9 10 Shaggy 12 13 14 15 16 17 18 19 20 21 Shaggy 23 24 25 26 27 28 29 30 31 32 Shaggy 34 35 36 37 38 39 40 41 42 43 Shaggy 45 46 47 48 49 50 51 52 53 54 Shaggy 56 57 58 59 60 61 62 63 64 65 Shaggy 67 68 69 70 71 72 73 74 75 76 Shaggy 78 79 80 81 82 83 84 85 86 87 Shaggy 89 90 91 92 93 94 95 96 97 98 Shaggy 100 101 102 103 104 105 106 107 108 109 Shaggy Shaggy Shaggy Shaggy Shaggy Shaggy Shaggy Shaggy Shaggy Shaggy 120 Shaggy 122 123 124 125 126 127 128 129 130 131 Shaggy 133 134 135 136 137 138 139 140 141 142 Shaggy 144 145 146 147 148 149 150 151 152 153 Shaggy 155 156 157 158 159 160 161 162 163 164 Shaggy 166 167 168 169 170 171 172 173 174 175 Shaggy 177 178 179 180 181 182 183 184 185 186 Shaggy 188 189 190 191 192 193 194 195 196 197 Shaggy 199 200 201 202 203 204 205 206 207 208 Shaggy 210 Shaggy 212
</code>```

Body:
Lua, <s>71</s> 70 Bytes

Saved a byte thanks to Flp.Tkc

Getting in before Jelly or Pyth or similar can swoop in and destroy my byte count.

a,b=...for i=1,a do print(((i..""):find(b)or i%b<1)and"Shaggy"or i)end

Ungolfed with comments

local a,b = ...                         -- Command Line Input
for i=1, a do                           -- For all numbers between 1 and a
    print(                              -- Print with newlines...
            ((i..""):find(b) or i%b<1)  -- if the String version of i contains b, or if the remainder when i is divided by b == 0
            and "Shaggy"                -- then Shaggy
            or i                        -- Else i
        )
end


答:
CJam, <s>19</s> 17 bytes

```<code>'a'b{_@_n\+}ri*;;
</code>```

explanation

```<code>"a": Push character literal "a" onto the stack.
"b": Push character literal "b" onto the stack.
{_@_p\+}
    {: Block begin.
    _: duplicate top element on the stack
    @: rotate top 3 elements on the stack
    _: duplicate top element on the stack
    n: print string representation
    \: swap top 2 elements on the stack
    +: add, concat
    }: Block end.
r: read token (whitespace-separated)
i: convert to integer
*: multiply, join, repeat, fold (reduce)
;: pop and discard
;: pop and discard
</code>```

Title: Print a letter Fibonacci

Body:
CJam, <s>19</s> 17 bytes

'a'b{_@_n\+}ri*;;

explanation

"a": Push character literal "a" onto the stack.
"b": Push character literal "b" onto the stack.
{_@_p\+}
    {: Block begin.
    _: duplicate top element on the stack
    @: rotate top 3 elements on the stack
    _: duplicate top element on the stack
    n: print string representation
    \: swap top 2 elements on the stack
    +: add, concat
    }: Block end.
r: read token (whitespace-separated)
i: convert to integer
*: multiply, join, repeat, fold (reduce)
;: pop and discard
;: pop and discard


答:
Pyth, <s>25</s> 23 bytes

```<code>m?|!%dQ}`Q`d"Shaggy"dSE
</code>```

A program that takes input of two newline-separated integers k, n and prints a list.

Try it online!

How it works

```<code>m?|!%dQ}`Q`d"Shaggy"dSE  Program. Inputs: Q, E
m                    SE  Map over [1, 2, 3, 4, ..., E] with varaible d:
 ?                         If
    %dQ                    d % Q
   !                       negated is truthy (divisible by H)
  |                        or
        `Q                 str(Q)
       }                   is in
          `d               str(d):
            "Shaggy"         Yield "Shaggy"
                           Else:
                    d        Yield d
                           Implicitly print
</code>```

Title: 1, 2, 3, 4, 5, Shaggy

Body:
Pyth, <s>25</s> 23 bytes

m?|!%dQ}`Q`d"Shaggy"dSE

A program that takes input of two newline-separated integers k, n and prints a list.

Try it online!

How it works

m?|!%dQ}`Q`d"Shaggy"dSE  Program. Inputs: Q, E
m                    SE  Map over [1, 2, 3, 4, ..., E] with varaible d:
 ?                         If
    %dQ                    d % Q
   !                       negated is truthy (divisible by H)
  |                        or
        `Q                 str(Q)
       }                   is in
          `d               str(d):
            "Shaggy"         Yield "Shaggy"
                           Else:
                    d        Yield d
                           Implicitly print


答:
SQL (PostgreSQL flavour), 130 <s>136</s> bytes

Done as a prepared statement:

```<code>prepare p(int,int)as select CASE WHEN i%$2=0or i::char like'%'||$2||'%'THEN'Shaggy'else i::char end from generate_series(1,$1)a(i)
</code>```

This is executed in the following manner

```<code>execute p(20,6)
</code>```

and the result is output as rows.

Title: 1, 2, 3, 4, 5, Shaggy

Body:
SQL (PostgreSQL flavour), 130 <s>136</s> bytes

Done as a prepared statement:

prepare p(int,int)as select CASE WHEN i%$2=0or i::char like'%'||$2||'%'THEN'Shaggy'else i::char end from generate_series(1,$1)a(i)

This is executed in the following manner

execute p(20,6)

and the result is output as rows.


答:
Batch, <s>102</s> 93 bytes

```<code>@set a=a
@set b=b
@for /l %%i in (2,1,%1)do @call:l
:l
@echo %a%
@set a=%b%&set b=%a%%b%
</code>```

Fortunately variables are expanded for every line before assignments take effect, so I can set both a and b using their old values without needing a temporary. Edit: Saved 9 bytes thanks to @nephi12.

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:
Batch, <s>102</s> 93 bytes

@set a=a
@set b=b
@for /l %%i in (2,1,%1)do @call:l
:l
@echo %a%
@set a=%b%&set b=%a%%b%

Fortunately variables are expanded for every line before assignments take effect, so I can set both a and b using their old values without needing a temporary. Edit: Saved 9 bytes thanks to @nephi12.


答:
C, 122 bytes

```<code>f(n,k){int m,i;for(i=1;i<=n;++i){if(i%k){for(m=i;m>0;m/=10)if(m%10==k)goto l;printf("%d ",i);continue;}l:puts("Shaggy");}}
</code>```

Newlines and spaces both act as separators.

Title: 1, 2, 3, 4, 5, Shaggy

Body:
C, 122 bytes

f(n,k){int m,i;for(i=1;i<=n;++i){if(i%k){for(m=i;m>0;m/=10)if(m%10==k)goto l;printf("%d ",i);continue;}l:puts("Shaggy");}}

Newlines and spaces both act as separators.


答:
C#, 97 bytes

```<code>n=>k=>{var r="";for(int i=1;i<=n;i++)r+=i%k>0&&(i+"").IndexOf(k+"")<0?i+" ":"Shaggy ";return r;};
</code>```

Full program with ungolfed method and test cases:

```<code>using System;

namespace Shaggy
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<int,Func<int,string>>f= n=>k=>
            {
                var r = "";
                for(int i = 1; i <=n ; i++)
                    r += i % k > 0 && (i + "").IndexOf(k + "") < 0 ? i + " " : "Shaggy ";
                return r;
            };

            Console.WriteLine(f(20)(6));
            Console.WriteLine(f(21)(4));
            Console.WriteLine(f(212)(11));
        }
    }
}
</code>```

Title: 1, 2, 3, 4, 5, Shaggy

Body:
C#, 97 bytes

n=>k=>{var r="";for(int i=1;i<=n;i++)r+=i%k>0&&(i+"").IndexOf(k+"")<0?i+" ":"Shaggy ";return r;};

Full program with ungolfed method and test cases:

using System;

namespace Shaggy
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<int,Func<int,string>>f= n=>k=>
            {
                var r = "";
                for(int i = 1; i <=n ; i++)
                    r += i % k > 0 && (i + "").IndexOf(k + "") < 0 ? i + " " : "Shaggy ";
                return r;
            };

            Console.WriteLine(f(20)(6));
            Console.WriteLine(f(21)(4));
            Console.WriteLine(f(212)(11));
        }
    }
}


答:
C, <s>143</s> 135 bytes

Thanks to @Kritixi Lithos for helping save 8 bytes

Surely this can be done better, but its the best I've got for now.  C doesn't handle strings very gracefully, so naturally it takes quite a few operations.

```<code>int C(int N,int l,int h){char b[99],n[99];int t=0,i=1;sprintf(n,"%d",N);for(;i<=h;i++){sprintf(b,"%d",i);if(strstr(b,n))++t;}return t;}
</code>```

Ungolfed + program

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

int C(int N,int l,int h)
{
    char b[99], n[99];
    int t=0,i=1;
    sprintf(n,"%d",N);
    for(;i<=h;i++)
    {
        sprintf(b,"%d",i);
        if(strstr(b,n))
            ++t;
    }
    return t;
}

int main()
{
  printf("%d\n", C(3, 1, 100));
}
</code>```

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:
C, <s>143</s> 135 bytes

Thanks to @Kritixi Lithos for helping save 8 bytes

Surely this can be done better, but its the best I've got for now.  C doesn't handle strings very gracefully, so naturally it takes quite a few operations.

int C(int N,int l,int h){char b[99],n[99];int t=0,i=1;sprintf(n,"%d",N);for(;i<=h;i++){sprintf(b,"%d",i);if(strstr(b,n))++t;}return t;}

Ungolfed + program

#include <string.h>
#include <stdlib.h>
#include <stdio.h>

int C(int N,int l,int h)
{
    char b[99], n[99];
    int t=0,i=1;
    sprintf(n,"%d",N);
    for(;i<=h;i++)
    {
        sprintf(b,"%d",i);
        if(strstr(b,n))
            ++t;
    }
    return t;
}

int main()
{
  printf("%d\n", C(3, 1, 100));
}


答:
Python 2, <s>74</s> 72 bytes

Having already been soundly beaten by @Flp.Tkc I'll just post my <s>74</s> 72 byte recursive solution because it's different and it works and not because it will win (and also because I like recursive functions).

```<code>def f(a,b,c=1):
 print(c,"Shaggy")[c%b<1or`b`in`c`]
 if c<a:f(a,b,c+1)
</code>```

Edit

-2 by removing the unneeded `` around the c in the print statement

From comments:

Call using

```<code> f(a,b)
</code>```

c will default to 1 due to the

```<code> c=1
</code>```

in the function definition and can then be incremented for the recursive function calls.

Title: 1, 2, 3, 4, 5, Shaggy

Body:
Python 2, <s>74</s> 72 bytes

Having already been soundly beaten by @Flp.Tkc I'll just post my <s>74</s> 72 byte recursive solution because it's different and it works and not because it will win (and also because I like recursive functions).

def f(a,b,c=1):
 print(c,"Shaggy")[c%b<1or`b`in`c`]
 if c<a:f(a,b,c+1)

Edit

-2 by removing the unneeded `` around the c in the print statement

From comments:

Call using

 f(a,b)

c will default to 1 due to the

 c=1

in the function definition and can then be incremented for the recursive function calls.


答:
JavaScript (ES6), <s>43</s> 42 bytes

Saved a byte thanks to @Arnauld

f=(n,a="a",b="b")=>n&&f(n-!alert(a),b,a+b)
```

Title: Print a letter Fibonacci


答:
Python 2, 41 bytes

Saved 3 bytes thanks to @xnor

a,b="ab";exec"print a;a,b=b,a+b;"*input()
```

Test on Ideone

Simply follows the recursive definition.

Title: Print a letter Fibonacci

Body:
Python 2, 41 bytes

Saved 3 bytes thanks to @xnor

a,b="ab";exec"print a;a,b=b,a+b;"*input()

Test on Ideone

Simply follows the recursive definition.


答:
Pyth - <s>16</s> 15 bytes

```<code>A"ab" m=H+
~GHH
</code>```

Try it online here.

Title: Print a letter Fibonacci

Body:
Pyth - <s>16</s> 15 bytes

A"ab" m=H+
~GHH

Try it online here.


答:
C, <s>98</s> 96 bytes

n,h[],t[];s(i,j){for(;n<=i;n&&puts(!strstr(t,h)&&n%j?t:"Shaggy"),n++)sprintf(n?t:h,"%d",n?n:j);}
```

Wandbox

Title: 1, 2, 3, 4, 5, Shaggy

Body:
C, <s>98</s> 96 bytes

n,h[],t[];s(i,j){for(;n<=i;n&&puts(!strstr(t,h)&&n%j?t:"Shaggy"),n++)sprintf(n?t:h,"%d",n?n:j);}

Wandbox


问:
Compute the kangaroo sequence

Backstory

Disclaimer: May contain made up information about kangaroos.

Kangaroos traverse several stages of development. As they grow older and stronger, they can jump higher and longer, and they can jump more times before they get hungry.

In stage 1, the kangaroo is very little and cannot jump at all. Despite this, is constantly requires nourishment. We can represent a stage 1 kangaroo's activity pattern like this.

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

In stage 2, the kangaroo can make small jumps, but not more than 2 before it gets hungry. We can represent a stage 2 kangaroo's activity pattern like this.

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

After stage 2 the kangaroo improves quickly. In each subsequent stage, the kangaroo can jump a bit higher (1 unit in the graphical representation) and twice as many times. For example, a stage 3 kangaroo's activity pattern looks like this.

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

All that jumping requires energy, so the kangaroo requires nourishment after completing each activity pattern. The exact amount required can be calculated as follows.

Assign each o in the activity pattern of a stage n kangaroo its height, i.e., a number from 1 to n, where 1 corresponds to the ground and n to the highest position.

Compute the sum of all heights in the activity pattern.

For example, a stage 3 kangaroo's activity pattern includes the following heights.

```<code>  3   3   3   3
 2 2 2 2 2 2 2 2
1   1   1   1   1
</code>```

We have five 1's, eight 2's, and four 3's; the sum is 5·1 + 8·2 + 4·3 = 33.

Task

Write a full program or a function that takes a positive integer n as input and prints or returns the nutritional requirements per activity of a stage n kangaroo.

This is code-golf; may the shortest answer in bytes win!

Examples

```<code> 1 ->     1
 2 ->     7
 3 ->    33
 4 ->   121
 5 ->   385
 6 ->  1121
 7 ->  3073
 8 ->  8065
 9 -> 20481
10 -> 50689
</code>```

答:
Jelly, 4 bytes

```<code>ŒḄ¡S
</code>```

Try it online! or verify all test cases.

How it works

```<code>ŒḄ¡S  Main link. Argument: n (integer)

ŒḄ    Bounce; turn the list [a, b, ..., y, z] into [a, b, ..., y, z, y, ..., b, a].
      This casts to range, so the first array to be bounced is [1, ..., n].
      For example, 3 gets mapped to [1, 2, 3, 2, 1].
  ¡   Call the preceding atom n times.
      3 -> [1, 2, 3, 2, 1]
        -> [1, 2, 3, 2, 1, 2, 3, 2, 1]
        -> [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]
   S  Compute the sum.
</code>```

Title: Compute the kangaroo sequence

Body:
Jelly, 4 bytes

ŒḄ¡S

Try it online! or verify all test cases.

How it works

ŒḄ¡S  Main link. Argument: n (integer)

ŒḄ    Bounce; turn the list [a, b, ..., y, z] into [a, b, ..., y, z, y, ..., b, a].
      This casts to range, so the first array to be bounced is [1, ..., n].
      For example, 3 gets mapped to [1, 2, 3, 2, 1].
  ¡   Call the preceding atom n times.
      3 -> [1, 2, 3, 2, 1]
        -> [1, 2, 3, 2, 1, 2, 3, 2, 1]
        -> [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]
   S  Compute the sum.


答:
APL, 30 bytes.

⎕IO must be 1.

```<code>{⎕←⍵}¨{⍵∊⍳2:⍵⌷'ab'⋄∊∇¨⍵-⌽⍳2}¨⍳
</code>```

Title: Print a letter Fibonacci

Body:
APL, 30 bytes.

⎕IO must be 1.

{⎕←⍵}¨{⍵∊⍳2:⍵⌷'ab'⋄∊∇¨⍵-⌽⍳2}¨⍳


答:
Batch, 93 bytes

```<code>@set/pn=
:l
@set/an+=1,r=n%%3
@if %r%==0 goto l
@if not "%n:3=%"=="%n%" goto l
@echo %n%
</code>```

Takes input on STDIN.

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:
Batch, 93 bytes

@set/pn=
:l
@set/an+=1,r=n%%3
@if %r%==0 goto l
@if not "%n:3=%"=="%n%" goto l
@echo %n%

Takes input on STDIN.


问:
Binary Countdown Length
inspired by Count down from infinity

Given a non-negative integer N, output the number of repetitions of the following steps it takes to reach 0:

Convert N to binary (4812390 -> 10010010110111001100110)

Flip each bit (10010010110111001100110 -> 01101101001000110011001)

Trim leading zeroes (01101101001000110011001 -> 1101101001000110011001)

Convert back to decimal (1101101001000110011001 -> 3576217)

Rules

Input and output may be in any unambiguous, consistent format

The input will be within the native representable integer range for your language (if your language supports arbitrarily-large integers, there is no bound)

Test Cases

```<code>0 -> 0
1 -> 1
42 -> 6
97 -> 3
170 -> 8
255 -> 1
682 -> 10
8675309 -> 11
4812390 -> 14
178956970 -> 28
2863311530 -> 32
</code>```

This sequence is A005811 in the OEIS.

答:
Java 7, 64 bytes

```<code>long g(Long n){return n.toString(n,2).split("0+").length*2-n%2;}
</code>```

I know this could be beaten by a port of one of the better answers, but I came up with it in chat, and I can't not post it after Poke said something about it :)

Title: Binary Countdown Length

Body:
Java 7, 64 bytes

long g(Long n){return n.toString(n,2).split("0+").length*2-n%2;}

I know this could be beaten by a port of one of the better answers, but I came up with it in chat, and I can't not post it after Poke said something about it :)


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

```<code>”a”bṄ;¥@¡f
</code>```

Try it online!

How it works

```<code>”a”bṄ;¥@¡f  Main link. Argument: n

”a          Set the return value to 'a'.
  ”b    ¡   Call the link to the left n times, with left argument 'b' and right
            argument 'a'. After each call, the right argument is replaced with the
            left one, and the left argument with the return value. The final
            return value is yielded by the quicklink.
      ¥       Combine the two atoms to the left into a dyadic chain.
    Ṅ           Print the left argument of the chain, followed by a linefeed.
     ;          Concatenate the left and right argument of the chain.
       @      Call the chain with reversed argument order.
         f  Filter the result by presence in n. This yields an empty string
            and thus suppresses the implicit output.
</code>```

Title: Print a letter Fibonacci

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

”a”bṄ;¥@¡f

Try it online!

How it works

”a”bṄ;¥@¡f  Main link. Argument: n

”a          Set the return value to 'a'.
  ”b    ¡   Call the link to the left n times, with left argument 'b' and right
            argument 'a'. After each call, the right argument is replaced with the
            left one, and the left argument with the return value. The final
            return value is yielded by the quicklink.
      ¥       Combine the two atoms to the left into a dyadic chain.
    Ṅ           Print the left argument of the chain, followed by a linefeed.
     ;          Concatenate the left and right argument of the chain.
       @      Call the chain with reversed argument order.
         f  Filter the result by presence in n. This yields an empty string
            and thus suppresses the implicit output.


答:
Jelly, <s> 7 </s> 6 bytes

-1 thanks to caird coinheringaahing! (Use w and filtering to avoiding @.)

```<code>rAwƇ⁵L
</code>```

TryItOnline!

Input: Start, End, ToFind

How?

```<code>rAwƇ⁵L - Main link: Start, End, ToFind
r      - range: [Start, ..., End]
 A     - absolute values
    ⁵  - third input: ToFind
   Ƈ   - filter keep those (absolute values, a) for which:
  w    -   first index of sublist (implicit digits of ToFind) in (implicit digits of a)
     L - length
</code>```

The default casting of an integer to an iterable for the sublist existence check casts to a decimal list (not a character list), so negative numbers have a leading negative value (e.g. -122->[-1,2,2] which won't find a sublist of [1,2]) so taking the absolute value first seems like the golfiest solution.

Body:
Jelly, <s> 7 </s> 6 bytes

-1 thanks to caird coinheringaahing! (Use w and filtering to avoiding @.)

rAwƇ⁵L

TryItOnline!

Input: Start, End, ToFind

How?

rAwƇ⁵L - Main link: Start, End, ToFind
r      - range: [Start, ..., End]
 A     - absolute values
    ⁵  - third input: ToFind
   Ƈ   - filter keep those (absolute values, a) for which:
  w    -   first index of sublist (implicit digits of ToFind) in (implicit digits of a)
     L - length

The default casting of an integer to an iterable for the sublist existence check casts to a decimal list (not a character list), so negative numbers have a leading negative value (e.g. -122->[-1,2,2] which won't find a sublist of [1,2]) so taking the absolute value first seems like the golfiest solution.


问:
Ordered list of binary sequences of multiple dimensions
Given a positive integer n, output the 2^n binary sequences of length n sorted in the following precise ordering.

Test cases:

0:

```<code>0 or 1 (defining this is a matter of debate)
</code>```

1:

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

2:

```<code>00
01
10
11
</code>```

3:

```<code>000
001
010
100
011
101
110
111
</code>```

4:

```<code>0000
0001
0010
0100
1000
0011
0101
1001
0110
1010
1100
0111
1011
1101
1110
1111
</code>```

etc.

Additionally, the pattern of combinatorics is related to Pascal's Triangle.

0:

```<code>1 (this is given regardless of the definition given to 2^0)
</code>```

1:

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

2:

```<code>1
2
1
</code>```

3:

```<code>1
3
3
1
</code>```

4:

```<code>1
4
6
4
1
</code>```

etc.

答:
Haskell, 78 bytes

```<code>import Data.List
f n=sortOn(\x->sum x:reverse(map(1-)x))$mapM id$[0,1]<$[1..n]
</code>```

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

How it works:

```<code>         [0,1]<$[1..n]  -- make n copies of the list [0,1]
     mapM id            -- make all lists where the ith element is from the ith list.
                        -- that gives us all binary sequences
sortOn                  -- sort this list of list
    sum x               -- first by number of ones
      reverse(map(1-)x) -- then by the reversed list with bits flipped
</code>```

Body:
Haskell, 78 bytes

import Data.List
f n=sortOn(\x->sum x:reverse(map(1-)x))$mapM id$[0,1]<$[1..n]

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

How it works:

         [0,1]<$[1..n]  -- make n copies of the list [0,1]
     mapM id            -- make all lists where the ith element is from the ith list.
                        -- that gives us all binary sequences
sortOn                  -- sort this list of list
    sum x               -- first by number of ones
      reverse(map(1-)x) -- then by the reversed list with bits flipped


答:
Swift 3, 76 Bytes

```<code>func f(_ n:Int,_ x:String="a",_ y:String="b"){if n>1{print(x);f(n-1,y,x+y)}}
</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:
Swift 3, 76 Bytes

func f(_ n:Int,_ x:String="a",_ y:String="b"){if n>1{print(x);f(n-1,y,x+y)}}