|
-
Dec 2nd, 2007, 03:05 AM
#1
Thread Starter
Frenzied Member
algorithm for solving for groups that add up to a number in a 6X5 block
I have a table (looks like this but the numbers might move around)
Code:
A B C D E F
1| 6 100 120 140 100 100
2| 120 100 80 100 120 80
3| 80 120 140 140 180 100
4| 60 120 140 100 220 120
5| 100 120 100 220 120 200
How would go about making somthing in vb6 (or at all) to solve this.
To solve, you must find 6 groups, each group add up to exatly 600.
Each block in the group must tuch (on one side, so from top,buttom,left or right, no diagonals). the number of blocks in a groups may vary.
so example F1, F2, F3, F4, and F5 are a valid group all tuch on a side, and the sum of all of them is 600
same goes for B4, C3, C4, D4, and C5, and so on...
-
Dec 2nd, 2007, 08:24 AM
#2
Fanatic Member
Re: algorithm for solving for groups that add up to a number in a 6X5 block
So you seem to have an arbiterilly sized grid for which any given mapped area must be calculated to 600.
I would create an 2D array to store the grid within and then I might create a user type, object or array of arrays to store pattern shapes (blocks) in. Then each action (timer, user click, whatever) I would loop the collection and sum the values for each array point indicated.
So if my array of arrays looked like this:
$array =
0 = (0 = (x=1, y=2), 1 = (x=1, y=3) ... counter = 0)
...
I would be putting the x and y values into the array and adding the returned value to my counter for that object.
That would allow you to track the shapes. However if you need to find the shapes that amount to 600 you are going to need something more powerful.
Look up mapping algorithms becuase you are after them even if you did not know it.
The simple brute force approach would be to try every possible combination until you got a 600. You could try known shapes as per the first suggestion and offset them on the x and y step by step until you have tried each possibility. You can save time if you have a grasp of rotations and reflections as a mathematical idea.
I hope I have thrown you some useful ideas.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|