That's not possible for your example string, is it? (there's 10 x 10 characters)
Maybe I'm overthinking... bin packing?
use Algorithm::Bucketizer; while (my $in = <>) { chomp($in); my %counts; $counts{$_}++ for split //, $in; my $b = Algorithm::Bucketizer->new(bucketsize=>length($in)/4); $b->add_item($_, $counts{$_}) for keys %counts; $b->optimize(maxrounds=>100); print $_->serial, " => ", join(", ", map {"$_ ($counts{$_})"} $_->items ), "\n" for $b->buckets; }
e.g.
chhbfbjjjcgaiiaachbaefeabcbjffdgaggbgccaihgjddedfheejdigcdeiacebdehfig +egifibdabhfdihbdhifcgjfjhcaejj 1 => f (10), g (10) 2 => b (10), h (10) 3 => i (10), j (10) 4 => e (10), d (10) 5 => c (10), a (10) abbbbbbbccddddddeeefffffgggghhhh 1 => e (3), f (5) 2 => b (7), a (1) 3 => c (2), d (6) 4 => g (4), h (4)
In reply to Re: mapping 10 -> 4 equally.
by Anonymous Monk
in thread mapping 10 -> 4 equally.
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |