StatCounter

Wednesday, December 01, 2004

Interview question #3

I came out with another interview question to find out the candidate's visualizing power:

The object is chessboard--you know it has black and white squares.
  1. How will you visualize the chessboard in terms of mathematical formula?
  2. How will you visualize/depict the same in PHP code?

2 comments:

lawrence krubner said...

What's the mathmatical answer? In PHP code I'd probably deal with the chess board as a 2 dimensional array. Are you looking for something more clever than that? I'm curious.

You could also handle it as a one dimensional array in which, perhaps, the keys of the array are the formal positions on the board:

$chessBoard["r1"] = "r";
$chessBoard["kn1"] = "kn";
$chessBoard["b1"] = "b";
$chessBoard["k1"] = "k";

but then movement isn't as straight forward.

R. Rajesh Jeba Anbiah said...

Thanks lawrence krubner for your comments. Actually, I'll be expecting just two keywords: Matrix and two dimensional array; that's all. I don't expect any brilliant answer:-)