Say i have an 2d array A of nxn size, int values already given for each item.these values can be the same or different. There's gonna be another nxn array B being input. I can only interchange one row from B with another row from B, or one col from B with another col from B. (Exchanging a row with a col is not a thing. Just row with row, col with col.) I cant use any other function or action. I cant change anything about A, and i can only swap rows/cols from B.
The goal is making B as same as possible from A. (If an item in A has value a, and same index item in B is value b; the sum of all |a-b|, aka L1 distance would be the number we should try to reduce as much as we can.)
L1 distance is the metric of which we get to know how same A and B is.
but problem being; all item from B has random int values. The size of B is same as A for sure, but the numbers in B are completely random. So, there's no guarantee for all, if any items from A to fit B at all.
I basically have no clue how to approach making L1 distance as small as possible. I was completely capable when the second array guaranteed to be able to be the exact same as the first. Now i dont know where to start.