[Rio-pm] Combinação

Fernando Oliveira fernandocorrea em gmail.com
Sexta Março 23 10:25:22 PDT 2012


Fernando em ACNBRG809F61V ~
$ perl -E 'say"qwerty"^(unpack"b6",chr)=~y/10/\0 /r for 0..63'
Bareword found where operator expected at -e line 1, near "y/10/\0 /r"
Can't modify unpack in transliteration (tr///) at -e line 1, near "y/10/\0
/r "
syntax error at -e line 1, near "y/10/\0 /r "
Execution of -e aborted due to compilation errors.




Just another Perl Hacker,
Fernando (SmokeMachine)


2012/3/23 Stanislaw Pusep <creaktive em gmail.com>

> Golf, they said. Binary operations, they said.
>
> perl -E 'say"qwerty"^(unpack"b6",chr)=~y/10/\0 /r for 0..63'
>
> ABS()
>
>
>
>
> On Fri, Mar 23, 2012 at 12:47, Fernando Oliveira <fernandocorrea em gmail.com
> > wrote:
>
>> se a intensão era Golf, segue a minha 1a tacada:
>>
>> perl -E'@a=map{["\u$_","\l$_"]}split//,pop;sub
>> r{return""if!@_;my$b=pop;map{($_.$b->[0],$_.$b->[1])}r(@_)}say for r(@a)'
>> ola
>>
>>
>>
>> Just another Perl Hacker,
>> Fernando (SmokeMachine)
>>
>>
>>
>> 2012/3/23 Junior Moraes <juniiior182 em gmail.com>
>>
>>> Hi.
>>>
>>> Acp, você conseguiu entender o script que postei lá?
>>> Tá que eu não fiz ele pra ficar bonito e ser entendido e sim pra
>>> resolver o mini challenge, mas no caso:
>>>
>>> use strict;
>>> use warnings;
>>>
>>> sub re {
>>>     if($_[2] != length($_[0])) {
>>>         my $ch = (split(//, $_[0]))[$_[2]];
>>>         for((lc($ch), uc($ch))) {
>>>             $_[1]->[$_[2]] = $_;
>>>             &re($_[0], $_[1], $_[2] + 1);
>>>         }
>>>         return;
>>>     }
>>>     print join(q(), @{$_[1]}), "\n";
>>> }
>>> re('ola', [], 0);
>>>
>>> Ou conseguiu utilizar a lógica binária pra fazer o mapeamento e mudar os
>>> cases?
>>> Por exemplo:
>>> *:~$ perl -E 'printf("%b\n", $_) for 0 .. 10'*
>>>
>>> 000 = ola
>>> 001 = olA
>>> 010 = oLa
>>> 011 = oLA
>>> 100 = Ola
>>> 101 = OlA
>>>
>>> E por aí vai...
>>>
>>> []'s
>>>
>>> Em 23 de março de 2012 10:45, Aureliano Guedes <guedes_1000 em hotmail.com>escreveu:
>>>
>>>>  Boma dia, monges.
>>>>
>>>> Estou tentando fazer uma função que faça a combinação de cases sem usar
>>>> o Set::CrossProduct.
>>>>
>>>> Exemplo, tenho [A-F] e [1-6], e uma string com 6 caracteres (_ _ _ _ _
>>>> _), ou seja 6 posições
>>>> na primeira posição pode ser 1 ou A, na segunda 2 ou B ... na ultima 6
>>>> ou B, dai
>>>> quero que a saida seja todas as combinações possiveis, oou seja, todas
>>>> as possibilidades da string.
>>>>
>>>> Ja estou tentando a 2 dias, mas nada vem em mente.
>>>>
>>>> Caso eu tenha me expressado mal (como o de costume), eu tento explicar
>>>> melhor.
>>>>
>>>> Aguardando alguma ajuda, desde ja obrigado.
>>>>
>>>> _______________________________________________
>>>> Rio-pm mailing list
>>>> Rio-pm em pm.org
>>>> http://mail.pm.org/mailman/listinfo/rio-pm
>>>>
>>>
>>>
>>>
>>> --
>>> Junior Moraes (fvox)
>>> Perl Developer
>>> http://www.unsecurity.com.br/
>>>
>>> <http://www.twitter.com/juniiormoraes> <http://pt-br.facebook.com/juniiormoraes>
>>>   <http://plus.google.com/104958988925423385684> <http://www.lastfm.com.br/user/juniior182>
>>>   <http://www.delicious.com/fvox>  <http://github.com/fvox>
>>>
>>>
>>> _______________________________________________
>>> Rio-pm mailing list
>>> Rio-pm em pm.org
>>> http://mail.pm.org/mailman/listinfo/rio-pm
>>>
>>
>>
>> _______________________________________________
>> Rio-pm mailing list
>> Rio-pm em pm.org
>> http://mail.pm.org/mailman/listinfo/rio-pm
>>
>
>
> _______________________________________________
> Rio-pm mailing list
> Rio-pm em pm.org
> http://mail.pm.org/mailman/listinfo/rio-pm
>
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://mail.pm.org/pipermail/rio-pm/attachments/20120323/ddad71c6/attachment.html>


Mais detalhes sobre a lista de discussão Rio-pm