[Rio-pm] [OT-GOLF] Merge

Nilson Santos Figueiredo Jr. acid06 em gmail.com
Quinta Fevereiro 4 09:58:41 PST 2010


Menos 2 chars, abusando de variáveis especiais:

sub merge{$_=pop;@_=pop=~/./g;s/(.)/$1.shift/ge;join'',$_, at _}

-Nilson

On Thu, Feb 4, 2010 at 3:54 PM, Nilson Santos Figueiredo Jr.
<acid06 at gmail.com> wrote:
> Acho que vale. Consegui cortar 3 chars da sua:
>
> sub merge{@a=pop=~/./g;$_=pop;s/(.)/$1.shift at a/ge;join'',$_, at a}
>
> -Nilson
>
> 2010/2/4 Renan Rangel <rvr777 at gmail.com>:
>> Olá pessoal,
>> Vale dessa forma?
>> sub merge{@a=split//,pop;$_=pop;s/(.)/$1.shift at a/ge;$_.join'', at a}
>> --
>> Renan Rangel
>>
>>
>> 2010/2/4 Fernando Oliveira <fernandocorrea at gmail.com>
>>>
>>> mais uma tacada:
>>>
>>> sub merge{$z="a";@{$z++}=split//for at _;join"",map{$a[$_].$b[$_]}0.. at a+@b}
>>>
>>> Just another Perl Hacker,
>>> Fernando (SmokeMachine)
>>> http://perl-e.org
>>> Sent from Rio De Janeiro, RJ, Brazil
>>>
>>>
>>> 2010/2/4 Daniel de Oliveira Mantovani
>>> <daniel.oliveira.mantovani at gmail.com>
>>>>
>>>> Ops ele diz sim desculpa....
>>>>
>>>> On 4 February 2010 13:28, Daniel de Oliveira Mantovani
>>>> <daniel.oliveira.mantovani at gmail.com> wrote:
>>>> > Que eu saiba tem que retornar a saída que o blabos pois:
>>>> > merge('abc', 12345) -> a1b2c345
>>>> >
>>>> > Ele não diz que a saída é uma string.
>>>> >
>>>> > Pelo que eu entendi tem que aparecer isso no terminal:
>>>> > a1b2c345
>>>> >
>>>> > 2010/2/4 Fernando Oliveira <fernandocorrea at gmail.com>:
>>>> >> Mantovani, claro q precisa! Isso nao ta retornando uma string...
>>>> >>
>>>> >> On Feb 4, 2010 12:59 PM, "Daniel de Oliveira Mantovani"
>>>> >> <daniel.oliveira.mantovani at gmail.com> wrote:
>>>> >>
>>>> >> Não precisa do join:
>>>> >> sub merge{@b=split//,pop;@a=split//,pop;map{$a[$_].$b[$_]}0.. at a+@b}
>>>> >>
>>>> >> mantovani at mantovani-desktop:~$ perl -MMerge -E 'say merge("dan",12)'
>>>> >> d1a2n
>>>> >>
>>>> >>
>>>> >> 2010/2/4 breno <breno at rio.pm.org>:
>>>> >>> e -2 tirando parenteses
>>>> >>>
>>>> >>> sub merge{@b=split//,pop;@a=split...
>>>> >>
>>>> >> --
>>>> >> "If you’ve never written anything thoughtful, then you’ve never had
>>>> >> any difficult, important, or interesting thoughts. That’s the secret:
>>>> >> people who don’t write, are people who don’t think."
>>>> >>
>>>> >> _______________________________________________
>>>> >> Rio-pm mailing list
>>>> >> Rio-pm at pm.org
>>>> >> http://mail.pm.org...
>>>> >>
>>>> >> _______________________________________________
>>>> >> Rio-pm mailing list
>>>> >> Rio-pm at pm.org
>>>> >> http://mail.pm.org/mailman/listinfo/rio-pm
>>>> >>
>>>> >
>>>> >
>>>> >
>>>> > --
>>>> > "If you’ve never written anything thoughtful, then you’ve never had
>>>> > any difficult, important, or interesting thoughts. That’s the secret:
>>>> > people who don’t write, are people who don’t think."
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> "If you’ve never written anything thoughtful, then you’ve never had
>>>> any difficult, important, or interesting thoughts. That’s the secret:
>>>> people who don’t write, are people who don’t think."
>>>> _______________________________________________
>>>> Rio-pm mailing list
>>>> Rio-pm at pm.org
>>>> http://mail.pm.org/mailman/listinfo/rio-pm
>>>
>>>
>>> _______________________________________________
>>> Rio-pm mailing list
>>> Rio-pm at pm.org
>>> http://mail.pm.org/mailman/listinfo/rio-pm
>>
>>
>> _______________________________________________
>> Rio-pm mailing list
>> Rio-pm at pm.org
>> http://mail.pm.org/mailman/listinfo/rio-pm
>>
>


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