Reject multiple column letters in get_input#40
Merged
jserv merged 1 commit intojserv:mainfrom Mar 12, 2025
Merged
Conversation
This update adds validation to reject inputs with multiple column letters, such as "aa", which were previously treated as out of bounds instead of being explicitly rejected. Additionally, a comment was updated for clarity, changing "row number" to "row numbers" for consistency. Co-authored-by: charliechiou <charlie910417@gmail.com>
Owner
|
Thank @EricccTaiwan for contributing! |
visitorckw
reviewed
Mar 20, 2025
| for (int i = 0; i < (r - 1); i++) { | ||
| if (isalpha(line[i]) && parseX) { | ||
| // input has multiple column alphabets | ||
| if (i > 0 && isalpha(line[i])) { |
Collaborator
There was a problem hiding this comment.
I'm quite late to respond. But the isalpha(line[i]) check seems to be checked twice in the same path, so it looks like a redundant condition to me?
Contributor
Author
There was a problem hiding this comment.
I'm quite late to respond. But the
isalpha(line[i])check seems to be checked twice in the same path, so it looks like a redundant condition to me?
Inputs like aa previously showed "index exceeds board size," which wasn’t accurate since the issue was multiple column letters. Also, isalpha(line[i]) is checked twice, which might be redundant, there could be a better way to handle this. I'll look into it!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This update adds validation to reject inputs with multiple column letters, such as "aa", which were previously treated as out of bounds instead of being explicitly rejected.
Additionally, a comment was updated for clarity, changing "row number" to "row numbers" for consistency. #38
Before
After