Add an array of values up to a specific value

  • I have a table that has values in it Example

    Record      -     Value

    131
    262
    3124
    4121
    5115
    6103
    779
    815
    930
    1060
    11120
    12113
    1399
    1471

    If I pass in the value of 254 - would want to know record 1,3 and 13 values equal 254 (31+124+99)=254  This may not be the only scenario that would work for the scenario, would like to know all scenarios that work.

    If I pass in the value of 460 would want to know record 1,3,6,6 and 13 (31+124+103+103+99) = 460

    Any help would be appreciated

     

     

  • The killer in this problem is that a value can be used multiple times. Thus if the target value is 60 the following represent solutions:

    60

    30,30

    30,15,15

    15,15,15,15

    Although your table goes in the right direction, this kind of combinatorics will be hard to generate.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply