[Question]
  [
A string is considered to be square if the following conditions are met:
* Each line has the same number of characters
* The number of characters on each line is equal to the number of lines.
Your task is to write a program or function which determines whether or not a given input string is a square. 
You may require input to be delimited by your choice of LF, CR, or CRLF.
The newline character(s) are not considered part of the line's length.
You may require there to be or to not be a trailing newline in input, which doesn't count as an additional line.
Input is a string or 1D char array; it is not a list of strings.
You may assume input is non-empty and only contains printable ASCII, including spaces.
You must output a truthy value for square strings and a falsy one for other strings.
## Truthy test cases:
```
foo
bar
baz
```
```
.
```
```
.s.
.ss
.s.
(s represents space)
```
```
ss
ss
(s represents space)
```
```
aaaaa
aaaaa
aaaaa
aaaaa
aaaaa
```
## Falsy test cases:
```
..
.
```
```
.
```
```
.
```
```
....
....
```
```
4444
333
22
```
```
333
333
```
```
abc.def.ghi
```
Note extra blank lines in some of the falsy cases.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") - fewest bytes wins!
  
[Answer]
# [Python 2](https://docs.python.org/2/), 52 bytes
```
x=input().split('\n')
print{len(x)}==set(map(len,x))
```
[Try it online!](https://tio.run/##K6gsycjPM/r/v8I2M6@gtERDU6@4ICezREM9Jk9dk6ugKDOvpDonNU@jQrPW1rY4tUQjN7FAAyigU6Gp@f@/eiIIxOThptQB "Python 2 – Try It Online") or [Try all test cases](https://tio.run/##dUxBCsMgELz7Cm8qBKHaUyE/2UtKlQjpRtRQ29K329WeO7Azs8vMxmdZdzSt3ZznXmZ1YbzOWee4hSIFoFCMJ1eOhO/NoazqM8/ZFXlfoqTDVJVqjzVsjp9GNWA8iqRSTAELr1P/MXkqDteE33fA65I6vQQTmmbpAPwvPacBe5aE@OfPBEBrLaAxtA9HJL4 "Python 2 – Try It Online")
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog) (2), 3 bytes
```
ṇẹṁ
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r//@HO9oe7dj7c2fj/v1Jafj5XUmIREFcpAQA "Brachylog – Try It Online")
Full program. Outputs `true.` for truthy, `false.` for falsey.
## Explanation
```
ṇẹṁ
ṇ     Split {standard input} into lines
 ẹ    Split {each line} into basic elements {in this case, characters}
  ṁ   Assert that the result is square
```
I was a bit sceptical about the usefulness of the `ṁ` builtin when it was added, but I can't really deny that it's helpful here…
# [Brachylog](https://github.com/JCumin/Brachylog) (2), 7 bytes
```
ṇẹ.\l~l
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r//@HO9oe7durF5NTl/P@vlJafz5WUWATEVUoA "Brachylog – Try It Online")
Non-builtin solution. ~~*Still* beats all the other entries, as of the time of writing.~~ EDIT: Not quite, the equal-length Jelly entry got in while I was writing this, and beats it via the timestamp tiebreak.
## Explanation
```
ṇẹ.\l~l
ṇ         Split {standard input} into lines
 ẹ        Split {each line} into basic elements {in this case, characters}
   \l     Assert that the result is rectangular, and the number of columns
  .  ~l     is equal to the number of rows
```
[Answer]
# JavaScript (ES6), ~~46~~ 45 bytes
```
s=>!(s=s.split`
`).some(x=>x.length-s.length)
```
* 1 byte saved thank to [ETHproductions](https://codegolf.stackexchange.com/users/42545/ethproductions)
---
## Explanation
1. Split the string to an array on newlines.
2. Loop over the array.
3. Subtract the length of the array from the length of each line.
4. If a non-zero (i.e., truthy) value is returned for any line, the string is not square.
5. Negate the result of the loop to get `true` for square and `false` for not.
---
## Try it
```
f=
s=>!(s=s.split`
`).some(x=>x.length-s.length)
oninput=_=>o.innerText=f(i.value)
o.innerText=f(i.value=`foo
bar
baz`)
```
```
<textarea id=i></textarea><pre id=o>
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~7~~ 5 bytes
```
Ỵ¬⁼Z$
```
[Try it online!](https://tio.run/##y0rNyan8///h7i2H1jxq3BOl8v///0QQ4EoCAa5kEOBKAQGuVBAAAA "Jelly – Try It Online")
Thanks to [FryAmTheEggman](https://codegolf.stackexchange.com/users/31625/fryamtheeggman) for -2
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~10~~ 8 bytes
```
¶¡€gDgQP
```
[Try it online!](https://tio.run/##MzBNTDJM/f//0LZDCx81rUl3SQ8M@P9fSUkpMTGRK7EYiBMTgTwA "05AB1E – Try It Online")
***-2 thanks to Riley, this is basically his answer .\_.***
```
Code       # Explanation                  | Truthy Example          | Falsy Example
-----------#------------------------------+-------------------------+--------------
¶¡         # Split on newlines            | [['aaa','aaa','aaa']]   | [['aa']]
  €g       # Get length of each           | [[3,3,3]]               | [[2]]
    D      # Dupe                         | [[3,3,3],[3,3,3]]       | [[2],[2]]
     g     # Get length                   | [[3,3,3],3]             | [[2],1]
      Q    # Check equality               | [[1,1,1]]               | [[0]]
       P   # Take product                 | 1                       | 0
```
[Answer]
## Haskell, ~~38~~ 34 bytes
```
l=length
(all=<<(.l).(==).l).lines
```
[Try it online!](https://tio.run/##FcXBCoAgDADQe18xpINCCdXV/YmXFZrSGpH@/6J3eYXalZhVGTnJ2cuQ0RIzhmA9O28R3T9XSU1vqgIIz1ulwwgZDO1HlGXdokx@NvoB "Haskell – Try It Online")
Pointfree version of `f s = all ((==length (lines s)).length) (lines s)`, i.e split the input into lines and check if the length of each line is equal to the number of lines.
Edit: Thanks to @xnor for 4 bytes.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 7 bytes
```
ỴµL;L€E
```
[Try it online!](https://tio.run/##y0rNyan8///h7i2HtvpY@zxqWuP6////RCDgSgICrmQg4EoBAgA "Jelly – Try It Online")
## Explanation
```
Ỵµ       Split the input on newline and use as input in the second link     
  L      Get the number of list items
   ;     And append to that
    L€   A list with the legth of each list item
      E  Check to see if all items are equal.
```
[Answer]
## [Husk](https://github.com/barbuz/Husk), 6 bytes
```
S≡T'a¶
```
Takes a string and prints either `1` or `0`.
[Try it online!](https://tio.run/##yygtzv6vkPuoqfF/8KPOhSHqiYe2/f//P1rJ0Mg4Ji8xKTkmr6KySklHSQ@IFRRi8hQUgIxEIADKwkmQvB6YiMmD0CAWCIJYSrEA "Husk – Try It Online")
The first line iterates over the test cases; remove it if you want to test on a single value.
## Explanation
Husk is a new functional golfing language created by myself and [Leo](https://codegolf.stackexchange.com/users/62393/leo).
It's missing a lot of features and development is ongoing.
Its main feature is a rigid type system that allows us to overload higher order functions.
On a high level, the program works like this:
```
S≡T'a¶  Define a function:
     ¶  split on newlines,
  T'a   transpose and pad to rectangle using character 'a',
 ≡      check if this has the same shape as
S       the split input.
```
The function `≡` actually checks if two arrays have the same shape and the same distribution of truthy elements.
In Husk, all characters except the null byte are truthy, and that won't occur in our inputs.
Also, `S` is the **S-combinator**, a function that takes as inputs two functions, here `≡` and `T'a`, and returns a new function that maps `x` to `≡(x)(T'a x)`.
The result of `S` is composed with `¶`, and that function is applied to the input implicitly.
How does Husk know that it should apply `S` to the next function, but `¶` should be composed with the function on its left?
Simple: it just tries every interpretation and picks the one where the types make sense.
This is explained in more detail in the [Husk documentation](https://github.com/barbuz/Husk/wiki).
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 9 bytes
```
=Ur.Q)¥Uy
```
[Test it online!](http://ethproductions.github.io/japt/?v=1.4.5&code=PVVyLlEppVV5&input=ImFiYwpkZWYKZ2hpIg==)
### Explanation
```
 =Ur.Q)¥ Uy
