1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Findings element that sum up to a value

Discussion in 'C#' started by tin2mon, Sep 6, 2010.

  1. #1
    Hi
    I have a tricky question that cannot find solved by searchig.
    I have an array (ASP) like this
    Array(ID, Coeff)
    SEMrush
    a(1,2)
    a(2,2)
    a(3,1)
    a(4,3)
    a(5,1)
    a(6,1)

    I want to find all the possible combinations of ID where summing the respective Coeff give a sum of Coeff that is a specific value.
    I.E. I wand all the IDs where summing their Coeff the result is 3: in my array above several combinations of Coeff sum up to 3:
    id=1 and id=3
    id=2 and id=3
    id=3 and id=5 and id=6
    ... other valid ...
    No limit on how many IDs I have to use, maybe a single one or all the array.

    Anyone able to help me?
    Thanks
     
    tin2mon, Sep 6, 2010 IP
    SEMrush