Dmitri Tikhonov >
Algorithm-Partition-0.04 >
Algorithm::Partition

Module Version: 0.04
Algorithm::Partition - Partition a set of integers.

Version 0.04

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"; }

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

use Algorith::Partition qw(partition);

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.

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.

Dmitri Tikhonov, `<dtikhonov at yahoo.com>`

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.

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
- CPAN Ratings
- RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Algorithm-Partition

- Search CPAN

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

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.

syntax highlighting: