fave77 / Mathball

A JavaScript library for Competitive Programming
https://fave77.github.io/Mathball-Docs/
MIT License
99 stars 49 forks source link

Matrix Chain Multiplication #104

Closed devRD closed 5 years ago

devRD commented 5 years ago

Do the checklist before filing the issue:

NOTE: Provide a clear and concise description of the feature that needs to be added! Or if its a bug, then provide the necessary steps to reproduce it along with screenshots.

To find the least number of operations needed to multiply a chain of matrices together. For example, given 4 matrices A, B, C, D, there can be multiple ways of multiplying them, such as: (ABC)D = (AB)(CD) = A(BCD) ...

Validation: Input taken should be an array of positive integers, otherwise it should throw an error.

Input: An array with number of rows of the respective matrices.

Output: Minimum number of operations.

M.matrixChain([40, 20, 30, 10])  //14000

//Validations

M.matrixChain(12) //Error: not an array
M.matrixChain(10, -20, 40, 10) //Error: not positive integers
devRD commented 5 years ago

I would like to work on this