A Little Code Puzzle
Here's a fun puzzle for you to try in the language of your choice. We have two boolean contrarians, A and B. (A contrarian might be too-simply defined as someone who opposes the conventional wisdom on a topic.) Since they're contrarians, we expect/want them to not agree on a topic. If they do, we're in trouble.
What's the shortest function that will return true if A is true AND B is true OR A is false AND B is false?


def AreBothTrueOrBothFalse a, b
!(a ^ b)
end
function e(a,b){return a==b}
alert(e(true, true)); // alerts true
alert(e(true, false)); // alerts false
alert(e(false, false)); // alerts true
alert(e(false, true)); // alerts false
return ( A == B);
Since they are boolean, they can each only be true or false.
I like little exercises like this. We all get a tiny bit smarter.