phillip1882 Posted August 30, 2008 Author Report Posted August 30, 2008 (1+2+3+4-5-6-7-8 (5+6+9-7-8-10 (7+11-8-12 (12-13 8,13 8,10 8,12) (7+12-8-11 8,11 7,8 7,12) (11-13 7,13 7,10 7,11) ) (5-6 (7-8 8,6 10,6 7,6) (7-8 8,9 10,9 7,9) (7-8 8,5 10,5 7,5) ) (5+11-6-12 (12-13 6,13 6,9 6,12) (5+12-6-11 6,11 5,6 5,12) (11-13 5,13 5,9 5,11) ) ) (1+2+5+9+10-3-4-6-11-12 (3-4 (7-8 4,8 4,6 4,7) (11-12 12,13 11,12 11,13) (7-8 3,8 3,6 3,7) ) (1+2+9-3-4-11 (5+3-4-10 10,11 5,4 5,3) (9+11-10-12 10,12 err 9,11) (6+1-2-12 9,12 6,2 6,1) ) (1-2 (7-8 2,8 2,5 2,7) (9-10 10,13 9,10 9,13) (7-8 1,8 1,5 1,7) ) ) (1+2+9-3-4-10 (3+11-4-12 (12-13 4,13 4,10 4,12) (3+12-4-11 4,11 3,4 3,12) (11-13 3,13 3,10 3,11) ) (1-2 (3-4 2,4 2,10 2,3) (3-4 9,4 9,10 9,3) (3-4 1,4 1,10 1,3) ) (1+11-2-12 (12-13 2,13 2,9 2,12) (1+12-2-11 2,11 1,2 1,12) (11-13 1,13 1,9 1,11) ) ) ) i'm not sure this is correct, in particular the even, even case concerns me, but i believe i have it right. modest 1 Quote
CraigD Posted August 30, 2008 Report Posted August 30, 2008 …i'm not sure this is correct, in particular the even, even case concerns me, but i believe i have it right.It works. :) Quote
phillip1882 Posted September 5, 2008 Author Report Posted September 5, 2008 its been a fairly busy week for me. i just now finished scetching out the general algorithm for one heavy/light on paper, i just need to transfer it to actual code.here's basically my code. int left[numobjects/3], right[numobjects/3]; int unknown[numobjects], heavy[numobjects/3], light[numobjects/3], normal[numobjects]; all objects start off in the unknown array. void splitsimple(int numobjects, int numwiegh){ divide numobjects by 3. place that number of unknowns into the left and right array. "weigh" left agianst right. if equal, place all left and all right into normal array, and call splitsimple agian on remaining number of unknowns. if not equal, place the light side into the light array, the heavy side into the heavy array, and the remaining unknowns into the normal array. call splitcomplex. } void splitcomplex(int numheavy, numlight, int numwiegh){ if numheavy equals numlight{ place 1/2 of the heavy and 1/4 the light on the left. place 1/4 heavy, 1/4 light, and remaining normal on right. "weigh" them. if equal, then 1/4 heavy and 1/2 light remains. if the left side is heavy, then 1/2 heavy and 1/4 light remians. if the right side is heavy, then 1/4 heavy and 1/4 light remains. call splitcomplex with proper heavy light arrangement. } if numheavy doesnt equal numlight{ split the the one with more in half and wiegh. wether or not they are equal, you'll know which group has the specail object, and can call something fairly similar to splitsimple. } } of cousre i need some terminatiting conditions and such, but jsut a rough outline for now. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.