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

series: Clarify edge case of zero-length substrings #1751

Merged
merged 2 commits into from
Sep 25, 2023

Conversation

senekor
Copy link
Contributor

@senekor senekor commented Sep 24, 2023

@MatthijsBlom
Copy link

MatthijsBlom commented Sep 24, 2023

The intuition is:

 t e x t
^ ^ ^ ^ ^ slices can begin/end at these spots

When the slice length is 0, the first slice starts & ends at the first of these spots, the second one starts & ends at the second spot, the third one at the third, etc.

There is always one more start/end spot than there are letters.

Comment on lines 3 to 6
What do you expect the result to be if the length of the substrings is zero?
There is no one right answer, but we expect you to output a number of empty strings:
one more than the length of the input string.
While not intuitive to everyone, this upholds the property that the number of substrings is one more than the length of the input string minus the length of the substrings.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe simplify it and make it a little less apologetic (when someone doesn't have the context of this being controversial, it probably seems confusing to explain it in such depth, rather than just telling them the requirement).

Suggested change
What do you expect the result to be if the length of the substrings is zero?
There is no one right answer, but we expect you to output a number of empty strings:
one more than the length of the input string.
While not intuitive to everyone, this upholds the property that the number of substrings is one more than the length of the input string minus the length of the substrings.
Different languages on Exercism have different expectations about what the result should be if the length of the substrings is zero.
For Rust, we expect you to output a number of empty strings, which will one greater than the length of the input string.

Copy link

@filakhtov filakhtov left a comment

Choose a reason for hiding this comment

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

Thanks a lot. 🙇🏻‍♂️ Even though we can agree this is not ideal, at least we have a clear expectations documented now, which is a reasonable trade-off considering we don't want to break all existing solutions.

@senekor senekor merged commit 4a32737 into main Sep 25, 2023
11 checks passed
@senekor senekor deleted the series-instructions-append branch September 25, 2023 12:05
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.

4 participants