¹ Pulse-Coupled Neural Networks (PCNNs) are neural models proposed by modeling a cat’s visual cortex and developed for high-performance biomimetic image processing. (Wikipedia et al., 2008)
Why all the hate on web developers? Can't we all just get along
Name:
Anonymous2009-01-18 7:57
LIKE TO PARTY
Name:
Anonymous2009-01-18 9:58
import Data.Array
subsetsum xs = foldl f (listArray (min, max) (repeat False)) xs ! 0
where f s x = listArray (min, max) (map g [min .. max])
where g i = i == x || s ! i || inRange (min, max) (i - x) && s ! (i - x)
min = sum (filter (< 0) xs)
max = sum (filter (> 0) xs)
subsetsum xs = foldl f (listArray (min, max) (repeat False)) xs ! 0
where f s x = listArray (min, max) (map g [min .. max])
where g i = i == x || s ! i || inRange (min, max) (i - x) && s ! (i - x)
min = sum (filter (< 0) xs)
max = sum (filter (> 0) xs)
$ ghc -C -c subsetsum.hs
Name:
Anonymous2009-01-18 15:20
bool subsetsum(int *xs, int n) {
int neg = 0, pos = 0;
for (int i = 0; i < n; i++) {
if (xs[i] < 0) {
neg += xs[i];
} else {
pos += xs[i];
}
}
int *p = calloc(pos - neg + 1, sizeof(*p));
int *q = calloc(pos - neg + 1, sizeof(*q));
for (int i = 0; i < n; i++) {
for (int j = neg; j <= pos; j++) {
q[j - neg] = j == xs[i]
|| p[j - neg]
|| neg <= j - xs[i] && j - xs[i] <= pos && p[j - xs[i] - neg];
}
int *t = p; p = q; q = t;
}
bool ret = p[-neg];
free(p);
free(q);
return ret;
}
Name:
Anonymous2009-01-18 21:05
' freebasic
' first command line argument is file to open
' returns exit status 0 if there is, 1 if there is not
dim a(0) as long uinteger : dim na as integer=0 ' array of read values, number of values in array
dim ia as integer=0, nt as integer=0 ' ia is recently read value from file, nt is subset total
dim l1 as integer=0, l2 as integer=0 ' loop vars
dim f as integer=0 ' set to -1 if subset = 0
open command$(1) for input as 1
do until eof(1)
input#1, ia
na=na+1
redim preserve a(na)
a(na)=ia
for l2=1 to na
nt=0
for l1=l2 to na
nt=nt+a(l1)
next
if nt=0 then f=-1:exit do
next
if nt=0 then f=-1:exit do
loop
if f then exit 0 else exit 1
close 1
Name:
Anonymous2009-01-19 17:02
I solved this a few years ago with an O(n) algorithm written in the programming language HTML.
Name:
Anonymous2009-01-19 18:05
I solved this a few years ago with an O(log n) algorithm written in the programming language BBCode.