So pra lembrar, ja rodei algo semelhante:

20m55.517s

Este foi o tempo que demorou para rodar o KickSort em Java.
Acho que estava com bastante sorte no dia

2011/5/19 Renato Santos <renato.c...@gmail.com>

> ta rodando
> mas o resultado eu sei, será 60 elementos ordernados ^^
>
> use Data::Dumper;
> use List::Util qw(shuffle);
>
>  sub bogosort {
>     my @a = @_;
>     my @sorted = sort {$a <=> $b} @a;
> print "Em ordem é @sorted, mas vale a pena conferir se você está com
> sorte\n";
>      while("@a" ne "@sorted") {
>        @a = shuffle(@a);
>     }
>     return @a;
>  }
>
> @b = (30..60, 0..30); # too complex order
>
> print Dumper  bogosort(@b);
> renato@renato-desktop:/projetos/youdb/nestle/datamotion_ps$ time perl
> /tmp/xxx.pl2
> Em ordem é 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
> 25 26 27 28 29 30 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
> 49 50 51 52 53 54 55 56 57 58 59 60, mas vale a pena conferir se você está
> com sorte
>
>
> 2011/5/19 Wesley Seidel <wesley.sei...@gmail.com>
>
>> Não precisa ser 100k não.
>> Ponha apenas 60 elementos e dê-nos o resultado.
>> :D
>>
>>
>> 2011/5/19 Bruno Buss <bruno.b...@gmail.com>
>>
>>> Agora testa ai com 100k elementos :)
>>>
>>>
>>> [ ]'s
>>>
>>> 2011/5/19 Renato Santos <renato.c...@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@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 <nfer...@gmail.com>
>>>>
>>>>> 2011/5/19 Wesley Seidel <wesley.sei...@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@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@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/
>>>
>>> =begin disclaimer
>>>   Sao Paulo Perl Mongers: http://sao-paulo.pm.org/
>>>  SaoPaulo-pm mailing list: SaoPaulo-pm@pm.org
>>>  L<http://mail.pm.org/mailman/listinfo/saopaulo-pm>
>>> =end disclaimer
>>>
>>>
>>
>>
>> --
>> Wesley Seidel Carvalho
>> 11-6671-6118
>> 11-8169-1163
>> http://twitter.com/wseidel
>>
>>
>>
>> =begin disclaimer
>>   Sao Paulo Perl Mongers: http://sao-paulo.pm.org/
>>  SaoPaulo-pm mailing list: SaoPaulo-pm@pm.org
>>  L<http://mail.pm.org/mailman/listinfo/saopaulo-pm>
>> =end disclaimer
>>
>>
>
>
> --
> Renato Santos
> http://www.renatocron.com/blog/
>



-- 
Renato Santos
http://www.renatocron.com/blog/
=begin disclaimer
   Sao Paulo Perl Mongers: http://sao-paulo.pm.org/
 SaoPaulo-pm mailing list: SaoPaulo-pm@pm.org
 L<http://mail.pm.org/mailman/listinfo/saopaulo-pm>
=end disclaimer

Responder a