Algorithm::Partition - Partition a set of integers.


Algorithm-Partition documentation  | view source Contained in the Algorithm-Partition distribution.

Index


NAME

Top

Algorithm::Partition - Partition a set of integers.

VERSION

Top

Version 0.04

SYNOPSIS

Top

    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

Top

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

  use Algorith::Partition qw(partition);

DESCRIPTION

Top

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

Top

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

Top

Dmitri Tikhonov, <dtikhonov at yahoo.com>

BUGS

Top

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

Top

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

    perldoc Algorithm::Partition

You can also look for information at:

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Algorithm-Partition

* CPAN Ratings

http://cpanratings.perl.org/d/Algorithm-Partition

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Algorithm-Partition

* Search CPAN

http://search.cpan.org/dist/Algorithm-Partition

ACKNOWLEDGEMENTS

Top

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

COPYRIGHT & LICENSE

Top


Algorithm-Partition documentation  | view source Contained in the Algorithm-Partition distribution.