Skip to content

Saddle Point: Uses y, x coordinate values, rather than x, y #313

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

Closed
kotp opened this issue Aug 1, 2016 · 8 comments
Closed

Saddle Point: Uses y, x coordinate values, rather than x, y #313

kotp opened this issue Aug 1, 2016 · 8 comments

Comments

@kotp
Copy link
Member

kotp commented Aug 1, 2016

So say you have a matrix like so:

    0  1  2
  |---------
0 | 9  8  7
1 | 5  3  2     <--- saddle point at (1,0)
2 | 6  6  7

It has a saddle point at (1, 0).

It appears that the saddle point at 1, 0 is 8 (though the arrow distracts from this coordinates given) which goes against the "unambiguous definition above" as stated in the readme, though 8 is not following the rules of what it means to be a saddle by the definition given.

The point at (0, 1) however, which is 5 does fulfil this definition. And matches the grid "pointer".

Edit: The change, then, may be to change the coordinate shown as (1,0) to (0,1).

@kytrinyx
Copy link
Member

kytrinyx commented Aug 1, 2016

I think this is my fault. I tend to get the order wrong when listing points in a Matrix. (I also have trouble with left and right, which is troubling in a completely different way).

@petertseng
Copy link
Member

It is at least noted that https://en.wikipedia.org/wiki/File:Matrix.svg uses the same ordering of coordinates (although 1-based rather than 0-based).

Also see that if the matrix is stored as m = [[9, 8, 7], [5, 3, 2], [6, 6, 7]] (it can make sense to store this way because printing it will naturally show them as the diagram does) then m[1][0] would be 5 and m[0][1] would be 8.

The opposition is that (x, y) is conventional in other applications with grids.

Whatever choice we make, we can certainly clarify it in the README.

Finally, surely there are some expected coordinates in tracks' test suites. What do they say about which coordinate should come first?

@rbasso
Copy link
Contributor

rbasso commented Aug 2, 2016

I'll try to summarize what I think to make things clearer in my head:

  • Matrix indexing (Math)
    • (i, j) - [1..m] x [1..n]
    • Down-right orientation.
    • Good for matrix (math) exercises.
  • 2D "Computer" Cartesian
    • (x, y) - [0..width -1] x [0..height - 1]
    • Right-down orientation.
    • Good for representations with discrete positive values.
  • 2D "Standard" Cartesian (Math)
    • (x, y) - [xMin..xMax] x [yMin..yMax]
    • Right-Up orientation.
    • Good for representations that allow negative values.
    • Good for unbounded spaces.
    • Good for indexing with real values.
  • Chess Algebraic Notation - "Standard Cartesian"
    • (col, row) - [a..h] x [1..8]
    • Right-Up orientation.
    • [a..h] can be represented internally the same way as [1..8].
    • Good for chess exercises.
    • queen-attack should have used this.

@kotp
Copy link
Member Author

kotp commented Aug 2, 2016

Thanks, I agree, the numbering is correct, and definitely appropriate for the exercise.

The change, then, is to note the matrix ordering, which is down -> right.

@rbasso
Copy link
Contributor

rbasso commented Aug 2, 2016

If we use matrix indexing, we should probably start indexing at (1,1) to avoid creating a non-standard indexing that will confuse users.

Edit: I don't think it would be problematic to use "Computer" Cartesian in this exercise, if you think it would be easier for users to write the solution. I'm against just mixing the systems. Your original idea seems good.

@rbasso
Copy link
Contributor

rbasso commented Aug 2, 2016

Putting it in examples, I think we should choose between these two options:

Matrix indexing
    1  2  3
  |---------
1 | 9  8  7
2 | 5  3  2     <--- saddle point at (2,1)
3 | 6  6  7

"Computer Cartesian" indexing
    0  1  2
  |---------
0 | 9  8  7
1 | 5  3  2     <--- saddle point at (0,1)
2 | 6  6  7

@kotp
Copy link
Member Author

kotp commented Aug 2, 2016

Should we then provide the value at that point, either way?

? | 5 3 2 <--- saddle point at (coordinates) with value 5

@rbasso
Copy link
Contributor

rbasso commented Aug 2, 2016

That would help a lot! 😄

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

No branches or pull requests

6 participants