3 ms·
What is a single inline math statement?
by heavenlyblue 6y ago
What is a single inline math statement?
- addaon 6y ago!!(n & (n >> 1)), I assume.
- joezydeco 6y agoBonus points for the boolean sanitation! Now let me tell you about the candidate that wanted to turn the integer into a character string and then search the string for “11”...
- heavenlyblue 6y agoThe solution gives you an answer if there is “at least two”, not two exactly? However I understand that may be part of the discussion afterwards.
- joezydeco 6y agoLike I mentioned above, most of the time it never got that far. Candidates were messing with string handling and converting base-10 integers into binary (not understanding that the machine already had the integer represented in binary)
- Jach 6y agoHeh, I'd accept it. In screening I used to ask them to implement an isOdd() function for an unsigned int, and after they did it (never had someone fail) see if they could come up with alternate ways. Mainly to see if they're aware of bitwise operators, though it's nice to see they can write loops too. It wasn't a fatal flaw if they weren't (it would be if they couldn't solve it in any way), but knowing is better than not knowing. Anyway one person who didn't know nevertheless amused me by doing a conversion to string and checking the last digit. After years of asking the same questions to intern candidates and to senior+ candidates, interns did consistently better. There are a lot of "experienced" but not very skilled people out there. They exist already inside ompanies too (Principle level checking in hundreds of lines of code with many classes and tests, purportedly to add logging support to something, but the code was ultimately a NOP as it did nothing) but even if it's impossible to put out the tire fire it's best not to contribute to it.