Hacker News new | past | comments | ask | show | jobs | submit login

Don't forget to practice doing math like 36^5 in your head. No pencil or paper allowed!



Well, let's see, 36 is 00100100 in binary. Binomial coefficients are 1 5 10 10 5 1. 2^25 + 5 * 2^22 + 10 * 2^19 + 10 * 2^16 + 5 * 2^13 + 2^10. 10 is 5 * 2, so bit shift those middle two. 5 is binary 0101, so add copies bit shifted by 2. 2^25 + 2^24 + 2^22 + 2^22 + 2^20 + 2^19 + 2^17 + 2^15 + 2^13 + 2^10. Comes out to

  0011 1001 1010 1010 0100 0000 0000
  0x039AA400
Which is a perfectly cromulent numeric response. If the interviewer asks what that is in decimal, they ought to be glad I don't have a pencil, because it would end up in someone's eye on my way out the door.


Me as interviewer: have you heard of the XOR operator?


Yeah, it looks like a plus sign with a circle around it. It's not in the ASCII character set.

Sometimes, programming languages will use the caret character to represent XOR for boolean types and bitwise XOR for integral types, perhaps using two asterisks for exponentiation, or leaving it as a named function call, like Math.Exp or Math.Pow. But you have to be careful there, because sometimes Math.Exp is actually the inverse of the natural log function, rather than exponentiation.

If caret means XOR, then 36 ^ 5 is 0010 0001, or 33.

And that is the point where the interviewer marks me as "do not hire", because they can't stand it when they can't show off how smart they are to the candidate.


If you would need to practice that, the job is not for you.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: