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

Improve Problem description for Rectangles #2062

Open
matthewmorgan opened this issue Jun 19, 2022 · 4 comments
Open

Improve Problem description for Rectangles #2062

matthewmorgan opened this issue Jun 19, 2022 · 4 comments

Comments

@matthewmorgan
Copy link
Contributor

matthewmorgan commented Jun 19, 2022

The Rectangles problem asks users to count the number of rectangles in an array of ASCII text. In the problem description, an illustration of such an array is given, and its valid rectangles are called out.

However, there's a sentence at the end of the problem description that seems unhelpful:

You may assume that the input is always a proper rectangle (i.e. the length of every line equals the length of the first line).

What does this mean? It's confusing because:

  1. The sides of the rectangles do not need to all be equal (that's a square of course, which is a special case of a rectangle.)
  2. The "first line" means what?

I would propose that this sentence simply be removed, since knowing what a rectangle is seems pretty fundamental, and this sentence doesn't make anything clearer. If for some reason there needs to be explanatory text there, I think it should be helpful and unambiguous, perhaps like:

A rectangle's opposite sides will be both parallel and equal to each other in length. A rectangle's adjacent sides may or may not be equal to each other in length. You can see in the above examples that some rectangles have a height that is equal to their width, and some do not.

Or maybe the sentence is intended to convey something different than what a rectangle is? If that's the case, then I still think it could be clarified to communicate whatever is actually intended.

@matthewmorgan matthewmorgan changed the title Problem description for Rectangles is unclear, maybe untrue, and potentially confusing Improve Problem description for Rectangles Jun 19, 2022
@kotp
Copy link
Member

kotp commented Jun 20, 2022

I read it without any indication that there is a number of lines (for the vertical length of the rectangle) that is arbitrary, but the length of those lines must match the length of the first line. Otherwise it is a rhombus. If it were a square then the specification, written, would say that the number of lines must match the length of the first line, which would provide us with a square.

The first line means, the first line. I am not sure why that is not clear.

Perhaps, though, I can agree that this line does not need to be there, we can enforce, and clarify in the tests.

The tests, which are meant to be read, may clarify the meaning of the written words. And while the tests do not have to be exhaustive, (and most often should not be) the reading material should never contradict the tests.

@kotp
Copy link
Member

kotp commented Jun 20, 2022

Also, thank you for the opportunity to talk about this exercise!

@petertseng
Copy link
Member

For an input like:

  +-+
  | |
+-+-+
| |
+-+

those instructions indicate that the last two lines will be padded to the right with spaces, thus making all lines in the input equal length (five characters per line), rather than the first three lines having five characters and the last two lines having only three.

Presumably, the student is spared the possibility of having to check for and prevent an index out of bounds.

@matthewmorgan
Copy link
Contributor Author

matthewmorgan commented Jun 20, 2022

Well, now it makes sense in the context of the input format! Maybe no change is needed, or something simple like:

You may assume that the length of every line of the input will match the length of its first line.

And/or a test to validate that?

I'm happy to create a PR if a change would be helpful. If not, I'm equally happy to close this issue.

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

No branches or pull requests

3 participants