答:
Pyth, 12 bytes

```<code>.usi!MjN2 2C
</code>```

A program that takes input of a quoted string and prints the result as a list of integers.

Verify all test cases

How it works

```<code>.usi!MjN2 2C  Program. Input: Q
           C  Convert Q to an integer by code-points using base-256 (implicit input)
.u            Apply the following function A(N) until a repeat occurs, storing the results
              in a list:
      jN2       Convert to binary as a list
    !M          Map negation over the above
   i      2     Convert from binary to integer
  s             Integer (Converts final False to 0)
              Implicitly print
</code>```

Title: Count down from "Infinity"

Body:
Pyth, 12 bytes

.usi!MjN2 2C

A program that takes input of a quoted string and prints the result as a list of integers.

Verify all test cases

How it works

.usi!MjN2 2C  Program. Input: Q
           C  Convert Q to an integer by code-points using base-256 (implicit input)
.u            Apply the following function A(N) until a repeat occurs, storing the results
              in a list:
      jN2       Convert to binary as a list
    !M          Map negation over the above
   i      2     Convert from binary to integer
  s             Integer (Converts final False to 0)
              Implicitly print


答:
CJam, <s>17</s> <s>16</s> 18 bytes

```<code>q256b0{_p2b:!2bj}j
</code>```

Try it online!

```<code>q256b   e# read printable ascii to integer
0       e# value for terminal case
{       e# recursive function
  _p    e#   print current number
  2b    e#   create binary representation with no leading zeros
  :!    e#   flip bits
  2b    e#   convert binary back to integer
  j     e#   recursive call
}j      e# end
</code>```

NOTE: The old 16 byte version didn't behave correctly with empty strings:

```<code>q256b{_p2b:!2b}h
</code>```

Also, thanks to Dennis for suggesting p which saves 1 byte over N\ putting newlines into the stack.

ContentLicense: CC BY-SA 4.0

Title: Count down from "Infinity"

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

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

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

The way you'll count down is:

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

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

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

Output the number in decimal

Repeat steps 2-4 as until you reach 0.

Challenge:

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

Test case:

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

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

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

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

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

Leaderboard

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
CJam, <s>17</s> <s>16</s> 18 bytes

q256b0{_p2b:!2bj}j

Try it online!

q256b   e# read printable ascii to integer
0       e# value for terminal case
{       e# recursive function
  _p    e#   print current number
  2b    e#   create binary representation with no leading zeros
  :!    e#   flip bits
  2b    e#   convert binary back to integer
  j     e#   recursive call
}j      e# end

NOTE: The old 16 byte version didn't behave correctly with empty strings:

q256b{_p2b:!2b}h

Also, thanks to Dennis for suggesting p which saves 1 byte over N\ putting newlines into the stack.

ContentLicense: CC BY-SA 3.0


问:
Palindromize this string!
Your task is to palindromize a string as follows:

Take the string.

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

Reverse it.

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

Remove the first letter.

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

Glue it onto the original string.

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

But here's the catch: since this challenge is about palindromes, your code itself also has to be a palindrome.

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

答:
05AB1E, 1 byte

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

Try it online!

Title: Palindromize this string!

Body:
05AB1E, 1 byte

û

Try it online!


答:
Pyth - 13 bytes

It kinda looks like its crying.

```<code>+Qt_Q " Q_tQ+
</code>```

Try it online here.

Title: Palindromize this string!

Body:
Your task is to palindromize a string as follows:

Take the string.

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

Reverse it.

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

Remove the first letter.

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

Glue it onto the original string.

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

But here's the catch: since this challenge is about palindromes, your code itself also has to be a palindrome.

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

Body:
Pyth - 13 bytes

It kinda looks like its crying.

+Qt_Q " Q_tQ+

Try it online here.


答:
Dip, 1 byte

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

Body must be at least 30 characters; you entered 13.

Title: Palindromize this string!

Body:
Dip, 1 byte

B

Body must be at least 30 characters; you entered 13.


问:
Pairable strings
A string is pairable if it can be split into subtrings, each of which is a string repeated twice consecutively. For example, aabaaababbbaba is pairable as:

```<code>aaba aaba
b b
ba ba
</code>```

Given a non-empty string of a's and b's, output a Truthy value if it's pairable and a Falsey value if it isn't.

Pairable:

```<code>aa
abaaba
bbababbb
aabaaababbbaba
babababa
bbbbbbbbbbbb
aaababbabbabbbababbaabaabaababaaba
aaaabaab
</code>```

Not pairable:

```<code>a
ba
baab
abaabaaba
bbbbbbbbbbbbbbb
baababbabaaaab
aaaaabbaaaaa
</code>```

I encourage you to come up with non-regex-based solutions even when there's already a shorter regex answer in your language. You can mark them as "no regex". By regex, I mean a built-in string pattern matching subsystem.

Leaderboard:

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

答:
Lithp, 57 characters

```<code>#S::((? (!= (null) (match S "^((.+)\\2)+$")) true false))
</code>```

Sample usage:

```<code>% pairable_strings.lithp
(
    (def f #S::((? (!= (null) (match S "^((.+)\\2)+$")) true false)))
    (print (f "aa"))
    (print (f "aabaaababbbaba"))
    (print (f "aaababbabbabbbababbaabaabaababaaba"))
    (print (f "ba"))
)

# ./run.js pairable_strings.lithp
AtomValue { value: 2, type: 'Atom', name: 'true' }
AtomValue { value: 2, type: 'Atom', name: 'true' }
AtomValue { value: 2, type: 'Atom', name: 'true' }
AtomValue { value: 3, type: 'Atom', name: 'false' }
</code>```

Title: Pairable strings

Body:
Lithp, 57 characters

#S::((? (!= (null) (match S "^((.+)\\2)+$")) true false))

Sample usage:

