0

I have a requirement where i have to find a list of combinations where the sum =180. I have an array of intergers and have to pick up the elements from this array only.

For example : Array = {30,45,60,15,60,30} now i as an output should get - 60,60,30,30 or 45,15,60,30,30 or 45,15,60,60

I am trying various approaches but its failing in one or the other scenario. Please suggest implementation in C#.

Please provide inputs.

Thanks

4
  • 2
    Please provide what you've tried ... (it's a rather trivial question, but I don't feel the need to solve other people homework if they didn't tried anything ... ) Commented Nov 11, 2013 at 11:50
  • 1
    Possibilities are there, You show your try..This is similar to probability.. Commented Nov 11, 2013 at 11:52
  • 1
    ahhh ... the possibilities ... recursion ... loops ... iterations ... brute force ... smart objects ... energy wielding dogs ... if only the OP have tried something ... Commented Nov 11, 2013 at 11:56
  • Sort out array by weight in descending order and use recursively calls to approach to decision. Each call is try to take the next number (stone))) to summarize. Commented Nov 11, 2013 at 11:58

1 Answer 1

1

Sub set problems solutions can be found everywhere on the net or stack overflow:

Try this:

Sum array values with sum equals X

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.