Skip to content

Instantly share code, notes, and snippets.

@poppen
Created February 10, 2013 12:38
Show Gist options
  • Select an option

  • Save poppen/4749465 to your computer and use it in GitHub Desktop.

Select an option

Save poppen/4749465 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use YAML;
use Algorithm::Bucketizer;
my $size = 20;
my $bucketizer = Algorithm::Bucketizer->new(bucketsize => $size);
foreach my $item (1..100) {
# say $item;
$bucketizer->add_item($item, int(rand(10)) );
}
$bucketizer->optimize(maxrounds => 100);
my @buckets = $bucketizer->buckets();
foreach my $bucket (@buckets) {
my @items = $bucket->level();
print YAML::Dump(@items);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment