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

wordy: test that problems with zero operations give the correct answer #1382

Merged
merged 1 commit into from
Nov 9, 2018
Merged

wordy: test that problems with zero operations give the correct answer #1382

merged 1 commit into from
Nov 9, 2018

Conversation

petertseng
Copy link
Member

It's possible to have a healthy debate about whether a problem with zero
operations really should count as in scope.

One might expect that a generically-written solution would indeed accept
such a problem.

Consider an implementation that strips away all tokens except for
numbers and the four recognised operators (ignoring the intro like "What
is"). Such an implementation would now be required to distinguish
between the valid "What is 5?" versus the invalid "What is 4 cubed"
instead of simply stripping away the "cubed" and declaring the problem
invalid because it only contains the single token 4 (for that would
also declare What is 5? invalid)

Note that this PR intentionally has a merge conflict to prevent accidental merges. The merge conflict is trivially resolvable if it is decided this should be merged, but it should not be resolved unless discussion indicates so.

@petertseng
Copy link
Member Author

The following comment is my current opinion; you might consider averting your eyes if you don't want to be influenced by it:

I think we should consider such problems out of scope and leave them as untested (and undefined) behaviour. I just can't convince myself that these should be considered word problems since they're so degenerate.

This is despite the fact that I have argued in the commit message that such problems should already be accepted by a reasonably-written implementation and that it helps implementations be more robust. While these statements are true, my understanding of this exercise's scope informs my current thinking on the issue.

@coriolinus
Copy link
Member

My opinion: the implementation which just strips out everything which is neither a word nor a supported operation is overly simplistic, and shouldn't pass the test suite.

The implied syntax of a word problem in regex form is currently What is \d+ ((plus|minus|multiplied by|divided by) \d+)+\?. This PR changes the regex only by changing the final + to a *; that seems reasonable for students to handle.

Also, while "What is 5" is a degenerate word problem, it's pretty hard to argue that it isn't a word problem.

@petertseng
Copy link
Member Author

the implementation which just strips out everything which is neither a word nor a supported operation is overly simplistic, and shouldn't pass the test suite.

I agree, and if this PR is rejected, I have in mind some alternatives that would help with that. Perhaps something like What is 5 plus nonsense 5?.

@petertseng
Copy link
Member Author

I have determined that my opposition to this PR is strength 1/10.

Since I have an approval, if no further comments are forthcoming, one should expect me to merge this when 120 hours have passed since the PR was submitted.

wordy 1.4.0

It's possible to have a healthy debate about whether a problem with zero
operations really should count as in scope.

One might expect that a generically-written solution would indeed accept
such a problem.

Consider an implementation that strips away all tokens except for
numbers and the four recognised operators (ignoring the intro like "What
is"). Such an implementation would now be required to distinguish
between the valid "What is 5?" versus the invalid "What is 4 cubed"
instead of simply stripping away the "cubed" and declaring the problem
invalid because it only contains the single token `4` (for that would
also declare `What is 5?` invalid)
@petertseng petertseng changed the title wordy: should problems with zero operations be considered valid? wordy: test that problems with zero operations give the correct answer Nov 9, 2018
@petertseng petertseng merged commit 2ac55e4 into exercism:master Nov 9, 2018
@petertseng petertseng deleted the wordy-degenerate branch November 9, 2018 23:15
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tsk tsk tsk. 😉

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.

3 participants