Created
April 1, 2010 06:13
-
-
Save JEEN/351453 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use v6; | |
| my $file = open 'scores'; | |
| my @names = $file.get.split(' '); | |
| my %games; | |
| my %sets; | |
| for $file.lines -> $line { | |
| my ($pairing, $result) = $line.split(' | '); | |
| my ($p1, $p2) = $pairing.split(' vs '); | |
| my ($r1, $r2) = $result.split(':'); | |
| %sets{$p1} += $r1; | |
| %sets{$p2} += $r2; | |
| if $r1 > $r2 { | |
| %games{$p1}++; | |
| } else { | |
| %games{$p2}++; | |
| } | |
| } | |
| #my @sorted = @names.sort({ %sets{$_} }).sort({ %games{$_} }).reverse; | |
| my @sorted = @names.sort({ %sets{$_} }).reverse.sort({ %games{$_} }); | |
| for @sorted -> $n { | |
| say "$n has won { %games{$n} } game and { %sets{$n} } sets"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment