JavaScript (ES6), 83 bytes
Expects (u)(v).
Disclaimer: Either that's correct, or I completely misunderstood the challenge.
u=>v=>[0,1,2,4].reduce((p,i)=>p.map(n=>i&&n+u[i%=7]*v[j%=7]-u[j++]*v[i++],j=i*3),u)
Commented
u => // u[] = first vector
v => // v[] = second vector
[0, 1, 2, 4] // lookup list
.reduce((p, i) => // for each value i with p[] as the accumulator:
p.map(n => // for each value n in p[]:
i && // force to zero if i = 0
n + // otherwise, take the current value n
u[i %= 7] * // and add u[i] * v[j] - u[j] * v[i]
v[j %= 7] - // where both i and j are reduced modulo 7
u[j++] * // and incremented afterwards
v[i++], //
j = i * 3 // start with j = i * 3, which gives (modulo 7):
// (i,j) = (1,3), (2,6), (4,5)
), // end of map()
u // start with p[] = u[] (but the content of p[]
// is cleared on the first iteration)
) // end of reduce()
JavaScript (ES6), 83 bytes
Expects (u)(v).
Disclaimer: Either that's correct, or I completely misunderstood the challenge.
u=>v=>[0,1,2,4].reduce((p,i)=>p.map(n=>i&&n+u[i%=7]*v[j%=7]-u[j++]*v[i++],j=i*3),u)
Commented
u => // u[] = first vector
v => // v[] = second vector
[0, 1, 2, 4] // lookup list
.reduce((p, i) => // for each value i with p[] as the accumulator:
p.map(n => // for each value n in p[]:
i && // force to zero if i = 0
n + // otherwise, take the current value n
u[i %= 7] * // and add u[i] * v[j] - u[j] * v[i]
v[j %= 7] - // where both i and j are reduced modulo 7
u[j++] * // and incremented afterwards
v[i++], //
j = i * 3 // start with j = i * 3, which gives (modulo 7):
// (i,j) = (1,3), (2,6), (4,5)
), // end of map()
u // start with p[] = u[] (but the content of p[]
// is cleared on the first iteration)
) // end of reduce()
JavaScript (ES6), 83 bytes
Expects (u)(v).
u=>v=>[0,1,2,4].reduce((p,i)=>p.map(n=>i&&n+u[i%=7]*v[j%=7]-u[j++]*v[i++],j=i*3),u)
Commented
u => // u[] = first vector
v => // v[] = second vector
[0, 1, 2, 4] // lookup list
.reduce((p, i) => // for each value i with p[] as the accumulator:
p.map(n => // for each value n in p[]:
i && // force to zero if i = 0
n + // otherwise, take the current value n
u[i %= 7] * // and add u[i] * v[j] - u[j] * v[i]
v[j %= 7] - // where both i and j are reduced modulo 7
u[j++] * // and incremented afterwards
v[i++], //
j = i * 3 // start with j = i * 3, which gives (modulo 7):
// (i,j) = (1,3), (2,6), (4,5)
), // end of map()
u // start with p[] = u[] (but the content of p[]
// is cleared on the first iteration)
) // end of reduce()
JavaScript (ES6), 83 bytes
Expects (u)(v).
Disclaimer: Either that's correct, or I completely misunderstood the challenge.
u=>v=>[0,1,2,4].reduce((p,i)=>p.map(n=>i&&n+u[i%=7]*v[j%=7]-u[j++]*v[i++],j=i*3),u)
Commented
u => // u[] = first vector
v => // v[] = second vector
[0, 1, 2, 4] // lookup list
.reduce((p, i) => // for each value i with p[] as the accumulator:
p.map(n => // for each value n in p[]:
i && // force to zero if i = 0
n + // otherwise, take the current value n
u[i %= 7] * // and add u[i] * v[j] - u[j] * v[i]
v[j %= 7] - // where both i and j are reduced modulo 7
u[j++] * // and incremented afterwards
v[i++], //
j = i * 3 // start with j = i * 3, which gives (modulo 7):
// (i,j) = (1,3), (2,6), (4,5)
), // end of map()
u // start with p[] = u[] (but the content of p[]
// is cleared on the first iteration)
) // end of reduce()
JavaScript (ES6), 83 bytes
Expects (u)(v).
Disclaimer: Either that's correct, or I completely misunderstood the challenge.
u=>v=>[0,1,2,4].reduce((p,i)=>p.map(n=>i&&n+u[i%=7]*v[j%=7]-u[j++]*v[i++],j=i*3),u)
Commented
u => // u[] = first vector
v => // v[] = second vector
[0, 1, 2, 4] // lookup list
.reduce((p, i) => // for each value i with p[] as the accumulator:
p.map(n => // for each value n in p[]:
i && // force to zero if i = 0
n + // otherwise, take the current value n
u[i %= 7] * // and add u[i] * v[j] - u[j] * v[i]
v[j %= 7] - // where both i and j are reduced modulo 7
u[j++] * // and incremented afterwards
v[i++], //
j = i * 3 // start with j = i * 3
), // end of map()
u // start with p[] = u[] (but the content of p[]
// is cleared on the first iteration)
) // end of reduce()
JavaScript (ES6), 83 bytes
Expects (u)(v).
Disclaimer: Either that's correct, or I completely misunderstood the challenge.
u=>v=>[0,1,2,4].reduce((p,i)=>p.map(n=>i&&n+u[i%=7]*v[j%=7]-u[j++]*v[i++],j=i*3),u)
Commented
u => // u[] = first vector
v => // v[] = second vector
[0, 1, 2, 4] // lookup list
.reduce((p, i) => // for each value i with p[] as the accumulator:
p.map(n => // for each value n in p[]:
i && // force to zero if i = 0
n + // otherwise, take the current value n
u[i %= 7] * // and add u[i] * v[j] - u[j] * v[i]
v[j %= 7] - // where both i and j are reduced modulo 7
u[j++] * // and incremented afterwards
v[i++], //
j = i * 3 // start with j = i * 3, which gives (modulo 7):
// (i,j) = (1,3), (2,6), (4,5)
), // end of map()
u // start with p[] = u[] (but the content of p[]
// is cleared on the first iteration)
) // end of reduce()
JavaScript (ES6), 83 bytes
Expects (u)(v).
Disclaimer: Either that's correct, or I completely misunderstood the challenge.Disclaimer: Either that's correct, or I completely misunderstood the challenge.
u=>v=>[0,1,2,4].reduce((p,i)=>p.map(n=>i&&n+u[i%=7]*v[j%=7]-u[j++]*v[i++],j=i*3),u)
Commented
u => // u[] = first vector
v => // v[] = second vector
[0, 1, 2, 4] // lookup list
.reduce((p, i) => // for each value i with p[] as the accumulator:
p.map(n => // for each value n in p[]:
i && // force to zero if i = 0
n + // otherwise, take the current value n
u[i %= 7] * // and add u[i] * v[j] - u[j] * v[i]
v[j %= 7] - // where both i and j are reduced modulo 7
u[j++] * // and incremented afterwards
v[i++], //
j = i * 3 // start with j = i * 3
), // end of map()
u // start with p[] = u[] (but the content of p[]
// is cleared on the first iteration)
) // end of reduce()
JavaScript (ES6), 83 bytes
Expects (u)(v).
Disclaimer: Either that's correct, or I completely misunderstood the challenge.
u=>v=>[0,1,2,4].reduce((p,i)=>p.map(n=>i&&n+u[i%=7]*v[j%=7]-u[j++]*v[i++],j=i*3),u)
JavaScript (ES6), 83 bytes
Expects (u)(v).
Disclaimer: Either that's correct, or I completely misunderstood the challenge.
u=>v=>[0,1,2,4].reduce((p,i)=>p.map(n=>i&&n+u[i%=7]*v[j%=7]-u[j++]*v[i++],j=i*3),u)
Commented
u => // u[] = first vector
v => // v[] = second vector
[0, 1, 2, 4] // lookup list
.reduce((p, i) => // for each value i with p[] as the accumulator:
p.map(n => // for each value n in p[]:
i && // force to zero if i = 0
n + // otherwise, take the current value n
u[i %= 7] * // and add u[i] * v[j] - u[j] * v[i]
v[j %= 7] - // where both i and j are reduced modulo 7
u[j++] * // and incremented afterwards
v[i++], //
j = i * 3 // start with j = i * 3
), // end of map()
u // start with p[] = u[] (but the content of p[]
// is cleared on the first iteration)
) // end of reduce()