Fog Creek Software
Discussion Board




function definition

Consider a set of input data: AQB544, AQD967, AQF154, AQP104, AQP544, .. (complete input data set at http://users.pandora.be/stefaan.meeuws/q.htm)

I want to run this data against a function, and the function should return "AQZ584". The function may re-order the input to produce the result.

So the function should structure the input data. This is the keystone of the problem, for which I am seeking food for thought.

Stefaan


- sidebar -
This reminds me of a similar conundrum: take a set of numbers, and add the average (of the numbers in the set), to the set. The sum of the set increases, but what is the new average?

[Take 2, 3, 5: sum is 10, avg. is 2; add 2 so you get 2, 3, 5, 2: sum is 12, avg. is 2 again, so add 2 again. Now the set is 2, 3, 5, 2, 2: sum is 14, avg. is 2 again! Etc.]
- end sidebar -

Stefaan R. M. Meeuws
Sunday, September 26, 2004

The problem sounds interesting but I have no idea what the function is trying to do, other than "return AQZ584" which can be done with a print statement without even looking at the input.

Ham Fisted
Thursday, September 30, 2004

I don't understand your averages conundrum.  I think your numbers are incorrect.

2, 3, 5  Avg: 3.33333
2, 3, 5, 3.33333  Avg: 3.33333
2, 3, 5, 3.33333, 3.333333 Avg: 3.33333
etc.

The whole point of an average is that you can add the average of those numbers in a million times and the average stays the same.  Now you might be talking about the median or the mode, I don't know about that.  But the average stays the same.

nathan
Wednesday, October 06, 2004

It would be curious to encounter interviewers like this one, with "function definition".

But there is an advantage in a face-to-face interview: you can ask questions to get an understanding of what that person actually means. This helps. Even idiots may turn out to have a point.

Vlad Patryshev
Thursday, October 07, 2004

*  Recent Topics

*  Fog Creek Home