text:
Is my barcode valid?
An EAN-8 barcode includes 7 digits of information and an 8th checksum digit.
The checksum is calculated by multiplying the digits by 3 and 1 alternately, adding the results, and subtracting from the next multiple of 10.
For example, given the digits 2103498:
Digit:        2   1   0   3   4   9   8
Multiplier:   3   1   3   1   3   1   3
Result:       6   1   0   3  12   9  24

The sum of these resulting digits is 55, so the checksum digit is 60 - 55 = 5

The Challenge
Your task is to, given an 8 digit barcode, verify if it is valid - returning a truthy value if the checksum is valid, and falsy otherwise.

You may take input in any of the following forms:

A string, 8 characters in length, representing the barcode digits
A list of 8 integers, the barcode's digits
A non-negative integer (you can either assume leading zeroes where none are given, i.e. 1 = 00000001, or request input with the zeroes given)

Builtins that compute the EAN-8 checksum (i.e, take the first 7 digits and calculate the last) are banned.
This is code-golf, so the shortest program (in bytes) wins!

Test Cases
20378240 -> True
33765129 -> True
77234575 -> True
00000000 -> True

21034984 -> False
69165430 -> False
11965421 -> False
12345678 -> False

Related to Luhn algorithm for verifying credit card numbers, possibly a dupe.

This question is not actually about a bar code (which is the black-white striped thing), but about the number encoded by a barcode. The number can exist without a bar code, and the bar code can encode other things than EANs. Maybe just "Is my EAN-8 valid" is a better title?

@PaŭloEbermann doesn't quite have the same ring to it...

When reading about barcodes, I expect some image reading (or at least a bit-string), not verifying a checksum.

Strongly related, since an ISBN-13 is an EAN.

Jelly, 7 bytes
s2Sḅ3⁵ḍ

Try it online!
How it works
s2Sḅ3⁵ḍ  Main link. Argument: [a,b,c,d,e,f,g,h] (digit array)

s2       Split into chunks of length 2, yielding [[a,b], [c,d], [e,f], [g,h]].
  S      Take the sum of the pairs, yielding [a+c+e+g, b+d+f+h].
   ḅ3    Convert from ternary to integer, yielding 3(a+c+e+g) + (b+d+f+h).
     ⁵ḍ  Test if the result is divisible by 10.

JavaScript (ES6), 41 40 38 bytes
Saved 2 bytes thanks to @ETHProductions and 1 byte thanks to @Craig Ayre.
s=>s.map(e=>t+=e*(i^=2),t=i=1)|t%10==1

Takes input as a list of digits.
Determines the sum of all digits, including the checksum.
If the sum is a multiple of 10, then it's a valid barcode.
Test Cases

let f=

s=>s.map(e=>t+=e*(i^=2),t=i=1)|t%10==1

console.log(f([2,0,3,7,8,2,4,0]));
console.log(f([3,3,7,6,5,1,2,9]));
console.log(f([7,7,2,3,4,5,7,5]));
console.log(f([0,0,0,0,0,0,0,0]));

console.log(f([2,1,0,3,4,9,8,4]));
console.log(f([6,9,1,6,5,4,3,0]));
console.log(f([1,1,9,6,5,4,2,1]));
console.log(f([1,2,3,4,5,6,7,8]));

I was going to say you could save 3 bytes by switching from pre-recursion to post-recursion with g=([n,...s],i=3,t=0)=>n?g(s,4-i,t+n*i):t%10<1, but you may have found a better way...

Thanks, @ETHproductions, I've changed to map, which I think works better since input can be a list of digits instead of a string.

Perhaps save another byte with s=>s.map(e=>t+=e*(i=4-i),t=i=1)&&t%10==1?

Yes, brilliant, thanks : )

Great solution! Could you replace && with | to output 1/0 since truthy/falsy is allowed?

One more byte with i^=2?

Sweet, thanks @ETHproductions!

Python 2, 64 48 35 29 bytes
mypetlion saved 19 bytes
lambda x:sum(x[::2]*2+x)%10<1

Try it online!

lambda x:sum(x[::2]*3+x[1::2])%10<1 For 35 bytes.

lambda x:sum(x[::2]*2+x)%10<1 For 29 bytes.

Jelly, 8 bytes
m2Ḥ+µS⁵ḍ

Try the test suite.
Jelly, 9 bytes
JḂḤ‘×µS⁵ḍ

Try it online or Try the test suite.
How this works

m2Ḥ+µS⁵ḍ ~ Full program.

m2       ~ Modular 2. Return every second element of the input.
  Ḥ      ~ Double each.
   +µ    ~ Append the input and start a new monadic chain.
     S   ~ Sum.
      ⁵ḍ ~ Is divisible by 10?

JḂḤ‘×µS⁵ḍ  ~ Full program (monadic).

J          ~ 1-indexed length range.
 Ḃ         ~ Bit; Modulo each number in the range above by 2.
  Ḥ        ~ Double each.
   ‘       ~ Increment each.
    ×      ~ Pairwise multiplication with the input.
     µ     ~ Starts a new monadic chain.
      S    ~ Sum.
       ⁵ḍ  ~ Is the sum divisible by 10?

The result for the first 7 digits of the barcode and the checksum digit must add to a multiple of 10 for it to be valid. Thus, the checksum is valid iff the algorithm applied to the whole list is divisible by 10.

Still 9 bytes but with consistent values: JḂḤ‘×µS⁵ḍ

@HyperNeutrino Thanks, I knew there was an atom for this!

Also 9 bytes: JḂaḤ+µS⁵ḍ :P

@HyperNeutrino Well there are a lot of alternatives :P

8 bytes or 8 characters? m2Ḥ+µS⁵ḍ is 15 bytes in UTF-8, unless I've calculated it wrong.

@ta.speot.is 8 bytes, Jelly has its own codepage

MATL, 10 bytes
Thanks to @Zgarb for pointing out a mistake, now corrected.
IlhY"s10\~

Try it online! Or verify all test cases.
Explanation
Ilh     % Push [1 3]
Y"      % Implicit input. Run-length decoding. For each entry in the
        % first input, this produces as many copies as indicated by
        % the corresponding entry of the second input. Entries of
        % the second input are reused cyclically
s       % Sum of array
10\     % Modulo 10
~       % Logical negate. Implicit display

Befunge-98 (PyFunge), 16 14 bytes
Saved 2 bytes by skipping the second part using j instead of ;s, as well as swapping a ~ and + in the first part to get rid of a + in the second.
~3*+~+6jq!%a+2

Input is in 8 digits (with leading 0s if applicable) and nothing else.
Outputs via exit code (open the debug dropdown on TIO), where 1 is true and 0 is false.
Try it online!
Explanation
This program uses a variety of tricks.
First of all, it takes the digits in one by one through their ASCII values. Normally, this would require subtracting 48 from each value as we read it from the input. However, if we don't modify it, we are left with 16 (3+1+3+1+3+1+3+1) extra copies of 48 in our sum, meaning our total is going to be 768 greater than what it "should" be. Since we are only concerned with the sum mod 10, we can just add 2 to the sum later. Thus, we can take in raw ASCII values, saving 6 bytes or so.
Secondly, this code only checks if every other character is an EOF, because the input is guaranteed to be only 8 characters long.
Thirdly, the # at the end of the line doesn't skip the first character, but will skip the ; if coming from the other direction. This is better than putting a #; at the front instead.
Because the second part of our program is only run once, we don't have to set it up so that it would skip the first half when running backwards. This lets us use the jump command to jump over the second half, as we exit before executing it going backwards.
Step by step
Note: "Odd" and "Even" characters are based on a 0-indexed system. The first character is an even one, with index 0.
~3*+~+      Main loop - sum the digits (with multiplication)
~           If we've reached EOF, reverse; otherwise take char input. This will always
                be evenly indexed values, as we take in 2 characters every loop.
 3*+        Multiply the even character by 3 and add it to the sum.
    ~       Then, take an odd digit - we don't have to worry about EOF because
                the input is always 8 characters.
     +      And add it to the sum.
      6j    Jump over the second part - We only want to run it going backwards.

        q!%a+2    The aftermath (get it? after-MATH?)
            +2    Add 2 to the sum to make up for the offset due to reading ASCII
          %a      Mods the result by 10 - only 0 if the bar code is valid
         !        Logical not the result, turning 0s into 1s and anything else into 0s
        q         Prints the top via exit code and exits

C,  78  77 bytes
i,s,c,d=10;f(b){for(i=s=0,c=b%d;b/=d;)s+=b%d*(3-i++%2*2);return(d-s%d)%d==c;}

Try it online!
C (gcc), 72 bytes
i,s,c,d=10;f(b){for(i=s=0,c=b%d;b/=d;)s+=b%d*(i++%2?:3);b=(d-s%d)%d==c;}

Try it online!

Wolfram Language (Mathematica), 26 21 bytes
10∣(2-9^Range@8).#&

Try it online!
Takes input as a list of 8 digits.
How it works
2-9^Range@8 is congruent modulo 10 to 2-(-1)^Range@8, which is {3,1,3,1,3,1,3,1}. We take the dot product of this list with the input, and check if the result is divisible by 10.
Wolfram Language (Mathematica), 33 bytes and non-competing
Check[#~BarcodeImage~"EAN8";1,0]&

Try it online!
Takes input as a string. Returns 1 for valid barcodes and 0 for invalid ones.
How it works
The best thing I could find in the way of a built-in (since Mathematica is all about those).
The inside bit, #~BarcodeImage~"EAN8";1, generates an image of the EAN8 barcode, then ignores it entirely and evaluates to 1. However, if the barcode is invalid, then BarcodeImage generates a warning, which Check catches, returning 0 in that case.

Are you doing the calculation by hand because it's shorter, or because Wolfram doesn't yet have a ValidateEAN8BarCode() function somewhere in its standard library?

@Mark Mathematica can't validate the barcode directly, but I just found BarcodeImage, which generates the image of the barcode, and validates the barcode in the process. So Check[#~BarcodeImage~"EAN8";0,1]<1& would work (but it's longer).

Haskell, 40 38 bytes
a=3:1:a
f x=mod(sum$zipWith(*)a x)10<1

Try it online!
Takes input as a list of 8 integers. A practical example of using infinite lists.
Edit: Saved 2 bytes thanks to GolfWolf

Using a recursive definition instead of cycle saves 2 bytes.

Java 8, 58 56 55 bytes
a->{int r=0,m=1;for(int i:a)r+=(m^=2)*i;return r%10<1;}

-2 bytes indirectly thanks to @RickHitchcock, by using (m=4-m)*i instead of m++%2*2*i+i after seeing it in his JavaScript answer.
-1 byte indirectly thanks to @ETHProductions (and @RickHitchcock), by using (m^=2)*i instead of (m=4-m)*i.
Explanation:
Try it here.
a->{              // Method with integer-array parameter and boolean return-type
  int r=0,        //  Result-sum
      m=1;        //  Multiplier
  for(int i:a)    //  Loop over the input-array
    r+=           //   Add to the result-sum:
       (m^=2)     //    Either 3 or 1,
       *i;        //    multiplied by the digit
                  //  End of loop (implicit / single-line body)
  return r%10<1;  //  Return if the trailing digit is a 0
}                 // End of method

You can save another byte with a trick @ETHProductions showed me:  change m=4-m to m^=2.

@RickHitchcock Ah, of course.. I use ^=1 pretty often in answers when I want to alter between 0 and 1. ^=2 works in this case to alter between 1 and 3. Nice trick, and thanks for the comment to mention it. :)

