Skip to main content
7 of 8
added 13 characters in body
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

MATL, 19 bytes

,!ix"0GYs@12XQ!g]v! 

Inputs are M (matrix), H (column vector), V (column vector). The row separator is ;.

Try it online! Or verify all test cases: 1, 2, 3, 4, 5.

I'll add an explanation tomorrow later.

Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382