Microsoft Interview Question Software Engineer / Developers




Comment hidden because of low score. Click to expand.
2
of 2 vote

888
88
8
8
8
----------
1000

- Anonymous on October 16, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Guys this is not a puzzle,
they are asking you to sort out an algo for the problem
Finding the result is not the point..

- erm on October 18, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

yes u r right ern, this is a typical subset sum problem ...
scan the the values ...and store them...
after scanning first 2 8's list should be ..16,88
after scanning first 3 8's list should be ...24,96,888
we can find the soln if we proceed in this way...

- Anonymous on October 22, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

888
 88
  8
  8
  8
----------
1000

- Anonymous on October 16, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

with no order of operation:
8+8*8*8+8-8-8-8-8
8+8*8*8-8+8-8-8-8
8+8*8*8*8/8-8-8-8
8+8*8+8-8*8-8-8-8
8+8*8-8+8*8-8-8-8
8+8*8*8/8*8-8-8-8
8+8+8-8*8*8-8-8-8
8+8-8+8*8*8-8-8-8
8-8+8+8*8*8-8-8-8
8*8/8+8*8*8-8-8-8
8/8*8+8*8*8-8-8-8
8+8*8/8*8*8-8-8-8
8+8/8*8*8*8-8-8-8
8+8*8*8-8-8+8-8-8
8+8*8*8-8*8/8-8-8
8+8*8*8-8/8*8-8-8
8+8*8*8-8-8-8+8-8
8+8*8*8-8-8*8/8-8
8+8*8*8-8-8/8*8-8
8+8*8*8-8-8-8-8+8
8+8*8*8-8-8-8*8/8
8+8*8*8-8-8-8/8*8

- Restless on October 16, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

with no order of operation:
8+8*8*8+8-8-8-8-8
8+8*8*8-8+8-8-8-8
8+8*8*8*8/8-8-8-8
8+8*8+8-8*8-8-8-8
8+8*8-8+8*8-8-8-8
8+8*8*8/8*8-8-8-8
8+8+8-8*8*8-8-8-8
8+8-8+8*8*8-8-8-8
8-8+8+8*8*8-8-8-8
8*8/8+8*8*8-8-8-8
8/8*8+8*8*8-8-8-8
8+8*8/8*8*8-8-8-8
8+8/8*8*8*8-8-8-8
8+8*8*8-8-8+8-8-8
8+8*8*8-8*8/8-8-8
8+8*8*8-8/8*8-8-8
8+8*8*8-8-8-8+8-8
8+8*8*8-8-8*8/8-8
8+8*8*8-8-8/8*8-8
8+8*8*8-8-8-8-8+8
8+8*8*8-8-8-8*8/8
8+8*8*8-8-8-8/8*8

- Restless on October 16, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

8 8 8 + 8 8 + 8 + 8 + 8 = 1000

- gulusworld1989 on October 16, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

888 + 88 + 8 + 8 + 8 = 1000, but doesn't it look to simple?

- airfang613 on October 16, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

888 + 88 + 8 + 8 + 8 = 1000, but doesn't it look to simple?

- airfang613 on October 16, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

can't believe MS asking such crap questions

- DP on October 17, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I cant believe they asked this question in an interview. It is an NP complete problem, isn't it?

- Pranz on October 27, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Plus88888888
{
class Program
{
static void PrintArray(int[] arr, int index)
{
Console.Write("{0} ", arr[0]);
for (int i = 1; i < index; i++)
{
Console.Write(" + {0}", arr[i]);
}
Console.WriteLine();
}
static int CalculateValue(int n)
{
int result = 0;
for (int i = 0; i < n; i++)
{
result = (result * 10) + 8;
}
return result;
}
static void CalculateEightEights(int numEightLeft, int[] arr, int index, int currentResult)
{
int tmp = 0;
if (numEightLeft == 0)
{
if (currentResult == 1000)
{
PrintArray(arr, index);
return;
}
}
for (int i = 1; i <= numEightLeft; i++)
{
tmp = CalculateValue(i);
arr[index] = tmp;
CalculateEightEights(numEightLeft - i, arr, index+1, currentResult+tmp);
}
}
static void Main(string[] args)
{
int[] arr = new int[8];
CalculateEightEights(8, arr, 0, 0);
}
}
}

- Anonymous on November 11, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Anonymous, cud u plz explain the code? I dont think this code will work. It will sum up eight 8s, four 88s, two 888s,... so on.
Am I missing something obvious?

- ms on November 19, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I am modifying Anonymous code as follows:

int[] arr = new int[8];
   int index = 0;

   void calculateEightEights(int target, int numEightLeft)
   {
       int prevResult = 0, curResult = 0;
       for (int i=1; i<=numEightLeft; i++)
       {
           curResult = (curResult * 10) + 8;
           if (curResult > target)
           {
               arr[index++] = prevResult;
               calculateEightEights(target - prevResult, numEightLeft - i + 1);
           }
           prevResult = curResult;
        }
    }

    To invoke the method: calculateEightEights(1000,8);

For simplicity I have taken global variables. We can avoid using them as found in anonymous code.
Hope this would help. Let me know the bugs,if any.

Thanks.

- ms on November 19, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

add eight 8s and add 36 '++'

- thecodemaster on November 18, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

It wont work.. Required result is 1000.. not 100.

- sp on November 19, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

888+88+8+8+8...so simple yaar..

- prasathsarath on December 27, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think first is to recognize that to get a zero in the one's place you need 5 8s, i.e., 5 terms to be added. The next is that to get to 1000 you're going to need a big number (888). The rest is even simpler.

- Frank on January 27, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

8+8+8+88+888=1000

- abhishek on February 20, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

{[(8+8)*8]-[(8+8)/8]}*8-8=1000,so i m genious

- Raj Rana on March 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

great

- maci lewis on December 12, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

( ( ((8+8)*8)- (8+8+8)/8) ) *8)

- sudarson on October 16, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

You can only use '+' operator.
I think its pretty simple.
888+ 88+ 8 + 8 + 8 = 1000

- ManishSindhi on October 16, 2010 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book walking you through getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More