˜εQy*yFÁ]øεø€à
-5 bytes thanks to @ovs.
Try it online or verify all test cases.
Explanation:
Z # Get the flattened maximum of the (implicit) input-matrix
L # Pop and push a list in the range [1,max]
˜ # (`ZL` is now `˜`: flatten the (implicit) input-matrix)
ε # Map over each:
Q # Check for each integer in the (implicit) input-matrix whether it's equal
# to this integer
y* # Multiply each by this integer
yF # Loop `y` amount of times:
Á # And rotate the rows that many times towards the right
] # Close both the inner loop and map
ø # Zip/transpose to get a list of lists of rows
ε # Map each list of rows to:
ø # Zip/transpose; so the values of each cell are grouped together now
ۈ # Get the maximum of each list of cell-values
# (after which the matrix is output implicitly as result)
Here a step-by-step of an input to output; with the old ZL
(flattened maximum; [1,max] ranged list) instead of ˜
(flatten the input-matrix):
Z # i.e. [[0,0,2,0,1],
# [0,2,1,1,0],
# [3,0,2,1,0],
# [0,0,0,0,0]] → 3
L # → [1,2,3]
εQ # → [[[0,0,0,0,1],[0,0,1,1,0],[0,0,0,1,0],[0,0,0,0,0]],
# [[0,0,1,0,0],[0,1,0,0,0],[0,0,1,0,0],[0,0,0,0,0]],
# [[0,0,0,0,0],[0,0,0,0,0],[1,0,0,0,0],[0,0,0,0,0]]]
y* # → [[[0,0,0,0,1],[0,0,1,1,0],[0,0,0,1,0],[0,0,0,0,0]],
# [[0,0,2,0,0],[0,2,0,0,0],[0,0,2,0,0],[0,0,0,0,0]],
# [[0,0,0,0,0],[0,0,0,0,0],[3,0,0,0,0],[0,0,0,0,0]]]
yFÁ] # → [[[0,0,0,0,0],[0,0,0,0,1],[0,0,1,1,0],[0,0,0,1,0]],
# [[0,0,2,0,0],[0,0,0,0,0],[0,0,2,0,0],[0,2,0,0,0]],
# [[0,0,0,0,0],[3,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]]]
ø # → [[[0,0,0,0,0],[0,0,2,0,0],[0,0,0,0,0]],
# [[0,0,0,0,1],[0,0,0,0,0],[3,0,0,0,0]],
# [[0,0,1,1,0],[0,0,2,0,0],[0,0,0,0,0]],
# [[0,0,0,1,0],[0,2,0,0,0],[0,0,0,0,0]]]
εø # → [[[0,0,0],[0,0,0],[0,2,0],[0,0,0],[0,0,0]],
# [[0,0,3],[0,0,0],[0,0,0],[0,0,0],[1,0,0]],
# [[0,0,0],[0,0,0],[1,2,0],[1,0,0],[0,0,0]],
# [[0,0,0],[0,2,0],[0,0,0],[1,0,0],[0,0,0]]]
€à # → [[0,0,2,0,0],
# [3,0,0,0,1],
# [0,0,2,1,0],
# [0,2,0,1,0]]
3100 -> 0013
(jumping over); column800 -> 008
(wrapping around more than once) \$\endgroup\$