% pairable_strings.lithp
(
    (def f #S::((? (!= (null) (match S "^((.+)\\2)+$")) true false)))
    (print (f "aa"))
    (print (f "aabaaababbbaba"))
    (print (f "aaababbabbabbbababbaabaabaababaaba"))
    (print (f "ba"))
)

# ./run.js pairable_strings.lithp
AtomValue { value: 2, type: 'Atom', name: 'true' }
AtomValue { value: 2, type: 'Atom', name: 'true' }
AtomValue { value: 2, type: 'Atom', name: 'true' }
AtomValue { value: 3, type: 'Atom', name: 'false' }


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

```<code>s=>s+[...s].reverse().slice(1).join("")//)""(nioj.)1(ecils.)(esrever.]s...[+s>=s
</code>```

I tried a smarter solution but it's still longer :/ even abusing [,...a]=s didn't seem to save bytes

Title: Palindromize this string!

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

s=>s+[...s].reverse().slice(1).join("")//)""(nioj.)1(ecils.)(esrever.]s...[+s>=s

I tried a smarter solution but it's still longer :/ even abusing [,...a]=s didn't seem to save bytes


Title: Palindromize this string!

Body:
Ruby, 47 bytes

->s{s+s.reverse[1..-1]}#}[1-..1]esrever.s+s{s>-


答:
Python 3, 41 bytes

```<code>lambda t:t+t[-2::-1]#]1-::2-[t+t:t adbmal
</code>```

Try it here.

Title: Palindromize this string!

Body:
Python 3, 41 bytes

lambda t:t+t[-2::-1]#]1-::2-[t+t:t adbmal

Try it here.


问:
How many peaks in my mountain range?
A list of positive integers can be visualized as a quantized mountain range where each list entry represents the height of one vertical section of the mountains.

For example, the list

```<code>1, 2, 2, 3, 4, 3, 5, 3, 2, 1, 2, 3, 3, 3, 2, 2, 1, 3
</code>```

can become the range

```<code>      x
    x x
   xxxxx   xxx   x
 xxxxxxxx xxxxxx x
xxxxxxxxxxxxxxxxxx
</code>```

(Less poetic people might call this a bar chart, but I digress.)

The question in this challenge is: How many peaks are in the mountain range of some arbitrary list? Essentially, how many local maxima are in the list?

A peak is defined as a contiguous section of one or more columns of the mountain range that are all equal in height, where the columns immediately to the left and the right are lower in height.

It's easy to visually tell that the example has four peaks at these parenthesized locations:

```<code>1, 2, 2, 3, (4), 3, (5), 3, 2, 1, 2, (3, 3, 3), 2, 2, 1, (3)
</code>```

Note how the (3, 3, 3) plateau section counts as a peak because it is a contiguous set of columns equal in height, higher than its neighboring columns.

The last (3) counts as a peak as well because, for the purposes of this challenge, we'll define the left neighbor of the leftmost column and the right neighbor of the rightmost column to both be height zero.

This means that a list with only one value, for example 1, 1, 1, can be interpreted as 0, 1, 1, 1, 0, and thus has one peak, not none: 0, (1, 1, 1), 0.

The only list with zero peaks is the empty list.

Challenge

Write a function or program that takes in an arbitrary list of positive integers and prints or returns the number of peaks in the corresponding mountain range.

The shortest code in bytes wins. Tiebreaker is earlier post.

Test Cases

```<code>Input List -> Output Peak Count
</code>```
```<code>[empty list] -> 0
1, 1, 1 -> 1
1, 2, 2, 3, 4, 3, 5, 3, 2, 1, 2, 3, 3, 3, 2, 2, 1, 3 -> 4
1 -> 1
1, 1 -> 1
2, 2, 2, 2, 2 -> 1
90 -> 1
2, 1, 2 -> 2
5, 2, 5, 2, 5 -> 3
2, 5, 2, 5, 2, 5, 2 -> 3
1, 2, 3, 4 -> 1
1, 2, 3, 4, 1, 2 -> 2
1, 3, 5, 3, 1 -> 1
7, 4, 2, 1, 2, 3, 7 -> 2
7, 4, 2, 1, 2, 1, 2, 3, 7 -> 3
1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 -> 10
1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1 -> 10
2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 -> 10
1, 3, 3, 3, 1, 3, 3, 1, 3, 1, 3, 3, 3, 3, 1 -> 4
12, 1, 2, 1, 2, 3, 3, 3, 2, 4, 4, 4, 1, 5, 5, 4, 7, 9 -> 6
87, 356, 37673, 3676, 386, 909, 909, 909, 909, 454, 909, 909 -> 3
87, 356, 37673, 3676, 386, 909, 909, 909, 909, 454, 909, 908, 909 -> 4
</code>```

答:
Jelly, 27 bytes

```<code>ṡ2EÐḟFs2ḣ€1S€ṡ3M€Fċ2
0;⁸;0Ç
</code>```

Try it online!

Title: How many peaks in my mountain range?

Body:
Jelly, 27 bytes

ṡ2EÐḟFs2ḣ€1S€ṡ3M€Fċ2
0;⁸;0Ç

Try it online!


问:
Hyperprogramming: N+N, N×N, N^N all in one
Write a program that takes in a number N from 1 to 9 inclusive. In its native form your program should output N+N. E.g. output 2 if N is 1, 4 if N is 2, 6 if N is 3, and so on.

When every character in your program is duplicated in place, then it should be a program that takes in N (still from 1 to 9) and outputs N×N. E.g. output 1 if N is 1, 4 if N is 2, 9 if N is 3, and so on.

When every character in your program is triplicated in place, then it should be a program that takes in N (still from 1 to 9) and outputs N^N. E.g. output 1 if N is 1, 4 if N is 2, 27 if N is 3, 387420489 if N is 9, etc.

Numbers above 9 aren't required because 10^10 is outside of many language's usual integer range.

Example

If your initial program was

```<code>My_Program!
Exit();
</code>```

Then it should be capable of taking in N and outputting N+N.

Additionally, the program

```<code>MMyy__PPrrooggrraamm!!

EExxiitt(());;
</code>```

should take in N and output N×N.

Finally, the program

```<code>MMMyyy___PPPrrrooogggrrraaammm!!!

EEExxxiiittt((()));;;
</code>```

should take in N and output N^N.

Quadrupled-character programs and beyond are not required.

Rules

Input and output should be plain, normally formatted decimal numbers. You may answer using a different base to show off your code but then your answer is non-competitive.

Windows users may treat \r\n as one character since things like \r\r\n\n wouldn't make sense or perhaps even work.

The shortest native program (the N+N one) in bytes wins.

答:
Befunge-98 (FBBI), <s>38</s> 41 bytes

(+3 bytes to fix bug, thanks Jo King!)

```<code>vx:k::1-k*\/.@
20@
j3.
>^*
>:^
>:+.@
</code>```

Try it online: N+N, N*N, N^N

This program won't work out-of-the-box since it requires input to be on the stack at the start of execution. By replacing the first line with the following code (adding three more bytes) it will take input from stdin:

```<code>v
&x:k:2-
</code>```

Explanation

Setup

```<code>v       Redirect motion downward
02j     Jump over two instructions/spaces, executing the third
        If N=1, it will skip to the 6th line
        If N=2, it will skip to the 5th line
        If N=3, it will skip to the 4th line
</code>```

N=1

```<code>>       Move right
:+.@    Duplicate, add, print and exit
</code>```

N=2

```<code>>>::^^  Move right, duplicate twice, move up
*.@     Multiply, print and exit
</code>```

N=3

```<code>>>>^^^  Redirect motion
30x     Set instruction pointer delta to (3, 0), causing it to
        move right, executing every third instruction
:k::    Duplicate the number (we'll call it M) M+2 times
        The stack is now [M]*(M+3)
1-k*    Multiply things M times (`k' is a quirky instruction)
\/      Divide that result by M (workaround for `k` being quirky)
.@      Print and exit
</code>```

Body:
Befunge-98 (FBBI), <s>38</s> 41 bytes

(+3 bytes to fix bug, thanks Jo King!)

vx:k::1-k*\/.@
20@
j3.
>^*
>:^
>:+.@

Try it online: N+N, N*N, N^N

This program won't work out-of-the-box since it requires input to be on the stack at the start of execution. By replacing the first line with the following code (adding three more bytes) it will take input from stdin:

v
&x:k:2-

Explanation

Setup

v       Redirect motion downward
02j     Jump over two instructions/spaces, executing the third
        If N=1, it will skip to the 6th line
        If N=2, it will skip to the 5th line
        If N=3, it will skip to the 4th line

N=1

>       Move right
:+.@    Duplicate, add, print and exit

N=2

>>::^^  Move right, duplicate twice, move up
*.@     Multiply, print and exit

N=3

>>>^^^  Redirect motion
30x     Set instruction pointer delta to (3, 0), causing it to
        move right, executing every third instruction
:k::    Duplicate the number (we'll call it M) M+2 times
        The stack is now [M]*(M+3)
1-k*    Multiply things M times (`k' is a quirky instruction)
\/      Divide that result by M (workaround for `k` being quirky)
.@      Print and exit


问:
Golf you a quine for great good!
Using your language of choice, golf a quine.

A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output.

No cheating -- that means that you can't just read the source file and print it. Also, in many languages, an empty file is also a quine: that isn't considered a legit quine either.

No error quines -- there is already a separate challenge for error quines.

Points for:

Smallest code (in bytes)

Most obfuscated/obscure solution

Using esoteric/obscure languages

Successfully using languages that are difficult to golf in

The following Stack Snippet can be used to get a quick view of the current score in each language, and thus to know which languages have existing answers and what sort of target you have to beat:

var QUESTION_ID=69;
var OVERRIDE_USER=98;

var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk";var answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,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:!0,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=!1;comment_page=1;getComments()}})}
function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,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=(function(){var headerTag=String.raw `h\d`
var score=String.raw `\-?\d+\.?\d*`
var normalText=String.raw `[^\n<>]*`
var strikethrough=String.raw `<s>${normalText}</s>|<strike>${normalText}</strike>|<del>${normalText}</del>`
var noDigitText=String.raw `[^\n\d<>]*`
var htmlTag=String.raw `<[^\n<>]+>`
return new RegExp(String.raw `<${headerTag}>`+String.raw `\s*([^\n,]*[^\s,]),.*?`+String.raw `(${score})`+String.raw `(?=`+String.raw `${noDigitText}`+String.raw `(?:(?:${strikethrough}|${htmlTag})${noDigitText})*`+String.raw `</${headerTag}>`+String.raw `)`)})();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;lang=jQuery(''+a.language+'').text().toLowerCase();languages[lang]=languages[lang]||{lang:a.language,user:a.user,size:a.size,link:a.link,uniq:lang}});var langs=[];for(var lang in languages)
if(languages.hasOwnProperty(lang))
langs.push(languages[lang]);langs.sort(function(a,b){if(a.uniq>b.uniq)return 1;if(a.uniq<b.uniq)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;float:left}#language-list{padding:10px;float:left}table thead{font-weight:700}table td{padding:5px}</code>```

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

Winners by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

 ```

答:
Dip, 10 bytes

```<code>"N+|+"N+|+
</code>```

Explanation:

```<code>"N+|+"      Push string
      N+    Add " on the left side of the string
        |+  Duplicate and concatenate
</code>```

Title: Golf you a quine for great good!

Body:
Dip, 10 bytes

"N+|+"N+|+

Explanation:

"N+|+"      Push string
      N+    Add " on the left side of the string
        |+  Duplicate and concatenate


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

答:
05AB1E, 5 bytes

```<code>Dg;î£
</code>```

Try it online!

Explanation:

```<code>D      Duplicate
 g;î   Divide length by two and round up
    £  First b letters of a
</code>```

Title: Depalindromize this string!

Body:
05AB1E, 5 bytes

Dg;î£

Try it online!

Explanation:

D      Duplicate
 g;î   Divide length by two and round up
    £  First b letters of a


答:
Pyth - 4 bytes

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

Test Suite.

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:
Pyth - 4 bytes

hc2Q

Test Suite.


答:
Cheddar, <s>22</s> 18 bytes

```<code>@.head($0.len/2+1)
</code>```

So simple I don't think needs explanation but I'll add one if wanted.

Try it online

Title: Depalindromize this string!

Body:
Cheddar, <s>22</s> 18 bytes

@.head($0.len/2+1)

So simple I don't think needs explanation but I'll add one if wanted.

Try it online


答:
Haskell, 27 bytes

```<code>take=<<succ.(`div`2).length
</code>```

Pointfree version of

```<code>\x->take(div(length x)2+1)x
</code>```

which is also 27 bytes.

Title: Depalindromize this string!

Body:
Haskell, 27 bytes

take=<<succ.(`div`2).length

Pointfree version of

\x->take(div(length x)2+1)x

which is also 27 bytes.


Title: Depalindromize this string!

Body:
Ruby, <s>21</s> 19 bytes

->s{s[0..s.size/2]}


答:
Python 2, 23 bytes

I am not able to test on my phone, but this should work:

```<code>lambda s:s[:-~len(s)/2]
</code>```

Title: Depalindromize this string!

Body:
Python 2, 23 bytes

I am not able to test on my phone, but this should work:

lambda s:s[:-~len(s)/2]


答:
Python 2, 23 bytes

```<code>lambda x:x[:len(x)/2+1]
</code>```

Title: Depalindromize this string!

Body:
Python 2, 23 bytes

lambda x:x[:len(x)/2+1]


答:
JavaScript (ES6), <s>32 26</s> 25 bytes

1 byte saved thanks to Neil:

s=>s.slice(0,-s.length/2)
```
<p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>f=
  s=>s.slice(0,-s.length/2)
;
console.log(f('abcdedcba'))
console.log(f('johncenanecnhoj'))
console.log(f('ppapapp'))
console.log(f('codegolflogedoc'))</code>```

Previous solutions

26 bytes thanks to Downgoat:

s=>s.slice(0,s.length/2+1)
```
<p>32 bytes:</p>
<pre class="lang-js prettyprint-override"><code>s=>s.slice(0,(l=s.length/2)+l%2)
</code>```

Title: Depalindromize this string!

Body:
JavaScript (ES6), <s>32 26</s> 25 bytes

1 byte saved thanks to Neil:

s=>s.slice(0,-s.length/2)

f=
  s=>s.slice(0,-s.length/2)
;
console.log(f('abcdedcba'))
console.log(f('johncenanecnhoj'))
console.log(f('ppapapp'))
console.log(f('codegolflogedoc'))

Previous solutions

26 bytes thanks to Downgoat:

s=>s.slice(0,s.length/2+1)

32 bytes:

s=>s.slice(0,(l=s.length/2)+l%2)


答:
PHP, 40 bytes

```<code><?=substr($a=$argv[1],0,1+strlen($a)/2);
</code>```

strlen($a)/2 gets cast to int, with the input always having odd length, +1 suffices to round up.

42 bytes for any length:

```<code><?=substr($a=$argv[1],0,(1+strlen($a))/2);
</code>```

for unknown length, (1+strlen)/2 gets cast to int, rounding up strlen/2.

Title: Depalindromize this string!

Body:
PHP, 40 bytes

<?=substr($a=$argv[1],0,1+strlen($a)/2);

strlen($a)/2 gets cast to int, with the input always having odd length, +1 suffices to round up.

42 bytes for any length:

<?=substr($a=$argv[1],0,(1+strlen($a))/2);

for unknown length, (1+strlen)/2 gets cast to int, rounding up strlen/2.


答:
05AB1E, 3 bytes

```<code>2ä¬
</code>```

Uses the CP-1252 encoding. Try it online!

Title: Depalindromize this string!

Body:
05AB1E, 3 bytes

2ä¬

Uses the CP-1252 encoding. Try it online!


答:
Haskell, 27 bytes

```<code>f[x]=[x]
f(a:b)=a:f(init b)
</code>```

No indexing. Recursively takes from the start and end, keeping letters from the end.

Title: Depalindromize this string!

Body:
Haskell, 27 bytes

f[x]=[x]
f(a:b)=a:f(init b)

No indexing. Recursively takes from the start and end, keeping letters from the end.


答:
Perl 6, 21 bytes

*.substr(0,1+* div 2)
```

<h2>Expanded:</h2>

<pre class="lang-perl6 prettyprint-override"><code>*\            # Whatever lambda
.substr(
  0,
  1 + * div 2 # Whatever lambda
)
</code>```

Title: Depalindromize this string!

Body:
Perl 6, 21 bytes

*.substr(0,1+* div 2)

Expanded:

*\            # Whatever lambda
.substr(
  0,
  1 + * div 2 # Whatever lambda
)


答:
Julia, <s>21</s> 15 bytes

```<code>x->x[1:end/2+1]
</code>```

Try it online! (extra code is for printing output)

Title: Depalindromize this string!

Body:
Julia, <s>21</s> 15 bytes

x->x[1:end/2+1]

Try it online! (extra code is for printing output)


答:
PHP, 38+39=77 bytes

```<code><?=($s=$argv[1]).substr(strrev($s),1);#;)1,)s$(verrts(rtsbus.)]1[vgra$=s$(=?<
</code>```

stupid restriction ... for non-eso languages :)

Title: Palindromize this string!

Body:
Your task is to palindromize a string as follows:

Take the string.

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

Reverse it.

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

Remove the first letter.

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

Glue it onto the original string.

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

But here's the catch: since this challenge is about palindromes, your code itself also has to be a palindrome.

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

Body:
PHP, 38+39=77 bytes

<?=($s=$argv[1]).substr(strrev($s),1);#;)1,)s$(verrts(rtsbus.)]1[vgra$=s$(=?<

stupid restriction ... for non-eso languages :)


答:
MATLAB / Octave, <s>20</s> <s>19</s> <s>18</s> 16 bytes

1 byte off borrowing an idea from Easterly Irk's answer (add 1 instead of .5)

2 bytes off thanks to @StewieGriffin (unnecessary parentheses)

```<code>@(x)x(1:end/2+1)
</code>```

Try it at Ideone.

Title: Depalindromize this string!

Body:
MATLAB / Octave, <s>20</s> <s>19</s> <s>18</s> 16 bytes

1 byte off borrowing an idea from Easterly Irk's answer (add 1 instead of .5)

2 bytes off thanks to @StewieGriffin (unnecessary parentheses)

@(x)x(1:end/2+1)

Try it at Ideone.


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

```<code>9LQ2/)
</code>```

Try it online!

Explanation

```<code>9L       % Push array [1, 1j]
  Q      % Add 1: transforms into [2, 1+1j]
   2/    % Divide by 2: transforms into [1, 0.5+0.5j]
     )   % Apply as index into implicit input. The array [1, 0.5+0.5j] used as an index
         % is interpreted as [1:0.5+end*0.5]
</code>```

Title: Depalindromize this string!

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

9LQ2/)

Try it online!

Explanation

9L       % Push array [1, 1j]
  Q      % Add 1: transforms into [2, 1+1j]
   2/    % Divide by 2: transforms into [1, 0.5+0.5j]
     )   % Apply as index into implicit input. The array [1, 0.5+0.5j] used as an index
         % is interpreted as [1:0.5+end*0.5]


答:
TI-Basic, 14 bytes

Standard function. Returns string from index 1 to index (length/2 + 1/2).

```<code>sub(Ans,1,.5+.5length(Ans
</code>```

Title: Depalindromize this string!

Body:
TI-Basic, 14 bytes

Standard function. Returns string from index 1 to index (length/2 + 1/2).

sub(Ans,1,.5+.5length(Ans


答:
GameMaker Language, 59 bytes

```<code>a=argument0 return string_copy(a,1,ceil(string_length(a)/2)
</code>```

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:
GameMaker Language, 59 bytes

a=argument0 return string_copy(a,1,ceil(string_length(a)/2)


答:
Fuzzy Octo Guacamole, 4 bytes

```<code>2.^/
</code>```

I spent a while searching for a language in which this challenge is short, and realized I was dumb and my own language did that.

Title: Depalindromize this string!

Body:
Fuzzy Octo Guacamole, 4 bytes

2.^/

I spent a while searching for a language in which this challenge is short, and realized I was dumb and my own language did that.


问:
Implement a Truth-Machine
A truth-machine (credits goes to this guy for coming up with it) is a very simple program designed to demonstrate the I/O and control flow of a language. Here's what a truth-machine does:

Gets a number (either 0 or 1) from STDIN.

If that number is 0, print out 0 and terminate.

If that number is 1, print out 1 forever.

Challenge

Write a truth-machine as described above in your language of choice. The truth-machine must be a full program that follows these rules:

take input from STDIN or an acceptable alternative

If your language cannot take input from STDIN, it may take input from a hardcoded variable or suitable equivalent in the program

must output to STDOUT or an acceptable alternative

If your language is incapable of outputting the characters 0 or 1, byte or unary I/O is acceptable.

when the input is 1, it must continually print 1s and only stop if the program is killed or runs out of memory

the output must only be either a 0 followed by either one or no newline or space, or infinite 1s with each 1 followed by either one or no newline or space. No other output can be generated, except constant output of your language's interpreter that cannot be suppressed (such as a greeting, ANSI color codes or indentation). Your usage of newlines or spaces must be consistent: for example, if you choose to output 1 with a newline after it all 1s must have a newline after them.

if and only if your language cannot possibly terminate on an input of 0 it is acceptable for the code to enter an infinite loop in which nothing is outputted.

Since this is a catalog, languages created after this challenge are allowed to compete. Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language. Other than that, all the standard rules of code-golf must be obeyed. Submissions in most languages will be scored in bytes in an appropriate preexisting encoding (usually UTF-8).

Catalog

The Stack Snippet at the bottom of this post generates the catalog from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

答:
Valve scripting language, 38 bytes

```<code>alias 0 echo 0
alias 1 "echo 1;wait;1"
</code>```

This defines two commands, 0 and 1. Type 0 into the console for the zero case, and 1 for the 1 case.

Title: Implement a Truth-Machine

Body:
Valve scripting language, 38 bytes

alias 0 echo 0
alias 1 "echo 1;wait;1"

This defines two commands, 0 and 1. Type 0 into the console for the zero case, and 1 for the 1 case.


答:
Perl 5, 44 bytes

43 bytes, plus 1 for -pe instead of -e

```<code>s#(.*).#$&.reverse$1#e#1$esrever.&$#.)*.(#s
</code>```

Title: Palindromize this string!

Body:
Perl 5, 44 bytes

43 bytes, plus 1 for -pe instead of -e

s#(.*).#$&.reverse$1#e#1$esrever.&$#.)*.(#s


答:
Jelly, 4 bytes

```<code>œs2Ḣ
</code>```

Try it online!

Explanation

```<code>œs2      Split input into 2 chunks of similar lengths. For odd-length input,
         the first chunk is the longest
   Ḣ     Keep the first chunk
</code>```

Title: Depalindromize this string!

Body:
Jelly, 4 bytes

œs2Ḣ

Try it online!

Explanation

œs2      Split input into 2 chunks of similar lengths. For odd-length input,
         the first chunk is the longest
   Ḣ     Keep the first chunk


答:
아희(Aheui), <s>149</s> 137 bytes (47 chars + 2 newlines)

```<code>붛뱐쎤붇쎡뻐처순의이멓희
빠본땨벌다따토먀의썩속썩의먀토따다벌땨본빠
희멓이의순처뻐쎡붇쎤뱐붛
</code>```

Due to the nature of the Aheui language, the input must end in a double quotation mark (") (gets ignored).

Try it here! (copy and paste the code)

Bonus (each line is palindromic), 131 bytes (42 chars + 5 newlines)

```<code>밯빪반분반빪밯
쏜발뚝볃뚝발쏜
쏙툼닿뗘닿툼쏙
뽓첡순괆순첡뽓
숙쌱멈긕멈쌱숙
몋희익욥익희몋
</code>```

Title: Palindromize this string!

Body:
아희(Aheui), <s>149</s> 137 bytes (47 chars + 2 newlines)

붛뱐쎤붇쎡뻐처순의이멓희
빠본땨벌다따토먀의썩속썩의먀토따다벌땨본빠
희멓이의순처뻐쎡붇쎤뱐붛

Due to the nature of the Aheui language, the input must end in a double quotation mark (") (gets ignored).

Try it here! (copy and paste the code)

Bonus (each line is palindromic), 131 bytes (42 chars + 5 newlines)

밯빪반분반빪밯
쏜발뚝볃뚝발쏜
쏙툼닿뗘닿툼쏙
뽓첡순괆순첡뽓
숙쌱멈긕멈쌱숙
몋희익욥익희몋


答:
APL -- 13 bytes.

```<code>⊣,¯1↓⌽⍝⌽↓1¯,⊣
</code>```

Explanation:

```<code>⊣,¯1↓⌽
     ⌽ Reverse the argument.
  ¯1↓  Drop the last character.
⊣,     Concatenate the original to the result.
</code>```

Title: Palindromize this string!

Body:
APL -- 13 bytes.

⊣,¯1↓⌽⍝⌽↓1¯,⊣

Explanation:

⊣,¯1↓⌽
     ⌽ Reverse the argument.
  ¯1↓  Drop the last character.
⊣,     Concatenate the original to the result.


答:
Dyalog APL, 9 bytes

```<code>⊢↑⍨2÷⍨1+⍴
</code>```

Thanks to  Adám for saving 4 bytes.

Title: Depalindromize this string!

Body:
Dyalog APL, 9 bytes

⊢↑⍨2÷⍨1+⍴

Thanks to  Adám for saving 4 bytes.


答:
J, 17 bytes

```<code>}:,|.NB. .BN.|,:}
</code>```

Takes the easy way out by using a comment to mirror the code. In J, NB. starts a line comment. I do hope to find a method that doesn't involve a comment but the digrams in J probably do make it harder.

Also forms two smileys, }: and :}.

Usage

```<code>   f =: }:,|.NB. .BN.|,:}
   f 'abcde'
abcdedcba
</code>```

Explanation

Comment part removed since it is just filler.

```<code>}:,|.  Input: string S
   |.  Reverse S
}:     Curtail, get S with its last char removed
  ,    Join them and return
</code>```

Title: Palindromize this string!

Body:
J, 17 bytes

}:,|.NB. .BN.|,:}

Takes the easy way out by using a comment to mirror the code. In J, NB. starts a line comment. I do hope to find a method that doesn't involve a comment but the digrams in J probably do make it harder.

Also forms two smileys, }: and :}.

Usage

   f =: }:,|.NB. .BN.|,:}
   f 'abcde'
abcdedcba

Explanation

Comment part removed since it is just filler.

}:,|.  Input: string S
   |.  Reverse S
}:     Curtail, get S with its last char removed
  ,    Join them and return


答:
WinDbg, <s>142</s> 287 bytes

```<code>db$t0 L1;.for(r$t1=@$t0;@$p;r$t1=@$t1+1){db$t1 L1};r$t3=@$t1-1;.for(r$t1=@$t1-3;@$t1>=@$t0;r$t1=@$t1-1;r$t3=@$t3+1){m$t1 L1 $t3};eb$t3 0;da$t0;*;0t$ad;0 3t$be;}3t$ 1L 1t$m{)1+3t$@=3t$r;1-1t$@=1t$r;0t$@=>1t$@;3-1t$@=1t$r(rof.;1-1t$@=3t$r;}1L 1t$bd{)1+1t$@=1t$r;p$@;0t$@=1t$r(rof.;1L 0t$bd
</code>```

+145 bytes to make it a palindrome, nearly missed that requirement...

Input is passed in via an address in psuedo-register $t0. For example:

```<code>eza 2000000 "abcde"           * Write string "abcde" into memory at 0x02000000
r $t0 = 33554432              * Set $t0 = 0x02000000
* Edit: Something got messed up in my WinDB session, of course r $t0 = 2000000 should work
* not that crazy 33554432.
</code>```

This may be more golfable, for example I feel like there should be an easier way to convert a memory address in a register to the value at that address.

It works by concatenating the chars from the second-to-last to the first to the end of the string.

```<code>db $t0 L1;                                      * Set $p = memory-at($t0)
.for (r $t1 = @$t0; @$p; r $t1 = @$t1 + 1)      * Set $t1 = $t0 and increment until $p == 0
{
    db $t1 L1                                   * Set $p = memory-at($t1)
};
r $t3 = @$t1 - 1;                               * Point $t3 at end of string

* From the second-to-last char, reverse through the string with $t1 back to the start ($t0)
* and continue to increment $t3 as chars are appended to the string.
.for (r $t1 = @$t1 - 3; @$t1 >= @$t0; r $t1 = @$t1 - 1; r $t3 = @$t3 + 1)
{
    m $t1 L1 $t3                                * Copy char at $t1 to end of string ($t3)
};
eb $t3 0;                                       * Null terminate the new string
da $t0;                                         * Print the palindrome string

* Comment of the previous code in reverse, making the whole thing a palindrome
*;0t$ad;0 3t$be;}3t$ 1L 1t$m{)1+3t$@=3t$r;1-1t$@=1t$r;0t$@=>1t$@;3-1t$@=1t$r(rof.;1-1t$@=3t$r;}1L 1t$bd{)1+1t$@=1t$r;p$@;0t$@=1t$r(rof.;1L 0t$bd
</code>```

Output:

```<code>0:000> eza 2000000 "abcde"
0:000> r $t0 = 33554432
0:000> db$t0 L1;.for(r$t1=@$t0;@$p;r$t1=@$t1+1){db$t1 L1};r$t3=@$t1-1;.for(r$t1=@$t1-3;@$t1>=@$t0;r$t1=@$t1-1;r$t3=@$t3+1){m$t1 L1 $t3};eb$t3 0;da$t0;*;0t$ad;0 3t$be;}3t$ 1L 1t$m{)1+3t$@=3t$r;1-1t$@=1t$r;0t$@=>1t$@;3-1t$@=1t$r(rof.;1-1t$@=3t$r;}1L 1t$bd{)1+1t$@=1t$r;p$@;0t$@=1t$r(rof.;1L 0t$bd
02000000  61                                               a
02000000  61                                               a
02000001  62                                               b
02000002  63                                               c
02000003  64                                               d
02000004  65                                               e
02000005  00                                               .
02000000  "abcdedcba"
</code>```

Title: Palindromize this string!

Body:
WinDbg, <s>142</s> 287 bytes

db$t0 L1;.for(r$t1=@$t0;@$p;r$t1=@$t1+1){db$t1 L1};r$t3=@$t1-1;.for(r$t1=@$t1-3;@$t1>=@$t0;r$t1=@$t1-1;r$t3=@$t3+1){m$t1 L1 $t3};eb$t3 0;da$t0;*;0t$ad;0 3t$be;}3t$ 1L 1t$m{)1+3t$@=3t$r;1-1t$@=1t$r;0t$@=>1t$@;3-1t$@=1t$r(rof.;1-1t$@=3t$r;}1L 1t$bd{)1+1t$@=1t$r;p$@;0t$@=1t$r(rof.;1L 0t$bd

+145 bytes to make it a palindrome, nearly missed that requirement...

Input is passed in via an address in psuedo-register $t0. For example:

eza 2000000 "abcde"           * Write string "abcde" into memory at 0x02000000
r $t0 = 33554432              * Set $t0 = 0x02000000
* Edit: Something got messed up in my WinDB session, of course r $t0 = 2000000 should work
* not that crazy 33554432.

This may be more golfable, for example I feel like there should be an easier way to convert a memory address in a register to the value at that address.

It works by concatenating the chars from the second-to-last to the first to the end of the string.

db $t0 L1;                                      * Set $p = memory-at($t0)
.for (r $t1 = @$t0; @$p; r $t1 = @$t1 + 1)      * Set $t1 = $t0 and increment until $p == 0
{
    db $t1 L1                                   * Set $p = memory-at($t1)
};
r $t3 = @$t1 - 1;                               * Point $t3 at end of string

* From the second-to-last char, reverse through the string with $t1 back to the start ($t0)
* and continue to increment $t3 as chars are appended to the string.
.for (r $t1 = @$t1 - 3; @$t1 >= @$t0; r $t1 = @$t1 - 1; r $t3 = @$t3 + 1)
{
    m $t1 L1 $t3                                * Copy char at $t1 to end of string ($t3)
};
eb $t3 0;                                       * Null terminate the new string
da $t0;                                         * Print the palindrome string

* Comment of the previous code in reverse, making the whole thing a palindrome
*;0t$ad;0 3t$be;}3t$ 1L 1t$m{)1+3t$@=3t$r;1-1t$@=1t$r;0t$@=>1t$@;3-1t$@=1t$r(rof.;1-1t$@=3t$r;}1L 1t$bd{)1+1t$@=1t$r;p$@;0t$@=1t$r(rof.;1L 0t$bd

Output:

0:000> eza 2000000 "abcde"
0:000> r $t0 = 33554432
0:000> db$t0 L1;.for(r$t1=@$t0;@$p;r$t1=@$t1+1){db$t1 L1};r$t3=@$t1-1;.for(r$t1=@$t1-3;@$t1>=@$t0;r$t1=@$t1-1;r$t3=@$t3+1){m$t1 L1 $t3};eb$t3 0;da$t0;*;0t$ad;0 3t$be;}3t$ 1L 1t$m{)1+3t$@=3t$r;1-1t$@=1t$r;0t$@=>1t$@;3-1t$@=1t$r(rof.;1-1t$@=3t$r;}1L 1t$bd{)1+1t$@=1t$r;p$@;0t$@=1t$r(rof.;1L 0t$bd
02000000  61                                               a
02000000  61                                               a
02000001  62                                               b
02000002  63                                               c
02000003  64                                               d
02000004  65                                               e
02000005  00                                               .
02000000  "abcdedcba"


答:
WinDbg, <s>87</s> 71 bytes

```<code>db$t0 L1;.for(r$t1=@$t0;@$p;r$t1=@$t1+1){db$t1 L1};da$t0 L(@$t1-@$t0)/2
</code>```

-16 bytes by not inserting NULL, instead passing length to da

Input is passed in via an address in psuedo-register $t0. For example:

```<code>eza 2000000 "abcdedcba"       * Write string "abcdedcba" into memory at 0x02000000
r $t0 = 33554432              * Set $t0 = 0x02000000
* Edit: Something got messed up in my WinDB session, of course r $t0 = 2000000 should work
* not that crazy 33554432.
</code>```

It works by replacing the right of middle char (or right-middle if the string has even length) with a null and then prints the string from the original starting memory address.

```<code>db $t0 L1;                                   * Set $p = memory-at($t0)
.for (r $t1 = @$t0; @$p; r $t1 = @$t1 + 1)   * Set $t1 = $t0 and increment until $p == 0
{
    db $t1 L1                                * Set $p = memory-at($t1)
};
da $t0 L(@$t1-@$t0)/2                        * Print half the string
</code>```

Output:

```<code>0:000> eza 2000000 "abcdeedcba"
0:000> r $t0 = 33554432
0:000> db$t0 L1;.for(r$t1=@$t0;@$p;r$t1=@$t1+1){db$t1 L1};da$t0 L(@$t1-@$t0)/2
02000000  61                                               a
02000000  61                                               a
02000001  62                                               b
02000002  63                                               c
02000003  64                                               d
02000004  65                                               e
02000005  65                                               e
02000006  64                                               d
02000007  63                                               c
02000008  62                                               b
02000009  61                                               a
0200000a  00                                               .
02000000  "abcde"
</code>```

Title: Depalindromize this string!

Body:
WinDbg, <s>87</s> 71 bytes

db$t0 L1;.for(r$t1=@$t0;@$p;r$t1=@$t1+1){db$t1 L1};da$t0 L(@$t1-@$t0)/2

-16 bytes by not inserting NULL, instead passing length to da

Input is passed in via an address in psuedo-register $t0. For example:

eza 2000000 "abcdedcba"       * Write string "abcdedcba" into memory at 0x02000000
r $t0 = 33554432              * Set $t0 = 0x02000000
* Edit: Something got messed up in my WinDB session, of course r $t0 = 2000000 should work
* not that crazy 33554432.

It works by replacing the right of middle char (or right-middle if the string has even length) with a null and then prints the string from the original starting memory address.

db $t0 L1;                                   * Set $p = memory-at($t0)
.for (r $t1 = @$t0; @$p; r $t1 = @$t1 + 1)   * Set $t1 = $t0 and increment until $p == 0
{
    db $t1 L1                                * Set $p = memory-at($t1)
};
da $t0 L(@$t1-@$t0)/2                        * Print half the string

Output:

0:000> eza 2000000 "abcdeedcba"
0:000> r $t0 = 33554432
0:000> db$t0 L1;.for(r$t1=@$t0;@$p;r$t1=@$t1+1){db$t1 L1};da$t0 L(@$t1-@$t0)/2
02000000  61                                               a
02000000  61                                               a
02000001  62                                               b
02000002  63                                               c
02000003  64                                               d
02000004  65                                               e
02000005  65                                               e
02000006  64                                               d
02000007  63                                               c
02000008  62                                               b
02000009  61                                               a
0200000a  00                                               .
02000000  "abcde"


问:
Shortest code to determine if a string is a palindrome
A palindrome is some string that is spelled the same way both backwards and forwards.  For instance, 'Eva, can I stab bats in a cave?' is a palindrome (EVACANISTAB | BATSINACAVE)

For this code golf, using the language of your choice, determine if a given string is a palindrome or not.

Edge Cases:

Punctuation is not counted towards palindrominess.

Control characters are not counted towards palindrominess.

Whitespace is not counted towards palindrominess.

Numbers are counted towards palindrominess.

Case in this challenge is not counted towards palindrominess.

There is no limit to the length of strings to evaluate, except for what is imposed by your language of choice.

For this challenge, limit yourself to the ASCII character set.

Technical Requirements:

Only method bodies are needed; additional things like method signatures, data structure declarations, etc. do not count towards the victory requirement.

Code must compile or interpret without compile-time errors or exceptions.

Code must not throw any unhandled exceptions or crash.  (Almost needless to say.  Almost.)

Code must return some value indicating palindrominess.  The data type depends on the language you use (e.g. a C# user might use a bool, whereas a JavaScript user could use a var.)

You may not write your own interpreter that performs this task as a 'native' capability so you can 'golf' a near-winning score.  (Hopefully needless to say.)

Victory Condition:

The shortest code in characters wins.

Current Leader: tmartin (k, 25 characters)

...Want the magic green check mark by your answer?  Beat this guy's answer!

答:
APL, <s>78</s> 65 Bytes

```<code>l←⎕D,⎕UCS v+32⊣c←⎕D,⎕UCS v←64+⍳26⋄(⌽≡⊢)∊{⍵/⍨⍵∊l}¨{⍵∊c:l[c⍳⍵]⋄⍵}¨⎕
</code>```

I'm going to assume that the Original Poster meant limit the INPUT string to the Ascii character set.

Body:
APL, <s>78</s> 65 Bytes

l←⎕D,⎕UCS v+32⊣c←⎕D,⎕UCS v←64+⍳26⋄(⌽≡⊢)∊{⍵/⍨⍵∊l}¨{⍵∊c:l[c⍳⍵]⋄⍵}¨⎕

I'm going to assume that the Original Poster meant limit the INPUT string to the Ascii character set.


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

答:
JavaScript (ES6), 30 bytes

```<code>f=n=>++n%3*!/3/.test(n)?n:f(n)
</code>```

Title: Count without 3

Body:
JavaScript (ES6), 30 bytes

f=n=>++n%3*!/3/.test(n)?n:f(n)


答:
Java 8, <s>57</s> <s>56</s> <s>55</s> 50 bytes

Thanks to @Numberknot for 1 byte
Thanks to @Kevin Cruijssen for 5 bytes

```<code>i->{for(;++i%3<1|(i+"").contains("3"););return i;}
</code>```

This is a Function<Integer, Integer>

Explanation

Naive implementation that simply increments until it reaches an acceptable number.

Test Class

```<code>public class CodeGolf {

    public static void main(String[] args) {
        Function<Integer, Integer> countingGame = i->{for(;++i%3<1|(i+"").contains("3"););return i;};
        int val = 1;
        for (int i = 0; i < 10; i++) {
            System.out.print(val + " ");
            val = countingGame.apply(val);
        }
    }

}
</code>```

Output of Test Class:

```<code>1 2 4 5 7 8 10 11 14 16
</code>```

Title: Count without 3

Body:
Background

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

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

However, the following numbers must be skipped while counting:

Numbers that are multiples of 3.

Numbers that have a 3 in its decimal representation.

The first 15 numbers the kids should say are

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

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

Task

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

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

Input and output can use any convenient base.

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

Test cases

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

Body:
Java 8, <s>57</s> <s>56</s> <s>55</s> 50 bytes

Thanks to @Numberknot for 1 byte
Thanks to @Kevin Cruijssen for 5 bytes

i->{for(;++i%3<1|(i+"").contains("3"););return i;}

This is a Function<Integer, Integer>

Explanation

Naive implementation that simply increments until it reaches an acceptable number.

Test Class

public class CodeGolf {

    public static void main(String[] args) {
        Function<Integer, Integer> countingGame = i->{for(;++i%3<1|(i+"").contains("3"););return i;};
        int val = 1;
        for (int i = 0; i < 10; i++) {
            System.out.print(val + " ");
            val = countingGame.apply(val);
        }
    }

}

Output of Test Class:

1 2 4 5 7 8 10 11 14 16


答:
Python 2, 73 66 43 bytes

Thanks to xnor for telling me I was being silly by using 2 variables, and thanks to Mitch Schwartz too.

```<code>x=~input()
while'3'[:x%3]in`x`:x-=1
print-x
</code>```

Title: Count without 3

Body:
Python 2, 73 66 43 bytes

Thanks to xnor for telling me I was being silly by using 2 variables, and thanks to Mitch Schwartz too.

x=~input()
while'3'[:x%3]in`x`:x-=1
print-x


答:
D - 87 bytes

```<code>void main(){import std.stdio,std.conv;int i=readln[0..$-1].to!int;do i.write;while(i);}
</code>```

Title: Implement a Truth-Machine

Body:
A truth-machine (credits goes to this guy for coming up with it) is a very simple program designed to demonstrate the I/O and control flow of a language. Here's what a truth-machine does:

Gets a number (either 0 or 1) from STDIN.

If that number is 0, print out 0 and terminate.

If that number is 1, print out 1 forever.

Challenge

Write a truth-machine as described above in your language of choice. The truth-machine must be a full program that follows these rules:

take input from STDIN or an acceptable alternative

If your language cannot take input from STDIN, it may take input from a hardcoded variable or suitable equivalent in the program

must output to STDOUT or an acceptable alternative

If your language is incapable of outputting the characters 0 or 1, byte or unary I/O is acceptable.

when the input is 1, it must continually print 1s and only stop if the program is killed or runs out of memory

the output must only be either a 0 followed by either one or no newline or space, or infinite 1s with each 1 followed by either one or no newline or space. No other output can be generated, except constant output of your language's interpreter that cannot be suppressed (such as a greeting, ANSI color codes or indentation). Your usage of newlines or spaces must be consistent: for example, if you choose to output 1 with a newline after it all 1s must have a newline after them.

if and only if your language cannot possibly terminate on an input of 0 it is acceptable for the code to enter an infinite loop in which nothing is outputted.

Since this is a catalog, languages created after this challenge are allowed to compete. Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language. Other than that, all the standard rules of code-golf must be obeyed. Submissions in most languages will be scored in bytes in an appropriate preexisting encoding (usually UTF-8).

Catalog

The Stack Snippet at the bottom of this post generates the catalog from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

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

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

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

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

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

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

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

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

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

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

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

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

```

Body:
D - 87 bytes

void main(){import std.stdio,std.conv;int i=readln[0..$-1].to!int;do i.write;while(i);}


答:
Japt, 18 bytes

```<code>°U%3*!Us f'3 ?U:ßU
</code>```

Test it online

I finally have a chance to use ß :-)

