gregbo (gregbo) wrote,

It has occurred to me that what I've been posting about problem solving may not be so clear to all of my readers, so here is an example of something that is hopefully easy to understand yet illustrates the topic well.

Multiply the numbers 95 and 85 only using one-digit multiplications, shifts, and subtractions. (A shift allows one to do multiplications or divisions in one step. For example, 8 is 1 shifted three places to the left (with zeros) in binary (base 2). 10 (base 2) equals 2 (base 10), 100 (base 2) equals 4 (base 10), and so on. Assume you can do a shift in any base.) Do not do it the long way.

The trick is to notice that 95 * 85 equals (90 + 5) * (90 - 5) which is equal to 90 * 90 - 5 * 5. Thus all you need to do is two simple multiplies, a shift of one product by two zeros to the left, and a subtraction to yield the answer 8075.

So, this doesn't seem too difficult, right? Well, if you see that the product has the property of the difference of two squares, no. But you might not see it, which is sort of what I'm getting at with regards to problem solving, interviews, tests, etc.: depending on one's frame of mind one might not see the trick and get stuck. Also, there are times when the question will not be phrased to give an indication that the asker is looking for an elegant or insightful solution, so one's first reaction to the question might be to do it the long way, especially if one is stressed out.

As to what this might have to do with computer science, there are issues in computer architecture and digital design that involve fast computations (and special-purpose hardware to carry out such computations). Someone who's interviewing someone for such a job might ask this type of question looking for an answer that shows an understanding of how to do fast computations.

  • Ciena interview

    I had an onsite interview at Ciena a couple of weeks ago for a Senior Systems Test position. Long story short — I didn't get the job. I think they…

  • ProtonMail test

    I took a test from 7-9am this morning from ProtonMail, a secure email provider based in Geneva, Switzerland, that has an office in SF. The test was…

  • IBM interview

    I had an interview loop yesterday at the IBM Silicon Valley Lab facility with several people from the Cloud Network Services group. Four engineers…

  • Post a new comment


    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 1 comment