This is my first post in this stack, but I have posted on StackOverflow before. Let me declare that I am a coder in search of an algorithm. This is not homework.
Bart has two bags of kiddies wooden blocks, bag A and bag B.
All the blocks in both bags are random (and potentially different) heights.
Miss Hoover asks Bart to build a tower from bag A's blocks, and a tower from bag B's blocks, such that both towers are exactly the same height.
Bart is allowed to measure the height of each block before building.
All heights are integer values (ref: User24142).
Let's assume I cannot rotate the blocks to use their width, "height" is just used to illustrate a single dimension, an analogous property of the actual object in question.
To solve this for Bart, my first guess would be to combine all blocks in bag A and work out all possible total tower heights, repeat the process for bag B, and then try to find two values in both result sets that match. This is computationally expensive and becomes untenable with large numbers of blocks.
Is this a known problem with a known solution, or do I have no alternative but to grind out the solution from all possible data?