Microsoft Interview Question for Software Engineer in Tests






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

sample python code, language doesn't matter...

def hint(i,j,sudo_map) :
  ret = {}
  for p in range(1,10) :
    ret[p] = 1
  for y in range(9) :
    tmp = sudo_map[i][y]
    if tmp :
      ret[tmp] = 0
  for x in range(9) :
    tmp = sudo_map[x][j]
    if tmp :
      ret[tmp] = 0
  xc = int(i/3)
  yc = int(j/3)
  for x in range(xc*3,xc*3+3) :
    for y in range(yc*3,yc*3+3) :
      tmp = sudo_map[x][y]
      if tmp :
        ret[tmp] = 0
  return ret

- Anonymous February 01, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

A lil more python-like. Wot say?

from itertools import product
def suggest(board, i, j):
	gridX, gridY = (int(i / 3) * 3, int(j / 3) * 3)
	suggestions = set(range(1, 10)) - set(board[i]) - set([board[x][j] for x in range(0, 9)])
	suggestions -= set([board[gridX + x][gridY + y] for (x, y) in product(range(0,3), range(0, 3))])
	return list(suggestions)

- Anonymous March 26, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

nice code.
In short, what he is trying to do is:

1. Check the entire ith row and jth column and eliminate the possibilities of a number if it appears in these.
2. Repeat the same for the 3*3 square that (i,j) is part of nice.

Thanks.

- neo1234 February 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Nice Explanation

- Anonymous March 04, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Not all Sudoku is 9*9 large. Some easy ones are 2*3 and some difficult ones are 4*4.
Use two extra args to fit into more general cases.
(C# code)

public List<int> SudokuHint(int[,] board, Point p, int row, int col)

- Sonia June 16, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Oh, by 2*3 and 4*4, I mean the size of a unit.

- Sonia June 16, 2010 | Flag


Add a Comment
Name:

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

Books

is a comprehensive book on 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