问:
Print multiplication tables by input
In this challenge you've to print multiplication tables by input, Here are some examples:

```<code>Input: 2

Output:
0 2  4 6 8  10  12  14  16  18  20

Input: 20

Output: 20 40 60 80 100 120 140 160 180 200
</code>```

Rules

The shortest code in bytes wins.

This challenge is a code-golf, It follows code-golf general rules (code-golf)

If, just if, your code can't print number, you can use letters, Here is an example:

Input: B

Output: B D F H J L N P R T

You can choose to start from 0 or your number (like 20). You can choose if put spaces or don't. The challenge is free, just take an input and print multiplication tables.

Your output must list the first 10 members of the times table for the given number. You may leave out 0*n.

答:
Sesos, 12 bytes

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

Since this contains unprintables, here is an xxd reversible hexdump:

```<code>0000000: d6cb82 06efbe 7e7ed0 ef1fcf                       ......~~....
</code>```

The SASM that was used to compile the above SBIN is here:

```<code>set numin            ;Input consists of linefeed-separated integers from now on.
set numout           ;Output consists of linefeed-separated integers from now on.
get                  ;Get the input.
fwd 1                ;Go to the repeat-count cell.
add 10               ;Repeat 10 times.
jmp                  ;Enter the loop.
 sub 1                ;This is a repeat-n-times loop.
 rwd 1                ;Go to the proper cell.
 jmp                  ;Table generation method.
  sub 1                ;Value copying.
  fwd 2                ;Go to the multiple cell.
  add 1                ;Add the value.
  fwd 1                ;Go to an empty cell.
  add 1                ;Copy the original value, so that we don't lose it.
  rwd 3                ;Enable finishing check.
 jnz                  ;Check if the method is finished.
 fwd 3                ;Where the original value has been copied.
 jmp                  ;Move the value back to its original place.
  sub 1                ;Empty the cell.
  rwd 3                ;Go to the original cell.
  add 1                ;Set it to the original value.
  fwd 3                ;Enable finishing check.
 jnz                  ;Check if the moving is finished.
 rwd 1                ;Go to the multiply cell.
 put                  ;Print its value.
 rwd 1                ;Enable finishing check.
                     ;(implicit jnz) Check if execution should be terminated.
</code>```

Try it online!

Output is like this:

```1
2
3
4
5
6
7
8
9
10

```

Title: Print multiplication tables by input

Body:
Sesos, 12 bytes

~~

Since this contains unprintables, here is an xxd reversible hexdump:

0000000: d6cb82 06efbe 7e7ed0 ef1fcf                       ......~~....

The SASM that was used to compile the above SBIN is here:

set numin            ;Input consists of linefeed-separated integers from now on.
set numout           ;Output consists of linefeed-separated integers from now on.
get                  ;Get the input.
fwd 1                ;Go to the repeat-count cell.
add 10               ;Repeat 10 times.
jmp                  ;Enter the loop.
 sub 1                ;This is a repeat-n-times loop.
 rwd 1                ;Go to the proper cell.
 jmp                  ;Table generation method.
  sub 1                ;Value copying.
  fwd 2                ;Go to the multiple cell.
  add 1                ;Add the value.
  fwd 1                ;Go to an empty cell.
  add 1                ;Copy the original value, so that we don't lose it.
  rwd 3                ;Enable finishing check.
 jnz                  ;Check if the method is finished.
 fwd 3                ;Where the original value has been copied.
 jmp                  ;Move the value back to its original place.
  sub 1                ;Empty the cell.
  rwd 3                ;Go to the original cell.
  add 1                ;Set it to the original value.
  fwd 3                ;Enable finishing check.
 jnz                  ;Check if the moving is finished.
 rwd 1                ;Go to the multiply cell.
 put                  ;Print its value.
 rwd 1                ;Enable finishing check.
                     ;(implicit jnz) Check if execution should be terminated.

<a href="http://sesos.tryitonline.net#code=c2V0IG51bWluICAgICAgICAgICAgO0lucHV0IGNvbnNpc3RzIG9mIGxpbmVmZWVkLXNlcGFyYXRlZCBpbnRlZ2VycyBmcm9tIG5vdyBvbi4Kc2V0IG51bW91dCAgICAgICAgICAgO091dHB1dCBjb25zaXN0cyBvZiBsaW5lZmVlZC1zZXBhcmF0ZWQgaW50ZWdlcnMgZnJvbSBub3cgb24uCmdldCAgICAgICAgICAgICAgICAgIDtHZXQgdGhlIGlucHV0Lgpmd2QgMSAgICAgICAgICAgICAgICA7R28gdG8gdGhlIHJlcGVhdC1jb3VudCBjZWxsLgphZGQgMTAgICAgICAgICAgICAgICA7UmVwZWF0IDEwIHRpbWVzLgpqbXAgICAgICAgICAgICAgICAgICA7RW50ZXIgdGhlIGxvb3AuCiBzdWIgMSAgICAgICAgICAgICAgICA7VGhpcyBpcyBhIHJlcGVhdC1uLXRpbWVzIGxvb3AuCiByd2QgMSAgICAgICAgICAgICAgICA7R28gdG8gdGhlIHByb3BlciBjZWxsLgogam1wICAgICAgICAgICAgICAgICAgO1RhYmxlIGdlbmVyYXRpb24gbWV0aG9kLgogIHN1YiAxICAgICAgICAgICAgICAgIDtWYWx1ZSBjb3B5aW5nLgogIGZ3ZCAyICAgICAgICAgICAgICAgIDtHbyB0byB0aGUgbXVsdGlwbGUgY2VsbC4KICBhZGQgMSAgICAgICAgICAgICAgICA7QWRkIHRoZSB2YWx1ZS4KICBmd2QgMSAgICAgICAgICAgICAgICA7R28gdG8gYW4gZW1wdHkgY2VsbC4KICBhZGQgMSAgICAgICAgICAgICAgICA7Q29weSB0aGUgb3JpZ2luYWwgdmFsdWUsIHNvIHRoYXQgd2UgZG9uJ3QgbG9zZSBpdC4KICByd2QgMyAgICAgICAgICAgICAgICA7RW5hYmxlIGZpbmlzaGluZyBjaGVjay4KIGpueiAgICAgICAgICAgICAgICAgIDtDaGVjayBpZiB0aGUgbWV0aG9kIGlzIGZpbmlzaGVkLgogZndkIDMgICAgICAgICAgICAgICAgO1doZXJlIHRoZSBvcmlnaW5hbCB2YWx1ZSBoYXMgYmVlbiBjb3BpZWQuCiBqbXAgICAgICAgICAgICAgICAgICA7TW92ZSB0aGUgdmFsdWUgYmFjayB0byBpdHMgb3JpZ2luYWwgcGxhY2UuCiAgc3ViIDEgICAgICAgICAgICAgICAgO0VtcHR5IHRoZSBjZWxsLgogIHJ3ZCAzICAgICAgICAgICAgICAgIDtHbyB0byB0aGUgb3JpZ2luYWwgY2VsbC4KICBhZGQgMSAgICAgICAgICAgICAgICA7U2V0IGl0IHRvIHRoZSBvcmlnaW5hbCB2YWx1ZS4KICBmd2QgMyAgICAgICAgICAgICAgICA7RW5hYmxlIGZpbmlzaGluZyBjaGVjay4KIGpueiAgICAgICAgICAgICAgICAgIDtDaGVjayBpZiB0aGUgbW92aW5nIGlzIGZpbmlzaGVkLgogcndkIDEgICAgICAgICAgICAgICAgO0dvIHRvIHRoZSBtdWx0aXBseSBjZWxsLgogcHV0ICAgICAgICAgICAgICAgICAgO1ByaW50IGl0cyB2YWx1ZS4KIHJ3ZCAxICAgICAgICAgICAgICAgIDtFbmFibGUgZmluaXNoaW5nIGNoZWNrLgogICAgICAgICAgICAgICAgICAgICA7KGltcGxpY2l0IGpueikgQ2hlY2sgaWYgZXhlY3V0aW9uIHNob3VsZCBiZSB0ZXJtaW5hdGVkLg&input=MTE" rel="nofollow noreferrer">Try it online!

Output is like this:

1
2
3
4
5
6
7
8
9
10


问:
Folding Numbers
Given a number determine if it is a folding number.

A folding number is a number such that if you take it binary representation and "fold" it in half,  That is take the result of XNOR multiplication of the first half of the number and the second half with it digits in reverse, you will get zero.

If the number has a odd number of digits in binary its middle digit must be 1 and is ignored when folding.

Since that might be a bit confusing I will give some examples:

178

The binary representation of 178 is

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

To fold this we first split it in half

```<code>1011 0010
</code>```

We reverse the second half

```<code>1011
0100
</code>```

And we XNOR the two halves:

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

This is zero so this is a folding number.

1644

The binary representation of 1644 is

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

To fold this we first split it in half

```<code>11001 1 01100
</code>```

The middle bit is 1 so we throw it out.

```<code>11001 01100
</code>```

We reverse the second half

```<code>11001
00110
</code>```

And we XNOR the two halves:

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

This is zero so this is a folding number.

4254

The binary representation of 4254 is

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

To fold this we first split it in half

```<code>100001 0 011110
</code>```

The middle bit is 0 so this is not a folding number.

Task

Your task is to take in a positive number and return a truthy if the number is folding and falsy if it is not.  This is code golf so try to keep the byte count down.

Test Cases

Here are the first 99 folding numbers:

```<code>[1, 2, 6, 10, 12, 22, 28, 38, 42, 52, 56, 78, 90, 108, 120, 142, 150, 170, 178, 204, 212, 232, 240, 286, 310, 346, 370, 412, 436, 472, 496, 542, 558, 598, 614, 666, 682, 722, 738, 796, 812, 852, 868, 920, 936, 976, 992, 1086, 1134, 1206, 1254, 1338, 1386, 1458, 1506, 1596, 1644, 1716, 1764, 1848, 1896, 1968, 2016, 2110, 2142, 2222, 2254, 2358, 2390, 2470, 2502, 2618, 2650, 2730, 2762, 2866, 2898, 2978, 3010, 3132, 3164, 3244, 3276, 3380, 3412, 3492, 3524, 3640, 3672, 3752, 3784, 3888, 3920, 4000, 4032, 4222, 4318, 4462, 4558]
</code>```

答:
Python 2, 63 bytes

s=bin(input())[2:]
while s[0]!=s[-1]:s=s[1:-1]or'1'
print'1'==s
```

Prints True or False. Takes the binary representation of s and repeatedly removed the first and last characters as long as they are unequal. Checks whether what remains is the empty string or a central 1. This is done by converting '' to '1' and checking if the result equals '1', which also avoid an index error on the empty string.

ContentLicense: CC BY-SA 3.0

Title: Folding Numbers

Body:
Python 2, 63 bytes

s=bin(input())[2:]
while s[0]!=s[-1]:s=s[1:-1]or'1'
print'1'==s

Prints True or False. Takes the binary representation of s and repeatedly removed the first and last characters as long as they are unequal. Checks whether what remains is the empty string or a central 1. This is done by converting '' to '1' and checking if the result equals '1', which also avoid an index error on the empty string.


问:
Get dimension of a list
Find out the dimension of a simple nested list:

```<code>[] -> 1
[[]] -> 2
[[[]]] -> 3
...
</code>```

List taken as input, dimension as output.
No counting length of strings - list manipulation and loops only.
i.e. no getting the length of the input and dividing by 2.

Any language is permitted. Get golfing!

答:
Retina, <s>2</s> 1 byte<s>s</s>

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

Just Regex.

One byte to Martin Ender.

Title: Get dimension of a list

Body:
Retina, <s>2</s> 1 byte<s>s</s>

]

Just Regex.

One byte to Martin Ender.


问:
Print Triangle Wave of Numbers
Given the amplitude and period for a wave, print the wave. See sample output for more details. The total number of wave forms equals the period, and the height of each wave equals the amplitude. Amplitude and Period are less than 10. You can ignore the trailing spaces but not the leading spaces.</p>

```<code>Sample Input
3 2

Sample Output
  3           3
 232         232
12321 12321 12321 12321
       232         232
        3           3
</code>```

答:
Haskell (<s>226</s> <s>225</s> <s>222</s> <s>220</s> 214)

My try in Haskell:

```<code>import List
n!k|n>k=p:n!(k+1)++[p]|0<1=[p]where p=(n-1)?" "++k?show k++(n-k)?" ">>=id
f[n,k]=k?(n!1++(2*n-1)?' ':map reverse(n!1)++[(2*n-1)?' '])>>=id
main=interact$unlines.transpose.f.map read.words
(?)=replicate
</code>```

Sorry guys, (€) is optimized away, it takes three bytes for one € as opposed to ! which only takes one byte each.

Here is a "beta Version", that doesn't satisfies the spec:

```<code>import List

-- Creates a single wave of numbers. k should be equal to 1
-- and is used for internal stuff,
wave n k|n==k=[peek]
        |otherwise = peek:wave n(k+1)++[peek] where
  peek=replicate(n-1)" "++replicate k(show k)++replicate(n-k)" ">>=id

-- Creates a full wave
-- k: number of waves, n: size of waves
fullWave[n,k]=unlines.transpose.concat.replicate k$wave n 1++map reverse(wave n 1)

main=interact$fullWave.map read.words
</code>```

ContentLicense: CC BY-SA 2.5

Title: Print Triangle Wave of Numbers

Body:
Haskell (<s>226</s> <s>225</s> <s>222</s> <s>220</s> 214)

My try in Haskell:

import List
n!k|n>k=p:n!(k+1)++[p]|0<1=[p]where p=(n-1)?" "++k?show k++(n-k)?" ">>=id
f[n,k]=k?(n!1++(2*n-1)?' ':map reverse(n!1)++[(2*n-1)?' '])>>=id
main=interact$unlines.transpose.f.map read.words
(?)=replicate

Sorry guys, (€) is optimized away, it takes three bytes for one € as opposed to ! which only takes one byte each.

Here is a "beta Version", that doesn't satisfies the spec:

import List

-- Creates a single wave of numbers. k should be equal to 1
-- and is used for internal stuff,
wave n k|n==k=[peek]
        |otherwise = peek:wave n(k+1)++[peek] where
  peek=replicate(n-1)" "++replicate k(show k)++replicate(n-k)" ">>=id

-- Creates a full wave
-- k: number of waves, n: size of waves
fullWave[n,k]=unlines.transpose.concat.replicate k$wave n 1++map reverse(wave n 1)

main=interact$fullWave.map read.words


答:
Jelly, 2 bytes

```<code>ŒḊ
</code>```

TryItOnline

It's a single atom, the depth monad.

Title: Get dimension of a list

Body:
Find out the dimension of a simple nested list:

```<code>[] -> 1
[[]] -> 2
[[[]]] -> 3
...
</code>```

List taken as input, dimension as output.
No counting length of strings - list manipulation and loops only.
i.e. no getting the length of the input and dividing by 2.

Any language is permitted. Get golfing!

Body:
Jelly, 2 bytes

ŒḊ

TryItOnline

It's a single atom, the depth monad.


答:
Brain-Flak, <s>44</s> <s>36</s> <s>32</s> 26 + 3 = 29 bytes

Try it online

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

+3 bytes from the -a flag.

Explanation

```<code>([])                         #Push the stack height
     {<({}[()()])>()}{}      #For loop decrement by 2
    (                  <>)   #Push number of runs to the offstack
</code>```

Title: Get dimension of a list

Body:
Brain-Flak, <s>44</s> <s>36</s> <s>32</s> 26 + 3 = 29 bytes

Try it online

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

+3 bytes from the -a flag.

Explanation

([])                         #Push the stack height
     {<({}[()()])>()}{}      #For loop decrement by 2
    (                  <>)   #Push number of runs to the offstack


问:
Simple cat program
One of the most common standard tasks (especially when showcasing esoteric programming languages) is to implement a "cat program": read all of STDIN and print it to STDOUT. While this is named after the Unix shell utility cat it is of course much less powerful than the real thing, which is normally used to print (and concatenate) several files read from disc.

Task

You should write a full program which reads the contents of the standard input stream and writes them verbatim to the standard output stream. If and only if your language does not support standard input and/or output streams (as understood in most languages), you may instead take these terms to mean their closest equivalent in your language (e.g. JavaScript's prompt and alert). These are the only admissible forms of I/O, as any other interface would largely change the nature of the task and make answers much less comparable.

The output should contain exactly the input and nothing else. The only exception to this rule is constant output of your language's interpreter that cannot be suppressed, such as a greeting, ANSI color codes or indentation. This also applies to trailing newlines. If the input does not contain a trailing newline, the output shouldn't include one either! (The only exception being if your language absolutely always prints a trailing newline after execution.)

Output to the standard error stream is ignored, so long as the standard output stream contains the expected output. In particular, this means your program can terminate with an error upon hitting the end of the stream (EOF), provided that doesn't pollute the standard output stream. If you do this, I encourage you to add an error-free version to your answer as well (for reference).

As this is intended as a challenge within each language and not between languages, there are a few language specific rules:

If it is at all possible in your language to distinguish null bytes in the standard input stream from the EOF, your program must support null bytes like any other bytes (that is, they have to be written to the standard output stream as well).

If it is at all possible in your language to support an arbitrary infinite input stream (i.e. if you can start printing bytes to the output before you hit EOF in the input), your program has to work correctly in this case. As an example yes | tr -d \\n | ./my_cat should print an infinite stream of ys. It is up to you how often you print and flush the standard output stream, but it must be guaranteed to happen after a finite amount of time, regardless of the stream (this means, in particular, that you cannot wait for a specific character like a linefeed before printing).

Please add a note to your answer about the exact behaviour regarding null-bytes, infinite streams, and extraneous output.

Additional rules

This is not about finding the language with the shortest solution for this (there are some where the empty program does the trick) - this is about finding the shortest solution in every language. Therefore, no answer will be marked as accepted.

Submissions in most languages will be scored in bytes in an appropriate preexisting encoding, usually (but not necessarily) UTF-8.

Some languages, like Folders, are a bit tricky to score. If in doubt, please ask on Meta.

Feel free to use a language (or language version) even if it's newer than this challenge. Languages specifically written to submit a 0-byte answer to this challenge are fair game but not particularly interesting.

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.

Also note that languages do have to fulfil our usual criteria for programming languages.

If your language of choice is a trivial variant of another (potentially more popular) language which already has an answer (think BASIC or SQL dialects, Unix shells or trivial Brainfuck derivatives like Headsecks or Unary), consider adding a note to the existing answer that the same or a very similar solution is also the shortest in the other language.

Unless they have been overruled earlier, all standard code-golf rules apply, including the http://meta.codegolf.stackexchange.com/q/1061.

As a side note, please don't downvote boring (but valid) answers in languages where there is not much to golf; these are still useful to this question as it tries to compile a catalogue as complete as possible. However, do primarily upvote answers in languages where the author actually had to put effort into golfing the code.

Catalogue

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

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

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

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

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

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

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

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

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

 <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

```

答:
Emotinomicon, 16 bytes

```<code>⏫⏪⏬⏩
</code>```

Explanation:

```<code>⏫⏪⏬⏩
⏫             Get input
             Reverse Stack
    ⏪  ⏩     Loop
      ⏬       Output one char
</code>```

Title: Simple cat program

Body:
Emotinomicon, 16 bytes

⏫⏪⏬⏩

Explanation:

⏫⏪⏬⏩
⏫             Get input
             Reverse Stack
    ⏪  ⏩     Loop
      ⏬       Output one char


答:
Scala, 24 bytes

```<code>(n:Int)=>0 to 10 map(n*)
</code>```

Explanation:

```<code>(n:Int)=> //define an anonymous function
  0 to 10 //create a range from 0 to 10
  map(n*) //multiply each element by the input
</code>```

Title: Print multiplication tables by input

Body:
In this challenge you've to print multiplication tables by input, Here are some examples:

```<code>Input: 2

Output:
0 2  4 6 8  10  12  14  16  18  20

Input: 20

Output: 20 40 60 80 100 120 140 160 180 200
</code>```

Rules

The shortest code in bytes wins.

This challenge is a code-golf, It follows code-golf general rules (code-golf)

If, just if, your code can't print number, you can use letters, Here is an example:

Input: B

Output: B D F H J L N P R T

You can choose to start from 0 or your number (like 20). You can choose if put spaces or don't. The challenge is free, just take an input and print multiplication tables.

Your output must list the first 10 members of the times table for the given number. You may leave out 0*n.

Body:
Scala, 24 bytes

(n:Int)=>0 to 10 map(n*)

Explanation:

(n:Int)=> //define an anonymous function
  0 to 10 //create a range from 0 to 10
  map(n*) //multiply each element by the input


答:
PowerShell v2+, 143 bytes

Two possible approaches, both the same byte count.

Method 1:

```<code>param($n)if($n-eq1){$n++}$o=1;0..(($b=($n=[convert]::ToString($n,2)).length-1)/2-!($b%2))|%{$o*=$n[$_]-ne$n[$b-$_]};$o*(+"$($n[$b/2])",1)[$b%2]
</code>```

Takes input $n, if it's -equal to 1 (a special case for this algorithm), increment it. Set $output to be 1 (i.e., assume truthy), then loop from 0 to the midway point of the input number that has been [convert]ed to binary. Note the -!($b%2) to account for odd length binary numbers.

Each iteration, we compare the current digit $n[$_] with the digit the same length from the end $n[$b-$_], and multiply the Boolean result into $o (essentially performing an -and on all of them). Once the loop is done, we need to potentially account for the middle binary digit, that's the pseudo-ternary at the end (array indexed via $b%2). That 1 or 0 is left on the pipeline, and output is implicit.

Method 2:

```<code>param($n)for($n=[convert]::ToString($n,2);$n.Length-gt2){if($n[0]-ne$n[-1]){$n=$n[1..($n.Length-2)]}else{0;exit}}($n-join'+'|iex)-eq1-or$n-eq10
</code>```

Takes input and does the same process to [convert] the number to binary. Then we're in a for loop so long as the .length of the binary string is -greaterthan 2. When we're in the loop, if the first $n[0] and last $n[-1] digits are -notequal, slice those two digits off of $n and re-store it into $n. Otherwise, output 0 and exit. Once we're out of the loop, we either have (an array of 1, 1,0, 0,1, 1,1, or 0,0), or the binary string for two 10, or 3 11. So, we need to test those two possibilities. For the first, we -join $n together with + and evaluate the result and test that it's 1 (this is true for arrays 1, 1,0, and 0,1, but is $false for arrays 0,0 and 1,1 or strings 10 or 11). The other half of the -or is testing whether $n is -equal to 10 (i.e., input of 2). That Boolean is left on the pipeline, and output is implicit.

Title: Folding Numbers

Body:
Given a number determine if it is a folding number.

A folding number is a number such that if you take it binary representation and "fold" it in half,  That is take the result of XNOR multiplication of the first half of the number and the second half with it digits in reverse, you will get zero.

If the number has a odd number of digits in binary its middle digit must be 1 and is ignored when folding.

Since that might be a bit confusing I will give some examples:

178

The binary representation of 178 is

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

To fold this we first split it in half

```<code>1011 0010
</code>```

We reverse the second half

```<code>1011
0100
</code>```

And we XNOR the two halves:

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

This is zero so this is a folding number.

1644

The binary representation of 1644 is

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

To fold this we first split it in half

```<code>11001 1 01100
</code>```

The middle bit is 1 so we throw it out.

```<code>11001 01100
</code>```

We reverse the second half

```<code>11001
00110
</code>```

And we XNOR the two halves:

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

This is zero so this is a folding number.

4254

The binary representation of 4254 is

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

To fold this we first split it in half

```<code>100001 0 011110
</code>```

The middle bit is 0 so this is not a folding number.

Task

Your task is to take in a positive number and return a truthy if the number is folding and falsy if it is not.  This is code golf so try to keep the byte count down.

Test Cases

Here are the first 99 folding numbers:

```<code>[1, 2, 6, 10, 12, 22, 28, 38, 42, 52, 56, 78, 90, 108, 120, 142, 150, 170, 178, 204, 212, 232, 240, 286, 310, 346, 370, 412, 436, 472, 496, 542, 558, 598, 614, 666, 682, 722, 738, 796, 812, 852, 868, 920, 936, 976, 992, 1086, 1134, 1206, 1254, 1338, 1386, 1458, 1506, 1596, 1644, 1716, 1764, 1848, 1896, 1968, 2016, 2110, 2142, 2222, 2254, 2358, 2390, 2470, 2502, 2618, 2650, 2730, 2762, 2866, 2898, 2978, 3010, 3132, 3164, 3244, 3276, 3380, 3412, 3492, 3524, 3640, 3672, 3752, 3784, 3888, 3920, 4000, 4032, 4222, 4318, 4462, 4558]
</code>```

Body:
PowerShell v2+, 143 bytes

Two possible approaches, both the same byte count.

Method 1:

param($n)if($n-eq1){$n++}$o=1;0..(($b=($n=[convert]::ToString($n,2)).length-1)/2-!($b%2))|%{$o*=$n[$_]-ne$n[$b-$_]};$o*(+"$($n[$b/2])",1)[$b%2]

Takes input $n, if it's -equal to 1 (a special case for this algorithm), increment it. Set $output to be 1 (i.e., assume truthy), then loop from 0 to the midway point of the input number that has been [convert]ed to binary. Note the -!($b%2) to account for odd length binary numbers.

Each iteration, we compare the current digit $n[$_] with the digit the same length from the end $n[$b-$_], and multiply the Boolean result into $o (essentially performing an -and on all of them). Once the loop is done, we need to potentially account for the middle binary digit, that's the pseudo-ternary at the end (array indexed via $b%2). That 1 or 0 is left on the pipeline, and output is implicit.

Method 2:

param($n)for($n=[convert]::ToString($n,2);$n.Length-gt2){if($n[0]-ne$n[-1]){$n=$n[1..($n.Length-2)]}else{0;exit}}($n-join'+'|iex)-eq1-or$n-eq10

Takes input and does the same process to [convert] the number to binary. Then we're in a for loop so long as the .length of the binary string is -greaterthan 2. When we're in the loop, if the first $n[0] and last $n[-1] digits are -notequal, slice those two digits off of $n and re-store it into $n. Otherwise, output 0 and exit. Once we're out of the loop, we either have (an array of 1, 1,0, 0,1, 1,1, or 0,0), or the binary string for two 10, or 3 11. So, we need to test those two possibilities. For the first, we -join $n together with + and evaluate the result and test that it's 1 (this is true for arrays 1, 1,0, and 0,1, but is $false for arrays 0,0 and 1,1 or strings 10 or 11). The other half of the -or is testing whether $n is -equal to 10 (i.e., input of 2). That Boolean is left on the pipeline, and output is implicit.


问:
Shortest code to produce infinite output
Write the shortest code you can that produces an infinite output.

That's all. You code will only be disqualified if it stops producing output at some point. As always in code golf, the shortest code wins.

Here's a list of answers that I think are really clever, so they can get credit:

The comma is both code and data

Infinite errors (that counts)

Infinite warnings (that also counts)

What's Marbelous?

Leaderboard

var QUESTION_ID=13152,OVERRIDE_USER=8611;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

```

答:
x86 .COM Executable, 5 bytes

in hex:

```<code>40 CD 29 FF E6
</code>```

in asm:

```<code>inc ax
int 0x29
jmp si
</code>```

Explanation:

inc ax increments the register AX by one. int 0x29 is the "fast put char" routine of MSDOS, which simply outputs the value in AL (the low part of AX) and advances the cursor by one. jmp si is just a weird way to jump back to the top, since the register SI is 0x100 on almost every DOS-like operating system, which is also where a .com program starts ;) It's also possible to do a short jump instead, which also uses 2 bytes.

Sources:

MSDOS Start Values

Sizecoding WIKI

ContentLicense: CC BY-SA 4.0

Body:
x86 .COM Executable, 5 bytes

in hex:

40 CD 29 FF E6

in asm:

inc ax
int 0x29
jmp si

Explanation:

inc ax increments the register AX by one. int 0x29 is the "fast put char" routine of MSDOS, which simply outputs the value in AL (the low part of AX) and advances the cursor by one. jmp si is just a weird way to jump back to the top, since the register SI is 0x100 on almost every DOS-like operating system, which is also where a .com program starts ;) It's also possible to do a short jump instead, which also uses 2 bytes.

Sources:

MSDOS Start Values

Sizecoding WIKI


Title: Print multiplication tables by input

Body:
Retina, 63 bytes

Feels a bit long...

$
¶10$*
+`¶(1(1+))
¶$2 $1
^.+
$*
(?<=(1+)¶.*)1
$1
.*¶

(1)+
$#1

Try it online


答:
Retina, <s>71</s> <s>70</s> 60 bytes

```<code>.+
$*
+`^(1*)\1(1?)\b
$1 $.2
+`^ (.)(.*) (?!\1).$
$2
^( 1)?$
</code>```

I probably still have a lot to learn about Retina (e.g. recursive regex?). Explanation: Step 1 converts from decimal to unary. Step 2 converts from unary to pseudo-binary. Step 3 removes digits from both ends as long as they mismatch. Step four matches an optional final central 1 if necessary. Edit: Saved 1 byte thanks to @mbomb007. Saved 10 bytes by improving my unary to binary conversion.

Title: Folding Numbers

Body:
Retina, <s>71</s> <s>70</s> 60 bytes

.+
$*
+`^(1*)\1(1?)\b
$1 $.2
+`^ (.)(.*) (?!\1).$
$2
^( 1)?$

I probably still have a lot to learn about Retina (e.g. recursive regex?). Explanation: Step 1 converts from decimal to unary. Step 2 converts from unary to pseudo-binary. Step 3 removes digits from both ends as long as they mismatch. Step four matches an optional final central 1 if necessary. Edit: Saved 1 byte thanks to @mbomb007. Saved 10 bytes by improving my unary to binary conversion.


问:
Find the Swirling Words!
Don't ask me how or why but while coding on a project I noticed that the characters of a couple of words had a particular pattern referred to the alphabet, I connected each character of the words with the pencil on the alphabet and I obtained two spirals, then I noticed that the first spiral was clockwise and the other was counterclockwise, and other characteristics... so I named them Swirling Words!

A Swirling Word can be:

clockwise or counterclockwise

centripetal or centrifugal

Here there are some examples of Swirling Words:

Task 1:

Write a full program or function that will take a word from standard input and will output if is a Swirling Word and it's characteristics, in a readable format, extended text, 3 characters, flags, etc.

Test cases and example outputs for different words (but you can decide how to represent the results):

