aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-06-03 13:03:59 +0100
committerGitHub <noreply@github.com>2025-06-03 13:03:59 +0100
commit5f179669067fcaa68f6da278d71e40a82ec47f3b (patch)
tree79e604f3054914276c4a179e2e8f5af97e2f284a
parente959cfd9e91d0d3cd960a8e5e0d28143f5b65aa8 (diff)
parent7f6dad803c03aee03010892819032307f726128e (diff)
downloadperlweeklychallenge-club-5f179669067fcaa68f6da278d71e40a82ec47f3b.tar.gz
perlweeklychallenge-club-5f179669067fcaa68f6da278d71e40a82ec47f3b.tar.bz2
perlweeklychallenge-club-5f179669067fcaa68f6da278d71e40a82ec47f3b.zip
Merge pull request #12115 from jaldhar/challenge-323
Challenge 323 by Jaldhar H. Vyas.
-rw-r--r--challenge-323/jaldhar-h-vyas/blog.txt1
-rwxr-xr-xchallenge-323/jaldhar-h-vyas/perl/ch-1.pl16
-rwxr-xr-xchallenge-323/jaldhar-h-vyas/perl/ch-2.pl19
-rwxr-xr-xchallenge-323/jaldhar-h-vyas/raku/ch-1.raku18
-rwxr-xr-xchallenge-323/jaldhar-h-vyas/raku/ch-2.raku22
5 files changed, 76 insertions, 0 deletions
diff --git a/challenge-323/jaldhar-h-vyas/blog.txt b/challenge-323/jaldhar-h-vyas/blog.txt
new file mode 100644
index 0000000000..cd2d1a13b5
--- /dev/null
+++ b/challenge-323/jaldhar-h-vyas/blog.txt
@@ -0,0 +1 @@
+https://www.braincells.com/perl/2025/06/perl_weekly_challenge_week_323.html
diff --git a/challenge-323/jaldhar-h-vyas/perl/ch-1.pl b/challenge-323/jaldhar-h-vyas/perl/ch-1.pl
new file mode 100755
index 0000000000..e0fd4b82eb
--- /dev/null
+++ b/challenge-323/jaldhar-h-vyas/perl/ch-1.pl
@@ -0,0 +1,16 @@
+#!/usr/bin/perl
+use v5.38;
+
+my @operations = @ARGV;
+my $total = 0;
+
+for my $operation (@operations) {
+ if ($operation =~ /\+\+/) {
+ $total++;
+ }
+ if ($operation =~ /\-\-/) {
+ $total--;
+ }
+}
+
+say $total;
diff --git a/challenge-323/jaldhar-h-vyas/perl/ch-2.pl b/challenge-323/jaldhar-h-vyas/perl/ch-2.pl
new file mode 100755
index 0000000000..b304c2a002
--- /dev/null
+++ b/challenge-323/jaldhar-h-vyas/perl/ch-2.pl
@@ -0,0 +1,19 @@
+#!/usr/bin/perl
+use v5.38;
+
+my ($income, @tax) = @ARGV;
+my $taxed = 0;
+my %taxes = map { my ($k, $v) = split /\s+/, $_; $k => $v } @tax;
+my $total = 0;
+
+for my $bracket ( sort { $a <=> $b } keys %taxes ) {
+ if ($taxed >= $income) {
+ last;
+ }
+
+ my $tax = ($bracket > $income ? $income : $bracket) - $taxed;
+ $taxed += $tax;
+ $total += $tax * ($taxes{$bracket} / 100);
+}
+
+say $total;
diff --git a/challenge-323/jaldhar-h-vyas/raku/ch-1.raku b/challenge-323/jaldhar-h-vyas/raku/ch-1.raku
new file mode 100755
index 0000000000..1009734930
--- /dev/null
+++ b/challenge-323/jaldhar-h-vyas/raku/ch-1.raku
@@ -0,0 +1,18 @@
+#!/usr/bin/raku
+
+sub MAIN(
+ *@operations
+) {
+ my $total = 0;
+
+ for @operations -> $operation {
+ if $operation ~~ /\+\+/ {
+ $total++;
+ }
+ if $operation ~~ /\-\-/ {
+ $total--;
+ }
+ }
+
+ say $total;
+} \ No newline at end of file
diff --git a/challenge-323/jaldhar-h-vyas/raku/ch-2.raku b/challenge-323/jaldhar-h-vyas/raku/ch-2.raku
new file mode 100755
index 0000000000..2effb7f3c3
--- /dev/null
+++ b/challenge-323/jaldhar-h-vyas/raku/ch-2.raku
@@ -0,0 +1,22 @@
+#!/usr/bin/raku
+
+sub MAIN(
+ Int $income,
+ *@tax
+) {
+ my $taxed = 0;
+ my %taxes = @tax.map({ [=>] $_.words });
+ my $total = 0;
+
+ for %taxes.keys.sort({$^a <=> $^b }) -> $bracket {
+ if $taxed >= $income {
+ last;
+ }
+
+ my $tax = ($bracket > $income ?? $income !! $bracket) - $taxed;
+ $taxed += $tax;
+ $total += $tax * (%taxes{$bracket} / 100);
+ }
+
+ say $total;
+} \ No newline at end of file