Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Golf Soccer Stats

by andreychek (Parson)
on May 23, 2002 at 23:33 UTC ( #168931=note: print w/replies, xml ) Need Help??

in reply to Golf Soccer Stats

Here's another stab (with help from quadzero):

Chars: 37
sub stats { $p=pop;$w=int$p/3,$t=$p%3,$_[0]-$w-$t }

Lucy: "What happens if you practice the piano for 20 years and then end up not being rich and famous?"
Schroeder: "The joy is in the playing."

Replies are listed 'Best First'.
Re: Re: Golf Soccer Stats
by meta4 (Monk) on May 24, 2002 at 04:08 UTC
    Close. But you return ($wins, $ties, $losses). The Game is ($wins, $losses, $ties). I only know this because I fell into the same trap, and switching it arround ain't easy.

    update: um ... ain't easy ... uh ... err ... unless your jynx! Yeah, that's the ticket! That's what I ment to say.

    Wow! I am continualy enlightened.

      Not looking to start a war cuz i'm as new to perl as they come but still... this particular golf challenge doesn't *explicitly* say that the order of the results returned is significant. I agree that it does list them in the order w/l/t, but it doesn't say that they *must* be returned in this order.

      As in logic puzzles, i think it makes good sense not to assume anything at all. For example, if the goal was to return a string with the characters "a", "b" and "c" both surrounded with, and separated by, a tilde character ("~"), would you assume that the "correct" results looked like this: "~a~b~c~", or would "~b~a~c~" also qualify?

      In my opinion (and I do mean *just* my opinion :-) both of the above examples qualify as legitimate because the challenge specified the content without specifying the order of the letters. Had it said something along the lines of "return the characters 'a', 'b' and 'c' (in that order) both surrounded by....", then I would certainly agree that the order was an explicit and significant aspect of the solution.

      Anyway, as you've already noticed, if the original soccer score order *was* actually significant, jynx (sp?) took care of that for us.

      Again, not looking for a fight here, just sharing my point of view.

      Cheers! 8-D
      quadzero (at) users (dot) sourceforge (dot) net

Re: Re: Golf Soccer Stats
by jynx (Priest) on May 24, 2002 at 18:25 UTC

    a little rearranging gives 38:
    sub stats { #23456789_123456789_123456789_123456789_ $p=pop;$w=int$p/3,-$w-($t=$p%3)+pop,$t }
    and removing the $p assignment gets it back to 37:
    sub stats2 { #23456789_123456789_123456789_123456789_ $w=int$_[1]/3,-$w-($t=pop()%3)+pop,$t }

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://168931]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2021-10-26 03:38 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (90 votes). Check out past polls.