```<code>EARTH, GROUP            > NO        // NOT A SWIRLING WORD
OPERA, STAY, IRIS       > SW,CF,CW  // SWIRLING WORD, CENTRIFUGAL, CLOCKWISE
MINER, TAX, PLUG, META  > SW,CF,CC  // SWIRLING WORD, CENTRIFUGAL, COUNTERCLOCKWISE
AXIOM, AXIS, COOK       > SW,CP,CW  // SWIRLING WORD, CENTRIPETAL, CLOCKWISE
WATCH, YETI, PILL       > SW,CP,CC  // SWIRLING WORD, CENTRIPETAL, COUNTERCLOCKWISE

MORE EXAMPLES OF FALSE TEST CASES (NOT SWIRLING WORDS):
EARTH, GROUP, OUTPUT, WORD, CONNECTION, ODD, MOM, DAD,
CHARACTER, EXAMPLE, QUESTION, NEWSLETTER, OTHER
</code>```

Rules:

The connection between the first two characters must be up (like in the graphics), all the even connection must be down, all the odd connections must be up.

You can ignore upper/lowercase or consider/convert all to upper case or all to lower case.

The input words are only characters in the alphabet range of A-Z, no spaces, no punctuation, etc.

If a word has double characters, like "GROOVE", you must collapse the doubles to one character: "GROOVE" > "GROVE".

The input words will contain at least 3 distinct characters. Words like "MOM", "DAD", "LOL" are not valid words.

It's possible to pass multiple times in the same character, like "IRIS".

Shortest code wins.

Task 2:

To obtain more reputation, find the longest Swirling Words, and it's characteristics, that you can find in the english dictionary, following the above rules. You can take for example as reference the complete list of the english words here.

Happy coding!

答:
Mathematica, <s>117</s> 111 bytes

Thanks to JHM for saving 6 bytes, and making it case-insensitive to boot!

```<code> {o=OrderedQ/@{a=Abs[d=Differences[#&@@@Split@LetterNumber@#]],Reverse@a},d[[1]]>0,Or@@o&&Max[Most[d]Rest@d]<0}&
</code>```

Unnamed function that takes a string and returns a nested list of booleans in the form {{B1,B2},B3,B4}. B4 records whether the word is swirling (and if it's not, the rest of the output is garbage). If the word is swirling, then B1 records whether the word is centrifugal, B2 records whether the word is centripetal, and B3 records whether the word is clockwise (True) or counterclockwise (False).

Here's a longer version that post-processes (first line) the above function (spaced over the 2nd-5th lines) to make it identical to the OP: NO if the word isn't swirling, and the appropriate choice of {SW,CF,CW} , {SW,CF,CC} , {SW,CP,CW}, or {SW,CP,CC} if the word is swirling:

```<code>If[#3, {SW, If[#[[1]], CF, CP], If[#2, CW, CC]}, NO] & @@
  {o = OrderedQ /@
    {a = Abs[d = Differences[# & @@@ Split@LetterNumber@#]], Reverse@a},
  d[[1]] > 0,
  Or @@ o && Max[Most[d] Rest@d] < 0} &
</code>```

The explanation is the same as in Martin Ender's CJam answer, with one additional note: the list of consecutive differences must alternate in sign for the word to be swirling, and that can be detected by making sure all products of pairs of consecutive differences are negative (that's what Max[Most[d]Rest@d]<0 does).

Running the function on all 40,000+ words of Mathematica's WordList[], we find the following 8-letter swirling words, which are the longest of their respective swirling types:

```<code>operetta    {SW, CF, CW}
opposite    {SW, CF, CW}
stowaway    {SW, CF, CW}
assassin    {SW, CP, CW}
assessor    {SW, CP, CW}
baccarat    {SW, CF, CC}
keenness    {SW, CF, CC}
positive    {SW, CF, CC}
</code>```

(Brownie points to positive for having no double letters, and fewer repeated letters than stowaway.)

But the absolute champion is the 9-letter counterclockwise-swirling centripetal word vassalage!

Title: Find the Swirling Words!

Body:
Mathematica, <s>117</s> 111 bytes

Thanks to JHM for saving 6 bytes, and making it case-insensitive to boot!

 {o=OrderedQ/@{a=Abs[d=Differences[#&@@@Split@LetterNumber@#]],Reverse@a},d[[1]]>0,Or@@o&&Max[Most[d]Rest@d]<0}&

Unnamed function that takes a string and returns a nested list of booleans in the form {{B1,B2},B3,B4}. B4 records whether the word is swirling (and if it's not, the rest of the output is garbage). If the word is swirling, then B1 records whether the word is centrifugal, B2 records whether the word is centripetal, and B3 records whether the word is clockwise (True) or counterclockwise (False).

Here's a longer version that post-processes (first line) the above function (spaced over the 2nd-5th lines) to make it identical to the OP: NO if the word isn't swirling, and the appropriate choice of {SW,CF,CW} , {SW,CF,CC} , {SW,CP,CW}, or {SW,CP,CC} if the word is swirling:

If[#3, {SW, If[#[[1]], CF, CP], If[#2, CW, CC]}, NO] & @@
  {o = OrderedQ /@
    {a = Abs[d = Differences[# & @@@ Split@LetterNumber@#]], Reverse@a},
  d[[1]] > 0,
  Or @@ o && Max[Most[d] Rest@d] < 0} &

The explanation is the same as in Martin Ender's CJam answer, with one additional note: the list of consecutive differences must alternate in sign for the word to be swirling, and that can be detected by making sure all products of pairs of consecutive differences are negative (that's what Max[Most[d]Rest@d]<0 does).

Running the function on all 40,000+ words of Mathematica's WordList[], we find the following 8-letter swirling words, which are the longest of their respective swirling types:

operetta    {SW, CF, CW}
opposite    {SW, CF, CW}
stowaway    {SW, CF, CW}
assassin    {SW, CP, CW}
assessor    {SW, CP, CW}
baccarat    {SW, CF, CC}
keenness    {SW, CF, CC}
positive    {SW, CF, CC}

(Brownie points to positive for having no double letters, and fewer repeated letters than stowaway.)

But the absolute champion is the 9-letter counterclockwise-swirling centripetal word vassalage!


答:
Scala, 110 bytes

```<code>def/(s:String)={val ? =s.sliding(2).map(t=>(t(0)-t(1)).abs).toSeq
(Seq(?,?reverse)indexOf(?sorted),s(0)<s(1))}
</code>```

Returns a tuple (a,b) with

a == 1 if s is centripetal

a == 0 if s is centrifugal

a == -1 if s is not swirling

and

b == true if s is clockwise

b == false if s is counterclockwise

b can be true or false if s is not swirling

Explanation:

```<code>def/(s:String)={      //define a method called / with a String argument
  val ? =s            //define ? as...
    .sliding(2)       //an iterator for each two consecutive elements
    .map(t=>          //foreach 2 chars
      (t(0)-t(1)).abs //get the absolute value of their difference
    )
    .toSeq            //and convert the iterator to a Seq, because iterator doesn't have reverse and sorted methods
  (                   //return a tuple of
    Seq(?,?reverse)     //a Seq of ? and reversed ?
    .indexOf(?sorted)   //and check which of them is sorted ?
  ,                   //and
   s(0)< s(1)          //the difference bewteen the first two elements of the string.
  )
}
</code>```

Title: Find the Swirling Words!

Body:
Don't ask me how or why but while coding on a project I noticed that the characters of a couple of words had a particular pattern referred to the alphabet, I connected each character of the words with the pencil on the alphabet and I obtained two spirals, then I noticed that the first spiral was clockwise and the other was counterclockwise, and other characteristics... so I named them Swirling Words!

A Swirling Word can be:

clockwise or counterclockwise

centripetal or centrifugal

Here there are some examples of Swirling Words:

Task 1:

Write a full program or function that will take a word from standard input and will output if is a Swirling Word and it's characteristics, in a readable format, extended text, 3 characters, flags, etc.

Test cases and example outputs for different words (but you can decide how to represent the results):

```<code>EARTH, GROUP            > NO        // NOT A SWIRLING WORD
OPERA, STAY, IRIS       > SW,CF,CW  // SWIRLING WORD, CENTRIFUGAL, CLOCKWISE
MINER, TAX, PLUG, META  > SW,CF,CC  // SWIRLING WORD, CENTRIFUGAL, COUNTERCLOCKWISE
AXIOM, AXIS, COOK       > SW,CP,CW  // SWIRLING WORD, CENTRIPETAL, CLOCKWISE
WATCH, YETI, PILL       > SW,CP,CC  // SWIRLING WORD, CENTRIPETAL, COUNTERCLOCKWISE

MORE EXAMPLES OF FALSE TEST CASES (NOT SWIRLING WORDS):
EARTH, GROUP, OUTPUT, WORD, CONNECTION, ODD, MOM, DAD,
CHARACTER, EXAMPLE, QUESTION, NEWSLETTER, OTHER
</code>```

Rules:

The connection between the first two characters must be up (like in the graphics), all the even connection must be down, all the odd connections must be up.

You can ignore upper/lowercase or consider/convert all to upper case or all to lower case.

The input words are only characters in the alphabet range of A-Z, no spaces, no punctuation, etc.

If a word has double characters, like "GROOVE", you must collapse the doubles to one character: "GROOVE" > "GROVE".

The input words will contain at least 3 distinct characters. Words like "MOM", "DAD", "LOL" are not valid words.

It's possible to pass multiple times in the same character, like "IRIS".

Shortest code wins.

Task 2:

To obtain more reputation, find the longest Swirling Words, and it's characteristics, that you can find in the english dictionary, following the above rules. You can take for example as reference the complete list of the english words here.

Happy coding!

Body:
Scala, 110 bytes

def/(s:String)={val ? =s.sliding(2).map(t=>(t(0)-t(1)).abs).toSeq
(Seq(?,?reverse)indexOf(?sorted),s(0)<s(1))}

Returns a tuple (a,b) with

a == 1 if s is centripetal

a == 0 if s is centrifugal

a == -1 if s is not swirling

and

b == true if s is clockwise

b == false if s is counterclockwise

b can be true or false if s is not swirling

Explanation:

def/(s:String)={      //define a method called / with a String argument
  val ? =s            //define ? as...
    .sliding(2)       //an iterator for each two consecutive elements
    .map(t=>          //foreach 2 chars
      (t(0)-t(1)).abs //get the absolute value of their difference
    )
    .toSeq            //and convert the iterator to a Seq, because iterator doesn't have reverse and sorted methods
  (                   //return a tuple of
    Seq(?,?reverse)     //a Seq of ? and reversed ?
    .indexOf(?sorted)   //and check which of them is sorted ?
  ,                   //and
   s(0)< s(1)          //the difference bewteen the first two elements of the string.
  )
}


问:
Determine whether strings are anagrams

Challenge

Given two strings, work out if they both have exactly the same characters in them.

Example

Input

word, wrdo

This returns true because they are the same but just scrambled.

Input

word, wwro

This returns false.

Input

boat, toba

This returns true

Rules

Here are the rules!

Assume input will be at least 1 char long, and no longer than 8 chars.

No special characters, only a–z

All inputs can be assumed to be lowercase

Test Cases

```<code>boat, boat = true
toab, boat = true
oabt, toab = true
a, aa = false
zzz, zzzzzzzz = false
zyyyzzzz, yyzzzzzy = true
sleepy, pyels = false
p,p = true
</code>```

答:
Java (134 bytes)

```<code>int[][]c=new int[2][26];
for(int i=0;i<2;i++)for(byte a:args[i].getBytes())c[i][a-97]++;
System.out.print(Arrays.equals(c[0],c[1]));`
</code>```

This makes an array to count the number of times each letter appears, and then compares the arrays to check if they are equal.

Title: Determine whether strings are anagrams

Body:
Java (134 bytes)

int[][]c=new int[2][26];
for(int i=0;i<2;i++)for(byte a:args[i].getBytes())c[i][a-97]++;
System.out.print(Arrays.equals(c[0],c[1]));`

This makes an array to count the number of times each letter appears, and then compares the arrays to check if they are equal.


答:
MATL, <s>33</s> <s>31</s> 30 bytes

```<code>lydhg)dt|dZSXz&=wZSdh?4M1)3M1)
</code>```

Input is in uppercase letters (or in lowercase letters, but not mixed).

Output is:

If the word is non-swirling: no output is produced

If it is swirling: two numbers are produced in different lines:

First number 1/ -1  indicates centrifugal / centripetal.

Second number 1/ `-1'  indicates clockwise / counterclockwise.

Try it online! Or verify all test cases (code modified to take all inputs and to produce the two output numbers on the same line)

Explanation

Let's take input 'OPERAA' as an example.

The first part of the code removes double letters:

```<code>l     % Push 1
      %   STACK: 1
y     % Take input implicitly from below, and duplicate
      %   STACK: 'OPERAA', 1, 'OPERAA'
d     % Convert to code points and compute differences
      %   STACK: 'OPERAA', 1, [1 -11  13 -17 0]
h     % Concatenate horizontally
      %   STACK: 'OPERAA', [1 1 -11  13 -17 0]
g     % Convert to logical
      %   STACK: 'OPERAA', [true true true true true false]
)     % Index
      %   STACK: 'OPERA'
</code>```

We now check if the distances between letters are non-decreasing (necessary condition for the word to be swirling):

```<code>d     % Convert to code points and compute differences
      %   STACK: [1 -11  13 -17]
t|    % Duplicate and take absolute value
      %   STACK: [1 -11  13 -17], [1 11  13 17]
d     % Differences
      %   STACK: [1 -11  13 -17], [10 2 4]
ZS    % Signum
      %   STACK: [1 -11  13 -17], [1 1 1]
Xz    % Remove zeros (gives a vertical vector). Needed for words like 'IRIS',
      % where some consecutive distances are equal
      %   STACK: [1 -11  13 -17], [1; 1; 1]
&=    % All pairwise equality comparisons. Gives a matrix. If all the signs
      % were equal the matrix will contain all ones
      %   STACK: [1 -11  13 -17], [1 1 1; 1 1 1; 1 1 1]
</code>```

We then check if the letters go back and forth  (this is the other condition for the word to be swirling):

```<code>w     % Swap
      %   STACK: [1 1 1; 1 1 1; 1 1 1], [1 -11  13 -17]
ZS    % Signum
      %   STACK: [1 1 1; 1 1 1; 1 1 1], [1 -1 1 -1]
d     % Differences
      %   STACK: [1 1 1; 1 1 1; 1 1 1], [-2 2 -2]
</code>```

Lastly, we check if the two conditions hold, and in that case produce the output:

```<code>h     % Concatenate horizontally
      %   STACK: [1 1 1 1 1 1 1 1 1 -2 2 -2]
?     % If all elements are nonzero
  4M  %   Push first signum array without zeros, from the automatic clipboard
      %     STACK: [1; 1; 1]
  1)  %   Get first element (tells if first difference was positive or negative)
      %     STACK: 1
  3M  %   Push second signum array, from the automatic clipboard
      %     STACK: 1, [1 -1 1 -1]
  1)  %   Get first element (tells if first movement was right or left)
      %     STACK: 1, 1
      %   Implicitly end if
      % Implicitly display
</code>```

Title: Find the Swirling Words!

Body:
MATL, <s>33</s> <s>31</s> 30 bytes

lydhg)dt|dZSXz&=wZSdh?4M1)3M1)

Input is in uppercase letters (or in lowercase letters, but not mixed).

Output is:

If the word is non-swirling: no output is produced

If it is swirling: two numbers are produced in different lines:

First number 1/ -1  indicates centrifugal / centripetal.

Second number 1/ `-1'  indicates clockwise / counterclockwise.

Try it online! Or verify all test cases (code modified to take all inputs and to produce the two output numbers on the same line)

Explanation

Let's take input 'OPERAA' as an example.

The first part of the code removes double letters:

l     % Push 1
      %   STACK: 1
y     % Take input implicitly from below, and duplicate
      %   STACK: 'OPERAA', 1, 'OPERAA'
d     % Convert to code points and compute differences
      %   STACK: 'OPERAA', 1, [1 -11  13 -17 0]
h     % Concatenate horizontally
      %   STACK: 'OPERAA', [1 1 -11  13 -17 0]
g     % Convert to logical
      %   STACK: 'OPERAA', [true true true true true false]
)     % Index
      %   STACK: 'OPERA'

We now check if the distances between letters are non-decreasing (necessary condition for the word to be swirling):

d     % Convert to code points and compute differences
      %   STACK: [1 -11  13 -17]
t|    % Duplicate and take absolute value
      %   STACK: [1 -11  13 -17], [1 11  13 17]
d     % Differences
      %   STACK: [1 -11  13 -17], [10 2 4]
ZS    % Signum
      %   STACK: [1 -11  13 -17], [1 1 1]
Xz    % Remove zeros (gives a vertical vector). Needed for words like 'IRIS',
      % where some consecutive distances are equal
      %   STACK: [1 -11  13 -17], [1; 1; 1]
&=    % All pairwise equality comparisons. Gives a matrix. If all the signs
      % were equal the matrix will contain all ones
      %   STACK: [1 -11  13 -17], [1 1 1; 1 1 1; 1 1 1]

We then check if the letters go back and forth  (this is the other condition for the word to be swirling):

w     % Swap
      %   STACK: [1 1 1; 1 1 1; 1 1 1], [1 -11  13 -17]
ZS    % Signum
      %   STACK: [1 1 1; 1 1 1; 1 1 1], [1 -1 1 -1]
d     % Differences
      %   STACK: [1 1 1; 1 1 1; 1 1 1], [-2 2 -2]

Lastly, we check if the two conditions hold, and in that case produce the output:

h     % Concatenate horizontally
      %   STACK: [1 1 1 1 1 1 1 1 1 -2 2 -2]
?     % If all elements are nonzero
  4M  %   Push first signum array without zeros, from the automatic clipboard
      %     STACK: [1; 1; 1]
  1)  %   Get first element (tells if first difference was positive or negative)
      %     STACK: 1
  3M  %   Push second signum array, from the automatic clipboard
      %     STACK: 1, [1 -1 1 -1]
  1)  %   Get first element (tells if first movement was right or left)
      %     STACK: 1, 1
      %   Implicitly end if
      % Implicitly display


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

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

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

"A", whether uppercase or lowercase.

"U", whether lowercase or uppercase.

X, whether uppercase or lowercase.

+

&

#

0

1

4

5

6

7

9

Cheating, loopholes, etc, are not allowed.

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

Validity Checker

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

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

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

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

<h3>Leaderboard</h3>

<p><div class="snippet" data-lang="js" data-hide="true" data-console="false" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var QUESTION_ID=90349,OVERRIDE_USER=58717;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;</code>```

body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td>Link</td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td>Link</td></tr></tbody> </table></code>```

答:
PowerShell, 89 59 32 Bytes:

```<code>[Convert]::ToString((8-3)*2,8*2)
</code>```

$d=2-2;[char][byte]"".insert($d,(3*3)-(2*2)).insert($d,2*3)
$b=[string]::Concat(2*3);$c=[string]::Concat((3*3)-(2*2));[char][byte]$b.insert(2*2-3,$c)

edit: use of a I see no way around this(not a golf language) It is possible...

Title: The Letter A without A

Body:
PowerShell, 89 59 32 Bytes:

[Convert]::ToString((8-3)*2,8*2)

$d=2-2;[char][byte]"".insert($d,(3*3)-(2*2)).insert($d,2*3)
$b=[string]::Concat(2*3);$c=[string]::Concat((3*3)-(2*2));[char][byte]$b.insert(2*2-3,$c)

edit: use of a I see no way around this(not a golf language) It is possible...


问:
KITT car ASCII art
The 80's TV series Knight Rider featured an intelligent, self-aware car called KITT. One distinctive aspect of the car was a front-mounted scanner bar that allowed KITT to "see" (and that looked suspiciously familiar to fans of another, earlier TV series).

The scanner had eight lights as seen in this picture:

The lights "moved" as shown in this animated image.

Your task, as you have guessed by now, it to recreate the scanner bar with the moving lights in ASCII art.

The challenge

Given an integer t, output the state of the scanner bar at that instant, defined as follows:

The scanner consists of eight lights.

At any instant one of the lights is active, and is shown as #. The lights that were active at times t-1 and t-2 are now dimmed, and are shown as +; unless they coincide with the current active one. The rest of the lights are off, and are shown as -.

The active light moves left to right, then right to left.

The exact output for each t is detailed below.

```<code>0  -->  #++-----   % The leftmost light is active, and it just came from the right.
                   % The two neighbouring lights are dimmed
1  -->  +#------   % The active light has bounced to the right, and it is covering
                   % one of the two lights that should be dimmed. So there is only
                   % one dimmed light
2  -->  ++#-----   % The active light has moved one more step to the right, and the
                   % two trailing dimmed lights are visible
3  -->  -++#----
7  -->  -----++#
8  -->  ------#+   % The active light has bounced to the left
9  -->  -----#++
10 -->  ----#++-
13 -->  -#++----
14 -->  #++-----   % Same as 0
15 -->  +#------   % Same as 1
</code>```

For negative values of t the cycle is simply extended:

```<code>-1 -->  -#++----   % Same as 13
-2 -->  --#++---   % Same as 12
</code>```

#Additional rules

You can write a program or function.

Output can contain trailing whitespace and a leading newline.

Shortest code in bytes wins.

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

```<code>n=>"01234567".replace(/./g,i=>"-+##"[g=n=>!((+i+n)%14&&(n-i)%14),g(n)*2|g(n-1)|g(n-2)])
</code>```

"-+##" is indexed by a bitmask, where bit 1 signifies an active light and bit 0 signifies a dimmed light. Active/dimmedness is now calculated by adding and subtracting the current position from the desired position and seeing if either result is divisible by 14.

Title: KITT car ASCII art

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

n=>"01234567".replace(/./g,i=>"-+##"[g=n=>!((+i+n)%14&&(n-i)%14),g(n)*2|g(n-1)|g(n-2)])

"-+##" is indexed by a bitmask, where bit 1 signifies an active light and bit 0 signifies a dimmed light. Active/dimmedness is now calculated by adding and subtracting the current position from the desired position and seeing if either result is divisible by 14.


答:
Racket 92 bytes

```<code>(λ(a b)(define(g s)(sort(map(λ(x)(char->integer x))(string->list s))>))(equal?(g a)(g b)))
</code>```

Ungolfed:

```<code>(define f
  (λ (a b)
    (define (g s)    ; fn to get sorted list of string chars as numbers.
      (sort
       (map
        (λ(x)(char->integer x))
        (string->list s))
       >))
    (equal? (g a) (g b))))
</code>```

Testing:

```<code>(f "test" "ttse")
(f "boat" "boat")
(f "toab" "boat")
(f "oabt" "toab")
(f "zyyyzzzz" "yyzzzzzy")
(f "a" "aa")
(f "zzz" "zzzzzzzz")
(f "sleepy" "pyels")
</code>```

Output:

```<code>#t
#t
#t
#t
#t
#f
#f
#f
</code>```

Title: Determine whether strings are anagrams

Body:
Challenge

Given two strings, work out if they both have exactly the same characters in them.

Example

Input

word, wrdo

This returns true because they are the same but just scrambled.

Input

word, wwro

This returns false.

Input

boat, toba

This returns true

Rules

Here are the rules!

Assume input will be at least 1 char long, and no longer than 8 chars.

No special characters, only a–z

All inputs can be assumed to be lowercase

Test Cases

```<code>boat, boat = true
toab, boat = true
oabt, toab = true
a, aa = false
zzz, zzzzzzzz = false
zyyyzzzz, yyzzzzzy = true
sleepy, pyels = false
p,p = true
</code>```

Body:
Racket 92 bytes

(λ(a b)(define(g s)(sort(map(λ(x)(char->integer x))(string->list s))>))(equal?(g a)(g b)))

Ungolfed:

(define f
  (λ (a b)
    (define (g s)    ; fn to get sorted list of string chars as numbers.
      (sort
       (map
        (λ(x)(char->integer x))
        (string->list s))
       >))
    (equal? (g a) (g b))))

Testing:

(f "test" "ttse")
(f "boat" "boat")
(f "toab" "boat")
(f "oabt" "toab")
(f "zyyyzzzz" "yyzzzzzy")
(f "a" "aa")
(f "zzz" "zzzzzzzz")
(f "sleepy" "pyels")

Output:

#t
#t
#t
#t
#t
#f
#f
#f


答:
Scala - 64 Bytes

Could be made shorter (the toList could be changed to toSeq, I believe)
('a'to'z').forall(c=>y.toList.count(_==c)==z.toList.count(_==c))

Title: Determine whether strings are anagrams


答:
MATL, <s>34</s> <s>30</s> 27 bytes

```<code>'++#-'I:7XyY+4LZ)t2&P&viY))
</code>```

7 bytes saved thanks to @Luis

Try it Online!

Another example with the first 25 steps

Explanation

```<code>'++#-'      % Push the string literal to the stack
I:          % Create the array [1 2 3]
7Xy         % Create a 7 x 7 identity matrix
Y+          % Perform 2D convolution between the vector and this matrix
4LZ)        % Grab all but the first column. Yields the following matrix
            %
            %    2 3 0 0 0 0 0 0
            %    1 2 3 0 0 0 0 0
            %    0 1 2 3 0 0 0 0
            %    0 0 1 2 3 0 0 0
            %    0 0 0 1 2 3 0 0
            %    0 0 0 0 1 2 3 0
            %    0 0 0 0 0 1 2 3
            %
t2&P&v      % Copy this matrix, flip it horizontally and vertically concatenate
            % it with itself.
i           % Explicitly grab the input (n)
Y)          % Get the n-th row of the above matrix (and use modular indexing)
)           % Index into the initial string literal to replace 2 with #, 1 and 3 with +
            % and all 0's with -
            % Implicitly display the result
</code>```

Title: KITT car ASCII art

Body:
The 80's TV series Knight Rider featured an intelligent, self-aware car called KITT. One distinctive aspect of the car was a front-mounted scanner bar that allowed KITT to "see" (and that looked suspiciously familiar to fans of another, earlier TV series).

The scanner had eight lights as seen in this picture:

The lights "moved" as shown in this animated image.

Your task, as you have guessed by now, it to recreate the scanner bar with the moving lights in ASCII art.

The challenge

Given an integer t, output the state of the scanner bar at that instant, defined as follows:

The scanner consists of eight lights.

At any instant one of the lights is active, and is shown as #. The lights that were active at times t-1 and t-2 are now dimmed, and are shown as +; unless they coincide with the current active one. The rest of the lights are off, and are shown as -.

The active light moves left to right, then right to left.

The exact output for each t is detailed below.

```<code>0  -->  #++-----   % The leftmost light is active, and it just came from the right.
                   % The two neighbouring lights are dimmed
1  -->  +#------   % The active light has bounced to the right, and it is covering
                   % one of the two lights that should be dimmed. So there is only
                   % one dimmed light
2  -->  ++#-----   % The active light has moved one more step to the right, and the
                   % two trailing dimmed lights are visible
3  -->  -++#----
7  -->  -----++#
8  -->  ------#+   % The active light has bounced to the left
9  -->  -----#++
10 -->  ----#++-
13 -->  -#++----
14 -->  #++-----   % Same as 0
15 -->  +#------   % Same as 1
</code>```

For negative values of t the cycle is simply extended:

```<code>-1 -->  -#++----   % Same as 13
-2 -->  --#++---   % Same as 12
</code>```

#Additional rules

You can write a program or function.

Output can contain trailing whitespace and a leading newline.

Shortest code in bytes wins.

Body:
MATL, <s>34</s> <s>30</s> 27 bytes

'++#-'I:7XyY+4LZ)t2&P&viY))

