diff options
| author | drbaggy <js5@sanger.ac.uk> | 2021-03-08 22:58:37 +0000 |
|---|---|---|
| committer | drbaggy <js5@sanger.ac.uk> | 2021-03-08 22:58:37 +0000 |
| commit | 97f2d6ee35c4fea1e282f42eb1979c7701317289 (patch) | |
| tree | ddd648ed6b803433b07b6dc98ef2ba0bd91709d7 /challenge-103/james-smith | |
| parent | 2fb98d85f3b55202fa7fc177258001a576d973d2 (diff) | |
| download | perlweeklychallenge-club-97f2d6ee35c4fea1e282f42eb1979c7701317289.tar.gz perlweeklychallenge-club-97f2d6ee35c4fea1e282f42eb1979c7701317289.tar.bz2 perlweeklychallenge-club-97f2d6ee35c4fea1e282f42eb1979c7701317289.zip | |
tidied up
Diffstat (limited to 'challenge-103/james-smith')
| -rw-r--r-- | challenge-103/james-smith/perl/ch-1.pl | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/challenge-103/james-smith/perl/ch-1.pl b/challenge-103/james-smith/perl/ch-1.pl index cf59635f31..d5c564f14c 100644 --- a/challenge-103/james-smith/perl/ch-1.pl +++ b/challenge-103/james-smith/perl/ch-1.pl @@ -6,15 +6,23 @@ use warnings; use feature qw(say); use Test::More; +## Slight extension - include the Yin/Yang prefix... + is( year_name( 2017 ), 'Yin Fire Rooster' ); is( year_name( 1938 ), 'Yang Earth Tiger' ); done_testing(); +## Choose the order based on what would happen in years "0"..."60" - "Yang Metal Monkey" +## is the base year there then... + +## To save doing the int/2 we just + sub year_name { return join q( ), - qw(Yang Yin)[$_[0]%2], - qw(Metal Metal Water Water Wood Wood Fire Fire Earth Earth)[$_[0]%10], - qw(Monkey Rooster Dog Pig Rat Ox Tiger Rabbit Dragon Snake Horse Goat)[$_[0]%12], + qw(Yang Yin )[ $_[0] %2 ], + qw(Metal Water Wood Fire Earth )[ ($_[0]/2) %5 ], + qw(Monkey Rooster Dog Pig Rat Ox + Tiger Rabbit Dragon Snake Horse Goat)[ $_[0] %12 ], } |
