Dart icon indicating copy to clipboard operation
Dart copied to clipboard

Create Boolean_expression.dart

Open RimjhimGupta opened this issue 4 years ago • 4 comments

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}.

RimjhimGupta avatar Oct 21 '20 14:10 RimjhimGupta

@Parowicz Sir, I request you to please help me in resolving the failed check.

RimjhimGupta avatar Oct 22 '20 17:10 RimjhimGupta

Tests are failing because

  1. evaluateBoolExpr("0A1") returns '1' ==> false and true != true
  2. evaluateBoolExpr("1B0") returns '0' ==> true or false != false
  3. evaluateBoolExpr("1C0") returns '0' ==> true xor false != false

Parowicz avatar Oct 22 '20 18:10 Parowicz

@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.

RimjhimGupta avatar Oct 23 '20 14:10 RimjhimGupta

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.

Parowicz avatar Oct 23 '20 14:10 Parowicz