text:
Is this a half-sort?
The problem over here introduces an new type of strings: if you split the string into equal halfs and swap the pairs, it produces the same output as sorting the string. We call that a half-sort.
Given a purely ASCII string, check if the string is in a half-sort.
An example of a half-sort string
The string node is a half-sort string, because if you sort by codepoints (note that the codepoints are in decimal, not binary):
n 110
o 111
d 100
e 101

That gets turned into:
d 100
e 101
n 110
o 111

You'll see that the node to deno conversion is exactly moving the right half to the left position.
Specification

For odd-length strings, splitting should make the first half longer.
Sorting a string means sorting the string based on the codepoints of the characters.

Reference program & test cases
Here is the reference program I made for checking my test cases.
node -> True
rum  -> True
aaa  -> True

deno -> False
rim  -> False

Can we assume the triple back tick at the end of your test cases are meaningless and the result of a typo?

I'd suggest adding aaa as a truthy test-case.

I guess I know why this has a downvote... the challenge is too easy for golfing languages.

I think this challenge would be better if the input was guaranteed to have positive even length, rather than imposing the somewhat arbitrary specification that “splitting should make the first half longer” for odd-length inputs. I didn't vote down, though.

Brachylog, 5 bytes
oḍ↔c?

Try it online!
Outputs through success or failure.
o        The input sorted
 ḍ       and split in half (with the *second* half longer if the length is odd),
  ↔      with those halves reversed
   c     and concatenated,
    ?    is the input.

J, 20 18 15 14 bytes
-1 thanks to Jonah.
Goes the other way around: sorts the string ('node' -> 'deno'), rotates it back ('deno' -> 'node') and checks if this equals the input. Fits better J trains.
-:<.@-:@#|./:~

Try it online!
How it works
-:<.@-:@#|./:~
           /:~  sort input
  <.@-:@#       length of input, halved and floored
         |.     rotate sorted input by that amount
-:              input equal to that?

/:~ to save 1 byte

Python 3, 45 42 bytes
-3 bytes thanks to @dingledooper

lambda s:sorted(s)==s+[s.pop(0)for c in s]

Try it online!
Takes input as a list of characters. Returns True if the list is half-sorted, False otherwise.
How
[s.pop(0)for c in s] gets the first half of the list. After this is evaluated, s only has the later half left.
Thus s+[s.pop(0)for c in s] is the list with the 2 halves swapped. Note that this works because Python evaluates anything inside square brackets first.
I then check if the swapped list is sorted, aka compare it with sorted(s).

@dingledooper Thanks, I might have done something wrong when trying it for the first time.

Using undefined behaviour in Python (modifying a sequence during iteration over said sequence). Thanks, I hate it! +1

Pyth, 8 bytes
qSzs_c2z

Try it online!

Luckily, Pyth offers most of what we need out of the box, so we just need to call the operations necessary.
 Sz       # Sort the input
     c2z  # Chop the input into two equal pieces (first longer if needed)
    _     # Reverse the chopped elements
   s      # Join them back together
q         # Check for equality

perl -plF//, 49 bytes
push@F,splice@F,0,(@F+1)/2;$_="@F"eq"@{[sort@F]}"

Try it online!
Splits a line of input into characters, which are placed in @F. We remove the first half and tag it to the end. We then check whether the array is the same if we sort it -- if the result is the same, the string was a half sort, if not, it wasn't.
Outputs 1 for a half sort, the empty string when not.

You can shave a byte off your score by using splice@F,0,.5+@F/2 instead of splice@F,0,(@F+1)/2, methinks.

Jelly, 6 bytes
ŒHṚFṢƑ

A monadic Link accepting a list of characters which yields 1 (truthy) if a half-sort and 0 (falsey) otherwise.
Try it online!
How?
Fairly straightforward in Jelly, pretty much just implements the challenge specification directly...
ŒHṚFṢƑ - Link: list of characters (full Unicode, but works with ASCII only too)
ŒH     - split it into two halves (first half 1-longer if odd in length)
  Ṛ    - reverse
   F   - flatten back to a list of characters
     Ƒ - is invariant under?:
    Ṣ  -   sort

05AB1E, 7 bytes
{I2äRJQ

Try it online or verify all test cases.
Explanation:
{        # Sort the characters in the (implicit) input
 I       # Push the input again
  2ä     # Split it into 2 equal-sized parts (first part will be longer for odd lengths)
    R    # Reverse this pair
     J   # Join them back together to a string
      Q  # And check if both strings are equal
         # (after which the result is output implicitly)

You always used s to swap up an input; what makes you change your style all of a sudden?

@Λ̸̸ I did? A lot of other people do that for 05AB1E answer, but I usually use the input. Actually, you might be right I did so in the past, so the TIO and test suite use the same code section. In this case I could also use 2äRJD{Q or 2ä`ìD{Q to accomplish that I guess. :)

Hmm I was wondering if there would be a way to {œ and check the index of the input string but I can't seem to find the equation easily for the position of the half sorted string in this (although it should be constant right?)

@ExpiredData So it starts with {œIk and you then want to check whether that value equals a certain value based on the input-length? It certainly won't be shorter than 7 bytes, but I also can't find this sequence on oeis.org unfortunately.

@ExpiredData And using the sorted input as index in the permutations of the input, unfortunately also cannot be found on oeis.org.

You actually don't need I here. 6 bytes

@Memberfor3months Umm.. yes I do. It may coincidentally work for node, but it doesn't work for rum nor rin. :)

Charcoal, 22 bytes
≔⪫⮌⪪θ⊘⊕Ｌθωθ¬⊙θ∧κ‹ι§θ⊖κ

Try it online! Link is to verbose version of code. Outputs a Charcoal boolean, i.e. - for true, nothing for false. Explanation:
≔⪫⮌⪪θ⊘⊕Ｌθωθ

Split the string into half, reverse, and join.
¬⊙θ∧κ‹ι§θ⊖κ

Check whether any characters are less than their predecessor.

Python 3.8,  68  46 bytes
lambda s:sorted(s)==s[(h:=-~len(s)//2):]+s[:h]

An unnamed function accepting a list of characters which yields True if a half-sort and False otherwise.
Try it online!

Turns out the straightforward way is terser!
Original 68 byter in Python 2:
lambda s:all(i==~-len(s)/2for i in range(len(s))if(s[1:]+s)[i]<s[i])

Try it online!

I think the consensus is that character array is an acceptable form of string.

Ruby, 33 bytes
->a{a.rotate(-~a.size/2)==a.sort}

Try it online!
Takes input as an array of characters (which feels like cheating). Simply rotates the array by half its length and checks whether this is equal to the sorted array.

APL+WIN, 39 36 bytes
Prompts for input of string:
(⍴s)=+/1,2≤/⎕av⍳(-⍴s)↑s,(⌈.5×⍴s)↑s←⎕

Try it online! Courtesy of Dyalog Classic
Explanation:
(⌈.5×⍴s)↑s take the front half of the string rounding up for odd number length

(-⍴s)↑s,prepend the original string and take trailing characters up to
the original length of string

⎕av⍳ get code points

(⍴s)=+/1,2≤/ check that successive code points are ascending, sum the
 result and compare to length of string; equal = 1 = true, not equal = 0 = false

C (gcc), 82 81 bytes
i;e;r;l;f(char*s){l=strlen(s);for(r=1,e=i=~-l/2;++i%l-e;)r&=s[-~i%l]/s[i%l];e=r;}

Try it online!

Clojure, 48 bytes
#(=(sort %)(flatten(reverse(partition-all 2%))))

Try it online!

Vyxal, 5 bytes
s½Ṙ∑=

Try it Online!
s     # Input Sorted
 ½    # Split into two halves
  Ṙ∑  # And concatenated reversed
    = # Equals original input?


text:
Complete a sequence using its distances
Given \$A = (a_1,\dots,a_k)\ k\ge2 \$ a sequence of positive integers, in which all elements are different.
Starting from \$i=2\$, while \$a_i\in A:\$ (until the last element)

If \$d=|a_i-a_{i-1}|\$ is not already in \$A\$, append \$d\$ to \$A\$
Increase \$i\$

Output the completed sequence.
This is code-golf
Example
In:  16 21 11 2

     16 21 11 2 5
      --^
     16 21 11 2 5 10
         --^
     16 21 11 2 5 10 9
            --^
     16 21 11 2 5 10 9 3
              --^
     16 21 11 2 5 10 9 3
                --^
     16 21 11 2 5 10 9 3 1
                   --^
     16 21 11 2 5 10 9 3 1 6
                     --^
     16 21 11 2 5 10 9 3 1 6
                       --^
     16 21 11 2 5 10 9 3 1 6
                         --^
Out: 16 21 11 2 5 10 9 3 1 6

You should explain stopping and simply not appending more clearly then. For me it reads to stop doing anything.

@Noodle 9 The if condition is inside a while loop that continues until the index reaches the last element in $A$. I can't say while $i\le k$ because $A$ will probably get extended with new element, so the condition has to be while $a_i \in A$

Yeah, sure I see that now. But questions are always better when they're totally clear.

@Noodle 9 I left the post in the sandbox for a few days, and I though it was fine

I couple of weeks is recommended so all these warts can be sorted out.

@DomenicoModica Your new wording, "without repetition", can still be interpreted as "without contiguous elements being equal". If you mean "all elements are different", write it like that, or with a similar unambiguous phrase

@Luis Mendo Oh, right, I used the definition found on Wikipedia

@DomenicoModica Maybe it's just me. But I think it's clearer now

@LuisMendo If you don't mind, take a look at the related challenge in the Sandbox

@DomenicoModica Sure. I added some comments. I'm not sure if I understood the problem correclty; please disregard any comment that doesn't apply

Can we display a meaningless value at the start? (see my answer) I think it would be valid in term of "outputting the completed sequence"..

05AB1E, 6 5 bytes
Δ¥Ä«Ù

Try it online!
Δ         until the output doesn't change:
 ¥Ä           absolute differences
   «          concatenate to the original input
    Ù         only keep unique values

You beat me to it. I was about to post an answer.. Only difference is that I had üα instead of ¥Ä. :)

@KevinCruijssen Apparently this wasn't optimal, since all differences are computed in every iteration, we can just concatenate with the original input.

Oh, I wouldn't have thought of that, but you're indeed correct. Nice golf!

Python 2, 57 bytes
l=input()
d=0
for i in l:l+={abs(d-i)}-set(l);d=i
print l

Try it online!

48 bytes in Python 3 by mutating the input: Try it online!

Ruby, 40 bytes
->a,i=0{a|=[(p(a[i])-a[i+=1]).abs];redo}

Try it online!
Takes an array a as input and adds unique new elements to it using the set append operator |=. Terminates by throwing a rescuable TypeError (which is now allowed) when attempting to subtract beyond the last element of the array. By that point all of the required output has already been printed to STDOUT.

Ruby, 48 bytes
->a,i=0{a|=[(p(A).-a[i+=1]||0).abs]while A=a[i]}

Try it online!
This version avoids the TypeError at a cost of 8 bytes.

J, 17 16 bytes
(~.@,2|@-/\])^:_

Try it online!
How it works
(~.@,2|@-/\])^:_
(           )^:_   until output does not change
     2   /\]       for each neighboring pair
      |@-          get the absolute difference
    ,              append the result to the list
 ~.@               and remove duplicates

R, 68 57 bytes
v=scan();while(any(F-(F=v)))v=unique(c(v,abs(diff(v))));v

Try it online!
Edit: -9 bytes thanks to Giuseppe, and -2 more from (F-(F=v)) (had to be tested to see whether that would work...)
Boringly follows the instructions in the question, in the same order...

64 bytes keeping your recursive function or 63 bytes with a while loop. I think taking input from scan() while using a while loop would also save bytes.

Thanks Giuseppe!  ...and I even managed to squeeze-out 2 more...

APL (Dyalog Unicode), 14 bytes SBCS
{⍵,⍵~⍨|2-/⍵}⍣≡

Try it online!
Same method as the J answer; I came up with this on my own :) also ended up being 3 bytes shorter, at least atm.

f 2 3 4 5 return 2 3 4 5 1 1 1 0 0

You can fix ^ and shorten the code by replacing ⍵,⍵~⍨ (set difference then concat) with ∪⍵, (concat then unique). Try it online!

Perl 5 -pl, 58 bytes
$d=abs$a[$;]-$a[++$;],/\b$d\b/||s/$/ $d/ while(@a=split)>$

Try it online!
Ungolfed:
# with -pl the special var $_ is initialized with the input line string
while(
       @a = split    # array @a = the numbers currently in the $_ special var
   and $i++ < @a     # and the $i index (counter) is less than the length of @a
                     # in the golfed version $; is used instead of $i
){
  $d = abs $a[$i] - $a[$i-1] # $d = non-zero absolute diff btw element $i and $i-1
  and !/\b$d\b/              # and $d unseen before? \b is "borders" around digits
  and s/$/ $d/               # and if so append space and $d to $_
}
# with -pl the current $_ and \n is printed

Run:
$ echo 16 21 11 2 | perl -pl program_58_bytes.pl
16 21 11 2 5 10 9 3 1 6

Save two bytes by replacing and with ,. One byte by removing the ! and replacing the && by a ||. And another byte by using split instead of /\d+/g. Try it online!

Thanks @Abigail ! This makes Perl beat JavaScript for once :-)

Nice one! I kept playing with -F and List::MoreUtils but couldn't get a shorter solution! Another couple of minor changes can save you three more bytes: move the ++ to where you currently have $i-1, use $; instead of $i and reverse the condition of the while to use the implicit ; added by -p: Try it online!. Also, you probably need to acknowledge that it's Perl 5 + `-pl` in the header...

Thanks to @DomHastings also. The implicit ; feels almost too nasty, but in war and golf... :-)

Gaia, 9 bytes
e⟨:ọȯ¦|⟩°

Try it online!
Note that the documentation states that ȯ is sign of z when z is a numeric type, but it's actually abs...
e		# eval input as Gaia code (push as a list)
 ⟨	⟩°	# until there's no change:
  :		# dup the list
   ọ		# take the differences
    ȯ¦		# take the absolute values
      |		# and set union

Jelly, 8 7 bytes
;IAQƲÐL

-1 byte thanks to @JonathanAllan.
Try it online.
Explanation:
         # Full program taking a single list argument
     ÐL  # Repeat until the result no longer changes,
    Ʋ    # using the previous four links as monads:
 I       #  Get the forward differences of the current list
  A      #  Take their absolute values
;        #  Merge it to the current list
   Q     #  And uniquify it
         # (after which it is output implicitly as result)

Either of ÐL or ƬṪ do what ÐĿṪ does (first one is a built-in for it, second uses the Ƭ alias for ÐĿ). I may have gone with ;ạƝQƊÐL.

@JonathanAllan Ah oops, I copied the wrong one apparently from the Quicks wiki page.. Not sure how that happened.. :S Thanks for the -1, I will use ÐL! As for Ɲ, is that something like apply on overlapping pairs (similar as ü in 05AB1E)? I can't find Ɲ in neither the Atoms nor Quicks wiki pages though, so I guess it's rather new?

It's on the quicks page "Apply a dyadic link or a monadic chain for all pairs of neighbouring elements".

@JonathanAllan Wth.. my Ctrl+F function just yet gave no results for sure, I even tried it twice by copying the Ɲ from your first comment. :/  But it's indeed there. I'm really confused about Google Chrome rn.. Ah well, thanks for the -1.

perl -M5.010 -a, 79 bytes
@F{@F}=@F;{$d=abs($F[0]-$F[1]);$F{$d}++or$F[@F]=$d;say shift@F;@F>1&&redo}say@F

Try it online!
Reads in a line of input, with the integers space separated. Outputs the sequence with each number on a different line.
How does it work? It gets the input in the array @F (due to the -a command line argument). In the hash %F it stores the numbers already in @F (here we use the given that all numbers in sequence are positive integers†). Then, in a loop, we find the distance between the first two elements of @F; if not seen before, we add it to @F (and %F). We then remove the first element of @F and print it. We exit the loop if only one element is left, which is printed just before exiting the program.
†The sequence can never contain a zero, as that requires two subsequent elements to be the same, but that is not allowed.

Charcoal, 21 bytes
Ｗ⁻Ｅθ↔⁻κ∧λ§θ⊖λθＦι⊞θκＩθ

Try it online! Link is to verbose version of code. Explanation:
Ｗ⁻Ｅθ↔⁻κ∧λ§θ⊖λθ

Generate the absolute differences between adjacent elements of the input and filter out those appearing in the input.
Ｆι⊞θκ

While there were any new values, push them to the input and repeat.
Ｉθ

Output the result.

K (Kona), 14 bytes
{?x,_abs-':x}/

Try it online!
Similar to J and APL answers.

Japt -h, 10 6 bytes
£=âUäa

Try it
£=âUäa     :Implicit input of array U
£          :Map
 =         :Reassign to U, for the next iteration
  â        :Setwise union of U and
   Uä      :Consecutive pairs of U
     a     :  Reduced by absolute difference

Wolfram Language (Mathematica), 57 51 46 bytes
-11 bytes thanks to att!
#//.a_:>Keys@Counts@Join[a,Abs@Differences@a]&

Try it online! Pure function. Takes a list as input and returns another list as output. It just repeatedly appends the absolute differences to the end of the list and removes duplicates, until the list no longer changes.

51 bytes

DeleteDuplicates@ -> Keys@Counts@ for 46

Pyth, 10 bytes
u{+GaM.:G2

Try it online!
u{+GaM.:G2
u            Apply inner function until a repeat is found, current value G, starting with input
      .:G2     Find all sublists of length 2
    aM         Absolute difference between each pair
  +G           Append to G
 {             Deduplicate
             Implicit print

Wolfram Language (Mathematica), 50 bytes
#//.l:_[___,b_,a_,___]:>l<>d/;FreeQ[l,d=Abs[b-a]]&

Try it online!
Takes a sequence with any head. If the sequence is already complete, returns it unchanged. Otherwise, returns the completed sequence in a StringJoin.
<> (StringJoin) is short, flattens Lists, does not operate on integer (non-string) arguments, and is Flat. It's also not Orderless, so can store ordered data.
      _[             ]                           (* match a nonatomic expression with any head, *)
    l:                                           (*  and name it l. it contains: *)
            b_,a_,                               (*   two adjacent numbers, b,a, *)
        ___,      ___                            (*   as close to the front as possible, *)
                            /;                   (* subject to the condition that *)
                              FreeQ[l,d=Abs[b-a] (*  |b-a| is not in l. *)
#//.                  :>l<>d                     (* while the condition holds, append |b-a|. *)

Raku, 45 bytes
{|$_,{|keys abs([-] @_[++$,$++])∖@_}...^!*}

Try it online!
Explanation
{                                         }    # Anonymous codeblock
                                    ...        # Generating a sequence
 |$_,                                          # Starting with the input
     {                             }           # Where we add to the sequence
            abs([-]            )               # The absolute difference
                    @_[++$,$++]                # Of the next pair of elements
      |keys                     ∖@_            # Set subtracting the sequence
                                    ...!*      # Continue until we run out of pairs

APL(NARS), 22 chars, 44 bytes
{⍬≡k←∪⍵∼⍨∣2-/⍵:⍵⋄∇⍵,k}

test:
  f←{⍬≡k←∪⍵∼⍨∣2-/⍵:⍵⋄∇⍵,k}
  f 16 21 11 2
16 21 11 2 5 10 9 3 1 6
  f 2 3 4 5
2 3 4 5 1

Factor + math.unicode, 47 bytes
[ [ dup differences vabs ∪ ] to-fixed-point ]

Try it online!
Explanation

[ ... ] to-fixed-point Do [ ... ] to the input until it stops changing.

               ! { 16 21 11 2 }
dup            ! { 16 21 11 2 } { 16 21 11 2 }
differences    ! { 16 21 11 2 } { 5 -10 -9 }
vabs           ! { 16 21 11 2 } { 5 10 9 }
∪              ! { 16 21 11 2 5 10 9 }   (set union)
               ! (etc...)

Uiua SBCS, 14 bytes
⍥(◴⊂:⌵↘1°\+.)∞

Try it!
⍥(◴⊂:⌵↘1°\+.)∞
⍥(          )∞  # to fixed point
           .    # duplicate
      ↘1°\+     # differences
     ⌵          # abs
   ⊂:           # append
  ◴             # deduplicate

J-uby, 36 bytes
:!~&:|%(~:each_cons&2|:*&(+:-|:abs))

Attempt This Online!
Explanation
:!~ & :| % (~:each_cons & 2 | :* & (+:- | :abs))
:!~ &                                             # Until fixed point...
      :| % (                                   )  #   Union of input and...
                                    +:- | :abs    #     absolute differences of...
            ~:each_cons & 2 | :* & (          )   #     consecutive pairs

PowerShell Core, 73 bytes
for($t=$args;$t[$i+2]){$t+=,($d=$t[$i++]-$t[$i]-replace'-')*!($d-in$t)}$t

Try it online!

Java (JDK), 90 bytes
l->{for(int i=0,v;i+1<l.size();)if(!l.contains(v=Math.abs(l.get(i++)-l.get(i))))l.add(v);}

Try it online!

PHP, 96 78 bytes
for($a=$argv;$n=$a[++$i];print"$n ")in_array($v=abs($n-$a[$i+1]),$a)?:$a[]=$v;

Try it online!
EDIT: 18 bytes saved with the help of Domenico Modica, thanks!

16 bytes saved without array_shift and without outputting the script name :D.

@DomenicoModica Nice! Also removed the brackets, print doesn't need them

JavaScript (ES6), 63 bytes
f=(a,i=0)=>(v=a[i]-a[++i])?f([...new Set(a).add(v>0?v:-v)],i):a

Try it online!

Io, 59 bytes
Port of the Python 2 answer.
method(x,a :=0;x foreach(i,x=x push((i-a)abs)unique;a=i);x)

Try it online!

Retina, 84 68 66 bytes
Edit: Saved 16 18 bytes thanks to @Neil !! This answer is now mildly competitive :P
\d+
*
^
#
{`#( _+)(_*)(\1(_*).*)
$1$2#$3 $2$4
)D` _+
^ |#

_+
$.&

Try it online!
Not the shortest answer to this question, but it was fun to golf anyway :)
Explanation
\d+
*

Convert each input number to unary (using _'s)
^
#

Insert a # at the start of the input
{`
)`

Run the following 2 stages in a loop until the input stops changing:
#( _+)(_*)(\1(_*).*)
$1$2#$3 $2$4

Take the two numbers to the right of the # and remove the maximal number of _'s from each. This results in the absolute difference between the two numbers. Append this result to the end of the list.
D` _+

Deduplicate. If the number that was just added matches a number already in the list, remove it.
^ |#

_+
$.&

Once the loop breaks, remove the # and leading space, and convert back to decimal

I didn't think to try this in Retina, but now you've answered it, I think you can save 4 bytes by performing the subtraction as you match the two values, and more usefully I think you can save a massive 13 bytes by using a Deduplicate stage.

@Neil Wow, thanks! I might have missed something though because I ended up with 68 bytes rather than 67

I didn't have the \b on the Deduplicate; I don't know whether that's an error in my code. On the other hand, if that works, that makes yours 66! Your byte saving came from having the space inside $1 - I erroneously had it outside, so my other golfs were only able to bring the score down to 67.

(Oh, and your loop only has 2 stages now.)

Looks like that works! I had misunderstood how the Deduplicate stage was working

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Magic Square, Magic Code
A magic square is an \$ n \times n \$ square grid, such that the sum of the integers on each row and column are equal. Note that the definition which will be used in this challenge is different than the one used by Wikipedia, since

diagonal sums are not accounted for
the numbers are not required to be distinct or in the range \$ 1, 2, ..., n^2 \$

Task
Write a program/function such that given an \$ n \times n \$ square, return Truthy if it is a magic square, and Falsey otherwise. There is a catch, however. The source code itself must also form a magic square, where each character in the source code corresponds to its Unicode codepoint.
Rules/Clarifications

You may take input in any reasonable format (e.g. 2D array, flattened list, etc.)
The source code should be a list of \$ n \$ strings, each consisting of \$ n \$ characters, joined by newlines.
The unicode character should be in its composed representation.
Here is a program to check if your program/function is a magic square

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

Related.

Unicode characters can have multiple representations (composed, de-composed). If the source code has, say À, is that codepoint U+00C0 (LATIN CAPITAL LETTER A WITH GRAVE) or codepoints U+0041 U+0300 (LATIN CAPITAL LETTER A COMBINING GRAVE ACCENT)?

@Abagail I suppose it would have to be the composed character.

I suspect this has the same problem as this recent question had: programs are made of bytes not characters. The current answer you have could also equivalently be given by another program as you can see here (sorry it's a pastebin). Would the bytes of a program interpreted in any code page be a valid choice? I don't think this is clear as it is.

@FryAmTheEggman I agree. And it's not just bytes, it's a linear stream of bytes, while the question is about representation. For pure ASCII text, I don't see much problems, but in Unicode, it's difficult. Unicode has composed and decomposed characters, but not all decomposed combinations have a composed form. How does, say ́ (NEUTRAL FACE COMBINING ACUTE ACCENT) line up? It's one grapheme, 2 Unicode characters, and multiple bytes (how many will depend on the encoding (UTF-8, UTF-16, something else)). How many columns in your program does it take?

I assumed (from the checker code) that we must split our code at newline characters, but the post does not actually state that is what we are to do. (I imagine that for a subset of programs a code-page choice would still possible with that stipulation, but stating that would vastly reduce the possibility I believe.)

The presence of a checker program renders and unclarity in the rules about what source code is valid irrelevant.

@pppery So, people are to reconstruct the rules based on program in a language they may not be familiar with? I can't deduce from the source code whether it's grouping columns by byte, character or grapheme. The fact the example input only uses ASCII where one grapheme is one character is one byte doesn't clarify anything. An example with zero-width characters, combining characters and wide characters would be useful.

This may be a badly specified challenge, but the existence of a checking program nevertheless means it is possible to unambiguously determine whether or not a given answer is valid, so the challenge should not be closed as "Needs details or clarity"

@dingledooper Your checker program strips all white spaces on the right of each line, but some magic square might intentionally have spaces or tabs after each line.

@SurculoseSputum The checker should be fixed now.

@pppery Possible, yes. But it will then be game of "I guess this might be right, let's check". You cannot reason what your program should look like. It's not even clear what encoding the checker program assumes (UTF-8?, UTF-16? UCS-2? Big-Endian? Little-Endian?)

The outputted magic square should be a list of  strings - I'm confused by this. The program outputs truthy or falsy. What output does this refer to? Does it mean the source code itself? Or the input?

@Abigail I'm not disagreeing with you (and I downvoted the challenge), but that doesn't make the challenge unclear.

@SteveBennett Sorry, that should say the source code. Fixed now.

05AB1E, 11 bytes
Executed code is the same as this answer. I was extremely lucky all the required characters were in the 05AB1E codepage.
ø«O
Ëq¶
/Öí

Try it online! Verify it!

The only answer here that has spent time making the magic square! +1

@Memberfor3months Not true, I spent quite some time trying things out for a smaller square than the one I posted, using calls to previous & next Links.

Jelly, 19 bytes
§E;Z
Z;E§
E§Z;
;Z§E

A monadic Link which yields 1 if the argument is a magic square as per the definition and 0 otherwise. Also works as a full program which prints the result (the first three helper links are actually unused).
The sums of the diagonals of the Unicode characters in the code are also equal to the row and column sums (385).
Try it online!
How?
;Z§E - Main Link: list of lists of numbers, M
 Z   - transpose M
;    - M concatenated with that
  §  - sums
   E - all equal?

05AB1E, 29 bytes
Just a port of the Jelly answer.
ø«OËq
qø«OË
Ëqø«O
OËqø«
«OËqø

Try it online!
Explanation
ø     Transpose the input
 «    Concatenate with the original input
  O   Sum (vectorizes over sublists)
   Ë  Are these sums all equal?
    q Exit the program (to create a garbage dump)

Now we got a HUGE garbage dump over here.

qø«OË
Ëqø«O
OËqø«
«OËqø

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Draw the NASA worm logo
Introduction
On 30 May 2020, NASA and SpaceX launched a crewed rocket to the international space station on the SpaceX Demo 2 mission. This is the first time humans have been launched into orbit from American soil since the retiring of the Space Shuttle in 2011, and the first time ever that a private company has launched astronauts into orbit. The rocket bore the iconic NASA worm logo, the first time this logo has been used since 1992. Let's celebrate NASA and SpaceX's achievement by drawing the worm logo.
I looked on the internet for a specification of this logo. The best I could find was on Reddit. However there are a number of issues with this version. For example the thickness of vertical and curved lines is defined as 1 but for horizontal lines it is 0.95 and there is no specification of how to transition between the two thicknesses.
Challenge
Draw the simplified version of the NASA worm logo defined in the SVG below.
Some notes on the design:

All parts of the worm are 100 units wide.
All diagonal lines have a slope of 24/7. This takes advantage of the pythagorean triple 24^2 + 7^2 = 25^2 to ensure accurate and consistent positions of the thickness of the worm and the beginnings and endings of arcs while using only integer coordinates.
As the vertical height of the arms of the A's are not multiples of 24, the x coordinates of the bottoms of the A are not integers, but they are integer multiples of 1/6.
The S is 500 units high, from y=100 to y=600. The curved parts of the S have internal and external radii of 50 and 150.
The internal and internal radii of the curved parts of the N and A's are 25 and 125. The y coordinates of the centres of these arcs are y=215 and y=485. This means that the tops and bottoms of the arcs extend above and below the top and bottom of the S, specifically to y=90 and y=610. This is similar to the official logo.
The ends of the N terminate at y=100 and y=600. Similarly, the ends of the A's terminate at y=600.
There is an overlap region between the first A and the S. The length of the upper and lower arms of the S is chosen to be 231.67 units so that this overlap region is triangular. The top of the lower arm of the S meets the A at 1043.33,600
In addition to the SVG script, A PNG image (not perfectly to scale) is given with annotations of the coordinates of all parts of the logo: all four coordinates of each straight section and the centre and radius of each curved section. Note that because of the way SVG defines arcs, the coordinates of the centres of the curved sections do not appear in the SVG script. Curved sections are shown in black and straight sections are shown in red, with the exception of the lower arm of the S, which is shown in blue to distinguish it from the part of the A which it overlaps.

PNG

SVG

<svg xmlns="http://www.w3.org/2000/svg" viewbox=0,0,2000,700>

<path fill="red" d="M110,600 L110,215 A125,125,0,0,1,355,180 L446,492 A25,25,0,0,0,495,485 L495,100 L595,100 L595,485 A125,125,0,0,1,350,520 L259,208 A25,25,0,0,0,210,215 L210,600"/>

<path fill="red" d="M587.5,600 L710,180 A125,125,0,0,1,950,180 L1072.5,600 L968.33,600 L854,208 A25,25,0,0,0,806,208 L691.67,600" />

<path fill="red" d="M1043.33,500 L1275,500 A50,50,0,0,0,1275,400 L1175,400 A150,150,0,0,1,1175,100 L1406.67,100 L1406.67,200 L1175,200 A50,50,0,0,0,1175,300 L1275,300 A150,150,0,0,1,1275,600 L1043.33,600"/>

<path fill="red" d="M1407.5,600 L1530,180 A125,125,0,0,1,1770,180 L1892.5,600 L1788.33,600 L1674,208 A25,25,0,0,0,1626,208 L1511.67,600" />

</svg>

Rules
The logo shall be in a single arbitrary colour on a distinctly coloured background.
The accuracy of the logo shall be within +/- 2 units of the specification given in this question.
It is not essential to use the coordinate system used in the specification given in this question. The logo may be rescaled, and different amounts of whitespace may be added above, below, left and right, so long as the logo can be visualized easily with free and easily available software. The logo may not be rotated.
The logo may be drawn filled, or as an outline. The first A and the S overlap slightly. If drawn as an outline, it is preferred that the lines at the overlap of these two letters are omitted, so that the A and S form a single continuous outline. It is however permitted to include the complete outline of the A and/or the complete outline of the S, with the shape specified in the PNG and SVG in the question. No other extraneous lines are permitted.
Any pre-existing graphics format is acceptable provided it can be viewed with free and easily available software. Any means of output accepted by standard rules on this site is acceptable, inlcuding viewing on the screen, output to a file, or (if applicable) as a returned value from a function call. Please Include instructions on how to view your output in your answer. Your program or function should take no input.
It is not acceptable to use a font with letters of the correct or similar shape to print "NASA", with or without modification. (In practice this is unlikely to be an issue, because although there are similar fonts, I think it's very unlikely that the letters match the proportions specified in this question.)
This is codegolf. Shortest code wins.

Looking at the NASA Graphics Standards Manual, their main advice is that "the NASA logotype should be reproduced photographically whenever possible." They do provide a large version against a grid on p. 1.7, but leave out any numbers, if they exist.

@LegionMammal978 despite its modern look this logo was designed in the 70's when there was very little in the way of electronic reproduction. I'm familiar with that manual, and I think some of the curves (especially on the N) aren't simple radii. That's why I did my own simplified design, based loosely on the Reddit construction. There's a precedent for this type of simplification on this site. For example there was a question on the google "G" (single character, multicolour) logo that was simplified to make it easier to specify and to golf.

Does a program which just prints "NASA" qualify, assuming an appropriate font has been installed? (Not that I know of such a font.)

@Abigail that's an interesting point and there is a font called Nasalization based on the NASA logo, but I don't think it matters because the shape of the letters will almost certainly be out of spec (as will the spacing.) In any case thanks fo bringing it up. I'm going to say no, you can't use such a font.

SVG (HTML 5), 370 bytes

<svg viewbox=0,0,240,64 fill=none stroke=red stroke-width=12.5><path d=M82,62V11M180.4,62V11 transform=skewX(-17) /><path d=M90.8,62V11M189.2,62V11 transform=skewX(17) /><path stroke-width=12 d=M6,62V15.8A9,9,0,0,1,23.6,13.3L34.6,50.7A9,9,0,0,0,52.2,48.2V2M78,13.3a9,9,0,0,1,16.8,0M112,56H139.8a12,12,0,0,0,0,-24h-12A12,12,0,0,1,127.8,8H155.6M176.4,13.3a9,9,0,0,1,16.8,0

Based on my optimised answer, but drawing the logo as a stroked path rather than an outline, which takes a few more bytes to set up but requires fewer drawing operations. Edit: Original version was clipped incorrectly. Hopefully this one is nearer to the original.

@Arnauld I originally used square line caps but when I tweaked the answer to use the default butt line caps I forgot to adjust the S. Should be fixed now.

@LevelRiverSt I'd tried to convert some absolute coordinates to relative coordinates in my other answer and got one of my sums wrong, which then also threw off this answer. Should be fixed now.

Here's a path per the original spec at the original scale and coordinates (correct except the bottoms of the A's are sloped) stroke-width="100" d="M160,600 V215 A75,75,0,0,1,307,194 L398,506 A75,75,0,0,0,545,485 V100 M639.58,600 L758,194 A75,75,0,0,1,902,194 L1020.42,600 M1043.33,550 L1275,550 A100,100,0,0,0,1275,350 L1175,350 A100,100,0,0,1,1175,150 L1406.67,150M1459.58,600 L1578,194 A75,75,0,0,1,1722,194 L1840.42,600" If you want to copy this, note that stack exchange inserts special characters at new lines in comments so you may have to remove them.

I did a transform=scale(8.333333 8.333333) translate(13.2,12) on your answer and overlaid it on my original SVG. some of your Y coordinates are a little off. Per the question the curves of the N and A's are supposed to extend 10 units above and below the S. You have the the top curve of the N starting and finishing 10 units lower than it should be and the bottom 10 units higher. The curves of your A's start and end at Y=196.666 instead of 194. That's out by 2.666 so nearly within tolerance, but the tops are clipping on the bounding box, which should be expanded upwards to make space for them

The bottom of the bounding box should be expanded downwards to make space for the curve of the revised N. Unfortunately this means the bottom of the A's should be clipped in a different way. Your X coordinates are good though. The tops of the A's are exactly at +/- 2 units (per original scale) tolerance. I didn't check the bottoms of the A's but everything else is good.

@LevelRiverSt Ugh, that was a pain, but I translated everything down by 2 so that I could fix the N. I've had to manually guess the new A measurements, except for the curved tops, which should be correct now.

HTML / JS, 406 bytes
A RegPack'ed version of the reference SVG with slightly rounded values and uppercase keywords so that the full range [Y-k] is available for compression.

<script>for(_='5,k00jjLi9k1i5h9k485gi1f1f407,e15d7kc0,bbbab180`jA5b5aa1_,6^,208]jAdbdab1,1[A2k2kabZA12k12ka1,Y<SVG VIEWBOX=a2jb7j><PATH D=M110^f1b2dY35k180L446,492Z4gL4hhgY35b520L259]Z21b2dL210^jM587^i71`Y95`L1072^i968^i854]Z806]L692^jM1043,5f2c5_2c4f1c4[1cee2f1c2_1c3f2c3[275^f043^jM1407^id3`Y177`L1892^f788^f674]Z1626]Ld12^j>';G=/[Y-k]/.exec(_);)with(_.split(G))_=join(shift());document.write(_)</script>

Huh, I never knew JavaScript had a with statement

Wolfram Language (Mathematica), 342 bytes
a=#~Partition~2&;b=ToCharacterCode;c=Disk;d=Pi/2;e=ArcTan[24/7];Graphics[Thread/@{Cuboid@@@a[2a@b@"ê?êįĦHș?ʾʂ·ʾ{ʂį̍ó"],Parallelogram[a@b@"ĦfɃЌ؛ߤ",a@a@b@"ĒȭĒĨʍĒʍĒĨʍĒʍ"-149],c[f=6a@b@"NINĵN",150,{{d-e,2d},{-d-e,0},g={d-e,d+e},g}],c[h=6a@b@"êÖG",180,a@{-d,d,d,3d}],White,f~c~30,h~c~60}]&

Pure function. Takes no input and returns a Graphics object as output. In a Mathematica notebook, the output is automatically rendered to the screen. It can be seen in this Wolfram Cloud notebook; a screenshot is shown below.

Some 1-pixel gaps may be visible, but those are just artifacts of the vector graphics. Also, several unprintable characters are used for compression, so here's a UTF-8 hexdump:
00000000: 613d 237e 5061 7274 6974 696f 6e7e 3226  a=#~Partition~2&
00000010: 3b62 3d54 6f43 6861 7261 6374 6572 436f  ;b=ToCharacterCo
00000020: 6465 3b63 3d44 6973 6b3b 643d 5069 2f32  de;c=Disk;d=Pi/2
00000030: 3b65 3d41 7263 5461 6e5b 3234 2f37 5d3b  ;e=ArcTan[24/7];
00000040: 4772 6170 6869 6373 5b54 6872 6561 642f  Graphics[Thread/
00000050: 407b 4375 626f 6964 4040 4061 5b32 6140  @{Cuboid@@@a[2a@
00000060: 6240 2203 c3aa 3f03 c3aa c4af c4a6 48c8  b@"...?.......H.
00000070: 993f cabe 03ca 82c2 b7ca be7b ca82 c4af  .?.........{....
00000080: cc8d c3b3 225d 2c50 6172 616c 6c65 6c6f  ...."],Parallelo
00000090: 6772 616d 5b61 4062 4022 c4a6 66c9 8306  gram[a@b@"..f...
000000a0: d08c 06d8 9b06 dfa4 0622 2c61 4061 4062  .........",a@a@b
000000b0: 4022 c492 c295 1ec8 adc4 92c2 95c4 a8ca  @"..............
000000c0: 8dc4 92c2 9502 ca8d c492 c295 c4a8 ca8d  ................
000000d0: c492 c295 02ca 8d22 2d31 3439 5d2c 635b  ......."-149],c[
000000e0: 663d 3661 4062 4022 1a4e 4918 c291 4ec4  f=6a@b@".NI...N.
000000f0: b54e 222c 3135 302c 7b7b 642d 652c 3264  .N",150,{{d-e,2d
00000100: 7d2c 7b2d 642d 652c 307d 2c67 3d7b 642d  },{-d-e,0},g={d-
00000110: 652c 642b 657d 2c67 7d5d 2c63 5b68 3d36  e,d+e},g}],c[h=6
00000120: 6140 6240 22c3 aa1f c396 4722 2c31 3830  a@b@".....G",180
00000130: 2c61 407b 2d64 2c64 2c64 2c33 647d 5d2c  ,a@{-d,d,d,3d}],
00000140: 5768 6974 652c 667e 637e 3330 2c68 7e63  White,f~c~30,h~c
00000150: 7e36 307d 5d26                           ~60}]&

Congratulations on the first non-SVG answer. The 1-pixel gaps seem to appear / disappear depending on zoom level (but for some reason Chrome will only let me change the zoom a couple of times, then refuses to respond.) The shape looks right but I'm not sure how to go about checking it.

Here's the list of graphics primitives: Axis-aligned rectangles (corner, corner): (6, 468), (126, 6); (468, 606), (588, 144); (1074, 126), (1404, 6); (1284, 366), (1404, 246); (1284, 606), (1562, 486). Parallelograms (corner, displacement, displacement): (294, 102), (125, 0), (-119, 408); (579, 6), (125, 0), (147, 504); (1036, 6), (125, 0), (-147, 504); (1563, 6), (125, 0), (147, 504); (2020, 6), (125, 0), (-147, 504)...

Black disks (center, radius, start angle, stop angle; α = arctan(24/7)): (156, 468), 150, π/2 - α, π; (438, 144), 150, -π/2 - α, 0; (870, 468), 150, π/2 - α, π/2 + α; (1854, 468), 150, π/2 - α, π/2 + α; (1404, 186), 180, -π/2, π/2; (1284, 426), 180, π/2, 3π/2. White disks (center, radius): (156, 468), 30; (438, 144), 30; (870, 468), 30; (1854, 468), 30; (1404, 186), 60; (1284, 426), 60...

@LevelRiverSt A displacement of (6, 6) in my coordinate system corresponds to a displacement of (5, -5) in your coordinate system. The origin (0, 0) of my coordinate system corresponds to the point (80, 630) in your coordinate system.

The dimensions all seem correct, but your origin actually appears to correspond to (105,605) in my coordinate system, for example (6,468) -> (105+6/1.2,605-468/1.2) = (110,215). This is the shortest answer so far. I'll wait at least a week more before accepting

PostScript, 325 bytes
Code (compressed version):
<</M{moveto}/L{lineto}>>begin 20 setlinewidth 0 50 translate 32 0 M 47 77 15 180 16.3 arcn 94 23 15 196.3 0 arc 109 100 L 126.4 -4.8 M 166 77 15 163.7 16.3 arcn 201.2 10 L 255 30 20 -90 90 arc 235 70 20 -90 90 arcn 281.4 90 L 290.6 -4.8 M 330 77 15 163.7 16.3 arcn 369.4 -4.8 L stroke 1 setgray 110 0 280 -9 rectfill showpage

Code (uncompressed version):
% define some short-named procedures for later use
<<
  /M {moveto}
  /L {lineto}
>> begin

% to get shorter code we use stroke (with a big linewidth) instead of fill
20 setlinewidth

0 50 translate  %  we need some empty space at the bottom

% draw N
32 0 M
47 77 15 180 16.3 arcn
94 23 15 196.3 0 arc
109 100 L

% draw A
126.4 -4.8 M   % descender will be cut off later
166 77 15 163.7 16.3 arcn
201.2 10 L

% draw S
 % no moveto here, so we get a connected line
255 30 20 -90 90 arc
235 70 20 -90 90 arcn
281.4 90 L

% draw A
290.6 -4.8 M   % descender will be cut off later
330 77 15 163.7 16.3 arcn
369.4 -4.8 L   % descender will be cut off later

stroke

1 setgray  % white
110 0 280 -9 rectfill  % overwrite the excess bottoms of A

showpage

Result:

PostScript, 259 249 bytes
[/M{moveto}/L{lineto}/a{arcn}/m{77 15 163.7 16.3 a}/c{20 -90 90}>>begin
20 setlinewidth
32 0 M 47 77 15 180 16.3 a 94 23 15 196.3 0 arc 109 100 L
126.4 -4.8 M 166 m 201.2 10 L 255 30 c arc 235 70 c a 281.4 90 L
290.6 -4.8 M 330 m 369.4 -4.8 L
stroke

A shortened version of Thomas Fritsch's answer with more defs to save bytes, and flush with the bottom of the page so the final crop could be removed without changing the appearance.
(This should be a comment on Thomas's answer, but I can't comment yet).

SVG (HTML5), 442 440 438 bytes

<svg viewbox=0,0,240,64><path fill=red d=M13.2,62V15.8A15,15,0,0,1,42.6,11.6L53.5,49a3,3,0,0,0,5.9,-.8V2h12V48.2A15,15,0,0,1,42,52.4L31.1,15a3,3,0,0,0,-5.9,.8V62m45.3,0L85.2,11.6a15,15,0,0,1,28.8,0L128.7,62H116.2L102.5,15a3,3,0,0,0,-5.8,0L83,62M125.2,50H153a6,6,0,0,0,0,-12H141A18,18,0,0,1,141,2H168.8V14H141a6,6,0,0,0,0,12h12A18,18,0,0,1,153,62H125.2m43.7,0L183.6,11.6a15,15,0,0,1,28.8,0L227.1,62H214.6L200.9,15a3,3,0,0,0,-5.8,0L181.4,62

Just an optimisation of the SVG given in the question. There's a better way of doing this!

No +1, too boring IMO, but remove fill=red  since "The logo shall be in a single arbitrary colour on a distinctly coloured background". Eagerly awaiting the "better way" :)

@JonathanAllan I've added that as another answer as I thought it made sense that way.


text:
Placing Dominoes On A Chequerboard
How many ways can one place (unlabelled) dominoes on a square chequerboard such that the number placed horizontally is equal to the number placed vertically?
The dominoes must align with, and may not protrude, the chequerboard and may not overlap.
This is OEIS sequence A330658, 1, 1, 1, 23, 1608, 371500, 328956227, 1126022690953, ...
Challenge
Given the side length of the chequerboard, \$n\$, produce the number of ways to arrange dominoes as described above, \$a(n)\$, in as few bytes as possible in your chosen programming language. Alternatively you may use any of the sequence defaults.
You do not have to handle \$n=0\$
If you're producing a list/generator/etc. it may start either:

1, 1, 23, 1608, ... or,
1, 1, 1, 23, 1608, ...

A Worked Example, \$n=3\$
There are \$23\$ ways to place an equal number of horizontal and vertical dominoes on a three by three board. Here they are represented as 0 where no dominoes lie and labelling cells where distinct dominoes lie as positive integers:
There is one way to place zero in each direction:
0 0 0
0 0 0
0 0 0

There are twenty ways to place one in each direction:
1 1 0   1 1 0   1 1 0   1 1 2      0 0 2      2 0 0      2 1 1   0 1 1   0 1 1   0 1 1
2 0 0   0 2 0   0 0 2   0 0 2      1 1 2      2 1 1      2 0 0   2 0 0   0 2 0   0 0 2
2 0 0   0 2 0   0 0 2   0 0 0      0 0 0      0 0 0      0 0 0   2 0 0   0 2 0   0 0 2

2 0 0   0 2 0   0 0 2   0 0 0      0 0 0      0 0 0      0 0 0   2 0 0   0 2 0   0 0 2
2 0 0   0 2 0   0 0 2   0 0 2      1 1 2      2 1 1      2 0 0   2 0 0   0 2 0   0 0 2
1 1 0   1 1 0   1 1 0   1 1 2      0 0 2      2 0 0      2 1 1   0 1 1   0 1 1   0 1 1

There are two ways to place two in each direction:
1 1 2   2 1 1
3 0 2   2 0 3
3 4 4   4 4 3

There are no ways to place more than two in each direction.
\$1+20+2=23 \implies a(3)=23\$

APL (Dyalog Extended), 61 bytes
{+/∊{(∪≡⊢)¨(,2,/m)[M],.,⍉C[M←⍵⌂cmat≢C]}¨0,⍳≢C←,2,⌿⊢m←⍵⊥¨⍳,⍨⍵}

Try it online!
Finally got how to circumvent the funky inner assignment on Extended ;-)
The difference with the one below is that dfns is auto-loaded under ⌂, and a no-op is added after assignment into m.
I have a 68-byte Unicode and 60-byte Extended solution by rewriting from scratch; it is left as an exercise for the reader.

APL (Dyalog Unicode), 72 69 bytes
⎕CY'dfns'
{+/∊{(∪≡⊢)¨(,2,/m)[M],.,⍉C[M←⍵cmat≢C]}¨0,⍳≢C←,2,⌿m←⍵⊥¨⍳,⍨⍵}

Try it online!
Non-recursive brute force. This works the other way around: generate all possible horizontal/vertical domino placements, generate all possible combinations of n horizontal and n vertical placements, and count the ones that don't have any duplicated cells.
Ungolfed with comments
⎕CY'dfns'  ⍝ Load dfns library to access function "cmat"

f←{  ⍝ Main function; ⍵←1-based index n (does not handle 0)

  m←⍵⊥¨⍳,⍨⍵  ⍝ n-by-n matrix of unique integers
        ,⍨⍵  ⍝ [n n]
       ⍳     ⍝ Nested matrix having [1..n;1..n]
    ⍵⊥¨      ⍝ Compute n×i+j for each cell containing [i j]

  R←,2,/m  ⍝ Horizontal domino placements
     2,/m  ⍝ From the matrix m, pair horizontally consecutive cells
    ,      ⍝ Flatten the outermost layer to make it a nested vector
  C←,2,⌿m  ⍝ Vertical domino placements, using ⌿ instead of /

  +/(0,⍳≢R){M←⍺cmat⍵⋄+/(∪≡⊢)¨,R[M],.,⍉C[M]}¨≢R  ⍝ Count the placements
    (0,⍳≢R){                              }¨≢R  ⍝ For each ⍺←0..length(≢) of R with ⍵←R,
            M←⍺cmat⍵                        ⍝ Generate all combinations to use for R and C
                    ⋄        ,R[M],.,⍉C[M]  ⍝ Concatenate all combinations of R with all combinations of C
                     +/(∪≡⊢)¨  ⍝ Count the ones whose cell values are all unique
  +/  ⍝ Sum all the counts
}

JavaScript (ES6),  150 133  126 bytes
n=>(g=(a,k=0,y=n,x,h=d=>a[(b=[...a])[y-!~d]|=m=2+d<<x,y]&m?0:g(b,k+~~d,y,-~x))=>(x%=n)||y--?h()+(y&&h(-1))+(x^n-1&&h(1)):!k)``

Try it online!
Commented
The board is described as an array of \$n\$ bit masks. We start at \$(0,n-1)\$ and attempt to put either a horizontal domino, a vertical domino or no domino at all at each position, going from right to left and bottom to top:
$$\begin{matrix}
(n-1,0)&\cdots&(1,0)&(0,0)\\
(n-1,1)&\cdots&(1,1)&(0,1)\\
\vdots&&\vdots&\vdots\\
(n-1,n-1)&\cdots&(1,n-1)&(0,n-1)
\end{matrix}$$
For horizontal dominoes, we test the bits at \$(x,y)\$ and \$(x+1,y)\$ and set both of them if the location is available. For vertical dominoes, we only test the bit at \$(x,y)\$ and set the one at \$(x,y-1)\$ if the location is available.
The helper function \$h\$ is used to process the tests and the recursive calls to its parent function \$g\$ in the scope of which it's defined:
h = d =>                // helper function taking a direction d:
                        //   -1 = vertical, undefined = no domino, 1 = horizontal
  a[                    // test a[]:
    (b = [...a])        //   b[] = copy of the current board
    [y - !~d] |=        //   apply the mask m to either b[y] or b[y - 1]
      m =               //   set m to:
        2 + d << x,     //     3 << x for horizontal, 1 << x for vertical,
                        //     or 0 for no domino (NaN << x)
    y                   //   test a[y]
  ] & m ?               // if there's a collision:
    0                   //   do nothing and leave the final result unchanged
  :                     // else:
    g(                  //   do a recursive call to g:
      b,                //     use the updated board
      k + ~~d,          //     add d to k
      y,                //     leave y unchanged
      -~x               //     increment x
    )                   //   end of recursive call

Below is the main recursive function \$g\$:
g = (                   // main recursive function taking:
  a,                    //   a[] = board
  k = 0,                //   k = counter which is incremented when a horizontal
                        //       domino is put on the board and decremented when
                        //       a vertical domino is used
  y = n, x,             //   (x, y) = current position
  h = ...               //   h = helper function (see above)
) =>                    //
  (x %= n) ||           // turn x = n into x = 0
  y--                   // decrement y if x = 0
  ?                     // if we haven't reached the end of the board:
    h() +               //   try to put no domino
    (y && h(-1)) +      //   if y > 0, try to put a vertical domino
    (x ^ n - 1 && h(1)) //   if x < n - 1, try to put a horizontal domino
  :                     // else:
    !k                  //   return 1 if k = 0 (meaning that we've put as many
                        //   horizontal dominoes as vertical ones)

Charcoal, 88 84 66 bytes
Ｎθ⊞υ⁰ＦυＦ×¹⁵Ｘ⁴⊖Φ×θθ﹪κθＦ∧¬＆ικ×θ⊖θ«≔×Ｘ⁴λ⊕Ｘ⁴θη≧｜ικ¿¬∨＆κη№υ｜κη⊞υ｜κη»ＩＬυ

Try it online! Link is to verbose version of code. Explanation:
Ｎθ

Input n.
⊞υ⁰

Start the list of results with an empty chequerboard of size n. This is represented using an integer in base 4 of n² digits with each digit representing an element of the array in row-major order, 0 for empty, 1 for half of a vertical domino and 3 for half of a horizontal domino. (2 is unused, but that's code golf for you.)
Ｆυ

Perform a breadth-first search of chequerboards.
Ｆ×¹⁵Ｘ⁴⊖Φ×θθ﹪κθ

Consider all squares of the current chequerboard that are not on the left column, then decrement the index, giving the squares that are not on the right column, then convert to a pair of base 4 digits 33 representing a horizontal domino on those two squares.
Ｆ∧¬＆ικ×θ⊖θ«

Check whether those squares are empty on the current chequerboard. If so, then consider all of the squares of the current chequerboard, except for the bottom row.
≔×Ｘ⁴λ⊕Ｘ⁴θη

Calculate the base 4 digits corresponding to a vertical domino at that square.
≧｜ικ

Merge the current chequerboard with the current horizontal domino.
¿¬∨＆κη№υ｜κη⊞υ｜κη

If the vertical domino does not overlap the merged chequerboard and the domino arrangement including the vertical domino has not yet been seen then add it to the list.
»ＩＬυ

Output the number of arrangements found.

Some nice golfing of the 84 byter :)

Jelly, 38 31 bytes
-7 bytes thanks to Jonathan Allan
’»1p⁸U+Ø.żƊŒPẈĠịƊpU$€ẎḅFQƑɗ€⁹S‘

TIO can run successfully for n=1,2,3, but it times out for n>3 since this is a brute force solution. I have verified n=4 on my computer.
Try it online!
Commented
’»1p⁸U+Ø.żƊŒPẈĠịƊpU$€ẎḅFQƑɗ€⁹S‘  # main link
’  p³                            # [1..n-1] Cartesian product with [1..n]
 »1                              # [1..n] x [1..n] if n=1 to avoid empty list output
     U                           # reverse, yielding list of pairs from ex. [1,1] to [3,2] for n=3 (tops of vertical dominoes)
      +Ø.                        # add [0,1] to each pair to get coordinates of bottoms of vertical dominoes
         żƊ                      # zip with the tops list to get a list of pairs of pairs: [[[1,1], [1,2]], ...]
           ŒPẈĠịƊ                # take the powerset to get all possible vertical dominoes, and group these subsets by length
                   U             # switch coordinates to get grouped horizontal domino sets
                  p $€           # Cartesian product of each set of horizontal dominoes with each set of vertical dominos of the same count
                      Ẏ          # tighten to get a single list of domino sets
                       ḅFQƑɗ€⁹   # 1 for each set pair if it is a valid arrangement of dominoes, otherwise 0 (check for no repeat coordinates)
                              S‘ # sum to find the count of valid arrangements, and increment for the case where there are no 0's

-7 bytes by using: 3-wise chain quicks (Ɗ and ɗ); the length-of-each atom (Ẉ); and the tighten atom (Ẏ).

...and welcome back!! :D

Clingo, 98 bytes
{v(1..n,2..n)}.{h(2..n,1..n)}.:-{v(I,J)}=C,{h(I,J)}!=C.:-I=1..n,J=1..n,2{v(I,J..J+1);h(I..I+1,J)}.

Wow, I'm just describing the problem, and it's still bigger than most of the more explicit solutions!
A commented version:
% Select some positions for vertical dominoes,
% v(I,J) is meant to also cover (I,J-1).
{v(1..n,2..n)}.

% Select some positions for horizontal dominoes,
% h(I,J) is meant to also cover (I-1,J).
{h(2..n,1..n)}.

% Constraints:

% The selections must not have different sizes:
:- {v(I,J)}=C,{h(I,J)}!=C.

% No position can be covered by two or more dominoes:
:- I=1..n,J=1..n,2{v(I,J..J+1);h(I..I+1,J)}

Save the program in a file dom.lp and give n as command line argument as shown below. The result is the number of models reported.
Here is an example run:
$ clingo -c n=5 dom.lp -q 0
clingo version 5.1.0
Reading from dom.lp
Solving...
SATISFIABLE

Models       : 371500
Calls        : 1
Time         : 2.519s (Solving: 2.51s 1st Model: 0.00s Unsat: 0.00s)
CPU Time     : 2.510s

-q stops clingo from printing solutions, 0 tells it to search for all solutions. Performance can be increased with the option --config=frumpy. With it, I was able to compute n=6 in 48 min.
In Debian, clingo is in the gringo packet.


text:
Which side has more?
The challenge is to golf a program when given a string composed of any number of asterisks, then a comma, than any number of asterisks, say which side has more.
The asterisk-strings can be empty.
Output
0 for ties.
1 for the left.
2 for the right.
Examples
Input: ***,**** Output: 2
Input: ***, Output: 1
Input: ***,*** Output: 0
Input: , Output: 0
Scoring
This is code-golf. Shortest answer wins.

It seems this would be improved by loosening the output format—for example, allowing -1, 0, and 1 for the three possibilities, or really any three consistent outputs.

I'm not sure that this is Ok at this stage (already 25 answers).  Some of the existing answers (including my own) already made some effort to adhere to the originally-specified output format.

@DominicvanEssen Alright, I will remove this option,

Python 2, 25 bytes
lambda s:cmp(s[::-1],s)%3

Try it online!

///, 60 64 28 bytes
/*,*/,//,*/2//*,/1//,/0//*//

Try it online!
Found out most of my program was unnecessary, -32 bytes.
I made this program when I was learning the language, and decided to post it as a question.

Very cool language for the problem

05AB1E, 6 bytes
Â.S(3%

Try it online!
How?
Note that ',' is greater than '*'.
Â.S(3%
Â      - input, reversed(input) (say a, b)
 .S    - compare: 1 if a > b; -1 if a < b; 0 if a = b
   (   - negate
    3  - push three
     % - modulo

Nice approach!!

@LuisMendo Did you see dingledooper's Python answer?

@Memberfor3months I hadn't seen it. Thanks!

C (gcc), 65 \$\cdots\$ 54 47 bytes
Saved a 10 bytes thanks to dingledooper!!!
Saved a byte thanks to ceilingcat!!!
Saved 7 bytes thank to l4m2!!!
f(c){c=strlen(c)-strspn(c,"*")*2;c=c>1?2:c!=1;}

Try it online!

f(c){c=strlen(c)-strspn(c,"*")*2;c=c>1?2:c!=1;} if high address not used

@l4m2 Works on TIO, so I guess it's allowed - thanks! :D

Bash + Standard utilities, 28 bytes
dc<<<1`tr *, 1d`1-dd*v/3+3%p

Try it online!

sed -E, 30 bytes
s/(.*),\1/0/;s/.+0/1/;s/0.+/2/

Try it online!

Gema, 20 characters
*,*=@cmps{*;*;2;0;1}

Sample run:
bash-5.0$ echo -n '***,****' | gema '*,*=@cmps{*;*;2;0;1}'
2

Try it online! / Try all test cases online!

K (ngn/k), 17 16 bytes
Solution:
{2/c<|c:#'","\x}

Try it online!
Explanation:
{2/c<|c:#'","\x} / the solution               -> e.g. 1         e.g. 2     e.g. 3
{             x} / lambda taking implicit 'x' -> "***,****"     "***,"     "***,***"
          ","\   / split string on comma      -> ("***";"****") ("***";"") ("***";"***")
        #'       / count length of each       -> 3 4            3 0        3 3
      c:         / store as c                 -> 3 4 (noop)     3 0        3 3
     |           / reverse it                 -> 4 3            0 3        3 3
   c<            / is c less than this?       -> 1 0            0 1        0 0
 2/              / convert from base 2        -> 2              1          0

Extra:

13 bytes if it doesn't need to be a function 2/c<|c:#'","\

Jelly,  7  6 bytes
,ṚMḄ2c

A monadic Link accepting a list of characters which yields an integer in \$[0,2]\$.
Try it online!
How?
Note that ',' is greater than '*'.
,ṚMḄ2c - Main Link: s                     e.g.:  "*,"          ",*"          ","
 Ṛ     - reverse (s)                             ",*"          "*,"          ","
,      - pair (s) with (that)                    ["*,",",*"]   [",*","*,"]   [",",","]
  M    - indices of maximal values               [2]           [1]           [1,2]
   Ḅ   - convert from base 2, say x              2             1             4
    2  - two                                     2             2             2
     c - (2) choose (x) - i.e. binomial(2,x)     1             2             0
       - implicit print (a list with a single element prints the element)

JavaScript (ES6),  26  25 bytes
Saved 1 byte thanks to @tsh
Taking advantage of the looser output rules: this versions returns 0 for ties, undefined for left or * for right.
s=>(s+0)[s.search`,`*2+1]

Try it online!

JavaScript (ES6), 31 bytes
Returns a Boolean value instead of 0 / 1.
s=>([a,b]=s.split`,`,a<b?2:a>b)

Try it online!

@Shaggy Do you mean other than the one I'm linking to in my answer?

Christ! I really can't function without caffeine, can I?! :\

Perl 5 + -pl, 21 bytes
/,/;$_=$`cmp$';s;-1;2

Try it online!

APL (Dyalog Unicode), 20 19 13 bytesSBCS
Whooping -6 thanks to @Bubbler.
(⊃3|⍒-⍋)⊂,⊂∘⌽

Try it online! This should be golfable as there are some things I am repeating there but I am not sure how to do it yet.
APL (Dyalog Unicode), 19  bytesSBCS
{3|×1+(2×⍵⍳',')-≢⍵}

Try it online!

13 bytes using your second answer as the starting point.

@Bubbler thanks for the step by step!

I would be interested in understanding how my answer isn't helpful and the reason it got downvoted :)

(1 of 2) 05AB1E, Jelly, Japt and (2 of 2) APL answers downvoted - I imagine someone does not think we're counting bytes, (only ones missing would be Charcoal and Stax, maybe they didn't go to page 2).

@JonathanAllan that is weird, I even link the SBCS wiki page so people can rest assured I'm really counting bytes :/ these downvote floods always confuse me

APL (Dyalog Extended), 9 bytes
(⊥⍋|⍒)⊢⍮⌽

Try it online!
How it works
(⊥⍋|⍒)⊢⍮⌽  ⍝ left '*,' | right ',*' | equal ','
      ⊢⍮⌽  ⍝ Length-2 nested vector of self and reverse
  ⍋        ⍝ Grade up; order of indices to make it ascending-sorted
           ⍝ 1 2       | 2 1        | 1 2
    ⍒      ⍝ Grade down; order of indices to make it descending-sorted
           ⍝ 2 1       | 1 2        | 1 2
   |       ⍝ Right modulo left
           ⍝ 0 1       | 1 0        | 0 0
 ⊥         ⍝ From base 2 to integer
           ⍝ 1         | 2          | 0

How many bytes if you port my oK answer?

@streetster APL doesn't have a built-in for "split at ','".

Ruby -nl, 18 bytes
~/,/;p ($`<=>$')%3

Try it online!
Takes input from STDIN. Compares the regex match groups $` and $', which are set equal to everything on the left and right of the comma, respectively.

Japt, 9 8 bytes
Returns true/false instead of 1/0
>Ô?2:U<Ô

>Ô?2:U<Ô     :Implicit input of string U
>            :Greater than
 Ô           :  U reversed
  ?          :If true
   2         :  Literal 2
    :        :Else
     U<Ô     :  U less than U reversed?

Try it
Original, 9 bytes
5 bytes just to handle the I/O requirements :\
q, mÊrÎu3

Try it
q, mÊrÎu3     :Implicit input of string
q,            :Split on ","
   m          :Map
    Ê         :  Length
     r        :Reduce by
      Î       :  Sign of difference
       u3     :Positive modulo 3

If we could take a space delimited string as input then -2 bytes:
¸mÊrÎu3

If we could take an array as input then -1 more byte:
mÊrÎu3

And, if we could use any 3 distinct values for the output then -2 more bytes:
mÊrÎ

Io, 51 bytes
Mod3 doesn't work in Io. Too bad.
method(x,I := -x compare(x reverse);if(I== -1,2,I))

Try it online!

C (gcc), 83 bytes
x;f(char*z){char*Z,*W;for(Z=z;44-*Z++;);for(W=Z;*W++;)Z--;x=!!x*((x=z-Z+1)<0?1:2);}

Try it online!
C (gcc), 58 bytes

Thanks to ceilingcat for this shorter version.

f(z,Z)long z,Z;{Z-=strlen(Z=index(z,44))+z-1;z=Z<0?2:!!Z;}

Try it online!

brainfuck, 57 bytes
-[>>,<--[>-<++++++]>-]<+[<<,]>[<-->+[<+>+]]-[<+>-----]<-.

Try it online!
It spreads * on the tape and checks if the second branch went past the first.

Retina, 15 13 bytes
(.*),\1$

\*+

Try it online!
If the right-hand-side has an equal or less number of *'s, then those *'s are removed from both sides, along with the ,.
Then the number of runs of *'s are counted.

Java 10, 74 51 50 bytes
s->(Long.signum(s.indexOf(44)*2-s.length()+1)+3)%3

-24 bytes thanks to @OlivierGrégoire.
Try it online.
Explanation:
s->{                          // Method with String parameter and long return-type
  Math.signum(                //  Take the signum of:
   s.indexOf(44)              //   The index of ',' (codepoint 44)
   *2                         //   multiplied by 2
   -s.length()                //   Subtract the entire length of the input
   +1                         //   And add 1
  +3)                         //  Then increase that result by 3
  %3                          //  And take modulo-3 on it

51 bytes if double as result is accepted

@OlivierGrégoire Oh, nice approach. Maybe you should post it as a separated answer, since it's completely different than what I currently have. :)

@OlivierGrégoire Ah ok, from that 72 byter to your 51 byter makes indeed sense. If you don't want to post it, I will edit. Thanks! :)

F.Y.I. I just noticed that Long.signum exists. It might be better than Math.signum so that there's not this trailing .0.

A further byte can be saved by replacing "," with 44 (which is the codepoint for the comma).

Excel, 64 63 62 bytes
=IF(LEN(A1)+1=2*FIND(",",A1),0,IF(LEN(A1)<2*FIND(",",A1),1,2))

-1 byte thanks to Dominic van Essen
-1 byre thanks to Chronocidal

63 bytes by using >=: =IF(LEN(A1)+1=2*FIND(",",A1),0,IF(LEN(A1)>=2*FIND(",",A1),2,1))

Can't you save another byte by changing >= to <, and swapping the 2 and the 1? (i.e. inverting the Logical Condition)

A few bytes can be saved by subtracting from 2 rather than using conditionals:. =2-(find(",",A1)>Len(a1)/2)-(find(",",A1)*2=Len(A1)+1)

Ruby -n, 21 20 bytes
p (~/,/*2<=>~/.$/)%3

Try it online!

That's cool! I think it's its own answer.

Posted :)

J, 19 18 bytes
3|i.&','*@--:@<:@#

Try it online!
How it works
3|i.&','*@--:@<:@#
           -:@<:@# halved (length-1) of list
                   (where , would be in a balanced list)
  i.&','           position of the ,
        *@-        signum'd difference between both
3|                 mod 3

Alternative version, 19 bytes
This inserts - and + between the bit mask of the string: **,* -> 1 1 0 1 -> 1 + (1 + (0 - 1))) to get the difference between both sides. Then both signum and mod 3 like other solutions.
3|[:*'*'-`+@.[/@:=]

Try it online!
How it works
3|[:*'*'-`+@.[/@:=]
     '*'         =] '***,*' -> 1 1 1 0 1
        -`+@.[      a function that chooses - or + based on the left argument
              /@:   puts this function inbetween: 1+(1+(1+(0-1))) = 2
  [:*               signum: 2 -> 1
3|                  mod 3

14 bytes by porting my APL answer.

Befunge-93, 31 bytes
2>1~:1+v
p^_"$"2 0
.@^-","_$2\-

Try it online!
After initially pushing 2 to the stack, we push 1 for every * we encounter. After finding the ,, we start popping them instead. When we run out of input we subtract the top of the stack from 2, resulting in the correct output values.

Python 3, 56 60 bytes
-4 bytes thanks to math junkie

A third approach to this in python.
def f(x):a,b=x.split(',');return(1,0,2)[((a<b)-(a>b))+1]

Try it online!

You can remove some unnecessary whitespace: Try it online!

PHP, 55 51 47 bytes
fn($s)=>(3+(($a=explode(',',$s))[0]<=>$a[1]))%3

Try it online!
This is the best I have so far.. Gosh, longer than Java and C :O
EDIT: saved 4 bytes using value of $v, now shorter than C!
EDIT2: thanks a lot to 640KB for finding the finely elegant way to have the right numbers! -4 bytes
Much shorter with only distinct values instead of fixed numbers requirement:
PHP, 39 bytes
fn($s)=>($a=explode(',',$s))[0]<=>$a[1]

Try it online!

For fun, here's what I came up with before I saw yours - the same size actually! https://tio.run/##XY49C8IwEIbn5lccJZIPI9p2s02dBAeh3VWklIQMYkOTTuJvj0EKfgw33PM@x73W2FDtrLEIYa@cdyDhhBLCORdxOBGQrNfQTN5Ofgv5HP3h7HNBxHewiUGUk192KeM3LYO@U@yYrGmxpM6PdnBxjzphPK9kHdFNvZVVxtiiCCXSw6i63tC5a@cAewYPBKB6M0CK/dmnArCOBhPQHtrrvjmW6Ble

Excel,  44  40 Bytes
=MOD(3-SIGN(1+LEN(A1)-2*FIND(",",A1)),3)

Finds the difference between Total Length + 1 and twice the position of the comma (Negative: Left; Zero: Tie; Positive: Right), use SIGN to convert these into -1, 0 and 1.  Then subtract this from 3 to give 4/0/2, and take the Modulo Base 3 (1, 0, 2)
Old version: 44 Bytes
=MID(102,2+SIGN(1+LEN(A1)-2*FIND(",",A1)),1)

Finds the difference between Total Length + 1 and twice the position of the comma (Negative: Left; Zero: Tie; Positive: Right), use SIGN to convert these into -1, 0 and 1, add 2 (1, 2, 3), and then use MID to take the first, second or third digit from 102, respectively.
(Using MID saved 3 bytes over using CHOOSE)
I also experimented with a more maths-based approach (Multiply the Sign by 1.5, round it in the Positive direction with CEILING, then take the Absolute value), but that was 51 bytes instead.

C (gcc) - 67 bytes
This is a complete program and can be compiled with gcc. Input is the first command line argument and output is the exit status.
main(u,v)int**v;{u=strlen(*++v)-strspn(*v,"*")*2;exit(u>1?2:u!=1);}

AWK -F,, 24 22 20+3 = 23 bytes
$0=$2>$1?2:($1>$2)""

Try it online!
Edit: amazingly, golfing-away 2 bytes has actually made it (a bit) more readable
Commented version:
$0=             # set the line to
    $2>$1 ?     # if $2>$1 (alphabetic comparison)
            2   # 2
    :           # otherwise
      ($1>$2)   # logical: 1 for $1>$2, 0 if not
             "" # append "" to force text output
                # otherwise awk won't print zero

# use default behaviour to print line

Python 3.8 (pre-release), 62 bytes
lambda x:y.index(max(y))+1if len({*(y:=x.split(","))})>1else 0

Try it online!
I know that there is a shorter python solution already posted, but cmp doesn't exist in python 3. And don't bother trying to use bitwise operators to increment the value... it ends up being the same byte count.

By unfolding the cmp function you can be much shorter:
https://codegolf.stackexchange.com/a/206139/2212

Ruby -nlaF,, 22 bytes
p ($F[0]<=>$F[1]||1)%3

Try it online!

R, 46 45 bytes
(or 42 bytes using TRUE/FALSE instead of 1/0)
d=scan(,'',,,',');`if`(d[2]>d,2,1-!d[2]<d[1])

Try it online!
Edit: -1 byte thanks to Giuseppe

You can use ,, in place of se= (forcing R to use the argument order rather than the names) to save a byte. Might also be able to use a sign(diff(* lengths))%%3 like I've seen in other answers to golf off some bytes.

Thanks for the ,,!  Updated with acknowledgment... (again!)

...and you should post the other approach (which is much better than mine and beats it by at least 7 bytes)...

Befunge-93, 48 bytes
>~:1+!#v_","-!#v_1+
^ p 0 +$#99 "-"<
+1`_: #<.@.

Try it online!
Adds one for each character it encounters, until it sees a ,; in that case, the program self modifies to start subtracting one for each character it encounters. After seeing the end of the string, it checks whether the tally is 0, less than 0, or something else, and prints 0, 2 or 1 accordingly.

SimpleTemplate, 66 bytes
This was quite fun!
Uses the most basic and naive approach, but the shortest one i can come up with as well.
{@ifargv.0 is equalargv.1}0{@elseifargv.0 is lowerargv.1}2{@else}1

That's quite a mess, lets explore it:
{@if argv.0 is equal to argv.1}
    {@echo 0}
{@else if argv.0 is lower than argv.1}
    {@echo 2}
{@else}
    {@echo 1}
{@/}

Should be self-explanatory.
A string is considered lower or higher depending on it's length and the characters on it are lower numerically (e.g.: b > a).
To turn into a function, all it needs is that the {@echo} is converted to {@return}.
Due to a bug (version 0.83), you can't return 0, but you can return "0".

You can test this on http://sandbox.onlinephpfunctions.com/code/683ec5b3e71cfb4f2bb78267125330b077248ef7

R, 38 bytes
sign(-diff(nchar(scan(,'',,,','))))%%3

Try it online!
Credit to Dominic van Essen for the sep argument to scan(), which I probably use less often than I should.
Ports the mod 3 approach found in a few other answers.

Golfscript, 22 bytes
','/).@).@;@>@@>2 0if+

Try it online!
code   | explanation                      | example
','/   | split input at ',' into list     | "*,**" -> ["*", "**"]
).     | uncons from the right and double | ["*", "**"] -> ["*"] "**" "**"
@).    | put list on tos and do it again  | ["*"] "**" "**" -> "**" "**" [] "*" "*"
@;     | discard empty list               | "**" "**" [] "*" "*" -> "**" "**" "*" "*"
@>     | pull up a "right" and compare    | "**" "**" "*" "*" -> "**" "*" 0
@@     | pull up remaining elements       | "**" "*" 0 -> 0 "**" "*"
>2 0if | compare, if 1 replace with two   | 0 "**" "*" -> 0 2
+      | add the results                  | 0 2 -> 2

Pyth, 16 bytes
%_._h.+mldcQ","3

Try it online!

12 bytes: Try it online!

Python 3.8, 32 bytes
lambda s:((r:=s[::-1])!=s)+(r<s)

Try it online!
It is just one byte shorter than other Python 3.x
lambda s:(s[::-1]!=s)+(s[::-1]<s)

05AB1E, 14 bytes
[ÂQ#',¡ć@>,q}0

Try it online!
A weird program method, I know, but hey, it works! The ÂQ part is from this answer regarding 05AB1E golfing tips

Octave / MATLAB, 41 38 bytes
@(x)mod(sign(2*find(x-42)-nnz(x)-1),3)

Try it online!

Charcoal, 18 bytes
⊞υθ⊞υ⮌θＩ⁻²↨⮌⌕Ａυ⌈υ²

Try it online! Link is to verbose version of code. Based on @JonathanAllen's answer. Explanation:
⊞υθ⊞υ⮌θ

Push the input and its reverse to the predefined empty list.
         υ  List of input and reverse
        ⌈   Take the maximum
     ⌕Ａυ    Get the indices of that in the list
    ⮌       Reverse the list of indices
   ↨      ² Convert from base 2
 ⁻²         Subtract from 2
Ｉ           Cast to string
            Implicitly print

When the input equals its reverse, both indices 0, 1 are returned, and 10 equals 2 in base 2, while if the left side has more then the maximum is at index 1, while if the right side has more then the maximum is at index 0. Subtracting this from 2 results in the desired value.

T-SQL, 43 bytes
DECLARE @ varchar(max)='*,**'

PRINT(3+sign(charindex(',',@)*2+~len(@)))%3

Stax, 9 7 bytes
üJN☺ïS♂

Run and debug it
Unpacked:
',/E|$3%

-2 bytes thanks to recursive

You can omit {%m, as comparisons work on strings too.

FEU, 30 26 bytes
Saved 4 bytes by using map instead of multiple substitutes
m/(\**),\1/0/\*+0/1/0\*+/2

Try it online!
Explanation
m                          # Map mode, execute multiple substitutions
 /(\**),\1/0               # Replaces the balance of the sides with 0
            /\*+0/1        # If there are asterisks on the left of 0, replace with 1
                   /0\*+/2 # If there are asterisks on the right of 0, replace with 2

PowerShell, 59 bytes
$a,$b=$i.split(',');if($a-gt$b){1}elseif($a-eq$b){0}else{2}

Try it online!


text:
Score a 1 player game of Carcassonne
Carcassonne is a tile-based game, where the objective is to construct Roads, Cities and Monasteries, in order to score points. The game works by players taking turns to draw and place tiles to construct a landscape, then claiming roads, cities and monasteries. An example landscape is:

There are \$19\$ distinct tiles (ignoring rotations), each of which contains at least one feature (Road, City or Monastery):

Also, notice that the landscape must be consistent. This means that roads must connect to other roads, city edges must connect to other city edges and fields must connect to fields. Therefore, these tiles are inconsistent:

In a normal game of Carcassonne, each feature in the landscape is claimed by a player, and contributes to their final score. However, in this version, we will change the rules slightly (primarily for people who already know the standard Carcassonne rules):

There will only be \$1\$ player
The player will automatically own every feature in the landscape
There will be no "badge" score for cities

Notice that in some of the tiles in the pictures have badge symbols on them. In this challenge, we're ignoring them.

In a landscape, each feature is either complete or incomplete:

A complete monastery is one where it's tile is surrounded by \$8\$ tiles. This landscape contains one complete monastery (in the center) and one incomplete monastery (Top center).
A complete city is one fully enclosed by walls. This landscape has \$2\$ complete cities and \$2\$ incomplete cities.
A complete road is one where both ends terminate at either a city, village or by forming a loop. This landscape has \$2\$ complete roads and \$2\$ incomplete roads.

A landscape is scored as follows:

For every complete city, the player scores \$2\$ points for every tile containing that city. Therefore this city scores \$4\$ points, and this city scores \$18\$ points.
For every complete road, the player scores \$1\$ point for every tile containing that road. Therefore this road scores \$6\$ points, and this road scores \$2\$.
For every complete monastery, the player scores \$9\$ points, such as this monastery.
For every incomplete city, the player scores \$1\$ point for every tile containing that city. This landscape contains two incomplete cities, one scoring \$2\$ and the other \$5\$.
For every incomplete road, the player scores \$1\$ point for each tile containing that road. This landscape contains three incomplete roads, scoring \$1\$, \$2\$ and \$3\$ points.
For every incomplete monastery, the player scores \$1\$ point for each tile that neighbours the monastery, plus \$1\$ for the monastery itself. This landscape contains \$3\$ monasteries, scoring \$2\$, \$5\$ and \$7\$.

Take this landscape:

This landscape contains \$1\$ complete city, \$2\$ incomplete cities, \$4\$ complete roads, \$2\$ incomplete roads and \$1\$ incomplete monastery which scores \$4 + (3+3) + (3+2+6+2) + (4+2) + 4 = 33\$ points.

To avoid this challenge being about image processing, we can translate each tile into a list containing \$5\$ values, according to this legend:
[North edge, East edge, South edge, West Edge, # of cities]

0: Field
1: Road
2: City

For instance, this tile can be described as [2, 0, 1, 1, 1]. Using this legend, we can describe each tile uniquely, and it's rotations are rotations of the first four elements.  The entire grid can be described as a rectangular matrix, with a \$20^\text{th}\$ distinct value for an empty square. Translating the first landscape into this format, we get:
[
 [             [],              [], [1, 1, 0, 0, 0], [1, 1, 2, 1, 1], [0, 1, 0, 1, 0],              [],              []],
 [[1, 0, 1, 0, 0],              [], [0, 0, 0, 0, 0], [2, 0, 2, 0, 2],              [], [0, 2, 2, 2, 1], [0, 0, 0, 2, 1]],
 [[1, 1, 0, 1, 0], [0, 0, 1, 1, 0], [0, 0, 0, 0, 0], [2, 2, 0, 0, 1], [2, 2, 0, 2, 1], [2, 0, 0, 2, 1],              []]
]

using [] to represent an empty square. The complete list of tiles (ignoring rotations) in the same grid as the second image is
[1, 0, 1, 0, 0] [0, 0, 1, 1, 0] [2, 1, 1, 1, 1] [0, 1, 1, 1, 0] [2, 0, 0, 0, 1]
[2, 2, 0, 2, 1] [0, 0, 0, 0, 0] [2, 2, 2, 2, 1] [2, 2, 0, 0, 1] [2, 1, 1, 2, 1]
[2, 2, 0, 0, 2] [0, 0, 1, 0, 0] [2, 0, 1, 1, 1] [2, 1, 1, 0, 1] [0, 2, 0, 2, 1]
[1, 1, 1, 1, 0] [2, 1, 0, 1, 1] [2, 2, 1, 2, 1] [2, 0, 2, 0, 2]

Note that the only way to distinguish tiles with monasteries and villages is by the number of roads/cities on the tile, and that there is no specific indicator that a tile has a monastery/village aside from the roads.

Your task is to take a matrix of lists in the above format representing a landscape and to output the score the player would have if they claimed all the features, complete or incomplete, in the landscape. You may take input in any convenient method, may choose any three consistent values to represent Field, City and Road edges and may use any value to represent the empty squares that isn't already a tile. Output must be an integer represented in your language's most natural format. If you aren't sure about an I/O format, just ask.
In addition, the inputs will always have consistent landscapes, and will always have at least 1 tile. Finally, the tiles will not be constrained by the tile availability (like in the real game).
This is code-golf so the shortest code in bytes wins.
Test cases
Each test case has the matrix followed by the score, with the score breakdown underneath with abbreviations.
[[[], [], [1, 1, 0, 0, 0], [1, 1, 2, 1, 1], [0, 1, 0, 1, 0], [], []], [[1, 0, 1, 0, 0], [], [0, 0, 0, 0, 0], [2, 0, 2, 0, 2], [], [0, 2, 2, 2, 1], [0, 0, 0, 2, 1]], [[1, 1, 0, 1, 0], [0, 0, 1, 1, 0], [0, 0, 0, 0, 0], [2, 2, 0, 0, 1], [2, 2, 0, 2, 1], [2, 0, 0, 2, 1], []]] -> 32
1 c. city (4), 1 i. city (6), 6 i. roads (10), 2 i. monasteries (12)

[[[0, 2, 2, 2, 1], [1, 0, 1, 2, 1], [0, 1, 1, 0, 0], [2, 2, 2, 1, 1]], [[2, 1, 1, 2, 1], [1, 0, 0, 1, 0], [1, 1, 1, 0, 0], [2, 2, 2, 1, 1]], [[1, 1, 1, 0, 0], [0, 2, 1, 1, 1], [1, 0, 1, 2, 1], [2, 1, 1, 0, 1]], [[1, 0, 0, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 1, 0], [1, 0, 1, 0, 0]]] -> 33
1 c. city (4), 2 i. cities (6), 4 c. roads (13), 2 i. roads (6), 1 i. monastery (4)

[[[0, 1, 1, 0, 0], [2, 1, 0, 1, 1], [1, 2, 1, 1, 1], [0, 2, 0, 2, 1], [0, 1, 1, 2, 1]], [[], [], [1, 0, 2, 1, 1], [0, 1, 1, 0, 0], [1, 2, 1, 1, 1]], [[2, 1, 0, 1, 1], [1, 2, 1, 1, 0], [2, 1, 1, 2, 1], [], [1, 1, 0, 1, 0]], [[], [1, 0, 0, 1, 1], [1, 0, 1, 0, 0], [2, 2, 0, 0, 2], [0, 1, 1, 2, 1]]] -> 39
2 c. cities (12), 4 i. cities (5), 1 c. road (2), 12 i. roads (20)

[[[2, 1, 1, 0, 1]]] -> 2
1 i. city (1), 1 i. road (1)

[[[1, 2, 1, 1, 1], [0, 0, 0, 2, 1], [], [1, 1, 0, 1, 0], [2, 2, 2, 1, 1]], [[1, 0, 1, 0, 0], [], [2, 0, 2, 0, 2], [0, 0, 0, 0, 0], []], [[1, 1, 2, 2, 1], [0, 1, 0, 1, 0], [2, 0, 1, 1, 1], [], []], [[], [], [2, 2, 1, 2, 1], [], []]] -> 29
2 c. cities (8), 4 i. cities (4), 2 c. roads (8), 4 i. roads (4), 1 i. monastery (5)

[[[], [0, 0, 2, 0, 1], [], [], [0, 0, 2, 0, 1], [], [], []], [[], [2, 1, 1, 0, 1], [0, 1, 0, 1, 0], [0, 1, 0, 1, 0], [2, 0, 1, 1, 1], [], [], []], [[], [1, 0, 1, 0, 0], [0, 2, 2, 0, 1], [0, 2, 2, 2, 1], [1, 1, 2, 2, 1], [0, 0, 1, 1, 0], [], []], [[0, 1, 1, 0, 0], [1, 2, 2, 1, 1], [2, 0, 2, 2, 1], [2, 0, 2, 0, 1], [2, 2, 0, 0, 2], [1, 1, 2, 2, 1], [0, 1, 2, 1, 1], [0, 0, 1, 1, 0]], [[1, 1, 1, 0, 0], [2, 2, 2, 1, 1], [2, 2, 2, 2, 1], [2, 1, 2, 2, 1], [0, 0, 0, 1, 0], [2, 2, 0, 0, 1], [2, 1, 2, 2, 1], [1, 0, 1, 1, 0]], [[1, 0, 1, 0, 0], [2, 2, 0, 0, 1], [2, 0, 2, 2, 1], [2, 0, 2, 0, 1], [0, 0, 0, 0, 0], [0, 2, 2, 0, 1], [2, 1, 1, 2, 1], [1, 0, 0, 1, 0]], [[1, 1, 0, 0, 0], [0, 0, 1, 1, 0], [2, 2, 0, 0, 1], [2, 2, 0, 2, 1], [0, 2, 0, 2, 1], [2, 1, 1, 2, 1], [1, 0, 0, 1, 0], []], [[], [1, 1, 0, 0, 0], [0, 1, 0, 1, 0], [0, 1, 0, 1, 0], [0, 1, 0, 1, 0], [1, 0, 0, 1, 0], [], []]] -> 106
3 c. cities (54), 5 c. roads (34), 2 c. monasteries (18)

Note that in the largest city in the final example, the tile [2, 2, 0, 0, 2] has two sections of the city, but is only a single tile. Therefore, it only counts for 2 points, not 4.
If you have a copy of Carcassonne, I'd highly recommend building the test cases, if only to help visualise them

Sandbox (deleted). Don't hesitate to provide any and all feedback

I knew tiles like this one existed but I think that layout (with or without the Trader's icon) only exists in expansions, not the originals. Otherwise, it may have broken the encoding scheme.

Charcoal, 306 246 bytes
Ｅθ⭆ι⎇λ⊟λψ≔ΣＥθΣＥι∨⁼²№λ¹№λ¹ζＦＬθＦＬ§θι«Ｊκι¿›²Σ∨§§θικ²≧⁺⊕ＬΦＫＭ℅λζ»ＦＬθＦＬ§θι«Ｊκι¿⁼²ΣＫＫ«≔⌕§§θικ²δ≔δεＭ✳⁻χ⊗ε¿ΣＫＫ«Ｗ∨⁻ⅉι⁻ⅈκ«≧⁻ΣＫＫεＷ∨›²§§§θⅉⅈε¬Σ§ＫＶε≦⊕εＭ✳⁻χ⊗ε»¿¬⁼﹪⁺²ε⁴δ1»»»Ｗφ«≔⁰φＦＬθＦＬ§θκ«Ｊλκ≔ΣＫＫδ≔§§θκλη≔∧δΦ⌕Ａη²¬℅§ＫＶμε¿ε«≔¹φ¿‹Ｌεδ«§≔η⊟ε⁰≔¹δ1»ψ≧⁺δζ»»»≧⁺⊗ΣＥＫＡΣιζ⎚Ｉζ

Try it online! Link is to verbose version of code. Explanation:
Ｅθ⭆ι⎇λ⊟λψ

Start by printing the number of cities on each tile so that the tiles can be walked using canvas operations rather than array indexing. Just getting the number of cities via AtIndex(AtIndex(AtIndex(q, i), k), 4) normally takes 7 bytes, whereas it can be read from the canvas in only 6 via JumpTo(k, i); and then Sum(Peek()) (although obviously we can only do that as a separate statement). We can also directly inspect adjacent cells using PeekMoore() and PeekVonNeumann() to see whether they are empty tiles (empty tiles will be a null byte or an empty string for out-of-range tiles, but both have an ordinal of 0). Furthermore, removing the city count data from the input array makes the code to deal with the features cleaner (i.e. shorter).
≔ΣＥθΣＥＥι№λ¹∨⁼²λλζ

Start off by counting the roads. Complete and incomplete roads both score their length, so the only special case here is that a tile with two roads only scores 1.
ＦＬθＦＬ§θι«Ｊκι¿›²Σ∨§§θικ²≧⁺⊕ＬΦＫＭ℅λζ»

Next, find the monasteries, whose tiles have with no features apart from an optional road. For each monastery, simply count one more than the number of adjacent tiles, since complete monasteries count 9 anyway.
ＦＬθＦＬ§θι«

We need to check whether tiles with two cities are connected. Loop over all of the tiles.
Ｊκι¿⁼²ΣＫＫ«

Is this a tile of two cities?
≔⌕§§θικ²δ≔δεＭ✳⁻χ⊗ε

Pick one of the city directions and move one step.
¿ΣＫＫ«

Is there city here?
Ｗ∨⁻ⅉι⁻ⅈκ«

Repeat until we get back to the original tile.
≧⁻ΣＫＫε

If this is a different tile of two cities, then immediately U-turn, otherwise turn left. This allows us to perform a left-following maze traversal.
Ｗ∨›²§§§θⅉⅈε¬Σ§ＫＶε≦⊕ε

Turn right until there is a connected city.
Ｍ✳⁻χ⊗ε

Move to the next city.
»¿¬⁼﹪⁺²ε⁴δ1»»»

If we did not arrive in the opposite direction to which we left, then the two cities on this tile are actually connected, so count them as a single city.
Ｗφ«≔⁰φ

Next, we need to find tiles with incomplete cities. Use a variable with a predefined non-zero value as a loop variable, but immediately set it to zero inside the loop.
ＦＬθＦＬ§θκ«

Loop over each tile.
Ｊλκ≔ΣＫＫδ≔§§θκλη≔∧δΦ⌕Ａη²¬℅§ＫＶμε

Check for adjacent tiles in the appropriate directions. We can assume that these tiles will be city tiles if they exist, but if they don't exist then this tile is part of an incomplete city.
¿ε«≔¹φ

If so, then note that we had an incomplete city for later.
¿‹Ｌεδ«

If this tile has two cities, but only one was found to be incomplete, then...
§≔η⊟ε⁰

... mark that direction as a field, and...
≔¹δ

... reduce the score for this tile to 1, and...
1

... reduce the number of remaining cities to 1.
»ψ

Otherwise delete the tile completely. This will cause any adjacent city tiles to be (re)evaluated for incompleteness.
≧⁺δζ»»»

Score the number of cities deleted.
≧⁺⊗ΣＥＫＡΣιζ

Score two for any remaining cities on the remaining tiles, as these must now be complete cities.
⎚Ｉζ

Clear the canvas and output the final score.