text:
Count how many months are having a full 31 days by counting knuckles
How many of you that still use your own knuckle to determine whether a month is having a full 31 days or less?
You job is to write a program to count how many months, in a month range, are having a full 31 days and how many are having less than 31 days by "counting the knuckles".

Courtesy: amsi.org.au

Input
A pair of months, the first of which doesn't have to come chronologically before the second, given in any suitable format. For instance: 201703 201902 — March 2017 to February 2019. Please describe the input format you choose. Note that the input must be able to include all years from 1 to 9999. The range of months specified includes both the starting and ending months.
Output
Two integers: the number of months in the given range with 31 days and the number of months in the range with less than 31 days.
Example: 14 10 — 14 knuckles, 10 grooves (it means that in that month range we have 14 months that have a full 31 days, and 10 months that have less than 31 days).
For an input where the second month in the range comes chronologically before the first, for example 201612 201611, you have to output a pair of zero.
Examples of input and output
| Input         | Output      |
|---------------|-------------|
| 201703 201902 | 14 10       |
| 201701 202008 | 26 18       |
| 000101 999912 | 69993 49995 |
| 201802 201803 | 1 1         |
| 201601 201601 | 1 0         |
| 201612 201611 | 0 0         |

Rules

You may choose any language you like
One input per line
This is code-golf, so shortest code in bytes wins!
The winner will be chosen in April 9
Standard loopholes apply
PS: this is my first question in PCG, it might have some inconsistencies. Feel free to edit and confirm what's unclear for you.

You say the first of which is guaranteed to come chronologically before the second, but this is false for test case 201612 201611.

There exists a sandbox on the site where you can post the question solely to get all the doubts cleared.

Thirty days hath September, April, June, and November. After February's done, all the rest have thirty-one. That's how I remember it.

@AdmBorkBork The only trouble with that is the infinite looping (mandatory xkcd reference).

I presume you intend to use the Gregorian calendar throughout the date range?

@Dennis and all, Just came back online today. I'm going to clarify that the last test case is valid. Actually I wrote a rule for that, before it got edited. Check back my edited question again. Thanks!

@softtama That's unfortunate, as it invalidates at least four answers, including my own. While I realize now that the conflict was caused by someone else's edit, it's usually preferable to chose the option that doesn't invalidate answers, unless doing so actively hurts the challenge.

Jelly, 21 bytes
ḅ12r/ị7RḂṁ12¤żC$S×⁼Ṣ$

Takes input like [[y, m], [y, m]].
Try it online!
How it works
ḅ12r/ị7RḂṁ12¤żC$S×⁼Ṣ$  Main link. Argument: [[a, b], [c, d]]

ḅ12                    Unbase 12; yield [x, y] := [ 12a + b, 12c + d].
   r/                  Reduce by range; yield [x, ..., y].
           ¤           Combine the five links to the left into a niladic chain.
      7                  Set the return value to 7.
       R                 Range; yield [1, 2, 3, 4, 5, 6, 7].
        Ḃ                Bit; yield [1, 0, 1, 0, 1, 0, 1].
         ṁ12             Mold 12; repeat the Booleans to create an array of length
                         12. Yields [1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1].
     ị                 At-index; yield the elements of the array to the right at
                       the indices (1-based and modular) of the array to the left.
               $       Combine the two links to the left into a monadic chain.
              C          Complement; map t -> 1-t over the array.
             ż           Zip the original array with the complements.
                S      Take the sum of each column.
                    $  Combine the two links to the left into a monadic chain.
                  Ṣ      Sort [[a, b], [c, d]].
                   ⁼     Compare the result with [[a, b], [c, d]], yielding 1 if
                         the input is sorted, 0 if not.
                 ×     Multiply the results to both sides.

Python 2, 92 90 86 80 bytes
lambda a,b,c,d:[(bin(2741)[2:]*(c+1-a))[b-1:-12+d or None].count(x)for x in'10']

Try it online!
6 more by converting to a lambda, with thanks to @math_junkie for the idea. Now outputs a list containing the two numbers.
Previous non-lambda version (86 bytes)
a,b,c,d=input()
for x in'10':print(bin(2741)[2:]*(c+1-a))[b-1:-12+d or None].count(x),

Try it online old!
2 saved with thanks to @ovs for helping me get rid of the len(k). I hadn't thought about using None.
Input is a list of integers in the format y1,m1,y2,m2
Some credit due to @KeerthanaPrabhakaran who got bin(2741)[2:] before I did which saves 1 byte over hard coding the binary string.

Impressive... k=bin(2741)[2:]*(c+1-a) blew my mind

This is 2 bytes shorter

Brilliant! I was trying to work out hoe to get rid of the len(k) from the last slice. Thanks.

You can save 6 bytes by using a lambda: TIO

JavaScript (ES6), 70 68 67 64 bytes
Takes input as two integers in yyyymm format, in currying syntax (a)(b). Outputs an array of two integers [knuckles, grooves].
a=>g=(b,c=d=0)=>a>b?[c,d-c]:g(--b,c+!((b%=100)>11||b/.87&!!++d))

Formatted and commented
a =>                        // main function: takes start date (a) as input / returns g
  g = (                     // recursive function g, which takes:
        b,                  //   - b = end date
        c = d = 0           //   - c = number of knuckles
      ) =>                  // and also keeps track of: d = total number of months
    a > b ?                 // if a is greater than b:
      [ c, d - c ]          //   stop recursion and return the final result
    :                       // else:
      g(                    //   do a recursive call to g():
        --b,                //   - decrement the end date
        c +                 //   - increment the # of knuckles if
        !(                  //     both of these conditions are false:
          (b %= 100)        //     - the end month (now stored in b in 0-based indexing)
          > 11 ||           //       is greater than 11
          b / 0.87 & !!++d  //     - the number of days in this month is not 31
        )                   //       (at the same time, d is incremented if the first
      )                     //       condition is false)

Test cases
NB: The third test case is not included in this snippet, because it won't work unless your browser has Tail Call Optimization enabled.

let f =

a=>g=(b,c=d=0)=>a>b?[c,d-c]:g(--b,c+!((b%=100)>11||b/.87&!!++d))

console.log(f(201703)(201902)); // 14 10
console.log(f(201701)(202008)); // 26 18
console.log(f(201802)(201803)); // 1 1
console.log(f(201601)(201601)); // 1 0
console.log(f(201612)(201611)); // 0 0

PHP, 259 256 249 248 237 221 bytes
Outgolfed by aross: https://codegolf.stackexchange.com/a/114512/38505
Input Format: yyyymm,yyyymm
$i=explode(",",fgets(STDIN));$_="DateTime::createFromFormat";foreach(new DatePeriod($_(Ym,$i[0]),new DateInterval(P1M),$_(Ym,$i[1])) as$f)date(t,mktime(0,0,0,$f->format(m),1,$f->format(y)))>30?++$x:++$y;
echo $x.' '.++$y;

Try it online!

Older versions
$i=explode(",",fgets(STDIN));$_="DateTime::createFromFormat";$y=1;foreach(new DatePeriod($_("Ym",$i[0]),new DateInterval('P1M'),$_("Ym",$i[1])) as$f)date("t",mktime(0,0,0,$f->format("m"),1,$f->format("y")))==31?++$x:++$y;
echo $x.' '.$y;

Try it online!
$i=explode(",",fgets(STDIN));$_="DateTime::createFromFormat";$y=1;foreach(new DatePeriod($_(Ym,$i[0]),DateInterval::createFromDateString('1 month'),$_(Ym,$i[1])) as$f)date(t,mktime(0,0,0,$f->format(m),1,$f->format(y)))>30?++$x:++$y;
echo $x.' '.$y;

Try it online!
$i=explode(",",fgets(STDIN));$_="DateTime::createFromFormat";$y=1;foreach(new DatePeriod($_(Ym,$i[0]),DateInterval::createFromDateString('1 month'),$_(Ym,$i[1])) as$f)date(t,mktime(0,0,0,$f->format(m),1,$f->format(y)))==31?++$x:++$y;
echo $x.' '.$y;

Try it online!
$i=explode(",",fgets(STDIN));$_="DateTime::createFromFormat";foreach(new DatePeriod($_("Ym",$i[0]),DateInterval::createFromDateString('1 month'),$_("Ym",$i[1])) as$f)date("t",mktime(0,0,0,$f->format("m"),1,$f->format("y")))==31?++$x:++$y;
echo $x.' '.++$y;

Try it online!
$i=explode(",",fgets(STDIN));$_="DateTime::createFromFormat";$y=1;foreach(new DatePeriod($_("Ym",$i[0]),DateInterval::createFromDateString('1 month'),$_("Ym",$i[1])) as$f)date("t",mktime(0,0,0,$f->format("m"),1,$f->format("y")))==31?++$x:++$y;
echo $x.' '.$y;

Try it online!

Python 3.5 (164 162 154 152 150 148 140 137 bytes)
n=int;a,b=input().split();t=k=0
for r in range(n(a[4:]),(n(b[:4])-n(a[:4]))*12+n(b[4:])+1):t+=1;k+=n('101010110101'[r%12-1])
print(k,t-k)

repl.it
takes input in the form of yyyymm yyyymm
prints output as number_of_knuckles number_of_grooves

saved 2 bytes: Thanks to Cole
saved 8 bytes: removed unwanted variables
saved 2 bytes: reduced t=0;k=0 as t=k=0
saved 2 bytes: Thanks to Cole (I had missed this before)
saved 2 bytes: Thanks to  Keerthana
saved 8 bytes: removed unwanted variables
saved 3 bytes: Thanks to math_junkie ( split(' ') to split() )

I think you can reduce some bytes by doing n=int and also perhaps some exec tomfoolery.

I think you can do 2773&1<<r%12-1>0 instead of int('101010110101'[r%12-1])

@Loovjo I am getting error in doing so!

using print([k,t-k]) as print(k,t-k) would produce the desired result as (k,g) thereby reducing 2 bytes!

I believe you can replace split(' ') with split()

Python 2, 147 146 142 bytes
def s(a,b):y=100;r=bin(2741)[2:];x=b/y-a/y;i=r*(x-1);return((0,0),map((i+r[a%y-1:]+r[:b%y]if i or x else r[a%y-1:b%y]).count,('1','0')))[a<=b]

Try it online!

Saved 4 bytes - Thanks to @math_junkie for suggesting the if-else clause with array lookup!

Breaking down the code,
def s(a,b):
 y=100
 r=bin(2741)[2:] #'101010110101'
 x=b/y-a/y #to get the difference between the two years
 i=r*(x-1)
 return((0,0),map((i+r[a%y-1:]+r[:b%y]if i or x else r[a%y-1:b%y]).count,('1','0')))[a<=b]

You can save bytes by replacing the if-else clauses with array lookups. See this post for details

That was indeed a cool way! Didn't know that before! Thanks!

Batch, 93 bytes
@set/ag=(y=%2/100-%1/100)*5+(x=%2%%100+6)*5/12-(w=%1%%100+5)*5/12,k=y*12+x-w-g
@echo %k% %g%

Accepts two parameters in ymm format (i.e. 101 - 999912). Previous 129-byte loop-based solution:
@set/al=%1-%1/100*88,u=%2-%2/100*88,k=g=0
@for /l %%i in (%l%,1,%u%)do @set/a"m=%%i%%12,k+=1451>>m&1,g+=2644>>m&1
@echo %k% %g%

Incorrect result for 000101 999912, probably because of the integer size limit?

@officialaimm Wrong input format, sorry - year should not have leading zeros.

PHP, 120 103 97 96 bytes
for($f=strtotime;$f($argv[2])>=$n=$f($argv[1].+$x++.month);)$k+=date(t,$n)>30;echo+$k,_,$x-1-$k;

Run like this:
php -nr 'for($f=strtotime;$f($argv[2])>=$n=$f($argv[1].+$x++.month);)$k+=date(t,$n)>30;echo+$k,_,$x-1-$k;' 0001-01 9999-12;echo
> 69993_49995

Explanation
for(
  $f=strtotime;          # Alias strtotime function which is called twice.
  $f($argv[2]) >=        # Create end date timestamp. Iterate until the end
                         # date is reached.
  $n=$f(
    $argv[1].+$x++.month # Create timestamp from start date + X months.
  );
)
  $k+=date(t,$n) > 30;   # If "t" of current date (days in month) is 31
                         # increment $k (knuckles).

echo+$k,_,$x-1-$k;       # Compute grooves (iterations - $k) and output,
                         # implicit cast to int to account for 0 count.

Tweaks

Saved 17 bytes by using timestamp style instead of DateTime object style
Saved 6 bytes by not assigning end date timestamp to variable $e, just compare directly
Saved 1 byte by not keeping count of grooves, but just computing it after the loop

$x++ instead of +$x++ also works.

@Titus, I had that at first, but realized that with $x uninitialized the string would be 2017-12month, which is an unrecognized format and results in 1970

Wicked ... it worked somewhere. Wicked enough though that it works without a literal + in the string.

PowerShell, 96 bytes
for($a,$b=[datetime[]]$args;$a-le$b;$a=$a.AddMonths(1)){$x++;$z+=$a.Month-in2,4,6,9,11};$x-$z;$z

Try it online!
Takes input as form 2017-03. Uses the built-in .NET date libraries and loops through from inputs $a to $b, each iteration incrementing $x++ and adding to $z if the current .Month is -in 2,4,6,9,11 (i.e., a non-31-day month). Then we output our total months minus the non-31-day months $x-$z, and the non-31-day months $z.
Tosses an error on the 0001-01 to 9999-12 test case, because .NET only supports years up to 9999, so the final .AddMonths(1) causes an overflow. Still outputs the correct values, though, because it's a non-terminating error; it just causes the loop to exit.
Probably would be shorter to do this arithmetically, like the Python or JavaScript answers, but I wanted to show an approach using the .NET built-ins.

Bash, 113 bytes
s="$1-1";e="$2-1";sort <(while [ "$s" \< "$e" ];do s=$(date +%F -d"$s+1month");date +%d -d"$s-1day";done)|uniq -c

Try it online!
needs golfing...
takes input as 2016-03 2018-10
outputs:
  1 28
  7 30
 12 31

ungolfed:
s="$1-1"
e="$2-1"                     # adds first day of month to the dates
sort <(
while [ "$s" \< "$e" ]; do   #iterates over dates
s=$(date +%F -d"$s+1month")  #adds one month to start date
date +%d -d"$s-1day"         #outputs last day of previous month
done) | uniq -c              #counts ocurrences of day number prevously sorted

Swift, 151 bytes
let f={(m:[Int])->[Int] in var k=[0,0]
(m.min()!...m.max()!).map{$0%100}.filter{$0>0&&$0<13}.forEach{m in let n = m>7 ?m-7:m
k[(n%2+1)%2]+=1}
return k}

input is an array of two integers in the format as per the example


text:
Find the binarray!
We define a binarray as an array satisfying the following properties:

it's non-empty
the first value is a 1
the last value is a 1
all other values are either 0 or 1

For instance, the array [ 1, 1, 0, 1 ] is a valid binarray.
The task
Given a non-empty array A of non-negative integers and a positive integer N, your job is to find a binarray B of length N which allows to generate A by summing an unrestricted number of copies of B, shifted by an unrestricted number of positions.
Example
A = [ 1, 1, 2, 4, 1, 2, 2, 1, 0, 1, 0, 1, 1, 0, 1 ]
N = 4

For this input, the binarray B = [ 1, 1, 0, 1 ] would be a valid answer because we can do:
  [ 1, 1, 0, 1 ]
+       [ 1, 1, 0, 1 ]
+       [ 1, 1, 0, 1 ]
+          [ 1, 1, 0, 1 ]
+                   [ 1, 1, 0, 1 ]
+                                  [ 1, 1, 0, 1 ]
  -----------------------------------------------
= [ 1, 1, 2, 4, 1, 2, 2, 1, 0, 1, 0, 1, 1, 0, 1 ]

Rules

Input can be taken in any reasonable format.
Output can be either a native array (e.g. [1, 1, 0, 1]) or a binary string with or without a separator (e.g. "1,1,0,1" or "1101")
You're only required to print or return one valid binarray. Alternatively, you may choose to print or return all of them when several solutions exist.
You are not required to support inputs that do not lead to any solution.
The sum may include implicit zeros which do not overlap with any copy of B. The second zero in the above sum is such an implicit zero.
Your can assume that the maximum size of A is 100 and the maximum size of B is 30.
This is code-golf, so the shortest answer in bytes wins. Standard loopholes are forbidden.

Test cases
Input : N = 1 / A = [ 1, 2, 3, 4, 5 ]
Output: [ 1 ]

Input : N = 2 / A = [ 1, 2, 100, 99 ]
Output: [ 1, 1 ]

Input : N = 3 / A = [ 1, 1, 1 ]
Output: [ 1, 1, 1 ]

Input : N = 3 / A = [ 1, 1, 3, 2, 2 ]
Output: [ 1, 1, 1 ]

Input : N = 3 / A = [ 1, 0, 2, 1, 1, 1, 0, 0, 1, 0, 1 ]
Output: [ 1, 0, 1 ]

Input : N = 4 / A = [ 1, 2, 2, 2, 1 ]
Output: [ 1, 1, 1, 1 ]

Input : N = 4 / A = [ 1, 1, 2, 4, 1, 2, 2, 1, 0, 1, 0, 1, 1, 0, 1 ]
Output: [ 1, 1, 0, 1 ]

Input : N = 4 / A = [ 1, 1, 0, 2, 1, 0, 1 ]
Output: [ 1, 0, 0, 1 ] or [ 1, 1, 0, 1 ]

Input : N = 5 / A = [ 1, 3, 6, 9, 8, 6, 3, 4 ]
Output: [ 1, 1, 1, 0, 1 ]

Input : N = 8 / A = [ 2, 1, 0, 2, 3, 3, 1, 2, 1 ]
Output: [ 1, 0, 0, 1, 1, 1, 0, 1 ]

Input : N = 10 / A = [ 1, 2, 1, 2, 2, 1, 3, 3, 3, 2, 3, 0, 2, 1, 1, 0, 1 ]
Output: [ 1, 1, 0, 1, 0, 1, 1, 1, 0, 1 ]

Input : N = 13 / A = [ 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 ]
Output: [ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]

Input : N = 5 / A = [ 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 ]
Output: [ 1, 1, 1, 1, 1 ]

Input : N = 6 / A = [ 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 ]
Output: [ 1, 0, 0, 0, 0, 1 ]

Input : N = 7 / A = [ 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 ]
Output: [ 1, 1, 0, 0, 0, 1, 1 ]

Input : N = 9 / A = [ 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 ]
Output: [ 1, 0, 1, 0, 1, 0, 1, 0, 1 ]

What's the largest value of N that should reasonably be supported?

@Neil I've added size limits on both A and B.

If you treat the array as each element to the power of two it is find an odd divisor between 2^n-1 and 2^n

@fəˈnɛtɪk Maybe, but for N=4, A = [ 1, 1, 2, 4, 1, 2, 2, 2, 1, 2, 2, 1, 2, 0, 1 ], you get 30459 which is divisible by both 11 and 13 yet only one of [ 1, 1, 0, 1 ] and [ 1, 0, 1, 1 ] is a valid answer.

@fəˈnɛtɪk These numbers aren't written in base 2 so rules of arithmetic don't apply. For instance, you explicitly cannot carry when adding.

Please add these test cases, which seem to break nearly all the posted answers: N = 3, A = [1, 0, 2, 0, 2, 0, 1], output = [1, 0, 1]; N = 3, A = [1, 1, 1, 0, 0, 0, 1, 1, 1], output = [1, 1, 1].

PHP, 105 92 90 86 bytes
Jörg´s solution fixed and golfed:
for($b=1+2**$argv[1];;)--$argc>1?$s+=$argv[$argc]*2**$i++:$s%($b-=2)||die(decbin($b));

takes N from first command line argument, values after that;
run with -ror test it online.
prints binary number (format 10001);
prints invalid solution or runs dead if there is no valid solution.
first version (now 97 bytes) that prints nothing for invalid input: test it online
for($b=1+$m=2**$argv[1];$m/2<=$b;)--$argc>1?$s+=$argv[$argc]*2**$i++:$s%($b-=2)||die(decbin($b));

breakdown
for($b=1+$m=2**$argv[1];$m/2<=$b;)  # second loop: loop $b from 2^N-1 by -2 to 2^(N-1)
--$argc>1                           # first loop: decrease $argc ...
    ?$s+=$argv[$argc]*2**$i++           # while $argc>1: binary sum from last to 2nd argument
    :$s%($b-=2)||die(decbin($b));       # later: if $b divides $s, print in binary and exit

Nice could you not reach a byte count under 100?

@JörgHülsermann I could.

Heavy Thinking. I know before this that you are better. I hope you can hold the lowest byte count

On N = 3, A = [1, 0, 2, 0, 2, 0, 1], this incorrectly returns 111 where the only correct result is [1, 0, 1].

PHP, 219 bytes
<?for(list($g,$z)=$_GET,$d=~-$l=2**$z;$d>=$l/2;max(array_diff_assoc($r,$g)?:[0])?:$o[]=$b,$d-=2)for($r=[],$b=decbin($d),$k=0;$k<count($g);$k++)for($u=$g[$k]-$r[$k],$i=0;$i<$z;$i++)$u<1?:$r[$k+$i]+=$u*$b[$i];print_r($o);

Try it online!
-4 Bytes using [$g,$z]=$_GET PHP 7.1 instead of list($g,$z)=$_GET

It seems like it outputs both a valid ([1,0,1,0,1,0,1,0,1]) and an invalid answer ([1,0,0,0,1,0,1,1,1]) for the last test case.

-8 bytes: while($_GET[0])$s+=2**$i++*array_pop($_GET[0]);. -5 bytes: range(1|.5*$m=2**$_GET[1],$m,2).

@Arnauld Yes I should give as Output only the highest binarray too make this solution valid

@Arnauld it is a valid answer. The initial array is equivalent to 101111111101 in binary which is 3069, 100010111 is equivalent to 279, which goes into 3069 11 times

(+5)-11 bytes: for($b=2**$_GET[1]/2-1|1;2**$l>$b+=2;) (|1 to fix N=1); another -6 if you go from high to low: for($b=1+$m=2**$_GET[1];$m/2<$b-=2;). -4 bytes with -r and $argv instead of $_GET: while(--$argc>1)$s+=2**$i++*array_pop($argv); (N as first argument, array values after that).

@fəˈnɛtɪk I do agree with your maths, but the challenge is about finding a pattern that can be summed exactly to A, not an equivalent arrangement. Here, we'd get [ 1,0,1,1,1,0,2,2,2,2,2,1 ].

@Titus feel free to add your solution or make an own post. Sometimes if you golfed a version from me down I could not really understand your ideas

-1 byte with for($g=$_GET[0];$g;).

-1 byte with while($g=&$_GET[0])