05AB1E, 14 bytes
θ¹¨3X‚7∍*O(T%Q

Try it online!
Needs leading 0s, takes list of digits.

Seems to fail on 3100004 (should be truthy).

@Zgarb You're missing a 0 there.

Oh, it takes a string? Okay then, my bad.

@Zgarb Well, you can omit the quotes, but yes, you do need the leading 0. This answer actually uses number functions on strings, one of the features of 05AB1E.

@Mr.Xcoder The question isn't very clear on that, I'll add another code which does handle for that below.

Pyth, 8 bytes
!es+*2%2

Verify all the test cases!
Pyth, 13 bytes
If we can assume the input always has exactly 8 digits:
!es.e*bhy%hk2

Verify all the test cases!

How does this work?

!es+*2%2 ~ Full program.

      %2 ~ Input[::2]. Every second element of the input.
    *2   ~ Double (repeat list twice).
   +     ~ Append the input.
  s      ~ Sum.
 e       ~ Last digit.
!        ~ Logical NOT.

!es.e*sbhy%hk2 ~ Full program.

               ~ Convert the input to a String.
   .e          ~ Enumerated map, storing the current value in b and the index in k.
          %hk2 ~ Inverted parity of the index. (k + 1) % 2.
        hy     ~ Double, increment. This maps odd integers to 1 and even ones to 3.
      b        ~ The current digit.
     *         ~ Multiply.
  s            ~ Sum.
 e             ~ Last digit.
!              ~ Logical negation.

If the sum of the first 7 digit after being applied the algorithm is subtracted from 10 and then compared to the last digit, this is equivalent to checking whether the sum of all the digits, after the algorithm is applied is a multiple of 10.

Seems to fail on 3100004 (should be truthy).

@Zgarb Wait should we do 3*3+1*1+0*3+... or 0*3+3*1+1*0..? I thought we are supposed to do the former

In the new spec, leading digits are added to ensure there are exactly 8 (if I understand correctly).

@Zgarb Ok, fixed.

Retina, 23 22 bytes
-1 byte thanks to Martin Ender!
(.).
$1$1$&
.
$*
M`
1$

Try it online!
Explanation
Example input: 20378240
(.).
$1$1$&

Replace each couple of digits with the first digit repeated twice followed by the couple itself.
We get 2220333788824440
.
$*

Convert each digit to unary. With parentheses added for clarity, we get (11)(11)(11)()(111)(111)...
M`

Count the number of matches of the empty string, which is one more than the number of ones in the string. (With the last two steps we have basically taken the sum of each digit +1) Result: 60
1$

Match a 1 at the end of the string. We have multiplied digits by 3 and 1 alternately and summed them, for a valid barcode this should be divisible by 10 (last digit 0); but we also added 1 in the last step, so we want the last digit to be 1. Final result: 1.

I think you can drop the . on the match stage and match 1$ at the end.

@MartinEnder very nice, I'll do that, thanks!

Jelly, 16 bytes
ż3,1ṁ$P€SN%⁵
Ṫ=Ç

Try it online!
takes input as a list of digits

Nitpick: your TIO timeouts. Also, 16 bytes.

@EriktheOutgolfer Wait what how. It works when I put the D in the footer. And yay thanks! :D

@EriktheOutgolfer Am I doing something wrong? Your 16-byter appears to be invalid?

Maybe, it works kinda differently, but yours seems a bit invalid too...specifically I think the last line should be DµṪ=Ç.

@EriktheOutgolfer Oh that would make sense. Yeah fixed that for +1 and I'll see what I'm doing wrong with your golf

Looks like the 00000000 case has issues with mine. Since D returns [0], Ṫ gets 0 and Ç gets [] and trying to multiply with [3, 1, 3, 1, 3, 1, 3] returns [3, 1, 3, 1, 3, 1, 3] then sum returns 15 negate returns -15 and mod 10 then returns 5 which is unequal to 0.

Seems to fail on 3100004 (should be truthy).

@Zgarb How is 3 * 3 + 1 * 1 = 4?

@HyperNeutrino You need to do 0*3+3*1+1*3 = 4 (if I understand correctly).

@HyperNeutrino In the spec, leading zeros are added to ensure the input has exactly 8 digits, if you take it as an integer.

@Zgarb Oh I didn't see the spec change. In that case I'll just take it as digits

I managed to abuse Jelly's 1-indexing to get 10 bytes.

@Mr.Xcoder Oh wow nice +1

PowerShell, 85 bytes
param($a)(10-(("$a"[0..6]|%{+"$_"*(3,1)[$i++%2]})-join'+'|iex)%10)%10-eq+"$("$a"[7])"

Try it online! or Verify all test cases
Implements the algorithm as defined. Takes input $a, pulls out each digit with "$a"[0..6] and loops through them with |%{...}. Each iteration, we take the digit, cast it as a string "$_" then cast it as an int + before multiplying it by either 3 or 1 (chosen by incrementing $i modulo 2).
Those results are all gathered together and summed -join'+'|iex. We take that result mod 10, subtract that from 10, and again take the result mod 10 (this second mod is necessary to account for the 00000000 test case). We then check whether that's -equal to the last digit. That Boolean result is left on the pipeline and output is implicit.

Seems to fail on 3100004 (should be truthy).

@Zgarb Works for me? Try it online!

Ah ok, I tested it without the quotes.

@Zgarb Ah, yeah. Without the quotes, PowerShell will implicitly cast as an integer, stripping the leading zero(s).

J, 17 bytes
-10 bytes thanks to cole
0=10|1#.(8$3 1)*]

Try it online!
This uses multiplication of equal sized lists to avoid the zip/multiply combo of the original solution, as well as the "base 1 trick" 1#. to add the products together.  The high level approach is similar to the original explanation.
original, 27 bytes
0=10|{:+[:+/[:*/(7$3 1),:}:

Try it online!
explained
0 =                                        is 0 equal to...
    10 |                                   the remainder when 10 divides...
         {: +                              the last input item plus...
              [: +/                        the sum of...
                    [: */                  the pairwise product of...
                          7$(3 1) ,:       3 1 3 1 3 1 3 zipped with...
                                     }:    all but the last item of the input

0=10|1#.(8$3 1)*] should work for 17 bytes (does the same algorithm, too). I'm pretty sure that in the beta you can have a hook ended on the right side with a noun, so 0=10|1#.]*8$3 1 may work for 15 (I'd check on tio but it seems to be down?)

@cole, I love this improvement.  I've learned about and forgotten the 1#. trick like 2 or 3 times... thanks for reminding me.  Oh btw the 15 byte version did not work in TIO.

C (gcc), 84 82 72 61 54 bytes
c;i;f(x){for(i=c=0;x;x/=10)c+=(1+2*i++%4)*x;c=c%10<1;}

-21 bytes from Neil
-7 bytes from Nahuel Fouilleul
Try it online!
Developed independently of Steadybox's answer
'f' is a function that takes the barcode as an int, and returns 1 for True and 0 for False.

f stores the last digit of x in s (s=x%10),
Then calculates the sum in c (for(i=c=0;x;x/=10)c+=(1+2*i++%4)*x;)

c is the sum, i is a counter
for each digit including the first, add 1+2*i%4 times the digit (x%10) to the checksum and increment i (the i++ in 3-2*i++%4)

1+2*i%4 is 1 when i is even and 0 when i is odd

Then returns whether the sum is a multiple of ten, and since we added the last digit (multiplied by 1), the sum will be a multiple of ten iff the barcode is valid. (uses GCC-dependent undefined behavior to omit return).

I think (x%10) can just be x as you're taking c%10 later anyway. Also I think you can use i<8 and then just test whether c%10 is zero at the end.

@Neil Thanks! That got -10 bytes.

In fact I think s is unnecessary: c;i;f(x){for(i=c=0;i<8;x/=10)c+=(1+2*i++%4)*x;return c%10<1;}

the tio link is 61 bytes but in the answer it's 72, also don't know why x=c%10<1 or c=c%10<1 instead of return c%10<1 still works

also i<8 can be replaced by x

APL (Dyalog), 14 bytes
Equivalent with streetster's solution.
Full program body. Prompts for list of numbers from STDIN.
0=10|+/⎕×8⍴3 1

Try it online!
Is…
 0= zero equal to
 10| the mod-10 of
 +/ the sum of
 ⎕× the input times
 8⍴3 1 eight elements cyclically taken from [3,1]
?

You mean APL can't do it in one character from something like Ancient Sumerian or Linear B?

train: 0=10|-/+2×+/

05AB1E, 9 bytes
3X‚7∍*OTÖ

Try it online!
3X‚7∍*OTÖ    # Argument a
3X‚          # Push [3, 1]
   7∍        # Extend to length 7
     *       # Multiply elements with elements at same index in a
      O      # Total sum
       TÖ    # Divisible by 10

Nice! First thing I thought was "extend to length" when I saw this, haven't used that one yet.

31×S*OTÖ for 8 bytes. × just pushes 31 n number of times. When you multiply, it automatically drops the extra 31's.

@MagicOctopusUrn That seems to fail on the 6th testcase 69165430 -> 1

C, 63 bytes
i;s=0;c(int*v){for(i=0;i<8;i++){s+=v[i]*3+v[++i];}return s%10;}

Assumes that 0 is true and any other value is false.
+3 bytes for better return value
i;s=0;c(int*v){for(i=0;i<8;i++){s+=v[i]*3+v[++i];}return s%10==0;}

Add ==0 to the return statement.
Ungolfed
int check(int* values)
{
    int result = 0;
    for (int index = 0; index < 8; index++)
    {
        result += v[i] * 3 + v[++i]; // adds this digit times 3 plus the next digit times 1 to the result
    }
    return result % 10 == 0; // returns true if the result is a multiple of 10
}

This uses the alternative definition of EAN checksums where the check digit is chosen such that the checksum of the entire barcode including the check digit is a multiple of 10. Mathematically this works out the same but it's a lot simpler to write.
Initialising variables inside loop as suggested by Steadybox, 63 bytes
i;s;c(int*v){for(i=s=0;i<8;i++){s+=v[i]*3+v[++i];}return s%10;}

Removing curly brackets as suggested by Steadybox, 61 bytes
i;s;c(int*v){for(i=s=0;i<8;i++)s+=v[i]*3+v[++i];return s%10;}

Using <1 rather than ==0 for better return value as suggested by Kevin Cruijssen
i;s=0;c(int*v){for(i=0;i<8;i++){s+=v[i]*3+v[++i];}return s%10<1;}

Add <1 to the return statement, this adds only 2 bytes rather than adding ==0 which adds 3 bytes.

You can save two bytes by removing the {} after the for. Also, function submissions have to be reusable, so you need to initialize s inside the function (just change i;s=0; to i,s; and i=0; to i=s=0;).

@Steadybox How can I remove the curly brackets?

There's only one statement inside them. When there are no curly brackets after for, the loop body will be the next statement. for(i=0;i<8;i++){s+=v[i]*3+v[++i];} is the same as for(i=0;i<8;i++)s+=v[i]*3+v[++i];.

@Steadybox Oh of course. That's one of the quirks of C syntax that I usually forget about, because when writing normal code I always include the curly brackets even if they're unnecessary, because it makes the code more readable.

In your true/false answer, instead of +3 by adding ==0 it can be +2 by using <1 instead. :)

@KevinCruijssen Good catch!

JavaScript (Node.js), 47 bytes
e=>eval(e.map((a,i)=>(3-i%2*2)*a).join`+`)%10<1

Although there is a much shorter answer already, this is my first attempt of golfing in JavaScript so I'd like to hear golfing recommendations :-)
Testing

let f=

e=>eval(e.map((a,i)=>(3-i%2*2)*a).join`+`)%10<1

console.log(f([2,0,3,7,8,2,4,0]));
console.log(f([3,3,7,6,5,1,2,9]));
console.log(f([7,7,2,3,4,5,7,5]));
console.log(f([0,0,0,0,0,0,0,0]));

console.log(f([2,1,0,3,4,9,8,4]));
console.log(f([6,9,1,6,5,4,3,0]));
console.log(f([1,1,9,6,5,4,2,1]));
console.log(f([1,2,3,4,5,6,7,8]));

Alternatively, you can Try it online!

K (oK), 16 15 bytes
Solution:
{~10!+/x*8#3 1}

Try it online!
Examples:
{~10!+/x*8#3 1}2 1 0 3 4 9 8 5
1
{~10!+/x*8#3 1}2 1 0 3 4 9 8 4
0
{~10!+/x*8#3 1}2 0 3 7 8 2 4 0
1

Explanation:
K is interpreted right-to-left:
{~10!+/x*8#3 1} / the solution
{             } / lambda with x as implicit input
           3 1  / the list [3,1]
         8#     / 8 take this list = [3,1,3,1,3,1,3,1]
       x*       / multiply input by this
     +/         / sum over the list
  10!           / 10 mod this sum
 ~              / not, 0 => 1, anything else => 0

Perl 5, 37 32 + 1 (-p) bytes
s/./$-+=$&*(--$|*2+1)/ge;$_=/0$/

-5 bytes thanks to Dom Hastings.
 37 +1 bytes was
$s+=$_*(++$i%2*2+1)for/./g;$_=!!$s%10

try it online

Had a little play with this and thought I'd share a useful trick: --$| toggles between 1 and 0 so you can use that instead of ++$i%2 for an alternating boolean! Also, all that matters is that the total ($s) matches /0$/, managed to get 33 bytes combining those changes with s///: Try it online! (-l is just for visibility)

yes i though to s/./(something with $&)/ge and to /0$/ match but not the two combined.

Brainfuck, 228 Bytes
>>>>++++[<++>-]<[[>],>>++++++[<++++++++>-]<--[<->-]+[<]>-]>[->]<<<<[[<+>->+<]<[>+>+<<-]>>[<+>-]<<<<<]>>>>[>>[<<[>>+<<-]]>>]<<<++++[<---->-]+++++[<++<+++>>-]<<[<[>>[<<->>-]]>[>>]++[<+++++>-]<<-]<[[+]-<]<++++++[>++[>++++<-]<-]>>+.

Can probably be improved a fair bit.
Input is taken 1 digit at a time, outputs 1 for true, 0 for false.
How it works:
>>>>++++[<++>-]<

Put 8 at position 3.
[[>],>>++++++[<++++++++>-]<--[<->-]+[<]>-]

Takes input 8 times, changing it from the ascii value to the actual value +2 each time. Inputs are spaced out by ones, which will be removed, to allow for easier multiplication later.
>[->]

Subtract one from each item. Our tape now looks something like
0 0 0 0 4 0 4 0 8 0 7 0 6 0 2 0 3 0 10 0 0
                                         ^

With each value 1 more than it should be. This is because zeros will mess up our multiplication process.
Now we're ready to start multiplying.
<<<<

Go to the second to last item.
[[<+>->+<]<[>+>+<<-]>>[<+>-]<<<<<]

While zero, multiply the item it's at by three, then move two items to the left. Now we've multiplied everything we needed to by three, and we're at the very first position on the tape.
>>>>[>>[<<[>>+<<-]]>>]

Sum the entire list.
<<<++++[<---->-]

The value we have is 16 more than the actual value. Fix this by subtracting 16.
+++++[<++<+++>>-]

We need to test whether the sum is a multiple of 10. The maximum sum is with all 9s, which is 144. Since no sum will be greater than 10*15, put 15 and 10 on the tape, in that order and right to the right of the sum.
<<[<[>>[<<->>-]]>[>>]++[<+++++>-]<<-]

Move to where 15 is. While it's non-zero, test if the sum is non-zero. If it is, subtract 10 from it. Now we're either on the (empty) sum position, or on the (also empty) ten position. Move one right. If we were on the sum position, we're now on the non-zero 15 position. If so, move right twice. Now we're in the same position in both cases. Add ten to the ten position, and subtract one from the 15 position.
The rest is for output:
<[[+]-<]<++++++[>++[>++++<-]<-]>>+.

Move to the sum position. If it is non-zero (negative), the barcode is invalid; set the position to -1. Now add 49 to get the correct ascii value: 1 if it's valid, 0 if it's invalid.

Java 8, 53 bytes
Golfed:
b->(3*(b[0]+b[2]+b[4]+b[6])+b[1]+b[3]+b[5]+b[7])%10<1

Direct calculation in the lambda appears to the shortest solution. It fits in a single expression, minimizing the lambda overhead and removing extraneous variable declarations and semicolons.
public class IsMyBarcodeValid {

  public static void main(String[] args) {
    int[][] barcodes = new int[][] { //
        { 2, 0, 3, 7, 8, 2, 4, 0 }, //
        { 3, 3, 7, 6, 5, 1, 2, 9 }, //
        { 7, 7, 2, 3, 4, 5, 7, 5 }, //
        { 0, 0, 0, 0, 0, 0, 0, 0 }, //
        { 2, 1, 0, 3, 4, 9, 8, 4 }, //
        { 6, 9, 1, 6, 5, 4, 3, 0 }, //
        { 1, 1, 9, 6, 5, 4, 2, 1 }, //
        { 1, 2, 3, 4, 5, 6, 7, 8 } };
    for (int[] barcode : barcodes) {
      boolean result = f(b -> (3 * (b[0] + b[2] + b[4] + b[6]) + b[1] + b[3] + b[5] + b[7]) % 10 < 1, barcode);
      System.out.println(java.util.Arrays.toString(barcode) + " = " + result);
    }
  }

  private static boolean f(java.util.function.Function<int[], Boolean> f, int[] n) {
    return f.apply(n);
  }
}

Output:
[2, 0, 3, 7, 8, 2, 4, 0] = true
[3, 3, 7, 6, 5, 1, 2, 9] = true
[7, 7, 2, 3, 4, 5, 7, 5] = true
[0, 0, 0, 0, 0, 0, 0, 0] = true
[2, 1, 0, 3, 4, 9, 8, 4] = false
[6, 9, 1, 6, 5, 4, 3, 0] = false
[1, 1, 9, 6, 5, 4, 2, 1] = false
[1, 2, 3, 4, 5, 6, 7, 8] = false

C# (.NET Core), 65 62 bytes
b=>{int s=0,i=0,t=1;while(i<8)s+=b[i++]*(t^=2);return s%10<1;}

Try it online!
Acknowledgements
-3 bytes thanks to @KevinCruijssen and the neat trick using the exclusive-or operator.
DeGolfed
b=>{
    int s=0,i=0,t=1;

    while(i<8)
        s+=b[i++]*(t^=2); // exclusive-or operator alternates t between 3 and 1.

    return s%10<1;
}

C# (.NET Core), 53 bytes
b=>(3*(b[0]+b[2]+b[4]+b[6])+b[1]+b[3]+b[5]+b[7])%10<1

Try it online!
A direct port of @Snowman's answer.

For your first answer: b=>{int s=0,i=0,t=1;while(i<8)s+=b[i++]*(t^=2);return s%10<1;} (62 bytes), or alternatively with a foreach, also 62 bytes: b=>{int s=0,t=1;foreach(int i in b)s+=i*(t^=2);return s%10<1;} (which is a port of my Java 8 answer).

QBasic, 54 52 bytes
Ugh, the boring answer turned out to be the shortest:
INPUT a,b,c,d,e,f,g,h
?(3*a+b+3*c+d+3*e+f+3*g+h)MOD 10=0

This inputs the digits comma-separated. My original 54-byte solution, which inputs one digit at a time, uses a "nicer" approach:
m=3
FOR i=1TO 8
INPUT d
s=s+d*m
m=4-m
NEXT
?s MOD 10=0

Vyxal, 8 bytes
y$3*J∑₀Ḋ

Try it Online!
y        # Uninterleave
 $       # Swap
  3*     # Multiply by 3 (vectorised)
    J    # Join
     ∑   # Sum
      ₀Ḋ # Is divisible by 10?

Ruby, 41 Bytes
Takes an array of integers. -6 bytes thanks to Jordan.
->n{n.zip([3,1]*4){|x,y|$.+=x*y};$.%10<1}

Nice! FWIW you don’t need map here at all: zip takes a block. You can save a couple more bytes by using $. instead of initializing s: ->n{n.zip([3,1]*4){|x,y|$.+=x*y};$.%10<1}

MATLAB/Octave, 32 bytes
@(x)~mod(sum([2*x(1:2:7),x]),10)

Try it online!
I'm going to post this despite the other Octave answer as I developed this code and approach without looking at the other answers.
Here we have an anonymous function which takes the input as an array of 8 values, and return true if a valid barcode, false otherwise..
The result is calculated as follows.
              2*x(1:2:7)
             [          ,x]
         sum(              )
     mod(                   ,10)
@(x)~

Odd digits (one indexed) are multiplied by 2.
The result is prepended to the input array, giving an array whose sum will contain the odd digits three times, and the even digits once.
We do the sum which will also include the supplied checksum within our sum.
Next the modulo 10 is performed. If the checksum supplied was valid, the sum of all multiplied digits including the checksum value would end up being a multiple of 10. Therefore only a valid barcode would return 0.
The result is inverted to get a logical output of true if valid.

Japt, 12 11 bytes
Takes input as an array of digits, outputs 1 or 0.
xÈ*31sgYÃvA

Try it

Excel, 37 bytes
Interpreting "A list of 8 integers" as allowing 8 separate cells in Excel:
=MOD(SUM(A1:H1)+2*(A1+C1+E1+G1),10)=0

=MOD(SUM((A1:H1)+2*(A1+C1+E1+G1)),10)=0  this formula exist in Excel?

@RosLuP, not predefined, no.  But Modulo, Sum, + etc do ;-)

I want only to say that seems that in APL goes well doing first y= (A1:H1)+2*(A1+C1+E1+G1), and after the sum and the mod; in APL not goes well first sum(A1:H1) etc something as (1,2,3)+4=(5,6,7) and than sum(5,6,7)=18; note that sum(1,2,3)=6 and 6+4=10 different from 18. But possible I make error in something

@RosLuP, Apologies, missed the changed ()s in your comment.

Problem is how Excel interprets =(A1:H1):
This is not handled as an array.
Is invalid if placed in any column not in A-H range.
If placed in a column in A-H, returns the value for that column only.
(Formula in % results in %:
C2 --> C1
H999 --> H1
K1 --> #VALUE!)

TI-Basic (83 series), 18 bytes
not(fPart(.1sum(2Ans-Ans9^cumSum(binomcdf(7,0

Takes input as a list in Ans. Returns 1 for valid barcodes and 0 for invalid ones.
A port of my Mathematica answer. Includes screenshot, in lieu of an online testing environment:

Notable feature: binomcdf(7,0 is used to generate the list {1,1,1,1,1,1,1,1} (the list of probabilities that from 7 trials with success probability 0, there will be at most N successes, for N=0,1,...,7). Then, cumSum( turns this into {1,2,3,4,5,6,7,8}.
This is one byte shorter than using the seq( command, though historically the point was that it's also significantly faster.

><>, 89 84 Bytes
8>i$1\
/\?:-/
\8+  \
/1-:?v~r3*+\
\ } \$>3*+v<
/++-/f}   l
\+3ff/\?-4/
/a+++/
\%0=n;

Can probably certainly be improved (this is my second ><> program)
How it works:
8>i$1\
 \?:-/

Gets user input, 8 times. Note that since i pushes -1 if the input stack is empty, this may not always return false for inputs shorter than 8 digits.
/
\8+  \
/1-:?v
\ } \$
/++-/f
\+3ff/

Converts the ascii values to their actual values.
      ~r3*+\
      >3*+v<
      }   l
      \?-4/

Remove the counter, and reverse the stack. Then, while the stack is longer than 4, multiply the top value by three, add it to the digit below it, and move the result to the bottom of the stack.
     /
/a+++/
\%0=n;

Sum the values on the stack. If the answer is divisible by 10, the code is valid. If so, print 1, otherwise, 0.

Nice work! Here are a couple of suggestions to help get the bytes down. You can use the fish's wrapping behaviour to cut down on direction commands — it's often possible to fit a loop on a single line, with clever use of / and ?. The register (accessed with &) is a good place to store a counting variable, like you use to count how many times to go through a loop. Here's what your code might look like after applying these ideas (and a couple of others): Try it online!

Julia 29 bytes
~x=[3,1,3,1,3,1,3,1]⋅x%10<1

golfing away that long literal array would be nice.
⋅ is a 3 byte character.
But it is shorter than calling dot(...,x).
and shorter that anything that handles everything as arrays and then grabs the only element.

!x=~2(1:8)%4⋅x%10==0  saves a few bytes. Try it online!

Acc!!, 60 45 bytes
3*N+N+3*N+N+3*N+N+3*N+N-8
Write 1/(1+_%10)+48

Try it online!
Explanation
We read eight digits, multiplying the appropriate ones by 3, and add. It's not quite that simple, because what we're actually reading is ASCII codes, and so each digit has 48 added to it. Thus, the resulting sum is too big by 3*48*4 + 48*4 = 768. We only care about the 1's digit, so subtracting 8 is sufficient to get the correct result.
We want to print 1 if the accumulator mod 10 is 0, and 0 otherwise. Acc!! doesn't have comparison operators, so we have to use integer division:
_%10        0  1  9
1+_%10      1  2  10
1/(1+_%10)  1  0  0

Then we add 48 to get an ASCII value and Write it.

Original 60-byte solution with a loop:
Count i while 8-i {
_+(N-48)*(3-i%2*2)
}
Write 1/(1+_%10)+48

C 98, 118 bytes
Ive edited this now to instead of echoing F or T it will return 0 or 1 to the pipe.
int i,j,k;int main(int,char**v){for(;i<7;(j+=(v[1][i]-48)*(i++%2?1:3)));for(;(k+=10)<j;);return v[1][7]-48==(k-j)%10;}

usage:
./a.out XXXXXXXX

where XXXXXXXX is a zero padded string, it will return either a 0 or a 1 as an exit code
this is 118 chars long in total. and the the compiled program is
   text    data     bss     dec     hex filename
   1307     544      16    1867     74b a.out

Welcome to the site! I don't think that C requires newlines after semi-colons, so I think you can shave off a newline while retaining your functionality.

Oh yeah for sure could've totally done that and bring it down to a 154 char solution. Though I don't think I could ever hit some of those 9 byte solutions with c.

It's best not to try to compare cross languages, the languages with the small solutions are designed to get short answers in the first place. (I've been here a while and I've never had the shortest answer yet)  C answers can be impressive in their own right.  I don't golf in C but I do know C a little bit and this seems like a pretty good answer to me.  It's all about how cleverly you use the tools.

Husk, 10 bytes
¬→dB3mΣTC2

Try it online!
Husk, 10 bytes
¦10B3mΣTC2

Try it online!

Perl 6, 23 bytes
{:1[$_ «*»(3,1)]%%10}

Try it online!
Takes a list of digits.

Ruby, 37 bytes
->n{(n+n.scan(/.(.)/)*''*2).sum%10<1}

Try it online!

Batch, 88 bytes
@set/as=0,n=%1
@for %%i in (1 2 3 4)do @set/as+=n+n/10*3,n/=100
@if %s:~-1%==0 echo 1

N.B. Leading zeros are not acceptable as they will cause the input to be treated as octal. As the numbers are always 8 digits the loop size can be hardcoded which saves 2 bytes.

Java (OpenJDK 8), 104 99 bytes
s->{int y=0,i=0;for(;i<7;y+=(3-i%2*2)*(s.charAt(i++)-48));return 58-(y%10<1?10:y%10)==s.charAt(7);}

Try it online!

Suggest return(y%10<1?10:y%10)+s.charAt(7)==58; instead of return 58-(y%10<1?10:y%10)==s.charAt(7);

Pyke, 14 13 12 9 bytes
2%2*+sT%!

Try it here!
2%        -      input[::2]
  2*      -     ^ * 2
    +     -    input + ^
     s    -   sum(^)
      T%  -  ^ % 10
        ! - not ^

Thanks Mr. Xcoder for saving 3 bytes!

10 bytes: 2%2*+s10%!

Octave, 40 bytes
@(a)9-mod(a*("31313130"'-48)-1,10)==a(8)

Accepts an array of integers as input and returns true/false.
Try it online!

QBIC, 23 bytes
[4|_!_!p=p+b*3+c]?p%z=0

Explanation
[4|          DO four times
_!           Ask the user for a digit, save as 'b' ('a' is taken by [4| )
_!           Ask the user for a digit, save as 'c'
p=p          Add to running total p
+b*3         the first digit times 3
+c           and the second digit
]            NEXT
?p%z=0       PRINT -1 if the seven digits + checksum MOD 10 == 0

Perl 5, 54 + 1 (-F) = 55bytes
$r=pop@F;map$s+=$_*(($.+=2)%4),@F;say$r==(10-$s%10)%10

Try it online!

PHP, 82 bytes
<?for(;$i<strlen($p=$argv[1])-1;)$t+=($i%2?1:3)*$p[$i++];echo(10-$t%10)%10==$p[7];

Try it online!
Input as a string; prints 1 for valid, nothing for invalid.

Clojure, 41 bytes
#(=(mod(apply +(map *(cycle[3 1])%))10)0)

GolfScript - 54 52 bytes
1/[{~}/][):a;[3 1]3*[3]+]zip 0\{{*}*+}/10%10\- 10%a=

Input: 33765129
Output: 1

If the input is an array the code can be modified to:
~[):a;[3 1]3*[3]+]zip 0\{{*}*+}/10%10\- 10%a=     # 45 bytes

Input: [3 3 7 6 5 1 2 9]
Output: 1

Explanation
1/[{~}/]     # Parse input
[):a;        # Gets last digit
[3 1]3*[3]+  # Generates the vector [3 1 3 1 3 1 3]
]zip         # Transposes the vector [[input] [3 1s]]
0\{{*}*+}/   # Vector dot product
10%10\- 10%  # (10-ans mod10)mod10
a=           # Compare

C (gcc), 54 by pizzapants184 51 bytes
c;i;f(x){for(i=3,c=0;x;x/=10)c+=(i^=2)*x;c=c%10<1;}

Try it online!
This answer heavily builds upon the answer of pizzapants184, but improves the bytecount by 3. i would have commented, but rep is below 50. The 3 bytes are removed, by replacing i=0 (...) (1+2*i++%4) with i=3 (...) (i^=2).

R, 45 bytes 42 bytes
x=scan();(140-sum(x[-8]*c(3,1)))%%10==x[8]

Try it online!
Explanation:
140-         #the largest value possible is 135 (all 9's)
sum(
  x[-8]      #drop last value from input vector
     *c(3,1) #multiply by a automatically replicating vector of 3,1
)
  %%10       #modulo 10
== x[8]      #compare to the checksum

GolfScript, 16 bytes
0\~{\3*++}4*10%!

Try it online!
Example Input
2 0 3 7 8 2 4 0

Output:
1

How it Works
Takes a string of 8 digits separated by spaces. For convenience I have included a header which automatically adds spaces to the input.
0\                          - Add zero to stack and place under input
  ~                         - Dump digits in input string onto stack
   {     }4*                - Loop 4 times.
    \                       - Swap top two indices of stack
     3*                     - Multiply by three
       ++                   - Add twice
            10%             - Modulo 10
               !            - Logical(?) not

PHP, 50 bytes
while($c++<8)$s+=$argv[$c]*($c&1?3:1);echo$s%10<1;

Run with -nr, provide digits as separate command line arguments
or try it online.

APL (Dyalog Unicode), 36 bytes
f←{0=10∣+/⍵+2×+/⍵×8⍴0 1}

Try it online!
I just copy and modify (because that formula it seems wrong) the above Excel solution....

Z80 Assembly, 22 bytes
; INPUT:
;   HL = a memory location storing barcode as a sequence of integers
; OUTPUT:
;   flag Z signals that barcode is valid, NZ signals invalid barcode

CheckBarcode:
        xor a : ld bc,7*256+%10101010       ; B is the number of loop iterations
                                            ; bits of C say when factor 3 is to be used
AddLoop:
        sub (hl) : rl c : jr nc,Times1      ; negative checksum computation
Times3: sub (hl) : sub (hl)
Times1: inc hl : djnz AddLoop

        jr z,Check                          ; the ugly line to deal with 00000000

Rem:    add 10 : jr nc,Rem                  ; add 10s until the answer is non-negative...

Check:  cp (hl) : ret                       ; ...and compare it with 8th digit!

This task fits into 8-bit assembly quite well.

Tcl, 89 bytes
proc C L {lmap c $L {incr t [expr [incr i]%8?$i%2?3*$c:$c:0]}
expr [lindex $L 7]==-$t%10}

Try it online!

Tcl, 93 bytes
proc C s {expr ([regsub -all (.)(.) [string repl $s 7 7 0] {-3*\1-\2}])%10==[string in $s 7]}

Try it online!
Will golf it more later!

Jelly, 17 bytes
Ṗµ3,1ṁ×⁸S⁵a%⁵⁼³Ṫ¤

Try it online!
Explanation:
Ṗµ                 take off the last element
  3,1ṁ             repeat [3, 1] to the same length as the input without the last element
      ×⁸           multiply together
        S          sum
         ⁵a        abs(10 - sum)
           %⁵      mod 10
              ³Ṫ¤  the last element of the original input
             ⁼     are they equal?

05AB1E, 6 bytes
ιO3βTÖ

Try it online! Beats all other answers. Takes input as a list of digits with leading zeros.
ιO3βTÖ  # full program
     Ö  # is...
        # (implicit) list of...
 O      # sum...
        # (implicit) s...
 O      # of...
        # (implicit) each element of...
   β    # list of base-10 values of base...
  3     # literal...
   β    # digits of...
        # implicit input...
ι       # split into pieces of...
        # (implicit) 2...
ι       # with each digit of each element concatenated with digits in corresponding indices in other elements...
   β    # in decimal...
     Ö  # divisible by...
    T   # 10...
     Ö  # ?
        # implicit output

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


text:
Find the BCD difference of a number
BCD difference
Given an integer n, convert it to BCD (binary-coded decimal)  by replacing each decimal digit with its 4-digit binary representation
 234 -> 0 0 1 0 0 0 1 1 0 1 0 0

Then rotate the list of binary digits in order to find the largest and smallest numbers, representable by this list without other rearrangements.
max: 1 1 0 1 0 0 0 0 1 0 0 0  (the entire list rotated left 6 times)
min: 0 0 0 0 1 0 0 0 1 1 0 1 (the entire list rotated right 2 times)

Convert these numbers back to decimal, treating the list of bits as regular binary and subtract the smallest from the largest:
1 1 0 1 0 0 0 0 1 0 0 0 -> 3336
0 0 0 0 1 0 0 0 1 1 0 1 -> 141

3336 - 141 -> 3195

The output is the difference of the largest and smallest numbers found.
Test cases:
234 -> 3195
1234 -> 52155
12 -> 135
975831 -> 14996295
4390742 -> 235954919
9752348061 -> 1002931578825

Wolfram Language (Mathematica), 89 88 bytes
Thanks to Jenny_mathy for saving 1 byte.
i=IntegerDigits;Max@#-Min@#&[#~FromDigits~2&/@NestList[RotateRight,Join@@i[i@#,2,4],#]]&

Try it online!
This is terribly inefficient, because it generates n rotations of the BCD of n, which is way more than we need. We can make this is a bit more efficient by saving the result of the Join@@ in k and replacing the # at the end with Length@k. That lets us generate a scatterplot quite easily:

I'm really intrigued by the contrast of local structure and overall chaos.

Max@#-Min@#& saves a byte. right?

@Jenny_mathy Yeah, thanks! :)

I made this from our solutions Max@#-Min@#&[#~FromDigits~2&/@Partition[s=Join@@(i=IntegerDigits)[i@#,2,4],Tr[1^s],1,1]]& 89 bytes AND efficient. damn that byte!

Actually the plot is a repeated patern.Those "chaotic clouds" happen every 10^n (the plot "jumps" and create a new one): 1-9,10-99,100-999...   here are some different zooms:  https://imgur.com/RXLMkco

@Jenny_mathy sure, but the structure within these intervals appears very chaotic (with structures only at much smaller scales).

It's like throwing a rubber crazy ball in a room and taking snapshots: (1 per sec)(10/0.1sec)(100/0.01sec).All those groups depict 1 sec. The last group has just more data.But it is the same chaotic phenomenon in all scales... I think ;-)

Jelly, 13 bytes
Dd4d2FṙJ$ḄṢIS

Try it online!
How it works
Dd4d2FṙJ$ḄṢIS  Main link. Argument: n

D              Decimal; convert n to base 10 (digit array).
 d4            Divmod 4; map each digit d to [d/4, d%4].
   d2          Divmod 2; map each [d/4, d%4] to [[d/8, d/4%2], [d%4/2, d%2]].
     F         Flatten the resulting 3D binary array.
      ṙJ$      Take all possible rotations.
         Ḅ     Convert each rotation from binary to integer.
          Ṣ    Sort the resulting integer array.
           I   Take the forward differences.
            S  Take the sum.

Python 3, 115 108 bytes
thanks to Jonathan Frech for -7 bytes
k=''.join(f'{int(i):04b}'for i in input())
v=[int(k[i:]+k[:i],2)for i in range(len(k))]
print(max(v)-min(v))

Try it online!

PowerShell, 153 bytes
$b=[char[]]-join([char[]]"$args"|%{[convert]::toString(+"$_",2).PadLeft(4,'0')})
($c=$b|%{$x,$y=$b;[convert]::ToInt64(-join($b=$y+$x),2)}|sort)[-1]-$c[0]

Try it online!
Stupid lengthy .NET calls to convert to/from binary really bloats the length here. ;-)
We take input as $args, wrap it in a string, then cast it as a char-array. We loop over each digit, converting the digit toString in base 2 (i.e., turning the digit into a binary number), then .padLeft to make it a four-digit binary number. That resulting array of strings is then -joined into a single string and re-cast as a char-array before being saved into $b.
Next, we loop over $b, which just makes sure we loop enough times to account for every rotation. Each iteration, we peel off the first character into $x and the remaining characters into $y using multiple assignment. Then, we merge them back together into $b=$y+$x to move the first element to the end, i.e., effectively rotating the array by one. That's -joined into a string, which is used as the input to the convert call to turn the string from binary base 2 into an Int64. We then sort all of those resultant numbers and store them into $c. Finally, we take the biggest [-1] and subtract the smallest [0]. That's left on the pipeline and output is implicit.

Ohm v2, 15 bytes
€b4Ü. 0\;Jγó↕]a

Try it online!
Explanation:
€b4Ü. 0\;Jγó↕]a  Main wire, arguments: a (integer)

€       ;        Map the following over each digit of a...
 b                 Convert to binary
  4Ü               Right-justify w/ spaces to length 4
    . 0\           Replace all spaces with zeroes
         J       Join together binary digits
          γó     Get all possible rotations and convert back to decimal
            ↕    Find the minimum *and* maximum rotation
             ]a  Flatten onto stack and get the absolute difference

JavaScript (ES6), 118 100 99 bytes

f=
n=>(g=m=>Math[m](...[...s=(`0x1`+n-0).toString(2)].map(_=>`0b${s=0+s.slice(2)+s[1]}`)))`max`-g`min`
<input type=number min=0 oninput=o.textContent=f(this.value)><pre id=o>

Edit: Saved 11 bytes thanks to @RickHitchcock. Saved 1 byte thanks to @ETHproductions. Explanation: The 0x1 prefix causes the input to get reparsed as a hexadecimal number, whose binary is the same as the BCD of the original number with a 1 prefix (I think this is golfier than any other way of padding to a multiple of 4 digits). Excluding the prefix, which is changed from 1 to 0, the resulting string is then rotated at each possible position and converted from binary back to decimal. Finally the maximum and minimum are subtracted.

@RickHitchcock Wrap the string in double backticks... unless you want to write something like .join``  in which case you need triple backticks etc.

Good idea to use hexadecimal. Save 11 bytes like this: n=>(g=m=>Math[m](...[...s=(+`0x1${n}`).toString(2).slice(1)].map(_=>`0b${s=s.slice(1)+s[0]}`)))`max`-g`min`

@RickHitchcock Thanks, that helped me... slice... off another 7 bytes by removing another slice too!

The m=>Math[m] trick is great. Perhaps change (+`0x1${n}`) to ('0x1'+n-0) or similar?

Python 2, 115 113 bytes

Saved some bytes thanks to ovs.
Saved two bytes thanks to Mr. Xcoder.

b="".join(format(int(n),"04b")for n in`input()`)
b=[int(b[s:]+b[:s],2)for s in range(len(b))]
print max(b)-min(b)

Try it online!

Pyth, 29 bytes
Ksm.[\04.Bsd`Q-eJSmi.<Kd2lKhJ

Try it here! or Check out the test suite.

-3 or -5 bytes

Husk, 18 bytes
§-▼▲mḋUMṙNṁȯtḋ+16d

Try it online!
There should be a shorter way to convert a digit into its 4-bit binary representation...
Explanation
§-▼▲mḋUMṙNṁȯtḋ+16d
                 d    Get the list of digits of the input
          ṁȯ          For each digit...
              +16      add 16
             ḋ         convert to binary
            t          drop the first digit
       MṙN            Rotate the list by all possible (infinite) numbers
      U               Get all rotations before the first duplicated one
    mḋ                Convert each rotation from binary to int
§-▼▲                  Subtract the minimum from the maximum value

APL (Dyalog), 37 34 bytes
{(⌈/-⌊/)2⊥¨(⍳⍵)∘.⌽⊂,↑(4⍴2)∘⊤¨⍎¨⍕⍵}

Try it online!

APL (Dyalog), 31 bytes
Full program body. Prompts for number from STDIN. Prints result to STDOUT.
(⌈/-⌊/)2⊥¨(⍳≢b)⌽¨⊂b←,⍉(4/2)⊤⍎¨⍞

Try it online!
⍞ prompt for line of text from STDIN
⍎¨ execute (evaluate) each (character)
(…)⊤ encode (anti-base) in the following number system:
 4/2 four binary bits
⍉ transpose
, ravel (flatten)
b← store in b (for binary)
⊂ enclose (so that we will use this entire list for each rotation)
(…)⌽¨ rotate (left) by each of the following amounts:
≢b length of b
 ⍳ indices of that
2⊥¨ decode each from base-2.
(…) apply the following tacit function to that
 ⌈/ the max(-reduction)
 - minus
 ⌊/ the min(-reduction)

you could easily trainify this bit: (⍳≢b)⌽¨⊂b←

or even better - use (≢,/,⍨) instead of the obvious (⍳∘≢⌽¨⊂)

Jelly, 21 bytes
DB0;$4¡€ṫ€-3FṙJ$ḄµṀ_Ṃ

Try it online!

Mathematica, 110 99 bytes
Max@#-Min@#&[#~FromDigits~2&/@Partition[s=Join@@Tuples[{0,1},4][[IntegerDigits@#+1]],Tr[1^s],1,1]]&

Try it online!

Retina, 96 89 bytes
.
@@@$&
@(?=@@[89]|@[4-7]|[2367])
_
T`E`@
\d
_
.
$&$'$`¶
O`
_
@_
+`_@
@__
s`(_+).*\W\1

_

Try it online! Somewhat slow, so link only includes a small test case. Edit: Saved 7 bytes thanks to @MartinEnder. Explanation:
.
@@@$&

Prefix three @s to each digit. (These represent the 0s of the BCD, but are golfier.)
@(?=@@[89]|@[4-7]|[2367])
_

Change the @s to _s (representing the 1s of the BCD) where appropriate.
T`E`@
\d
_

Fix up the last digit of the BCD.
.
$&$'$`¶

Generate all of the rotations.
O`

Sort them into ascending order.
_
@_
+`_@
@__

Convert them to unary.
s`(_+).*\W\1

_

Subtract the first from the last number, ignoring intermediate numbers, and convert to decimal.

There's no need to use % for the binary to unary conversion and you can save a few more bytes by using other characters than 0 and 1 for binary: https://tio.run/##K0otycxL/P9fj0tRUVFFjUtRw95WUTHawjK2RjHaRNc8tibayNjMPFaTy5ErJME1QZErJgXI1ONSUVNRV0k4tI3LPwHIV3Tk0k5wVATSjlzFCRqO2pp6WjHhMYZcXI7//xsaAQA

@MartinEnder Oh, I think that dated from when I was trying and failing to use one of your binary conversion routines...

Ruby, 96 91 bytes
->n{r=""
n.digits.map{|d|r="%04b"%d+r}
s=r.chars.map{(r=r[1..-1]+r[0]).to_i 2}
s.max-s.min}

Try it online!

Saved 5 bytes thanks to displayname

->n{r=""
n.digits.map{|d|r="%04b"%d+r}
s=r.chars.map{(r=r[1..-1]+r[0]).to_i 2}
s.max-s.min} should be 91 bytes

@displayname Ha, yeah, you're right. Thank you

PHP, 156 153 bytes
<?foreach(str_split($argv[1])as$n)$s.=str_pad(decbin($n),4,0,0);for(;$i<$a=strlen($s);)$r[]=bindec(substr($s,$i).substr($s,0,$i++));echo max($r)-min($r);

Try it online!

Python 3, 141 bytes
def f(a):a=''.join([format(int(i),'#010b')[-4:]for i in str(a)]);b=[int(''.join(a[-i:]+a[:-i]),2)for i in range(len(a))];return max(b)-min(b)

Try it online

Haskell, 130 bytes
r=foldl1
f x=max#x-min#x
f#x|s<-show x=r((+).(2*)).r f.take(sum$4<$s).iterate(drop<>take$1)$do d<-s;mapM(pure[0,1])[1..4]!!read[d]

Try it online!
Explanation / Ungolfed
Since we're going to use foldl1((+).(2*)) to convert from binary to decimal, we might as well not use maximum and minimum but rather foldl1 max (or same with min respectively) and use a short r = foldr1.
Now, let us define an operator f#x which converts x to BCD, generates all rotations, reduce these using f and convert it to decimal:
f # xs
  | s <- show xs
  = foldr1 ((+).(2*))                             -- convert from binary to decimal
  . foldr1 f                                      -- reduce by either max or min
  . take (4 * length s)                           -- only keep 4*length s (ie. all "distinct" rotations)
  . iterate (drop<>take $ 1)                      -- generate infinite list of rotations
  $ do d<-s; mapM (pure[0,1]) [1..4] !! read [d]  -- convert to BCD

Now it's only a matter of using this operator once with max and once with min and subtracting their results:
f x = max#x - min#x

Japt -x, 20 bytes
®¤ùT4Ã¬¬£ZéY ì2Ãn äa

Try it online!
Input as an array of digits.
Explanation:
®¤                      #Map each digit to base 2
  ùT4Ã                  #Pad each one to 4 places
      ¬                 #Join them to a single binary string
       ¬                #Split them to an array of single characters
        £      Ã        #For each index Y in that array:
         ZéY            # Get the array rotated Y times
             ì2         # Convert the array from binary to decimal
                n       #Sort the results
                  äa    #Get the absolute difference between each element
                        #Implicitly output the sum

You can use the -x flag to save 2 bytes.

20 bytes.

Perl 5, 97 91 89 + 2 (-F) = 99 93 91 bytes
$a=sprintf"%04b"x@F,@F;@r=sort{$b<=>$a}map{oct"0b".($a=(chop$a).$a)}(@F)x4;say$r[0]-pop@r

Try it online!

Pyth, 24/26 bytes
s.+Smi.>Gd2l=Gsm.[\04.Bs

Takes input as a quoted string.  26 bytes if it needs to take input as an integer; append dz in that case.
Test Cases (input as strings, 24 bytes)
Test Cases (input as numbers, 26 bytes)

J, 43 bytes
3 :'(>./-<./)#.(i.@#|."0 1]),}.#:8,"."0":y'

Try it online!
Sometimes tacit style makes things difficult. But there's probably a way to do it tacit style that's a lot more concise than this. I think I remember a better way to split a number to digits other than "."0@": but I can't seem to recall it...
Explanation
3 :'(>./-<./)#.(i.@#|."0 1]),}.#:8,"."0":y'
                                         y  the input (integer)
                                       ":   convert to string
                                   "."0     evaluate each char (split to digits)
                                 8,         prepend 8
                               #:           debase 2
                             }.             behead (remove the 8)
                            ,               ravel (flatten)
               (i.@#|."0 1])                create a list of rotations
                    |.    ]                   rotate the list
                      "0 1                    for each number on the left
                i.@#                          range 0 ... length - 1
             #.                             convert rotations back to base 10
    (>./-<./)                               max minus min

The prepending and removing 8 is to ensure that the right number of zeroes are present (J will reshape its arrays to be the size of their maximum length element, and 8 is 4 digits in binary so it is used).

APL(NARS), 34 chars, 68 bytes
{(⌈/-⌊/)2⊥¨{⍵⌽a}¨⍳≢a←∊⍉(4⍴2)⊤⍎¨⍕⍵}

some little test:
  h←{(⌈/-⌊/)2⊥¨{⍵⌽a}¨⍳≢a←∊⍉(4⍴2)⊤⍎¨⍕⍵}
  h 9752348061
1002931578825
  h 0
0

source: Stack Exchange

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

sort: votes


text:
The Quantum Drunkard's Walk
It is well known that a person on a grid under the influence of alcohol has an equal chance of going in any available directions. However, this common-sense statement does not hold in the realm of very small drunkards, whose behavior is very much as if they take every available path at once, and the possible paths they take can interfere with each other. Your task is to display the possible positions of such a quantum drunkard after n steps.
Specification
The drunkard in question occupies a square grid, and may be considered to be a 3-state cellular automaton using a Von Neumann (plus-shaped) neighborhood which follows these simple rules:

Empty goes to Awake if it is adjacent to exactly one Awake, and otherwise goes to Empty
Awake goes to Sleeping
Sleeping goes to Sleeping

The initial state of the board is a single Awake surrounded by an infinite field of Emptys.
Challenge
Given a nonnegative integer n, create an ASCII representation of the drunkard after n steps. Each state should be represented by a different character, and solutions should state which character means which state. If you use spaces for Empty, you don't need to include a run of them at the end of a line.
This is code-golf, so shortest answer wins. Standard loopholes apply, leading and trailing whitespace is allowed, string array/2d char array output is allowed, etc.
Examples
These examples use  for Empty, @ for Awake, and # for Sleeping.
n=0
@

n = 1
 @
@#@
 @

n = 2
  @
  #
@###@
  #
  @

n = 3
   @
  @#@
 @ # @
@#####@
 @ # @
  @#@
   @

n=6

      @
      #
    @###@
     @#@
  @  ###  @
  #@# # #@#
@###########@
  #@# # #@#
  @  ###  @
     @#@
    @###@
      #
      @

n=10
          @
          #
        @###@
         @#@
         ###
        # # #
       #######
      #  ###  #
  @  ##  ###  ##  @
  #@# ### # ### #@#
@###################@
  #@# ### # ### #@#
  @  ##  ###  ##  @
      #  ###  #
       #######
        # # #
         ###
         @#@
        @###@
          #
          @

Interesting Note
By looking up the sequence of the number of occupied cells in the OEIS, I found that the quantum drunkard is isomorphic to the much better-studied toothpick sequence. If you can incorporate that knowledge into a better golf, I will be suitably impressed.

Can you check to verify that your case for n=10 is correct? I've tried a few approaches and they all get the same (wrong) answer, so I just want to make sure. It looks a bit off but I don't know.

@HyperNeutrino I can do you one better

Nice. +1 thanks. I'll have to look into why I made the same mistake like 5 times :P

Is a one-dimensional char array allowed?

Great first challenge, BTW!

@stellatedHexahedron Would you mind changing your arXiv link to point at the abstract page rather than the PDF file?

The number of Sleeping at each iteration seems to coincide with A169707 on OEIS. Actually, I don't think the distinction between sleeping and awake matters as long as we keep track of the parity of the number of neighbors...

Is my Python / Numpy answer valid, or do I need to add output conversion code?

@PM2Ring valid. a numpy array counts as much as a native python array in my book

@stellatedHexahedron Excellent. :)

Wolfram Language (Mathematica), 92 91 bytes
Print@@@CellularAutomaton[{7049487784884,{3,{a={0,3,0},3-2a/3,a}},{1,1}},{j={{1}},0},{j#}]&

A perfect challenge to use Mathematica's builtin CellularAutomaton!
Try it online!
Empty = 0, Awake = 1, Sleeping = 2
Animation of the first 256 iterations (white = empty, gray = awake, black = sleeping):

Explanation
CellularAutomaton[ ... ]

Run CellularAutomaton with specifications...
{7049487784884,{3,{a={0,3,0},3-2a/3,a}},{1,1}}

Apply the 3-color totalistic rule 7049487784884, with Von Neumann neighborhood...
{j={{1}},0}

On a board with a single 1 in the middle, with a background of 0s...
{j#}

Repeat <input> times ({j#} evaluates to {{{#}}}). The array automatically expands if a cell outside of the border is not the same as the background
7049487784884

This rule comes from the base-3 number 220221220221220221220221220, which means "change all 1 or 2 to 2, and change 0 to 1 if and only if there is an odd number of 1s around it."
Print@@@

Print the array.
Semi-proof of "'odd 1s' is equivalent to 'exactly one 1'":
Consider this 5x5 grid of pixels. White is a 0 or a 2 cell (non-awake pixels), and gray is a 1 cell.

If a 1 cell was generated around three 0 cells, then the grid must look like this: it has three 1s arranged in a U-shape (or a rotated version) as follows:

Due to the self-similarity of this cellular automaton, any pattern that appears in the cellular automaton must appear on the diagonal (by induction). However, this pattern is not diagonally symmetric. i.e. it cannot occur on the diagonal and cannot appear anywhere on the cellular automaton.
Awake/Sleeping are equivalent
Note that a 0 cell cannot be surrounded by exactly one or three 2 cells and rest 0 cells, since that would imply that some steps prior, the cell had a neighbor of one or three 1 cells -- and must have turned into a 1 already (contradiction). Therefore, it is okay to ignore the distinction between 1 and 2 and state 'change all 1 to 1, and a 0 to a 1 if and only if it has an odd number of nonzero neighbors.'
The resulting cellular automaton is indeed identical to the original, the only difference being there is no distinction between "awake" and "asleep" drunkards. This pattern is described in OEIS A169707.
Print@@@CellularAutomaton[{750,{2,{a={0,2,0},2-a/2,a}},{1,1}},{j={{1}},0},{j#}]&

Try it online!
Side-by-side comparison of the first 16 iterations:

Adding two consecutive iterations gives a result that follows the challenge specs (94 bytes):
Print@@@Plus@@CellularAutomaton[{750,{2,{a={0,2,0},2-a/2,a}},{1,1}},{{{1}},0},{Ramp@{#-1,#}}]&

Try it online!

Python 2, 192 bytes
x=input()
o=c={x+x*1j}
R=range(x-~x)
exec"n=[C+k for k in-1j,1j,-1,1for C in c];n={k for k in n if(k in o)<2-n.count(k)};o|=c;c=n;"*x
print[[`(X+Y*1jin c)+(X+Y*1jin o|c)`for Y in R]for X in R]

Try it online!
-17 bytes thanks to Mr. Xcoder
-9 bytes using Jonathan's output format
-11 bytes thanks to Lynn
-3 bytes thanks to ovs

Switching to a full program where you can use exec saves 9 bytes, and …for k in 0,1,2,3for… saves one more: Link

Actually, n=[C+k for k in-1j,1j,-1,1for C in c] saves one more byte!

...ok, I'll have to admit X+Y*1jin is something I didn't really think was possible :P

@ETHproductions I didn't expect it to work either but I was like "hey you can remove spaces after a number before an identifier/keyword so if it matches greedily like that would it work with complex numbers? :D Python is amazing :P

C, 360 354 343 319
#define A(i,b,e)for(int i=b;i<e;++i)
#define B(b,e)A(r,b,e){A(c,b,e)
#define W(n)(n<0?-(n):n)
#define C(r,c)b[W(r)*s+W(c)]
#define D C(r,c)

q(n){char N,s=n+2,(*b)[2]=calloc(s,2*s);C(0,0)
[1]=1;A(g,0,n+1){B(0,s)*D=D[1];}B(0,g+2){N=(*C
(r-1,c)+*C(r+1,c)+*C(r,c-1)+*C(r,c+1))&1;D[1]=
*D?2:N;}}}B(2-s,s-1)putchar(*D+32);puts("");}}

Newlines after non-#define lines are just for presentation here, so they’re not counted. I included a wrapper function, so it’s −6 (313) if the function isn’t counted and you assume n comes from elsewhere. q(10) outputs:
          !
          "
        !"""!
         !"!
         """
        " " "
       """""""
      "  """  "
  !  ""  """  ""  !
  "!" """ " """ "!"
!"""""""""""""""""""!
  "!" """ " """ "!"
  !  ""  """  ""  !
      "  """  "
       """""""
        " " "
         """
         !"!
        !"""!
          "
          !

Using  for empty, " for sleeping, and ! for awake.
This works like so:

A(i,b,e) is “∀i∈[b,e).”, B(b,e) is “∀r∈[b,e).∀c∈[b,e).”
Observe that after n generations, the board is 2n + 1 square.
Because of the symmetry of the board, this only needs to simulate the lower right quadrant, so we allocate an n + 1 square matrix with 1 row & column of padding for the later neighbour lookup (so n + 2).
Allocating with calloc lets us simultaneously multiply the width by the height and clear the board to 0 (empty).
When looking up a cell by its coordinates (C and D), it uses the absolute value of the row and column (W) to automatically mirror the coordinates.
The board is stored as an array of pairs of integers representing the current and previous generations. The integers in question are char so we can avoid sizeof.
The generation looked up most frequently (by the neighbour test) is the past generation, so it’s placed at index 0 in the pair so it can be accessed with *.
At each generation (g), the current generation is copied over the previous generation using a B loop, then the new generation is generated from the old.
Each cell is represented using 0 for empty, 1 for awake, and 2 for sleeping. Counting neighbours was originally a calculation of the number of bits set in the low 4 bits of the cell when the 4 neighbours are shifted & OR’d together as flags (N), using 16 for sleeping. But with the observation that an odd number of neighbours is equivalent to exactly 1 neighbour, we can save several characters just using a mask with 1.
At the end, the board is printed in full by iterating over the lower right quadrant using the same absolute value coordinate trick, minus padding so we don’t print the outer padding on the board. This is also why the B loop includes an opening curly bracket, because we have the extra newline statement in the outer loop.
The ASCII codes conveniently map 0+32 (empty) to a space, 2+32 (sleeping) to ", and 1+32 (awake) to !.

All in all I think this is a surprisingly readable golf because of the nice structure of the problem.

Wow. Tiny thing, but I think you can save a few more bytes by replacing the shifts with multiplication and putchar(10) with puts("")

@undercat: Thanks! Added to the answer. Sometimes I focus on reducing some things so much that I miss other wins that are obvious as soon as someone points them out.

343 bytes.

@JonathanFrech: Thanks, added. I forgot that the counting of neighbours can use a NAND.

@JonathanFrech: Sorry, I guess that was unclear. &~ is not a NAND, I meant that I sometimes think of !(a &~ b) in terms of a NAND (NOT b), although in this case the logical ! isn’t the same as the bitwise ~ because we’re relying on the 0 or 1 result of !.

MATL, 39 bytes
QtE:=&*G:"tt0=w1Y6Z+Xj1=*w|gJ*+]Q|U31+c

This displays

Empty as   (space)
Awake as #
Sleeping as !.

Try it online! You can also watch the pattern grow in ASCII art, or graphically (modified code).
Explanation
The code uses complex numbers 0, 1, j to represent the three states: empty, wake, sleeping respectively.
Q         % Implicitly input n. Add 1
tE        % Duplicate and multiply by 2
:         % Range [1 2 ... 2*n]
=         % Test for equalty. Gives [0 ... 0 1 0... 0], with 1 at position n
&*        % Matrix of all pairwise products. Gives square matrix of size 2*n
          % filled with 0, except a 1 at position (n,n). This is the grid
          % where the walk will take place, initiallized with an awake cell
          % (value 1). The grid is 1 column and row too large (which saves a
          % byte)
G:"       % Do n times
  tt      %   Duplicate current grid state twice
  0=      %   Compare each entry with 0. Gives true for empty cells, false
          %   for the rest
  w       %   Swap: moves copy of current grid state to top
  1Y6     %   Push 3×3 matrix with Von Neumann's neighbourhood
  Z+      %   2D convolution, maintaining size
  Xj      %   Real part
  1=      %   Compare each entry with 1. This gives true for cells that
          %   have exactly 1 awake neighbour
  *       %   Multiply, element-wise. This corresponds to logical "and":
          %   cells that are currently empty and have exactly one awake
          %   neighbour. These become 1, that is, awake
  w       %   Swap: moves copy of current grid state to top
  |g      %   Absolute value, convert to logical: gives true for awake or
          %   sleeping cells, false for empty cells
  J*+     %   Mulltiply by j and add, element-wise. This sets awake and
          %   sleeping cells to sleeping. The grid is now in its new state
]         % End
Q         % Add 1, element-wise. Transforms empty, awake, sleeping
          % respectively from 0, 1, j into 1, 2, 1+j
|U        % Abolute value and square, element-wose. Empty, awake, sleeping
          % respectively give 1, 4, 2
31+c      % Add 31 element-wise and convert to char. Empty, awake, sleeping
          % respectively give characters ' ' (codepoint 32), '#' (codepoint
          % 35) and '!' (codepoint 33). Implicitly display

Befunge, 384 304 bytes
&:00p->55+,000g->>00g30p:40p\:50p\5>>40g!50g!*vv0g05g04p03-<
@,+55_^#`g00:+1$_^>p:4+4g5%2-50g+5#^0#+p#1<v03_>30g:!#v_:1>^
#v_>$99g,1+:00g`^ ^04+g04-2%5g4:\g05\g04\p<>g!45*9+*3+v>p:5-
 >\50p\40p\30p:#v_>>0\99g48*`!>v >30g:1-30^>>**\!>#v_>v^9 9<
$0\\\\0$        >\99g88*-!+\:4->#^_\>1-!48>^       >$3>48*+^

Try it online!
The problem with trying to implement this sort of thing in Befunge is the limited memory size (2000 bytes for both data and code). So I've had to use an algorithm that calculates the correct character for any given coordinate without reference to previous calculations. It achieves this by recursively looking back in time across all possible paths the drunkard might have followed to reach that point.
Unfortunately this is not a particular efficient solution. It works, but it's incredibly slow, and it becomes exponentially slower the larger the value of n. So while it could potentially work for any n up to about 127 (Befunge's 7-bit memory cell limit), in practice you'll inevitably lose interest waiting for the result. On TIO, it'll hit the 60 second timeout on anything higher than around 6 (at best). A compiler will do a lot better, but even then you probably wouldn't want to go much higher than 10.
Still, I thought it was worth submitting because it's actually quite a nice demonstration of a recursive "function" in Befunge.

Python 2, 214 bytes
def f(n):k=n-~n;N=k*k;A=[0]*N;A[N/2]=2;exec"A=[[2*([j%k>0and A[j-1],j%k<k-1and A[j+1],j/k>0and A[j-k],j/k<k-1and A[j+k]].count(2)==1),1,1][v]for j,v in enumerate(A)];"*n;print[map(str,A)[k*x:][:k]for x in range(k)]

Try it online!
Explanation
Uses 0 for empty, 1 for sleeping and 2 for awake. Prints out a two-dimensional character (one-length strings) list.
Defines a function which takes in a non-negative integer n. Successively advances the cellular automaton until the desired state is reached. Finally, a conversion between the internal integer values and actual characters is applied.

Lua, 251 242 239 238 bytes
-8 bytes by simplifying the array initializer at the cost of some additional leading whitespace.
-1 byte by changing c=i==2+...and print(s) into c=i~=2+...or print(s).
-3 bytes by building a complete string first and printing once at the end.
-1 byte thanks to Jonathan Frech by rewriting or(g(...)==1 and as or(1==g(...)and.
function g(x,y)return(a[x]or{})[y]or 0 end a={{1}}for i=2,2+...do n={}s=""for x=-i,i do n[x]=n[x]or{}q=a[x]or{}for y=-i,i do n[x][y]=q[y]and 0or(1==g(x+1,y)+g(x,y+1)+g(x-1,y)+g(x,y-1)and 1)s=s..(q[y]or" ")end s=s.."\n"end a=n end print(s)

Try it online!
Empty = Space
Awake = 1
Sleeping = 0
Takes input from the command line and prints to stdout.
By representing the states as false/nil, 1 and 0 internally, detecting "empty" doesn't need any code and the "exactly one awake" check can be done with just an addition.

I think or(g(...)==1 and can be or(1==g(...)and.

APL (Dyalog), 38 bytes
((2∘∧⌈1={2⊃+/1=⍵,⍉⍵}⌺3 3)(⌽0,⍉)⍣4)⍣⎕⍪1

Try it online!
-4 thanks to Adám.
-8 thanks to ngn.

Let us continue this discussion in chat.

APL (Dyalog Classic), 38 bytes
((2∘∧⌈2|⍉∘g∘⍉+g←3+/0,,∘0)(⌽0,⍉)⍣4)⍣⎕⍪1

Try it online!
based on Erik the Outgolfer's solution
⍪1 is a 1x1 matrix containing 1
⎕ eval'ed input
( )⍣⎕ apply that many times

(⌽0,⍉)⍣4 surround with 0s, that is 4 times do: transpose (⍉), add 0s on the left (0,), reverse horizontally (⌽)
g←3+/0,,∘0 a function that sums horizontal triples, call it g
⍉∘g∘⍉ a function that sums vertical triples - that's g under transposition
2 | ⍉∘g∘⍉ + g←3+/0,,∘0 sum of the two sums modulo 2
⌈ the greater between that and ...
2∘∧ the LCM of 2 and the original matrix - this turns 1s into 2s, while preserving 0s and 2s

Jelly, 39 29 bytes
-,1ṙ@€Sµ+Z
‘ṬŒḄ×þ`µÇ×¬Ḃ+Ḃ+µ³¡

Try it online!
Uses 0,1 and 2 for empty awake and sleeping. The footer in the link converts this to , @ and #.

-1 byte by using ṬŒḄ instead of ḤḶ=¹.
-2 bytes by using - instead of 1N. Also makes ¤ unnecessary.
-1 byte by using S instead of +/.
-6 bytes by using Ḃ+Ḃ+ instead of %3=1+=1Ḥ$+. Now uses 2 for sleeping instead of 3.

Explanation coming...

Perl 5, 192 + 1 (-n) = 193 bytes
for$i(1..2*$_+1){push@a,[()x$_]}$a[$_][$_]=1;map{@b=();for$i(0..$#a){map$b[$i][$_]=$a[$i][$_]?2:$a[$i-1][$_]+($_&&$a[$i][$_-1])+$a[$i+1][$_]+$a[$i][$_+1]==1?1:0,0..$#a}@a=@b}1..$_;say@$_ for@a

Try it online!
Uses 0 for empty, 1 for awake, and 2 for asleep.

Ruby, 164 153 bytes
->n{(r=([e=' ']*(l=2*n+1)<<"
")*l)[n+n*l+=1]=a=?@
n.times{r=r.map.with_index{|c,i|c==a ??#:c==e ?r.values_at(i-1,i+1,i-l,i+l).one?{|v|v==a}?a:e:c}}
r*""}

Try it online!
Uses " " for Empty, "@" for Awake, and "#" for Sleeping (as in the example). I could save 6 bytes by using numbers instead, I suppose, but it looks better like this.

Pip, 69 61 bytes
60 bytes of code, +1 for -l flag.
YZG2*a+1y@a@a:1LaY{y@a@b?2oN(y@(a+_)@(b+B)MP[0o0v0])=1}MC#yy

Takes n as a command-line argument. Uses 0 for empty, 1 for awake, and 2 for sleeping. (To get nicer ASCII-art as in the challenge's examples, replace the final y with " @#"@y.)
Try it online!
Explanation
Setup:
YZG2*a+1y@a@a:1

                 Implicit: a is 1st cmdline arg; o is 1; v is -1
 ZG2*a+1         Square grid (i.e. nested list) of 0's, with side length 2*a+1
Y                Yank into y variable
        y@a@a:1  Set the element at coordinates (a,a) to 1

Main loop:
LaY{...}MC#y

La            Loop (a) times:
          #y  Len(y) (i.e. 2*a+1)
   {   }MC    Map this function to the coordinate pairs in a 2*a+1 by 2*a+1 grid
  Y           and yank the resulting nested list back into y

where the function body is:
y@a@b?2oN(y@(a+_)@(b+B)MP[0o0v0])=1

                                     The function args, representing the coords of the
                                     current cell, are a and b
y@a@b?                               Is the cell at these coords 0 or nonzero?
      2                              If nonzero (1 or 2), make it 2
                                     Else, if zero, we need to check the neighbors
                         [0o0v0]     List of [0; 1; 0; -1; 0]
                       MP            Map this function to each adjacent pair of values--
                                     i.e. call it four times with args (0; 1), (1; 0),
                                     (0; -1), and (-1; 0)
          y                           Index into the grid using
           @(a+_)                     a + the 1st item in the pair as the row and
                 @(b+B)               b + the 2nd item in the pair as the column
                                     The result of MP is a list of the values of the cells
                                     in the Von Neumann neighborhood
       oN(                      )    Get the number of 1's in that list
                                 =1  and test if it equals 1
                                     If so, the new value of this cell is 1; if not, it's 0

After the loop, we simply autoprint y. The -l flag means that the nested list is printed by concatenating the contents of each row and separating the rows with newlines.

Java (OpenJDK 8), 220 bytes
n->{int s=n*2+3,i=0,x,y;char[][]a=new char[s][s],b;for(a[s/2][s--/2]=61;i++<n;a=b)for(b=new char[s+1][s+1],x=0;++x<s;)for(y=0;++y<s;)b[x][y]=a[x][y]>32?'0':(a[x][y-1]+a[x][y+1]+a[x-1][y]+a[x+1][y])%8==5?61:' ';return a;}

Try it online!
Note: the array returned contains a border or '\0' characters. Since the plane is supposed to be infinite, only non-border is used.
Character mapping:

Empty:  (space)
Awake: =
Sleeping: 0

Saves

29 bytes saved thanks to Jonathan S.
9 further bytes thanks to Jonathan S. by swapping characters with others and "doing magic with primes and modular arithmetic"

229 bytes.

Thanks @JonathanS. I was looking really hard at improving my @-check, and you found the key! Nice. The char-cast was a total oversight from me.

220 bytes by doing magic with primes and modular arithmetic.

That's some very nice thinking!

Thanks! I just found a prettier version that's also 220 bytes, different modulus.

Python, 199 192 bytes
This code runs on both Python 2 and Python 3, but it uses the popular 3rd-party Numpy library to do the array handling.
from numpy import*
def f(n):
 m=2*n+1;g=zeros((m+2,)*2,'i');g[n+1,n+1]=1
 while n:a=g[1:-1,1:-1];a[:]=(a<1)*(sum(g[r:r+m,c:c+m]&1for r,c in((0,1),(1,0),(1,2),(2,1)))==1)+(a>0)*2;n-=1
 return g

Empty = 0
Awake = 1
Sleeping = 2

print(f(6)) outputs
[[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 1 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 2 0 0 0 0 0 0 0]
 [0 0 0 0 0 1 2 2 2 1 0 0 0 0 0]
 [0 0 0 0 0 0 1 2 1 0 0 0 0 0 0]
 [0 0 0 1 0 0 2 2 2 0 0 1 0 0 0]
 [0 0 0 2 1 2 0 2 0 2 1 2 0 0 0]
 [0 1 2 2 2 2 2 2 2 2 2 2 2 1 0]
 [0 0 0 2 1 2 0 2 0 2 1 2 0 0 0]
 [0 0 0 1 0 0 2 2 2 0 0 1 0 0 0]
 [0 0 0 0 0 0 1 2 1 0 0 0 0 0 0]
 [0 0 0 0 0 1 2 2 2 1 0 0 0 0 0]
 [0 0 0 0 0 0 0 2 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 1 0 0 0 0 0 0 0]
 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]

If you want prettier printing, you can call it this way:
n=6;print('\n'.join(''.join(' @#'[v]for v in u)for u in f(n)))

which prints using the same characters as given in the question.

I do not know if ouputting an integer matrix is allowed, as [e]ach state should be represented by a different character (I interpret character as an actual ASCII character, rather than an integer).

@JonathanFrech Fair call. I'll ask the OP.

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


text:
Sort an Option String
Background
In C, there is a function to help parse command-line arguments: getopt.
Getopt takes the argument count (argc), the argument list (argv), and a string representing the options the program should take (optstring).
The option string (optstring) is a series of option characters each followed by one colon (for an option requiring an argument), two colons (for an option with an optional argument), or zero colons (for an option without an argument).
For example: one might use the following option string for their company's new widget.
"v::x:hy:S:G::dns:f::"

But that looks horrible! The options are all mixed together! This option string would look much better if it were sorted:
"f::G::v::S:s:x:y:dhn"

Specifications

The input will be a string matching the regular expression ([A-Za-z]:{0,2})+
You should take input as a string or list of characters.
You should output the string sorted by the method detailed below.
You do not need to handle empty input.
You do not need to handle input with repeated options of the same type ("aa" is not valid, but "aa:a::" is valid).

Sorting Method
In the sorted option string:

The characters followed by two colons come first, sorted alphabetically, with uppercase letters before their respective lowercase letters (i.e. "aBb", not "Bab").
Then are the characters with one colon, sorted alphabetically, with uppercase letters before their respective lowercase letters.
Last are the characters with no colon, sorted alphabetically, with uppercase letters before their respective lowercase letters.

Rules

Standard Loopholes are forbidden.

Scoring
This is code-golf, so shortest answer in bytes in each language wins.
Examples
# "input" => "output"
"v::x:hy:S:G::dns:f::" => "f::G::v::S:s:x:y:dhn"
"aa:a::" => "a::a:a"
"B:" => "B:"
"Confusio:n::" => "n::o:Cfinosu"
"Confusio:n:" => "n:o:Cfinosu"
"m:qW:X:xc:vViI" => "c:m:W:X:IiqVvx"
"V:omo:V" => "o:V:moV"
"agg:ra:va::ting::" => "a::g::a:g:aginrtv"
"input" => "inptu"

Long test case (312 characters)
Invaid Inputs (you don't have to handle):
"gg" (duplicated option)
"" (empty string)
":w:" (first colon isn't after a character)
"x:y:0:fhn" ('0' is not alphabetic)
"A:::" (3 colons is invalid)

agg:ra:va::ting:: broke mine heh... Ironic.

Husk, 11 bytes
ΣÖom_↔Oġλ¬√

Try it online!
Explanation
ΣÖom_↔Oġλ¬√  Implicit input, say "kH::r:R:Hk:"
       ġ     Split between characters for which this gives a falsy result:
        λ      Take two arguments, ignore the first.
          √    Is the second argument a letter?
         ¬     Negate.
             Now we have the options: ["k","H::","r:","R:","H","k:"]
      O      Sort: ["H","H::","R:","k","k:","r:"]
 Ö           Sort by
     ↔       reversing and
  om_        converting everything to lowercase: ["H::","k:","R:","r:","H","k"]
Σ            Concatenate: H::k:R:r:Hk

There are a couple of really clever ideas here, you should add an explanation so people can appreciate them :D

@Leo Added a breakdown of the code.

Japt, 17 16 bytes
f".:*" ñ_iZw vÃq

Test it online!
How it works
Say the input string is v:vg::G:G::o:. The first part of the code, f".:*", finds all matches of the regex /.:*/g, which matches a character followed by any number of colons. This splits the input into [v:, v, g::, G:, G::, o:].
The ñ method on an array sorts each the array as if certain changes were applied, without actually applying them (like sorted(array, key=<whatever>) in Python). So we need to sort:

double-colons before everything else;
single-colons after double-colons, but before no-colons;
letters in their alphabetical order; and finally
uppercase letters before lowercase.

Z{ZiZéJ v} is the shortest way I could find to do this:
  Zw     Reverse Z.
     v   Convert to lowercase.
Zi       Insert this at the beginning of Z.

This is easiest to understand with some examples:
         v:   v  g::    G:   G::    o:
  Zw     :v   v  ::g    :G   ::G    :o
     v   :v   v  ::g    :g   ::g    :o
Zi       :vv: vv ::gg:: :gG: ::gG:: :oo:

The original values are then sorted lexicographically by these keys. The result is that ::gG:: is sorted to the front, then ::gg::, and so on, giving us [G::, g::, G:, o:, v:, v], which is then joined with q and outputted.

Retina, 47 bytes
.
$&$&
T01`L`l`..
O^`\w.:*
.(.)
$1
O$^`\w:*
$.&

Try it online!
The trickiest part was actually sorting the letters, because Retina's "sort-by" feature doesn't have a case-insensitive sort (so by default it sorts the upper case letters in front of all lower case letters). To work around this, I had to insert a lower-case copy of each character to do the sorting and then get rid of it again.

Has a case-insensitive sort been added somewhere in the last year? And if not, is there a way to sort case-insensitive, but retain original order? I.e. tEsTiNg with your above sorting method sorts the pairs of letters to eEggiinNsstTtt → EgiNsTt instead of eEggiinNsstttT → EgiNstT  (the uppercase letters are always placed before the lowercase letters).

@KevinCruijssen You can do it with sort-by now, because you can easily transform the character to lowercase in the substitution string. https://tio.run/##K0otycxLNPyvquGe8N9fJUGPSyVHRe3//xLX4pBMv3QA

Ah, nice. Would have never thought of that myself.. Thanks a lot. I've been able to fix my answer now. :)

Python 2, 100 90 bytes
lambda s:''.join(sorted(re.findall('.:*',s),key=lambda s:(-len(s),s.lower(),s)))
import re

Try it online!

Jelly, 14 bytes
n”:œṗ⁸ṢŒuÞṚLÞṚ

Try it online!
Full program.

Perl 5, 69 + 1 (-n) = 70 bytes
say sort{$b=~y///c<=>length$a||($"=lc$a)cmp lc$b||1-2*($"ne$a)}/.:*/g

Try it online!

Each capital comes before its lowercase. E.g. 'AaBb'. I think changing =~/A-Z/ to ==/A-Z/ should fix the problem.

JavaScript (ES6), 93 bytes

f=
s=>s.match(/\w:*/g).sort((a,b)=>b.length-a.length||parseInt(a,36)-parseInt(b,36)||a>b).join``
<input oninput=o.textContent=this.value&&f(this.value)><pre id=o>

Bash, 232 213 bytes
s(){ s=${1#?} c=${1%$s} o=${s%%[^:]*} s=${s#$o} o=$c$o;};
p()(s $1;l= g= p=$o d=$c;[[ $o ]]&&(while s $s;[[ $o ]];do
(((x=${#o}-${#p},y=36#$d-36#$c,x?x:y?y:62#$c-62#$d)>0))&&g+=$o||l+=$o;done;echo `p $g`$p`p $l`))

try it online

Haskell, 124 bytes
import Data.List
import Data.Char
s(c:x)|(l,r)<-span(==':')x=(-length l,toLower c,c:l):s r;s _=[]
t(_,_,x)=x
f=(t=<<).sort.s

Try it online!

C# (.NET Core), 152 bytes
s=>{var o="";for(var d=":::";d!="";){d=d.Substring(1);for(var c='@';c!=90;o+=s.IndexOf(c+d)>=0?c+d:"",s=s.Replace(c+d,""),c^=' ')if(c<97)c++;}return o;}

Try it online!
Ungolfed:
s => {
    var o = "";
    for (var d = ":::"; d != "";) {
        d = d.Substring(1);
        for (
            var c = '@';
            c != 90;
            o += s.IndexOf(c + d) >= 0 ? c + d : "", s = s.Replace(c + d, ""), c ^= ' '
        ) if (c < 97) c++;
    }
    return o;
}

The basic idea is to iterate over all 156 possible options and check for their existence.  If found, append to the output, and remove from the input.


text:
Is it bipartite?
A bipartite graph is a graph whose vertices can be divided into two disjoint set, such that no edge connects two vertices in the same set. A graph is bipartite if and only if it is 2-colorable.

Challenge
Your task is to, given the adjacency matrix of an undirected simple graph, determine whether it is a bipartite graph. That is, if an edge connects vertices i and j, both (i, j) and (j, i) entry of the matrix are 1.
Since the graph is undirected and simple, its adjacency matrix is symmetric and contains only 0 and 1.
Specifics
You should take an N-by-N matrix as input (in any form, e.g. list of lists, list of strings, C-like int** and size, flattened array, raw input, etc.).
The function/program should return/output a truthy value if the graph is bipartite, and falsy otherwise.
Test Cases
['00101',
 '00010',
 '10001',
 '01000',
 '10100'] : False
['010100',
 '100011',
 '000100',
 '101000',
 '010000',
 '010000'] : True (divide into {0, 2, 4, 5} and {1, 3})
['00',
 '00'] : True

Scoring
Builtins that compute the answer directly are banned.
This is code-golf, so the shortest program (in bytes) by the end of this month wins!

Related, and in fact borderline dupe, because being bipartite is equivalent to having no odd cycles, and most of the answers to that question work by enumerating all cycles and examining their lengths.

@PeterTaylor Yeah, but there are simpler ways to solve this problem.

@ColeraSu Instead of truthy / falsy, can we return -1 for falsy and any non-negative integer for truthy?

@MishaLavrov 0 -> Falsy, >0 -> Truthy is generally allowed by standard truthy/falsy rules. -1 and ≥ 0 is not that common, that's why I asked.

@Mr.Xcoder It's okay.

Husk, 17 bytes
§V¤=ṁΣṠMSȯDfm¬ṀfΠ

Prints a positive integer if the graph is bipartite, 0 if not.
Try it online!
Explanation
This is a brute force approach: iterate through all subsets S of vertices, and see whether all edges in the graph are between S and its complement.
§V¤=ṁΣṠMSȯDfm¬ṀfΠ  Implicit input: binary matrix M.
                Π  Cartesian product; result is X.
                   Elements of X are binary lists representing subsets of vertices.
                   If M contains an all-0 row, the corresponding vertex is never chosen,
                   but it is irrelevant anyway, since it has no neighbors.
                   All-1 rows do not occur, as the graph is simple.
      ṠM           For each list S in X:
              Ṁf   Filter each row of M by S, keeping the bits at the truthy indices of S,
        S  fm¬     then filter the result by the element-wise negation of S,
         ȯD        and concatenate the resulting matrix to itself.
                   Now we have, for each subset S, a matrix containing the edges
                   from S to its complement, twice.
§V                 1-based index of the first matrix
  ¤=               that equals M
    ṁΣ             by the sum of all rows, i.e. total number of 1s.
                   Implicitly print.

@Mr.Xcoder Well, suppose M = [[1,2,3],[4,5,6],[7,8,9]] and S = [1,0,1] (M is always a binary matrix in the program, but it's easier to explain this way). Filtering each row of M by S gives [[1,3],[4,6],[7,9]]: for each row, I remove the elements at those indices where S has a 0. Then I negate S element-wise to get [0,1,0], and filter M by that to get [[4,6]]: the first and last rows have 0 in the corresponding indices, so they are removed.

Wolfram Language (Mathematica), 26 25 bytes
Tr[#//.x_:>#.#.Clip@x]<1&

Try it online!
How it works
Given an adjacency matrix A, we find the fixed point of starting with B=A and then replacing B by A2B, occasionally clipping values larger than 1 to 1. The kth step of this process is equivalent up to the Clip to finding powers A2k+1, in which the (i,j) entry counts the number of paths of length 2k+1 from vertex i to j; therefore the fixed point ends up having a nonzero (i,j) entry iff we can go from i to j in an odd number of steps.
In particular, the diagonal of the fixed point has nonzero entries only when a vertex can reach itself in an odd number of steps: if there's an odd cycle. So the trace of the fixed point is 0 if and only if the graph is bipartite.
Another 25-byte solution of this form is Tr[#O@n//.x_:>#.#.x]===0&, in case this gives anyone ideas about how to push the byte count even lower.
Previous efforts
I've tried a number of approaches to this answer before settling on this one.
26 bytes: matrix exponentials
N@Tr[#.MatrixExp[#.#]]==0&

Also relies on odd powers of the adjacency matrix. Since x*exp(x2) is x + x3 + x5/2! + x7/4! + ..., when x is a matrix A this has a positive term for every odd power of A, so it will also have zero trace iff A has an odd cycle. This solution is very slow for large matrices.
29 bytes: large odd power
Tr[#.##&@@#~Table~Tr[2#!]]<1&

For an n by n matrix A, finds A2n+1 and then does the diagonal check. Here, #~Table~Tr[2#!] generates 2n copies of the n by n input matrix, and #.##& @@ {a,b,c,d} unpacks to a.a.b.c.d, multiplying together 2n+1 copies of the matrix as a result.
53 bytes: Laplacian matrix
(e=Eigenvalues)[(d=DiagonalMatrix[Tr/@#])+#]==e[d-#]&

Uses an obscure result in spectral graph theory (Proposition 1.3.10 in this pdf).

I think you can shave a couple of bytes off your more efficient method with Tr[#.Nest[#.#&,#,Tr[#!]]]<1&. (This is an incredible answer that keeps getting better every time I look at it!)

This has fewer bytes that the semi-built-in (needs two functions)BipartiteGraphQ@AdjacencyGraph@#&

Also, just wondering why you need the N@ ?

@KellyLowder:  for large matrices MatrixExp returns results in terms of unevaluated Root objects, which are not automatically simplified when added.  The N@ forces these Roots to be calculated numerically so that the truthiness can then be evaluated.

@Notatree Your approach does indeed shave off a few bytes, but they cost; for 18x18 matrices, it's 1000 times slower, and it gets worse from there. I think if I make that change, I lose the right to call the efficient method "efficient".

@KellyLowder You could shorten that to BipartiteGraphQ@*AdjacencyGraph, but it's still longer.

APL (Dyalog Extended), 16 13 bytes
⍱1 1⍉∨.∧⍣2⍣≡⍨

Try it online!
-3 bytes thanks to @H.PWiz.
Uses the algorithm from Misha Lavrov's top Mathematica answer: initialize A = B = M, left-multiply B twice to A and clamp it until it reaches the fixed point, and test if the diagonal entries are all zero.
The regular matrix product A+.×B counts the number of two-step paths from node m to node p passing through any intermediate node n. If we change the code to A∨.∧B, we instead get a boolean matrix indicating if there exists any two-step path from node m to node p. We don't need extra "clamping" operation that way.
How it works
⍱1 1⍉∨.∧⍣2⍣≡⍨  ⍝ Input: adjacency matrix M
          ⍣≡⍨  ⍝ Find the fixed point, with
               ⍝     Starting point A = Left arg B = M...
     ∨.∧⍣2     ⍝   Left-multiply (matmul) B twice to A
               ⍝   indicating existence of paths (boolean)
 1 1⍉          ⍝ Extract the main diagonal
⍱              ⍝ Test if all elements are zero

Would it work to raise the matrix to a large odd power and check if the diagonal is all zero?

@xnor Yes it's possible, but giving a computed iteration count is less concise than simple fixpoint.

Weird, I don't know APL, but does it really take that many characters? Does APL not have matrix-powers built-in? If is does, it looks to me like you could compute a large value as the matrix size or number of elements or sum, make it odd by either bitwise-or with 1 or (yuck) raise 3 to that power, take the input matrix to that power, then only 1 1⍉ and ⍱ remain.

@xnor APL is basically not a golfing language. Matrix product alone is not a single built-in, but rather a combination of three built-ins +.× (which allows me to write a Boolean variant ∨.∧ at no extra cost). Matrix power is even more complex, and I lose tacit programming when I need to compute the power explicitly (that solution would be like ⍱1 1⍉{∨.∧⍣(2×≢⍵)⍨⍵} at 19 bytes). And APL doesn't even have bitwise ops.

I recognize this piece of code :P

JavaScript, 78 bytes
m=>!m.some((l,i)=>m.some((_,s)=>(l=m.map(t=>t.some((c,o)=>c&&l[o])))[i]&&s%2))

Input array of array of 0 / 1, output true / false.

f =

m=>!m.some((l,i)=>m.some((_,s)=>(l=m.map(t=>t.some((c,o)=>c&&l[o])))[i]&&s%2))

run = () => o.value=f(i.value.trim().split('\n').map(v=>v.trim().split('').map(t=>+t)))
<textarea id=i oninput="o.value=''" style="width:100%;display:block;">010100
100011
000100
101000
010000
010000
</textarea>
<button type=button onclick="run()">Run</button>

Result = <output id=o></output>

Pyth, 25 bytes
xmyss.D.DRx0dQx1d.nM*FQss

Try it online!
This returns -1 for falsy, and any non-negative integer for truthy.
How it works

xmyss.D.DRx0dQx1d.nM*FQss ~ Full program, receives an adjacency matrix from STDIN.

                    *FQ   ~ Reduce (fold) by cartesian product.
                 .nM      ~ Flatten each.
 m                        ~ Map with a variable d.
         R   Q            ~ For each element in the input,
       .D                 ~ Delete the elements at indexes...
          x0d             ~ All indexes of 0 in d.
     .D                   ~ And from this list, delete the elements at indexes...
              x1d         ~ All indexes of 1 in d.
    s                     ~ Flatten.
   s                      ~ Sum. I could have used s if [] wouldn't appear.
  y                       ~ Double.
x                         ~ In the above mapping, get the first index of...
                       ss ~ The total number of 1's in the input matrix.

This works in commit d315e19, the current Pyth version TiO has.