Follow up to interview question

My first interview question was pretty successful. The one that was closest to my solution was Paul Bartrum (that name sounds familiar for some reason) followed closely by domovoi (though I didn't test his). Both Paul and I had just a single for loop enumerating once over the collection. I used the concept of "period" which probably has some other name but that's the best description I could come up with. Basically, a period in this sense (and in my mind) is how long it takes a single dimension's index to change when the lower indices are enumerated. This is determined by multiplying the upper bounds of dimensions following that dimension. For example, if you had: int[,,] arr[3,2,3] the third dimension's period is 1 because no dimensions follow it. The second dimension's period is 3 and the 1st dimension's period is 6 (2 x 3). Once I conceptualized that, the rest was trivial. Paul was pretty much thinking along the same lines. There were some good solutions but due to time, I can't go through all of them (especially the python one which threw me for a loop hehe).

Now, here's the next interview question. I think this one will be a lot easier and it follows along the same line. Here goes.

Given a multidimensional array, set each value in that array as efficiently as possible. In other words, don't have a series of nested for loops. Let's say that I will just give you an array without any preconceived notion of how that array was constructed. Make sense? Then get to it!