5 kyu

One-Semicolon Matrix Multiplication

Description:

In this kata, you'll have to write a function multiply(int[][], int[][]) -> int[][] that multiplies two matrices. The matrices are represented by arrays of rows, where each row is an int[]. For example, the 3x3 identity represented this way would be:

int[][] ident = new int[][] {
  new int[] {1, 0, 0},
  new int[] {0, 1, 0},
  new int[] {0, 0, 1}
};

Of course, there's a catch: you only get one semicolon!

All the matrices you receive are guaranteed to be valid matrices (i.e. you won't get rows of varying sizes in the same matrix). If a particular multiplication is impossible, your function should return null. The input arrays will not be empty.

For your convenience, a utility function Utils.print(int[][]) -> void has been provided. If you pass it a matrix, it'll print it to the console in a somewhat readable fashion. Remember to remove any debug code in your final answer, though -- can't have any stray semicolons!

Good luck!

Linear Algebra
Matrix
Algorithms
Puzzles
Restricted

Stats:

CreatedOct 18, 2017
PublishedOct 18, 2017
Warriors Trained490
Total Skips40
Total Code Submissions1053
Total Times Completed92
Java Completions86
C# Completions11
Total Stars17
% of votes with a positive feedback rating92% of 38
Total "Very Satisfied" Votes34
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes2
Total Rank Assessments3
Average Assessed Rank
5 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • phantamanta44 Avatar
  • Voile Avatar
  • Madjosz Avatar
  • hobovsky Avatar
  • dfhwze Avatar
  • pablo.bf Avatar
Ad