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

Incorrect Example Code - C++ 240-0C1 3.7 Balanced Symbols #632

Open
davis-lx opened this issue Jan 15, 2025 · 0 comments
Open

Incorrect Example Code - C++ 240-0C1 3.7 Balanced Symbols #632

davis-lx opened this issue Jan 15, 2025 · 0 comments
Assignees

Comments

@davis-lx
Copy link

In Oakton CSC-240-0C1 section 3.7 https://runestone.academy/ns/books/published/CSC-240-0C1-CPlusPlusDS-OaktonCollege-Spring2025/LinearBasic/BalancedSymbolsGeneralCase.html the example code in C++ doesn't work as intended because it doesn't check the index of the open symbol against the index of the closed symbol in matches(), only that there is an opening symbol to pair with the closing symbol. The Python implementation does check index, and so doesn't suffer this bug. This can be confirmed as a C++ only bug by testing "( [ ) ]" in each language; C++ sees it as a pass, because it isn't checking parentheses versus brackets, whereas Python fails it. Images attached with only my test line added to each language - code is otherwise unaltered from what is presented as the example.
Screenshot 2025-01-15 121227
Screenshot 2025-01-15 121243

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

2 participants