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

Matrix: Ensure whole matrix is correct #2195

Closed
wants to merge 1 commit into from

Conversation

homersimpsons
Copy link

@homersimpsons homersimpsons commented Feb 6, 2023

There are some proposed solutions where the mentee submit solution that would emit extra empty rows. For instance with an off by one error in a for-loop.

By checking that the whole matrix is exactly as expected we can catch such mistakes.

For the record this was discussed in the following thread; https://forum.exercism.org/t/pull-requrest-on-exercism-javascript/3440/3

Detailed summary from the thread

For instance the following solution will fail nearly all newer columns tests while it currently pass those tests:

export class Matrix {
  constructor(matrix) {
    this.matrix = matrix
  }

  get rows() {
    return this.matrix
      .split('\n')
      .map(row => row.split(' ').map(entry => +entry));
  }

  get columns() {
    const columns = [];
    for (let i = 0; i <= this.rows.length; i++) {
      columns[i] = this.rows.map((row) => {
        return row[i];
      });
     }
     return columns;
  }
}

The issue is that the user is iterating on this.rows.length instead of this.rows[0].length. And the user is using <= over <.

Those are the failing tests:

// extract column from one number matrix
expected: [[1]]
received: [[1], [undefined]]
// can extract column
expected: [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
received: [[1, 4, 7], [2, 5, 8], [3, 6, 9], [undefined, undefined, undefined]]
// extract column where numbers have different widths
expected: [[89, 18, 9], [1903, 3, 4], [3, 1, 800]]
received: [[89, 18, 9], [1903, 3, 4], [3, 1, 800], [undefined, undefined, undefined]]

Also, I do not know if this expected but the JS test suite has one more test:

https://github.com/homersimpsons/javascript/blob/f9f722fc7c4b6ab3d700178f076e305784ba686b/exercises/practice/matrix/matrix.spec.js#L34-L36

NB: A Pull Request is already opened on the exercism/javascript repository: https://github.com/exercism/javascript/pull/2065/files

There are some proposed solutions where the mentee submit solution that would emit extra empty rows. For instance with an off by one error in a for-loop.

By checking that the whole matrix is exactly as expected we can catch such mistakes.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2023

Hello. Thanks for opening a PR on Exercism. We are currently in a phase of our journey where we have paused community contributions to allow us to take a breather and redesign our community model. You can learn more in this blog post. As such, all issues and PRs in this repository are being automatically closed.

That doesn't mean we're not interested in your ideas, or that if you're stuck on something we don't want to help. The best place to discuss things is with our community on the Exercism Community Forum. You can use this link to copy this into a new topic there.


Note: If this PR has been pre-approved, please link back to this PR on the forum thread and a maintainer or staff member will reopen it.

@github-actions github-actions bot closed this Feb 6, 2023
@homersimpsons
Copy link
Author

homersimpsons commented Feb 7, 2023

For the record I did update the code with the reimplements and comments keys homersimpsons@9c22e01.

@SleeplessByte
Copy link
Member

@homersimpsons I cannot reopen this because the branch was force pushed. If you recreate the PR and then tag me, I'll open it.

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