Python, 166 bytes
def f(a,n):
 for i in range(1<<n-1,1<<n):
  b=bin(i)[2:];u,v=(int(('0{:0>%d}'%sum(a)*len(s)).format(*s))for s in[a,b])
  if u%v<1>int(str(u//v*10)[::~sum(a)]):yield b

Try it online!
How it works
Consider A and B as the digits of base k numbers u and v.  For example (we’ll use k = 1000 for illustration):
A = [1, 2, 1, 3, 2, 1, 2]
B = [1, 0, 0, 1]
u = 1 002 001 003 002 001 002
v = 1 000 000 001
As many of the other answerers noticed, if B is a valid answer, then u is divisible by v. In this case,
u = 1 002 001 002 ⋅ v
This quotient, translated back to the array [1, 2, 1, 2], tells us exactly how many copies of B we need shifted to each position.
  [1, 0, 0, 1]
+    [1, 0, 0, 1]
+    [1, 0, 0, 1]
+       [1, 0, 0, 1]
+          [1, 0, 0, 1]
+          [1, 0, 0, 1]
-----------------------
  [1, 2, 1, 3, 2, 1, 2]

(Why? Because that is exactly how long multiplication works in base k.)
What the other answerers failed to notice is that the above condition is not sufficient.  For example:
A = [1, 2, 1, 3, 2, 1, 2]
B = [1, 1, 1, 1]
u = 1 002 001 003 002 001 002
v = 1 001 001 001
u = 1 000 999 002 ⋅ v
Mathematically speaking, we can still translate that quotient back to the array [1, 1, −1, 2], which works fine if we’re allowed to use negative copies of B:
  [1, 1, 1, 1]
+    [1, 1, 1, 1]
−       [1, 1, 1, 1]
+          [1, 1, 1, 1]
+          [1, 1, 1, 1]
-----------------------
  [1, 2, 1, 3, 2, 1, 2]

but of course the challenge does not permit negative copies.  So we need an additional check.
Toward that end, we select a base k = 10e where k > 10 ⋅ sum(A), and check that none of the base k digits overflow into the next base k digit when we multiply the quotient by ten.  That is, every eth base ten digit, starting at the end, in the base ten representation of the quotient times ten, must be 0.  This guarantees that the quotient translates back to an array with nonnegative elements.

I love your trick of using a large power of 10 as the base to make the base conversion easier.

PHP, 213 Bytes
Same way a little bit golfed
<?for($b=2**~-$l=$_GET[1];$b<2**$l;array_filter($t[$b++])?:$d[]=$o)for($g=count($t[$b]=$_GET[$i=0]);min($t[$b])>-1&$i<=$g-$l;$i++)for($e=$t[$b][$i],$k=0,$o=decbin($b);$k<$l;)$t[$b][$k+$i]-=$o[$k++]*$e;print_r($d);

Try it online!
PHP, 344 Bytes first working
After my first answer I have decide to make a longer try that give back all valid solutions.
<?foreach(range(2**($l=$_GET[1])-1,2**($l-1))as$b){$t[$b]=($g=$_GET[0]);for($i=0;$t[$b]&&$i<=count($g)-$l;$i++){$e=reset($y=array_slice($t[$b],$i,$l));foreach(str_split(decbin($b))as$k=>$v)$t[$b][$k+$i]=$y[$k]-$e*$v;if(min($t[$b])<0)unset($t[$b]);}}foreach($t as$k=>$v)if(max($v)>0)unset($t[$k]);echo join(",",array_map(decbin,array_keys($t)));

Online Version
Breakdown
foreach(
    range(2**($l=$_GET[1])-1
    ,2**($l-1)
    ) # make decimal range of a binarray with given length
    as$b){
$t[$b]=($g=$_GET[0]); # make a copy for each possible solution pattern
    for($i=0;$t[$b]&&$i<=count($g)-$l;$i++){ # Loop till solution is valid or reach last digit
        $e=reset($y=array_slice($t[$b],$i,$l)); # take first value of a sequence with the length
        foreach(str_split(decbin($b))as$k=>$v)
            $t[$b][$k+$i]=$y[$k]-$e*$v; # replace values in copy
        if(min($t[$b])<0)unset($t[$b]); # kill solution if a minimum <0 exists
    }
}
foreach($t as$k=>$v)if(max($v)>0)unset($t[$k]); # drop all solutions where the sum is not zero

echo join(",",array_map(decbin,array_keys($t))); #Output all solutions

This seems to work for N ≥ 2, but fails on N = 1 cases, such as the first test case in the challenge.

@AndersKaseorg Now it supports the N = 1 Cases it needs only to set a = in the first loop for the shorter version In the greater version it needs to delete four Bytes

Python, 205 bytes
def f(a,l):
 b=lambda s:b(s[:-1])*sum(a)*8+int(s[-1])if s else 0
 c=lambda n:n and(n/sum(a)/4%2 or c(n/sum(a)/8))
 for i in range(2**~-l,2**l):
  j=bin(i)[2:]
  if b(a)%b(j)<1 and not c(b(a)/b(j)):return j

Returns a binary string without separator. As @AndersKaseorg points out, there are inputs for which @fəˈnɛtɪk's solution doesn't work because the division represents a negative coefficient which is disallowed. To work around this, I use a very large base and test that there is no borrow in the division.

Okay, I think this is an actual counterexample: f([1, 1, 1, 0, 0, 0, 1, 1, 1], 3) incorrectly returns 101.

@AndersKaseorg Hmm, does reversing the order of the loop help, or is the algorithm still fundamentally broken?

I think it’s fundamentally broken without additional checks. The reverse variant fails on f([1, 0, 2, 0, 2, 0, 1], 3), and both the forward and reverse variants fail on f([1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0], 5).

And even if you check that i is odd, both the forward and reverse variants fail on f([1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0]*10, 5).

@AndersKaseorg Ah yes, when gcd(k,n)=1, (x^kn-1)/(x^k-1) always has (x^n-1)/(x-1) as a factor, which fools @fəˈnɛtɪk's solution in any base.

@AndersKaseorg I have tweaked my answer so it's a bit more resilient now.

Okay. It still fails for cases with N = 1, though, such as the first test case given in the challenge.

@AndersKaseorg Ah, that seems to be down to a useless +1 which didn't achieve anything but broke the N=1 case.

Still fails when N = 1 and A has length 1.

@AndersKaseorg Ugh, those edge cases where my base just wasn't large enough...

This version looks correct now.

You can combine the two assignments into a single line, separated by a semicolon, to save a byte.

@Challenger5 Thanks, but I'm not going to get anywhere near AndersKaseorg's far superior answer, so it's hardly worth it.

Pari/GP, 77 74 96 80 bytes
n->a->[v|d<-divisors(b=Pol(a)),(v=Vec(d))%2==v&&vecmin(Vec(b/d))>=0&&d%x&&#d==n]

Returns all solutions.
First converts the array a to a polynomial b. Then chooses from the divisors b the polynomials d such that the coefficients of d are all 1 and 0, and the coefficients of b / d are all nonnegative, and d(0) = 1, and deg(d) = n + 1. Finally, converts them back to arrays.
Try it online!

Pyth, 32 bytes
f!|%FKiRJysQ,QT>#sQj/FKJ+L1^U2tE

Try it online
How it works
                           ^U2tE   Cartesian power [0, 1]^(N - 1)
                        +L1        prepend 1 to every list
f                                  filter for lists T such that:
          sQ                         sum(A)
         y                           double
        J                            assign to J
      iR    ,QT                      convert [A, T] from base J
     K                               assign to K
   %F                                fold modulo
  |                                  logical OR with
                    /FK                fold integer division over K
                   j   J               convert to base J
               >#sQ                    filter for digits greater than sum(A)
 !                                   logical NOT

The strategy is similar to my Python answer, except that since Pyth has builtins for base conversion, we can use a more efficient base k = 2 ⋅ sum(A), and check directly that every digit of the quotient is at most sum(A).

source: Stack Exchange

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

sort: votes


text:
Topple the sandpile
(There are related questions about infinite sandpiles, and finding identity elements of sandpiles.)
Given a matrix of non-negative integers, return a matrix of the same dimensions, but toppled:

If the matrix doesn't contain any values larger than 4, return it.
Every "cell" that is larger than 3 gets reduced by 4, and all directly neighboring cells (above, below, left, and right) are incremented, if they exist.
GOTO 1.

Examples:
0 1 0        0 2 0
2 4 0   ->   3 0 1
0 0 3        0 1 3

1 2 3    2 3 4    2 5 1    4 1 2    0 3 3    0 3 3    0 3 3
4 5 6 -> 2 4 4 -> 4 2 3 -> 0 5 4 -> 3 2 1 -> 3 3 1 -> 3 3 2
7 8 9    5 7 7    2 6 5    4 3 2    0 5 3    1 1 4    1 2 0

(You only need to return the final result. The path on which you reach it may differ from the one shown here: it doesn't matter in which order you perform the toppling operations, they all lead to the same result.)
For a deeper explanation and some motivation see this Numberphile video or the Wikipedia article on the Abelian sandpile model.
Rules:

You may take input and output in any of the standard ways
Loopholes are forbidden
Input and output may be:

a nested list: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
a simple list: [1, 2, 3, 4, 5, 6, 7, 8, 9] and the shape
some kind of native matrix type
a string, e.g. 1 2 3\n4 5 6\n7 8 9
or whatever else works in your language.

Input and output must be in the same form
The input may contain larger numbers than the ones shown here, but the size may be bound by the limits of your language (MAXINT equivalents, if applicable)
The matrix may have any shape (e.g. 1x1, 2x2, 3x3, 4x4, 2x7, 11x3, ...)
You don't need to handle the case where the shape is 0xN or Nx0.

Testcases
[[2, 5, 4], [8, 6, 4], [1, 2, 3]] -> [[3, 3, 0], [1, 2, 2], [1, 3, 2]]
[[0, 0, 2], [1, 3, 3], [0, 0, 0]] -> [[0, 0, 2], [1, 3, 3], [0, 0, 0]]
[[9, 9, 9], [9, 9, 9], [9, 9, 9]] -> [[1, 3, 1], [3, 1, 3], [1, 3, 1]]
[[4, 5], [2, 3]] -> [[2, 3], [0, 1]]
[[2, 3, 5], [2, 2, 0]] -> [[3, 0, 2], [2, 3, 1]]
[[7]] -> [[3]]

This is codegolf, the shortest code (per language) wins.

Is it OK to display all the intermediate results?

@feersum I guess so, as long as it's clear what the final result is.

MATL, 17 bytes
tss:"t3>t1Y6Z+w4*-+

Try it at MATL Online! Or verify all test cases.
Explanation
The program iterates for as many times as the sum of the input. This is a loose upper bound on the required number of iterations.
For each iteration, entries in the sandpile matrix exceeding 3 are detected, giving a matrix of 1 and 0, which is convolved with the 4-neighbour mask. The entries exceeding 3 in the sandpile matrix are reduced by 4, and the result of the convolution is added.
For the last iterations, in which the sandpile matrix does not have any numbers exceeding 3, zeros are subtracted from and added to it, so it is unaffected.
t       % Implicit input (matrix). Duplicate
ss      % Sum of matrix entries
:"      % Repeat that many times
  t     %   Duplicate
  3>    %   True for matrix entries that exceed 3
  t     %   Duplicate
  1Y6   %   Push predefined literal [0, 1, 0; 1, 0, 1; 0, 1, 0]
  Z+    %   2D convolution, keeping size
  w     %   Swap
  4*    %   Multiply by 4
  -     %   Subtract
  +     %   Add
        % Implicit end. Implicit display

Convolution high five.

@MartinEnder Ah, you also used that :-) Nice to see a fellow convoluter! I'm sure flawr will join us soon

@LuisMendo Convolutionista

Mathematica, 65 bytes
#//.s_:>s+ListConvolve[{v={0,1,0},1-v,v},x=UnitStep[s-4],2,0]-4x&

Explanation
#//.s_:>...&

Repeatedly transform the input by toppling all piles greater than 3. This process stops automatically when the transformation fails to change the matrix (i.e. when no large piles exist any more). In the following expression the matrix is called s.
...x=UnitStep[s-4]...

Create a matrix that has a 1 whenever the current matrix has a 4 or greater, and a zero otherwise. This is essentially a mask that indicates which piles need to be toppled. Call the mask x.
ListConvolve[{v={0,1,0},1-v,v},x=UnitStep[s-4],2,0]

First we compute the number of sand that is added to each pile due to toppled neighbouring piles. This is done with a convolution of the following matrix over x:
0 1 0
1 0 1
0 1 0

Essentially, it adds one to the current cell for each of its von-Neumann neighbours in the mask.
s+...-4x

We add the previous result to s and then we subtract four times the mask from it to reduce the toppled piles.

Octave, 65 bytes
This doesn't seem very good, I must be missing some tricks...
m=input(0);do;m+=conv2(m>3,[0 1 0;1 -4 1;0 1 0],"same")
until m<4

What version of Octave are you using that allows input(0)?

@Suever >> version ans = 4.0.1

JavaScript (ES6), 101 95 bytes
Takes the width of the matrix w and an array of values a in currying syntax (w)(a). Returns an array of values.
w=>g=a=>(b=a.map((n,i)=>n%4+(F=d=>~m|i%w&&a[i+d]>>2)(m=w)+F(-w)+F(m=-1)+F(!++i)))+0==a+0?a:g(b)

Formatted and commented
w =>                      // main function: takes w as input, returns g
  g = a =>                // recursive function g: takes a as input
    (                     //
      b = a.map((n, i) => // for each element n at position i in a:
        n % 4 + (         //   keep only n MOD 4
          F = d =>        //   define F(): function that takes d as input
            ~m |          //     if m is not equal to -1
            i % w &&      //     or i MOD w is not null:
            a[i + d] >> 2 //       return a fourth of the value of the cell at i + d
        )(m = w) +        //   test the cell below the current cell
        F(-w) +           //   test the cell above
        F(m = -1) +       //   test the cell on the left
        F(!++i)           //   test the cell on the right
      )                   // end of map(): assign the result to b
    ) + 0 == a + 0 ?      // if b is equal to a:
      a                   //   stop recursion and return a
    :                     // else:
      g(b)                //   do a recursive call with b

Test cases

let f =

w=>g=a=>(b=a.map((n,i)=>n%4+(F=d=>~m|i%w&&a[i+d]>>2)(m=w)+F(-w)+F(m=-1)+F(!++i)))+0==a+0?a:g(b)

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

C++, 261 258 250 bytes
#import<vector>
#define S size()
void f(std::vector<std::vector<int>>&m){s:int i,j,r;for(i=r=0;i<m.S;++i)for(j=0;j<m[i].S;++j){if(m[i][j]>3){r=1;m[i][j]-=4;j>0&&m[i][j-1]++;i>0&&m[i-1][j]++;j<m[i].S-1&&m[i][j+1]++;i<m.S-1&&m[i+1][j]++;}}if(r)goto s;}

Takes input as a reference to a vector of vectors and modifies it directly.
Try it online!

237 bytes

JavaScript (ES6), 118 114 104 bytes
Saved 2 bytes thanks to @Neil
f=a=>a.find(b=>++y&&b.find(c=>++x&&c>3,x=0),y=0)?f(a.map(b=>b.map(c=>c+=--i|y?i*i+y*y==1:-4,i=x,--y))):a

Does (i-=x)|y-j?i*i+ help?

@Neil It does indeed, thanks!

...I was on the phone but I was also considering a.find(...b.find(...c>3&&a.map(...)))&&f(a).

@Neil I don't think that would work, since .map doesn't mutate...

It seems that making it mutate costs slightly less than moving the map inside the find saves: f=a=>a.find((b,x)=>b.find((c,y)=>c>3&&a.map(b=>b.map((_,j)=>b[j]+=x|(j-=y)?x*x+j*j==1:-4)&x--)))&&f(a)

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

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


text:
Good Vibrations
The sound of the theremin has been immortalized in The Beach Boys song Good Vibrations.  Many also associate its sound with the theme for the original series of Star Trek, though apparently it was a soprano's emulation.
This challenge requires you to implement a theremin.
Input

Take 2 dimensional input from a mouse or other input device (e.g. you could use a joystick), which will produce a tone from an audio output device as follows:

increasing x will increase the frequency of the tone.  Note that frequency increases exponentially with musical note, so you must implement a linear relationship between mouse x position and the musical note, and
increasing y will increase the volume of the tone.

There appears to be confusion regarding the waveform produced by a real theremin, so for simplicity, a sine wave (or close approximation thereof) must be used.

Rules

The tone produced must have at least a 2-octave range.  More range is acceptable.  A-440 must lie within the range.
In order to create the audible appearance of continuously variable frequency and amplitude, the range of values considered in both dimensions from the input device must be at least 500 Implementations may open a window (at least 500x500 pixels) to read input from mouse cursor position.  Or without opening a window, coordinates may be read directly from the mouse or other input device.
There must be a simple means to stop the program - key-combination, mouse-click or other common input device.  CTRL-c is sufficient.
Any standard libraries may be used, as long as they do not totally implement the solution with no other work required.
Standard rules for Code Golf and I/O
You may stop by having the mouse or input device lose focus on the input box.

Notes

Because the output tone is dynamically-generated, care must be take to ensure the tone is a continuous waveform; that is there are no audible clicks or pops caused by sudden changes of phase or amplitude.
You may limit the input size zone to 500 by 500 but it may be bigger.

This is code-golf, so the shortest answer in any language wins.
Special thanks
Special thanks to Digital Trauma for making this challenge and posting it in the Secret Santa's Sandbox. I have made a few edits and here is the original post.

JavaScript ES6, 215 188 bytes
This seems to work well in Chrome and Edge. Firefox and Safari not so much.
with(new AudioContext)o=createOscillator(onmousemove=e=>{o.frequency.value=9/innerWidth*e.x**2,v.gain.value=1-e.y/innerHeight}),v=createGain(),v.connect(destination),o.start(),o.connect(v)

Saved 27 bytes thanks to @darrylyeo
Try it online!

with(new AudioContext)o=createOscillator(onmousemove=e=>{o.frequency.value=9/innerWidth*e.x**2,v.gain.value=1-e.y/innerHeight}),v=createGain(),v.connect(destination),o.start(),o.connect(v)
<button onClick="o.stop()">Stop</button>

That is pretty good! I had way too much fun

Thanks. I think it's even more fun with a with a square wave

Trying it out and about lost an eardrum

o.type='sine' is unnecessary since it's the default. You can simplify document.onmousemove to just onmousemove.

Golfed from 215 to 188 bytes: with(new AudioContext)o=createOscillator(onmousemove=e=>{o.frequency.value=9/innerWidth*e.x**2,v.gain.value=1-e.y/innerHeight}),v=createGain(),v.connect(destination),o.start(),o.connect(v)

Thanks. I didn't know about with. That is some cool stuff.


text:
Flip a coin for me!

Note: There was not a vanilla challenge to actually flip a coin, even though there were mentions about flipping coins a lot of places. Even though there is a challenge to generate a random number from 1 to N, I suspect this is not a dupe. These questions ask for random numbers from 1 to N, while this ask for just truthy/falsy.

Flipping a coin is widely used in selecting decisions. But, I do not have a coin (only bills and credit/debit cards).
So, your program has to flip a coin for me!

I/O
Input:
None.
Output:
A truthy/falsy value depending on the coin's state(heads/tails). It does not have to be uniform, seeding by timestamp is allowed. Also, we do not count neither-heads-nor-tails, and assume the coin only has two sides.

Comments are not for extended discussion; this conversation has been moved to chat.

I don't think the question is actually a duplicate of the one marked. There is a slight variation if I'm not wrong. And the snippet get a random true or false value - and that answers the question!

The questuon 1/n probability is a more specific version of this question. Here it's just truths or false. The other one was printing a true in 1/n probability. This is what I meant when I said a difference in precious comment.

Not sure if it still matters, but in case your challenge gets reopened, you should clarify what you mean by it does not have to be uniform.

If it does not have to be uniform, there is a 100% chance for exit code 0 on empty program in lots of languages...

As I said in the chat room, if this challenge should be closed as a dupe, the vanilla hello, world challenge should be closed as a dupe of the similar challenges that came before it for all the same reasons.

Out of curiosity, would an answer written as a Windows command from the Command Line count as valid (22 chars)? set/a a=%RANDOM%/16384

Python 2, 18 17 15 14 bytes
0/(id(0)&4096)

Try it online! Output is via exit code, so check the Debug drawer.
If 50/50 chance isn't required, these shorter versions will work as well.
0/(id(0)%3)   # 11 bytes, awfully biased
0/(id(0)>>25) # 13 bytes, even more biased
0/(id(0)%6<3) # 13 bytes, fair enough for most practical purposes

How it works
In CPython 2.7.12, id(1) yields the memory location of the constant 1 as a 32-bit integer with the following pattern.1
000000yxxxxxxxxxxxxx000110100000

y isn't constant, but it's biased towards 0. All x bit seem to occur with the same probability. I ran the program 100,000 times and these were the distributions.
Bit  Zeroes  Ones
  0  100000       0
  1  100000       0
  2  100000       0
  3  100000       0
  4  100000       0
  5       0  100000
  6  100000       0
  7       0  100000
  8       0  100000
  9  100000       0
 10  100000       0
 11  100000       0
 12   50125   49875
 13   50319   49681
 14   50001   49999
 15   50164   49836
 16   50095   49905
 17   50072   49928
 18   49780   50220
 19   50056   49944
 20   49910   50090
 21   50038   49962
 22   50103   49897
 23   49811   50189
 24   50106   49894
 25   80950   19050
 26  100000       0
 27  100000       0
 28  100000       0
 29  100000       0
 30  100000       0
 31  100000       0

If the twelfth least significant bit is set, id(0)&4096 yields 1 and the program exits with status code 1. However, if it is not set, id(0)&4096 yields 0, a ZeroDivisionError is raised, and the program exits with status code 1.

1 I've verified anything I couldn't find in the docs empirically. Other implementations may behave differently.

Hah, great trick outputting via exit code.

MATL, 3 bytes
rEk

This outputs 0 or 1 with the same probability.
Try it online!
Explanation
r     % Random number uniformly distributed on the interval (0,1)
E     % Multiply by 2
k     % Round down

Pyth, 2 bytes
O2

Outputs 0 for heads, 1 for tails.
Similarity to any real-world company only incidental.
Try it!

JavaScript (ES6), 13 bytes
_=>new Date%2

Test snippet

let f =
_=>new Date%2
<button onclick="console.log(f())">Flip</button>

Powershell, 8 Bytes
random 2

outputs either 0 or 1 randomly.

Perl 6, 11 bytes
{Bool.pick}

Try it
Explanation:

Bool is an enum of True and False
.pick picks an element at random from a list
{…} in this case makes it a lambda

Japt, 3 bytes
K%2

Try it online! (Output cache disabled for obvious reasons)
Outputs 0 or 1 with equal probability. K is equivalent to new Date() in JavaScript, and %2 takes the timestamp mod 2.

Alternatively:
½>Mr

This one generates a random float x between 0 and 1, and outputs .5>x. Try it online!

CJam, 3 bytes
2mr

Try it online!
Explanation
2    e# Push 2
 mr  e# Random integer from 0 to n-1

PHP, 13 bytes
<?=rand(0,1);

Outputs a pseudo-random 0 or 1 value.
Test online

Octave, 10 bytes
@()rand<.5

Anonymous fuction that takes no inputs and returns 0 or 1.
Try it online!

Jelly, 3 bytes
2ḶX

Try it online!

><>, 14 11 bytes
x0n;n0
>1n;

Try it online!
Outputs either 0 or 1

Cubix, 7 bytes
w>O@D1.

Outputs 0 with 1/3 probability, 1 with 2/3 probability. Try it online!
I think this is the first time I've had to pad the source code with no-ops to make the cube the correct size...
Explanation
Cubix is a 2D stack-based esolang wrapped around a cube. The source code won't fit onto a size-1 cube, and so it gets wrapped around a size-2 cube, with the following cube net:
    w >
    O @
D 1 . . . . . .
. . . . . . . .
    . .
    . .

The IP (instruction pointer) is then sent into action, starting at the top-left corner of the left-most face, and facing east. The first instruction it hits is D, which points the IP in a random direction. This isn't the best possible source of randomness for this challenge, but it's the only one Cubix has.
If the IP is pointed north, it wraps onto the w on the top face, which moves the IP one position to the right (south at this point). O outputs the top item on the stack as a number (0 if the stack is empty), and @ ends the program.
If the IP is pointed south, it wraps around various faces before hitting the > on the top face. It's going west at this point, and > points the cursor east, sending it back to the D, which starts the whole process over.
If the IP is pointed east or west, it simply wraps around the third row of the above diagram, hitting the 1 at some point in the middle. When it gets back to the D, the process is started again as before, but when the IP eventually gets sent north, O outputs 1 instead of 0.
So each time D is hit, there's a 2/4 chance that the output will be 1, and a 1/4 chance that it will be 0. The other 1/4 is simply the chance of the process starting over, and so if we sum the infinitely shrinking chances of each output, we get 2/3 for 1 and 1/3 for 0.

05AB1E, 4 3 bytes
T.R

Try it online!
Explanation:
T   10
 .R Random choice (breaks into individual digits)

I believe that T.R also works.

@Adnan It does indeed, even though it pushes 10 and not '10' in this case.

Röda, 13 bytes
randomBoolean

Try it online!
This is a boring builtin.

*><>, 6 bytes
x0n;n1

Online interpreter

Gol><>, 3 bytes
xh1

Online interpreter

Befunge-98, 6 bytes
#1?0>q

Try it online!
Exits with exit code 0 or 1.
Explanation
Program flow in Befunge is a bit difficult to follow. The Instruction Pointer (IP) starts on the left, moving towards the right. The first instruction # tells it to ignore the next instruction, so it jumps to ?. This randomly sets the IP moving either up, down, left, or right. If it moves up or down, it "wraps around" and hits the ? again. If it moves right, 0 is pushed onto the stack and then q exits with the topmost value of the stack (0) as the exit code. If the IP moves left, 1 is pushed onto the stack, q is jumped over, > sets the IP moving to the right again, and then q exits the program with the topmost value of the stack (1) as the exit code.
I believe that this code also works in Unefunge-98, Trefunge-98, and possibly all members of the Funge-98 family. I have not tested any of these claims though.