Thread: How The best way to combine all possibilities in array?

  1. #1
    Registered User
    Join Date
    Nov 2008
    Location
    Santa Catarina - Brasil
    Posts
    184

    How The best way to combine all possibilities in array?

    Hi People,

    Scale: 1 Weight: 155
    Scale: 4 Weight: 231
    Scale: 5 Weight: 247
    Scale: 8 Weight: 332
    Scale: 9 Weight: 328
    Scale: 13 Weight: 342


    How The best way to combine all possibilities to form a package of 990 to 1015 (Adding the weight)?

    Example:

    1 + 4 = 155 + 231 = 386
    1 + 5 = 155 + 247 = 402
    1 + 8
    1 + 4 + 5
    1 + 4 + 8
    1 + 4 + 5 + 8
    8 + 9 + 13 = 332 + 328 + 342 = 1002 (THIS)
    13 + 5 + 4

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Are you trying to do this?
    Knapsack problem - Wikipedia
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Nov 2008
    Location
    Santa Catarina - Brasil
    Posts
    184
    That's right, perfect!
    Thank you very much, it helped a lot!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Possibilities? Inquiring
    By phil_illuminati in forum C++ Programming
    Replies: 4
    Last Post: 03-27-2011, 05:52 AM
  2. combine array elements
    By Fredir in forum C++ Programming
    Replies: 23
    Last Post: 11-16-2007, 05:43 PM
  3. Help with AI possibilities
    By Syneris in forum General AI Programming
    Replies: 2
    Last Post: 01-01-2006, 02:52 AM
  4. Numbers combinations(possibilities)
    By snaidis in forum C Programming
    Replies: 16
    Last Post: 11-20-2005, 08:32 AM
  5. N possibilities
    By vasanth in forum C++ Programming
    Replies: 6
    Last Post: 04-08-2002, 09:42 PM

Tags for this Thread