note
tadman
Thankfully, the statement doesn't "overflow" so this program works:
<BLOCKQUOTE><CODE>#!/usr/bin/perl -w
use strict;
my $statement = "The number of 0s in this sentence is _, of 1s is _, of 2s is _, of 3s is _, of 4s is _, of 5s is _, of 6s is _, of 7s is _, of 8s is _, and of 9s is _.";
my @index;
my $resume = 0;
while (($resume = index($statement, "_", $resume)) && $resume > 0)
{
push (@index, $resume++);
}
my $changed;
do {
$changed = 0;
for my $n (0 .. $#index)
{
my $count = (grep { /$n/ } split (//, $statement));
my $old_count = substr($statement, $index[$n], 1);
if ($count ne $old_count)
{
substr($statement, $index[$n], 1) = $count;
$changed++;
}
}
} while ($changed);
print $statement,"\n";
</CODE></BLOCKQUOTE>
The great mystery is finally revealed. Golf anyone?
168608
168608