Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hayden - Edges (C10) - Matrix Covert To Zero #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

haydenwalls
Copy link

No description provided.

@shrutivanw
Copy link

You're on the right track. There are however a few considerations that your current algorithm is missing.
Consider this test case:
The input, original matrix is:

1 1 1 0 0
1 1 1 1 1
1 0 1 1 1
1 1 1 1 1

Manually visualizing this matrix, the matrix is expected to be changed to:

0 0 0 0 0
1 0 1 0 0
0 0 0 0 0
1 0 1 0 0

Your algorithm converts it to:

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

To account for this and some other scenarios, I added more test cases to the spec file this morning:

    it "not all rows, not all columns" do
      # setup
      rows = 4
      columns = 5
      matrix = initialize_matrix(rows, columns)
      matrix[0][3] = 0 # row 0, column 1
      matrix[0][4] = 0 # row 1, column 1
      matrix[2][1] = 0 # row 2, column 1
      rows_array = [0, 2]
      columns_array = [1, 3, 4]

      # method call
      matrix_convert_to_0(matrix)

      # validation
      verify_matrix(matrix, rows_array, columns_array)
    end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants