Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Number Matching

Number Matching

Scheduled Pinned Locked Moved C / C++ / MFC
algorithmshelpcareer
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Humayun Kabir Hemoo
    wrote on last edited by
    #1

    Hi, I'm developing a reconciliation software. I have to find the matching items using some rules. However, some items represent sum of other items but I don't know which are they. So, I need to find, by trial and error, the numbers that represent the another number. List 1 : 10, 300, 50 List 2 : 5, 50,20,25,150,5,30,50,5,20 Here 10 = 5 + 5 300 = 50 + 150 + 25 + 5 + 50 + 20 50 = 20 + 30 There may be hundreds of such number like in List 2 and dozens likes List 1. My job is to find which number make up the numbers in List 1 base only on the numbers. Can any one knows about any algorithm to achieve this task. Thanks

    Md. Humayuon Kabir Hemoo

    R T H 3 Replies Last reply
    0
    • H Humayun Kabir Hemoo

      Hi, I'm developing a reconciliation software. I have to find the matching items using some rules. However, some items represent sum of other items but I don't know which are they. So, I need to find, by trial and error, the numbers that represent the another number. List 1 : 10, 300, 50 List 2 : 5, 50,20,25,150,5,30,50,5,20 Here 10 = 5 + 5 300 = 50 + 150 + 25 + 5 + 50 + 20 50 = 20 + 30 There may be hundreds of such number like in List 2 and dozens likes List 1. My job is to find which number make up the numbers in List 1 base only on the numbers. Can any one knows about any algorithm to achieve this task. Thanks

      Md. Humayuon Kabir Hemoo

      R Offline
      R Offline
      Rozis
      wrote on last edited by
      #2

      What comes in my mind is simply brute force: take a number from list 1 and try every combination in list 2. There are many ways to optimize this because it tries many combinations are surely wrong. for example: sort your list 2 and stop trying combinations if the sum gets bigger then the number from list 1. If your list 2 numbers have more characteristics (they are not completely random) maybe you can find rules so more needless combinations can be avoided. I hope this gives you a good start... Rozis

      1 Reply Last reply
      0
      • H Humayun Kabir Hemoo

        Hi, I'm developing a reconciliation software. I have to find the matching items using some rules. However, some items represent sum of other items but I don't know which are they. So, I need to find, by trial and error, the numbers that represent the another number. List 1 : 10, 300, 50 List 2 : 5, 50,20,25,150,5,30,50,5,20 Here 10 = 5 + 5 300 = 50 + 150 + 25 + 5 + 50 + 20 50 = 20 + 30 There may be hundreds of such number like in List 2 and dozens likes List 1. My job is to find which number make up the numbers in List 1 base only on the numbers. Can any one knows about any algorithm to achieve this task. Thanks

        Md. Humayuon Kabir Hemoo

        T Offline
        T Offline
        T2102
        wrote on last edited by
        #3

        Try sorting all #s first. Then for each element in list 1, search for a match in list 2. Upon finding it, remote the item from both lists. So if there are 3 50's in list 1 and 8 50's in list 2, you should be left with 0 in list 1 and 5 in list 2. Then with your new list 1 and 2, try to reconcile the largest items first. You should do sweeps assuming that an item in list is the sum of two #s. Then after trying this for all items, then look at sums of three #s... You will loop over the combinations using (d-1) dimensional arrays where d is the # of items in the sum. Note that this does not guarantee that it will find the right solution.... The correct algorithm is more complex. You could mark each # as being utilized for sum of k #s in the other list. Then you have to search multiple cases until you find your most explanatory match... Depending on what other information you have, there may be an even better method.

        1 Reply Last reply
        0
        • H Humayun Kabir Hemoo

          Hi, I'm developing a reconciliation software. I have to find the matching items using some rules. However, some items represent sum of other items but I don't know which are they. So, I need to find, by trial and error, the numbers that represent the another number. List 1 : 10, 300, 50 List 2 : 5, 50,20,25,150,5,30,50,5,20 Here 10 = 5 + 5 300 = 50 + 150 + 25 + 5 + 50 + 20 50 = 20 + 30 There may be hundreds of such number like in List 2 and dozens likes List 1. My job is to find which number make up the numbers in List 1 base only on the numbers. Can any one knows about any algorithm to achieve this task. Thanks

          Md. Humayuon Kabir Hemoo

          H Offline
          H Offline
          Humayun Kabir Hemoo
          wrote on last edited by
          #4

          Both of replies are very helpful. I think I have got the point. Thank you very very much.

          Md. Humayuon Kabir Hemoo

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups