Create a program to compute the product of several 128×128 matrices.
Each dataset is a binary file containing several 64K-byte blocks. All blocks, except the first, contain one 128×128 matrix containing unsigned, 32-bit, little endian integers in row-major order. Thus, each row is 128×4 = 512 bytes.
The first block contains a zero-terminated series of byte indexes indicating the order in which the matrices should be multplied. For example, if the first bytes of the first block consist are 01 02 02 01 00 ..., the final result is obtained by computing ABBA, where A is the matrix in block 1, and B is the matrix in block 2.
All arithmetic should be preformed using 32-bit operations, ignoring any overflow. Thus, all operations are modulo 232.
To compute the final answer, total each row, sort the totals to be ascending, and report the new index of each. To illustrate, assume the product was the 4×4 matrix shown below. The row index and total for each row are shown on the right.
1 4294967290 5 5 0, 5 4294967295 0 0 0 1, 4294967290 10 20 30 40 2, 100 1 1 1 1 3, 4
Sorting the row totals gives the following result:
3, 4 0, 5 2, 100 1, 4294967290
Thus, the final answer for this 4×4 matrix would be the 4-index sequence: 3, 0, 2, 1. Format your answer similar to example shown below, except of course, your the final answer will be a 128-index sequence.
{ "answer" : [3,0,2,1] }