[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sheflug] Re: Programming Question



On Fri, 2003-07-11 at 20:42, Michael J. FORD(SCI) wrote:
> Here is my quandary I have a number (x) which can be calculated from a
> numerical array (1, 2, 3, 4, 5),

Hmm, this smells rather homework-ey. Are you a Compsci undergrad by any
chance?

This is a fairly standard problem, which I guess is why you're looking
for an algae-rhythm book. SICP - Structure and Interpretation of
Computer Programs. This book is freely available online, but it's dead
tree format is much better.

One thing I would suggest: if your only functions are + and *, and your
array is guaranteed to be a subset of positive integers, then numbers
only grow: i.e., f(a, b) < x, where X is the number you're given and a
and b could be the result of any other number of functions. If your
numbers (well, x, basically) is fairly small, then you may find that
getting an answer by working backwards to the set of numbers which could
compose the answer.

You can also 'generate' answers, since members of your array (assuming
that is the array you've been given) are products of others (e.g., 1+3 =
4, so any permutation using '4' could have (1+3) mechanically
substituted in permutation).

Tra-la,

Alex.


___________________________________________________________________

Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html

  GNU the choice of a complete generation.