U=Ur.Q)==Uy
             // Implicit: U = input string, Q = quotation mark
U=    )      // Set U to
  Ur.Q       //   U with each non-newline (/./g) replaced with a quotation mark.
       ==Uy  // Return U == U transposed. U is padded to a rectangle with spaces before
             // transposing; if U was not a rectangle before, or the sides are not of
             // equal length, the result will not be the same as U.
             // Implicit: output result of last expression
```
---
Using some features implemented shortly after this challenge was posted, this can be 6 bytes:
```
r.Q
¥y
```
[Test it online!](http://ethproductions.github.io/japt/?v=1.4.5&code=ci5RCqV5&input=ImFiYwpkZWYKZ2hpIg==)
### Explanation
```
       // Implicit: U = input string
r.Q    // Replace each non-newline (/./g) in U with a quotation mark.
       // Newline: set U to the result.
¥      // Return U ==
 y     //   U transposed.
       // Implicit: output result of last expression
```
[Answer]
# [Retina](https://github.com/m-ender/retina), ~~33~~ 31 bytes
```
.
.
^(.(.)*)(?<-2>¶\1)*$(?(2).)
```
[Try it online!](https://tio.run/##K0otycxL/P9fj0uPK05DT0NPU0tTw95G18ju0LYYQ00tFQ17DSNNPc3//wE "Retina – Try It Online") Explanation: The first stage simply changes all printable ASCII into the same character to make it easier to match. (It could be done without, but this is code golf, not code challenge.) The second stage then matches at least one character on the first line. However, for each additional character on the first line, it then optionally matches a newline followed by a copy of the first line. The final part of the expression causes the match to fail if there are more columns than rows.
[Answer]
# Pure bash (no utilities), 55
```
mapfile -t a
for l in ${a[@]};{
((c+=${#l}^${#a[@]}))
}
```
* `mapfile` reads the input into array `a`
* then the number of elements of the array is XORed with each line length, and the sum taken. For a perfect square, each XOR result (and thus the sum) will be 0. For anything else, the result will be >0.
The opposite sense of this is returned as a shell return code (examine with `echo $?`) - perfect square is 1, anything else is 0.
[Try it online (truthy)](https://tio.run/##S0oszvj/PzexIC0zJ1VBt0QhkSstv0ghRyEzT0GlOjHaIbbWuppLQyNZ21alWjmnNg5IgkU1Nblq/6cmZ@QrqNj/TwQBLhwkAA).
[Try it online (falsy)](https://tio.run/##S0oszvj/PzexIC0zJ1VBt0QhkSstv0ghRyEzT0GlOjHaIbbWuppLQyNZ21alWjmnNg5IgkU1Nblq/6cmZ@QrqNj/NwECLmNjYy4jIwA).
---
### Previous answer using eval-escape-expansion hell, 78:
```
mapfile -t a
echo $[0$(eval eval echo +\\$\{#a[{0..$[${#a[@]}-1]}]}^${#a[@]})]
```
[Try it online (truthy)](https://tio.run/##S0oszvj/PzexIC0zJ1VBt0QhkSs1OSNfQSXaQEUjtSwxRwFCgMS0Y2JUYqqVE6OrDfT0VKJVQEyH2Fpdw9ja2No4GFcz9v//RBDgwkECAA).
[Try it online (falsy)](https://tio.run/##S0oszvj/PzexIC0zJ1VBt0QhkSs1OSNfQSXaQEUjtSwxRwFCgMS0Y2JUYqqVE6OrDfT0VKJVQEyH2Fpdw9ja2No4GFcz9v9/EyDgMjY25jIyAgA).
[Answer]
# [Perl 6](http://perl6.org/), 27 bytes
```
{.lines==all .lines».comb}
```
Tests whether the number of lines in the input string is equal to the number of characters on each line.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 4 bytes
```
Ỵ¬zƑ
```
[Try it online!](https://tio.run/##y0rNyan8///h7i2H1lQdm/j//3@lxKSYvGQlAA "Jelly – Try It Online")
Input via command-line argument. The input must be given with no trailing newline (otherwise the program sees a blank line at the end, which isn't the same length as the others); this I/O format is explicitly allowed by the question.
So far, the shortest answer that doesn't use an "is a square" builtin. (There's an existing 5-byte Jelly answer that works on similar principles, but is wrong, incorrectly considering `"aa\na"` to be square – this answer is not only shorter, it also fixes that issue.)
## Explanation
```
Ỵ¬zƑ
Ỵ      split {the input} on newlines
 ¬     replace every truthy character (i.e. all of them) with 0
   Ƒ   does that remain unchanged, after
  z      a ragged transpose that pads to a rectangle using {the input}?
```
There are two main cases:
* The string is not even a rectangle. In this case, the "transpose and pad to rectangle" builtin `z` will pad the string to a rectangle, but uses copies of the user input as the padding, which are not zeroes (even if the input uses the character `'0'`, this compares unequal to the integer `0`). So there's no way the ragged transpose can leave the split-and-zeroed version of the input unchanged.
* The string is a rectangle. In this case, the ragged transpose won't apply any padding, but will produce a rectangle of zeroes with the number of rows and columns swapped from the transpose input. The only way the input and output can match is therefore if the number of rows equals the number of columns, i.e. the input is a square. (If the input *is* a square, the transpose will leave it unchanged because, as every element is a zero, all the elements will be the same and thus it doesn't matter that the transpose swaps some of them.)
[Answer]
## Pyth, 7 bytes
```
CImL1.z
```
[Try it here](http://pyth.herokuapp.com/?code=CImL1.z&input=aaaaa%0Abbbbb%0Accccc%0Addddd%0Aeeeee&debug=0)
Requires no trailing newline. Replaces the input with a 2D array of 1s where a 1 represents any character in the original input. Then we check whether that array is unchanged after transposing it (replacing columns with rows). Only a square will return true in such a situation.
[Answer]
# [Java (OpenJDK 8)](http://openjdk.java.net/), ~~96~~ ~~91~~ ~~90~~ 87 bytes
*-5 bytes thanks to @KevinCruijssen*  
*-1 byte thanks to @TheLethalCoder*  
*-2 bytes thanks to @OlivierGrégoire* 
```
a->java.util.Arrays.stream(a.split("\n")).allMatch(x->x.length()==a.split("\n").length)
```
[Try it online!](https://tio.run/##rZGxTsMwEIbn5CmsTo5ErlLLRGklGLp1KhthuLpO4uKeI9upGlAfmznYoRJigHbgt3R3On@@@yXv8IC5aSTttq990260EkxodI6tUBF7T1nQue88@pAORm3ZPtzytbeKqucXhrZyWYCTXRgHrVcaypaEV4ZgeS7uv@gb9miMlkgLVrI56zFffD96sBY7B85biXuO4BqtPB8VNMoyQK1X6EXNj/niCFpS5Wuezec/sHM/65PZYD1qPGZPtvV1xwQ66e7SZN05L/dgWg9NMOU18RKwaXTHR6UxBW3QxvAW9s7@xuEyglEF/Z6GEWkSfC5Ru@tsAhR0xe7/gwDiynhidZm/DSpoOp0WNJlcxgcwhIGMv3ZKT/0HmVygqOUn "Java (OpenJDK 8) – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 7 bytes
```
|€gDgQP
```
[Try it online!](https://tio.run/##MzBNTDJM/f@/5lHTmnSX9MCA//8TQYALBwkA "05AB1E – Try It Online")
[Answer]
# [R](https://www.r-project.org/), 57 bytes
```
function(s)all(nchar(n<-strsplit(s,'
')[[1]])==length(n))
```
An anonymous function; Splits on newlines, computes the length of each line, and checks if all are the same as the number of lines.
[Try it online!](https://tio.run/##JYhBCoAgEEX3c5GZgQra50nExRRZgYyhtunyZvh5nwcvVW@qf3QrV1TKLCGQbqck0mXMJeU7XIXygIBs7ewcGxN2PcpJylw94YQMTT5GWCW1vz1MbQDwqwcRgR/k@gE "R – Try It Online")
[Answer]
# [MATL](https://github.com/lmendo/MATL), ~~14~~ 12 bytes
```
10H&XXot&n=h
```
The input string is defined using string concatenation (`[...]`) and with the code point `10` to represent LF. For example, `['aaa' 10 'bb']` is interpreted in MATL as string `'aaa'` concatenated with the character with code point `10` concatenated with string `'bb'`.
The output is a non-empty numeric vector, which is [truthy](https://codegolf.stackexchange.com/a/95057/36398) if and only if all its entries are non-zero.
**[Try it online!](https://tio.run/##y00syfmf8N/QwEMtIiK/RC3PNuO/S8j/aPW0/Hx1BUMDBfWkxCIYo0o9lktdT50rWj0RBCDCRDJjgbr0IAJ6eggekAEWgogAAVgJRBVUnQkQQDQaGxtDGEZGYBk4H8SIBQA "MATL – Try It Online")**
### Explanation
Consider input `['4444' 10 '333' 10 '22']`.
```
10H   % Push 10 (code point of LF). Push 2
      % STACK: 10, 2
&XX   % Regexp with three arguments. First argument is implicit input (string);
      % second is 2, which indicates that we want to split the input; third is
      % 10, which is the character to split on. The result is a cell array of
      % matched strings
      % STACK: {'4444', '333', '22'}
o     % Concatenate into a numeric 2D array of code points, right-padding with
      % zeros if needed
      % STACK: [52 52 52 52; 51 51 51 0; 50 50 0 0]
t&n   % Duplicate. Push number of rows and number of columns
      % STACK: [52 52 52 52; 51 51 51 0; 50 50 0 0], 3, 4
=     % Are they equal?
      % STACK: [52 52 52 52; 51 51 51 0; 50 50 0 0], 0
h     % Concatenate into a row vector (in column-major order). Implicit display
      % STACK: [52 51 50 52 51 50 52 51 0 52 0 0 0]
```
[Answer]
# R, 35 bytes
```
all(nchar(x<-scan(,""))==length(x))
```
Takes input from stdin. Checks that the number of characters in each line is equal to the total number of lines. Returns `TRUE` or `FALSE` as appropriate.
[Answer]
# Ruby, 50 bytes
```
s=$<.read.split $/,-1;p [s.size]==s.map(&:size)|[]
```
[Try it online!](https://tio.run/##KypNqvz/v9hWxUavKDUxRa@4ICezRENFX0fXUNO6QCG6WK84syo11ta2WC83sUBDzQrE1ayJjv3/Py0/nyspsQqIiwA "Ruby – Try It Online")
## Explanation
1. Split input into array on newline.
2. Assert that an array containing only the size of this array is equal to an array containing all uniq (set union with empty array) sizes of all elements in this array.
[Answer]
# JavaScript (ES6), 48 bytes
```
s=>(a=s.split`
`,a.every(l=>l.length==a.length))
```
[Answer]
## CJam, 11 bytes
```
qN/:,_,f=:*
```
[Try it online!](https://tio.run/##S85KzP3/v9BP30onXifN1krr//9EIOACE0lAwJUMBAA "CJam – Try It Online")
[Answer]
# [OCaml](http://www.ocaml.org/), 56 bytes
```
let f t=List.(for_all(fun l->String.length l=length t)t)
```
[Try it online!](https://tio.run/##dY89DsIwDIVnegrLUzKQC1ThAiAxMFZVFYFTIpkUJeb8oUoLAz@DZT@97z3J09nduBQmAQ9iDyGLUX5Kg2NW/hGBt7uTpBBHwxRHuQLb9RAtugaVBttsXM6UZuGhQ2OwBTTYgwXvOJNuP4EFeU3V/2nsvwuW2C9ntd6rIvf5BxkoXjhEAjzusSlP "OCaml – Try It Online")
[Answer]
# Pyth, ~~12~~ 10 bytes
```
!fnl.zlT.z
```
Saved 2 bytes thanks to @FryAmTheEggman.
[Try it online](http://pyth.herokuapp.com/?code=!fnl.zlT.z&input=aaaaa%0Aaaaaa%0Aaaaaa%0Aaaaaa%0Aaaaaa&debug=0)
### Explanation
```
!fnl.zlT.z
 f     T.z     Filter lines of the input
  nl.zl        whose length is not the number of lines
!              and return whether there are no such lines.
```
[Answer]
# [QBIC](https://drive.google.com/drive/folders/0B0R1Jgqp8Gg4cVJCZkRkdEthZDQ), 43 bytes
```
{_?~_lA||h=h+1┘g=g+_lA|~g%_lA||_Xp]\_xg/h=h
```
Me, I'm happy with how short a QBasic derivative got to go on this challenge.
## Explanation:
```
{_?       DO infinitely: ask the user for input, store as A$
~    |    IF
 _lA|       The length of A$   (implicitly <> 0)
h=h+1     Add 1 to our line counter
┘         (syntactic linebreak)
g=g+_lA|  Add the length of this line to the running total of line lengths
~      |  IF
 g%_lA|     The length of the running total modulo the length of the last string
            yields anything but 0, there is a discrepancy between earlier line
            lengths and this one.
_Xp]      THEN QUIT, printing 0, end IF
\         ELSE (refers to the LEN(A$), user didn't input anything.
_xg/h=h   QUIT (the inf. loop) printing -1 if the root of the chars is the row count
            or 0 if not.
```
[Answer]
# Pyth, 7 bytes
```
qCC.z.z
```
[Demonstration](https://pyth.herokuapp.com/?code=qCC.z.z&input=foo%0Abar%0Abaz&debug=0)
Transpose the input with truncation twice, then check if the result is the same as the original.
[Answer]
# [Perl 5](https://www.perl.org/), 31 bytes
29 bytes of code + `-p0` flags.
```
/.*/;$_=/^(.{@{+}}
){@{+}}\z/
```
[Try it online!](https://tio.run/##K0gtyjH9r6xYAKQVdAsM/uvraelbq8Tb6sdp6FU7VGvX1nJpQuiYKv3//9Py87mSEouAuIoLAA)
**Explanations:**  
`/.*/` matches the first line, and thus makes `@+` contain the length of the first line. Then the regex checks whether the string contains `@+` lines of length `@+`.
[Answer]
# MacOS Bash, 34
```
rs -EH|awk '{print $1}'|uniq|wc -l
```
`rs` is part of the default MacOS image. This will also work on Linux if `rs` is installed; it is on TIO.
* `rs -EH` lists the length of each line, along with the number of lines
* `awk` strips out extraneous info
* `uniq` outputs one line if the line lengths and number of lines are all the same, but more otherwise
* `wc -l` outputs `1` if the input is square or a greater number otherwise.
Try it online: [Truthy](https://tio.run/##S0oszvj/v6hYQdfVoyaxPFtBvbqgKDOvREHFsFa9pjQvs7CmPFlBN@f//0QQ4MJBAgA), [Falsey](https://tio.run/##S0oszvj/v6hYQdfVoyaxPFtBvbqgKDOvREHFsFa9pjQvs7CmPFlBN@f/fxMg4DI2NuYyMgIA).
[Answer]
# [AWK](https://www.gnu.org/software/gawk/manual/gawk.html), 49 bytes
```
{s=length($0)}L{x+=L!=s}{L=s}END{print x?0:L==NR}
```
[Try it online!](https://tio.run/##SyzP/v@/utg2JzUvvSRDQ8VAs9anukLb1kfRtri22gdIuPq5VBcUZeaVKFTYG1j52Nr6BdX@/6@np8cFxQA "AWK – Try It Online")
Could also have used a `BEGIN` block to set `FS=""` but that would be the same byte-count. For some reason using the `-F""` argument never seems to work.
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 9 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
éΘ┌«■/ÉW(
```
[Run and debug online!](https://staxlang.xyz/#p=82e9daaefe2f905728&i=foo%0Abar%0Abaz%0A%0A.%0A%0A.+.%0A.++%0A.+.%0A%0A++%0A++%0A%0Aaaaaa%0Aaaaaa%0Aaaaaa%0Aaaaaa%0Aaaaaa%0A%0A..%0A.%0A.%0A%0A4444%0A333%0A22%0A%0A333%0A333%0A%0Aabc.def.ghi&a=1&m=1)
Turns out that due to way pairwise difference is calculated, I don't need to worry about the equivalence of `k` and `x-k` here. Saving 5 bytes.
Uses the unpacked version to explain.
```
Lc{%mc%+:u
L             Collect rows in a list
 c{%m         List of length of each row
     c%+      Append number of rows to the list
        :u    All elements in the list are equal
```
]