7 bytes saved thanks to @Luis

Try it Online!

Another example with the first 25 steps

Explanation

'++#-'      % Push the string literal to the stack
I:          % Create the array [1 2 3]
7Xy         % Create a 7 x 7 identity matrix
Y+          % Perform 2D convolution between the vector and this matrix
4LZ)        % Grab all but the first column. Yields the following matrix
            %
            %    2 3 0 0 0 0 0 0
            %    1 2 3 0 0 0 0 0
            %    0 1 2 3 0 0 0 0
            %    0 0 1 2 3 0 0 0
            %    0 0 0 1 2 3 0 0
            %    0 0 0 0 1 2 3 0
            %    0 0 0 0 0 1 2 3
            %
t2&P&v      % Copy this matrix, flip it horizontally and vertically concatenate
            % it with itself.
i           % Explicitly grab the input (n)
Y)          % Get the n-th row of the above matrix (and use modular indexing)
)           % Index into the initial string literal to replace 2 with #, 1 and 3 with +
            % and all 0's with -
            % Implicitly display the result


问:
2048-like array shift
Assume we want to shift an array like it is done in the 2048 game: if we have two equal consecutive elements in array, merge them into twice the value element.
Shift must return a new array, where every pair of consecutive equal elements is replaced with their sum, and pairs should not intersect.
Shifting is performed only once, so we don't need to merge resulting values again.
Notice that if we have 3 consecutive equal elements, we have to sum rightmost ones, so for example, [2, 2, 2] should become [2, 4], not [4, 2].

The task is to write shortest function which takes an array and returns a shifted array.

You may assume that all integers will be strictly positive.

Examples:

```<code>[] -> []
[2, 2, 4, 4] -> [4, 8]
[2, 2, 2, 4, 4, 8] -> [2, 4, 8, 8]
[2, 2, 2, 2] -> [4, 4]
[4, 4, 2, 8, 8, 2] -> [8, 2, 16, 2]
[1024, 1024, 512, 512, 256, 256] -> [2048, 1024, 512]
[3, 3, 3, 1, 1, 7, 5, 5, 5, 5] -> [3, 6, 2, 7, 10, 10]
</code>```

I am also very interested in solution using reduce :)

答:
Racket 166 bytes

```<code>(λ(l)(let g((l(reverse l))(o '()))(cond[(null? l)o][(=(length l)1)(cons(car l)o)]
[(=(car l)(second l))(g(drop l 2)(cons(* 2(car l))o))][(g(cdr l)(cons(car l)o))])))
</code>```

Ungolfed:

```<code>(define f
  (λ (lst)
    (let loop ((lst (reverse lst))
               (nl '()))
      (cond                            ; conditions:
        [(null? lst)                   ; original list empty, return new list;
               nl]
        [(= (length lst) 1)            ; single item left, add it to new list
              (cons (first lst) nl)]
        [(= (first lst) (second lst))  ; first & second items equal, add double to new list
              (loop (drop lst 2)
                    (cons (* 2 (first lst)) nl))]
        [else                          ; else just move first item to new list
              (loop (drop lst 1)
                    (cons (first lst) nl))]
        ))))
</code>```

Testing:

```<code>(f '[])
(f '[2 2 4 4])
(f '[2 2 2 4 4 8])
(f '[2 2 2 2])
(f '[4 4 2 8 8 2])
(f '[1024 1024 512 512 256 256])
(f '[3 3 3 1 1 7 5 5 5 5])
(f '[3 3 3 1 1 7 5 5 5 5 5])
</code>```

Output:

```<code>'()
'(4 8)
'(2 4 8 8)
'(4 4)
'(8 2 16 2)
'(2048 1024 512)
'(3 6 2 7 10 10)
'(3 6 2 7 5 10 10)
</code>```

Title: 2048-like array shift

Body:
Racket 166 bytes

(λ(l)(let g((l(reverse l))(o '()))(cond[(null? l)o][(=(length l)1)(cons(car l)o)]
[(=(car l)(second l))(g(drop l 2)(cons(* 2(car l))o))][(g(cdr l)(cons(car l)o))])))

Ungolfed:

(define f
  (λ (lst)
    (let loop ((lst (reverse lst))
               (nl '()))
      (cond                            ; conditions:
        [(null? lst)                   ; original list empty, return new list;
               nl]
        [(= (length lst) 1)            ; single item left, add it to new list
              (cons (first lst) nl)]
        [(= (first lst) (second lst))  ; first & second items equal, add double to new list
              (loop (drop lst 2)
                    (cons (* 2 (first lst)) nl))]
        [else                          ; else just move first item to new list
              (loop (drop lst 1)
                    (cons (first lst) nl))]
        ))))

Testing:

(f '[])
(f '[2 2 4 4])
(f '[2 2 2 4 4 8])
(f '[2 2 2 2])
(f '[4 4 2 8 8 2])
(f '[1024 1024 512 512 256 256])
(f '[3 3 3 1 1 7 5 5 5 5])
(f '[3 3 3 1 1 7 5 5 5 5 5])

Output:

'()
'(4 8)
'(2 4 8 8)
'(4 4)
'(8 2 16 2)
'(2048 1024 512)
'(3 6 2 7 10 10)
'(3 6 2 7 5 10 10)


问:
Sum evens between 0 and N

Challenge

Given an integer n, calculate the sum of all even numbers between 0 and n

Examples

```<code>n     output
-------------
100   2550
255   16256
1000  2502500
</code>```

Shortest code in bytes wins

答:
Scala - 18 bytes

shortest I could figure:

```<code>(0 to i by 2).sum
</code>```

Using an anonymous function:

```<code>val i = (N:Int) => (0 to N by 2).sum
</code>```

Title: Sum evens between 0 and N

Body:
Scala - 18 bytes

shortest I could figure:

(0 to i by 2).sum

Using an anonymous function:

val i = (N:Int) => (0 to N by 2).sum


问:
It's time to make a histogram
Your task is to make a histogram given a sample of arbitrary size.

Input

A float array or any other reasonable form of input with an arbitrary number of elements.

Output

The histogram; more to follow.

How to make a histogram

We'll use the sample: [1.1, 3, 5, 13, 15.5, 21, 29.7, 63, 16, 5, 5.1, 5.01, 51, 61, 13]

To make a histogram, you first separate your observations into classes. The ideal number of classes is the lowest k such that 2^k > n, where k is the number of classes, and n is the number of observations. In our case, k = 4. The number of bars is not final. This k value's purpose is only to find the width of each class.

The width of each class is the range of your data set divided by the number of classes. The range of our data set is 63 - 1.1 = 61.9, so the width of each class is 15.475. This means that the first class is [1.1, 16.575), the second is [16.575, 32.05) and so on. The last class is [63.0, 78.475). The second value of the last class (b in [a,b)) must be greater than the max value of the set.

Now we rearrange our data into the classes; for us:

```<code>[1.1, 16.575): [1.1, 3, 5, 5, 5.01, 5.1, 13, 13, 15.5, 16]
[16.575, 32.05): [21, 29.7]
[32.05, 47.525): []
[47.525, 63.0): [51, 61]
[63.0, 78.475): [63]
</code>```

And finally, we graph!

For our purposes, a bar will be a ▉ stacked for the number of observations in the class (because I think that looks good). You can count the ▉ as one byte in your source code. There should be no space between bars (unless there is an empty bar), nor do you need to label axes or any of that fancy stuff. There can be trailing whitespace at the end of your output. In our case, that would be:

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

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

答:
Pyth, 76 bytes

This code is absolutely disgusting.  I've mentioned before how bad I am at golfing string-output challenges, right?

```<code>J_Mr8Smf>+*T/-h.MZQKh.mbQ.EllQKd)Q)=Y_.tUMme@+J]0xhMJdSheJ;jmj""m@"▉ "qk\ dY
</code>```

Explanation to follow.

Test it out online!

Title: It's time to make a histogram

Body:
Pyth, 76 bytes

This code is absolutely disgusting.  I've mentioned before how bad I am at golfing string-output challenges, right?

J_Mr8Smf>+*T/-h.MZQKh.mbQ.EllQKd)Q)=Y_.tUMme@+J]0xhMJdSheJ;jmj""m@"▉ "qk\ dY

Explanation to follow.

Test it out online!


问:
Remove leading and trailing zeroes
Given a non-empty list/array containing only non-negative integers like this:

```<code>[0, 0, 0, 8, 1, 4, 3, 5, 6, 4, 1, 2, 0, 0, 0, 0]
</code>```

Output the list with trailing and leading zeroes removed.

The output for this would be:

```<code>[8, 1, 4, 3, 5, 6, 4, 1, 2]
</code>```

Some other test cases:

```<code>[0, 4, 1, 2, 0, 1, 2, 4, 0] > [4, 1, 2, 0, 1, 2, 4]
[0, 0, 0, 0, 0, 0] > nothing
[3, 4, 5, 0, 0] > [3, 4, 5]
[6] > [6]
</code>```

Shortest code wins

答:
Python 3, <s>48</s> <s>55</s> <s>29</s> 26 bytes

```<code>print(input().strip('0 '))
</code>```

Input and output is taken as space-separated numbers, eg:

```<code>0 0 0 1 3 1 4 0 1 3 6 4 5 19 3 1 4 0
</code>```

Alternatively, a 29-byte Python 2 solution:

```<code>print raw_input().strip('0 ')
</code>```

Title: Remove leading and trailing zeroes

Body:
Python 3, <s>48</s> <s>55</s> <s>29</s> 26 bytes

print(input().strip('0 '))

Input and output is taken as space-separated numbers, eg:

0 0 0 1 3 1 4 0 1 3 6 4 5 19 3 1 4 0

Alternatively, a 29-byte Python 2 solution:

print raw_input().strip('0 ')


问:
Golf Your Language's Identicon
Identicons are small images of geometric patterns that represent the hash value of a string. Stack Exchange uses the identicons from Gravatar as each user's default avatar image.

In this challenge, we will use the Gravatar identicons as well to generate some text to golf.

Challenge

This stack snippet (a minified version of this JSFiddle) lets you type in a string and gives back a 100×100 pixel black and white version of that string's identicon, along with a text version where 1 is for black and 0 is for white:

 <input id='str' type='text' size='32' value='Python'> <button type='button' onclick='go()'>Go</button>

<input id='type1' name='type' type='radio' value='identicon' checked> Identicon <input id='type2' name='type' type='radio' value='monsterid'> Monster <input id='type3' name='type' type='radio' value='wavatar'> Wavatar <input id='type4' name='type' type='radio' value='retro'> Retro

original
<canvas id='original' style='border:1px solid gray;'> Your browser does not support the canvas tag. </canvas>

binary
<canvas id='binary' style='border:1px solid gray;'> </canvas>

text
 <textarea id='text' style='background-color:#eee' readonly></textarea>

your text
 <textarea id='userText'></textarea>
<button type='button' onclick='markDiffs()'>Mark Differences With X</button>

(this snippet has only been tested in Chrome and Firefox)
```
</div>
</div>
</p>
<p>(It also lets you load the Monster, Wavatar, and Retro Gravatar styles, but those are just for fun and aren't meant to be used for this challenge. Unicornicons are unfortunately missing due to XSS constraints. :/ )</p>
<p>Your task is to write a program that outputs the 100×100 character text block of <code>0</code>'s and <code>1</code>'s that is generated when you put your programming language's name into the snippet input box.</p>
<p>For example, if your submission is written in Python, you would type <code>Python</code> into the stack snippet and see that</p>
<p><img src="https://i.stack.imgur.com/HNQMh.png" alt="Python identicon" /></p>
<p>is the identicon for Python, and</p>
<p><img src="https://i.stack.imgur.com/saFGU.png" alt="binary Python identicon" /></p>
<p>is the black and white (binary) version, and</p>
```0000000000000000000000011111111111111111111111111100000000000000000000000010000000000000000000000000
[encoded data, 9900 characters]
```

is the corresponding textual output that your Python program must produce.

However, since identicons can have a lot of awkward angles and their rasterization as a black and white image can leave jaggies, your output is allowed to have up to 300 0's or 1's that are the opposites of what they are supposed to be. (That's 3% of the 10000 total 0's and 1's.)

Near the bottom of the snippet, you can paste in the output of your program and check how many 0's or 1's are different than what they should be. Any number of differences at or below 300 is valid.

Scoring

The submission with the fewest bytes wins. (Handy byte counter.)

Tiebreaker goes to the submission with the fewest incorrect 0's and 1's.

If there's still a tie, the earlier submission wins.

Details

Output goes to stdout or a similar alternative if your language does not have stdout.

The output may optionally have a trailing newline.

Please include the color identicon image in your post along with the exact string that generates it. There's no need to waste space and post your entire textual output.

Your program should run without an internet connection. You need to generate the text in your code, not query it from the Gravatar site.

Use common sense when "naming" your language. Use the language name you would normally use on this site. Don't be annoying and contrive a name that makes the identicon easy to golf. e.g. Python 2 is fine for Python but python 2.7.2 is stretching it and python 2.7.2 by Guido van Rossum would be ridiculous.

I realize some languages are inherently easier than others because their identicon shapes are simpler. That's just the way it's gonna be, don't get too disgruntled or competitive about that. ;)

Title: Golf Your Language's Identicon

Body:
ForceLang, <s>2749</s> <s>2499</s> 2495 bytes

def S set
S W io.writeln
S R string.rev
S a ""+0x6D79F82328EA3DA61E0701C9182D91DDE8B1C71C7
S b ""+0x786C90F379CE770387732B1CDC3135DC3CE1C71C6
S c ""+0x7984D36EB5187CC012312A961B9A27CB5BF9C71BC
S d ""+0x79A0DA14A16CB0862210C8BE24D40F55C1D5C7158
S e ""+0x79A3A78B9F751C1A0472203FA900BFF60DEBC6D70
S f ""+0x79A3EF4AB8DC5A0FFC9CDC4D56BD69F1DBBAC4660
S g ""+0x79A3F6776E99E049FE5189BC60823AF3FB1C2BFC0
S h ""+0x79A3F72F1A60079DE42E0BC3623C9CC0D0A4F7D80
S i ""+0x79A3F741785A41CCDA794C67E9EBDAB9EAC2CE700
S j ""+0x79A3F7434E8CFFB9AC2E70DEA901D141036760600
S k ""+0x79A3F7437D9343C8FBEF208311B066CF95614BC00
S l ""+0x79A3F7438253021069541D3C0D7DBD353F18E9800
S m ""+0x79A3F74382CB60F176B1C1A99D8D000C45AA51000
W a+a
W b+b
W c+c
W d+d
W e+e
W f+f
W g+g
W h+h
W i+i
W j+j
W k+k
W l+l
W m+m
W l+l
W k+k
W j+j
W i+i
W h+h
W g+g
W f+f
W e+e
W d+d
W c+c
W b+b
W a+a
W S n ""+0x2082FAED7A3F16F730463D6FB0529164157A6772E72577EC590ADCDD251957F2BC21BCECCEDA1000001
W S o "0"+0x3404C4AF29FE8B251A078D51F3422C44257DE9CCEE48C93AB6DDD70037D6F058EF1E96AE389780000B
W S p "00"+0x533AD44B766411D4F4ED5F3E08CDC08896ADBCDC1213E71D9792DAFE2655B4B0D387777F349C0006F
W S q "000"+0x852AED458A39B62094B066CF194EDEE006289DFD2093DCC403A9A369F588AB436E4125B928600457
W S r "0000"+0xD5117BA276C2BC68EEC80E4BF8D5C1A068B3ABB7496F715789D4298974E6B48DA0883E68B702B67
W S s "00000"+0x154E8C5D0BE0401A871156A755E768D3BEF3334F8FA7C61A4F116CE6907EB4964CFA6EB1559B207
W S t "000000"+0x221746FB462FE3C989A43900F01111A46D39389143FAB11D7C222D858D8B7420DC570C3CCCF447
W S u "0000000"+0x368BA4C53AC7AFE49E5162CA0DA3D0B1C8CDBE64A8195738CB712D2038B74223F9C849AEF8AC7
W S v "00000000"+0x5745D46D515CD860B238C63288EE96F8425A28BBF8CE27A5F060FE9F8B742263237710A66BC7
W S w "000000000"+0x8BA2EC93C7B8B205605DCC1242ACE73FE320C62A60CEC941E4474B78B742266B0F5F107B5C7
W S x "0000000000"+0xDF6A832B1C8B32B27AA702FBBFD960651EAB9E37CE30AD4E093DA78B7422670BEB558DD9C7
W S y "00000000000"+0x1651C9F6F18C5FB47C580D61E4F69EB8CFDD04644901F0B5CFB5078B742267151AEC7761C7
W S z "000000000000"+0x202C1796B182D85E5704E2B93930E38C74A50C6F9CC338492A1C78B7422671603C11C71C7
W y
W x
W w
W v
W u
W t
W s
W r
W q
W p
W o
W n
W R n
W R o
W R p
W R q
W R r
W R s
W R t
W R u
W R v
W R w
W R x
W R y
W R z
W R y
W R x
W R w
W R v
W R u
W R t
W R s
W R r
W R q
W R p
W R o
W R n
W S a R a+a
W S b R b+b
W S c R c+c
W S d R d+d
W S e R e+e
W S f R f+f
W S g R g+g
W S h R h+h
W S i R i+i
W S j R j+j
W S k R k+k
W S l R l+l
W R m+m
W l
W k
W j
W i
W h
W g
W f
W e
W d
W c
W b
W a


答:
JavaScript, 71 bytes

```<code>(i,n=i.toString(2))=>/^(1*)2?\1$/.test(+n+ +n.split``.reverse().join``)
</code>```

Defines an anonymous function.

This method may not be the shortest, but as far as I know, it is unique. It adds the number in binary to itself reversed, treating them as decimal, then checking if the result is valid using a regex.

Title: Folding Numbers

Body:
Given a number determine if it is a folding number.

A folding number is a number such that if you take it binary representation and "fold" it in half,  That is take the result of XNOR multiplication of the first half of the number and the second half with it digits in reverse, you will get zero.

If the number has a odd number of digits in binary its middle digit must be 1 and is ignored when folding.

Since that might be a bit confusing I will give some examples:

178

The binary representation of 178 is

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

To fold this we first split it in half

```<code>1011 0010
</code>```

We reverse the second half

```<code>1011
0100
</code>```

And we XNOR the two halves:

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

This is zero so this is a folding number.

1644

The binary representation of 1644 is

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

To fold this we first split it in half

```<code>11001 1 01100
</code>```

The middle bit is 1 so we throw it out.

```<code>11001 01100
</code>```

We reverse the second half

```<code>11001
00110
</code>```

And we XNOR the two halves:

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

This is zero so this is a folding number.

4254

The binary representation of 4254 is

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

To fold this we first split it in half

```<code>100001 0 011110
</code>```

The middle bit is 0 so this is not a folding number.

Task

Your task is to take in a positive number and return a truthy if the number is folding and falsy if it is not.  This is code golf so try to keep the byte count down.

Test Cases

Here are the first 99 folding numbers:

```<code>[1, 2, 6, 10, 12, 22, 28, 38, 42, 52, 56, 78, 90, 108, 120, 142, 150, 170, 178, 204, 212, 232, 240, 286, 310, 346, 370, 412, 436, 472, 496, 542, 558, 598, 614, 666, 682, 722, 738, 796, 812, 852, 868, 920, 936, 976, 992, 1086, 1134, 1206, 1254, 1338, 1386, 1458, 1506, 1596, 1644, 1716, 1764, 1848, 1896, 1968, 2016, 2110, 2142, 2222, 2254, 2358, 2390, 2470, 2502, 2618, 2650, 2730, 2762, 2866, 2898, 2978, 3010, 3132, 3164, 3244, 3276, 3380, 3412, 3492, 3524, 3640, 3672, 3752, 3784, 3888, 3920, 4000, 4032, 4222, 4318, 4462, 4558]
</code>```

Body:
JavaScript, 71 bytes

(i,n=i.toString(2))=>/^(1*)2?\1$/.test(+n+ +n.split``.reverse().join``)

Defines an anonymous function.

This method may not be the shortest, but as far as I know, it is unique. It adds the number in binary to itself reversed, treating them as decimal, then checking if the result is valid using a regex.


问:
Super Folding Numbers
We have already defined a folding number here.

But now we are going to define a Super Folding Number.  A Super Folding number is a number that if folded enough times it will eventually reach one less than a power of two.  The method of folding is slightly different than in the folding number question.

The folding algorithm goes as follows:

Take the binary representation

e.g. 5882

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

Spilt it into three partitions.  First half, last half and middle digit (iff it has a odd number of digits)

```<code>101101 1 111010
</code>```

If the middle digit is zero this number cannot be folded

Reverse the second half and superimposed on the first half

```<code>010111
101101
</code>```

Add the digits in place

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

Iff there are any 2s in the result the number cannot be folded otherwise the new number is the result of the folding algorithm.

A number is a Super Folding number if it can be folded to a continuous string of ones. (All Folding numbers are also Super Folding Numbers)

Your task is to write code that takes in a number and outputs a truthy value if the number is a Super Folding number and falsy otherwise.  You will be scored on the size of your program.

Examples

5200

Convert to binary:

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

Split in half:

```<code>101000 1 010000
</code>```

The middle is one so we continue
Superimpose the halves:

```<code>000010
101000
</code>```

Added them:

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

No twos so we continue
Split in half:

```<code>101 010
</code>```

Fold:

```<code>010
101

111
</code>```

The result is 111 (7 in decimal) so this is a Super Folding Number.

Test Cases

The first 100 Super Folding Numbers are:

```<code>101101 1 111010
</code>```0

答:
Java 7, 202 bytes

```<code>boolean g(Integer a){byte[]b=a.toString(a,2).getBytes();int i=0,l=b.length,o=0,c,z=(a+1&a)==0?-1:1;for(;i<l/2&z>0;o+=o+c*2,z*=c>1|(l%2>0&b[l/2]<49)?0:1)c=b[i]+b[l-++i]-96;return z<0?1>0:z<1?0>1:g(o/2);}
</code>```

It took a bit of effort to make the old folding function recursable, but here it is. It's ugly as sin, to be honest. I'll have to take a look in the morning to see if I can golf it further, since I can barely stand to look at it right now.

With line breaks:

```<code>boolean g(Integer a){
    byte[]b=a.toString(a,2).getBytes();
    int i=0,l=b.length,o=0,c,z=(a+1&a)==0?-1:1;
    for(;i<l/2&z>0;o+=o+c*2,z*=c>1|(l%2>0&b[l/2]<49)?0:1)
        c=b[i]+b[l-++i]-96;
    return z<0?1>0:z<1?0>1:g(o/2);
}
</code>```

Title: Super Folding Numbers

Body:
Java 7, 202 bytes

boolean g(Integer a){byte[]b=a.toString(a,2).getBytes();int i=0,l=b.length,o=0,c,z=(a+1&a)==0?-1:1;for(;i<l/2&z>0;o+=o+c*2,z*=c>1|(l%2>0&b[l/2]<49)?0:1)c=b[i]+b[l-++i]-96;return z<0?1>0:z<1?0>1:g(o/2);}

It took a bit of effort to make the old folding function recursable, but here it is. It's ugly as sin, to be honest. I'll have to take a look in the morning to see if I can golf it further, since I can barely stand to look at it right now.

With line breaks:

boolean g(Integer a){
    byte[]b=a.toString(a,2).getBytes();
    int i=0,l=b.length,o=0,c,z=(a+1&a)==0?-1:1;
    for(;i<l/2&z>0;o+=o+c*2,z*=c>1|(l%2>0&b[l/2]<49)?0:1)
        c=b[i]+b[l-++i]-96;
    return z<0?1>0:z<1?0>1:g(o/2);
}