Programming Test QR Team Developed Suite Analytical Models

Programming Test QR Team Developed Suite Analytical Models

QR team has developed a suite of analytical models that take 1-n variables as input. Say alpha (a), beta (b), gamma (g), delta (d), rho (‘r). All are double values.


  • QR_model_2(double a, double b)
  • QR_model_3(double a, double b, double c)
  • QR_model_4(double a, double b, double c, double d) … etc…

In order to run a particular model through a series of regressions, we are supplied with a test vector of values for each of the input parameters.

  • alpha = 1.1 1.2 1.3
  • beta = 2.1, 2.2, 2.3, 2.4, 2.5
  • gamma = 3.1, 3.2, 3.3
  • delta = 0.1, 0.2
  • rho = 5, 6, 7, 8, 9

Test vectors have the same cardinality as the model under test. Example: when testing QR_model_2, the test vector will comprise 2 items (alpha and beta), when testing QR_model_4, 4 test vectors will be provided.

We need a helper function that can take these vectors and create inputs that can be passed into the function such that the function is tested with each of the variations of the inputs. For example, given the above i.e a 5 argument model, the output of the helper function would be:
1.1, 2.1, 3.1, 0.1, 5
1.1, 2.1, 3.1, 0.2, 5 … etc …

Assume that you can be supplied the input arguments in a data structure of your choice. The results need to be some sort of data structure that can be used to extract the parameters for each run of QR_model_N. You can use Java, Python or C++ to implement your solution. Please include modest build instructions and ideally the results of a test run such as a simple main program.

This assignment typically takes 1.5 hours

Answer: Above problem looks very complex when you read first time but if you read four five times I believe you will understand what to do. Below is java class solution of above problem:

I have used Consumer interface from Java 8 which accept only parameter which list of double array value as below with main logic of iterating list which has double array inside it:


  • Now write main java program which will use this consumer where we could pass values dynamically:

Note: In above program you could add or delete as many as double array value you want and as its asked in question. I passed six double array values to consumer and below is output:

  • Output:


Leave a Reply

Your email address will not be published. Required fields are marked *