Related, but very different.
In the examples below, \$A\$ and \$B\$ will be \$2\times2\$ matrices, and the matrices are one-indexed.
A Kronecker product has the following properties:
A⊗B = A(1,1)*B A(1,2)*B A(2,1)*B A(2,2)*B = A(1,1)*B(1,1) A(1,1)*B(1,2) A(1,2)*B(1,1) A(1,2)*B(1,2) A(1,1)*B(2,1) A(1,1)*B(2,2) A(1,2)*B(2,1) A(1,2)*B(2,2) A(2,1)*B(1,1) A(2,1)*B(1,2) A(2,2)*B(1,1) A(2,2)*B(1,2) A(2,2)*B(2,1) A(2,2)*B(1,2) A(2,2)*B(2,1) A(2,2)*B(2,2) Challenge: Given two matrices, \$A\$ and \$B\$, return \$A\otimes B\$.
- The size of the matrices will be at least \$1\times1\$. The maximum size will be whatever your computer / language can handle by default, but minimum \$5\times5\$ input.
- All input values will be non-negative integers
- Builtin functions that calculate Kronecker products or Tensor/Outer products are not allowed
- In general: Standard rules regarding I/O format, program & functions, loopholes etc.
Test cases:
A = 1 2 3 4 B = 5 6 7 8 A⊗B = 5 6 10 12 7 8 14 16 15 18 20 24 21 24 28 32 B⊗A = 5 10 6 12 15 20 18 24 7 14 8 16 21 28 24 32 ------------------------ A = 1 2 B = 1 2 A⊗B = 1 2 2 4 ------------------------ A = 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1 B = 1 1 0 1 A⊗B = 16 16 2 2 3 3 13 13 0 16 0 2 0 3 0 13 5 5 11 11 10 10 8 8 0 5 0 11 0 10 0 8 9 9 7 7 6 6 12 12 0 9 0 7 0 6 0 12 4 4 14 14 15 15 1 1 0 4 0 14 0 15 0 1 B⊗A = 16 2 3 13 16 2 3 13 5 11 10 8 5 11 10 8 9 7 6 12 9 7 6 12 4 14 15 1 4 14 15 1 0 0 0 0 16 2 3 13 0 0 0 0 5 11 10 8 0 0 0 0 9 7 6 12 0 0 0 0 4 14 15 1 ------------------------ A = 2 B = 5 A⊗B = 10