#### Hasslehump

##### New member

- Local time
- Today, 21:48

- Joined
- May 16, 2020

- Messages
- 4

My requirement is to return a combination of records that will fit when combined together as a closest match to the desired integer.

I have records that have fixed values in the respective field containing the following values;

2

4

8

12

16

If the desired integer is 75; I would require the returned result as follows;

4 x 16

1 x 12

(remainder 1)

The match must return a value that is equal to or larger than the desired integer.

This must resolve with the fewest multiple of records as possible, i.e. it could not resolve as 18 x 4

To add further complexity to the problem, I need to be able to add weighted favour in bias of using fewer multiples. I would say the acceptable bias would be in favour of having a remainder of 3 over using an additional record to achieve the exact integer.

Example:

If the desired integer is 38; I would require the returned result as follows;

2 x 16

1 x 8

(remainder 2)

Rather than

2 x 16

1 x 4

1 x 2

(exact match)

At present I just have a fixed matrix with all combinations from 1-94. But this is not at all scalable.