Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
22 added 29 characters in body
source | link

C,  176  126125 bytes

Thanks to @ceilingcat for golfing 42 bytes, and thanks to both @Lynn and @Jonathan Frech for saving a byte each!

d(M,n)int*M;{int i=n--,s=*M*!n,c,T[n*n];for(;i--;s+=M[i]*(1-i%2*2)*d(T,n))for(c=n*n;c--;T[c]=M[n+1+c+c;T[c]=M[n-~c+c/n+(c%n>=i)]);return s;}

Calculates the determinant using the Laplace expansion along the first row.

Try it online!Try it online!

Unrolled:

d(M, n)int*M;
{
    int i=n--, s=*M*!n, c, T[n*n];
    for (; i--; s+=M[i]*(1-i%2*2)*d(T,n))
        for (c=n*n; c--;)
            T[c] = M[n+1+c+cM[n-~c+c/n+(c%n>=i)];
    return s;
}

C,  176  126 bytes

Thanks to @ceilingcat for golfing 42 bytes and thanks to @Lynn for saving a byte!

d(M,n)int*M;{int i=n--,s=*M*!n,c,T[n*n];for(;i--;s+=M[i]*(1-i%2*2)*d(T,n))for(c=n*n;c--;T[c]=M[n+1+c+c/n+(c%n>=i)]);return s;}

Calculates the determinant using the Laplace expansion along the first row.

Try it online!

Unrolled:

d(M, n)int*M;
{
    int i=n--, s=*M*!n, c, T[n*n];
    for (; i--; s+=M[i]*(1-i%2*2)*d(T,n))
        for (c=n*n; c--;)
            T[c] = M[n+1+c+c/n+(c%n>=i)];
    return s;
}

C,  176  125 bytes

Thanks to @ceilingcat for golfing 42 bytes, and thanks to both @Lynn and @Jonathan Frech for saving a byte each!

d(M,n)int*M;{int i=n--,s=*M*!n,c,T[n*n];for(;i--;s+=M[i]*(1-i%2*2)*d(T,n))for(c=n*n;c--;T[c]=M[n-~c+c/n+(c%n>=i)]);return s;}

Calculates the determinant using the Laplace expansion along the first row.

Try it online!

Unrolled:

d(M, n)int*M;
{
    int i=n--, s=*M*!n, c, T[n*n];
    for (; i--; s+=M[i]*(1-i%2*2)*d(T,n))
        for (c=n*n; c--;)
            T[c] = M[n-~c+c/n+(c%n>=i)];
    return s;
}
21 deleted 10 characters in body
source | link

C,  176  128126 bytes

Thanks to @ceilingcat for golfing 4042 bytes and thanks to @Lynn for saving a byte!

d(M,n)int*M;{int i=n,k=n-1-,s=*M*!kn,c,T[k*k];forT[n*n];for(;i--;s+=M[i]*(1-i%2*2)*d(T,kn))for(c=k*k;cc=n*n;c--;T[c]=M[n+c+c;T[c]=M[n+1+c+c/k+n+(c%k>=ic%n>=i)]);return s;}

Calculates the determinant using the Laplace expansion along the first row.

Try it online!Try it online!

Unrolled:

d(M, n)int*M;
{
    int i=n, k=n-1-, s=*M*!kn, c, T[k*k];T[n*n];
    for (; i--; s+=M[i]*(1-i%2*2)*d(T,kn))
        for (c=k*k;c=n*n; c--;)
            T[c] = M[n+c+cM[n+1+c+c/k+n+(c%k>=ic%n>=i)];
    return s;
}

C,  176  128 bytes

Thanks to @ceilingcat for golfing 40 bytes and thanks to @Lynn for saving a byte!

d(M,n)int*M;{int i=n,k=n-1,s=*M*!k,c,T[k*k];for(;i--;s+=M[i]*(1-i%2*2)*d(T,k))for(c=k*k;c--;T[c]=M[n+c+c/k+(c%k>=i)]);return s;}

Calculates the determinant using the Laplace expansion along the first row.

Try it online!

Unrolled:

d(M, n)int*M;
{
    int i=n, k=n-1, s=*M*!k, c, T[k*k];
    for (; i--; s+=M[i]*(1-i%2*2)*d(T,k))
        for (c=k*k; c--;)
            T[c] = M[n+c+c/k+(c%k>=i)];
    return s;
}

C,  176  126 bytes

Thanks to @ceilingcat for golfing 42 bytes and thanks to @Lynn for saving a byte!

d(M,n)int*M;{int i=n--,s=*M*!n,c,T[n*n];for(;i--;s+=M[i]*(1-i%2*2)*d(T,n))for(c=n*n;c--;T[c]=M[n+1+c+c/n+(c%n>=i)]);return s;}

Calculates the determinant using the Laplace expansion along the first row.

Try it online!

Unrolled:

d(M, n)int*M;
{
    int i=n--, s=*M*!n, c, T[n*n];
    for (; i--; s+=M[i]*(1-i%2*2)*d(T,n))
        for (c=n*n; c--;)
            T[c] = M[n+1+c+c/n+(c%n>=i)];
    return s;
}
20 added 36 characters in body
source | link

C,  176  129128 bytes

Thanks to @ceilingcat for golfing 40 bytes and thanks to @Lynn for saving a byte!

d(M,n)int*M;{int i=n,k=n-1,s=*M*!k,c,T[k*k];for(;i--;s+=M[i]*(i%2*1-2+1i%2*2)*d(T,k))for(c=k*k;c--;T[c]=M[n+c+c/k+(c%k>=i)]);return s;}

Calculates the determinant using the Laplace expansion along the first row.

Try it online!Try it online!

Unrolled:

d(M, n)int*M;
{
    int i=n, k=n-1, s=*M*!k, c, T[k*k];
    for (; i--; s+=M[i]*(i%2*1-2+1i%2*2)*d(T,k))
        for (c=k*k; c--;)
            T[c] = M[n+c+c/k+(c%k>=i)];
    return s;
}

C,  176  129 bytes

Thanks to @ceilingcat for golfing 40 bytes!

d(M,n)int*M;{int i=n,k=n-1,s=*M*!k,c,T[k*k];for(;i--;s+=M[i]*(i%2*-2+1)*d(T,k))for(c=k*k;c--;T[c]=M[n+c+c/k+(c%k>=i)]);return s;}

Calculates the determinant using the Laplace expansion along the first row.

Try it online!

Unrolled:

d(M, n)int*M;
{
    int i=n, k=n-1, s=*M*!k, c, T[k*k];
    for (; i--; s+=M[i]*(i%2*-2+1)*d(T,k))
        for (c=k*k; c--;)
            T[c] = M[n+c+c/k+(c%k>=i)];
    return s;
}

C,  176  128 bytes

Thanks to @ceilingcat for golfing 40 bytes and thanks to @Lynn for saving a byte!

d(M,n)int*M;{int i=n,k=n-1,s=*M*!k,c,T[k*k];for(;i--;s+=M[i]*(1-i%2*2)*d(T,k))for(c=k*k;c--;T[c]=M[n+c+c/k+(c%k>=i)]);return s;}

Calculates the determinant using the Laplace expansion along the first row.

Try it online!

Unrolled:

d(M, n)int*M;
{
    int i=n, k=n-1, s=*M*!k, c, T[k*k];
    for (; i--; s+=M[i]*(1-i%2*2)*d(T,k))
        for (c=k*k; c--;)
            T[c] = M[n+c+c/k+(c%k>=i)];
    return s;
}
19 deleted 9 characters in body
source | link
18 deleted 19 characters in body
source | link
17 deleted 28 characters in body
source | link
16 deleted 6 characters in body
source | link
15 added 282 characters in body
source | link
14 deleted 3 characters in body
source | link
13 deleted 14 characters in body
source | link
12 deleted 2 characters in body
source | link
11 deleted 3 characters in body
source | link
10 deleted 1 character in body
source | link
9 deleted 4 characters in body
source | link
8 added 39 characters in body
source | link
7 deleted 6 characters in body
source | link
6 deleted 2 characters in body
source | link
5 deleted 11 characters in body
source | link
4 added 4 characters in body
source | link
3 deleted 42 characters in body
source | link
2 added 68 characters in body
source | link
1
source | link