-
-
Save anonymous/af60e979bfa4df3a33b1ed99e84f6b68 to your computer and use it in GitHub Desktop.
random euros allocations
This file contains 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
#!/usr/bin/env perl6 | |
role Decorator { | |
method dump(){ | |
#say $!allocations; | |
#for $.allocations.kv -> $k,$v { | |
# say "$k - " ~ $v.join(" - "); | |
#} | |
} | |
} | |
class Allocator does Decorator { | |
has $.POT_1 is rw = qw|France Germany Spain England Belgium Italy Portugal Croatia Poland Austria Switzerland Russia|.map({ $_ => $_ }).Hash; | |
has $.POT_2 is rw = qw|Turkey Ukraine Wales Iceland Sweden Czech_Republic Romania Republic_of_Ireland Slovakia Hungary Albania Northern_Ireland|.map({ $_ => $_ }).Hash; | |
has $.users = qw|Matt_W Dan_S Kate_D Pete_K Samantha_C Mo_R Declan_T Natalie_S Tara_K Arda_T Dave_C Mahdi_M Aaron_F|.map({ $_ => $_}).Hash; | |
has $.allocations; | |
multi method allocate(){ | |
loop { | |
my $selected_user = $!users.keys.pick; $!users{$selected_user}:delete; | |
## get from POT 1 | |
my $selected_POT1 = $!POT_1.keys.pick; $!POT_1{$selected_POT1}:delete; | |
## get from POT 2 | |
my $selected_POT2 = $!POT_2.keys.pick; $!POT_2{$selected_POT2}:delete; | |
$!allocations{$selected_user} = [$selected_POT0, $selected_POT2]; | |
last if ( !$!users.Int ); | |
} | |
self | |
} | |
method dump(){ | |
for $.allocations.kv -> $k,$v { | |
say "$k - " ~ $v.join(" - "); | |
} | |
} | |
} | |
### main | |
Allocator.new.allocate().dump(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment