Post History
C, 147 bytes float d(float**m,int r){if(r<2)return**m;int i=r,j;float s=0,*n[--r];for(;i--;s+=(i%2?-1:1)**m[i]*d(n,r))for(j=r;j--;)n[j]=m[j+(j>=i)]+1;return s;} Try it online! Basically ...
Answer
#1: Initial revision
# C, 147 bytes ```c float d(float**m,int r){if(r<2)return**m;int i=r,j;float s=0,*n[--r];for(;i--;s+=(i%2?-1:1)**m[i]*d(n,r))for(j=r;j--;)n[j]=m[j+(j>=i)]+1;return s;} ``` [Try it online!][TIO-ksv2632l] Basically a C version of my example code. Takes an array of pointers and the size. Prettified and commented version: ```c float d(float **m, int r) { if(r < 2) return **m; // Base case: 1x1 matrix int i = r, j; // Variable initialization, i and j are counters float s = 0, *n[--r]; // s is the sum, n is the minor matrix for(; i--; s += (i % 2 ? -1 : 1) * *m[i] * d(n, r)) // Outer loop: loop over the rows of M. // After each iteration, add the term to the sum for(j = r; j--; ) // Inner loop to fill in the minor matrix n[j] = m[j + (j >= i)] + 1; // (j >= i) term skips over the ith row of M. // Addition of 1 effectively removes the first element return s; } ``` [Try it online!][TIO-ksv2hv64] [C (gcc)]: https://gcc.gnu.org/ [TIO-ksv2hv64]: https://tio.run/##nVRNb5tAED3DrxjFsgQOOAHsfoQkVSv10EPVQ6P2QKxoC4u9LizWsk7dRv7rdWf4iB0HuW45jHeZeW/ePNYbu9M43mzSrGAaEqv@HQxyB4TUoGx4MA2RWgouwbdBcb1UkvIhwNkZvGMlhxjDBXgrD3KmlViZiECsgCtQDsyxsn0Q8YUpwb5lHOmFFiwTv5gWhcR2wGQCc2AKGYul1FyVplHrKZHq3IGBjFxXTerWJYgS9IxDuUSxst3lQhZqKyQtlBWCcN0QAadXYAnogw9vwPUANdswgEEeiQn@JhaqULZN5J@W2B6yolhcVBGKe9wTvyp@lFCk8HFoGvAfD5K/TYmcs3gGAlfN/CxJqgb4JgddtKOZRjXDnMwMYU6D2IfpP0jZaCeaVGQZev3cG8MwZDSfIG8ezeEUsMX1FQh7gmsv3CV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