aboutsummaryrefslogtreecommitdiff
path: root/challenge-319
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-04-29 15:31:33 +0100
committerGitHub <noreply@github.com>2025-04-29 15:31:33 +0100
commit4c3aeaf8be235336cdc95447d767d91ec7e481d4 (patch)
tree2456941fe151c7062a433e36beca0cbcf8bc63b8 /challenge-319
parentd36691312ced193ec1e32a725a560ec360033398 (diff)
parent01499a091851526833f8bd503cbefc06939459c8 (diff)
downloadperlweeklychallenge-club-4c3aeaf8be235336cdc95447d767d91ec7e481d4.tar.gz
perlweeklychallenge-club-4c3aeaf8be235336cdc95447d767d91ec7e481d4.tar.bz2
perlweeklychallenge-club-4c3aeaf8be235336cdc95447d767d91ec7e481d4.zip
Merge pull request #11943 from vinodk89/challenge-319
Challenge-319 Solutions (Perl and Python)
Diffstat (limited to 'challenge-319')
-rw-r--r--challenge-319/vinod-k/perl/ch-1.pl16
-rw-r--r--challenge-319/vinod-k/perl/ch-2.pl30
-rw-r--r--challenge-319/vinod-k/python/ch-1.py9
-rw-r--r--challenge-319/vinod-k/python/ch-2.py15
4 files changed, 70 insertions, 0 deletions
diff --git a/challenge-319/vinod-k/perl/ch-1.pl b/challenge-319/vinod-k/perl/ch-1.pl
new file mode 100644
index 0000000000..2214d62894
--- /dev/null
+++ b/challenge-319/vinod-k/perl/ch-1.pl
@@ -0,0 +1,16 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+my @list = ("unicode", "xml", "raku", "perl");
+my $count = 0;
+
+foreach my $elements (@list){
+ $elements = lc($elements);
+ if ($elements =~ /^[aeiou]/i || $elements =~ /[aeiou]$/i){
+ $count++;
+ }
+}
+
+print $count;
diff --git a/challenge-319/vinod-k/perl/ch-2.pl b/challenge-319/vinod-k/perl/ch-2.pl
new file mode 100644
index 0000000000..b7f26aba3c
--- /dev/null
+++ b/challenge-319/vinod-k/perl/ch-2.pl
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+my @array_1 = (1, 2, 3, 4);
+my @array_2 = (1, 5, 7, 8);
+my @res = ();
+
+foreach my $e1 (@array_1){
+ foreach my $e2 (@array_2){
+ if ($e1 == $e2){
+ push (@res, $e1);
+ }
+ }
+}
+
+my $min;
+if (scalar @res == 0) {
+ $min = -1;
+} else {
+ $min = $res[0];
+}
+
+foreach my $element (@res){
+ if ($element < $min){
+ $min = $element;
+ }
+}
+print "Min: $min\n";
diff --git a/challenge-319/vinod-k/python/ch-1.py b/challenge-319/vinod-k/python/ch-1.py
new file mode 100644
index 0000000000..38ea54f505
--- /dev/null
+++ b/challenge-319/vinod-k/python/ch-1.py
@@ -0,0 +1,9 @@
+array_list = ["unicode", "xml", "raku", "perl"]
+vowels = ["a", "e", "i", "o", "u"]
+count = 0
+
+for element in array_list:
+ if element.startswith(tuple(vowels)) | element.endswith(tuple(vowels)):
+ count = count + 1
+
+print(count)
diff --git a/challenge-319/vinod-k/python/ch-2.py b/challenge-319/vinod-k/python/ch-2.py
new file mode 100644
index 0000000000..0591e2bf62
--- /dev/null
+++ b/challenge-319/vinod-k/python/ch-2.py
@@ -0,0 +1,15 @@
+array_1 = [1, 2, 3, 4]
+array_2 = [3, 4, 5, 6]
+result = []
+
+for e1 in array_1:
+ for e2 in array_2:
+ if e1 == e2:
+ result.append(e1)
+
+if len(result) > 0:
+ min_val = result[0]
+else:
+ min_val = -1
+
+print(min(result))