Derek wrote:

>

> i need help trying to solve the following problem. the algorithm to use

> would be much appreciated. having it in java would be ideal. the input is any

> number (1..N) factor types. each factor type having any number (1..N) factor

> values.

> the output are strings as shown below (order is important). i am guessing

> that recursion is involved in this. any help would be appreciated. please reply

> to newsgroup and email (E-Mail Removed) (remove NOSPAM).

> thank you. derek

>

> INPUT (any number of types and values per type):

>

> Factor Type Factor Values Factor Unit

> ----------- ------------------------------------- ------------

> Tissue kidney liver

> Time 0 30 60 min

> Dose 0.001 0.01 0.1 1 ug

>

> OUTPUT:

>

> kidney 0min 0.001ug

> kidney 0min 0.01ug
....

> liver 60min 0.1ug

> liver 60min 1ug
This can be broken down into three problems:

1. Reading the factor types, factor values, and units.

2. Representing the inputs in memory.

3. Generating the output combinations.

I suggest solving the second problem first.

For the first problem, you need to include details of what format the

input is in, how you know how many factors there are, how you know how

many factor values each has, etc. There are different ways to do this.

A common way is to use a special input (possibly no characters) to

signify the end of a list. I see that in your example the first factor

has no unit. You need to be able to handle that.

The third problem, generating the output, can use recursion. Start with

the first factor, which varies the least, then, for each value, generate

the outputs involving all other factors. The trick with using recursion

is to define the operation that the recursive function does.

Writing the code to do this is Derek's job.

Thad