`x` and `!x`, or `a && x` and `a && !x`.
(a: string, b: string)
| 657 | |
| 658 | /** `x` and `!x`, or `a && x` and `a && !x`. */ |
| 659 | function complementary(a: string, b: string): boolean { |
| 660 | if (!a || !b) return false; |
| 661 | const pa = a.split(' && '); |
| 662 | const pb = b.split(' && '); |
| 663 | if (pa.length !== pb.length) return false; |
| 664 | let flips = 0; |
| 665 | for (let i = 0; i < pa.length; i++) { |
| 666 | if (pa[i] === pb[i]) continue; |
| 667 | if (pa[i] === `!${pb[i]}` || pb[i] === `!${pa[i]}`) flips++; |
| 668 | else return false; |
| 669 | } |
| 670 | return flips === 1; |
| 671 | } |
| 672 | |
| 673 | function toPosix(p: string): string { |
| 674 | return p.replace(/\\/g, '/'); |