[Cascavel-pm] Golfe (Was: Re: Soma)

Wendel Scardua wendelscardua em gmail.com
Segunda Julho 10 17:27:27 PDT 2006


Deixa eu tentar também.... :-)

On 7/10/06, Daniel Ruoso <daniel em ruoso.com> wrote:
> Em Seg, 2006-07-10 às 13:58 -0300, Thomas Britis escreveu:
> >       Existe alguma forma de se fazer o seguinte:
> > $c = "2:3";
> > ($a, $b) += split (/:/, $c); ???
>
> Situação 1:
>
> $a=$b=5;$c="2:3";
> # YOUR CODE HERE
> print "$a, $b\n";
>
> Deve cuspir: "7, 8\n"
>

Minha jogada (27):

$a+=$c;$c=~s/\d+://;$b+=$c;

>
> Situação 2:
> $a=$b=0;@c=qw(1:2 3:4 5:6 7:8 9:10 11:12);
> # YOUR CODE HERE
> print "$a, $b\n";
>
> Deve cuspir: "36, 42\n"
>

Minha jogada (30):

map{$a+=$_;s/\d+://;$b+=$_}@c;



Wendel
ps: o enunciado não pede pra ser não-destrutivo, né ? ^_^;;;;
--
"Não ajustar o auto-ajuste" - http://wendel.scardua.net/


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