Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
.DS_Store
18 changes: 18 additions & 0 deletions 08_recursion_and_dynamic_programming/14_booleanEvaluation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
Given a boolean expression consisting of the symbols 0 (false), 1(true),
& (AND), | (OR), and ^(XOR), and a desired boolean result value 'result',
implement a function to count the number of ways of parenthesizing the expression such
that it evaluates to 'result'

E.g.
countEval('1^0|0|1', false) -> 2
countEval('0&0&0&1^1|0', true) -> 10
*/

'use strict';

function countEval() {
// Your code here
}

module.exports = countEval;
14 changes: 14 additions & 0 deletions 08_recursion_and_dynamic_programming/14_booleanEvaluation.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

const assert = require('chai').assert;
const countEval = require('./14_booleanEvaluation');

describe('recursion and dynamic programming', function() {
describe('boolean evaluation', function() {
it('should return the number of ways of parenthesizing an expression', function() {
const expression = '1^0|0|1';
const result = false;
assert.equal(countEval(expression, result), 2);
})
})
})