Skip to content

Conversation

@EricccTaiwan
Copy link
Contributor

@EricccTaiwan EricccTaiwan commented Mar 12, 2025

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

$ ./ttt
 1 |             
 2 |             
 3 |             
 4 |             
---+-------------
      A  B  C  D
X> a5
Invalid operation: index exceeds board size
X> aa
Invalid operation: index exceeds board size
X> aa5
Invalid operation: index exceeds board size
X> d5
Invalid operation: index exceeds board size
X> dd
Invalid operation: index exceeds board size
X> ^C
$

After

$ ./ttt
 1 |             
 2 |             
 3 |             
 4 |             
---+-------------
      A  B  C  D
X> a5
Invalid operation: index exceeds board size
X> aa
Invalid operation: multiple column alphabets detected
X> aa5
Invalid operation: multiple column alphabets detected
X> d5
Invalid operation: index exceeds board size
X> dd
Invalid operation: multiple column alphabets detected
X> ^C
$

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>
@jserv jserv merged commit 3007f7d into jserv:main Mar 12, 2025
2 checks passed
@jserv
Copy link
Owner

jserv commented Mar 12, 2025

Thank @EricccTaiwan for contributing!

@EricccTaiwan EricccTaiwan deleted the muliple-col branch March 12, 2025 15:32
for (int i = 0; i < (r - 1); i++) {
if (isalpha(line[i]) && parseX) {
// input has multiple column alphabets
if (i > 0 && isalpha(line[i])) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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!

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