Skip to content

Instantly share code, notes, and snippets.

@stanleykerr
Created September 10, 2018 17:19
Show Gist options
  • Select an option

  • Save stanleykerr/8cf15d95f6dee3ac6f27f8ce6d789fa3 to your computer and use it in GitHub Desktop.

Select an option

Save stanleykerr/8cf15d95f6dee3ac6f27f8ce6d789fa3 to your computer and use it in GitHub Desktop.
var xor = (a, b) => Boolean(a ^ b);
var one = (a, b) => [a && b, xor(a, b), a || b, !(a && !b)];
var two = (a, b, c) => [!((a && b) && (b || c)), xor(a && b, !(b || c))];
var thr = (a, b, c) => [xor(a, !b), !(xor(a, !b) || c), !c && !(xor(a, !b) || c)];
console.log('1.1', one(false, false));
console.log('1.2', one(false, true));
console.log('1.3', one(true, false));
console.log('1.4', one(true, true));
console.log('2.1', two(false, false, false));
console.log('2.2', two(false, false, true));
console.log('2.3', two(false, true, false));
console.log('2.4', two(false, true, true));
console.log('2.5', two(true, false, false));
console.log('2.6', two(true, false, true));
console.log('2.7', two(true, true, false));
console.log('2.8', two(true, true, true));
console.log('3.1', thr(false, false, false));
console.log('3.2', thr(false, false, true));
console.log('3.3', thr(false, true, false));
console.log('3.4', thr(false, true, true));
console.log('3.5', thr(true, false, false));
console.log('3.6', thr(true, false, true));
console.log('3.7', thr(true, true, false));
console.log('3.8', thr(true, true, true));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment