Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,25 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use feature 'say';
|
||||
|
||||
sub get_next {
|
||||
my($w,%wheels) = @_;
|
||||
my $wh = \@{$wheels{$w}}; # reference, not a copy
|
||||
my $value = $$wh[0][$$wh[1]];
|
||||
$$wh[1] = ($$wh[1]+1) % @{$$wh[0]};
|
||||
defined $wheels{$value} ? get_next($value,%wheels) : $value;
|
||||
}
|
||||
|
||||
sub spin_wheels {
|
||||
my(%wheels) = @_;
|
||||
say "$_: " . join ', ', @{${$wheels{$_}}[0]} for sort keys %wheels;
|
||||
print get_next('A', %wheels) . ' ' for 1..20; print "\n\n";
|
||||
}
|
||||
|
||||
spin_wheels(%$_) for
|
||||
(
|
||||
{'A' => [['1', '2', '3'], 0]},
|
||||
{'A' => [['1', 'B', '2'], 0], 'B' => [['3', '4'], 0]},
|
||||
{'A' => [['1', 'D', 'D'], 0], 'D' => [['6', '7', '8'], 0]},
|
||||
{'A' => [['1', 'B', 'C'], 0], 'B' => [['3', '4'], 0], 'C' => [['5', 'B'], 0]},
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue