[Question]
      [
# Introduction
A while ago a lost SO user posted a question here and its now been deleted but I think it would make a good challenge so here it goes...
# Challenge
Write a full program or function that takes two strings and checks whether any permutation of the first string is a sub-string of the second string.
# Input
Two strings, a string and a sub-string to test for (you may choose the order).
# Output:
A truthy value if the string contains any permutation of the sub-string.
A falsey value if the string does not contain any permutations of the the sub-string.
The test is case sensitive.
# Examples/Test cases
```
         sub-string    string
input    d!rl          Hello World!
output   truthy
input    Pog           Programming Puzzles & Code Golf
output   falsey
input    ghjuyt        asdfhytgju1234
output   truthy
```

[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 2 bytes
```
sp
```
[Try it online!](https://tio.run/nexus/brachylog2#@19c8P@/UmJxSlpGZUl6VqmhkbGJ0n@l9Iys0soSJQA "Brachylog – TIO Nexus")
### Explanation
```
Input variable = "Hello World!", Output variable = "d!rl"
(?)s        Take a substring of the Input variable
    p(.)    It is a permutation of the Output variable
```
[Answer]
# JavaScript (ES6), 77 bytes
```
(s,t)=>t&&[...t.slice(0,s.length)].sort()+''==[...s].sort()|f(s,t.slice(1))
```
Returns 1 or 0.
**Snippet**
```
f=
(s,t)=>t&&[...t.slice(0,s.length)].sort()+''==[...s].sort()|f(s,t.slice(1))
console.log(f('d!rl','Hello World!'))                   //1
console.log(f('Pog','Programming Puzzles & Code Golf')) //0
console.log(f('ghjuyt','asdfhytgju1234'))               //1
```
[Answer]
## Python 2, ~~67~~ 66 bytes
Takes input as two strings, substring first.
```
a=sorted
lambda s,S:a(s)in[a(S[n:n+len(s)])for n in range(len(S))]
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 3 bytes
```
œåZ
```
[Try it online!](https://tio.run/##MzBNTDJM/f//6OTDS6P@/09RLMrh8kjNycnXUQjPL8pJUQQA "05AB1E – Try It Online")
-1 byte thanks to [Emigna](https://codegolf.stackexchange.com/users/47066/emigna).
Explanation:
```
œåZ 2 inputs
œ                  permutations of the first input
 å  Is each of the                                 in the second input?
  Z Take the maximum of the resulting boolean list
```
[Answer]
# Japt, ~~10~~ ~~7~~ 6 bytes
```
á d!øV
```
[Try it online](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=4SBkIfhW&input=ImQhcmwiCiJIZWxsbyBXb3JsZCEi)
```
á d!øV   :Implicit input of sub-string U & string V
á        :Permutations of U
  d      :Any
   !øV   :  Contained in V
```
[Answer]
# Java 8, ~~266~~ 244 bytes
```
import java.util.*;Set l=new HashSet();s->p->{p("",p);for(Object x:l)if(s.contains(x+""))return 1>0;return 0>1;}void p(String p,String q){int n=q.length(),i=0;if(n<1)l.add(p);else for(;i<n;)p(p+q.charAt(i),q.substring(0,i)+q.substring(++i,n));}
```
**Explanation:**
[Try it here.](https://tio.run/nexus/java-openjdk#jZBBj9owEIXv/IrZHCqbBANtTw1Eaiu1e0FFolIPVQ8mcRIjxzb2eNks4rdTh7LaarnswfbM0/jz8ztPp/CzFWC5Qw8HiS1Mp@Ntj2JSmqBxDNwJwNb4Yed4aYdhMHUUBHDtD8KNRrKzJqo7/sBZQKnYOH9Fuh2pgy5RGs2@XYt8VCruPayOI4CNQFBLLQ5wz30bO0JvkADPVxcbdFI32ev@izFKcF0U5TJOA/hJYSfF0ZIkySzNa@PIj@1OlAiPnxSVNfGsNBq51J48pklCqRMYnIZ5Mcuv5ayY56dbK3lcD0ZWYMm/x8Fm12JPj1Ij6OWeKaEbbAnN5HKWx/f0Yk4V41VFoh2hYs6Dp1wudE4tsemelS13n5FImu2ZD1t/QZJZJmn6v5CmMtOU3jqLtmzYKlmCR47xuJjs4hevPn//AU6Pl3hW0MEShtBXMe6LtOk9io6ZgMzGaVSadKxk3FrVk@ReKGXgl3Gqukvos1rdORWjewtg7UzjeNcNMa3D05MSHt7BV1MJ@G5U/cJcm@aNSO6ruu2x2YX5@w8fXwhNuws9XiGn0el8/gs)
```
java.util.*;                   // Required import for Set and HashSet
Set l=new HashSet();           // Class-level Set
s->p->{                        // Method (1) with two String parameters and boolean return-type
  p("",p);                     //  Put all permutations in the class-level Set
  for(Object x:l)              //  Loop over the permutations:
    if(s.contains(x+""))       //   If the input String contains one of the permutations:
      return 1>0;//true        //    Return true
                               //  End of loop (implicit / single-line body)
  return 0>1;//false           //  Return false
}                              // End of method (1)
void p(String p,String q){     // Method (2) with two String parameters and no return-type
  int n=q.length(),i=0;        //  Two temp integers
  if(n<1)                      //  If `n` is zero:
    l.add(p);                  //   Add this permutation of the String to the Set
  else                         //  Else:
    for(;i<n;                  //   Loop over `n`
      p(p+q.charAt(i),q.substring(0,i)+q.substring(++i,n))
                               //    Recursive-call with permutation parts
    );                         //   End of loop (no body)
}                              // End of method (2)
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 5 bytes
```
Œ!ẇ€Ṁ
```
[Try it online!](https://tio.run/##y0rNyan8///oJMWHu9ofNa15uLPh////SimKRTlK/5U8gLL5Ogrh@UU5KYpKAA "Jelly – Try It Online")
-1 thanks to [Emigna](https://codegolf.stackexchange.com/users/47066/emigna) for encouraging me to retry golfing.
Explanation:
```
Œ!ẇ€Ṁ Main link, dyadic
Œ!               the permutations of the left argument
  ẇ€  Is each of                                      in the right argument?
    Ṁ Maximum of boolean values
```
[Answer]
# [Python](https://docs.python.org/), 60 bytes
An altered form of [TFeld's answer](https://codegolf.stackexchange.com/a/122945/53748) - go give some credit!
```
s=sorted
f=lambda u,t:s(u)==s(t[:len(u)])or t and f(u,t[1:])
```
Recursive function returning the boolean `True` (truthy) or an empty string (falsy).
**[Try it online!](https://tio.run/nexus/python3#HY67DoIwGEZneYqfDtKaOqBOTerioCObA2Go6QVIaU0vA7w8guP5cpLzrZFHH5KSheZWTB8pINPEIs6E84hTy6xyG3TEB0ggnASNN6OtWUdWvY8qJhgcYIxkGSyigF7KWg9vH6wsEaEYNd4giprgTRDTNDgDTV4WqyIc4eGlgqe3@m@afsxz2mQRpe7nZMZcX643RAgrDt8wuIT3IIXqfK/o9uW0IyHrDw "Python 3 – TIO Nexus")**
sorts the substring, `u`, and the same length of the front of the string, `t`, (using a slice `t[:len(u)]`) if they are the same then `True` is returned, otherwise if `t` is still truthy (not empty) recurses with a dequeued `t` (using a slice, `t[1:]`). If `t` does become empty the `and` is not executed and this empty `t` is returned.
[Answer]
# Pyth, ~~9~~ 8 bytes
```
sm}dQ.pE
```
*-1 byte thanks to @Erik\_the\_Outgolfer*
Takes two quoted strings, the second of which is the substring.
[Try it!](https://pyth.herokuapp.com/?code=sm%7DdQ.pE&input=%22Hello+World!%22%0A%22d!rl%22)
[Answer]
## Mathematica, ~~55~~ 50 bytes
-5 bytes from user202729
```
StringFreeQ[#2,""<>#&/@Permutations@Characters@#]&
```
Returns `False` if a permutation of the first input is in the second string. Returns `True` if a permutation of the first input is not in the second string.
Explanation:
```
                                    Characters@#   - split first string into array of characters
                       Permutations@               - make all permutations
               ""<>#&/@                            - join each array of characters together to form a single string
StringFreeQ[#2,                                 ]& - Check if any of these string is in the second input string
```
[Answer]
# [CJam](https://sourceforge.net/p/cjam), ~~13~~ 12 bytes
```
le!lf{\#)}:+
```
[Try it online!](https://tio.run/##S85KzP3/PydVMSetOkZZs9ZK@///9Iys0soSrsTilLSMypL0rFJDI2MTAA "CJam – Try It Online")
I feel like CJam is really limited compared to other golfing languages, but maybe it's just me being bad...
I'm thinking about moving to another. 05AB1E seems fun.
*Fixed small bug thanks to Erik the Outgolfer*
*Cut one bite because non-zero numbers are truthy*
Explanation:
```
l                 Read substring
 e!               Generate all permutations
   l              Read string
    f{            For each permutation
      \#            Check if it is in the string (returns -1 if not found)
        )           Add one
         }        End for
          :+      Sum the whole found/not found array
```
[Answer]
# [Java 9 JShell](http://jdk.java.net/9/), 160 bytes
```
p->q->IntStream.range(0,q.length()-p.length()+1).anyMatch(
    i->Arrays.equals(
        q.substring(i,i+p.length()).chars().sorted().toArray(),
        p.chars().sorted().toArray()))
```
(newlines inserted for readability)
[Try it online!](https://tio.run/nexus/java-openjdk9#hVBNb9swDL3rV7CXQVoTYd12S2NgGLAPYB0C5LDDsANr07YyWXIkqp079LdncuxmRVFsPEgE@d4jH03X@8CwwxvUiY3VL1fCPK3VyZVsvHu2GTkQdmNL9OnamhJKizHCFRoHvwXkmOuRkfN3400FXe7KLQfjmu8/AEMT1Qwe48M88HJCLGATqDIlMs2VooAa1od@WeyXxWfH22mJgK4h@Wqx15Zcw61Uy/6Unl8ojW64Qi5baZbFuxBwiJr2CW2Uex3TdTyKS7Mw5395SpcthiiVjtk5VTlhfyRLtej/0VTq8GBotS3ROQoQ8w9rcHQLc0luh8jUaePU6nSA29ZYAjmidYvxK/3iL8ZR1nx0pTGmc2Q9qjJhfdTX7gRfPQdus23G8ud/4dNiPrHuM5Gtk7XGvreDnOZlrxRZPuipR/x7Mb33h@osWPGJrPXwzQdbnYmNb8Qm@CZg1437bNLdnaUIL@C9rwg@eluLpt2lgQXGqm4Hbnbp4vWbt38A "Java (OpenJDK 9) – TIO Nexus")
Note: JShell includes a number of imports by default. As a Java 8 or Java 9 solution, it would be necessary to import:
```
import java.util.*;import java.util.stream.*;
```
For an extra 45 bytes, or 205 bytes total. The TIO link above is to a Java 9 program since TIO doesn't currently have JShell (and it's not clear to me how JShell would work on TIO).
[Answer]
# C#, 320 bytes
```
using System.Linq;s=>u=>p(u.ToArray(),0,u.Length-1).Any(p=>s.Contains(p));w=(c,a,b)=>{if (a!=b)(var t=c[a];c[a]=c[b];c[b]=t;)};System.Collections.Generic.IEnumerable<string>p(char[]l,int k,int m){if(k==m)yield return new string(l);else for(int i=k;i<=m;){w(l,k,i);foreach(var c in p(l,k+1,m))yield return c;w(l,k,i++);}}
```
I'm sure calculating the permutations can be a lot shorter but I can't see how at the moment.
Formatted/Full version:
```
void test()
{
    Func<string, Func<string, bool>> f = s => u =>
        p(u.ToArray(), 0, u.Length - 1).Any(p => s.Contains(p));
    Console.WriteLine(f("Hello World!")("d!rl"));
    Console.WriteLine(f("Programming Puzzles & Code Golf")("Pog"));
    Console.WriteLine(f("asdfhytgju1234")("ghjuyt"));
}
System.Collections.Generic.IEnumerable<string>p(char[] l, int k, int m)
{
    Action<char[], int, int> w = (c, a, b) =>
    {
        if (a != b)
        {
            var t = c[a];
            c[a] = c[b];
            c[b] = t;
        }
    };
    if (k == m)
        yield return new string(l);
    else
        for (int i = k; i <= m;)
        {
            w(l, k, i);
            foreach (var c in p(l, k + 1, m))
                yield return c;
            w(l, k, i++);
        }
}
```
[Answer]
# [Ruby](https://www.ruby-lang.org/), 69 bytes
```
->a,b{r=nil;a.chars.each_cons(b.size){|q|r||=q.sort==b.chars.sort};r}
```
[Try it online!](https://tio.run/nexus/ruby#RYu7DoIwFEB3v6J2EE2wiY@N1MVBRzYHQ0yhpUAKV25pwvPbURON48k5p@Xz9iT8eEBe5SYQLMkEWqZEkj0SqOw6Zjbv1WYY6xHHkdfMAjacx9/wQ1OA0/x0jSXt3bsqY4DcAI1cer4nl2i8aPGzIYJGUZZ5pUno@t4oS1bkDFKRC5j0PYSg/z0VVqZZ1@jC7faHI/WpzgrXNTSaXw "Ruby – TIO Nexus")
[Answer]
# [Perl 6](http://perl6.org/), 48 bytes
```
{$^a.contains(any $^b.comb.permutations».join)}
```
Returns an or-junction of each permutation's presence as a substring. For example, with arguments `"Hello World!"` and `"d!l"`, returns:
```
any(False, False, False, False, True, False)
```
...which "collapses" to `True` in a boolean context. That is, junctions are truthy values.
[Answer]
# PHP>=7.1, 91 Bytes
```
for([,$x,$y]=$argv;~$p=substr($y,$i++,strlen($x));)$t|=($c=count_chars)($x)==$c($p);echo$t;
```
[Testcases](http://sandbox.onlinephpfunctions.com/code/5593a150bb9b96c6d8bc13ee03c2ffcd0d7ca2a8)
[Answer]
# Haskell, 54 bytes
```
import Data.List
s#t=any(`isInfixOf`s)$permutations t
```
Using the power of Data.List for both `isInfixOf` as well as `permutations`.
[Answer]
# [R](https://www.r-project.org/), 103 bytes
```
function(w,x,y=u(w),z=u(x)){for(i in 1:n(w)){F=F|!sum(setdiff(y[1:n(x)+i-1],z))};F}
u=utf8ToInt
n=nchar
```
[Try it online!](https://tio.run/##JcqxbsIwFIXhPU9x4wHZwgwpHSogE1KALUOlDoghwrmOkeMrObZI0vLsaSKmI53v9xPCYQMTRncPhhx/yl4OeeRPIcd5eiF@kTw3YBxku9nno8iLv7SLLe/qoAwiH64L9WJtNtlNjkK89sUriXkM@PVNFxcSl7t7U/kJOTvX1hL8kLcqZRKYSr1lIpml9KR91bbGaSjjONq6gxUcSdVwIotLXJJ@t1WnsBmCfsTsY/u5kG4ecQhMTP8 "R – Try It Online")
Returns `TRUE` for truthy and `NA` for falsey.
[Answer]
# MATL, 10 bytes
```
Y@Z{w&Xfma
```
[Try it on MATL Online](https://matl.io/?code=Y%40Z%7Bw%26Xfma&inputs=%27d%21rl%27%0A%27Hello+World%21%27&version=20.9.1)
[Answer]
# [Ruby](https://www.ruby-lang.org/), 43 bytes
```
->a,b{b.chars.permutation.any?{|c|a[c*""]}}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsEiN9ulpSVpuhY3tXXtEnWSqpP0kjMSi4r1ClKLcktLEksy8_P0EvMq7atrkmsSo5O1lJRia2uhWjoKFNyilTxSc3LyFcLzi3JSFJV0FJRSFItylGIVlBVs7RRKikpTucCqAory04sSc3Mz89IVAkqrqnJSixXUFJzzU1IV3PNz0kAaA_LTYfrSEnOKoRoTi1PSMipL0rNKDY2MTUDq0jOySitLkK2AuGfBAggNAA)
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), 18 bytes
```
{∨/(∧/⍺∊⊢)¨⍵,/⍨⍴⍺}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///3/FR24TqRx0r9DUedSzXf9S761FH16OuRZqHVjzq3aoDFADSW4DCtf//q6coFuWoO6p7pObk5CuE5xflpCiqc6kH5KcDBQOK8tOLEnNzM/PSFQJKq6pyUosV1BSc81NSFdzzc9KA6tIzskorS4BKE4tT0jIqS9KzSg2NjE3UAQ "APL (Dyalog Unicode) – Try It Online")
[Answer]
# [Factor](https://factorcode.org/) + `math.combinatorics`, 35 bytes
```
[ '[ _ subseq? ] find-permutation ]
```
[Try it online!](https://tio.run/##TY@7TgMxEEX7/YqbLUJFpBAqkKCgCGnQShGiiCLk@LUOtmdjj4tNlG9fjBASU845dzTXCMmUpvft5m39AJEzyQyTRgTB/UJSOLgoquHqekiaeRySi4ysT0VHqTMem@bSoM4FrZol36J91d4TPih5NWtx/aMd2Qq7RDaJEFy06Mr57OuNOV5IaazJm3@@7Y9l5BoRWZl@ZHssy7vV/Y9xnXa42eETuRzqK8/Yw7iobgedQmHBjiL2k/kt9BTEgMxCfi2mbw "Factor – Try It Online")
Outputs the matching subsequence (which behaves as boolean true in Factor) for truthy and `f` for falsey.
]


[Question]
      [
Rearrange a given list such that all the odd numbers appear before all the even numbers. Besides for this requirement, the output list may be in any order.
The input will only contain integers, but they may be negative and there may be duplicates, and they may appear in any order.
Shortest solution wins.
### Test cases
`[1,2]` → `[1,2]`
`[2,1]` → `[1,2]`
`[1,0,0]` → `[1,0,0]`
`[0,0,-1]` → `[-1,0,0]`
`[3,4,3]` → `[3,3,4]`
`[-4,3,3]` → `[3,3,-4]`
`[2,2,2,3]` → `[3,2,2,2]`
`[3,2,2,2,1,2]` → `[1,3,2,2,2,2]` or `[3,1,2,2,2,2]`
`[-2,-2,-2,-1,-2,-3]` → `[-1,-3,-2,-2,-2,-2,]` or `[-3,-1,-2,-2,-2,-2,]`
`[]` → `[]`

[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 2 bytes
```
ΣÉ
```
[Try it online!](https://tio.run/##MzBNTDJM/f//3OLDnf//RxvqGOkY65jomOqY6ZjrWOhYxgIA "05AB1E – Try It Online")
[Answer]
# C++, ~~79~~ ~~76~~ 64 bytes
```
[](auto a,auto b){while(a<--b)*a%2?*++a:(*a^=*b,*b^=*a,*a^=*b);}
```
This function accepts a pair of iterators (which must be random access iterators), and steadily moves them towards each other. When `a` points to an odd number, it is advanced. Otherwise, `a` points to an even number; `b` is decremented, and `iter_swap`'ed with `a`. (We use XOR swap, which saves us having to include `<algorithm>` - or `<utility>` for `std::swap`).
There are unnecessary swaps when `b` points to an even number, but we're golfing, not squeezing efficiency!
## Demo
```
auto f=[](auto a,auto b){while(a<--b)*a%2?*++a:(*a^=*b,*b^=*a,*a^=*b);};
#include <array>
#include <iostream>
int main()
{
    auto a = std::array{ 3,2,2,5,2,1,2 };
    f(a.begin(),a.end());
    for (auto i: a)
        std::cout << i << " ";
    std::cout << std::endl;
}
```
---
## Non-competitive answer
The natural C++ method is `std::partition`, but that comes out at **83** bytes:
```
#include<algorithm>
[](auto a,auto b){std::partition(a,b,[](auto x){return x&1;});}
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), ~~4~~ 3 bytes
-1 byte thanks to isaacg
```
iD2
```
[Try it online!](https://tio.run/##K6gsyfj/P9PF6P//aEMdIx1jHRMdcx1TMMtSx9hEx9AoFgA "Pyth – Try It Online")
crossed out 4 is still regular 4
[Answer]
# [R](https://www.r-project.org/), ~~30~~ 24 bytes
```
(x=scan())[order(!x%%2)]
```
[Try it online!](https://tio.run/##K/r/X6PCtjg5MU9DUzM6vygltUhDsUJV1Ugz9r@hgpGCqYKlgpmCsYKJgjmYbQHmGSoYGvwHAA "R – Try It Online")
*-6 bytes thanks to JayCe*
[Answer]
# [J](http://jsoftware.com/), 5 bytes
```
\:2&|
```
[Try it online!](https://tio.run/##y/r/P83WKsbKSK0GyFIwUjBXMFSwANIWYNqYK03BGMgyAWJTBUuguJmCKQA "J – Try It Online")
`\:` sort descending by
`2&|` mod-2
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 2 bytes
```
ñv
```
[Try it online!](https://tio.run/##Dci5DYBADEXBhp4lvne9Ry2IgJSIANEXNVCYYcI59vPKfJ87c7XAKlYwx8SCcAqVoNEZTPSnkKOCKgrUUEcDze0D "Japt – Try It Online")
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 12 bytes
```
*.sort(*%%2)
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYKvwX0uvOL@oRENLVdVI8781V3FipUKaRrShjpGOsY5JrCZcxFjHVMdcx9AASchIx0THTMcSKPIfAA "Perl 6 – Try It Online")
Some Whatever code that sorts the input by parity, with odd numbers first. You can remove a `%` to get even numbers first instead. Note that 'Whatever' is the name of this sort of anonymous function.
[Answer]
# MATL, 6 bytes
```
tog&)v
```
[Try it on MATL Online](https://matl.io/?code=tog%26%29v&inputs=%5B5%2C2%2C3%2C4%2C19%2C7%2C8%2C1%2C20%5D&version=20.9.1)
Alternately:
```
to_2$S
```
[Try it on MATL Online](https://matl.io/?code=to_2%24S&inputs=%5B5%2C2%2C3%2C4%2C19%2C7%2C8%2C1%2C20%5D&version=20.9.1)
[Answer]
# [Haskell](https://www.haskell.org/), ~~23~~ 22 bytes
```
f odd<>f even
f=filter
```
[Try it online!](https://tio.run/##DY2xDoIwFEV3vuIOjtJI4uAgLpjoSOJiog4VXsuLpcVH4fOtnc5wz80Z9Pwh5xKPU5CIs45a3WhkK2GZUJbwAS54SwJP1FMP9rhcGxzUXlUIgoHtQLLFe4kQ@i4sWTJ5iAOhW0TIR6wkMwePbBIyI4fCosYzGYS@P54MaCVfmNqwiyRp1LlTYxLO7w0sHpVS1e6Vfp1x2s6pvDdt@wc "Haskell – Try It Online") This is equivalent to
```
g x = filter odd x ++ filter even x
```
*-1 byte thanks to [Lynn](https://codegolf.stackexchange.com/users/3852/lynn)*
---
Other approaches:
```
(<>).($odd)<*>($even)$filter
import Data.List;sortOn even
g x=[i|m<-[0,1],i<-x,odd$m+i]
g x=[i|m<-[1,0],i<-x,mod i 2==m]
g x=id=<<filter<$>[odd,even]<*>[x]
```
[Answer]
# [Python 2](https://docs.python.org/2/), ~~37~~ 36 bytes
```
lambda a:sorted(a,key=lambda x:~x%2)
```
[Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUSHRqji/qCQ1RSNRJzu10hYqWmFVV6FqpPm/oCgzr0QhTSNa11DHRMdYR9dYx0hH1yhW8z8A "Python 2 – Try It Online")
1 byte tip o' the hat to [Mr. Xcoder](https://codegolf.stackexchange.com/users/59487/mr-xcoder).
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 5 bytes
```
{|eom
```
[Run and debug it](https://staxlang.xyz/#c=%7B%7Ceom&i=[1,2,3,4,5,6]%0A[3,57,26,36823435,0]&a=1&m=2)
Explanation:
```
{|eom Full program, implicit input
{  o  Sort by key:
 |e     Is odd?
    m Map over result:
        Implicit output with newline
```
[Answer]
# [Attache](https://github.com/ConorOBrien-Foxx/Attache), 11 bytes
```
SortBy!Even
```
[Try it online!](https://tio.run/##SywpSUzOSP2fpmBl@z84v6jEqVLRtSw1779fampKcbRKQUFyeixXQFFmXklIanGJc2JxanF0mo5CNJcCEEQb6igY6SgY6yiY6CiYxupABC3BIhY6CoYGQGwI5hkbgrhAvhFMlS5Ery5QpzFMLJYrNvY/AA "Attache – Try It Online")
## Explanation
`Even` returns `true` for even numbers and `false` otherwise. `SortBy` ranks `false < true` (by a numerical cast to `0 < 1`), thus placing odd numbers before even ones.
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 29 bytes
```
a=>a.sort((a,b)=>(b&1)-(a&1))
```
[Try it online!](https://tio.run/##DcpBCoAgEADA38QKu0LZLfQj0WEtjULc0Oj75mVOc/PHdS/X81KWI7RoG1vHukp5ARi9sg78MCoC7qq27JKrpKCTnBBhpRFnNEgGJ6Rp6@MH "JavaScript (Node.js) – Try It Online") Save 4 bytes by only supporting positive values using `b%2-a%2`. If you write this as:
```
function(a){return a.sort((a,b)=>(b&1)-(a&1))}
```
then it will work on all sorts of old JavaScript implementations that didn't sort stably.
[Answer]
# T-SQL, 26 bytes
```
SELECT*FROM t ORDER BY~i&1
```
Uses the bitwise AND operator "&" to compare the last digit with 1.
EDIT: Bitwise NOT then shorter than adding 1.
EDIT2: Reorder to allow removal of the space.
[Answer]
# [PHP](https://php.net/), 55 bytes
~14 months later and I'm a little bit better at golfing now:
```
for(;''<$n=$argv[++$i];$s=$n%2?"$n $s":"$s $n");echo$s;
```
[Try it online!](https://tio.run/##DcTRCkAwAAXQX9G6QksxtbDJh8iDhHnZlpXfv5yHE12kneP/GZ7SFIWFn7A917tIiXs1SBN8rmYBnyGJUSBl8KIyx@4CkiGp2LBl3bJjTzWw1lp/ "PHP – Try It Online")
---
# [PHP](https://php.net/) (>=5.4), ~~84~~ 82 bytes
(-2 bytes, thanks to [Ismael Miguel](https://codegolf.stackexchange.com/users/14732/ismael-miguel))
```
<?array_shift($a=&$argv);usort($a,function($i){return$i%2==0;});echo join(' ',$a);
```
To run it:
```
php -n <filename> <number_1> <number_2> ... <number_n>
```
Example:
```
php -n sort_odds_first.php 2 0 1 -1 3 8 29 -666
```
Or [Try it online!](https://tio.run/##FczRCsIgGAbQV9mFNYUJm4EUTnqUkLGlXaj8ajCiV@@L3Z6Lk30G5rsjcvuj@LBVzpw9M0fPtzCtJDpg2FpcakiRsyA@tNZGkYWTsnY0X2HWxafulULkfdcPzAkDQGHEBDnhgivUDVJr/Uv5WApk/AM "PHP – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 3 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
ḂÞṚ
```
**[Try it online!](https://tio.run/##y0rNyan8///hjqbD8x7unPX//38LHSMdYx0DHV0THV1DHTMgNAQA "Jelly – Try It Online")**
One of the more oft-wanted atoms seems to be an is-even one (which would make this 2 bytes), without it we must reverse I believe...
```
ḂÞṚ - Link: list of integers
 Þ  - sort by:
Ḃ   -   bit (least significant bit - i.e. 1 if odd 0 if even)
  Ṛ - reverse
```
[Answer]
**JavaScript, ~~22~~ 20 bytes**
`a=>a.sort(a=>!(a%2))`
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@z/R1i5Rrzi/qEQDyFLUSFQ10tT8b52cn1ecn5Oql5OfrpGmEW2oY6RjrGOiY6pjpqNrqKNrpKNrrKNrEgtUCgA)
[Answer]
# [Python](https://docs.python.org/2/), 35 bytes
```
lambda l:sorted(l,key=(-1).__pow__)
```
[Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUSHHqji/qCQ1RSNHJzu10lZD11BTLz6@IL88Pl7zf46CrUK0rqGOiY6xjq6xjpGOrlEsV0FRZl6JQppGjuZ/AA "Python 2 – Try It Online")
Sorts by the function `x -> (-1)**x`, which gives `-1` for odd and `1` for even.
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), 50 bytes
```
A+S:-predsort([X,Y,Z]>>(Y/\1>Z/\1,X= <;X= >),A,S).
```
[Try it online!](https://tio.run/##FcpLCoAgAEXRrTg0fBZGEvQRXIOTvrMigkgxoeWbTQ5cuM7byx78ec8YNTMNd37fHusDnQeMmFal6FgsQk0JDD3p2oTKoGGyPDaczAIlJJIVZAXxR52yhlyZAXH@vAP95w8 "Prolog (SWI) – Try It Online")
-8 thanks to Jo King
[Answer]
# [Red](http://www.red-lang.org), 42 bytes
```
func[a][sort/compare a func[n][n % 2 = 1]]
```
[Try it online!](https://tio.run/##HcixCoAgFEbhvaf4l@bwqhRBL9F6uYOUQkMqZs9v2HCG7xR/tt2fLENYW3jjwU74SaVOR7qzKx4O/47CESMIG5RIy@WKFQGsoAikYXqaDKwm2A5L0FgwS/sA "Red – Try It Online")
If we need to account for negative values:
# [Red](http://www.red-lang.org), 43 bytes
```
func[a][sort/compare a func[n][n // 2 = 1]]
```
[Try it online!](https://tio.run/##HchBCoAgEEbhfaf4LxDiqBRBl2g7zEJKoUUWVuefsMVbfK@mTZe0sXR50vyWlaPwfdbHrOdxxZoQ8e8iXGAMCDOsiF51Lw8y2MISyMG3HHkER@hDUyA4jBhEPw "Red – Try It Online")
[Answer]
# [Husk](https://github.com/barbuz/Husk), 4 bytes
```
↔Ö%2
```
[Try it online!](https://tio.run/##yygtzv7//1HblMPTVI3@//8fbaljoWOuY6ZjqGOkY6xjomMaCwA "Husk – Try It Online")
**Explanation**
```
 Ö     sort input according to the result of the following function
  %2   modulo 2
↔      reverse result to get odd numbers to the front
```
[Answer]
# [Scala](http://scala-lang.org), 18 bytes
```
_.sortBy(_.+(1)%2)
```
[Answer]
# C#, 23 bytes
```
i=>i.OrderBy(u=>u%2==0)
```
Quite straigt forward really: This basically converts the numbers to booleans, whilst `true` means that the number is even and `false` that it's odd. Because `true` is higher than `false` the even numbers appear first.
The formatted version looks like that:
```
i => i.OrderBy (u => u % 2 == 0)
```
And you can test it like that:
```
Console.WriteLine (string.Join (",", new Func <IEnumerable <int>, IEnumerable <int>> (
                                    i => i.OrderBy (u => u % 2 == 0)
                                ).Invoke (new [] {3, 2, 2, 2, 1, 2, 5, 5})));
```
Which results in the following:
```
3,1,5,5,2,2,2,2
```
[Answer]
# JavaScript, 23 bytes
6 bytes shorter than [@Neil's answer](https://codegolf.stackexchange.com/a/168782/81748) using the same language :D
```
a=>a.sort(n=>-(n&1)||1)
```
**Explanation:**
The function passed to `sort` only cares about the first parameter. If it is odd it returns `-1` (the result of `-(n&1)`). Otherwise (when `-(n&1)` yields `0`) it returns `1`.
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9Wmpds@z/R1i5Rrzi/qEQjz9ZOVyNPzVCzpsZQ8791cn5ecX5Oql5OfroGSKlGtKGOgomOgq6xjoKpjoIRkAXimYGZEDFzIB@ELXQULHUUDHQUDEHYEEQbxGpq/gcA)
[Answer]
# JavaScript (Chrome v67) - ~~24~~ ~~19~~ 23 bytes
```
a=>a.sort(a=>!(a&1)-.5)
```
The use of `&1` rather than `Math.abs()%2` was stolen from @Neil. Thanks!
Thanks to @Shaggy for showing my hacky 19 byte solution wasn't valid. If anyone wants it:
 ~~Depends on how the browser handles a hacky return value of `0`. Chrome v67, after 100000 iterations of random arrays never sorted it wrong. I'm very sure it works -- and it relies on the specific sort algorithm Chrome uses too, I believe. (It might work in other browsers, that's not the point)~~
`a=>a.sort(a=>++a&1)`
[Answer]
# JavaScript, 21 bytes
```
a=>a.sort(n=>(-1)**n)
```
[Try it online](https://tio.run/##LUxbDoMwDPvnJC1yK0J5fsBFGBIVgwnEWgRo12ctoESx48Se9U/v/TathzD2PZxjdeqq1nK328FMVTNBPAwNP3trdrsMcrEf1gQNIW4RNDHIAyFC5IkDiEtSSKA8EQ5vFsOXuq/38sSIGE/TNW9jCucV6tEj/wwfmyJDjgIlyIkEcjkKlIBSUAbKQQWobINWfvXKRi5nO5nuZTp@/gE)
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~22~~ 19 bytes
```
$args|sort{!($_%2)}
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNyfn/XyWxKL24pji/qKRaUUMlXtVIs/b///@6RlBk8F/XEMw0/m/y3xQA "PowerShell – Try It Online")
Takes input via splatting, e.g., `$a=(3,4,3); .\sort-odd-numbers-first.ps1 @a`, which on TIO manifests as separate arguments for each entry.
Like some other answers here, `Sort-Object` can compare based on an expression. Here the expression is `!($_%2)`, i.e., odds get sorted to `$false` and evens get sorted to `$true`. Thanks to how Boolean values are compared, falsey values are sorted first. This moves the odds to the beginning of the output, and the evens to the end. `Sort-Object` is stable, so the ordering of the individual items in their respective categories doesn't change (as in the TIO example).
*-3 bytes thanks to mazzy.*
[Answer]
# [Ruby](https://www.ruby-lang.org/), 23 bytes
```
->a{a.sort_by{|i|~i%2}}
```
[Try it online!](https://tio.run/##LcjLCkBAFADQva@4jSzdsKP4EaQr1JRX81hM4/r1QVmdOsqOLix1SBvyhPpQZhidv@R1y6RgDgQ15Bkauc0aNzrBK9onSEvEkqPTGg1C7q8VQGdiTyz@VbO269vfLi31LMID "Ruby – Try It Online")
Explanation:
`sort_by` sorts every number as if its value were the result of the block (`~i%2`)
`~x` is equivalent to `-x-1` and takes precedence over `%2`
Odd numbers will evaluate to `0` and even numbers will evaluate to `1` so odd numbers will be sorted first.
### Barely related: this works on ruby from homebrew 2.5.1p57 (because it's based on a small bug) but only for non-negative integers, 20 bytes
```
->a{a.sort{|i|i%-2}}
```
Explanation:
This uses `sort` which expects a block that takes 2 values and returns `-1`, `0` or `1` depending on whether the first one is bigger, they're equal or the second one is bigger.
The block given here ignores the second value and returns `-1` if the first number is odd or `0` if it's even.
It's not guaranteed to work but it does in some (I think buggy) implementations.
[Answer]
# [6502 machine code](https://en.wikibooks.org/wiki/6502_Assembly) routine, 47 bytes
```
A0 00 84 FE B1 FB 4A 90 07 C8 C4 FD F0 20 D0 F4 2A 85 02 84 FE A4 FD 88 C4 FE
F0 12 B1 FB 4A 90 F6 2A AA A5 02 91 FB A4 FE 8A 91 FB 90 D6 60
```
Expects a pointer to an array of numbers in `$fb`/`$fc` and the length of this array in `$fd`. Manipulates the array in place to have all odd numbers in front. This is position independent code, so no load address is needed.
As the 6502 is an 8bit chip (so the instructions only deal with 8bit values, optionally signed), the valid number range is `[-128 .. 127]` and the maximum array size is `256`.
### Commented disassembly
```
; function to "partially sort" array, so all odd numbers come before all
; even numbers.
;
; input:
;   $fb/$fc: address of array to sort
;   $fd:     length of array to sort, 0 means 256 (maximum size)
;
; clobbers:
;   $fd/$fe: position from back/front of array
;   $2:      temporary for exchanging two values
;   A, X, Y
 .oddfirst:
A0 00       LDY #$00            ; initialize index from front
84 FE       STY $FE             ; to 0
 .search_front:
B1 FB       LDA ($FB),Y         ; load number from front
4A          LSR A               ; check for even/odd by shifting
90 07       BCC .search_back    ; if odd -> to searching from back
C8          INY                 ; next position from front
C4 FD       CPY $FD             ; same as position searching from back?
F0 20       BEQ .done           ; then we're finished
D0 F4       BNE .search_front   ; else check next from front
 .search_back:
2A          ROL A               ; shift carry back in
85 02       STA $02             ; and save number to temp
84 FE       STY $FE             ; save index from front
A4 FD       LDY $FD             ; load index from back
 .sb_loop:
88          DEY                 ; previous position from back
C4 FE       CPY $FE             ; same as position searching from front?
F0 12       BEQ .done           ; then we're finished
B1 FB       LDA ($FB),Y         ; load number from back
4A          LSR A               ; check for even/odd by shifting
90 F6       BCC .sb_loop        ; if odd -> check previous position
2A          ROL A               ; shift carry back in
AA          TAX                 ; remember in X
A5 02       LDA $02             ; load temporary from front
91 FB       STA ($FB),Y         ; store at current position
A4 FE       LDY $FE             ; load index from front
8A          TXA                 ; load remembered number
91 FB       STA ($FB),Y         ; store at current position
90 D6       BCC .search_front   ; and back to searching from front
 .done:
60          RTS
```
---
### Example C64 assembler program using the routine:
**[Online demo](https://vice.janicek.co/c64/#%7B%22controlPort2%22:%22joystick%22,%22primaryControlPort%22:2,%22keys%22:%7B%22SPACE%22:%22%22,%22RETURN%22:%22%22,%22F1%22:%22%22,%22F3%22:%22%22,%22F5%22:%22%22,%22F7%22:%22%22%7D,%22files%22:%7B%22oddfirst.prg%22:%22data:;base64,AQgLCOIHnjIwNjEAAACpF40Y0KkAhSqFUqnnoAkgHqup5KAJIB6rqU+gCqIFIHsIrU8K8B+pT6AKIAgJkAmpLaAKIB6rsNmi/4ZSpiqdVwrmKtDMpVLwI6lXhfupCoX8pSqF/SC1CakAhVKkUrlXCiDuCOZSpVLFKtDwYMqG+4X8hP2gAITMhP4gQvHw+4UCKX/JILAOyQ3wEMkU0Oul/vDn0Aal/sX78N94pNOx0Sl/kdGlAiAW56bP8Aqk07HRCYCR0aUCWMkU8CDJDfAJpP6R/MiE/tCxqQCk/pH8eKTTsdEpf5HR5sxYYMb+sJoQDUn/hQLmAqktIBbnpQKqqQAgzb2pIEwW54X7hPygAIT9hP6MVAqMVQqMVgqx+/AjyMkg8PfJLfAMyTCQFMk6sBDm/ZDnpf3QCKX+0ATm/tDbOGCIMPuiArH7yTCQC8k6sAc46TCdVArKiBDsqQCF+6IITlQKrVUKkAIJEEqNVQqtVgqQAgkQSo1WCmb7yvAmrVQKyQgwBekDjVQKrVUKyQgwBekDjVUKrVYKyQgww+kDjVYKsLyl/vAIqf9F+4X75vul+xhgoACE/rH7SpAHyMT98CDQ9CqFAoT+pP2IxP7wErH7SpD2KqqlApH7pP6KkfuQ1mA+IAANDcVOVEVSIE9ORSBOVU1CRVIgUEVSIExJTkUuDUpVU1QgUFJFU1MgRU5URVIgKEVNUFRZIExJTkUpIFdIRU4gRE9ORS4AxVJST1IgUEFSU0lORyBOVU1CRVIsIFRSWSBBR0FJTi4NAA==%22%7D,%22vice%22:%7B%22-autostart%22:%22oddfirst.prg%22%7D%7D)**
[![screenshot](https://i.stack.imgur.com/wDVrX.png)](https://i.stack.imgur.com/wDVrX.png)
**Code in [ca65](http://cc65.github.io/doc/ca65.html) syntax:**
```
.import oddfirst ; link with routine above
.segment "BHDR" ; BASIC header
                .word   $0801           ; load address
                .word   $080b           ; pointer next BASIC line
                .word   2018            ; line number
                .byte   $9e             ; BASIC token "SYS"
                .byte   "2061",$0,$0,$0 ; 2061 ($080d) and terminating 0 bytes
.bss
linebuf:        .res    5               ; maximum length of a valid signed
                                        ; 8-bit number input
convbuf:        .res    3               ; 3 BCD digits for signed 8-bit
                                        ; number conversion
numbers:        .res    $100            ; maximum array size that can be
                                        ; directly handled with indexing
                                        ; instructions
.data
prompt:         .byte   "> ", $0
message:        .byte   $d, $d, "Enter one number per line.", $d
                .byte   "just press enter (empty line) when done.", $0
errmsg:         .byte   "Error parsing number, try again.", $d, $0
.code
                lda     #$17            ; set upper/lower mode
                sta     $d018
                lda     #0
                sta     $2a             ; index for number array
                sta     $52             ; flag that at least one number was
                                        ; entered
                lda     #<message       ; display message
                ldy     #>message
                jsr     $ab1e
inputloop:
                lda     #<prompt        ; display prompt
                ldy     #>prompt
                jsr     $ab1e
                lda     #<linebuf       ; read string into buffer
                ldy     #>linebuf
                ldx     #5
                jsr     readline
                lda     linebuf         ; empty line?
                beq     process         ; -> start processing
                lda     #<linebuf       ; convert input to int8
                ldy     #>linebuf
                jsr     toint8
                bcc     numok           ; successful -> store number
                lda     #<errmsg        ; else show error message and repeat
                ldy     #>errmsg
                jsr     $ab1e
                bcs     inputloop
numok:          ldx     #$ff            ; set flag that we have a number
                stx     $52
                ldx     $2a
                sta     numbers,x
                inc     $2a             ; next index
                bne     inputloop       ; if array not full, next input
process:        lda     $52             ; check we have some numbers
                beq     exit            ; otherwise exit program
                lda     #<numbers       ; address of array to $fb/fc
                sta     $fb
                lda     #>numbers
                sta     $fc
                lda     $2a             ; length of array to $fd
                sta     $fd
                jsr     oddfirst        ; call "sorting" function
                lda     #$0             ; index variable for output loop
                sta     $52
outloop:        ldy     $52             ; load current index
                lda     numbers,y       ; load current number
                jsr     printnum        ; -> output
                inc     $52             ; next index
                lda     $52             ; compare with ...
                cmp     $2a             ; ... array size
                bne     outloop         ; not reached yet -> repeat
exit:           rts                     ; done, exit program
; read a line of input from keyboard, terminate it with 0
; expects pointer to input buffer in A/Y, buffer length in X
.proc readline
                dex
                stx     $fb
                sta     $fc
                sty     $fd
                ldy     #$0
                sty     $cc             ; enable cursor blinking
                sty     $fe             ; temporary for loop variable
getkey:         jsr     $f142           ; get character from keyboard
                beq     getkey
                sta     $2              ; save to temporary
                and     #$7f
                cmp     #$20            ; check for control character
                bcs     checkout        ; no -> check buffer size
                cmp     #$d             ; was it enter/return?
                beq     prepout         ; -> normal flow
                cmp     #$14            ; was it backspace/delete?
                bne     getkey          ; if not, get next char
                lda     $fe             ; check current index
                beq     getkey          ; zero -> backspace not possible
                bne     prepout         ; skip checking buffer size for bs
checkout:       lda     $fe             ; buffer index
                cmp     $fb             ; check against buffer size
                beq     getkey          ; if it would overflow, loop again
prepout:        sei                     ; no interrupts
                ldy     $d3             ; get current screen column
                lda     ($d1),y         ; and clear
                and     #$7f            ;   cursor in
                sta     ($d1),y         ;   current row
output:         lda     $2              ; load character
                jsr     $e716           ;   and output
                ldx     $cf             ; check cursor phase
                beq     store           ; invisible -> to store
                ldy     $d3             ; get current screen column
                lda     ($d1),y         ; and show
                ora     #$80            ;   cursor in
                sta     ($d1),y         ;   current row
                lda     $2              ; load character
store:          cli                     ; enable interrupts
                cmp     #$14            ; was it backspace/delete?
                beq     backspace       ; to backspace handling code
                cmp     #$d             ; was it enter/return?
                beq     done            ; then we're done.
                ldy     $fe             ; load buffer index
                sta     ($fc),y         ; store character in buffer
                iny                     ; advance buffer index
                sty     $fe
                bne     getkey          ; not zero -> ok
done:           lda     #$0             ; terminate string in buffer with zero
                ldy     $fe             ; get buffer index
                sta     ($fc),y         ; store terminator in buffer
                sei                     ; no interrupts
                ldy     $d3             ; get current screen column
                lda     ($d1),y         ; and clear
                and     #$7f            ;   cursor in
                sta     ($d1),y         ;   current row
                inc     $cc             ; disable cursor blinking
                cli                     ; enable interrupts
                rts                     ; return
backspace:      dec     $fe             ; decrement buffer index
                bcs     getkey          ; and get next key
.endproc
; print an int8 number to the screen
; input:
;   A - the number to print
; clobbers:
;   X, Y
.proc printnum
                bpl     doprint         ; positive? -> direct number output
                eor     #$ff            ; else invert,
                sta     $2              ; ...
                inc     $2              ; add one,
                lda     #'-'            ; output a minus sign
                jsr     $e716
                lda     $2
doprint:        tax                     ; number to X reg
                lda     #$0             ; set A to 0
                jsr     $bdcd           ; routine for uint16 in X/A output
                lda     #' '
                jmp     $e716           ; and print a space
.endproc
; parse / convert int8 number using a BCD representation and double-dabble,
; handle negative numbers.
.proc toint8
                sta     $fb
                sty     $fc
                ldy     #$0
                sty     $fd
                sty     $fe
                sty     convbuf
                sty     convbuf+1
                sty     convbuf+2
scanloop:       lda     ($fb),y
                beq     copy
                iny
                cmp     #$20
                beq     scanloop
                cmp     #$2d
                beq     minus
                cmp     #$30
                bcc     error
                cmp     #$3a
                bcs     error
                inc     $fd
                bcc     scanloop
minus:          lda     $fd
                bne     error
                lda     $fe
                bne     error
                inc     $fe
                bne     scanloop
error:          sec
                rts
copy:           dey
                bmi     error
                ldx     #$2
copyloop:       lda     ($fb),y
                cmp     #$30
                bcc     copynext
                cmp     #$3a
                bcs     copynext
                sec
                sbc     #$30
                sta     convbuf,x
                dex
copynext:       dey
                bpl     copyloop
                lda     #$0
                sta     $fb
                ldx     #$8
loop:           lsr     convbuf
                lda     convbuf+1
                bcc     skipbit1
                ora     #$10
skipbit1:       lsr     a
                sta     convbuf+1
                lda     convbuf+2
                bcc     skipbit2
                ora     #$10
skipbit2:       lsr     a
                sta     convbuf+2
                ror     $fb
                dex
                beq     done
                lda     convbuf
                cmp     #$8
                bmi     nosub1
                sbc     #$3
                sta     convbuf
nosub1:         lda     convbuf+1
                cmp     #$8
                bmi     nosub2
                sbc     #$3
                sta     convbuf+1
nosub2:         lda     convbuf+2
                cmp     #$8
                bmi     loop
                sbc     #$3
                sta     convbuf+2
                bcs     loop
done:           lda     $fe
                beq     positive
                lda     #$ff
                eor     $fb
                sta     $fb
                inc     $fb
positive:       lda     $fb
                clc
                rts
.endproc
```
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 9 bytes
-7 thanks to @rak1507.
```
{⍵[⍒2|⍵]}
```
Explanation:
```
{⍵[⍒2|⍵]}
    2|⍵      ⍝ ⍵ mod 2, return 1 for each odd element and 0 for each even element
   ⍒         ⍝ pick the indices that produce the array sorted in descending order
  [    ]     ⍝ pick elements corresponding to indices in provided order...
 ⍵           ⍝ from ⍵
```
For example:
```
2|6 7 8 9        => 0 1 0 1
⍒0 1 0 1         => 2 4 1 3
6 7 8 9[2 4 1 3] => 7 9 6 8
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/P@1R24TqR71box/1TjKqATJia/8/6psKFE1TMFQwUjBWMOGC8Q@tNwHyjf8DAA "APL (Dyalog Extended) – Try It Online")
]


[Question]
      [
## Defintion
A [centrosymmetric matrix](https://en.wikipedia.org/wiki/Centrosymmetric_matrix) is a square [matrix](https://en.wikipedia.org/wiki/Matrix_(mathematics)) that is symmetric about its center. More rigorously, a matrix \$A\$ of size \$n \times n\$ is centrosymmetric if, for any \$i,\: j \in ([1, n] \cap \mathbb{Z})\$ the following relation is satisfied:
$$A\_{i,\:j}=A\_{n+1-i,\:n+1-j}$$
## Examples of such matrices
Here is an illustration of the symmetry of a matrices like these (borrowed from the aforementioned Wikipedia article):
[![Centrosymmetric 5 by 5 matrix illustrated in a really nice way](https://i.stack.imgur.com/a3ZBh.png)](https://i.stack.imgur.com/a3ZBh.png)
An even-side-length (\$4\times 4\$) centrosymmetric matrix:
$$\left(\begin{matrix}
1 & 2 & 3 & 4 \\
5 & 6 & 7 & 8 \\
8 & 7 & 6 & 5 \\
4 & 3 & 2 & 1\end{matrix}\right)$$
And an odd-side-length (\$3\times 3\$) one:
$$\left(\begin{matrix}
1 & 2 & 3 \\
5 & 6 & 5 \\
3 & 2 & 1\end{matrix}\right)$$
## Task and Specs
Given a square matrix of size at least \$2\$, output one of two distinct and consistent values, deciding whether the matrix is centrosymmetric or not. You can assume that the matrix will consist entirely of positive integers.
**However, your code must also be centrosymmetric.** That is, it must be a program / function (or equivalents) consisting of \$n\$ lines, each of which containing \$n\$ **bytes** in your language's encoding, and must satisfy the definition given above, but with bytes instead of positive integers. Your submission's score will be the value of \$n\$, with a lower \$n\$ being better.
You can take input and provide output through any [standard method](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods) and in any reasonable format, while taking note that [these loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden by default. You may (optionally) choose to take the size, \$n\$, as input too (unless you take input as a 1D list, in which case you may only take \$n^2\$ as additional input).
## Test cases
Truthy:
```
[[1, 2], [2, 1]]
[[1, 2, 3], [5, 6, 5], [3, 2, 1]]
[[10, 5, 30], [2, 6, 2], [30, 5, 10]]
[[100, 100, 100], [100, 50, 100], [100, 100, 100]]
[[1, 2, 3, 4], [5, 6, 7, 8], [8, 7, 6, 5], [4, 3, 2, 1]]
[[3, 4, 5, 6, 7], [5, 6, 7, 8, 9], [3, 2, 10, 2, 3], [9, 8, 7, 6, 5], [7, 6, 5, 4, 3]]
```
Falsy:
```
[[1, 2], [1, 2]]
[[1, 2, 10], [5, 6, 5], [11, 2, 1]]
[[14, 5, 32], [2, 6, 2], [30, 5, 16]]
[[19, 19, 19], [40, 50, 4], [19, 19, 19]]
[[1, 2, 20, 4], [7, 6, 7, 8], [8, 7, 6, 6], [3, 3, 2, 1]]
[[3, 4, 5, 6, 7], [5, 6, 7, 8, 9], [4, 5, 10, 4, 5], [5, 6, 7, 8, 9], [3, 4, 5, 6, 7]]
```

[Answer]
# JavaScript (ES6), size ~~12~~ ~~11~~ 9
All versions return **false** for centrosymmetric or **true** for non-centrosymmetric.
---
## 1-dimensional array + length, size 9 (89 bytes)
Takes input in currying syntax `(length)(array)`, where *array* is 1-dimensional.
```
w=>a=> //
a.some //
(v=>v- //
a[--w])//
/////////
//)]w--[a
// -v>=v(
// emos.a
// >=a>=w
```
[Try it online!](https://tio.run/##rZNba4MwFMff/RSHvmhotN7bDhRG3/cFOh8ks1tHNUWdsk/vcky8rPTCYILxf@4m/vxMm7Ri5fFcmwV/y7pD1LVRnEYxrFZaalU8z1AZTRQ3Zu/bm2abEKFWwyUUSVrT3KdCgdnEUWOgynJeWb0vjtI4ajvGi4qfMuvE3w19lxV1yavvPM/q8siedKLN4wfDJ8ZeA3AouFQ8XQqOlpDLrO0sCzxMDCiEVKxCevRRmY2Z4NmYjbmiUo7zZMSx7xXbdFoGBwQXjmG50sgJf789@NMG1hQ2aG16OezIp3c25QayXd9o6jO2lD1hOzsaezq3bR@cD5MSi3HslYEbRwy0LEvkLkZsFrBEe4RH2SNCQ3wASdkjTqOtoBpthdZkS8AmW2K20BIrT88Gi2JmsY@03Amwn2uDEAJL0MGo@FfJMmDCTQR1v/akvxYvvDDZH@HE521Q1Pd1JGXBcKpY5zwk1JeEujcJDe8Ui2@qbmQHC5DQnrIp9hBM11ZkrmcYjWiiK1RIeRT@A05f/XtUqlsAz/rgwO4H "JavaScript (Node.js) – Try It Online")
---
## Matrix + width, size 11 (131 bytes)
Takes input in currying syntax `(width)(matrix)`.
```
/**/w=>a=>a
.some(r=>r.
some(v=>v-a
[y][w-++x],
x=!y--),y=w
);'*/'/*';)
w=y,)--y!=x
,]x++-w[]y[
a-v>=v(emos
.r>=r(emos.
a>=a>=w/**/
```
[Try it online!](https://tio.run/##pZPZUoMwFIbv8xSxN5CSpCxdXCbMON77AsgFE6nWEeKECuXpaxZqY5U6jkyAkz9nyfLlpWiLhsvN25bU4rHcr9l@Np3OOpYWqgHaiKr0JUslBcZsWdqSAmR9nnUkCHY5Bjt20ROCcM86gG686cybTb0bBDrWY0RIf8F2AOe7ICBdlvcZKEibstYvK9EAKlMmjUlBkTLVOl1@z0XdiNeSvoon37sr660UTV9V5VZu@LWHgDu@9mPkZ1mEYZxjmMUYRnmOTn2Sgw@GiXZbYLjEcKHNxKjjQaHyU1HhkH05FEqsHoXjgaEeth8dYezFSf/T4XuWuTNnDOfHaa8wvNS9S2Me1jE3biNLWehcOouZtM7xNR2GV85ehMeNujKDTpnBNKmSHypFkSoFIJw4IE2wFhyarOAgZQWHKys4cFnBIcwKDmZWcFizggPcMI8jdYPHEb0JyGlVvPkNSzNKaWN7nKWc8udC3qlLcrv1kXpgAD3oN@Jd8hJypSMF5pe98B7qe1ET/id@zf8sv1F4AnAU/UKwPfQkHiF4ORqoDt@@hq@BXgOiM3QW3PgQsPqZ3OVA3b/JnQ@30TqOwe0kUZX2Hw "JavaScript (Node.js) – Try It Online")
### Payload
```
w => a => a.some(r => r.some(v => v - a[y][w - ++x], x = !y--), y = w)
```
### Container
```
/**/CODE;'*/'/*';EDOC/**/
```
---
## Matrix only, size 12 (155 bytes)
This is my original solution, which computes the width of the matrix by itself.
```
/**/a=>a[w=a
.length-1,s=
'some']((r,y
)=>r[s]((v,x
)=>v-a[w-y][
w-x]))////*/
/*////))]x-w
[]y-w[a-v>=)
x,v((]s[r>=)
y,r((]'emos'
=s,1-htgnel.
a=w[a>=a/**/
```
[Try it online!](https://tio.run/##pZPdbtsgGIbPuQqUE@wMHDtO0nYSlqae7wYYB4jRpFNsKvCc@OozftyURXE1aUjYfC/fH@jhlxiEleb1rSed/qkuL/SyWi5XgjaCnagAxVF1@/5AKmwpQFa3CvEsM3gEOW0Ms84Y8NkbA3ERZOQMnMiZ5/nKjeUKuOlGnvMzOQHGR3JiggwNzcEZD1nGLTPeGLFxBlKttghQiyty6PedOhZAUBfRUOHbukjdWX1UxVHvM/Ssut5oO7at6s2r/IpykO6/ZIxVGK45hmyNYcVdU3cdMKy9zxbDHYZbv6yDOhNROicXUk55d1OJOupVORNV@r348e5hvb2xrw6ftIrh5qPbBwwfvfUYlu/tb4Lb7Al8itCrT/B3LgyfkvOXH5fzFDaTGtMypKpDmds6AMJFytICeyUFKiopVVFJ0boqV76ikkIWlZS0qKS4RSVlLiopeFFJ6YtKiuAC8KIVb5mlDSuKwkZL0kYW8iDMs3tE3/osdwN@gQhmVv82UkHp9BzdXBL60X3XHZH/znH4z8NRlTcgV9VnJEcK6vUMybv7UQ6FOANqE8WByWRrvsf1u/fDfYJ3E4D/R/BmeozRcQ7yJIkrc/kD "JavaScript (Node.js) – Try It Online")
### How?
We need a few critical tokens that cannot be split:
* `some`
* `length`
* `)=>`
Line-feeds may be inserted almost anywhere else.
The unrolled payload code reads as:
```
a => a[w = a.length - 1, s = 'some']((r, y) => r[s]((v, x) => v - a[w - y][w - x]))
```
and is wrapped inside the following structure:
```
/**/CODE////*/
```
which, once reversed, becomes a valid block comment:
```
/*////EDOC/**/
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), score 2
```
⁼Ṛ
Ṛ⁼
```
[Try it online!](https://tio.run/##y0rNyan8//9R456HO2dxATGQ9f///2hjHQUTHQVTHQUzHQVzJIaFjoKljgJQ1khHwdAATBmDhSzA0mZgpXAG0AjjWAA "Jelly – Try It Online")
Takes input as a flattened square matrix (vector of size \$n^2\$).
[Answer]
# [Befunge-93](https://github.com/catseye/Befunge-93), size 24
```
   &:00p110p920p::*:v
vp01:+1g01-1pg02g01&_v#<
>00g`#v_>:           1$^
v2p011<  v:g00p029p01< @
>0g1+20p^>*:#v_1# .#<@ .
v+1g00gg02g01<$ >1+10pv0
>:10g-\88++20g -g-     |
vg02p011_v#`g00g01-1  <1
>1+20p   >:   ^ ^      <

<      ^ ^   :>   p02+1>
1<  1-10g00g`#v_110p20gv
|     -g- g02++88\-g01:>
0vp01+1> $<10g20gg00g1+v
. @<#. #1_v#:*>^p02+1g0>
@ <10p920p00g:v  <110p2v
^$1           :>_v#`g00>
<#v_&10g20gp1-10g1+:10pv
   v:*::p029p011p00:&
```
[Try it online!](https://tio.run/##xVLLboQwDLz7KyyBOBCBbPZRsKKID1mxq0rb3CouzWn/nU4CUnvpuUYyxPHY4zHvz4@vz/jcNmZuTGRVlXUaZDVrLSFIaRU1p1G00zXKgI/mnipPQSQ@qnQPxj@m9UJpAEQ9c7KIijJMOHuegYjqUHsJrQGoFfeVn7mnlOtL3Kv7moM60EhCwVRidxtHB1zkLnaly4sScnMXMHlkaGbH7JVC6YCcQmvBU8wT/2H/e@H3987TAhz0choo64eZJB4q571AgkSvAshKQALnxvHWYXoLJHlTgHLtARuynFnvRD3Pvuq5ymJZG5bSIUqgGYLt20Zm3rYvXRIttf4iaeFQOZAHk2avvhZ26ixvKg@Y8MfYsW1FRWsQ3LYLn/jMF77y2@FHnhAbWAXuhMOI4BWXuz/z6Rs "Befunge-93 – Try It Online")
**Input:** `n`, followed by the elements of the array, all separated by spaces. NOTE: you may need to use a different interpreter if you have a large enough input.
I'm sure there's a better way to do this, I just wanted to try this in Befunge. The actual code portion is the top half.
## How?
The code is divided into two main sections, the **initialization** and the **verification**.
**Initialization:**
```
   &:00p110p920p::*:v
vp01:+1g01-1pg02g01&_v#<
>00g`#v_>:           1$^
```
This section of the code writes the input matrix right below the code as ASCII characters. Both this and the next section use the three cells at the top left of the code as data. They are stored as `n, i, j`.
**Verification:**
```
                     v
                     1
v2p011<  v:g00p029p01< @
>0g1+20p^>*:#v_1# .#<@ .
v+1g00gg02g01<$ >1+10pv0
>:10g-\88++20g -g-     |
vg02p011_v#`g00g01-1  <1
>1+20p   >:   ^ ^      <
```
This sections checks every index \$i, j\$ [1-indexed] against the condition \$ A\_{i, j} = A\_{n+1-i, n+1-j} \$. However, we have a problem: we have \$j\$ offset by \$8\$. To fix that, the following formulae are used:
\$ i' = (n + 1) - i \$
\$ j' = n + 1 - (j - 8) + 8 = (n + 1) + (8 + 8) - j\$
The other portions of code are unread garbage to make it centrosymmetric.
[Answer]
# [Haskell](https://www.haskell.org/), \$n = 8\$
*No comments!*
Takes input as a 1-D list
```
s a b=
    a/=b
f =s<*>
 reverse
esrever
 >*<s= f
b=/a
  =b a s
```
[Try it online!](https://tio.run/##JYzBCsIwEETv@Yo9eGhLsKR6zObUq18gHjaYYLBtSjb4@3GrMww8BmZexO@wLC2tey4VZqp0vuUtpyd0nXV93xgIPAIoENGIXkVAtoOTpoRPKBxU4B9J4wbLCFF5HOkYHDP0csFtpbThXtJWTxHuRk/6oo3kKv7TpM2jfQE "Haskell – Try It Online")
# \$n= 10\$
Takes input as a 2-D matrix
```
r =reverse
s a b=a/=b
f   =s<*>r
c  =concat
g =  f<$>c
c>$<f  = g
tacnoc=  c
r>*<s=   f
b=/a=b a s
esrever= r
```
[Try it online!](https://tio.run/##HY2xDoMwEEP3@4obGABFRUDHXKau/QLEcKSBokKCkqi/n54qL0@2Zb85fdxxlP28Qsz44My3Z/Bhf2Fda9M0JSJF93UxOUjIuBB3tMCKiJR0ayJYIRu85QwbEuKqK2PBmkpLiXCDzNYHK4mFaFqdhHCFhTqmRRYTuPR/IIzl5N3TFXefqw2nqVeDGlU/q2lUd9Eo1IsziDeXHw "Haskell – Try It Online")
Thanks to [potato44](https://codegolf.stackexchange.com/users/69655/potato44) for all their help in chat. And [Lynn](https://codegolf.stackexchange.com/users/3852/lynn) for golfing off a row.
## Explanation
The general idea here is a simple one, we `concat` the list and compare it to it's reverse. However since we want to be centrosymmetric we have to tread carefully. First we write the code as we would normally:
```
g=((==)<*>reverse).concat
```
Now in order for our reverse lines to also be valid Haskell we need the left hand side of our equations to look like a function definition `tacnoc.)esrever>*<)==((` doesn't.
The first step to fixing this is disposing of parentheses.
```
s a b=a==b
f=s<*>reverse
g=f.concat
```
However we have some new problems now. Both `.` and `==` when reversed are the same, so our reversed lines attempt to redefine the operators (`<*>` reversed is `>*<` so we are fine on that front). `.` can be replaced with `<$>` since functions are functors. And we can replace `==` with `/=`, which negates our output, but that is still within the specs. Now we have
```
s a b=a/=b
f=s<*>reverse
g=f<$>concat
```
In order to trim down our line length we alias `concat` and `reverse`.
```
r=reverse
s a b=a/=b
f=s<*>r
c=concat
g=f<$>c
```
Now we just finish this by making everything centrosymmetric and square.
The shorter 1-D version works in much the same way except since there is no need to `concat` we can save two lines by removing it.
[Answer]
# [Python 2](https://docs.python.org/2/), size 10 (109 bytes)
```
def f(a):#
 return(a#
==[r[::-1#
]for r in#
a[::-1]])#
#)]]1-::[a
#ni r rof]
#1-::[r[==
#a(nruter
#:)a(f fed
```
[Try it online!](https://tio.run/##vVO7boMwFJ3rr7jCAyA5FYaEJJboUqlf0M31YCmgIEUmcsiQryd@0ThRU6lLB@D6nHNfx@J4GfeDKqdp13bQZTJnGIFux7NWmcSoabjmjC0oRqIbNGjoFUbSQULkGOFcCLpgjEuEVW94PXQCYQdp3jQIy0zp89hqQJjlMjNd2t101L0aIfk0zP6SIFtamtLAOacESkGAlwRMCxM4hEBl4xWBmsDKhpVDZ0lhUKMpQmYdilQep8UsK@zBvyzi4tXD@VsQdyewvA2wJrCxp40L54mWTnYbyua49jbjPpnANtqhuC24dWRUNISuVCWEYOjFmydJ2rylxN4ZQg4KH0g@5OHUPrHVfaPFaPHgK6V3xvoNqvKJsXWQmbn944wIpjrHIipqW870@mdD62DPHw1dhuv2wmeeR0V@N9QT6fuwa9OZTZLkX/8V0@/1dDz0Y5Z@qTTPpys "Python 2 – Try It Online")
### Previous [Python 2](https://docs.python.org/2/), size 14 (209 bytes)
```
lambda a:all(#
a[i][j]==a[-i#
-1][-j-1]for #
i in range(  #
len(a))for j #
in range(len(#
a)))         #
#         )))a
#(nel(egnar ni
# j rof))a(nel
#  (egnar ni i
# rof]1-j-[]1-
#i-[a==]j[]i[a
#(lla:a adbmal
```
[Try it online!](https://tio.run/##3VPLboMwEDzXX7GCAyCZikdCHhK9VOoX9Ob44CiQGDkmIvSQr6deAwmJmkq9Fgmznpld747F6dIeap10Zb7plDhudwLEWijlu0QwyVnF81ywULokjDkLK7OWdQMukSA1NELvCx/MVhXaF0GAXIXsyCFuSgVBAOPjEvcaG1wQ19eF8ou9Fg1oadgKmro0DOIovnKArOF4bDphZiWuDJnIc14xLhmWUsr0D2K3PQrVnRqpW3A@m6/2cHEIdiewb8ZYTCHhFFhCIeYYWIRCivGcQkZhjmFq0VESGdRooiEzG4qkPR5HoyzCTb8gYuP5w/4qmJ5OYXZrYEFhibulDceOZlZ2awpz7PGYcZ9MYTWZIboNuLLkpOgQ2lIp53xNXnrzBPXyN4@W5nYJsdDwAedDqHPxxFb7nQwWRw@@xvGdsf0EafLE2GyQmb771xoxmGodm1CTY5ORXvxsaDbY80dDZ8N198Jnnk@K/G5oT3jv9a7wRtZxnH/3P5qZXs8nJVvf22gvCLpv "Python 2 – Try It Online")
[Answer]
# Pyth, size 6 (41 bytes)
```
q_M_QQ
q.q
   q.q
QQ_M_q
```
[Try it here](http://pyth.herokuapp.com/?code=q_M_QQ%0Aq.q%20%20%20%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%0A%20%20%20q.q%0AQQ_M_q&input=%5B%5B1%2C%202%2C%203%2C%204%5D%2C%20%5B5%2C%206%2C%207%2C%208%5D%2C%20%5B8%2C%207%2C%206%2C%205%5D%2C%20%5B4%2C%203%2C%202%2C%201%5D%5D&debug=0)
### Explanation
The first line reverses the input and each row, and checks if we're left with a copy of the input.
The `.q` in the second line exits the program, so everything after that, as well as the `q` before it, is a no-op.
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), score ~~7~~ ~~6~~ ~~5~~ 4
Full program. Prompts for matrix expression from stdin. Prints a 1 or a 0 and then throws a consistent error. No comments!
```
r←,⎕
r≡⌽r
r⌽≡r
⎕,←r
```
[Try it online!](https://tio.run/##pVJLTsMwEN3nFLMzSEZykjZt2SEQCyQ@gu6qLqzUbSKFJrKDql6ggFQQLFiy4CC9TC4SxnZKQ0XTBZESj2fmvfm88Cw5Gs15kk7K4vWjf3tyUyzeGJBTAqRYvKPv7JJA8fIJIc/DCHiSgJAylQr4dASjWGUJn@PJJ9NU5XEI90IpPhFwkOaRkLNYCZgJgrCIJznwcS4kYATGsVS55Tp0iqfHrJRYmmJFRxbPX8VyJdFYrtCWDnopRmWJiSXpy4c8mh8TB8yTObbTi7vrKzIYuBS8IYWBR8EdDhuSKPg6r00hoNDWpm@8DSiGiQhjFX9QlfKt32UNSKbj9qMhxm5v3X8S9rRNobXpvEOhq29dY65HaZm0xmk0jelbk/zmo9Cr7YNtltUzwVqdyjRUvi5Fznmi9opjzuYpXbaljuvuk8eO43s75Al2I3Eu@5rdVdKYJddCzf16a0Tnb1mCaqP/l6VV/W02cZdyNRIs9Q0 "APL (Dyalog Unicode) – Try It Online")
`⎕` prompt for expression and evaluate it
`,` ravel (flatten) it
`r←` store the result in `r` (for **r**avelled)
`⌽r` mirror `r`
`r≡` implicitly print whether `r` is identical to that
`≡` depth of `r` (gives 1)
`r⌽` use `r` to rotate that
(this will always cause a `RANK ERROR` and quit because a matrix is not permitted as left argument to `⌽`)
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), size ~~9 8~~ 7
```
{.flat#
#}talf.
#  ],R[
eq # qe
[R,]  #
.flat}#
#talf.{
```
[Try it online!](https://tio.run/##nZLLbsIwEEX3/oorIkFSWVbeQFDZVOoHoO4oi0jYLVKAkKSLCPHt1HacYqAs2kXi8cyd10lKXhXpedtiKPCM85GJIm8c4pyavBCMOMCKLpaEH@DgwMlyQVeAQ7TsJHVadjzXeYvRW/XVfLbZaEbEvoLrBhShR@GGFIHnUdJ5KCLlTChSikSZkfb2El96pcY3makpEnX@wO9lvrp0LxXXdnJz/xHY3SniywBjiom6TbTZTxRr2WUolaPbq4zrZIqptYN/WXCqg1ZRY@pSkefhSAA2FEyyIydCFMLB@@41L2reZoNbiPq01gj8G4pBcIWxmzcKH2BMjUxO2T16bYNQ87FCVtuwD49/x5caGH/EF5uP2wkfEbaK3OErq82uUQBf9muOTVPzQmSQGIlwi82O1/M521frmm3z0n1iPP/gldcfssbsv//@Nw "Perl 6 – Try It Online")
~~`reverse` is the bottleneck here. I've changed it to the technically longer, but much more splittable `[*-1 X-^*]`.~~ Okay, I've changed it to `[R,]` after seeing [Brad Gilbert's answer](https://codegolf.stackexchange.com/a/169008/76162) to another question.
The flattened code is `{.flat eq [R,] .flat}`.
Edit: Damn, I've realised I don't even *need* to flatten the first list, but attempts at shortening it to a size 6 have failed with just *one* byte too many to fit...
```
{@_#}_@
eq#<<|
[R,] #
# ],R[
|<<#qe
@_}#_@{
```
:(
Though if we take it as a one dimensional array, it's easy to fit it in a size 6.
```
{$_# }
eq #_$
[R,] #
# ],R[
$_# qe
} #_${
```
[Try it online!](https://tio.run/##lZPZaoNAFIbv5ylOojRaBnGJJlGSm0IfIPQuDUHI2ApGzWgLEnx26yzWSWhKe6Ge5T/LfIMloVnQnRp4SGAN3UU/aNAicgbtoKPdFu9BQxrs8XaHWOpMUMtSl66KG5i90I/6vQlnEUoKCobhYHBNDIaLwTFNjEQEg8eCPoYAg89Mj0cHid1He40tKwPZxBNxxx5kNnPEi@W57d/43wJ1Oob5uMACw5J5S24OG825bFyK1fDxrOK6GMNKOYM9HnDFk0pTafJWnmnCBQEkhpVkcW2R@I1Q0@oxohYhRnP6mj/HWUWacHrLk3@VEzn2DVDHuSIqVvfcO0QDKesXFg8nIGlyVEpKGesO6cXPJAPJ5Z8k5/KehfAebKXJbyRLmuY1Y/lUHAmkdUWyJISeKEoMfbLO0pxUm41V0GNlneLSeBzqxzaRuA99wvtHqmNR8kloRaK//ylf "Perl 6 – Try It Online")
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/) (REPL only), size 8 (71 bytes)
```
f=#[[c=-
1;;1;;-1
,c]]==#&
(*
      *(
&#==]]c,
1-;;1;;1
-=c[[#=f
```
Returns `True` for centrosymmetric input, and `False` otherwise.
On Mathematica REPL, lines with syntax errors are ignored (with a thick red bar appearing on the side of the screen). Here, only the first three lines, `f=#[[c=-1;;1;;-1,c]]==#&`, are executed.
This code captures the function in the name `f`.
Sadly, the built-in `PalindromeQ` is too long.
[Answer]
# [Pyt](https://github.com/mudkip201/pyt), size 1
```
₽
```
[Try it online!](https://tio.run/##K6gs@f//UdPe//@jjXUUTHQUTHUUzHQUzJEYFjoKljoKQFkjHQVDAzBlDBayAEubgZXCGUAjjGMB "Pyt – Try It Online")
Checks if the input (in the form of concatenated rows) is a palindrome.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), size ~~9~~ 4 (11 bytes)
```
UªSê
êSªU
```
[Try it online!](https://tio.run/##y0osKPn/P/TQquDDq7i4uA6vCj60KvT//2hDSx0IMjHQMTUAkTCRWAA "Japt – Try It Online")
Takes one-dimensional input, checks if it is a palindrome. If you want, you can fill the two empty lines for some ascii art.
The old two-dimensional version, rotates the input twice and checks if it's equal to the original:
```
W=U  I
Wz2;II
Vc)eUc
cUe)cV
II;2zW
I  U=W
```
[Try it online!](https://tio.run/##y0osKPn/P9w2VEHBkyu8ysja05MrLFkzNTSZKzk0VTM5jMvT09qoKpzLU0Eh1Db8///oaENLHQUIjtVRiDYx0FEwBWITEAdJKhYA)
[Answer]
# [Husk](https://github.com/barbuz/Husk), size 3
```
Ṡ=↔
=↔=
↔=Ṡ
```
[Try it online!](https://tio.run/##yygtzv7//@HOBbaP2qZwgQhbLhABFPn//78SVAKOgXwlAA "Husk – Try It Online") Input as 1D-List. Each line defines a function, but only the one on the first line is called.
`Ṡ=↔` is a palindrome tests which checks whether the input equals (`=`) its reverse (`↔`).
---
## [Husk](https://github.com/barbuz/Husk), size 4
```
Ṡ=↔Σ
Σ↔=Ṡ
Ṡ=↔Σ
Σ↔=Ṡ
```
[Try it online!](https://tio.run/##yygtzv7//@HOBbaP2qacW8x1bjGQtgXyubCI/f//P1oJLq6kowSXAbKxi8cCAA "Husk – Try It Online") For input as 2D-matrix, we concatenate (`Σ`) the list of lists before checking that it is a palindrome.
[Answer]
# [MATL](https://github.com/lmendo/MATL), score 4
```
t,!P
]=%?
?%=]
P!,t
```
Input has the format `[1 2; 2 1]`, using `;` as row separator.
Output is via STDERR ([allowed](https://codegolf.meta.stackexchange.com/a/2451/36398) by default):
* For centrosymmetric input a consistent error error is produced. With the current Linux and Octave versions in TIO the following STDERR output is produced (disregarding the final lines that start with `Real time: ...`):
```
octave: X11 DISPLAY environment variable not set
octave: disabling GUI features
Python 2.7.15 (default, May 16 2018, 17:50:09)
[GCC 8.1.1 20180502 (Red Hat 8.1.1-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> >>> /usr/include/c++/8/bits/basic_string.h:1048: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference = char&; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]: Assertion '__pos <= size()' failed.
panic: Aborted -- stopping myself...
```
The error may be different depending on the Linux and Octave versions, but will be consistent across inputs.
* For non-centrosymmetric input no error is produced, and the STDERR output on TIO is
```
octave: X11 DISPLAY environment variable not set
octave: disabling GUI features
Python 2.7.15 (default, May 16 2018, 17:50:09)
[GCC 8.1.1 20180502 (Red Hat 8.1.1-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> >>>
```
[Try it online!](https://tio.run/##y00syfn/v0RHMYAr1lbVnste1TaWK0BRp@T//2hDBSNrBSMFw1gA) Or verify all test cases:
* Centrosymmetric: [1](https://tio.run/##y00syfn/v0RHMYAr1lbVnste1TaWK0BRp@T//2hDBSNrBSMFw1gA), [2](https://tio.run/##y00syfn/v0RHMYAr1lbVnste1TaWK0BRp@T//2hDHQUjHQVjawVTHQUzHQVTawVjsIhhLAA), [3](https://tio.run/##y00syfn/v0RHMYAr1lbVnste1TaWK0BRp@T//2hDAx0FUx0FYwNrBSMdBTMdBSNrIAcsZmgQCwA), [4](https://tio.run/##y00syfn/v0RHMYAr1lbVnste1TaWK0BRp@T//2hDAwMdBRhhDWGZovBgRCwA), [5](https://tio.run/##y00syfn/v0RHMYAr1lbVnste1TaWK0BRp@T//2hDHQUjHQVjHQUTawVTHQUzHQVzHQULawULMAPINbVWMAErACozjAUA), [6](https://tio.run/##y00syfn/v0RHMYAr1lbVnste1TaWK0BRp@T//2hjHQUTHQVTHQUzHQVzaxhDR8FCR8HSWgEoa6SjYGgApoytFSzBEuZgRabWMAbYCONYAA).
* Non-centrosymmetric: [1](https://tio.run/##y00syfn/v0RHMYAr1lbVnste1TaWK0BRp@T//2hDHQUjawUQGQsA), [2](https://tio.run/##y00syfn/v0RHMYAr1lbVnste1TaWK0BRp@T//2hDHQUjHQVDA2sFUx0FMx0FU2sFQ6hYLAA), [3](https://tio.run/##y00syfn/v0RHMYAr1lbVnste1TaWK0BRp@T//2hDEx0FUx0FYyNrBSMdBTMdBSDD2AAsZmgWCwA), [4](https://tio.run/##y00syfn/v0RHMYAr1lbVnste1TaWK0BRp@T//2hDSx0FCLZWMDHQUTAFYhNrBYRwLAA), [5](https://tio.run/##y00syfn/v0RHMYAr1lbVnste1TaWK0BRp@T//2hDHQUjIDLQUTCxVjDXUTDTAZEW1goWOlCumbWCsQ4IAdUZxgIA), [6](https://tio.run/##y00syfn/v0RHMYAr1lbVnste1TaWK0BRp@T//2hjHQUTHQVTHQUzHQVzaxhDR8FCR8HSGiplaABRhCGNojkWAA).
[Check](https://tio.run/##y00syfn/v0QnQJEr1lbVnste1TaWSzFAp@T//2h1kLC6tYI6SAZEgyRBNEhePRYA) that the program is centrosymmetric.
### Explanation
`%` is the comment symbol, which causes the rest of the line o be ignored. Newlines are also ignored. So the code is just
```
t,!P]=?P!,t
```
which does the following:
```
t       % Input, implicit. Duplicate
,       % Do twice
  !     %   Transpose
  P     %   Flip vertically
]       % End
=       % Compare element-wise
?       % If all comparisons gave true
  P     %   Implicit input. Transpose. Actually, since there is no more input, an
        %   error is prand the program exits. The rest of the code is not executed,
        %   and will be described in parentheses
  !     %   (Transpose)
  ,     %   (Do twice)
    t   %     (Duplicate)
        %   (End, implicit)
        % (End, implicit)
```
[Answer]
# Haskell, size ~~11~~, ~~10~~, ~~9~~, 8
Takes the input as a 2D list! (Credit to Ørjan Johansen)
```
r= --r}-
 reverse
(==)<*>
 r.map{-
-{pam.r
 >*<)==(
esrever
-}r-- =r
```
[Answer]
# [Python 2](https://docs.python.org/2/), size 8
```
i=input#
a=i()###
a[::-1##
]!=a<_##
##_<a=!]
##1-::[a
###)(i=a
#tupni=i
```
[Try it online!](https://tio.run/##NcwhEoAgEAXQ7i10CwYCRoY9iTDMNikrAYOnx@8o7aVX73acuvVeuGi9Gk3CxaxEwO69dUCaWUIGiHIQnhPgrPe7ALSawkC7quLofRlT1FFB/xV1ZFHH9urrXn0f9IfLAw "Python 2 – Try It Online")
Takes input as a 1D list of concatenated rows (of length \$n^2\$) and outputs via exit code (0 for symmetric inputs, 1 otherwise).
The list is simply checked to be a palindrome. If it is, the comparison chain `a[::-1]!=a<_` fails at the `!=` step and short-circuits; otherwise the unknown variable `_` gets evaluated, crashing the program.
[Answer]
# [R](https://www.r-project.org/), size 9
```
   #)x-))
#(nacs-<x
#(ver(yna
#       #
#       #
#       #
any(rev(#
x<-scan(#
))-x)#
```
[Try it online!](https://tio.run/##bcq7CsAgDEbh3af4IUsyZKu9gC8TiquDgujTp5auPdM3nOoOgGSoSCAudjdNY6nnyrNYIHzRr6xMrrkzhZG03VaWRHTIu3jEiQM7LkRs/gA "R – Try It Online")
The last three lines are the actual program that takes a 1D array as input and checks if it's equal to its reverse. Truthy value: FALSE, Falsy value: TRUE.
```
any(rev(x<-scan())-x)
```
## [R](https://www.r-project.org/) + pryr, size 9
```
pryr::f(#
any(rev(#
x)-x))#
  #))x-)x
#(ver(yna
#(f::ryrp
```
[Try it online!](https://tio.run/##DcshCsAwDEZh31MEYvKLirkRdpkyGjlKRElPn@WpzzxPe3ouP65qwm18R3zuUqAHwEStImIgOqKx7OlyvlEy1RpXmrxy6Q3kDw "R – Try It Online")
[Answer]
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), score 13 11 10
```
l=>a=>a.//
Where((e//
,i)=>e!=//
a[l-i-1]//
).Any()///
///()ynA.)
//]1-i-l[a
//=!e>=)i,
//e((erehW
//.a>=a>=l
```
[Try it online!](https://tio.run/##pVJRb9MwEH7Pr/iWJxtcV6UbTAwHVZV4AgmJSX2o8mCy22qR2sL2gDDlt3eXtNsqkACJiyN9dz5/3519TZo0IdLuNjl/g09dyrTV753/elEUTWtTwsfirgBbyja7BpHsVfBt95D77tY3b5zP6tfAulb4HEJbVbiG2bWmsrz0dFqsNhRJCGKonDQVnRiGdt1O3GRWM5R64Tshpwz5F7LzCy0Z1jPOaNeWoTmhykinGA5UkTYrhtpWhle7w8G4i6PavwV3hQ/WeZFy5H7XNWy8SXLM2Xc52FC8qpEpZRh4@v4QueNvpvBCYa5wil6xf6bwUuGVwvnePx8dDp3t/dMxmY/M0KO/eBRZbqj5cskSYtBhOvm090flY9mDxj8JzP9bYP53gXGz//3Sn3KPLlcN4kjuJ0mY6pH3MEfL4FNoSa@iy8QTSaIcCLC1/HY/4BJKPIe4FgPBs5FlLEQvbcrDAFZC6suwiNHyLEm8RemDn5R4jbKUfLRsyOcYUrfdElM2uuQG@t09 "C# (.NET Core) – Try It Online")
Takes input as 1D array and n2 as length; returns `false` for centrosymmetric and `true` for non-centrosymmetric. This version uses `System.Linq` but I don't know how to fit it in the code submission due to the particular requirements of the challenge. Unrolled code:
```
l => a => a.Where((e,i) => e != a[l-i-1]).Any()
```
Following is my previous submission that does not use LINQ:
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), score 16 15 13
```
l=>a=>{/////*
var r=1<2;for
(int i=0;i<l;
)r&=a[i]==a[l
-i++-1];
return r;}
     /*/
   };r nruter
     ;]1-++i-
l[a==]i[a=&r)
;l<i;0=i tni(
rof;2<1=r rav
*/////{>=a>=l
```
[Try it online!](https://tio.run/##pVJRa9swEH7Xrzj8UOxYduqk3cpkeYzAnlYYrLCH4AfNVToxRWInJVsW/Nuzs5O2YYNtsBMI3en0fXefrgtF51EfNsG4B/iwC1Gvy3fGfRWMdVaFAO/ZngFZiCqaDlCre@/s7jH37cZ1tXGR/xpYthw@eW@bBlYgD1Y2Sjb76WATtlUIKKt6JlYeWUrpYOSlMLUVLMMLqZamlbRbVpg8L6pWMNRxgw5Q9GM5MJ1Mh0MvEBxuosZjWLRVkeemYHappGwN7ReYMWFrIy6lgehMytCvxKyuJBWhtmwyFrVvpGqkPcDJSICztrfe3MOtMi4NEUmqZQsKH0I25hwFGmzom7cQdYggwelvj5E9rYrDjMOcwxX0nPxrDi84vORwc/RvRodC10f/akymJxX01OcTyeKz7r7cEUU68BBc9nz3R@Zz2hPHPxHM/5tg/neC8bL/XfTn3DNx@UAOwfzQGcjmCfc0ggvvgre6/IgmahpmnSYDAKwV/d13MAESyCFdpQPAZEQZCykXKsRhdps0K@/8G0S1S7MMXkOSwCtInHdFktHTpNMuog@79VoTZFcm1EB/@Ak "C# (.NET Core) – Try It Online")
Unrolled code:
```
l => a =>
{
    var r = 1<2;
    for (int i = 0; i < l;)
        r &= a[i] == a[l-i++-1];
    return r;
}
```
[Answer]
# [Ruby](https://www.ruby-lang.org/), score ~~9~~ 8
```
->z{z==#
z.######
reverse#
}#######
#######}
#esrever
######.z
#==z{z>-
```
[Try it online!](https://tio.run/##pVPbboIwGL7vU/wpN1tWGg6KugRvdr8XIGRxrGQmCqaFJaI@O6MnRWPdxUho@5@/8n3w9nPfl2nvL7tDl6Ye6qinHsTZD@OCeejkGY/ZT8hjQkWNh3bIS9Ohfun3u7YRgN9Y1fBa7Ldb1vB18YqR8pdZloUEopxAFhEI85yWm1XTsCq/TiAQy5wpgYTAVB5j5XVUBEPSUBKYvokZEWt/GDiqAhnTi0xX5@mNfU54AJXA5IJ2RmAurbk6WvgTlea8gWyhsMoG170ILEb3Dy4fZ6GCoxnmqFrF4zHnOQgAW6IxkZZlW1uWcm1Z3rVlyTeWUcA4RjtjGS1glNPtanc4btYVO4JcafG94uJ0hkab@kPAC2B4EnXLCwZF/cWesYasceP3uvKLvwWldjdLYXCjqDB8JClNRxw5JJXcrxo40a/i3MhJiWMUcmOMbPbsvpQSo4T/SWli/gqd6FLbqMllTP8L "Ruby – Try It Online")
A lambda taking a flattened matrix as input. Returns true for centrosymmetric, false otherwise.
-1 thanks to Mr.XCoder,
Unpacked:
```
->z{
  z == z.reverse
}
```
[Answer]
# [Clean](https://github.com/Ourous/curated-clean-linux), size 9
Thanks to [Ørjan Johansen](https://codegolf.stackexchange.com/users/66041/%C3%98rjan-johansen)!
```
import //
 StdEnv//
r=reverse
?m=m==r//
    m
//r==m=m?
esrever=r
//vnEdtS
// tropmi
```
[Try it online!](https://tio.run/##TYyxDsIwDET3fIU/wCjQQilD1IUOSGwdEUPUBhSpTisnVOLnCWkGhIfz6d7p@tFoF2kaXqMB0tZFS/PEAaQU0IWhdUtyrNgshr0RDSlSileajlYRUrJKKTXC@NxTnLLFtUPoVgqBp5ls7IJOwwoauJUIe4QDQoVw/DM1wgkh0QJht82vzFGdcZWrP5Mmynv89I9RP33cXK7x/HaabO@/ "Clean – Try It Online")
# [Clean](https://github.com/Ourous/curated-clean-linux), size 10
```
import/*//
*/StdEnv//
r =reverse
?m      //
 =m==r m//
//m r==m=
//      m?
esrever= r
//vnEdtS/*
//*/tropmi
```
[Try it online!](https://tio.run/##TYw9C8IwEIb3/op3LpGo9XMIXXQQHISO4hDaKIVeWq6x4J83HhHEW@55P@7qzlkfqW@enQPZ1seWhp6DzrXOcl2F5ugnQYZhNzkeXVYS0ogLQ8YwSFBrAhvREPwWqMzcmK4MWNzJH5tQ6Vww14H7gdpYBcsBBiWuhcJKYa2wUdj@wU5hryDpUmExT6tI1i7Fm1T9gbwobvFd3zv7GOPsdI6Hl7fU1l9x6Wy490wf "Clean – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), size 3 (11 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage))
```
ÂQq

qQÂ
```
Input as a single list.
[Try it online.](https://tio.run/##MzBNTDJM/f//9JzDTYFchQqFXIGHm07P@f8/OtpYR8FER8FUR8FMR8E8VkchGsrUUbDQUbAECQBVGOkoGBqAKWOQiCVY0hys0BQkAGWCjTKOjQUA)
I guess this one doesn't count.. ;p
```
ÂQ
qâ
```
Input as a single list.
[Try it online.](https://tio.run/##MzBNTDJM/f//cFMgV@HhRf//RxvrKJjoKJjqKJjpKJgjMSx0FCx1FICyRjoKhgZgyhgsZAGWNgMrhTOARhjHAgA)
**Explanation:**
```
Â         # Bifurcate this list (short for DR: Duplicate & Reverse copy)
 Q        # Check if the input-list and the reversed list are equal
  q       # Terminate the program
   qQâ    # No-ops
```
---
**Some size 3 (11 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)) alternatives:**
```
R€R
QqQ
R€R
```
Matrix as input.
[Try it online.](https://tio.run/##MzBNTDJM/f8/6FHTmiCuwMJALjDr///oaGMdBRMdBVMdBTMdBfNYHYVoKFNHwUJHwRIkAFRhpKNgaACmjEEilmBJc7BCU5AAlAk2yjg2FgA)
```
RQ
 q
 QR
```
Single list as input.
[Try it online.](https://tio.run/##MzBNTDJM/f8/KFCBS6EQiAOD/v@PNtZRMNFRMNVRMNNRMEdiWOgoWOooAGWNdBQMDcCUMVjIAixtBlYKZwCNMI4FAA)
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 12 x 12
```
C(e,n,t,r)//
int*e;{for//
(r=t=0;e[t//
];r|=e[t]^//
e[~t+++n])//
;n=!!!!r;}//
//};r!!!!=n;
//)]n+++t~[e
//^]t[e=|r;]
//t[e;0=t=r(
//rof{;e*tni
//)r,t,n,e(C
```
[Try it online!](https://tio.run/##vZRNb4JAEIbP9VesNk0WnIZFPqzZkB7stTdvFJNGl4ZDV7PdnhD/Oh1ALSoaa4kENvsuM/MM7Auzx4/ZLM/HVIAEDcqwrE4itSl4Gi8UCqoCHTAuQo0i4moV4DSaohDhWvf7fRkVOVwGXTwUz1BYVsZVIQPJURiRxDi9DgWKaaRDEawUj1DglDOsrygKtYhTLkwtkyJHYTcSBB3n93MRJ1KQCX2FF@xwqbDBmPYe5iR4JsVIug/zN9mDcRFhQFdhFO98vieSGmnnbkIpxZQwMlJCiA1kAMQB4gLxgPhAhkCeynNYSq@85ZRhNjl/AMsMDDcxwTZOkrxt3cuKniE5plORlt/6i/Z6@JiN0GspjdCBObj14x2QWFWelfX9ilut2axlEoPDwTtewuHfpJvZ8IBRh412ALZtZ7Tfwl4vO5JnehfZsBjbtSE78SI3Fql6te1rjVjbsgZS9RqdQYMN/XZJuAvby91Y0IXacnuk6ndR1R82@dAvbXGRD2s2ZH@0obv5mrezY5f@Ju/bEElZ/gM "C (gcc) – Try It Online")
[Answer]
# ><>, Size 6
```
!/l2(\
s\?\ ?
/{=/ ;
: /={/
? \?\s
\(2l/!
```
[Try it online!](https://tio.run/##S8sszvj/X1E/x0gjhqs4xj5GwZ5Lv9pWX8Gay0pB37Zan8teAShazBWjYZSjr/j//3/dMgVDEGEEJwwB "><> – Try It Online")
(It turns out it's a pain passing multiple value to -v in tio)
Input is taken as a one dimensional array as the initial stack state with -v. Exits with no output if the matrix is centrosymmetric, exits with an error (prints "Something smells fishy...") if not.
```
l2(    Checks if the length of the stack is less than 2
?;     Exits cleanly if so
{=     Checks if the first and last elements are equal
?\s    Causes an error ('s' is not a valid instruction) if not
```
I wasn't entirely happy with this output format, so here's a size 7 one which outputs 1 for true, and 0 for false.
```
!/l2(\\
 ?   ?0
 =;n1/n
;{   {;
n/1n;=
0?   ?
\\(2l/!
```
[Try it online!](https://tio.run/##S8sszvj/X1E/x0gjJoZLwV5BQcHegEvB1jrPUD@Py7oayK@25srTN8yztlXgMgDLK3DFxGgY5egr/v//X7dMwRBEGMEJQwA "><> – Try It Online")
[Answer]
# [Stax](https://github.com/tomtheisen/stax), n = 3
```
$cr
=q=
rc$
```
[Run and debug it](https://staxlang.xyz/#c=%24cr%0A%3Dq%3D%0Arc%24&i=[[1,+2],+[2,+1]]%0A[[1,+2,+3],+[5,+6,+5],+[3,+2,+1]]%0A[[10,+5,+30],+[2,+6,+2],+[30,+5,+10]]%0A[[100,+100,+100],+[100,+50,+100],+[100,+100,+100]]%0A[[1,+2,+3,+4],+[5,+6,+7,+8],+[8,+7,+6,+5],+[4,+3,+2,+1]]%0A[[3,+4,+5,+6,+7],+[5,+6,+7,+8,+9],+[3,+2,+10,+2,+3],+[9,+8,+7,+6,+5],+[7,+6,+5,+4,+3]]%0A%0A[[1,+2],+[1,+2]]%0A[[1,+2,+10],+[5,+6,+5],+[11,+2,+1]]%0A[[14,+5,+32],+[2,+6,+2],+[30,+5,+16]]%0A[[19,+19,+19],+[40,+50,+4],+[19,+19,+19]]%0A[[1,+2,+20,+4],+[7,+6,+7,+8],+[8,+7,+6,+6],+[3,+3,+2,+1]]%0A[[3,+4,+5,+6,+7],+[5,+6,+7,+8,+9],+[4,+5,+10,+4,+5],+[5,+6,+7,+8,+9],+[3,+4,+5,+6,+7]]&m=2)
Explanation:
```
$cr =q= rc$ Full program, implicit input
$           Flatten
 cr         Copy and reverse
    =       Compare to original
     q      Print result
      =     Silently error because there is only one item on stack
        rc$ Not executed
```
3 is the best possible because I need at least three commands: Copy,
reverse, and compare
### [Stax](https://github.com/tomtheisen/stax), n = 4
```
Mrxr
M=qX
Xq=M
rxrM
```
[Run and debug it](https://staxlang.xyz/#c=Mrxr%0AM%3DqX%0AXq%3DM%0ArxrM&i=[[1,+2],+[2,+1]]%0A[[1,+2,+3],+[5,+6,+5],+[3,+2,+1]]%0A[[10,+5,+30],+[2,+6,+2],+[30,+5,+10]]%0A[[100,+100,+100],+[100,+50,+100],+[100,+100,+100]]%0A[[1,+2,+3,+4],+[5,+6,+7,+8],+[8,+7,+6,+5],+[4,+3,+2,+1]]%0A[[3,+4,+5,+6,+7],+[5,+6,+7,+8,+9],+[3,+2,+10,+2,+3],+[9,+8,+7,+6,+5],+[7,+6,+5,+4,+3]]%0A%0A[[1,+2],+[1,+2]]%0A[[1,+2,+10],+[5,+6,+5],+[11,+2,+1]]%0A[[14,+5,+32],+[2,+6,+2],+[30,+5,+16]]%0A[[19,+19,+19],+[40,+50,+4],+[19,+19,+19]]%0A[[1,+2,+20,+4],+[7,+6,+7,+8],+[8,+7,+6,+6],+[3,+3,+2,+1]]%0A[[3,+4,+5,+6,+7],+[5,+6,+7,+8,+9],+[4,+5,+10,+4,+5],+[5,+6,+7,+8,+9],+[3,+4,+5,+6,+7]]&m=2)
Explanation:
```
Mrxr M=qX Xq=M rxrM Full program, implicit input
Mr                  Transpose and reverse
  x                 Push input again
   r M              Reverse and transpose
      =             Compare
       qX Xq        Print result twice and save to X
            =       Silently error because there is only one item on stack
             M rxrM Not executed
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), size 2 (5 bytes)
```
ê"
"ê
```
[Try it](https://ethproductions.github.io/japt/?v=1.4.6&code=6iIKIuo=&input=WzEsMiwzLDQsNSw0LDMsMiwxXQ==)
[Answer]
# Java 10, size 13 (181 bytes)
```
a->{var r///*
=1>0;for(int
l=a.length,i=
0;i<l;)r&=a[i
]==a[l-++i];
return r;}
     /*/
   };r nruter
 ;]i++-l[a==]
i[a=&r);l<i;0
=i,htgnel.a=l
 tni(rof;0>1=
*///r rav{>-a
```
[Try it online.](https://tio.run/##rVRNj9owEL37V4z2sEogn8BCqdcceuite2FvKAcTDHjrdVaOQ4VQfjudGNiuL9tGqpLJaBLPx5sXvRd@4PHL5ue5VLyu4QeX@kQApLbCbHkp4KkLAdZVpQTXUAbroxWrAnhI8UNL8FFbbmUJT6CBwZnHi9OBGzBpmg4IyxcZ3VYmwIpAFOOJEnpn95FkJKPyUdHQ3DO@kqRg6FQ8HMqCAjHCNkaDoS02dxNAOkid76KWGtCmwSEJ0EIOh7FaccYKItHdm5CqR0kzwmS0tzstVMKZImC1DEy1pdkiZ2SA8@GU/HBaxPxMOyBvzVohkCueQyU38IoLCZbWSL1zoC/bSFN4xu7741cXLo@1Fa9J1djkDU9apQOdlIEWv@CyrVMejfDK29Bt7V8zxtFDNEUb983NuqQMs6ZdlS7Ks175WfTRHvwQrTeQiYMyi77gNXOgJr1h/alyqzW/1Mhci/l76fcGnxUPHeWOy@9c1aIXl2g9V@A46cbK875sdqjHI4/NaZ/8eXS5J47JSXR70RPBqMudeSxOce3/g8WJ@0Od@0jt9eBfWLxpQsfksmoMilZZbcSndN55KuWJlKdRnkR5CuUJlKdPnjx56uSJk6dNnjR5ynSX7IT9hqurgzC8am57/g0)
Inspired by [*@Charlie*'s C# answer](https://codegolf.stackexchange.com/a/168715/52210).
**Golfed explanation:**
```
a->{var r=1>0;for(int l=a.length,i=0;i<l;)r&=a[i]==a[l-++i];return r;}
a->{                    //  Method with byte-array parameter and boolean return-type
  var r=1>0;            //  Result-boolean, starting at true
  for(int l=a.length,   //  The length of the input-array
      i=0;i<l;)         //  Loop `i` in the range [0, length)
    r&=                 //   Bitwise-AND the result-boolean with:
       a[i]             //    Whether the current item
           ==a[l-++i];  //    equals the opposite item
  return r;}            //  Return the result
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), score 11
Takes a list of int and n as arguments. Returns n as truthy value, 0 as falsy.
```
/*//};n=l;k
--*==++l*=*
n);l>k;n*n+
l=k(rof{;l*
tni)n,l(f;k
*/*/////*/*
k;f(l,n)int
*l;{for(k=l
+n*n;k>l;)n
*=*l++==*--
k;l=n;}//*/
```
[Try it online!](https://tio.run/##jVLdboIwGL2mT9GYLGkLjfyJc0293BPsbu7CuLAZurogXiyEZ2f9oQNUdAYL6Tnn6/lOvx392O3adk7m84ZJLlgBKCWc@74gnACJmVgXTBLpA8ELVB7ymgkCKrnHMhAoV3yixeqn3qBgORKBxHtZASJYnR9KVHABfFWBFWvBsASqrvB9zgmlii@4ZI0Wt0oDv7Z7iTCogacreF5VnqrPn@j1DXJYRwGMzRM1wR8WD7EkgIsAZmZNLqhJRw0tHhpCZoV2LwoH9NTRQw2MlsXllloG2sWZq9QZWwbw0TxL5zO9ZjWz@jPlsMTqTxa6Q1bjwqMTGgY8F2q@Fcdxpno1pxtoFGmXlq0URQOnhusytTaT@EqmWc92kSqn7p92cab9VrTqFaMgY8tbXksyMxEk5/7@FWTaXb77usy5F9sgv0/VEc1ezF09bSSldCNn2EKlSjlHs4d3tRXAHHUzrJxhzZjAdWC38OQOnt7B9RzcwvUFYzxobiOfdYD3urPDNNmcHahJb3aGbsPpbXi6MTsAXV9N@ws "C (gcc) – Try It Online")
[Answer]
# Javascript ES6, size 8:
```
/***/a=>
""+a==a.
reverse(
)/////*/
/*/////)
(esrever
.a==a+""
>=a/***/
```
# Javascript ES6, size 7 (is it valid?):
```
a=>""+a
==a.//=
reverse
`     `
esrever
=//.a==
a+"">=a
```
### Test:
```
<script>
f=
a=>""+a
==a.//=
reverse
`     `
esrever
=//.a==
a+"">=a
</script>
<script>
console.log([
  [1, 2, 2, 1],
  [1, 2, 3, 5, 6, 5, 3, 2, 1],
  [10, 5, 30, 2, 6, 2, 30, 5, 10],
  [100, 100, 100, 100, 50, 100, 100, 100, 100],
  [1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1],
  [3, 4, 5, 6, 7, 5, 6, 7, 8, 9, 3, 2, 10, 2, 3, 9, 8, 7, 6, 5, 7, 6, 5, 4, 3],
].every(f))
console.log([
  [1, 2, 1, 2],
  [1, 2, 10, 5, 6, 5, 11, 2, 1],
  [14, 5, 32, 2, 6, 2, 30, 5, 16],
  [19, 19, 19, 40, 50, 4, 19, 19, 19],
  [1, 2, 20, 4, 7, 6, 7, 8, 8, 7, 6, 6, 3, 3, 2, 1],
  [3, 4, 5, 6, 7, 5, 6, 7, 8, 9, 4, 5, 10, 4, 5, 5, 6, 7, 8, 9, 3, 4, 5, 6, 7],
].every(x=>!f(x)))
</script>
```
or with lambda saved to variable named `a`:
```
a=
a=>""+a
==a.//=
reverse
`     `
esrever
=//.a==
a+"">=a
console.log([
  [1, 2, 2, 1],
  [1, 2, 3, 5, 6, 5, 3, 2, 1],
  [10, 5, 30, 2, 6, 2, 30, 5, 10],
  [100, 100, 100, 100, 50, 100, 100, 100, 100],
  [1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1],
  [3, 4, 5, 6, 7, 5, 6, 7, 8, 9, 3, 2, 10, 2, 3, 9, 8, 7, 6, 5, 7, 6, 5, 4, 3],
].every(a))
console.log([
  [1, 2, 1, 2],
  [1, 2, 10, 5, 6, 5, 11, 2, 1],
  [14, 5, 32, 2, 6, 2, 30, 5, 16],
  [19, 19, 19, 40, 50, 4, 19, 19, 19],
  [1, 2, 20, 4, 7, 6, 7, 8, 8, 7, 6, 6, 3, 3, 2, 1],
  [3, 4, 5, 6, 7, 5, 6, 7, 8, 9, 4, 5, 10, 4, 5, 5, 6, 7, 8, 9, 3, 4, 5, 6, 7],
].every(x=>!a(x)))
```
[Answer]
# Clojure, Size 9
```
#(= %(;;;
reverse;;
(map;;;;;
reverse;;
%)));)))%
;;esrever
;;;;;pam(
;;esrever
;;;(% =(#
```
[Try it online!](https://tio.run/##lVJNj4MgEL3zKyZpTDDh4HfbkKa3/QV7Mx4aS7M2ahukm/jrXRhoxe562AM6PN68GR5Tt7frQ4qJnsUFatEreRvGrhNKNvVx2tADBJRzTqT4FnIQOqLd6c75EgvCMOR6BYRzMSBOkHM/dXSJ0QAOdDOFhGBJJR/qayQlKcuYQVIxKBMGcVU5gEFqsJxBwSA3YYqoY0Qa1JTI5RVOIrV4HDlWZGL7MccY52/7F8ErzSCbq28Z7Mxuh@GznQxpr45MCtY2CctcBnuv/2i@3B4PPU0XolSqZaunW5dTO4ilW/ifW46jN7vi2PfL9pYmK34VlqUbsgsv6LxCJ7yjuWbyPN3@7VPhrv0/nzL3hJa4ZqUn4vmkxKA@7WQBUDN64xGasx7vRo1gJvjXrLtJ1EM8S3xYu2eJ/qZWsu3LmGxC77LpVdt7XYRL0OqG0w8 "Clojure – Try It Online")
]


[Question]
      [
Given a non-negative number `n`, output the number of ways to express `n` as the sum of two squares of integers `n == a^2 + b^2` ([OEIS A004018](https://oeis.org/A004018)). Note that `a` and `b` can be positive, negative, or zero, and their order matters. Fewest bytes wins.
For example, `n=25` gives `12` because `25` can be expressed as
```
(5)^2  + (0)^2
(4)^2  + (3)^2
(3)^2  + (4)^2
(0)^2  + (5)^2
(-3)^2 + (4)^2
(-4)^2 + (3)^2
(-5)^2 + (0)^2
(-4)^2 + (-3)^2
(-3)^2 + (-4)^2
(0)^2  + (-5)^2
(3)^2  + (-4)^2
(4)^2  + (-3)^2
```
Here are the values up to `n=25`. Be careful that your code works for `n=0`.
```
0 1
1 4
2 4
3 0
4 4
5 8
6 0
7 0
8 4
9 4
10 8
11 0
12 0
13 8
14 0
15 0
16 4
17 8
18 4
19 0
20 8
21 0
22 0
23 0
24 0
25 12
```
Here are the values up to `n=100` as a list.
```
[1, 4, 4, 0, 4, 8, 0, 0, 4, 4, 8, 0, 0, 8, 0, 0, 4, 8, 4, 0, 8, 0, 0, 0, 0, 12, 8, 0, 0, 8, 0, 0, 4, 0, 8, 0, 4, 8, 0, 0, 8, 8, 0, 0, 0, 8, 0, 0, 0, 4, 12, 0, 8, 8, 0, 0, 0, 0, 8, 0, 0, 8, 0, 0, 4, 16, 0, 0, 8, 0, 0, 0, 4, 8, 8, 0, 0, 0, 0, 0, 8, 4, 8, 0, 0, 16, 0, 0, 0, 8, 8, 0, 0, 0, 0, 0, 0, 8, 4, 0, 12]
```
Fun facts: The sequence contains terms that are arbitrarily high, and the limit of its running average is π.
**Leaderboard:**
```
    var QUESTION_ID=64812,OVERRIDE_USER=20260;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/64812/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;
```
```
    body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
```
```
    <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><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
```

[Answer]
# PHP, 70 bytes, not competing
```
for($x=-1;$x++<=$n=$argv[1];)$s+=(-($n%($x-~$x)<1))**$x*4;echo$n?$s:1;
```
algorithm stolen from one of the Python answers ... I forgot which one; wanted to at least partially understand what´s happening before I posted.
[Answer]
# PHP, 80 Bytes
```
for($m=-$a=1+$argv[1];++$m<$a;)for($n=-$a;$n++<$a;)$c+=$a-1==$m**2+$n**2;echo$c;
```
[Answer]
# ASP, 53 + 4 = 57 bytes
```
#show N:N=#count{o(A,B):k=A**2+B**2,A=-k..k,B=-k..k}.
```
[Answer Set Programming](https://en.wikipedia.org/wiki/Answer_set_programming) is a logical language, similar to prolog.
I use here the [Potassco implementation](https://potassco.org), *clingo*.
Input is taken from parameters (`-ck=` is 4 bytes long). Call example:
```
clingo -ck=25
```
Output sample:
```
12
```
You can try it in your [browser](https://potassco.org/clingo/run/) ; unfortunately, this method doesn't handle call flags, so you need to add the line `#const k=25` in order to make it work.
[Answer]
# [Add++](https://github.com/cairdcoinheringaahing/AddPlusPlus), 31 bytes
```
D,f,@,.5^1+iR2€Ω^d0BFB]d‽+A€=¦+
```
[Try it online!](https://tio.run/##S0xJKSj4/99FJ03HQUfPNM5QOzPI6FHTmnMr41IMnNycYlMeNezVdgSK2B5apv2/KDEvPdXKyIzLDczS4eJMyMxLSa0AMjJ1DYFkCoybUJRaAqRU0uxgIv5Akf8A "Add++ – Try It Online")
## How it works
This defines a function, \$f\$, that takes the input, \$x\$, as an argument and returns the correct output. We start by yielding \$y := \lfloor\sqrt{x}+1\rfloor\$. We then push the range \$a := [1, 4, ..., y^2]\$, the list of square numbers up to the smallest square number larger than \$x\$. We then duplicate this array and push \$0\$ to the stack. At this point, the stack looks like this, for an input of \$25\$:
```
[[1 4 9 16 25 36] [1 4 9 16 25 36] 0]
```
We then collect these values into a single list, which yields the list of \$n^2\$ for each \$n \in [-y, y]\$. We then duplicate this list and operate the *table* operator over the addition command. The *table* operator takes a dyad, \$g(p, q)\$, and two arrays, \$A\$ and \$B\$. It then takes the [Cartesian Product](https://en.wikipedia.org/wiki/Cartesian_product) of \$A\$ and \$B\$ and iterates \$g(a, b)\$ over each pair \$(a, b)\$ where \$a \in A\$ and \$b \in B\$.
In this code, this yields the array \$\big[a^2+b^2 \: | \: a, b \in [-y, y]\big]\$. We then compare each element of this list with the input, yielding a boolean array. Finally, we count the number of \$1\$s in this array by taking its sum, and returning that total.
Most of the code should be understandable when paired with the explanation. A few of the overlooked commands:
* `Ω` : The *reverse* operator. Takes a dyad and reverses the order of the arguments
* `‽` : The *table* operator, as described above.
* `¦` : The *fold* operator. Takes an array and a dyad and reduces by the dyad. `¦+` is an alias for sum.
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf/blob/master/math_golf.txt), 9 [bytes](https://github.com/maxbergmark/mathgolf/blob/master/code_page.py)
```
╤■mæ²Σk=Σ
```
[Try it online.](https://tio.run/##y00syUjPz0n7///R1CWPpi3IPbzs0KZzi7Ntzy3@/9@Ay5DL0IDLyJTL0hLIMAAA)
**Explanation:**
```
╤         # Take the (implicit) input-integer, and push a list in the range [-input, input]
 ■        # Take the cartesian product of this, creating a list of all possible pairs
  mæ      # Map these pairs to, using the following four commands:
    ²     #  Take the square of both values in the pair
     Σ    #  Sum those
      k=  #  And check whether it's equal to the input-integer (1 if truthy; 0 if falsey)
  Σ       # After the map, sum the list
          # (after which the entire stack joined together is output implicitly)
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 7 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
(ŸãnOQO
```
[Try it online](https://tio.run/##yy9OTMpM/f9f4@iOw4vz/AP9//83MgUA) or [verify the test cases in the range \$[0,100]\$](https://tio.run/##yy9OTMpM/X@x6dgkP3slhUdtkxSU7P1c/msc3XF4cZ6/X6D/f53/AA).
**Explanation:**
```
(        # Get the negative of the (implicit) input-integer
 Ÿ       # Push a list in the range [(implicit) input-integer, -input]
  ã      # Get the cartesian product of this list, creating all possible pairs
   n     # Square each value in each pair
    O    # Sum each inner pair
     Q   # Check for each sum whether it's equal to the (implicit) input-integer
         # (1 if truthy; 0 if falsey)
      O  # And sum those
         # (after which the result is output implicitly)
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-x`](https://codegolf.meta.stackexchange.com/a/14339/), 11 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
õUn)ï £¶Xx²
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LXg&code=9VVuKe8go7ZYeLI&input=MjU)
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 7 bytes
```
rNp`²§ċ
```
[Try it online!](https://tio.run/##y0rNyan8/7/IryDh0KZDy490/zcyPbrb@nC7yqOmNe7/AQ "Jelly – Try It Online")
## How it works
```
rNp`²§ċ - Main link. Takes n on the left
 N      - Yield -n
r       - Take the range [-n, -n+1, ..., -1, 0, 1, ..., n-1, n]
   `    - Use this list for both arguments for:
  p     -   Cartesian product
    ²   - Square each number
     §  - Take the sums of each pair
      ċ - Count the number of times n appears
```
[Answer]
# Perl 5, 52 bytes
56 bytes:
```
$n=pop;for$a(@a=-$n..$n){map$i+=$_*$_+$a*$a==$n,@a}say$i
```
If output can be in base 1, then 52 bytes:
```
$n=pop;for$a(@a=-$n..$n){print$_*$_+$a*$a==$n for@a}
```
[Answer]
## Python, ~~76~~ 74 bytes
I'm sure this can be golfed more, but I need to get back to work.
```
lambda n:sum([1for a in range(-n,n+1)for b in range(-n,n+1)if a*a+b*b==n])
```
[Try it online](http://ideone.com/mLUeBU)
Thanks to @mathmandan for taking off 2 bytes.
[Answer]
## C, 224 219 182 175 158 bytes
Non-golfed version (with descriptive variables):
```
#include <math.h>
main (argc, argv)
    char **argv;
{
    int n, count, max, i, j;
    n = atoi (argv[1]);
    count = 0;
    max = sqrt ((float) n);
    for (i = -max; i <= max; i++)
        for (j = -max; j <= max; j++)
            if (i * i + j * j == n)
                count++;
    printf ("%d", count);
}
```
Golfed version (with short variables):
```
#include<math.h>
main(c,v)char**v;{int n,o,x,i,j;n=atoi(v[1]);o=0;x=sqrt((float)n);for(i=-x;i<=x;i++)for(j=-x;j<=x;j++)if(i*i+j*j==n)o++;printf("%d",o);}
```
**Update** Sorry about the multiple edits, I'm learning how to abuse K&R-style C ;)
[Answer]
## C++, 175 bytes
```
#include<iostream> using namespace std; int main() {int i,j,k=0,n; cin>>n; for(i=1;i<n;++i) for(j=1;j<n;++j) if(i*i+j*j==n) ++k; for(i=1;i<=n;++i) if(i*i==n) ++k; cout<<4*k;}
```
Ungolfed
```
#include<iostream>
using namespace std;
int main()
{
int i,j,k=0,n;
cin>>n;
for(i=1;i<n;++i)
 for(j=1;j<n;++j)
  if(i*i+j*j==n)
   ++k;
for(i=1;i<=n;++i)
 if(i*i==n)
  ++k;
cout<<4*k;
}
```
[Answer]
# Ruby, ~~66~~ ~~58~~ ~~56~~ 54 bytes
```
->n{r=-n..n;r.map{|x|r.count{|y|n==x*x+y*y}}.reduce:+}
```
Thanks to sherlock9.
**56 bytes**
```
->n{r=-n..n;r.map{|x|r.count{|y|n==x**2+y**2}}.reduce:+}
```
**58 bytes**
```
->n{c=0;r=(-n..n);r.map{|x|c+=r.count{|y|n==x**2+y**2}};c}
```
**66 bytes**
```
->n{c=0;(-n..n).each{|x|c+=n.downto(-n).count{|y|n==x**2+y**2}};c}
```
**Ungolfed:**
```
-> n {
  r = -n..n
  r.map { |x|
    r.count { |y|
      n == x*x + y*y
    }
  }.reduce:+
}
```
**Usage:**
```
->n{r=-n..n;r.map{|x|r.count{|y|n==x*x+y*y}}.reduce:+}[25]
=> 12
```
[Answer]
# Swift 2.0, ~~110~~ ~~108~~ 107 bytes
```
var n=Int(readLine()!)!,c=0;for(var i = -n;i<=n;i++){for(var j = -n;j<=n;j++){if i*i+j*j==n{c++}}};print(c)
```
First attempt
[Answer]
# C++, 81 bytes
```
#define F(x) for(int x=~n;x++<n;)
void f(int n,int&r){r=0;F(a)F(b)r+=a*a+b*b==n;}
```
Returns via reference parameter. Simply two ranges over `[-n,n]`, so it works for `n=0`.
[Answer]
# Axiom 115 bytes
```
g(n)==(v:INT:=truncate(sqrt(n)::Float);c:=0;for i in -v..v repeat for j in -v..v repeat if i^2+j^2=n then c:=c+1;c)
```
ungolfed
```
gg(n:NNI):NNI==
   v:NNI:=truncate(sqrt(n)::Float)
   c:NNI:=0
   for i in -v..v repeat
      for j in -v..v repeat
          if i^2+j^2=n then c:=c+1
   c
```
results
```
(5) -> [i,g(i)]  for i in 0..25
   Compiling function g with type NonNegativeInteger -> NonNegativeInteger
   (5)
   [[0,1], [1,4], [2,4], [3,0], [4,4], [5,8], [6,0], [7,0], [8,4], [9,4],
    [10,8], [11,0], [12,0], [13,8], [14,0], [15,0], [16,4], [17,8], [18,4],
    [19,0], [20,8], [21,0], [22,0], [23,0], [24,0], [25,12]]
                                      Type: Tuple List NonNegativeInteger
```
dobious results
```
(13) -> g(10018)
   (13)  8
                                                    Type: PositiveInteger
(14) -> g(10019)
   (14)  0
                                                 Type: NonNegativeInteger
(15) -> g(10020)
   (15)  0
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 8 bytes
```
#¹´×+m□ṡ
```
[Try it online!](https://tio.run/##ARoA5f9odXNr//8jwrnCtMOXK23ilqHhuaH///8xMA "Husk – Try It Online") or [Verify first 25 values](https://tio.run/##AR8A4P9odXNr/23igoHFgDI2/yPCucK0w5crbeKWoeG5of// "Husk – Try It Online")
# [Husk](https://github.com/barbuz/Husk), 8 bytes
```
#¹mṁ□π2ṡ
```
[Try it online!](https://tio.run/##ARoA5f9odXNr//8jwrlt4bmB4pahz4Ay4bmh////MA "Husk – Try It Online")
[Answer]
# [Thunno 2](https://github.com/Thunno/Thunno2) `S`, 7 [bytes](https://github.com/Thunno/Thunno2/blob/main/docs/codepage.md)
```
ṄIDṖ²ʂ=
```
[Try it online!](https://Not-Thonnu.github.io/run#aGVhZGVyPSZjb2RlPSVFMSVCOSU4NElEJUUxJUI5JTk2JUMyJUIyJUNBJTgyJTNEJmZvb3Rlcj0maW5wdXQ9MjUmZmxhZ3M9Uw==)
#### Explanation
```
ṄIDṖ²ʂ=  # Implicit input
ṄI       # Push [-input..input]
  DṖ     # Cartesian product
    ²ʂ   # Square and sum
      =  # Equals input?
         # Sum the list
         # Implicit output
```
]