[SP-pm] [OT] Algorítimos de ordenação - performance artística

Bruno Buss bruno.buss at gmail.com
Thu May 19 09:08:52 PDT 2011


Agora testa ai com 100k elementos :)


[ ]'s

2011/5/19 Renato Santos <renato.cron at gmail.com>

> Me pareceu tão rapido...
> use Data::Dumper;
> use List::Util qw(shuffle);
>
>  sub bogosort {
>     my @a = @_;
>     my @sorted = sort {$a <=> $b} @a;
>     while("@a" ne "@sorted") {
>        @a = shuffle(@a);
>     }
>     return @a;
>  }
>
> @b = (4,56,8,5,2,5,6,4);
> renato at renato-desktop:/projetos/youdb/nestle/datamotion_ps$ time perl
> /tmp/xxx.pl2
> $VAR1 = 2;
> $VAR2 = 4;
> $VAR3 = 4;
> $VAR4 = 5;
> $VAR5 = 5;
> $VAR6 = 6;
> $VAR7 = 8;
> $VAR8 = 56;
>
> real 0m0.058s
> user 0m0.052s
> sys 0m0.000s
>
> print Dumper  bogosort(@b);
>
> 2011/5/19 Nelson Ferraz <nferraz at gmail.com>
>
>> 2011/5/19 Wesley Seidel <wesley.seidel at gmail.com>
>> > ahahaha
>> > Se levou tudo isso com um quicksort, imagine o tempo pra fazer essa
>> dança com um bubblesort.
>>
>> Imagina então um bogosort. :D
>>
>> http://en.wikipedia.org/wiki/Bogosort
>> =begin disclaimer
>>   Sao Paulo Perl Mongers: http://sao-paulo.pm.org/
>>  SaoPaulo-pm mailing list: SaoPaulo-pm at pm.org
>>  L<http://mail.pm.org/mailman/listinfo/saopaulo-pm>
>> =end disclaimer
>>
>
>
>
> --
> Renato Santos
> http://www.renatocron.com/blog/
>
> =begin disclaimer
>   Sao Paulo Perl Mongers: http://sao-paulo.pm.org/
>  SaoPaulo-pm mailing list: SaoPaulo-pm at pm.org
>  L<http://mail.pm.org/mailman/listinfo/saopaulo-pm>
> =end disclaimer
>
>


-- 
Bruno C. Buss
http://brunobuss.wordpress.com/
http://www.dcc.ufrj.br/~brunobuss/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/saopaulo-pm/attachments/20110519/5d05dd69/attachment-0001.html>


More information about the SaoPaulo-pm mailing list