How it works

```<code>                    // Implicit: U = input integer
°U%3                // Increment U, and take its modulo by 3.
     !Us f'3        // Take all matches of /3/ in the number, then take logical NOT.
                    // This returns true if the number does not contain a 3.
    *               // Multiply. Returns 0 if U%3 === 0  or the number contains a 3.
             ?U     // If this is truthy (non-zero), return U.
               :ßU  // Otherwise, return the result of running the program again on U.
                    // Implicit: output last expression
</code>```

Title: Count without 3

Body:
Japt, 18 bytes

°U%3*!Us f'3 ?U:ßU

Test it online

I finally have a chance to use ß :-)

How it works

                    // Implicit: U = input integer
°U%3                // Increment U, and take its modulo by 3.
     !Us f'3        // Take all matches of /3/ in the number, then take logical NOT.
                    // This returns true if the number does not contain a 3.
    *               // Multiply. Returns 0 if U%3 === 0  or the number contains a 3.
             ?U     // If this is truthy (non-zero), return U.
               :ßU  // Otherwise, return the result of running the program again on U.
                    // Implicit: output last expression


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

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

```<code>^HBS
</code>```

Try it online! or verify all test cases.

Background

Let n be a non-negative integer.

Steps 2 and 3 of the process described in the spec can alternatively be stated as removing all leading 1's and toggling the remaining bits.

This means that we'll remove exactly one group of adjacent and equal binary digits in each iteration, so the Binary Countdown Length of n is just the number of these groups in the binary representation of n. For the purposes of this challenge, think of 0 as having no digits.

For n = 8675309, the process looks as follows in binary.

```<code>100001000101111111101101
 11110111010000000010010
     1000101111111101101
      111010000000010010
         101111111101101
          10000000010010
           1111111101101
                   10010
                    1101
                      10
                       1
                       0
</code>```

Instead of counting these groups (which would fail for edge case 0), we do the following.

n and n:2 have the following binary representations.

```<code>n   = 8675309 = 100001000101111111101101_2
n:2 = 4337654 =  10000100010111111110110_2
</code>```

Note that n:2's binary representation is simply n's, shifted one bit to the left.

If we XOR n and n:2, we'll obtain a 1 (MSB), and an additional 1 for each pair of different adjacent digits. The number of groups is thus equal to the number of set bits in n ⊻ n:2.

How it works

```<code>^HBS  Main link. Argument: n

 H    Halve; yield n:2.
^     XOR n with n:2.
  B   Convert the result to binary.
   S  Compute the sum of the resulting binary digits.
</code>```

Title: Binary Countdown Length

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

^HBS

Try it online! or verify all test cases.

Background

Let n be a non-negative integer.

Steps 2 and 3 of the process described in the spec can alternatively be stated as removing all leading 1's and toggling the remaining bits.

This means that we'll remove exactly one group of adjacent and equal binary digits in each iteration, so the Binary Countdown Length of n is just the number of these groups in the binary representation of n. For the purposes of this challenge, think of 0 as having no digits.

For n = 8675309, the process looks as follows in binary.

100001000101111111101101
 11110111010000000010010
     1000101111111101101
      111010000000010010
         101111111101101
          10000000010010
           1111111101101
                   10010
                    1101
                      10
                       1
                       0

Instead of counting these groups (which would fail for edge case 0), we do the following.

n and n:2 have the following binary representations.

n   = 8675309 = 100001000101111111101101_2
n:2 = 4337654 =  10000100010111111110110_2

