NAME

Algorithm::Partition - Partition a set of integers.

VERSION

Version 0.04

SYNOPSIS

use Algorithm::Partition qw(partition);

my ($one, $two) = partition(2, 4, 1, 5, 8, 16);
unless (defined($one)) {
    print "Error: $two";    # now $two is an error
} else {
    print "Set 1: @$one\n";
    print "Set 2: @$two\n";
}

EXPORT

This module does not export anything by default. You can export function partition:

use Algorith::Partition qw(partition);

DESCRIPTION

This module implements an algorithm to see whether a set of integers can be split into two sets such that the sums of integers in one set is equal to the sum of integers in the other set.

FUNCTIONS

partition(@integers);

Given a list of integers, this function will return two values. If the first value is undef, then no solution was found and the second value is a string explaining why. Otherwise, two array references are returned which point to the two resulting sets.

The algorithm is meant for relatively small sets of integers with relatively small values. Beware.

AUTHOR

Dmitri Tikhonov, <dtikhonov at yahoo.com>

BUGS

Please report any bugs or feature requests to bug-algorithm-partition at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Algorithm-Partition. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Algorithm::Partition

You can also look for information at:

ACKNOWLEDGEMENTS

NJIT, Professor Joseph Leung, and the NP-Completeness course.

COPYRIGHT & LICENSE

Copyright 2007 Dmitri Tikhonov, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.