diff options
| author | Solathian <horvath6@gmail.com> | 2025-08-02 16:53:53 +0200 |
|---|---|---|
| committer | Solathian <horvath6@gmail.com> | 2025-08-02 16:53:53 +0200 |
| commit | 97f75e5e3dadf9b30b77c4aad2aa250ce8b4c68e (patch) | |
| tree | 594ab29562986cd3bb677821b864d1536ff5d928 | |
| parent | 4014f0eb1fa46f39fee72c2add76ca47f2dd1637 (diff) | |
| download | perlweeklychallenge-club-97f75e5e3dadf9b30b77c4aad2aa250ce8b4c68e.tar.gz perlweeklychallenge-club-97f75e5e3dadf9b30b77c4aad2aa250ce8b4c68e.tar.bz2 perlweeklychallenge-club-97f75e5e3dadf9b30b77c4aad2aa250ce8b4c68e.zip | |
Added solution for challenge 332
| -rw-r--r-- | challenge-332/solathian/perl/ch-1.pl | 11 | ||||
| -rw-r--r-- | challenge-332/solathian/perl/ch-2.pl | 20 |
2 files changed, 31 insertions, 0 deletions
diff --git a/challenge-332/solathian/perl/ch-1.pl b/challenge-332/solathian/perl/ch-1.pl new file mode 100644 index 0000000000..6fa2f460ba --- /dev/null +++ b/challenge-332/solathian/perl/ch-1.pl @@ -0,0 +1,11 @@ +use v5.40; +use List::Util qw(all); + +binaryDate("2025-07-26"); # "11111101001-111-11010" +binaryDate("2000-02-02"); # "11111010000-10-10" +binaryDate("2024-12-31"); # "11111101000-1100-11111" + +sub binaryDate($string) # it is assumed that the string is already of the correct format and is a valid date +{ + say join('-', map{sprintf("%b", $_)} split('-', $string)); +}
\ No newline at end of file diff --git a/challenge-332/solathian/perl/ch-2.pl b/challenge-332/solathian/perl/ch-2.pl new file mode 100644 index 0000000000..b888320e4c --- /dev/null +++ b/challenge-332/solathian/perl/ch-2.pl @@ -0,0 +1,20 @@ +use v5.40; +use List::Util qw(all); + +isOdd("weekly"); # false +isOdd("challenge"); # false +isOdd("perl"); # true +isOdd("perl112"); # true +isOdd(""); # true + + + +sub isOdd($string) +{ + my %hash; + + $string =~ s/[^a-z]//gi; # remove everything which is not between 'a' and 'z', since it only mentioned letters + $hash{$_}++ foreach (split('', $string)); + ((all{$_ % 2 != 0} values %hash) and (scalar values %hash > 0)) ? say 'true' : say 'false'; +} + |