Note that n:2's binary representation is simply n's, shifted one bit to the left.

If we XOR n and n:2, we'll obtain a 1 (MSB), and an additional 1 for each pair of different adjacent digits. The number of groups is thus equal to the number of set bits in n ⊻ n:2.

How it works

^HBS  Main link. Argument: n

 H    Halve; yield n:2.
^     XOR n with n:2.
  B   Convert the result to binary.
   S  Compute the sum of the resulting binary digits.


答:
J, 24 bytes

```<code>3(]0&({$:)~e.&":+.0=|)>:
</code>```

Straight-forward approach that just iterates forward from input n until it finds the next number that is valid by the rules.

Forms five smileys, $:, :), 0=, =|, and >:.

Usage

```<code>   f =: 3(]0&({$:)~e.&":+.0=|)>:
   (,.f"0) 1 2 11 22 29 251
  1   2
  2   4
 11  14
 22  25
 29  40
251 254
</code>```

Explanation

```<code>3(]0&({$:)~e.&":+.0=|)>:  Input: integer n
                      >:  Increment n
3                         The constant 3
 (                   )    Operate dyadically with 3 (LHS) and n+1 (RHS)
                    |       Take (n+1) mod 3
                  0=        Test if equal to 0
             &":            Format both 3 and n+1 as a string
           e.               Test if it contains '3' in str(n+1)
                +.          Logical OR the results from those two tests
  ]                         Right identity, gets n+1
   0&(   )~                 If the result from logical OR is true
       $:                     Call recursively on n+1
      {                       Return that as the result
                            Else act as identity function and return n+1
</code>```

Title: Count without 3

Body:
J, 24 bytes

3(]0&({$:)~e.&":+.0=|)>:

Straight-forward approach that just iterates forward from input n until it finds the next number that is valid by the rules.

Forms five smileys, $:, :), 0=, =|, and >:.

Usage

   f =: 3(]0&({$:)~e.&":+.0=|)>:
   (,.f"0) 1 2 11 22 29 251
  1   2
  2   4
 11  14
 22  25
 29  40
251 254

Explanation

3(]0&({$:)~e.&":+.0=|)>:  Input: integer n
                      >:  Increment n
3                         The constant 3
 (                   )    Operate dyadically with 3 (LHS) and n+1 (RHS)
                    |       Take (n+1) mod 3
                  0=        Test if equal to 0
             &":            Format both 3 and n+1 as a string
           e.               Test if it contains '3' in str(n+1)
                +.          Logical OR the results from those two tests
  ]                         Right identity, gets n+1
   0&(   )~                 If the result from logical OR is true
       $:                     Call recursively on n+1
      {                       Return that as the result
                            Else act as identity function and return n+1


答:
CJam, 14 bytes

```<code>ri0{2b:!2bj)}j
</code>```

Try it online!

```<code>ri      e# read integer
0       e# value for terminal case
{       e# recursive function
  2b    e#   create binary representation with no leading zeros
  :!    e#   flip bits
  2b    e#   convert binary back to integer
  j     e#   recursive call
  )     e#   increment from 0 on the way up
}j      e# end
</code>```

Basically a knock off of my answer to the other question.

Title: Binary Countdown Length

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

Body:
CJam, 14 bytes

ri0{2b:!2bj)}j

Try it online!

ri      e# read integer
0       e# value for terminal case
{       e# recursive function
  2b    e#   create binary representation with no leading zeros
  :!    e#   flip bits
  2b    e#   convert binary back to integer
  j     e#   recursive call
  )     e#   increment from 0 on the way up
}j      e# end

Basically a knock off of my answer to the other question.


答:
V, 12 bytes

Two completely different solutions, both 12 bytes.

```<code>ò"Bx$xh|ò"bP
</code>```

Try it online!

```<code>Ó./&ò
MjdGÍî
</code>```

Try it online!

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:
V, 12 bytes

Two completely different solutions, both 12 bytes.

ò"Bx$xh|ò"bP

Try it online!

Ó./&ò
MjdGÍî

Try it online!


答:
Racket 230 bytes

```<code>(let((sl string-length)(ss substring))(if(odd?(sl s))(printf ".~n")(begin(let p((s s))(if(equal? s "")(printf "!")
(for((i(range 1(add1(/(sl s)2)))))(when(equal?(ss s 0 i)(ss s i(* 2 i)))(p(ss s(* 2 i)(sl s)))))))(printf ".~n"))))
</code>```

Prints a '!' for each way in which the string is pairable. Prints a '.' at the end.

Ungolfed:

```<code>(define (f s)
  (let ((sl string-length)                              ; create short names of built-in fns
        (ss substring))
    (if (odd? (sl s))  (printf ".~n")                   ; odd length strings cannot be pairable; end here.
        (begin
          (let loop ((s s))                             ; start testing here
            (if (equal? s "") (printf "!")              ; if no remaining string, it must be pairable
                (for ((i (range 1 (add1 (/(sl s)2)))))  ; ch lengths varying from 1 to half of string length
                  (when (equal? (ss s 0 i)              ; ch if substrings are same
                                (ss s i (* 2 i)))
                    (loop (ss s (* 2 i) (sl s) ))))))   ; if yes, loop to check remaining string.
          (printf ".~n")))))                            ; End of testing.
</code>```

Testing:

```<code>(println "Following should be pairable")
(f "bbaabbaa")            ; should produce 2 '!' since 2 ways are possible.
(f "aa")
(f "abaaba")
(f "bbababbb")
(f "aabaaababbbaba")
(f "babababa")                    ; should be pairable in 2 ways.
(f "bbbbbbbbbbbb")                ; should be pairable in many ways.
(f "aaababbabbabbbababbaabaabaababaaba")
(f "aaaabaab")
(println "Following should be unpairable")
; (f "a")
(f "ba")
(f "baab")
(f "abaabaaba")
(f "bbbbbbbbbbbbbbb")
(f "baababbabaaaab")
(f "aaaaabbaaaaa")
</code>```

Output:

```<code>"Following should be pairable"
!!.
!.
!.
!.
!.
!!.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.
!.
!.
"Following should be unpairable"
.
.
.
.
.
.
</code>```

Title: Pairable strings

Body:
A string is pairable if it can be split into subtrings, each of which is a string repeated twice consecutively. For example, aabaaababbbaba is pairable as:

```<code>aaba aaba
b b
ba ba
</code>```

Given a non-empty string of a's and b's, output a Truthy value if it's pairable and a Falsey value if it isn't.

Pairable:

```<code>aa
abaaba
bbababbb
aabaaababbbaba
babababa
bbbbbbbbbbbb
aaababbabbabbbababbaabaabaababaaba
aaaabaab
</code>```

Not pairable:

```<code>a
ba
baab
abaabaaba
bbbbbbbbbbbbbbb
baababbabaaaab
aaaaabbaaaaa
</code>```

I encourage you to come up with non-regex-based solutions even when there's already a shorter regex answer in your language. You can mark them as "no regex". By regex, I mean a built-in string pattern matching subsystem.

Leaderboard:

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

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

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

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

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

```

Body:
Racket 230 bytes

(let((sl string-length)(ss substring))(if(odd?(sl s))(printf ".~n")(begin(let p((s s))(if(equal? s "")(printf "!")
(for((i(range 1(add1(/(sl s)2)))))(when(equal?(ss s 0 i)(ss s i(* 2 i)))(p(ss s(* 2 i)(sl s)))))))(printf ".~n"))))

Prints a '!' for each way in which the string is pairable. Prints a '.' at the end.

Ungolfed:

(define (f s)
  (let ((sl string-length)                              ; create short names of built-in fns
        (ss substring))
    (if (odd? (sl s))  (printf ".~n")                   ; odd length strings cannot be pairable; end here.
        (begin
          (let loop ((s s))                             ; start testing here
            (if (equal? s "") (printf "!")              ; if no remaining string, it must be pairable
                (for ((i (range 1 (add1 (/(sl s)2)))))  ; ch lengths varying from 1 to half of string length
                  (when (equal? (ss s 0 i)              ; ch if substrings are same
                                (ss s i (* 2 i)))
                    (loop (ss s (* 2 i) (sl s) ))))))   ; if yes, loop to check remaining string.
          (printf ".~n")))))                            ; End of testing.

Testing:

(println "Following should be pairable")
(f "bbaabbaa")            ; should produce 2 '!' since 2 ways are possible.
(f "aa")
(f "abaaba")
(f "bbababbb")
(f "aabaaababbbaba")
(f "babababa")                    ; should be pairable in 2 ways.
(f "bbbbbbbbbbbb")                ; should be pairable in many ways.
(f "aaababbabbabbbababbaabaabaababaaba")
(f "aaaabaab")
(println "Following should be unpairable")
; (f "a")
(f "ba")
(f "baab")
(f "abaabaaba")
(f "bbbbbbbbbbbbbbb")
(f "baababbabaaaab")
(f "aaaaabbaaaaa")

Output:

"Following should be pairable"
!!.
!.
!.
!.
!.
!!.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.
!.
!.
"Following should be unpairable"
.
.
.
.
.
.


答:
Python 2, 30 bytes

lambda n:bin(n^n/2).count('1')
```

<p>Test it on Ideone.</p>

<h3>Background</h3>

<p>Let <strong>n</strong> be a non-negative integer.</p>

<p>Steps 2 and 3 of the process described in the spec can alternatively be stated as removing all leading <strong>1</strong>'s and toggling the remaining bits. </p>

<p>This means that we'll remove exactly one group of adjacent and equal binary digits in each iteration, so the Binary Countdown Length of <strong>n</strong> is just the number of these groups in the binary representation of <strong>n</strong>. For the purposes of this challenge, think of <strong>0</strong> as having no digits.</p>

<p>For <strong>n = 8675309</strong>, the process looks as follows in binary.</p>

```100001000101111111101101
 11110111010000000010010
     1000101111111101101
      111010000000010010
         101111111101101
          10000000010010
           1111111101101
                   10010
                    1101
                      10
                       1
                       0
```

<p>Instead of counting these groups (which would fail for edge case <strong>0</strong>), we do the following.</p>

<p><strong>n</strong> and <strong>n:2</strong> have the following binary representations.</p>

```n   = 8675309 = 100001000101111111101101_2
n:2 = 4337654 =  10000100010111111110110_2
```

Note that n:2's binary representation is simply n's, shifted one bit to the left.

If we XOR n and n:2, we'll obtain a 1 (MSB), and an additional 1 for each pair of different adjacent digits. The number of groups is thus equal to the number of set bits in n ⊻ n:2.

Title: Binary Countdown Length

Body:
Python 2, 30 bytes

lambda n:bin(n^n/2).count('1')

Test it on Ideone.

Background

Let n be a non-negative integer.

Steps 2 and 3 of the process described in the spec can alternatively be stated as removing all leading 1's and toggling the remaining bits.

This means that we'll remove exactly one group of adjacent and equal binary digits in each iteration, so the Binary Countdown Length of n is just the number of these groups in the binary representation of n. For the purposes of this challenge, think of 0 as having no digits.

For n = 8675309, the process looks as follows in binary.

100001000101111111101101
 11110111010000000010010
     1000101111111101101
      111010000000010010
         101111111101101
          10000000010010
           1111111101101
                   10010
                    1101
                      10
                       1
                       0

Instead of counting these groups (which would fail for edge case 0), we do the following.

n and n:2 have the following binary representations.

n   = 8675309 = 100001000101111111101101_2
n:2 = 4337654 =  10000100010111111110110_2

Note that n:2's binary representation is simply n's, shifted one bit to the left.

If we XOR n and n:2, we'll obtain a 1 (MSB), and an additional 1 for each pair of different adjacent digits. The number of groups is thus equal to the number of set bits in n ⊻ n:2.


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

答:
Python 2, <s>122</s> <s>120</s> <s>102</s> 98 bytes

18 bytes saved thanks to  Flp.Tkc

4 bytes saved thanks to xnor

lambda x:sorted([bin(i)[2:].zfill(x)for i in range(2**x)],key=lambda x:(sorted(x),int(x[::-1],2)))
```

<h2>Explanation</h2>

<p>This makes all the binary strings of length x with:</p>

<pre class="lang-python prettyprint-override"><code>[bin(i)[2:].xfill(x)for i in range(2**x)]
</code>```

I then sort them according to:

lambda x:(sorted(x),int(x[::-1],2))
```

sorted(x) prioritizes the number of 1s while int(x[::-1],2) prioritizes the second condition

Lastly these are joined with newlines and printed.

Body:
Python 2, <s>122</s> <s>120</s> <s>102</s> 98 bytes

18 bytes saved thanks to  Flp.Tkc

4 bytes saved thanks to xnor

lambda x:sorted([bin(i)[2:].zfill(x)for i in range(2**x)],key=lambda x:(sorted(x),int(x[::-1],2)))

Explanation

This makes all the binary strings of length x with:

[bin(i)[2:].xfill(x)for i in range(2**x)]

I then sort them according to:

lambda x:(sorted(x),int(x[::-1],2))

sorted(x) prioritizes the number of 1s while int(x[::-1],2) prioritizes the second condition

Lastly these are joined with newlines and printed.


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

```

答:
Clojure/Groovy, 37 bytes

```<code>;/*
(println"trick");*/println"treat"
</code>```

Clojure (trick)

The ; denotes a single-line comment, so Clojure sees:

```<code>(println "trick")
</code>```

Groovy (treat)

Any single ; is a valid statement that does nothing. Obviously /* ... */ is a multi-line comment. Groovy sees:

```<code>println "treat"
</code>```

Title: Trick or Treat polyglot

Body:
Clojure/Groovy, 37 bytes

;/*
(println"trick");*/println"treat"

Clojure (trick)

The ; denotes a single-line comment, so Clojure sees:

(println "trick")

Groovy (treat)

Any single ; is a valid statement that does nothing. Obviously /* ... */ is a multi-line comment. Groovy sees:

println "treat"


答:
Brain-Flak, 45 bytes

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

Try it online!

42 bytes of code, and +3 for the -c flag which enables ASCII input and output.

Title: Depalindromize this string!

Body:
Brain-Flak, 45 bytes

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

Try it online!

42 bytes of code, and +3 for the -c flag which enables ASCII input and output.


答:
Lua, 58 Bytes

```<code>i=...+1while(i%3==0or(i..""):find"3")do i=i+1 end print(i)
</code>```

Title: Count without 3

Body:
Background

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

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

However, the following numbers must be skipped while counting:

Numbers that are multiples of 3.

Numbers that have a 3 in its decimal representation.

The first 15 numbers the kids should say are

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

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

Task

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

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

Input and output can use any convenient base.

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

Test cases

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

Body:
Lua, 58 Bytes

i=...+1while(i%3==0or(i..""):find"3")do i=i+1 end print(i)


问:
Draw an hourglass
Again inspired by a task for Programming 101 here's another challenge.

Input:

A positive integer n >= 3. (has to be odd)

Output:

n lines of asterisks, where the first line has n asterisks and every new line has two asterisks less than the line before. Until hitting 1 asterisk. From there every new line has two asterisks more than the line before until getting back to n asterisks. Spaces or something like spaces have to used to align the asterisks so that it really will look like an hourglass.

General rules:

Trailing newlines are allowed but do not have to be used.

indentation is a must.

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

Since the course is taught in C++, I'm eager to see solutions in C++.

Test case (n=5):

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

答:
Actually, 34 bytes

```<code>;╗R`1&`░`'**╜kd#"{:^%d}"%f`M;pXR+i
</code>```

Try it online!

Explanation:

```<code>;╗R`1&`░`'**╜kd#"{:^%d}"%f`M;pXR+i
;╗                                  store a copy of n in register 0
  R                                 range(1, n+1) ([1, n])
   `1&`░                            filter: keep only odd values
        `'**╜kd#"{:^%d}"%f`M        for each value:
         '**                          push a string containing that many asterisks
            ╜                         push n
             kd#                      list from stack, dequeue, listify (make both stack elements singleton lists)
                "{:^%d}"%             format string to center string in n-wide field
                         f            do the formatting
                            ;pXR+   duplicate list, discard the extra "*" element, reverse, and append original list (vertical mirroring)
                                 i  flatten and implicitly print
</code>```

Title: Draw an hourglass

Body:
Actually, 34 bytes

;╗R`1&`░`'**╜kd#"{:^%d}"%f`M;pXR+i

Try it online!

Explanation:

;╗R`1&`░`'**╜kd#"{:^%d}"%f`M;pXR+i
;╗                                  store a copy of n in register 0
  R                                 range(1, n+1) ([1, n])
   `1&`░                            filter: keep only odd values
        `'**╜kd#"{:^%d}"%f`M        for each value:
         '**                          push a string containing that many asterisks
            ╜                         push n
             kd#                      list from stack, dequeue, listify (make both stack elements singleton lists)
                "{:^%d}"%             format string to center string in n-wide field
                         f            do the formatting
                            ;pXR+   duplicate list, discard the extra "*" element, reverse, and append original list (vertical mirroring)
                                 i  flatten and implicitly print


答:
Python 2, 29 bytes

f=lambda n:n and-n%4/2+f(n/2)
```

Counts the number of alternations between 0 and 1 in the binary expansion, counting the leading 1 as an alternation. Does so by checking whether the last two binary digits are different, then recursing onto the number with the last digit removed. The last two digits are different exactly if n%4 is 1 or 2, which can be checked as -n%4/2.

Title: Binary Countdown Length

Body:
Python 2, 29 bytes

f=lambda n:n and-n%4/2+f(n/2)

Counts the number of alternations between 0 and 1 in the binary expansion, counting the leading 1 as an alternation. Does so by checking whether the last two binary digits are different, then recursing onto the number with the last digit removed. The last two digits are different exactly if n%4 is 1 or 2, which can be checked as -n%4/2.