Results 1 to 4 of 4
Thread: Logic to generate a pattern
- 11-07-2008, 10:19 AM #1Member
- Join Date
- Nov 2008
- Rep Power
Logic to generate a pattern
The requirement is something like this.......
Sum = 7
Availability Matrix = [5, 4, 6, 1]
Required: I need all set of possible unique combinations that sums to 7.
Few example combinations: [5, 2, 0, 0], [4, 3, 0, 0], [3, 4, 0, 0]
I also have a few questions...
? Can we tell the number of unique number of solutions that can be formed well in advance.
? There are many solutions to this problem which one would be the good in terms of performance imagine when the availabilty matrix is huge
Early help would be appreciated.
- 11-07-2008, 03:33 PM #2
Don't understand the problem statement.
If you are given a list with the 4 numbers [5, 4, 6, 1]
how do you get [5, 2, 0, 0],
There is no 2 in the given list.
How many of the numbers in the list can be used?
Can numbers outside of the list be used?
- 11-07-2008, 05:47 PM #3
yeah... I'd have to agree with Norm... I'm not understanding. From the description you posted, it would appear that you can only pick the numbers from the availability matrix. If that is the case, what I would is:
- create a copy of the availability matrix (lets call it "prime" matrix)
- with two for loops, add every array element in the availability matrix with every array element in the prime matrix
- check every addition for an equivalency to 7
- when this condition is met, print out the elements of each array
Does this help?
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 11-23-2008, 03:40 AM #4
See Sedgewick, great discussion in very readable work that brings great clarity to when and where to use what algorithms to huge availability.
In general, the number of nodes vis-a-vis the raw edge count defines the general approach.Introduction to Programming Using Java.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
- By tsaswathy in forum Web FrameworksReplies: 0Last Post: 09-27-2008, 01:13 PM
- By jermaindefoe in forum New To JavaReplies: 4Last Post: 03-11-2008, 01:22 AM
- By Heather in forum Web FrameworksReplies: 2Last Post: 07-03-2007, 10:47 PM