Results 41 to 57 of 57
Thread: Sorting 10 numbers
 02152009, 12:29 AM #41
End of BruteForce.java?
i've finished bruteforce.java. it can go up more than 20# now. I've also added a checker, so if difference of groups is == 0, then break out of loop. First I ran it on 20C10. w/o the checker, its 23sec. w/ the checker, its 11secs. So then i calculated that it checks about 78 combos per milisec on a 1ghz cpu (w/o checker). that's 8000 combo per sec. That means... for 100C50...
Java Code:100C50 [B]combos: 100891344545564193334812497256[/B] (it takes:) sec: 12611418068195524166851562 hours: 3503171685609867824125 days: 145965486900411159338 week: 20852212414344451334 month: 5213053103586112833 year: 434421091965509402 decade: 43442109196550940 cent: 4344210919655094
Last edited by angryboy; 02152009 at 04:33 AM.
USE CODE TAGS> [CODE]...[/CODE]
Get NotePad++ (free)
 02162009, 05:37 PM #42Member
 Join Date
 Jan 2009
 Posts
 40
 Rep Power
 0
hmmm sounds like this forum could be around for a couple of years before we actually figure out an answer to that 100C50 hehe
 02162009, 05:43 PM #43
couple of years? doesn't this mean centuries?
cent: 4344210919655094
Exactly what does the numberCnumber mean?
how could it take that long?Last edited by MK12; 02162009 at 05:45 PM.
Tell me if you want a cool Java logo avatar like mine and I'll make you one.
 02162009, 05:45 PM #44Member
 Join Date
 Jan 2009
 Posts
 40
 Rep Power
 0
sorry, sarcasm is hard to understand on the forums but i'm sure angryboy understood what i meant... a couple of years was intended to be a HAHA, good luck...
 02162009, 05:47 PM #45
Oh ok. but what does the 100C50 mean?
Tell me if you want a cool Java logo avatar like mine and I'll make you one.
 02162009, 06:49 PM #46Member
 Join Date
 Jan 2008
 Posts
 31
 Rep Power
 0
take this reply, would it best to get the difference between the two highest numbers then divide it up to
group 1 500, 10, 10, 10, 20.
group 2 400, 30, 30, 30, 20.
group 1 sum 550
group 2 sum 510 // the best we can get here
here we have a difference of 40, were as the difference in the quote is 100.
so you have to get the difference of the two highest numbers then try and get either a number that matches that difference or closest one and ............. it is getting close to 7am in New Zealand I must go to work now
 02162009, 08:20 PM #47
numCnum means nCk. say you have 10 numbers and want to divide into two even groups. thats 5 num per group. 10C5 would get you 252 possible combinations. 100C50 would be 100891344545564193334812497256 possible combinations. And that only applys only to bruteforce.java because it checks for all the possible combinations to find the smallest difference.
USE CODE TAGS> [CODE]...[/CODE]
Get NotePad++ (free)
 02162009, 08:31 PM #48
tghn2b, how would you apply your idea to this:
group1: 10, 5, 6, 7, 8
group2: 9, 1, 2, 3, 4USE CODE TAGS> [CODE]...[/CODE]
Get NotePad++ (free)
 02162009, 09:43 PM #49Member
 Join Date
 Feb 2009
 Posts
 48
 Rep Power
 0
whow holy shit! this makes my head hurt!
 02242009, 09:57 PM #50Member
 Join Date
 Jan 2009
 Posts
 40
 Rep Power
 0
Yes this is where the 2nd part comes into play. Because the difference between G1 and G2 > smallest in G2, swap out the smallest of G2 for the next size up in G1. so
G1: 500,30,10,10,10 = 560
G2: 400,30,30,20,20 = 500
rinse and repeat, now we are in the 2nd smallest number in G2... swap for the next largest number in G1.
G1: 500,20,10,10,10 = 550
G2: 400,30,30,30,20 = 510
rinse and repeat... now the 3rd smallest number... hey that's 30 still smaller than difference... the next number in G1 is 500 but the difference of 30 and 500 is Greater than 400 therefore don't swap... hence you have exactly what you said :) this is probably the more difficult thing to wrap your head around... so yes if your head hurt then, you'll probably have a seizsure now...
Sorry i was MIA, :)
Jason
 02252009, 06:23 AM #51Member
 Join Date
 Jan 2008
 Posts
 31
 Rep Power
 0
 02252009, 06:32 AM #52
err... can you tell me that in baby steps? haha.
USE CODE TAGS> [CODE]...[/CODE]
Get NotePad++ (free)
 02252009, 01:54 PM #53Member
 Join Date
 Jan 2009
 Posts
 40
 Rep Power
 0
Here we go.. what you don't understand is that the main listing needs to be sorted. I will step through the process that has been setup already, tested, and shows. If you are trying to program already what has been done you are clearly missing a step. Steps are broken up by the dotted line.
G1: 10
................
G1: 10
G2: 9
................
G1: 10
G2: 9,8
................
G1: 10,7
G2: 9,8
................
G1: 10,7,6
G2: 9,8
................
G1: 10,7,6
G2: 9,8,5
................
G1: 10,7,6
G2: 9,8,5,4
................
G1: 10,7,6,3
G2: 9,8,5,4
................
G1: 10,7,6,3,2
and then since G1 is full, rest goes in G2
G2: 9,8,5,4,1
................
G1 = 28
G2 = 27
but then we can check it by seeing the difference, 2827 = 1 which is NOT greater than our smallest value of G2, thereby we know we have the most correct grouping. if we take what you thought was the correct algorithm then you actually can fix the groups by running it through this secondary step which hasn't been programmed into Angryboy's. for instance.
G1: 10, 5, 6, 7, 8 = 36
G2: 9, 1, 2, 3, 4 = 19
the difference is 17 = 3619, highest number in G2 however G2 needs to be sorted and G1 also so rework your Groupings.
G1: 10,8,7,6,5
G2: 9,4,3,2,1
and then proceed....
1 moves to G1 and smallest in G1 moves to G2. we have
G1: 10,8,7,6,1 = 32
G2: 9,4,3,2,5 = 23
and now the next number in line happens to be at position 2, the number 2 which is smaller than the difference of 9 swap for postion 2...
G1: 10,8,7,2,1 = 28
G2: 9,4,3,6,5 = 27
now the difference is 1, and the 3rd position number is 3 which is greater than the difference therefore this is now the best way to group. hmm this may actually be faster than the first way we do the algorithm but this involves a lot of checking and a lot of theory.
Any questions... or in your case, arguements in which why you don't think we have the correct algorithm... because it seems that you tell us that our way is getting results in which we aren't getting in fact therefore it seems to me that the only one that is programming the algorithm the wrong way is the person who has in fact misinterupted. please get your facts straight before you try and convince others that an algorithm is in fact wrong which it's actually been programmed and showing expected results (and oh yes, correct results).
Please try again when they are either more intelligent checks or, you just want to know more.. questions are better than comments.. sorry for me being blunt but i kind of get annoyed when we have a couple of people who have thought about this problem and had quite a bit of time, then a newbie comes in spends 10 seconds on thought, choses the easiest grouping (which we have already looked at and shown) and says "see, your way is wrong because i programmed it to be like this"...
ok off my soap box... if you have questions ask, don't comment unless you know that your comments will be looked at...
Jason
 02252009, 05:54 PM #54
(every time i thought i was out, they PULL me back in...)
ok, now that i know the steps, i will put it to code. hopefully by monday, we will have 0 diff for 2010. now, do i have to sort the numbers everytime i swap, and are you going by positions only or the next smallest value?USE CODE TAGS> [CODE]...[/CODE]
Get NotePad++ (free)
 02252009, 07:27 PM #55Member
 Join Date
 Jan 2009
 Posts
 40
 Rep Power
 0
do not swap everytime... only the first time. by swapping it means you are sure that it needs to be in the other group... however if you do sort you will need to throw in a check which might be worth having the check in there anyway. the check is, if the difference between the groups is less than the difference the 2 numbers that you are swapping then dont' swap i believe. my logic might be reversed but right now i'm working on something else and can't really give it too much thought... let me know if you need help on the algo...
 02282009, 05:53 AM #56
i've put it to code. it worked for 110 but fails for 20/10. maybe i'm not getting the algo right, please check the code in your pm. (when you're free, offcourse)
USE CODE TAGS> [CODE]...[/CODE]
Get NotePad++ (free)
 03052009, 01:52 AM #57
Similar Threads

finding the largest k numbers in an array without sorting the whole list?
By jmmjm in forum Advanced JavaReplies: 5Last Post: 02072009, 07:48 AM 
printing two smallest numbers from a series of numbers
By trofyscarz in forum New To JavaReplies: 2Last Post: 10142008, 11:46 PM 
sorting
By jot321 in forum New To JavaReplies: 18Last Post: 10022008, 10:30 AM 
sorting problem
By mcal in forum New To JavaReplies: 1Last Post: 02142008, 08:13 AM 
sorting JTable
By mansi_3001 in forum Advanced JavaReplies: 3Last Post: 08102007, 06:29 PM
Bookmarks