Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. /** @returns {number[]} */
  2. const parseImplicantString = (str) => {
  3. if (str.indexOf('-') > -1) {
  4. return [
  5. ...parseImplicantString(str.replace('-', 0)),
  6. ...parseImplicantString(str.replace('-', 1)),
  7. ];
  8. } else {
  9. return [parseInt(str, 2)];
  10. }
  11. };
  12.  
  13. console.log(parseImplicantString('-100')); // => [4, 12]
  14. console.log(parseImplicantString('10--')); // => [8, 9, 10, 11]
  15. console.log(parseImplicantString('1--0')); // => [8, 10, 12, 14]
  16. console.log(parseImplicantString('1-1-')); // => [10, 11, 14, 15]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement