Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Split X into Y and Z where Y = Z (NP-issue)
#5
Oh yeah, KajitiSouls, you can just sort them in order and manipulate the list how you'd like to, as long you get the right answer.

And Stereo, nice one.
Then, first of all, find the sum of all the numbers. If odd, quit. Then find the half of the sum.
(Then, I'd check for a number higher than X/2.)
From that, say the list is sorted in ascending order. We can either put every second number in each list, or we can put all numbers in a list until sum of list >= X/2.
Then swap and move as you suggested. However, when do you prove it's not possible to set the list?

And what's faster? Every second number, or all numbers in a list until sum of list >= X/2?
Reply


Messages In This Thread
Split X into Y and Z where Y = Z (NP-issue) - by Nikkey - 2009-01-21, 08:59 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)