[Moscow.pm] Конкурс

Akzhan Abdulin akzhan.abdulin на gmail.com
Пт Окт 26 05:10:03 PDT 2012


Если я правильно понял ТЗ, то вот решение (надеюсь, там по умолчанию черный
цвет заливки). :)

Подсказка: нижней границы числа нечерных пискелов нет.

#!/usr/bin/perl
use strict;
use warnings;

use Imager;
use Time::HiRes qw(time);

my $filename = 'competition.jpg';
my $image = Imager->new(xsize=>1024, ysize=>1024);
my $before = time();

my $after = time();
$image->write(file=>$filename) or die $image->errstr;
my $filesize = -s $filename;
my $elapsed = ($after-$before) or die 'You are winner!';

print "Time: ",$elapsed,"\nFile size: ", $filesize, "\nResult:
",$filesize/$elapsed,"\n";



26 октября 2012 г., 16:01 пользователь Михаил Монашёв <
postmaster на softsearch.ru> написал:

> #!/usr/bin/perl
> use strict;
> use warnings;
>
> use Imager;
> use Time::HiRes qw(time);
>
> my $filename = 'competition.jpg';
> my $image = Imager->new(xsize=>1024, ysize=>1024);
> my $before = time();
>
> # этот блок кода надо ускорить
> srand(123);
> for (my $i=0; $i<39293; $i++) {
>         my $color = Imager::Color->new(rand(255), rand(255), rand(255) );
>         $image->setpixel(x=>rand(1024), y=>rand(1024), color=>$color);
> }
>
> my $after = time();
> $image->write(file=>$filename) or die $image->errstr;
> my $filesize = -s $filename;
> my $elapsed = ($after-$before) or die 'You are winner!';
>
> print "Time: ",$elapsed,"\nFile size: ", $filesize, "\nResult:
> ",$filesize/$elapsed,"\n";
>
----------- следущая часть -----------
Вложение в формате HTML было извлечено…
URL: <http://mail.pm.org/pipermail/moscow-pm/attachments/20121026/43069bd7/attachment.html>


Подробная информация о списке рассылки Moscow-pm