exercism / problem-specifications

Shared metadata for exercism exercises.
MIT License
326 stars 541 forks source link

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

Closed kotp closed 5 years ago

kotp commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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

kotp commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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

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

rbasso commented 8 years ago

That would help a lot! :smile: