14 ms·
A boolean value interview question
- RodgerTheGreat 14y agoThe solutions return a ^ b ? c : a return a == b ? a : c Are expressing exactly the same idea- When A and B are identical, they will xor to 0, and otherwise something nonzero. Thus, xor can be thought of in general as a "!=" operator, provided booleans work like you'd expect in C.
- sonic0002 14y agoThank you for your remind. We have corrected the error. Yes, you are right, these two solutions have the same logic.
- ajuc 14y ago(defn at_least_2 [a b c] (>= (count (filter true? [a b c])) 2))