Dart
Dart copied to clipboard
Create Boolean_expression.dart
This program is for the evaluation of the Boolean expression where a string consists of only 0, 1, A, B, C where A = AND B = OR C = XOR The evaluation is done from left to right. The length of string will be odd. It will always be a valid string. This pull request is for Hacktober Fest 2020.
Welcome to Dart community
Describe your change:
- [ ] Add an algorithm?
- [ ] Fix a bug or typo in an existing algorithm?
- [ ] Documentation change?
Checklist:
- [ ] I have read CONTRIBUTING.md.
- [ ] This pull request is all my own work -- I have not plagiarized.
- [ ] I know that pull requests will not be merged if they fail the automated tests.
- [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
- [ ] All new Dart files are placed inside an existing directory.
- [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
- [ ] If this pull request resolves one or more open issues then the commit message contains
Fixes: #{$ISSUE_NO}
.
@Parowicz Sir, I request you to please help me in resolving the failed check.
Tests are failing because
-
evaluateBoolExpr("0A1")
returns'1'
==>false
andtrue
!=true
-
evaluateBoolExpr("1B0")
returns'0'
==>true
orfalse
!=false
-
evaluateBoolExpr("1C0")
returns'0'
==>true
xorfalse
!=false
@Parowicz Sir, regarding the failing of tests, I had already specified in the description that evaluation is done from left to right only. But, you are trying to evaluate it from right to left. Please consider this Sir. Thank you.
Those operations are commutative https://en.wikipedia.org/wiki/Boolean_algebra#Laws
In your code evaluateBoolExpr("1A0")
is different from evaluateBoolExpr("0A1")
.
Evaluation strategy should not invalidate result.