Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

/prog/ challenge

Name: Anonymous 2008-04-28 23:45

The challenge is to produce an algorithm to solve the Subset-Sum Problem in your language of choice.  To make it somewhat interesting try to make it as efficient as possible and do not copy an existing algorithm but come up with one yourself.

Bonus Points:  Make the algorithm run in polynomial time.

Name: Anonymous 2008-04-29 0:08

Forget it, it's NP complete.

Name: Anonymous 2008-04-29 0:10

>>2
Doesn't mean you can't solve it in exponential time

Name: Anonymous 2008-04-29 0:59

>>3
Actually, it does

Name: Anonymous 2008-04-29 4:44

>>4
How do you know P != NP?

Name: Anonymous 2008-04-29 4:54

>>5
How do you know your ANUS != HAXED?

Name: A traveling salesman 2008-04-29 4:58

>>5
It are a facts, I know it because of my absolute knowledge.

Name: Anonymous 2008-04-29 5:15

What's the subset-sum problem?

Name: Anonymous 2008-04-29 5:21

>>8
suppose you have a set {a,...,k}
does there exist some sum of elements in the set which equals zero?

Name: Anonymous 2008-04-29 7:19

>>9
Yes

Name: Anonymous 2008-04-29 7:30

>>9
That's an interesting one. I'll have a think about it and post back later.

Name: Anonymous 2008-04-29 8:28

>>11
Forget it. It's NP-complete.

Name: Anonymous 2008-04-29 10:38

>>12
 Why forget it? It can be solved in exponential time so the challenge stands.

Name: Anonymous 2008-04-29 10:54

>>4
Wow

Seriously?  GTFO /prog/

Name: susman 2008-04-29 10:57

u can do nething
if u put ur mind 2 it

Name: Anonymous 2008-04-30 17:44

>>15
I suspect this isn't the real GJS

Name: Anonymous 2008-05-01 19:23

No takers?

Name: Anonymous 2008-05-01 19:31

>>17
No carers

Name: Anonymous 2008-05-01 23:46

proc subset-sum(Set input)
  Set subsets := powerset(input)
  foreach (subsets as current_subset)
     if sum(current_subset) = 0
        return true
  return false
end

proc sum(Set input)
   sum := 0
   foreach (input.elements as current_element)
      sum := sum + current_element
   return sum
end


O(n log n)

Name: Anonymous 2008-05-02 6:18

>>19
constructing the powerset is exponential time.

Thinking on this problem it seems clear it's NP, so you'd solve it like any NP problem such as the knapsack problem.

Name: Anonymous 2008-05-02 6:28

>>19
What language is that?

Name: Anonymous 2008-05-02 7:57

>>21
Homocode

Name: Anonymous 2008-05-02 7:58

>>21
Pseudocode

Name: Anonymous 2008-05-11 12:58

>>20
Did you not read >>1   To make it somewhat interesting try to make it as efficient as possible and do not copy an existing algorithm but come up with one yourself.

I am almost done and will post my results soon (next 3 days)

Name: Anonymous 2008-05-11 16:07

>>24

I'm waiting for your polynomial time algorithm. You have 3 days.

Name: Anonymous 2008-05-11 16:12

>>25
okay

Name: Anonymous 2008-05-11 16:23

>>25
the most beautiful thing about subset Sum problem is the inherent symmetry in everything.  As you approach it with different methods and representations they all seamlessly blend into each other.  It is almost like a million different ways to solve it in the same exact way.

Name: Anonymous 2008-05-11 17:16

>>27
That's funny. I feel the exact same way about 3-SAT.

Name: Anonymous 2008-05-11 17:57

>>28
Yes it will be glorious when /prog/ proves P=NP

Name: Anonymous 2008-05-11 20:20

O(n) complexity in Java:
int max = list[0];
int maxStart, maxStop, start, sum;
for (int i = 0; i < list.length; i++) {
    if (sum < 0) {
        start = i;
        sum = 0;
    }
    sum += list[i];
    if (sum > max) {
        max = sum;
        maxStart = start;
        maxStop = i;
    }
}

Name: Anonymous 2008-05-11 20:42

>>30
;_;

Name: Anonymous 2008-05-11 21:50

>>30
back to /pr/, please

Name: Anonymous 2008-05-11 22:14

Wait, this problem is easily solvable using the techniques learned in SIPI.

Name: Anonymous 2009-10-03 3:14

>>6
Back to /louunge/, please!

Name: Anonymous 2010-11-02 14:59

Name: Anonymous 2010-11-15 1:16

Name: Anonymous 2010-12-17 1:34

Erika once told me that Xarn is a bad boyfriend

Name: Sgt.Kabukiman抐䌟 2012-05-23 0:31

焁䣤쎅셰밼맳ᜉ⦴ᙸ

Don't change these.
Name: Email:
Entire Thread Thread List