Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** @returns {number[]} */
- const parseImplicantString = (str) => {
- if (str.indexOf('-') > -1) {
- return [
- ...parseImplicantString(str.replace('-', 0)),
- ...parseImplicantString(str.replace('-', 1)),
- ];
- } else {
- return [parseInt(str, 2)];
- }
- };
- console.log(parseImplicantString('-100')); // => [4, 12]
- console.log(parseImplicantString('10--')); // => [8, 9, 10, 11]
- console.log(parseImplicantString('1--0')); // => [8, 10, 12, 14]
- console.log(parseImplicantString('1-1-')); // => [10, 11, 14, 15]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement